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
ConfigurationDescriptions.h
DaqTestHistograms::~DaqTestHistograms
~DaqTestHistograms() override=default
DaqTestHistograms::DaqTestHistograms
DaqTestHistograms(edm::ParameterSet const &)
Definition: DaqTestHistograms.cc:57
dqm::impl::MonitorElement
Definition: MonitorElement.h:98
DaqTestHistograms::dqmAnalyze
void dqmAnalyze(edm::Event const &, edm::EventSetup const &, RunBasedHistograms const &) const override
Definition: DaqTestHistograms.cc:87
DaqTestHistograms::m_dqm_path
const std::string m_dqm_path
Definition: DaqTestHistograms.cc:44
mps_fire.i
i
Definition: mps_fire.py:428
DaqTestHistograms::m_num_histograms
const uint32_t m_num_histograms
Definition: DaqTestHistograms.cc:46
edm::Run
Definition: Run.h:45
LuminosityBlock.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
config
Definition: config.py:1
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
DaqTestHistograms
Definition: DaqTestHistograms.cc:28
Run.h
DaqTestHistograms::dqmBeginRun
void dqmBeginRun(edm::Run const &, edm::EventSetup const &, RunBasedHistograms &) const override
Definition: DaqTestHistograms.cc:63
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
DaqTestHistograms::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: DaqTestHistograms.cc:49
edm::EventSetup
Definition: EventSetup.h:57
histograms
Definition: histograms.py:1
DaqTestHistograms::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, RunBasedHistograms &) const override
Definition: DaqTestHistograms.cc:69
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
DaqTestHistograms::m_lumisections_range
const uint32_t m_lumisections_range
Definition: DaqTestHistograms.cc:45
EventSetup.h
dqm::implementation::IBooker
Definition: DQMStore.h:43
DQMGlobalEDAnalyzer
Definition: DQMGlobalEDAnalyzer.h:76
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
DQMGlobalEDAnalyzer.h