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");
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  // Subsystems could safely override this, but any changes to MEs would not be
59  // noticeable since the product was made already.
60  void globalEndRun(edm::Run const&, edm::EventSetup const&) const final{};
61 
62  // methods to be implemented by the user, in order of invocation
63  virtual void dqmBeginRun(edm::Run const&, edm::EventSetup const&, H&) const {}
64  virtual void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, H&) const = 0;
65  // TODO: rename this analyze() for consistency.
66  virtual void dqmAnalyze(edm::Event const&, edm::EventSetup const&, H const&) const = 0;
67 
68 protected:
71  uint64_t meId(edm::Run const& run) const { return (((uint64_t)run.run()) << 32) + this->moduleDescription().id(); }
72 };
73 
74 // Case without RunSummaryCache
75 template <typename H, typename... Args>
76 class DQMGlobalEDAnalyzer : public DQMGlobalEDAnalyzerBase<H, Args...> {
77 public:
78  void globalEndRunProduce(edm::Run& run, edm::EventSetup const& setup) const final {
79  auto const& h = *this->runCache(run.index());
80  dqmEndRun(run, setup, h);
81  this->dqmstore_->leaveLumi(run.run(), /* lumi */ 0, this->meId(run));
82  run.emplace(this->runToken_);
83  }
84 
85  virtual void dqmEndRun(edm::Run const&, edm::EventSetup const&, H const&) const {}
86 };
87 
88 // Case with RunSummaryCache, must be the second template argument
89 template <typename H, // type for RunCache
90  typename RSC, // type for RunSummaryCache
91  typename... Args>
92 class DQMGlobalRunSummaryEDAnalyzer : public DQMGlobalEDAnalyzerBase<H, edm::RunSummaryCache<RSC>, Args...> {
93 public:
94  void globalEndRunProduce(edm::Run& run, edm::EventSetup const& setup, RSC const* runSummaryCache) const final {
95  auto const& h = *this->runCache(run.index());
96  dqmEndRun(run, setup, h, *runSummaryCache);
97  this->dqmstore_->leaveLumi(run.run(), /* lumi */ 0, this->meId(run));
98  run.emplace(this->runToken_);
99  }
100 
101  virtual void dqmEndRun(edm::Run const&, edm::EventSetup const&, H const&, RSC const&) const {}
102 };
103 
104 #endif // DQMServices_Core_DQMGlobalEDAnalyzer_h
void globalEndRun(edm::Run const &, edm::EventSetup const &) const final
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, H &) const =0
void bookTransaction(iFunc f, uint64_t moduleId, bool canSaveByLumi)
Definition: DQMStore.h:655
void globalEndRunProduce(edm::Run &run, edm::EventSetup const &setup, RSC const *runSummaryCache) const final
void globalEndRunProduce(edm::Run &run, edm::EventSetup const &setup) const final
void leaveLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, uint64_t moduleID)
Definition: DQMStore.cc:524
unsigned int id() const
void initLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi)
Definition: DQMStore.cc:392
void enterLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, uint64_t moduleID)
Definition: DQMStore.cc:480
ModuleDescription const & moduleDescription() const
virtual void dqmAnalyze(edm::Event const &, edm::EventSetup const &, H const &) const =0
virtual void dqmEndRun(edm::Run const &, edm::EventSetup const &, H const &, RSC const &) const
void accumulate(edm::StreamID id, edm::Event const &event, edm::EventSetup const &setup) const final
unsigned long long uint64_t
Definition: Time.h:13
edm::EDPutTokenT< DQMToken > runToken_
double b
Definition: hdecay.h:118
dqm::reco::MonitorElement MonitorElement
dqm::reco::DQMStore DQMStore
virtual void dqmBeginRun(edm::Run const &, edm::EventSetup const &, H &) const
uint64_t meId(edm::Run const &run) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
virtual void dqmEndRun(edm::Run const &, edm::EventSetup const &, H const &) const
Definition: event.py:1
Definition: Run.h:45
std::shared_ptr< H > globalBeginRun(edm::Run const &run, edm::EventSetup const &setup) const final