CMS 3D CMS Logo

DQMOneEDAnalyzer.h
Go to the documentation of this file.
1 #ifndef DQMServices_Core_DQMOneEDAnalyzer_h
2 #define DQMServices_Core_DQMOneEDAnalyzer_h
3 
11 
19 template <typename... Args>
21  : public edm::one::EDProducer<edm::EndRunProducer, edm::one::WatchRuns, edm::Accumulator, Args...> {
22 public:
25 
26  virtual bool getCanSaveByLumi() { return true; }
27 
28  // framework calls in the order of invocation
30  // for whatever reason we need the explicit `template` keyword here.
31  runToken_ = this->template produces<DQMToken, edm::Transition::EndRun>("DQMGenerationRecoRun");
32  }
33 
34  void beginRun(edm::Run const& run, edm::EventSetup const& setup) final {
35  // if we run booking multiple times because there are multiple runs in a
36  // job, this is needed to make sure all existing MEs are in a valid state
37  // before the booking code runs.
38  edm::Service<DQMStore>()->initLumi(run.run(), /* lumi */ 0, this->moduleDescription().id());
39  edm::Service<DQMStore>()->enterLumi(run.run(), /* lumi */ 0, this->moduleDescription().id());
41  edm::Service<DQMStore>()->bookTransaction(
42  [this, &run, &setup](DQMStore::IBooker& booker) {
43  booker.cd();
44  this->bookHistograms(booker, run, setup);
45  },
46  this->moduleDescription().id(),
47  this->getCanSaveByLumi());
48  edm::Service<DQMStore>()->initLumi(run.run(), /* lumi */ 0, this->moduleDescription().id());
49  edm::Service<DQMStore>()->enterLumi(run.run(), /* lumi */ 0, this->moduleDescription().id());
50  }
51 
52  void accumulate(edm::Event const& event, edm::EventSetup const& setup) override {
53  auto& lumi = event.getLuminosityBlock();
55  lumi.run(), lumi.luminosityBlock(), this->moduleDescription().id());
56  analyze(event, setup);
58  lumi.run(), lumi.luminosityBlock(), this->moduleDescription().id());
59  }
60 
63  edm::Service<DQMStore>()->leaveLumi(run.run(), /* lumi */ 0, this->moduleDescription().id());
64  run.emplace<DQMToken>(runToken_);
65  }
66 
67  // Subsystems could safely override this, but any changes to MEs would not be
68  // noticeable since the product was made already.
69  void endRun(edm::Run const&, edm::EventSetup const&) final{};
70 
71 protected:
72  // methods to be implemented by the user, in order of invocation
73  virtual void dqmBeginRun(edm::Run const&, edm::EventSetup const&) {}
74  virtual void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) = 0;
75  virtual void analyze(edm::Event const&, edm::EventSetup const&) {}
76  virtual void dqmEndRun(edm::Run const&, edm::EventSetup const&) {}
77 
79 };
80 
89 template <typename... Args>
91  : public DQMOneEDAnalyzer<edm::EndLuminosityBlockProducer, edm::one::WatchLuminosityBlocks, Args...> {
92 public:
93  bool getCanSaveByLumi() override { return true; }
94 
95  // framework calls in the order of invocation
97  // for whatever reason we need the explicit `template` keyword here.
98  lumiToken_ = this->template produces<DQMToken, edm::Transition::EndLuminosityBlock>("DQMGenerationRecoLumi");
99  }
100 
103  lumi.run(), lumi.luminosityBlock(), this->moduleDescription().id());
105  }
106 
107  void accumulate(edm::Event const& event, edm::EventSetup const& setup) override { this->analyze(event, setup); }
108 
111  // fully qualified name required for... reasons.
113  lumi.run(), lumi.luminosityBlock(), this->moduleDescription().id());
114  lumi.emplace(lumiToken_);
115  }
116 
117  // Subsystems could safely override this, but any changes to MEs would not be
118  // noticeable since the product was made already.
120 
121 protected:
122  // methods to be implemented by the user, in order of invocation
125 
127 };
128 
129 #endif // DQMServices_Core_DQMOneEDAnalyzer_h
dqm::impl::MonitorElement
Definition: MonitorElement.h:99
DQMOneLumiEDAnalyzer::endLuminosityBlockProduce
void endLuminosityBlockProduce(edm::LuminosityBlock &lumi, edm::EventSetup const &setup) final
Definition: DQMOneEDAnalyzer.h:109
EDProducer.h
DQMOneLumiEDAnalyzer::dqmEndLuminosityBlock
virtual void dqmEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQMOneEDAnalyzer.h:124
edm::LuminosityBlock
Definition: LuminosityBlock.h:50
edm::Run
Definition: Run.h:45
edm::EDPutTokenT< DQMToken >
DQMOneEDAnalyzer::MonitorElement
dqm::reco::MonitorElement MonitorElement
Definition: DQMOneEDAnalyzer.h:24
DQMOneLumiEDAnalyzer::endLuminosityBlock
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) final
Definition: DQMOneEDAnalyzer.h:119
DQMOneEDAnalyzer
Definition: DQMOneEDAnalyzer.h:20
DQMStore.h
edm::one::EDProducer
Definition: EDProducer.h:30
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
DQMOneLumiEDAnalyzer::DQMOneLumiEDAnalyzer
DQMOneLumiEDAnalyzer()
Definition: DQMOneEDAnalyzer.h:96
DQMOneEDAnalyzer::bookHistograms
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)=0
dqm::legacy::DQMStore
Definition: DQMStore.h:728
DQMOneEDAnalyzer::endRunProduce
void endRunProduce(edm::Run &run, edm::EventSetup const &setup) final
Definition: DQMOneEDAnalyzer.h:61
DQMToken.h
Service.h
DQMToken
Definition: DQMToken.h:21
DQMOneLumiEDAnalyzer::dqmBeginLuminosityBlock
virtual void dqmBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: DQMOneEDAnalyzer.h:123
Run.h
dqm::implementation::NavigatorBase::cd
virtual void cd()
Definition: DQMStore.cc:29
DQMOneLumiEDAnalyzer::lumiToken_
edm::EDPutTokenT< DQMToken > lumiToken_
Definition: DQMOneEDAnalyzer.h:126
edm::one::EDProducerBase::moduleDescription
ModuleDescription const & moduleDescription() const
Definition: EDProducerBase.h:63
Event.h
DQMOneLumiEDAnalyzer
Definition: DQMOneEDAnalyzer.h:90
DQMOneEDAnalyzer::beginRun
void beginRun(edm::Run const &run, edm::EventSetup const &setup) final
Definition: DQMOneEDAnalyzer.h:34
edm::Service
Definition: Service.h:30
DQMOneLumiEDAnalyzer::getCanSaveByLumi
bool getCanSaveByLumi() override
Definition: DQMOneEDAnalyzer.h:93
edm::EventSetup
Definition: EventSetup.h:58
DQMOneEDAnalyzer::accumulate
void accumulate(edm::Event const &event, edm::EventSetup const &setup) override
Definition: DQMOneEDAnalyzer.h:52
DQMOneEDAnalyzer::DQMStore
dqm::reco::DQMStore DQMStore
Definition: DQMOneEDAnalyzer.h:23
DQMOneEDAnalyzer::getCanSaveByLumi
virtual bool getCanSaveByLumi()
Definition: DQMOneEDAnalyzer.h:26
DQMOneEDAnalyzer::DQMOneEDAnalyzer
DQMOneEDAnalyzer()
Definition: DQMOneEDAnalyzer.h:29
writedatasetfile.run
run
Definition: writedatasetfile.py:27
DQMOneLumiEDAnalyzer::accumulate
void accumulate(edm::Event const &event, edm::EventSetup const &setup) override
Definition: DQMOneEDAnalyzer.h:107
DQMOneEDAnalyzer::analyze
virtual void analyze(edm::Event const &, edm::EventSetup const &)
Definition: DQMOneEDAnalyzer.h:75
DQMOneLumiEDAnalyzer::beginLuminosityBlock
void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
Definition: DQMOneEDAnalyzer.h:101
dqm::implementation::IBooker
Definition: DQMStore.h:43
DQMOneEDAnalyzer::endRun
void endRun(edm::Run const &, edm::EventSetup const &) final
Definition: DQMOneEDAnalyzer.h:69
ParameterSet.h
DQMOneEDAnalyzer::dqmEndRun
virtual void dqmEndRun(edm::Run const &, edm::EventSetup const &)
Definition: DQMOneEDAnalyzer.h:76
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
lumi
Definition: LumiSectionData.h:20
DQMOneEDAnalyzer::runToken_
edm::EDPutTokenT< DQMToken > runToken_
Definition: DQMOneEDAnalyzer.h:78
DQMOneEDAnalyzer::dqmBeginRun
virtual void dqmBeginRun(edm::Run const &, edm::EventSetup const &)
Definition: DQMOneEDAnalyzer.h:73
edm::ModuleDescription::id
unsigned int id() const
Definition: ModuleDescription.h:46