CMS 3D CMS Logo

oneDQMEDAnalyzer.h
Go to the documentation of this file.
1 #ifndef DQMServices_Core_oneDQMEDAnalyzer_h
2 #define DQMServices_Core_oneDQMEDAnalyzer_h
3 
12 
15 
16 /*
17 A one::DQMEDAnalyzer<*> should be used in the case where a module must file DQM histograms and must be an
18 edm::one module.
19 
20 Inheriting from one::DQMEDAnalyzer<> gives access to Run transitions.
21 
22 Inheriting from one::DQMEDAnalyzer<edm::one::WatchLuminosityBlocks> gives access to Run and LuminosityBlock transitions but can only be used with Run based MonitorElements.
23 
24 Inheriting from one::DQMEDAnalyzer<one::DQMLuminosityBlockElements> give access to Run and LuminosityBlock transitions and filling LuminosityBlock based MonitorElements.
25 */
26 
27 namespace one {
28 
30 
31 namespace dqmimplementation {
32 template <typename... T>
33 class DQMRunEDProducer : public edm::one::EDProducer<edm::Accumulator,
34  edm::EndRunProducer,
35  edm::one::WatchRuns, T...>
36 {
37 public:
39  runToken_{this-> template produces<DQMToken,edm::Transition::EndRun>("endRun")}
40  {}
41  ~DQMRunEDProducer() override = default;
44 
45  void beginRun(edm::Run const& run, edm::EventSetup const& setup) final {
46  dqmBeginRun(run, setup);
47  edm::Service<DQMStore>()->bookTransaction(
48  [this, &run, &setup](DQMStore::IBooker & booker)
49  {
50  booker.cd();
51  this->bookHistograms(booker, run, setup);
52  },
53  run.run(),
54  this->moduleDescription().id(),
55  this->getCanSaveByLumi());
56  }
57 
58  void endRun(edm::Run const& run, edm::EventSetup const& setup) override {}
59  void endRunProduce(edm::Run& run, edm::EventSetup const& setup) override {
60  edm::Service<DQMStore>()->cloneRunHistograms(
61  run.run(),
62  this->moduleDescription().id());
63 
64  run.emplace<DQMToken>(runToken_);
65  }
66 
67  virtual void dqmBeginRun(edm::Run const&, edm::EventSetup const&) {}
68  virtual void bookHistograms(DQMStore::IBooker &i, edm::Run const&, edm::EventSetup const&) = 0;
69 
70  virtual void analyze(edm::Event const&, edm::EventSetup const&) {}
71  void accumulate(edm::Event const& ev, edm::EventSetup const& es) final {
72  analyze(ev,es);
73  }
74 
75  virtual bool getCanSaveByLumi() { return false; }
76 private:
78 
79 };
80 
81 class DQMLumisEDProducer : public DQMRunEDProducer<edm::EndLuminosityBlockProducer,
82  edm::one::WatchLuminosityBlocks>
83 
84 {
85 public:
87  ~DQMLumisEDProducer() override = default;
88  DQMLumisEDProducer(DQMLumisEDProducer const&) = delete;
90 
91  void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const& setup) override;
92 
93  void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) override;
94 
95  void endLuminosityBlockProduce(edm::LuminosityBlock & lumi, edm::EventSetup const& setup) final;
96 
97 
98  virtual void dqmBeginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
99  //virtual void bookLumiHistograms(DQMStore::IBooker &i, edm::LuminosityBlock const&, edm::EventSetup const&) = 0;
100 
101  private:
103 };
104 
105 template <typename... T> class DQMBaseClass;
106 
107 template<> class DQMBaseClass<> : public DQMLumisEDProducer {
108  bool getCanSaveByLumi() override { return true; }
109 };
111 template<> class DQMBaseClass<edm::one::WatchLuminosityBlocks> : public DQMRunEDProducer<edm::one::WatchLuminosityBlocks> {};
112 template<typename T> class DQMBaseClass<edm::LuminosityBlockCache<T>> : public DQMRunEDProducer<edm::LuminosityBlockCache<T>>{};
113 }
114 
115 template <typename... T>
117 {
118 public:
119  DQMEDAnalyzer() = default;
120  ~DQMEDAnalyzer() override = default;
121  DQMEDAnalyzer(DQMEDAnalyzer<T...> const&) = delete;
122  DQMEDAnalyzer(DQMEDAnalyzer<T...> &&) = delete;
123 };
124 }
125 #endif // DQMServices_Core_DQMEDAnalyzer_h
RunNumber_t run() const
Definition: RunBase.h:40
void emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Run.h:245
edm::EDPutTokenT< DQMToken > runToken_
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
bool ev
void beginRun(edm::Run const &run, edm::EventSetup const &setup) final
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
virtual void analyze(edm::Event const &, edm::EventSetup const &)
void accumulate(edm::Event const &ev, edm::EventSetup const &es) final
example_stream void bookHistograms(DQMStore::IBooker &,@example_stream edm::Run const &,@example_stream edm::EventSetup const &) override
virtual void dqmBeginRun(edm::Run const &, edm::EventSetup const &)
one::DQMEDAnalyzer<> DQMEDAnalyzer
Definition: DQMEDAnalyzer.h:6
HLT enums.
edm::EDPutTokenT< DQMToken > lumiToken_
long double T
void endRunProduce(edm::Run &run, edm::EventSetup const &setup) override
void endRun(edm::Run const &run, edm::EventSetup const &setup) override
Definition: Run.h:45