CMS 3D CMS Logo

DaqTestHistograms.cc
Go to the documentation of this file.
1 // Implementation based on FastTimerService.
2 // Target usage is to generate fake DAQ histograms for performance tests on RUBU machines (effect of running fastHadd) and to include in unit tests.
3 
4 // CMSSW headers
13 
14 namespace {
15 
16  struct RunBasedHistograms {
17  // overall event count and event types
18  dqm::reco::MonitorElement *events_processed;
19  std::vector<dqm::reco::MonitorElement *> element_array;
20 
21  RunBasedHistograms()
22  : // overall event count and event types
23  events_processed(nullptr),
24  element_array() {}
25  };
26 } // namespace
27 
28 class DaqTestHistograms : public DQMGlobalEDAnalyzer<RunBasedHistograms> {
29 public:
30  explicit DaqTestHistograms(edm::ParameterSet const &);
31  ~DaqTestHistograms() override = default;
32 
33  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
34 
35 private:
36  void dqmBeginRun(edm::Run const &, edm::EventSetup const &, RunBasedHistograms &) const override;
38  edm::Run const &,
39  edm::EventSetup const &,
40  RunBasedHistograms &) const override;
41  void dqmAnalyze(edm::Event const &, edm::EventSetup const &, RunBasedHistograms const &) const override;
42 
43  // module configuration
45  const uint32_t m_lumisections_range;
46  const uint32_t m_num_histograms;
47 };
48 
51  desc.addUntracked<std::string>("dqmPath", "DAQTEST/Test");
52  desc.addUntracked<uint32_t>("lumisectionRange", 25);
53  desc.addUntracked<uint32_t>("numberOfHistograms", 10);
54  descriptions.add("dqmHLTTestMonitor", desc);
55 }
56 
58  : // module configuration
59  m_dqm_path(config.getUntrackedParameter<std::string>("dqmPath")),
60  m_lumisections_range(config.getUntrackedParameter<uint32_t>("lumisectionRange")),
61  m_num_histograms(config.getUntrackedParameter<uint32_t>("numberOfHistograms")) {}
62 
64  edm::EventSetup const &setup,
65  RunBasedHistograms &histograms) const {
66  histograms.element_array.resize(m_num_histograms);
67 }
68 
70  edm::Run const &run,
71  edm::EventSetup const &setup,
72  RunBasedHistograms &histograms) const {
73  // book the overall event count and event types histograms
75  histograms.events_processed = booker.book1D(
76  "events", "Processed events vs. lumisection", m_lumisections_range + 1, -0.5, m_lumisections_range + 0.5);
77  for (size_t i = 0; i < histograms.element_array.size(); i++) {
78  std::stringstream strs;
79  strs << "element " << i;
80  std::stringstream strs2;
81  strs2 << "e vs ls " << i;
82  histograms.element_array[i] =
83  booker.book1D(strs.str(), strs2.str(), m_lumisections_range + 1, -0.5, m_lumisections_range + 0.5);
84  }
85 }
86 
88  edm::EventSetup const &setup,
89  RunBasedHistograms const &histograms) const {
90  unsigned int lumisection = event.luminosityBlock();
91 
92  histograms.events_processed->Fill(lumisection);
93  for (size_t i = 0; i < histograms.element_array.size(); i++) {
94  histograms.element_array[i]->Fill(lumisection);
95  }
96 }
97 
98 //define this as a plug-in
DaqTestHistograms(edm::ParameterSet const &)
const std::string m_dqm_path
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
const uint32_t m_num_histograms
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, RunBasedHistograms const &) const override
Definition: config.py:1
void dqmBeginRun(edm::Run const &, edm::EventSetup const &, RunBasedHistograms &) const override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, RunBasedHistograms &) const override
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
~DaqTestHistograms() override=default
Definition: event.py:1
Definition: Run.h:45
const uint32_t m_lumisections_range