@@ -35,10 +35,12 @@ namespace {
3535 struct RunBasedHistograms {
3636 // HLT configuration
3737 struct HLTIndices {
38+ unsigned int index_trigger;
3839 unsigned int index_l1_seed;
3940 unsigned int index_prescale;
4041
41- HLTIndices () : index_l1_seed((unsigned int )-1 ), index_prescale((unsigned int )-1 ) {}
42+ HLTIndices ()
43+ : index_trigger((unsigned int )-1 ), index_l1_seed((unsigned int )-1 ), index_prescale((unsigned int )-1 ) {}
4244 };
4345
4446 HLTConfigProvider hltConfig;
@@ -66,7 +68,7 @@ namespace {
6668 std::vector<MonitorElement *> l1t_counts;
6769
6870 // HLT triggers
69- std::vector<std::vector< HLTRatesPlots>> hlt_by_dataset_counts ;
71+ std::vector<HLTRatesPlots> hlt_counts ;
7072
7173 // datasets
7274 std::vector<MonitorElement *> dataset_counts;
@@ -86,7 +88,7 @@ namespace {
8688 // L1T triggers
8789 l1t_counts (),
8890 // HLT triggers
89- hlt_by_dataset_counts (),
91+ hlt_counts (),
9092 // datasets
9193 dataset_counts (),
9294 // streams
@@ -177,17 +179,16 @@ void TriggerRatesMonitor::dqmBeginRun(edm::Run const &run,
177179 if (histograms.hltConfig .init (run, setup, labels.process , changed)) {
178180 // number of trigger paths in labels.process
179181 auto const nTriggers = histograms.hltConfig .size ();
182+ histograms.hltIndices .clear ();
180183 histograms.hltIndices .resize (nTriggers);
184+ histograms.hlt_counts .clear ();
185+ histograms.hlt_counts .resize (nTriggers);
181186
182187 unsigned int const nDatasets = histograms.hltConfig .datasetNames ().size ();
183- histograms.hlt_by_dataset_counts .clear ();
184- histograms.hlt_by_dataset_counts .resize (nDatasets);
185-
186188 histograms.datasets .clear ();
187189 histograms.datasets .resize (nDatasets);
188190 for (unsigned int i = 0 ; i < nDatasets; ++i) {
189191 auto const &paths = histograms.hltConfig .datasetContent (i);
190- histograms.hlt_by_dataset_counts [i].resize (paths.size ());
191192 histograms.datasets [i].reserve (paths.size ());
192193 for (auto const &path : paths) {
193194 auto const triggerIdx = histograms.hltConfig .triggerIndex (path);
@@ -277,64 +278,58 @@ void TriggerRatesMonitor::bookHistograms(DQMStore::IBooker &booker,
277278 }
278279
279280 if (histograms.hltConfig .inited ()) {
280- auto const &datasetNames = histograms.hltConfig .datasetNames ();
281-
282281 // book the rate histograms for the HLT triggers
283- for (unsigned int d = 0 ; d < datasetNames.size (); ++d) {
284- booker.setCurrentFolder (m_dqm_path + " /HLT/" + datasetNames[d]);
285- for (unsigned int i = 0 ; i < histograms.datasets [d].size (); ++i) {
286- unsigned int index = histograms.datasets [d][i];
287- std::string const &name = histograms.hltConfig .triggerName (index);
288- histograms.hlt_by_dataset_counts [d][i].pass_l1_seed = booker.book1D (name + " _pass_L1_seed" ,
289- name + " pass L1 seed, vs. lumisection" ,
290- m_lumisections_range + 1 ,
291- -0.5 ,
292- m_lumisections_range + 0.5 );
293- histograms.hlt_by_dataset_counts [d][i].pass_prescale = booker.book1D (name + " _pass_prescaler" ,
294- name + " pass prescaler, vs. lumisection" ,
295- m_lumisections_range + 1 ,
296- -0.5 ,
297- m_lumisections_range + 0.5 );
298- histograms.hlt_by_dataset_counts [d][i].accept = booker.book1D (name + " _accept" ,
299- name + " accept, vs. lumisection" ,
300- m_lumisections_range + 1 ,
301- -0.5 ,
302- m_lumisections_range + 0.5 );
303- histograms.hlt_by_dataset_counts [d][i].reject = booker.book1D (name + " _reject" ,
304- name + " reject, vs. lumisection" ,
305- m_lumisections_range + 1 ,
306- -0.5 ,
307- m_lumisections_range + 0.5 );
308- histograms.hlt_by_dataset_counts [d][i].error = booker.book1D (name + " _error" ,
309- name + " error, vs. lumisection" ,
310- m_lumisections_range + 1 ,
311- -0.5 ,
312- m_lumisections_range + 0.5 );
313- }
314-
315- for (unsigned int i : histograms.datasets [d]) {
316- // look for the index of the (last) L1T seed and prescale module in each path
317- histograms.hltIndices [i].index_l1_seed = histograms.hltConfig .size (i);
318- histograms.hltIndices [i].index_prescale = histograms.hltConfig .size (i);
319- for (unsigned int j = 0 ; j < histograms.hltConfig .size (i); ++j) {
320- std::string const &label = histograms.hltConfig .moduleLabel (i, j);
321- std::string const &type = histograms.hltConfig .moduleType (label);
322- if (type == " HLTL1TSeed" or type == " HLTLevel1GTSeed" or type == " HLTLevel1Activity" or
323- type == " HLTLevel1Pattern" ) {
324- // there might be more L1T seed filters in sequence
325- // keep looking and store the index of the last one
326- histograms.hltIndices [i].index_l1_seed = j;
327- } else if (type == " HLTPrescaler" ) {
328- // there should be only one prescaler in a path, and it should follow all L1T seed filters
329- histograms.hltIndices [i].index_prescale = j;
330- break ;
331- }
282+ auto const &triggerNames = histograms.hltConfig .triggerNames ();
283+ for (unsigned int i = 0 ; i < triggerNames.size (); ++i) {
284+ std::string const &name = triggerNames[i];
285+ booker.setCurrentFolder (m_dqm_path + " /HLT/" + name);
286+
287+ histograms.hlt_counts [i].pass_l1_seed = booker.book1D (name + " _pass_L1_seed" ,
288+ name + " pass L1 seed, vs. lumisection" ,
289+ m_lumisections_range + 1 ,
290+ -0.5 ,
291+ m_lumisections_range + 0.5 );
292+ histograms.hlt_counts [i].pass_prescale = booker.book1D (name + " _pass_prescaler" ,
293+ name + " pass prescaler, vs. lumisection" ,
294+ m_lumisections_range + 1 ,
295+ -0.5 ,
296+ m_lumisections_range + 0.5 );
297+ histograms.hlt_counts [i].accept = booker.book1D (name + " _accept" ,
298+ name + " accept, vs. lumisection" ,
299+ m_lumisections_range + 1 ,
300+ -0.5 ,
301+ m_lumisections_range + 0.5 );
302+ histograms.hlt_counts [i].reject = booker.book1D (name + " _reject" ,
303+ name + " reject, vs. lumisection" ,
304+ m_lumisections_range + 1 ,
305+ -0.5 ,
306+ m_lumisections_range + 0.5 );
307+ histograms.hlt_counts [i].error = booker.book1D (
308+ name + " _error" , name + " error, vs. lumisection" , m_lumisections_range + 1 , -0.5 , m_lumisections_range + 0.5 );
309+
310+ // set trigger index, and indices of the (last) L1T seed and prescale module in each path
311+ histograms.hltIndices [i].index_trigger = histograms.hltConfig .triggerIndex (name);
312+ histograms.hltIndices [i].index_l1_seed = histograms.hltConfig .size (i);
313+ histograms.hltIndices [i].index_prescale = histograms.hltConfig .size (i);
314+ for (unsigned int j = 0 ; j < histograms.hltConfig .size (i); ++j) {
315+ std::string const &label = histograms.hltConfig .moduleLabel (i, j);
316+ std::string const &type = histograms.hltConfig .moduleType (label);
317+ if (type == " HLTL1TSeed" or type == " HLTLevel1GTSeed" or type == " HLTLevel1Activity" or
318+ type == " HLTLevel1Pattern" ) {
319+ // there might be more L1T seed filters in sequence
320+ // keep looking and store the index of the last one
321+ histograms.hltIndices [i].index_l1_seed = j;
322+ } else if (type == " HLTPrescaler" ) {
323+ // there should be only one prescaler in a path, and it should follow all L1T seed filters
324+ histograms.hltIndices [i].index_prescale = j;
325+ break ;
332326 }
333327 }
334328 }
335329
336330 // book the rate histograms for the HLT datasets
337331 booker.setCurrentFolder (m_dqm_path + " /Datasets" );
332+ auto const &datasetNames = histograms.hltConfig .datasetNames ();
338333 for (unsigned int i = 0 ; i < datasetNames.size (); ++i)
339334 histograms.dataset_counts [i] =
340335 booker.book1D (datasetNames[i], datasetNames[i], m_lumisections_range + 1 , -0.5 , m_lumisections_range + 0.5 );
@@ -387,37 +382,41 @@ void TriggerRatesMonitor::dqmAnalyze(edm::Event const &event,
387382 return ;
388383 }
389384
385+ for (unsigned int i = 0 ; i < histograms.hltIndices .size (); ++i) {
386+ auto const index = histograms.hltIndices [i].index_trigger ;
387+ edm::HLTPathStatus const &path = hltResults[index];
388+
389+ if (path.index () > histograms.hltIndices [i].index_l1_seed )
390+ histograms.hlt_counts [i].pass_l1_seed ->Fill (lumisection);
391+ if (path.index () > histograms.hltIndices [i].index_prescale )
392+ histograms.hlt_counts [i].pass_prescale ->Fill (lumisection);
393+ if (path.accept ())
394+ histograms.hlt_counts [i].accept ->Fill (lumisection);
395+ else if (path.error ())
396+ histograms.hlt_counts [i].error ->Fill (lumisection);
397+ else
398+ histograms.hlt_counts [i].reject ->Fill (lumisection);
399+ }
400+
390401 for (unsigned int d = 0 ; d < histograms.datasets .size (); ++d) {
391- for (unsigned int i : histograms.datasets [d])
402+ for (unsigned int i : histograms.datasets [d]) {
392403 if (hltResults[i].accept ()) {
393404 histograms.dataset_counts [d]->Fill (lumisection);
394405 // ensure each dataset is incremented only once per event
395406 break ;
396407 }
397- for (unsigned int i = 0 ; i < histograms.datasets [d].size (); ++i) {
398- unsigned int const index = histograms.datasets [d][i];
399- edm::HLTPathStatus const &path = hltResults[index];
400-
401- if (path.index () > histograms.hltIndices [index].index_l1_seed )
402- histograms.hlt_by_dataset_counts [d][i].pass_l1_seed ->Fill (lumisection);
403- if (path.index () > histograms.hltIndices [index].index_prescale )
404- histograms.hlt_by_dataset_counts [d][i].pass_prescale ->Fill (lumisection);
405- if (path.accept ())
406- histograms.hlt_by_dataset_counts [d][i].accept ->Fill (lumisection);
407- else if (path.error ())
408- histograms.hlt_by_dataset_counts [d][i].error ->Fill (lumisection);
409- else
410- histograms.hlt_by_dataset_counts [d][i].reject ->Fill (lumisection);
411408 }
412409 }
413410
414- for (unsigned int i = 0 ; i < histograms.streams .size (); ++i)
415- for (unsigned int j : histograms.streams [i])
411+ for (unsigned int i = 0 ; i < histograms.streams .size (); ++i) {
412+ for (unsigned int j : histograms.streams [i]) {
416413 if (hltResults[j].accept ()) {
417414 histograms.stream_counts [i]->Fill (lumisection);
418415 // ensure each stream is incremented only once per event
419416 break ;
420417 }
418+ }
419+ }
421420 }
422421}
423422
0 commit comments