CMS 3D CMS Logo

DQMGlobalEDAnalyzer.h
Go to the documentation of this file.
1 #ifndef DQMServices_Core_DQMGlobalEDAnalyzer_h
2 #define DQMServices_Core_DQMGlobalEDAnalyzer_h
3 
11 
12 template <typename H, typename... Args>
14  : public edm::global::EDProducer<edm::RunCache<H>,
15  // DQMGlobalEDAnalyzer are fundamentally unable to produce histograms for any
16  // other scope than MonitorElement::Scope::RUN.
17  edm::EndRunProducer,
18  edm::Accumulator,
19  Args...> {
20 public:
23 
24  // framework calls in the order of invocation
26  // for whatever reason we need the explicit `template` keyword here.
27  runToken_ = this->template produces<DQMToken, edm::Transition::EndRun>("DQMGenerationRecoRun");
28  dqmstore_ = edm::Service<DQMStore>().operator->();
29  }
30 
31  std::shared_ptr<H> globalBeginRun(edm::Run const& run, edm::EventSetup const& setup) const final {
32  auto h = std::make_shared<H>();
33 
34  dqmBeginRun(run, setup, *h);
35 
36  // in case of concurrent runs, this will create clones of the already
37  // booked MEs.
39  [&, this](DQMStore::IBooker& b) {
40  // this runs while holding the DQMStore lock
41  b.cd();
42  bookHistograms(b, run, setup, *h);
43  },
44  // The run number is part of the module ID here, since we want distinct
45  // local MEs for each run cache.
46  meId(run),
47  /* canSaveByLumi */ false);
48  dqmstore_->initLumi(run.run(), /* lumi */ 0, meId(run));
49  dqmstore_->enterLumi(run.run(), /* lumi */ 0, meId(run));
50  return h;
51  }
52 
53  void accumulate(edm::StreamID id, edm::Event const& event, edm::EventSetup const& setup) const final {
54  auto const& h = *this->runCache(event.getRun().index());
56  }
57 
58  void globalEndRunProduce(edm::Run& run, edm::EventSetup const& setup) const final {
59  auto const& h = *this->runCache(run.index());
60  dqmEndRun(run, setup, h);
61  dqmstore_->leaveLumi(run.run(), /* lumi */ 0, meId(run));
62  run.emplace(runToken_);
63  }
64 
65  // Subsystems could safely override this, but any changes to MEs would not be
66  // noticeable since the product was made already.
67  void globalEndRun(edm::Run const&, edm::EventSetup const&) const final{};
68 
69  // methods to be implemented by the user, in order of invocation
70  virtual void dqmBeginRun(edm::Run const&, edm::EventSetup const&, H&) const {}
71  virtual void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, H&) const = 0;
72  // TODO: rename this analyze() for consistency.
73  virtual void dqmAnalyze(edm::Event const&, edm::EventSetup const&, H const&) const = 0;
74  virtual void dqmEndRun(edm::Run const&, edm::EventSetup const&, H const&) const {}
75 
76 private:
79  uint64_t meId(edm::Run const& run) const { return (((uint64_t)run.run()) << 32) + this->moduleDescription().id(); }
80 };
81 
82 #endif // DQMServices_Core_DQMGlobalEDAnalyzer_h
class-composition.H
H
Definition: class-composition.py:31
edm::StreamID
Definition: StreamID.h:30
dqm::impl::MonitorElement
Definition: MonitorElement.h:98
DQMGlobalEDAnalyzer::MonitorElement
dqm::reco::MonitorElement MonitorElement
Definition: DQMGlobalEDAnalyzer.h:22
dqm::implementation::DQMStore::leaveLumi
void leaveLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, uint64_t moduleID)
Definition: DQMStore.cc:492
dqm::implementation::DQMStore::initLumi
void initLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi)
Definition: DQMStore.cc:360
edm::Run
Definition: Run.h:45
edm::EDPutTokenT< DQMToken >
h
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Definition: L1TUtmAlgorithmRcd.h:4
DQMGlobalEDAnalyzer::dqmBeginRun
virtual void dqmBeginRun(edm::Run const &, edm::EventSetup const &, H &) const
Definition: DQMGlobalEDAnalyzer.h:70
edm::global::EDProducerBase::moduleDescription
ModuleDescription const & moduleDescription() const
Definition: EDProducerBase.h:69
DQMGlobalEDAnalyzer::globalBeginRun
std::shared_ptr< H > globalBeginRun(edm::Run const &run, edm::EventSetup const &setup) const final
Definition: DQMGlobalEDAnalyzer.h:31
DQMStore.h
DQMGlobalEDAnalyzer::DQMGlobalEDAnalyzer
DQMGlobalEDAnalyzer()
Definition: DQMGlobalEDAnalyzer.h:25
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
dqm::legacy::DQMStore::IBooker
dqm::implementation::IBooker IBooker
Definition: DQMStore.h:729
dqm::legacy::DQMStore
Definition: DQMStore.h:727
DQMToken.h
DQMGlobalEDAnalyzer::dqmEndRun
virtual void dqmEndRun(edm::Run const &, edm::EventSetup const &, H const &) const
Definition: DQMGlobalEDAnalyzer.h:74
Service.h
Run.h
h
b
double b
Definition: hdecay.h:118
edm::global::EDProducer
Definition: EDProducer.h:32
Event.h
DQMGlobalEDAnalyzer::dqmstore_
DQMStore * dqmstore_
Definition: DQMGlobalEDAnalyzer.h:77
DQMGlobalEDAnalyzer::globalEndRun
void globalEndRun(edm::Run const &, edm::EventSetup const &) const final
Definition: DQMGlobalEDAnalyzer.h:67
edm::Service
Definition: Service.h:30
edm::EventSetup
Definition: EventSetup.h:57
DQMGlobalEDAnalyzer::DQMStore
dqm::reco::DQMStore DQMStore
Definition: DQMGlobalEDAnalyzer.h:21
writedatasetfile.run
run
Definition: writedatasetfile.py:27
DQMGlobalEDAnalyzer::runToken_
edm::EDPutTokenT< DQMToken > runToken_
Definition: DQMGlobalEDAnalyzer.h:78
dqm::implementation::DQMStore::bookTransaction
void bookTransaction(iFunc f, uint64_t moduleId, bool canSaveByLumi)
Definition: DQMStore.h:578
dqm::implementation::IBooker
Definition: DQMStore.h:43
DQMGlobalEDAnalyzer::dqmAnalyze
virtual void dqmAnalyze(edm::Event const &, edm::EventSetup const &, H const &) const =0
DQMGlobalEDAnalyzer::bookHistograms
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, H &) const =0
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
DQMGlobalEDAnalyzer
Definition: DQMGlobalEDAnalyzer.h:13
dqm::implementation::DQMStore::enterLumi
void enterLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, uint64_t moduleID)
Definition: DQMStore.cc:448
ParameterSet.h
EDProducer.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
DQMGlobalEDAnalyzer::accumulate
void accumulate(edm::StreamID id, edm::Event const &event, edm::EventSetup const &setup) const final
Definition: DQMGlobalEDAnalyzer.h:53
DQMGlobalEDAnalyzer::meId
uint64_t meId(edm::Run const &run) const
Definition: DQMGlobalEDAnalyzer.h:79
DQMGlobalEDAnalyzer::globalEndRunProduce
void globalEndRunProduce(edm::Run &run, edm::EventSetup const &setup) const final
Definition: DQMGlobalEDAnalyzer.h:58
edm::ModuleDescription::id
unsigned int id() const
Definition: ModuleDescription.h:46