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  // 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
edm::StreamID
Definition: StreamID.h:30
dqm::impl::MonitorElement
Definition: MonitorElement.h:98
DQMGlobalEDAnalyzerBase::bookHistograms
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, H &) const =0
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 >
DQMGlobalEDAnalyzerBase::globalBeginRun
std::shared_ptr< H > globalBeginRun(edm::Run const &run, edm::EventSetup const &setup) const final
Definition: DQMGlobalEDAnalyzer.h:31
edm::global::EDProducerBase::moduleDescription
ModuleDescription const & moduleDescription() const
Definition: EDProducerBase.h:68
DQMStore.h
DQMGlobalEDAnalyzerBase::DQMGlobalEDAnalyzerBase
DQMGlobalEDAnalyzerBase()
Definition: DQMGlobalEDAnalyzer.h:25
h
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
DQMGlobalEDAnalyzerBase::dqmBeginRun
virtual void dqmBeginRun(edm::Run const &, edm::EventSetup const &, H &) const
Definition: DQMGlobalEDAnalyzer.h:63
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
dqm::legacy::DQMStore
Definition: DQMStore.h:728
DQMToken.h
DQMGlobalEDAnalyzer::dqmEndRun
virtual void dqmEndRun(edm::Run const &, edm::EventSetup const &, H const &) const
Definition: DQMGlobalEDAnalyzer.h:85
Service.h
DQMGlobalRunSummaryEDAnalyzer::globalEndRunProduce
void globalEndRunProduce(edm::Run &run, edm::EventSetup const &setup, RSC const *runSummaryCache) const final
Definition: DQMGlobalEDAnalyzer.h:94
Run.h
h
b
double b
Definition: hdecay.h:118
DQMGlobalEDAnalyzerBase::dqmstore_
DQMStore * dqmstore_
Definition: DQMGlobalEDAnalyzer.h:69
edm::global::EDProducer
Definition: EDProducer.h:32
Event.h
DQMGlobalEDAnalyzerBase::MonitorElement
dqm::reco::MonitorElement MonitorElement
Definition: DQMGlobalEDAnalyzer.h:22
DQMGlobalEDAnalyzerBase::accumulate
void accumulate(edm::StreamID id, edm::Event const &event, edm::EventSetup const &setup) const final
Definition: DQMGlobalEDAnalyzer.h:53
edm::Service
Definition: Service.h:30
DQMGlobalEDAnalyzerBase::meId
uint64_t meId(edm::Run const &run) const
Definition: DQMGlobalEDAnalyzer.h:71
edm::EventSetup
Definition: EventSetup.h:58
DQMGlobalEDAnalyzerBase::runToken_
edm::EDPutTokenT< DQMToken > runToken_
Definition: DQMGlobalEDAnalyzer.h:70
DQMGlobalRunSummaryEDAnalyzer::dqmEndRun
virtual void dqmEndRun(edm::Run const &, edm::EventSetup const &, H const &, RSC const &) const
Definition: DQMGlobalEDAnalyzer.h:101
DQMGlobalEDAnalyzerBase::dqmAnalyze
virtual void dqmAnalyze(edm::Event const &, edm::EventSetup const &, H const &) const =0
writedatasetfile.run
run
Definition: writedatasetfile.py:27
dqm::implementation::DQMStore::bookTransaction
void bookTransaction(iFunc f, uint64_t moduleId, bool canSaveByLumi)
Definition: DQMStore.h:578
data-class-funcs.H
H
Definition: data-class-funcs.py:33
dqm::implementation::IBooker
Definition: DQMStore.h:43
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
DQMGlobalEDAnalyzer
Definition: DQMGlobalEDAnalyzer.h:76
dqm::implementation::DQMStore::enterLumi
void enterLumi(edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, uint64_t moduleID)
Definition: DQMStore.cc:448
DQMGlobalEDAnalyzerBase::globalEndRun
void globalEndRun(edm::Run const &, edm::EventSetup const &) const final
Definition: DQMGlobalEDAnalyzer.h:60
ParameterSet.h
DQMGlobalEDAnalyzerBase
Definition: DQMGlobalEDAnalyzer.h:13
EDProducer.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
DQMGlobalRunSummaryEDAnalyzer
Definition: DQMGlobalEDAnalyzer.h:92
DQMGlobalEDAnalyzer::globalEndRunProduce
void globalEndRunProduce(edm::Run &run, edm::EventSetup const &setup) const final
Definition: DQMGlobalEDAnalyzer.h:78
edm::ModuleDescription::id
unsigned int id() const
Definition: ModuleDescription.h:46
DQMGlobalEDAnalyzerBase::DQMStore
dqm::reco::DQMStore DQMStore
Definition: DQMGlobalEDAnalyzer.h:21