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
void endRunProduce(edm::Run &run, edm::EventSetup const &setup) final
void accumulate(edm::Event const &event, edm::EventSetup const &setup) override
virtual void dqmBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
dqm::reco::DQMStore DQMStore
edm::EDPutTokenT< DQMToken > lumiToken_
void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
ModuleDescription const & moduleDescription() const
dqm::reco::MonitorElement MonitorElement
virtual bool getCanSaveByLumi()
unsigned int id() const
virtual void dqmEndRun(edm::Run const &, edm::EventSetup const &)
bool getCanSaveByLumi() override
void beginRun(edm::Run const &run, edm::EventSetup const &setup) final
void endRun(edm::Run const &, edm::EventSetup const &) final
virtual void dqmEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) final
virtual void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &)=0
edm::EDPutTokenT< DQMToken > runToken_
void endLuminosityBlockProduce(edm::LuminosityBlock &lumi, edm::EventSetup const &setup) final
virtual void dqmBeginRun(edm::Run const &, edm::EventSetup const &)
void accumulate(edm::Event const &event, edm::EventSetup const &setup) override
virtual void analyze(edm::Event const &, edm::EventSetup const &)
Definition: event.py:1
Definition: Run.h:45