Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-14 11:44:53

0001 /*
0002  * \file BeamConditionsMonitor.cc
0003  * \author Geng-yuan Jeng/UC Riverside
0004  *         Francisco Yumiceva/FNAL
0005  *
0006  */
0007 
0008 #include "DQM/BeamMonitor/plugins/BeamConditionsMonitor.h"
0009 #include "FWCore/ServiceRegistry/interface/Service.h"
0010 #include "FWCore/Framework/interface/MakerMacros.h"
0011 #include "FWCore/Framework/interface/IOVSyncValue.h"
0012 #include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h"
0013 #include "FWCore/Framework/interface/ESHandle.h"
0014 #include "FWCore/Framework/interface/EventSetup.h"
0015 #include <numeric>
0016 #include <cmath>
0017 #include <TMath.h>
0018 #include <iostream>
0019 #include "TStyle.h"
0020 
0021 using namespace std;
0022 using namespace edm;
0023 
0024 //
0025 // constructors and destructor
0026 //
0027 BeamConditionsMonitor::BeamConditionsMonitor(const ParameterSet& ps) : countEvt_(0), countLumi_(0) {
0028   parameters_ = ps;
0029   monitorName_ = parameters_.getUntrackedParameter<string>("monitorName", "YourSubsystemName");
0030   bsSrc_ = parameters_.getUntrackedParameter<InputTag>("beamSpot");
0031   debug_ = parameters_.getUntrackedParameter<bool>("Debug");
0032   beamSpotToken_ = esConsumes();
0033   dbe_ = Service<DQMStore>().operator->();
0034 
0035   if (!monitorName_.empty())
0036     monitorName_ = monitorName_ + "/";
0037 }
0038 
0039 BeamConditionsMonitor::~BeamConditionsMonitor() {}
0040 
0041 //--------------------------------------------------------
0042 void BeamConditionsMonitor::beginJob() {
0043   // book some histograms here
0044   // create and cd into new folder
0045   dbe_->setCurrentFolder(monitorName_ + "Conditions");
0046 
0047   h_x0_lumi = dbe_->book1D("x0_lumi_cond", "x coordinate of beam spot vs lumi (Cond)", 10, 0, 10);
0048   h_x0_lumi->setAxisTitle("Lumisection", 1);
0049   h_x0_lumi->setAxisTitle("x_{0} (cm)", 2);
0050   h_x0_lumi->getTH1()->SetOption("E1");
0051 
0052   h_y0_lumi = dbe_->book1D("y0_lumi_cond", "y coordinate of beam spot vs lumi (Cond)", 10, 0, 10);
0053   h_y0_lumi->setAxisTitle("Lumisection", 1);
0054   h_y0_lumi->setAxisTitle("y_{0} (cm)", 2);
0055   h_y0_lumi->getTH1()->SetOption("E1");
0056 }
0057 
0058 //--------------------------------------------------------
0059 void BeamConditionsMonitor::beginRun(const edm::Run& r, const EventSetup& context) {}
0060 
0061 //--------------------------------------------------------
0062 void BeamConditionsMonitor::beginLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& context) {
0063   countLumi_++;
0064 }
0065 
0066 // ----------------------------------------------------------
0067 void BeamConditionsMonitor::analyze(const Event& iEvent, const EventSetup& iSetup) {
0068   countEvt_++;
0069   condBeamSpot = iSetup.getData(beamSpotToken_);
0070 }
0071 
0072 //--------------------------------------------------------
0073 void BeamConditionsMonitor::endLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& iSetup) {
0074   LogInfo("BeamConditions") << "[BeamConditionsMonitor]:" << condBeamSpot << endl;
0075   h_x0_lumi->ShiftFillLast(condBeamSpot.x(), condBeamSpot.xError(), 1);
0076   h_y0_lumi->ShiftFillLast(condBeamSpot.y(), condBeamSpot.yError(), 1);
0077 }
0078 //--------------------------------------------------------
0079 void BeamConditionsMonitor::endRun(const Run& r, const EventSetup& context) {}
0080 //--------------------------------------------------------
0081 void BeamConditionsMonitor::endJob() {}
0082 
0083 DEFINE_FWK_MODULE(BeamConditionsMonitor);