CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GtUtils.cc
Go to the documentation of this file.
1 
17 // this class header
19 
20 // system include files
21 #include <iomanip>
22 
23 // user include files
27 
29 
32 
36 
40 
43 
46 
48 
49 // constructor(s)
51 
52  m_l1GtStableParCacheID(0ULL), m_numberAlgorithmTriggers(0),
53 
54  m_numberTechnicalTriggers(0),
55 
56  m_l1GtPfAlgoCacheID(0ULL), m_l1GtPfTechCacheID(0ULL),
57 
58  m_l1GtTmAlgoCacheID(0ULL), m_l1GtTmTechCacheID(0ULL),
59 
60  m_l1GtTmVetoAlgoCacheID(0ULL), m_l1GtTmVetoTechCacheID(0ULL),
61 
62  m_l1GtMenuCacheID(0ULL),
63 
64  m_l1EventSetupValid(false),
65 
66  m_l1GtMenuLiteValid(false),
67 
68  m_beginRunCache(false),
69 
70  m_runIDCache(0),
71 
72  m_provRunIDCache(0),
73 
74  m_physicsDaqPartition(0),
75 
76  m_retrieveL1EventSetup(false),
77 
78  m_retrieveL1GtTriggerMenuLite(false)
79 
80  {
81 
82  // empty
83 }
84 
85 // destructor
87 
88  // empty
89 
90 }
91 
92 const std::string L1GtUtils::triggerCategory(
93  const TriggerCategory& trigCategory) const {
94 
95  switch (trigCategory) {
96  case AlgorithmTrigger: {
97  return "Algorithm Trigger";
98  }
99  break;
100  case TechnicalTrigger: {
101  return "Technical Trigger";
102  }
103 
104  break;
105  default: {
106  return EmptyString;
107  }
108  break;
109  }
110 }
111 
112 
114 
115  //
116  m_retrieveL1EventSetup = true;
117 
118  m_l1EventSetupValid = true;
119  // FIXME test for each record if valid; if not set m_l1EventSetupValid = false;
120 
121  // get / update the stable parameters from the EventSetup
122  // local cache & check on cacheIdentifier
123 
124  unsigned long long l1GtStableParCacheID =
125  evSetup.get<L1GtStableParametersRcd>().cacheIdentifier();
126 
127  if (m_l1GtStableParCacheID != l1GtStableParCacheID) {
128 
130  evSetup.get<L1GtStableParametersRcd>().get(l1GtStablePar);
131  m_l1GtStablePar = l1GtStablePar.product();
132 
133  // number of algorithm triggers
135 
136  // number of technical triggers
139 
140  int maxNumberTrigger = std::max(m_numberAlgorithmTriggers,
142 
143  m_triggerMaskSet.reserve(maxNumberTrigger);
144  m_prescaleFactorSet.reserve(maxNumberTrigger);
145 
146  //
147  m_l1GtStableParCacheID = l1GtStableParCacheID;
148 
149  }
150 
151  // get / update the prescale factors from the EventSetup
152  // local cache & check on cacheIdentifier
153 
154  unsigned long long l1GtPfAlgoCacheID =
155  evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().cacheIdentifier();
156 
157  if (m_l1GtPfAlgoCacheID != l1GtPfAlgoCacheID) {
158 
160  evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().get(l1GtPfAlgo);
161  m_l1GtPfAlgo = l1GtPfAlgo.product();
162 
164 
165  m_l1GtPfAlgoCacheID = l1GtPfAlgoCacheID;
166 
167  }
168 
169  unsigned long long l1GtPfTechCacheID = evSetup.get<
170  L1GtPrescaleFactorsTechTrigRcd>().cacheIdentifier();
171 
172  if (m_l1GtPfTechCacheID != l1GtPfTechCacheID) {
173 
175  evSetup.get<L1GtPrescaleFactorsTechTrigRcd>().get(l1GtPfTech);
176  m_l1GtPfTech = l1GtPfTech.product();
177 
179 
180  m_l1GtPfTechCacheID = l1GtPfTechCacheID;
181 
182  }
183 
184  // get / update the trigger mask from the EventSetup
185  // local cache & check on cacheIdentifier
186 
187  unsigned long long l1GtTmAlgoCacheID =
188  evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().cacheIdentifier();
189 
190  if (m_l1GtTmAlgoCacheID != l1GtTmAlgoCacheID) {
191 
193  evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().get(l1GtTmAlgo);
194  m_l1GtTmAlgo = l1GtTmAlgo.product();
195 
197 
198  m_l1GtTmAlgoCacheID = l1GtTmAlgoCacheID;
199 
200  }
201 
202  unsigned long long l1GtTmTechCacheID =
203  evSetup.get<L1GtTriggerMaskTechTrigRcd>().cacheIdentifier();
204 
205  if (m_l1GtTmTechCacheID != l1GtTmTechCacheID) {
206 
208  evSetup.get<L1GtTriggerMaskTechTrigRcd>().get(l1GtTmTech);
209  m_l1GtTmTech = l1GtTmTech.product();
210 
212 
213  m_l1GtTmTechCacheID = l1GtTmTechCacheID;
214 
215  }
216 
217  unsigned long long l1GtTmVetoAlgoCacheID =
218  evSetup.get<L1GtTriggerMaskVetoAlgoTrigRcd>().cacheIdentifier();
219 
220  if (m_l1GtTmVetoAlgoCacheID != l1GtTmVetoAlgoCacheID) {
221 
222  edm::ESHandle<L1GtTriggerMask> l1GtTmVetoAlgo;
223  evSetup.get<L1GtTriggerMaskVetoAlgoTrigRcd>().get(l1GtTmVetoAlgo);
224  m_l1GtTmVetoAlgo = l1GtTmVetoAlgo.product();
225 
227 
228  m_l1GtTmVetoAlgoCacheID = l1GtTmVetoAlgoCacheID;
229 
230  }
231 
232  unsigned long long l1GtTmVetoTechCacheID =
233  evSetup.get<L1GtTriggerMaskVetoTechTrigRcd>().cacheIdentifier();
234 
235  if (m_l1GtTmVetoTechCacheID != l1GtTmVetoTechCacheID) {
236 
237  edm::ESHandle<L1GtTriggerMask> l1GtTmVetoTech;
238  evSetup.get<L1GtTriggerMaskVetoTechTrigRcd>().get(l1GtTmVetoTech);
239  m_l1GtTmVetoTech = l1GtTmVetoTech.product();
240 
242 
243  m_l1GtTmVetoTechCacheID = l1GtTmVetoTechCacheID;
244 
245  }
246 
247  // get / update the trigger menu from the EventSetup
248  // local cache & check on cacheIdentifier
249 
250  unsigned long long l1GtMenuCacheID =
251  evSetup.get<L1GtTriggerMenuRcd>().cacheIdentifier();
252 
253  if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
254 
256  evSetup.get<L1GtTriggerMenuRcd>().get(l1GtMenu);
257  m_l1GtMenu = l1GtMenu.product();
258 
261 
263 
264  m_l1GtMenuCacheID = l1GtMenuCacheID;
265 
266  }
267 
268 }
269 
270 
272  const edm::InputTag& l1GtMenuLiteInputTag) {
273 
274  //
276 
277  // get L1GtTriggerMenuLite
279  iRun.getByLabel(l1GtMenuLiteInputTag, l1GtMenuLite);
280 
281  if (!l1GtMenuLite.isValid()) {
282 
283  LogDebug("L1GtUtils") << "\nL1GtTriggerMenuLite with \n "
284  << l1GtMenuLiteInputTag
285  << "\nrequested in configuration, but not found in the event."
286  << std::endl;
287 
288  m_l1GtMenuLiteValid = false;
289  } else {
290  m_l1GtMenuLite = l1GtMenuLite.product();
291  m_l1GtMenuLiteValid = true;
292 
293  LogDebug("L1GtUtils") << "\nL1GtTriggerMenuLite with \n "
294  << l1GtMenuLiteInputTag << "\nretrieved for run "
295  << iRun.runAuxiliary().run() << std::endl;
296 
300 
303 
308 
309  }
310 
311 }
312 
314  const edm::EventSetup& evSetup, const bool useL1EventSetup,
315  const bool useL1GtTriggerMenuLite, const edm::InputTag& l1GtTmLInputTag) {
316 
317  // first call will turn this to true: the quantities which can be cached in
318  // beginRun will not be cached then in analyze
319  m_beginRunCache = true;
320 
321  // if requested, retrieve and cache L1 event setup
322  // keep the caching based on cacheIdentifier() for each record
323  if (useL1EventSetup) {
324  retrieveL1EventSetup(evSetup);
325  }
326 
327  // cached per run
328 
329  // if requested, retrieve and cache the L1GtTriggerMenuLite
330  // L1GtTriggerMenuLite is defined per run and produced in prompt reco by L1Reco
331  // and put in the Run section
332  if (useL1GtTriggerMenuLite) {
333  retrieveL1GtTriggerMenuLite(iRun, l1GtTmLInputTag);
334  }
335 
336 }
337 
338 
340  const edm::EventSetup& evSetup, bool useL1EventSetup,
341  bool useL1GtTriggerMenuLite) {
342 
343  if (useL1GtTriggerMenuLite) {
345 
346  }
347 
348  getL1GtRunCache(iRun, evSetup, useL1EventSetup, useL1GtTriggerMenuLite,
350 
351 }
352 
353 
354 
356  const edm::EventSetup& evSetup, const bool useL1EventSetup,
357  const bool useL1GtTriggerMenuLite, const edm::InputTag& l1GtTmLInputTag) {
358 
359  // if there was no retrieval and caching in beginRun, do it here
360  if (!m_beginRunCache) {
361 
362  // if requested, retrieve and cache L1 event setup
363  // keep the caching based on cacheIdentifier() for each record
364  if (useL1EventSetup) {
365  retrieveL1EventSetup(evSetup);
366  }
367  }
368 
369  // cached per run
370 
371  const edm::Run& iRun = iEvent.getRun();
372  edm::RunID runID = iRun.runAuxiliary().id();
373 
374  if (runID != m_runIDCache) {
375 
376  if (!m_beginRunCache) {
377  // if requested, retrieve and cache the L1GtTriggerMenuLite
378  // L1GtTriggerMenuLite is defined per run and produced in prompt reco by L1Reco
379  // and put in the Run section
380  if (useL1GtTriggerMenuLite) {
381  retrieveL1GtTriggerMenuLite(iRun, l1GtTmLInputTag);
382  }
383  }
384 
385  // find from provenance and cache the input tags for L1GlobalTriggerRecord and
386  // L1GlobalTriggerReadoutRecord
389 
390  //
391  m_runIDCache = runID;
392 
393  }
394 
395 }
396 
397 
399  const edm::EventSetup& evSetup, const bool useL1EventSetup,
400  const bool useL1GtTriggerMenuLite) {
401 
402  // if the input tag for L1GtTriggerMenuLite was not found in beginRun, do it here
403  if (!m_beginRunCache) {
404 
405  const edm::Run& iRun = iEvent.getRun();
406  edm::RunID runID = iRun.runAuxiliary().id();
407 
408  if (runID != m_provRunIDCache) {
409 
410  if (useL1GtTriggerMenuLite) {
411 
414  }
415 
416  //
417  m_provRunIDCache = runID;
418  }
419 
420  }
421 
422  // call now the general method for getL1GtRunCache
423  getL1GtRunCache(iEvent, evSetup, useL1EventSetup, useL1GtTriggerMenuLite,
425 
426 }
427 
428 
430  edm::InputTag& l1GtRecordInputTag,
431  edm::InputTag& l1GtReadoutRecordInputTag) const {
432 
433  typedef std::vector<edm::Provenance const*> Provenances;
434  Provenances provenances;
435  std::string friendlyName;
436  std::string modLabel;
437  std::string instanceName;
438  std::string processName;
439 
440  bool foundL1GtRecord = false;
441  bool foundL1GtReadoutRecord = false;
442 
443  LogDebug("L1GtUtils") << "\nTry to get AllProvenance for event "
444  << iEvent.id().event() << std::endl;
445 
446  iEvent.getAllProvenance(provenances);
447 
448  LogTrace("L1GtUtils") << "\n" << "Event contains " << provenances.size()
449  << " product" << (provenances.size() == 1 ? "" : "s")
450  << " with friendlyClassName, moduleLabel, productInstanceName and processName:\n"
451  << std::endl;
452 
453  for (Provenances::iterator itProv = provenances.begin(), itProvEnd =
454  provenances.end(); itProv != itProvEnd; ++itProv) {
455 
456  friendlyName = (*itProv)->friendlyClassName();
457  modLabel = (*itProv)->moduleLabel();
458  instanceName = (*itProv)->productInstanceName();
459  processName = (*itProv)->processName();
460 
461  LogTrace("L1GtUtils") << friendlyName << "\t \"" << modLabel
462  << "\" \t \"" << instanceName << "\" \t \"" << processName
463  << "\"" << std::endl;
464 
465  if (friendlyName == "L1GlobalTriggerRecord") {
466  l1GtRecordInputTag = edm::InputTag(modLabel, instanceName,
467  processName);
468  foundL1GtRecord = true;
469  } else if (friendlyName == "L1GlobalTriggerReadoutRecord") {
470 
471  l1GtReadoutRecordInputTag = edm::InputTag(modLabel, instanceName,
472  processName);
473  foundL1GtReadoutRecord = true;
474  }
475  }
476 
477  // if not found, return empty input tags
478  if (!foundL1GtRecord) {
479  l1GtRecordInputTag = edm::InputTag();
480  } else {
481  LogTrace("L1GtUtils")
482  << "\nL1GlobalTriggerRecord found in the event with \n "
483  << l1GtRecordInputTag << std::endl;
484  }
485 
486  if (!foundL1GtReadoutRecord) {
487  l1GtReadoutRecordInputTag = edm::InputTag();
488  } else {
489  LogTrace("L1GtUtils")
490  << "\nL1GlobalTriggerReadoutRecord found in the event with \n "
491  << l1GtReadoutRecordInputTag << std::endl;
492  }
493 
494 }
495 
497  edm::InputTag& l1GtTriggerMenuLiteInputTag) const {
498 
499  typedef std::vector<edm::Provenance const*> Provenances;
500  Provenances provenances;
501  std::string friendlyName;
502  std::string modLabel;
503  std::string instanceName;
504  std::string processName;
505 
506  bool foundL1GtTriggerMenuLite = false;
507 
508  LogDebug("L1GtUtils") << "\nTry to get AllProvenance for run "
509  << iRun.runAuxiliary().run() << std::endl;
510 
511  iRun.getAllProvenance(provenances);
512 
513  LogTrace("L1GtUtils") << "\n" << "Run contains " << provenances.size()
514  << " product" << (provenances.size() == 1 ? "" : "s")
515  << " with friendlyClassName, moduleLabel, productInstanceName and processName:\n"
516  << std::endl;
517 
518  for (Provenances::iterator itProv = provenances.begin(), itProvEnd =
519  provenances.end(); itProv != itProvEnd; ++itProv) {
520 
521  friendlyName = (*itProv)->friendlyClassName();
522  modLabel = (*itProv)->moduleLabel();
523  instanceName = (*itProv)->productInstanceName();
524  processName = (*itProv)->processName();
525 
526  LogTrace("L1GtUtils") << friendlyName << "\t \"" << modLabel
527  << "\" \t \"" << instanceName << "\" \t \"" << processName
528  << "\"" << std::endl;
529 
530  if (friendlyName == "L1GtTriggerMenuLite") {
531  l1GtTriggerMenuLiteInputTag = edm::InputTag(modLabel, instanceName,
532  processName);
533  foundL1GtTriggerMenuLite = true;
534  }
535 
536  }
537 
538  if (!foundL1GtTriggerMenuLite) {
539  l1GtTriggerMenuLiteInputTag = edm::InputTag();
540  LogTrace("L1GtUtils") << "\nL1GtTriggerMenuLite not found in Run"
541  << std::endl;
542  } else {
543  LogTrace("L1GtUtils") << "\nL1GtTriggerMenuLite found in Run with \n "
544  << l1GtTriggerMenuLiteInputTag << std::endl;
545  }
546 
547 }
548 
549 
551  const std::string& nameAlgoTechTrig, TriggerCategory& trigCategory,
552  int& bitNumber) const {
553 
554  trigCategory = AlgorithmTrigger;
555  bitNumber = -1;
556 
558  if (m_l1GtMenuLiteValid) {
559 
560  // test if the name is an algorithm alias
561  for (L1GtTriggerMenuLite::CItL1Trig itTrig =
562  m_algorithmAliasMapLite->begin(); itTrig
563  != m_algorithmAliasMapLite->end(); itTrig++) {
564 
565  if (itTrig->second == nameAlgoTechTrig) {
566 
567  trigCategory = AlgorithmTrigger;
568  bitNumber = itTrig->first;
569 
570  return true;
571  }
572  }
573 
574  // test if the name is an algorithm name
575  for (L1GtTriggerMenuLite::CItL1Trig itTrig =
576  m_algorithmMapLite->begin(); itTrig
577  != m_algorithmMapLite->end(); itTrig++) {
578 
579  if (itTrig->second == nameAlgoTechTrig) {
580 
581  trigCategory = AlgorithmTrigger;
582  bitNumber = itTrig->first;
583 
584  return true;
585  }
586  }
587 
588  // test if the name is a technical trigger
589  for (L1GtTriggerMenuLite::CItL1Trig itTrig =
590  m_technicalTriggerMapLite->begin(); itTrig
591  != m_technicalTriggerMapLite->end(); itTrig++) {
592 
593  if (itTrig->second == nameAlgoTechTrig) {
594 
595  trigCategory = TechnicalTrigger;
596  bitNumber = itTrig->first;
597 
598  return true;
599  }
600  }
601 
602  } else if (m_retrieveL1EventSetup) {
603 
604  // test if the name is an algorithm alias
605  CItAlgo itAlgo = m_algorithmAliasMap->find(nameAlgoTechTrig);
606  if (itAlgo != m_algorithmAliasMap->end()) {
607  trigCategory = AlgorithmTrigger;
608  bitNumber = (itAlgo->second).algoBitNumber();
609 
610  return true;
611  }
612 
613  // test if the name is an algorithm name
614  itAlgo = m_algorithmMap->find(nameAlgoTechTrig);
615  if (itAlgo != m_algorithmMap->end()) {
616  trigCategory = AlgorithmTrigger;
617  bitNumber = (itAlgo->second).algoBitNumber();
618 
619  return true;
620  }
621 
622  // test if the name is a technical trigger
623  itAlgo = m_technicalTriggerMap->find(nameAlgoTechTrig);
624  if (itAlgo != m_technicalTriggerMap->end()) {
625  trigCategory = TechnicalTrigger;
626  bitNumber = (itAlgo->second).algoBitNumber();
627 
628  return true;
629  }
630 
631  } else {
632  // only L1GtTriggerMenuLite requested, but it is not valid
633  return false;
634 
635  }
636  } else if (m_retrieveL1EventSetup) {
637 
638  // test if the name is an algorithm alias
639  CItAlgo itAlgo = m_algorithmAliasMap->find(nameAlgoTechTrig);
640  if (itAlgo != m_algorithmAliasMap->end()) {
641  trigCategory = AlgorithmTrigger;
642  bitNumber = (itAlgo->second).algoBitNumber();
643 
644  return true;
645  }
646 
647  // test if the name is an algorithm name
648  itAlgo = m_algorithmMap->find(nameAlgoTechTrig);
649  if (itAlgo != m_algorithmMap->end()) {
650  trigCategory = AlgorithmTrigger;
651  bitNumber = (itAlgo->second).algoBitNumber();
652 
653  return true;
654  }
655 
656  // test if the name is a technical trigger
657  itAlgo = m_technicalTriggerMap->find(nameAlgoTechTrig);
658  if (itAlgo != m_technicalTriggerMap->end()) {
659  trigCategory = TechnicalTrigger;
660  bitNumber = (itAlgo->second).algoBitNumber();
661 
662  return true;
663  }
664 
665  } else {
666  // L1 trigger configuration not retrieved
667  return false;
668 
669  }
670 
671  // all possibilities already tested, so it should not arrive here
672  return false;
673 
674 
675 }
676 
677 const bool L1GtUtils::l1TriggerNameFromBit(const int& bitNumber,
678  const TriggerCategory& trigCategory, std::string& aliasL1Trigger,
679  std::string& nameL1Trigger) const {
680 
681  aliasL1Trigger.clear();
682  nameL1Trigger.clear();
683 
685  if (m_l1GtMenuLiteValid) {
686 
687  // for an algorithm trigger
688  if (trigCategory == AlgorithmTrigger) {
689 
690  bool trigAliasFound = false;
691  bool trigNameFound = false;
692 
693  for (L1GtTriggerMenuLite::CItL1Trig itTrig =
694  m_algorithmAliasMapLite->begin();
695  itTrig != m_algorithmAliasMapLite->end(); itTrig++) {
696 
697  if (static_cast<int>(itTrig->first) == bitNumber) {
698  aliasL1Trigger = itTrig->second;
699  trigAliasFound = true;
700  break;
701  }
702  }
703 
704  for (L1GtTriggerMenuLite::CItL1Trig itTrig =
705  m_algorithmMapLite->begin();
706  itTrig != m_algorithmMapLite->end(); itTrig++) {
707 
708  if (static_cast<int>(itTrig->first) == bitNumber) {
709  nameL1Trigger = itTrig->second;
710  trigNameFound = true;
711  break;
712  }
713  }
714 
715  if (!(trigAliasFound && trigNameFound)) {
716  return false;
717  }
718 
719  return true;
720 
721  } else if (trigCategory == TechnicalTrigger) {
722 
723  // for a technical trigger
724 
725  bool trigNameFound = false;
726 
727  for (L1GtTriggerMenuLite::CItL1Trig itTrig =
728  m_technicalTriggerMapLite->begin();
729  itTrig != m_technicalTriggerMapLite->end(); itTrig++) {
730 
731  if (static_cast<int>(itTrig->first) == bitNumber) {
732  nameL1Trigger = itTrig->second;
733 
734  // technically, no alias is defined for technical triggers
735  // users use mainly aliases, so just return the name here
736  aliasL1Trigger = itTrig->second;
737 
738  trigNameFound = true;
739  break;
740  }
741  }
742 
743  if (!(trigNameFound)) {
744  return false;
745  }
746 
747  return true;
748 
749  } else {
750 
751  // non-existing trigger category...
752  return false;
753  }
754 
755  } else if (m_retrieveL1EventSetup) {
756 
757  // for an algorithm trigger
758  if (trigCategory == AlgorithmTrigger) {
759 
760  bool trigAliasFound = false;
761 
762  for (CItAlgo itTrig = m_algorithmAliasMap->begin();
763  itTrig != m_algorithmAliasMap->end(); itTrig++) {
764 
765  if ((itTrig->second).algoBitNumber() == bitNumber) {
766  aliasL1Trigger = itTrig->first;
767  // get the name here, avoiding a loop on m_algorithmMap
768  nameL1Trigger = (itTrig->second).algoName();
769 
770  trigAliasFound = true;
771  break;
772  }
773  }
774 
775  if (!(trigAliasFound)) {
776  return false;
777  }
778 
779  return true;
780 
781  } else if (trigCategory == TechnicalTrigger) {
782 
783  // for a technical trigger
784 
785  bool trigNameFound = false;
786 
787  for (CItAlgo itTrig = m_technicalTriggerMap->begin();
788  itTrig != m_technicalTriggerMap->end(); itTrig++) {
789 
790  if ((itTrig->second).algoBitNumber() == bitNumber) {
791  nameL1Trigger = (itTrig->second).algoName();
792  // technically, no alias is defined for technical triggers
793  // users use mainly aliases, so just return the name here
794  aliasL1Trigger = nameL1Trigger;
795 
796  trigNameFound = true;
797  break;
798  }
799  }
800 
801  if (!(trigNameFound)) {
802  return false;
803  }
804 
805  return true;
806 
807  } else {
808 
809  // non-existing trigger category...
810  return false;
811  }
812 
813  } else {
814  // only L1GtTriggerMenuLite requested, but it is not valid
815  return false;
816 
817  }
818  } else if (m_retrieveL1EventSetup) {
819 
820  // for an algorithm trigger
821  if (trigCategory == AlgorithmTrigger) {
822 
823  bool trigAliasFound = false;
824 
825  for (CItAlgo itTrig = m_algorithmAliasMap->begin();
826  itTrig != m_algorithmAliasMap->end(); itTrig++) {
827 
828  if ((itTrig->second).algoBitNumber() == bitNumber) {
829  aliasL1Trigger = itTrig->first;
830  // get the name here, avoiding a loop on m_algorithmMap
831  nameL1Trigger = (itTrig->second).algoName();
832 
833  trigAliasFound = true;
834  break;
835  }
836  }
837 
838  if (!(trigAliasFound)) {
839  return false;
840  }
841 
842  return true;
843 
844  } else if (trigCategory == TechnicalTrigger) {
845 
846  // for a technical trigger
847 
848  bool trigNameFound = false;
849 
850  for (CItAlgo itTrig = m_technicalTriggerMap->begin();
851  itTrig != m_technicalTriggerMap->end(); itTrig++) {
852 
853  if ((itTrig->second).algoBitNumber() == bitNumber) {
854  nameL1Trigger = (itTrig->second).algoName();
855  // technically, no alias is defined for technical triggers
856  // users use mainly aliases, so just return the name here
857  aliasL1Trigger = itTrig->first;
858 
859  trigNameFound = true;
860  break;
861  }
862  }
863 
864  if (!(trigNameFound)) {
865  return false;
866  }
867 
868  return true;
869 
870  } else {
871 
872  // non-existing trigger category...
873  return false;
874  }
875 
876  } else {
877  // L1 trigger configuration not retrieved
878  return false;
879 
880  }
881 
882  // all possibilities already tested, so it should not arrive here
883  return false;
884 
885 }
886 
888  const edm::InputTag& l1GtRecordInputTag,
889  const edm::InputTag& l1GtReadoutRecordInputTag,
890  const std::string& nameAlgoTechTrig, bool& decisionBeforeMask,
891  bool& decisionAfterMask, int& prescaleFactor, int& triggerMask) const {
892 
893  // initial values for returned results
894  decisionBeforeMask = false;
895  decisionAfterMask = false;
896  prescaleFactor = -1;
897  triggerMask = -1;
898 
899  // initialize error code and L1 configuration code
900  int iError = 0;
901  int l1ConfCode = 0;
902 
903  // check if L1 configuration is available
904 
905  if (!availableL1Configuration(iError, l1ConfCode)) {
906  return iError;
907  }
908 
909  // at this point, a valid L1 configuration is available, so the if/else if/else
910  // can be simplified
911 
912  // if the given name is not an algorithm trigger alias, an algorithm trigger name
913  // or a technical trigger in the current menu, return with error code 1
914 
915  TriggerCategory trigCategory = AlgorithmTrigger;
916  int bitNumber = -1;
917 
918 
919  if (!l1AlgoTechTrigBitNumber(nameAlgoTechTrig, trigCategory, bitNumber)) {
920 
921  iError = l1ConfCode + 1;
922 
924  if (m_l1GtMenuLiteValid) {
925 
926  LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
927  << nameAlgoTechTrig
928  << "\not found in the trigger menu \n "
930  << "\nretrieved from L1GtTriggerMenuLite" << std::endl;
931 
932  } else {
933 
934  // fall through: L1 trigger configuration from event setup
935  LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
936  << nameAlgoTechTrig
937  << "\not found in the trigger menu \n "
939  << "\nretrieved from Event Setup" << std::endl;
940 
941  }
942 
943  } else {
944  // L1 trigger configuration from event setup only
945  LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
946  << nameAlgoTechTrig
947  << "\not found in the trigger menu \n "
949  << "\nretrieved from Event Setup" << std::endl;
950 
951  }
952 
953  return iError;
954 
955  }
956 
957  // check here if a positive bit number was retrieved
958  // exit in case of negative bit number, before retrieving L1 GT products, saving time
959 
960  if (bitNumber < 0) {
961 
962  iError = l1ConfCode + 2;
963 
965  if (m_l1GtMenuLiteValid) {
966  LogDebug("L1GtUtils") << "\nNegative bit number for "
967  << triggerCategory(trigCategory) << "\n "
968  << nameAlgoTechTrig << "\nfrom menu \n "
970  << "\nretrieved from L1GtTriggerMenuLite" << std::endl;
971 
972  } else {
973  // fall through: L1 trigger configuration from event setup
974  LogDebug("L1GtUtils") << "\nNegative bit number for "
975  << triggerCategory(trigCategory) << "\n "
976  << nameAlgoTechTrig << "\nfrom menu \n "
978  << "\nretrieved from Event Setup" << std::endl;
979 
980  }
981 
982  } else {
983  // L1 trigger configuration from event setup only
984  LogDebug("L1GtUtils") << "\nNegative bit number for "
985  << triggerCategory(trigCategory) << "\n "
986  << nameAlgoTechTrig << "\nfrom menu \n "
988  << "\nretrieved from Event Setup" << std::endl;
989 
990  }
991 
992  return iError;
993  }
994 
995 
996  // retrieve L1GlobalTriggerRecord and 1GlobalTriggerReadoutRecord product
997  // intermediate error code for the records
998  // the module returns an error code only if both the lite and the readout record are missing
999 
1000  int iErrorRecord = 0;
1001 
1002  bool validRecord = false;
1003  bool gtReadoutRecordValid = false;
1004 
1006  iEvent.getByLabel(l1GtRecordInputTag, gtRecord);
1007 
1008  if (gtRecord.isValid()) {
1009 
1010  validRecord = true;
1011 
1012  } else {
1013 
1014  iErrorRecord = 10;
1015  LogDebug("L1GtUtils") << "\nL1GlobalTriggerRecord with \n "
1016  << l1GtRecordInputTag << "\nnot found in the event."
1017  << std::endl;
1018  }
1019 
1021  iEvent.getByLabel(l1GtReadoutRecordInputTag, gtReadoutRecord);
1022 
1023  if (gtReadoutRecord.isValid()) {
1024 
1025  gtReadoutRecordValid = true;
1026  validRecord = true;
1027 
1028  } else {
1029 
1030  iErrorRecord = iErrorRecord + 100;
1031  LogDebug("L1GtUtils") << "\nL1GlobalTriggerReadoutRecord with \n "
1032  << l1GtReadoutRecordInputTag << "\nnot found in the event."
1033  << std::endl;
1034 
1035  }
1036 
1037  // get the prescale factor index from
1038  // L1GlobalTriggerReadoutRecord if valid
1039  // if not, from L1GlobalTriggerRecord if valid
1040  // else return an error
1041 
1042 
1043  int pfIndexTechTrig = -1;
1044  int pfIndexAlgoTrig = -1;
1045 
1046  if (validRecord) {
1047  if (gtReadoutRecordValid) {
1048 
1049  pfIndexTechTrig
1050  = (gtReadoutRecord->gtFdlWord()).gtPrescaleFactorIndexTech();
1051  pfIndexAlgoTrig
1052  = (gtReadoutRecord->gtFdlWord()).gtPrescaleFactorIndexAlgo();
1053 
1054  } else {
1055 
1056  pfIndexTechTrig
1057  = static_cast<int> (gtRecord->gtPrescaleFactorIndexTech());
1058  pfIndexAlgoTrig
1059  = static_cast<int> (gtRecord->gtPrescaleFactorIndexAlgo());
1060 
1061  }
1062 
1063  } else {
1064 
1065  LogDebug("L1GtUtils") << "\nError: "
1066  << "\nNo valid L1GlobalTriggerRecord with \n "
1067  << l1GtRecordInputTag << "\nfound in the event."
1068  << "\nNo valid L1GlobalTriggerReadoutRecord with \n "
1069  << l1GtReadoutRecordInputTag << "\nfound in the event."
1070  << std::endl;
1071 
1072  iError = l1ConfCode + iErrorRecord;
1073  return iError;
1074 
1075  }
1076 
1077  // depending on trigger category (algorithm trigger or technical trigger)
1078  // get the correct quantities
1079 
1080  // number of sets of prescale factors
1081  // index of prescale factor set retrieved from data
1082  // pointer to the actual prescale factor set
1083  // pointer to the set of trigger masks
1084 
1085  size_t pfSetsSize = 0;
1086  int pfIndex = -1;
1087  const std::vector<int>* prescaleFactorsSubset = 0;
1088  const std::vector<unsigned int>* triggerMasksSet = 0;
1089 
1090  switch (trigCategory) {
1091  case AlgorithmTrigger: {
1093  if (m_l1GtMenuLiteValid) {
1094  pfSetsSize = m_prescaleFactorsAlgoTrigLite->size();
1095  triggerMasksSet = m_triggerMaskAlgoTrigLite;
1096 
1097  } else {
1098  // fall through: L1 trigger configuration from event setup
1099  pfSetsSize = m_prescaleFactorsAlgoTrig->size();
1100  triggerMasksSet = m_triggerMaskAlgoTrig;
1101 
1102  }
1103 
1104  } else {
1105  // L1 trigger configuration from event setup only
1106  pfSetsSize = m_prescaleFactorsAlgoTrig->size();
1107  triggerMasksSet = m_triggerMaskAlgoTrig;
1108 
1109  }
1110 
1111  pfIndex = pfIndexAlgoTrig;
1112 
1113  }
1114  break;
1115  case TechnicalTrigger: {
1117  if (m_l1GtMenuLiteValid) {
1118  pfSetsSize = m_prescaleFactorsTechTrigLite->size();
1119  triggerMasksSet = m_triggerMaskTechTrigLite;
1120 
1121  } else {
1122  // fall through: L1 trigger configuration from event setup
1123  pfSetsSize = m_prescaleFactorsTechTrig->size();
1124  triggerMasksSet = m_triggerMaskTechTrig;
1125 
1126  }
1127 
1128  } else {
1129  // L1 trigger configuration from event setup only
1130  pfSetsSize = m_prescaleFactorsTechTrig->size();
1131  triggerMasksSet = m_triggerMaskTechTrig;
1132 
1133  }
1134 
1135  pfIndex = pfIndexTechTrig;
1136 
1137  }
1138  break;
1139  default: {
1140  // should not be the case
1141  iError = l1ConfCode + iErrorRecord + 3;
1142  return iError;
1143 
1144  }
1145  break;
1146  }
1147 
1148 
1149  // test prescale factor set index correctness, then retrieve the actual set of prescale factors
1150 
1151  if (pfIndex < 0) {
1152 
1153  iError = l1ConfCode + iErrorRecord + 1000;
1154  LogDebug("L1GtUtils")
1155  << "\nError: index of prescale factor set retrieved from the data \n"
1156  << "less than zero."
1157  << "\n Value of index retrieved from data = " << pfIndex
1158  << std::endl;
1159 
1160  return iError;
1161 
1162  } else if (pfIndex >= (static_cast<int>(pfSetsSize))) {
1163  iError = l1ConfCode + iErrorRecord + 2000;
1164  LogDebug("L1GtUtils")
1165  << "\nError: index of prescale factor set retrieved from the data \n"
1166  << "greater than the size of the vector of prescale factor sets."
1167  << "\n Value of index retrieved from data = " << pfIndex
1168  << "\n Vector size = " << pfSetsSize << std::endl;
1169 
1170  return iError;
1171 
1172  } else {
1173  switch (trigCategory) {
1174  case AlgorithmTrigger: {
1176  if (m_l1GtMenuLiteValid) {
1177  prescaleFactorsSubset
1178  = &((*m_prescaleFactorsAlgoTrigLite).at(pfIndex));
1179 
1180  } else {
1181  // fall through: L1 trigger configuration from event setup
1182  prescaleFactorsSubset
1183  = &((*m_prescaleFactorsAlgoTrig).at(pfIndex));
1184 
1185  }
1186 
1187  } else {
1188  // L1 trigger configuration from event setup only
1189  prescaleFactorsSubset
1190  = &((*m_prescaleFactorsAlgoTrig).at(pfIndex));
1191 
1192  }
1193 
1194  }
1195  break;
1196  case TechnicalTrigger: {
1198  if (m_l1GtMenuLiteValid) {
1199  prescaleFactorsSubset
1200  = &((*m_prescaleFactorsTechTrigLite).at(pfIndex));
1201 
1202  } else {
1203  // fall through: L1 trigger configuration from event setup
1204  prescaleFactorsSubset
1205  = &((*m_prescaleFactorsTechTrig).at(pfIndex));
1206 
1207  }
1208 
1209  } else {
1210  // L1 trigger configuration from event setup only
1211  prescaleFactorsSubset
1212  = &((*m_prescaleFactorsTechTrig).at(pfIndex));
1213 
1214  }
1215 
1216  }
1217  break;
1218  default: {
1219  // do nothing - it was tested before, with return
1220 
1221  }
1222  break;
1223  }
1224 
1225  }
1226 
1227 
1228  // algorithm result before applying the trigger masks
1229  // the bit number is positive (tested previously)
1230 
1231  switch (trigCategory) {
1232  case AlgorithmTrigger: {
1233  if (gtReadoutRecordValid) {
1234  const DecisionWord& decWord = gtReadoutRecord->decisionWord();
1235  decisionBeforeMask = trigResult(decWord, bitNumber,
1236  nameAlgoTechTrig, trigCategory, iError);
1237  if (iError) {
1238  return (iError + l1ConfCode + iErrorRecord);
1239  }
1240 
1241  } else {
1242 
1243  const DecisionWord& decWord =
1244  gtRecord->decisionWordBeforeMask();
1245  decisionBeforeMask = trigResult(decWord, bitNumber,
1246  nameAlgoTechTrig, trigCategory, iError);
1247  if (iError) {
1248  return (iError + l1ConfCode + iErrorRecord);
1249  }
1250 
1251  }
1252 
1253  }
1254  break;
1255  case TechnicalTrigger: {
1256  if (gtReadoutRecordValid) {
1257  const DecisionWord& decWord =
1258  gtReadoutRecord->technicalTriggerWord();
1259  decisionBeforeMask = trigResult(decWord, bitNumber,
1260  nameAlgoTechTrig, trigCategory, iError);
1261  if (iError) {
1262  return (iError + l1ConfCode + iErrorRecord);
1263  }
1264 
1265  } else {
1266 
1267  const DecisionWord& decWord =
1268  gtRecord->technicalTriggerWordBeforeMask();
1269  decisionBeforeMask = trigResult(decWord, bitNumber,
1270  nameAlgoTechTrig, trigCategory, iError);
1271  if (iError) {
1272  return (iError + l1ConfCode + iErrorRecord);
1273  }
1274 
1275  }
1276 
1277  }
1278  break;
1279  default: {
1280  // do nothing - it was tested before, with return
1281 
1282  }
1283  break;
1284  }
1285 
1286  // prescale factor
1287  // the bit number is positive (tested previously)
1288 
1289  if (bitNumber < (static_cast<int> (prescaleFactorsSubset->size()))) {
1290  prescaleFactor = (*prescaleFactorsSubset)[bitNumber];
1291  } else {
1292  iError = l1ConfCode + iErrorRecord + 4000;
1293  LogDebug("L1GtUtils") << "\nError: bit number " << bitNumber
1294  << " retrieved for " << triggerCategory(trigCategory) << "\n "
1295  << nameAlgoTechTrig
1296  << "\ngreater than size of actual L1 GT prescale factor set: "
1297  << prescaleFactorsSubset->size()
1298  << "\nError: Inconsistent L1 trigger configuration!"
1299  << std::endl;
1300 
1301  return iError;
1302  }
1303 
1304  // trigger mask and trigger result after applying the trigger masks
1305 
1306  if (bitNumber < (static_cast<int> ((*triggerMasksSet).size()))) {
1307 
1309  if (m_l1GtMenuLiteValid) {
1310  triggerMask = (*triggerMasksSet)[bitNumber];
1311 
1312  } else {
1313  // fall through: L1 trigger configuration from event setup
1314  // masks in event setup are for all partitions
1315  triggerMask = ((*triggerMasksSet)[bitNumber]) & (1
1317 
1318  }
1319 
1320  } else {
1321  // L1 trigger configuration from event setup only
1322  // masks in event setup are for all partitions
1323  triggerMask = ((*triggerMasksSet)[bitNumber]) & (1
1325 
1326  }
1327 
1328 
1329  } else {
1330  iError = l1ConfCode + iErrorRecord + 5000;
1331  LogDebug("L1GtUtils") << "\nError: bit number " << bitNumber
1332  << " retrieved for " << triggerCategory(trigCategory) << "\n "
1333  << nameAlgoTechTrig
1334  << "\ngreater than size of L1 GT trigger mask set: "
1335  << (*triggerMasksSet).size()
1336  << "\nError: Inconsistent L1 trigger configuration!"
1337  << std::endl;
1338 
1339  return iError;
1340 
1341  }
1342 
1343  decisionAfterMask = decisionBeforeMask;
1344 
1345  if (triggerMask) {
1346  decisionAfterMask = false;
1347  }
1348 
1349  return iError;
1350 
1351 }
1352 
1353 
1355  const std::string& nameAlgoTechTrig, bool& decisionBeforeMask,
1356  bool& decisionAfterMask, int& prescaleFactor, int& triggerMask) const {
1357 
1358  // initial values for returned results
1359  decisionBeforeMask = false;
1360  decisionAfterMask = false;
1361  prescaleFactor = -1;
1362  triggerMask = -1;
1363 
1364  int l1ErrorCode = 0;
1365 
1366  l1ErrorCode = l1Results(iEvent, m_provL1GtRecordInputTag,
1367  m_provL1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
1368  decisionAfterMask, prescaleFactor, triggerMask);
1369 
1370  return l1ErrorCode;
1371 
1372 }
1373 
1374 //
1375 
1377  const edm::InputTag& l1GtRecordInputTag,
1378  const edm::InputTag& l1GtReadoutRecordInputTag,
1379  const std::string& nameAlgoTechTrig, int& errorCode) const {
1380 
1381  // initial values
1382  bool decisionBeforeMask = false;
1383  bool decisionAfterMask = false;
1384  int prescaleFactor = -1;
1385  int triggerMask = -1;
1386 
1387  errorCode = l1Results(iEvent, l1GtRecordInputTag,
1388  l1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
1389  decisionAfterMask, prescaleFactor, triggerMask);
1390 
1391  return decisionBeforeMask;
1392 
1393 }
1394 
1396  const std::string& nameAlgoTechTrig, int& errorCode) const {
1397 
1398  // initial values
1399  bool decisionBeforeMask = false;
1400  bool decisionAfterMask = false;
1401  int prescaleFactor = -1;
1402  int triggerMask = -1;
1403 
1404  errorCode = l1Results(iEvent, nameAlgoTechTrig, decisionBeforeMask,
1405  decisionAfterMask, prescaleFactor, triggerMask);
1406 
1407  return decisionBeforeMask;
1408 
1409 }
1410 
1411 //
1412 
1414  const edm::InputTag& l1GtRecordInputTag,
1415  const edm::InputTag& l1GtReadoutRecordInputTag,
1416  const std::string& nameAlgoTechTrig, int& errorCode) const {
1417 
1418  // initial values
1419  bool decisionBeforeMask = false;
1420  bool decisionAfterMask = false;
1421  int prescaleFactor = -1;
1422  int triggerMask = -1;
1423 
1424  errorCode = l1Results(iEvent, l1GtRecordInputTag,
1425  l1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
1426  decisionAfterMask, prescaleFactor, triggerMask);
1427 
1428  return decisionAfterMask;
1429 
1430 }
1431 
1433  const std::string& nameAlgoTechTrig, int& errorCode) const {
1434 
1435  // initial values
1436  bool decisionBeforeMask = false;
1437  bool decisionAfterMask = false;
1438  int prescaleFactor = -1;
1439  int triggerMask = -1;
1440 
1441  errorCode = l1Results(iEvent, nameAlgoTechTrig, decisionBeforeMask,
1442  decisionAfterMask, prescaleFactor, triggerMask);
1443 
1444  return decisionAfterMask;
1445 
1446 }
1447 
1448 //
1449 
1451  const edm::InputTag& l1GtRecordInputTag,
1452  const edm::InputTag& l1GtReadoutRecordInputTag,
1453  const std::string& nameAlgoTechTrig, int& errorCode) const {
1454 
1455  // initial values
1456  bool decisionBeforeMask = false;
1457  bool decisionAfterMask = false;
1458  int prescaleFactor = -1;
1459  int triggerMask = -1;
1460 
1461  errorCode = l1Results(iEvent, l1GtRecordInputTag,
1462  l1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
1463  decisionAfterMask, prescaleFactor, triggerMask);
1464 
1465  return decisionAfterMask;
1466 
1467 }
1468 
1470  const std::string& nameAlgoTechTrig, int& errorCode) const {
1471 
1472  // initial values
1473  bool decisionBeforeMask = false;
1474  bool decisionAfterMask = false;
1475  int prescaleFactor = -1;
1476  int triggerMask = -1;
1477 
1478  errorCode = l1Results(iEvent, nameAlgoTechTrig, decisionBeforeMask,
1479  decisionAfterMask, prescaleFactor, triggerMask);
1480 
1481  return decisionAfterMask;
1482 
1483 }
1484 
1485 //
1486 
1488  const edm::InputTag& l1GtRecordInputTag,
1489  const edm::InputTag& l1GtReadoutRecordInputTag,
1490  const std::string& nameAlgoTechTrig, int& errorCode) const {
1491 
1492  // initial values
1493  bool decisionBeforeMask = false;
1494  bool decisionAfterMask = false;
1495  int prescaleFactor = -1;
1496  int triggerMask = -1;
1497 
1498  errorCode = l1Results(iEvent, l1GtRecordInputTag,
1499  l1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
1500  decisionAfterMask, prescaleFactor, triggerMask);
1501 
1502  return prescaleFactor;
1503 
1504 }
1505 
1507  const std::string& nameAlgoTechTrig, int& errorCode) const {
1508 
1509  // initial values
1510  bool decisionBeforeMask = false;
1511  bool decisionAfterMask = false;
1512  int prescaleFactor = -1;
1513  int triggerMask = -1;
1514 
1515  errorCode = l1Results(iEvent, nameAlgoTechTrig, decisionBeforeMask,
1516  decisionAfterMask, prescaleFactor, triggerMask);
1517 
1518  return prescaleFactor;
1519 
1520 }
1521 
1523  const edm::InputTag& l1GtRecordInputTag,
1524  const edm::InputTag& l1GtReadoutRecordInputTag,
1525  const std::string& nameAlgoTechTrig, int& errorCode) const {
1526 
1527  // initial values
1528  bool decisionBeforeMask = false;
1529  bool decisionAfterMask = false;
1530  int prescaleFactor = -1;
1531  int triggerMask = -1;
1532 
1533  errorCode = l1Results(iEvent, l1GtRecordInputTag,
1534  l1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
1535  decisionAfterMask, prescaleFactor, triggerMask);
1536 
1537  return triggerMask;
1538 
1539 }
1540 
1542  const std::string& nameAlgoTechTrig, int& errorCode) const {
1543 
1544  // initial values
1545  bool decisionBeforeMask = false;
1546  bool decisionAfterMask = false;
1547  int prescaleFactor = -1;
1548  int triggerMask = -1;
1549 
1550  errorCode = l1Results(iEvent, nameAlgoTechTrig, decisionBeforeMask,
1551  decisionAfterMask, prescaleFactor, triggerMask);
1552 
1553  return triggerMask;
1554 
1555 }
1556 
1557 const int L1GtUtils::triggerMask(const std::string& nameAlgoTechTrig,
1558  int& errorCode) const {
1559 
1560  // initial values for returned results
1561  int triggerMaskValue = -1;
1562 
1563  // initialize error code and L1 configuration code
1564  int iError = 0;
1565  int l1ConfCode = 0;
1566 
1567  // check if L1 configuration is available
1568 
1569  if (!availableL1Configuration(iError, l1ConfCode)) {
1570  errorCode = iError;
1571  return triggerMaskValue;
1572  }
1573 
1574  // at this point, a valid L1 configuration is available, so the if/else if/else
1575  // can be simplified
1576 
1577  // if the given name is not an algorithm trigger alias, an algorithm trigger name
1578  // or a technical trigger in the current menu, return with error code 1
1579 
1580  TriggerCategory trigCategory = AlgorithmTrigger;
1581  int bitNumber = -1;
1582 
1583  if (!l1AlgoTechTrigBitNumber(nameAlgoTechTrig, trigCategory, bitNumber)) {
1584 
1585  iError = l1ConfCode + 1;
1586 
1588  if (m_l1GtMenuLiteValid) {
1589 
1590  LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
1591  << nameAlgoTechTrig
1592  << "\not found in the trigger menu \n "
1594  << "\nretrieved from L1GtTriggerMenuLite" << std::endl;
1595 
1596  } else {
1597 
1598  // fall through: L1 trigger configuration from event setup
1599  LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
1600  << nameAlgoTechTrig
1601  << "\not found in the trigger menu \n "
1603  << "\nretrieved from Event Setup" << std::endl;
1604 
1605  }
1606 
1607  } else {
1608  // L1 trigger configuration from event setup only
1609  LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
1610  << nameAlgoTechTrig
1611  << "\not found in the trigger menu \n "
1613  << "\nretrieved from Event Setup" << std::endl;
1614 
1615  }
1616 
1617  errorCode = iError;
1618  return triggerMaskValue;
1619 
1620  }
1621 
1622  // check here if a positive bit number was retrieved
1623  // exit in case of negative bit number, before retrieving L1 GT products, saving time
1624 
1625  if (bitNumber < 0) {
1626 
1627  iError = l1ConfCode + 2;
1628 
1630  if (m_l1GtMenuLiteValid) {
1631  LogDebug("L1GtUtils") << "\nNegative bit number for "
1632  << triggerCategory(trigCategory) << "\n "
1633  << nameAlgoTechTrig << "\nfrom menu \n "
1635  << "\nretrieved from L1GtTriggerMenuLite" << std::endl;
1636 
1637  } else {
1638  // fall through: L1 trigger configuration from event setup
1639  LogDebug("L1GtUtils") << "\nNegative bit number for "
1640  << triggerCategory(trigCategory) << "\n "
1641  << nameAlgoTechTrig << "\nfrom menu \n "
1643  << "\nretrieved from Event Setup" << std::endl;
1644 
1645  }
1646 
1647  } else {
1648  // L1 trigger configuration from event setup only
1649  LogDebug("L1GtUtils") << "\nNegative bit number for "
1650  << triggerCategory(trigCategory) << "\n "
1651  << nameAlgoTechTrig << "\nfrom menu \n "
1653  << "\nretrieved from Event Setup" << std::endl;
1654 
1655  }
1656 
1657  errorCode = iError;
1658  return triggerMaskValue;
1659  }
1660 
1661  // depending on trigger category (algorithm trigger or technical trigger)
1662  // get the correct quantities
1663 
1664  // pointer to the set of trigger masks
1665 
1666  const std::vector<unsigned int>* triggerMasksSet = 0;
1667 
1668  switch (trigCategory) {
1669  case AlgorithmTrigger: {
1671  if (m_l1GtMenuLiteValid) {
1672  triggerMasksSet = m_triggerMaskAlgoTrigLite;
1673 
1674  } else {
1675  // fall through: L1 trigger configuration from event setup
1676  triggerMasksSet = m_triggerMaskAlgoTrig;
1677 
1678  }
1679 
1680  } else {
1681  // L1 trigger configuration from event setup only
1682  triggerMasksSet = m_triggerMaskAlgoTrig;
1683 
1684  }
1685 
1686  }
1687  break;
1688  case TechnicalTrigger: {
1690  if (m_l1GtMenuLiteValid) {
1691  triggerMasksSet = m_triggerMaskTechTrigLite;
1692 
1693  } else {
1694  // fall through: L1 trigger configuration from event setup
1695  triggerMasksSet = m_triggerMaskTechTrig;
1696 
1697  }
1698 
1699  } else {
1700  // L1 trigger configuration from event setup only
1701  triggerMasksSet = m_triggerMaskTechTrig;
1702 
1703  }
1704 
1705  }
1706  break;
1707  default: {
1708  // should not be the case
1709  iError = l1ConfCode + 3;
1710 
1711  errorCode = iError;
1712  return triggerMaskValue;
1713 
1714  }
1715  break;
1716  }
1717 
1718  // trigger mask
1719 
1720  if (bitNumber < (static_cast<int> ((*triggerMasksSet).size()))) {
1721 
1723  if (m_l1GtMenuLiteValid) {
1724  triggerMaskValue = (*triggerMasksSet)[bitNumber];
1725 
1726  } else {
1727  // fall through: L1 trigger configuration from event setup
1728  // masks in event setup are for all partitions
1729  triggerMaskValue = ((*triggerMasksSet)[bitNumber]) & (1
1731 
1732  }
1733 
1734  } else {
1735  // L1 trigger configuration from event setup only
1736  // masks in event setup are for all partitions
1737  triggerMaskValue = ((*triggerMasksSet)[bitNumber]) & (1
1739 
1740  }
1741 
1742  } else {
1743  iError = l1ConfCode + 5000;
1744  LogDebug("L1GtUtils") << "\nError: bit number " << bitNumber
1745  << " retrieved for " << triggerCategory(trigCategory) << "\n "
1746  << nameAlgoTechTrig
1747  << "\ngreater than size of L1 GT trigger mask set: "
1748  << (*triggerMasksSet).size()
1749  << "\nError: Inconsistent L1 trigger configuration!"
1750  << std::endl;
1751 
1752  errorCode = iError;
1753  return triggerMaskValue;
1754 
1755  }
1756 
1757  errorCode = iError;
1758  return triggerMaskValue;
1759 
1760 }
1761 
1763  const edm::InputTag& l1GtRecordInputTag,
1764  const edm::InputTag& l1GtReadoutRecordInputTag,
1765  const TriggerCategory& trigCategory, int& errorCode) const {
1766 
1767  // initialize the index to a negative value
1768  int pfIndex = -1;
1769 
1770  // initialize error code and L1 configuration code
1771  int iError = 0;
1772  int l1ConfCode = 0;
1773 
1774  // check if L1 configuration is available
1775 
1776  if (!availableL1Configuration(iError, l1ConfCode)) {
1777  errorCode = iError;
1778  return pfIndex;
1779  }
1780 
1781  // at this point, a valid L1 configuration is available, so the if/else if/else
1782  // can be simplified
1783 
1784  // retrieve L1GlobalTriggerRecord and 1GlobalTriggerReadoutRecord product
1785  // intermediate error code for the records
1786  // the module returns an error code only if both the lite and the readout record are missing
1787 
1788  int iErrorRecord = 0;
1789 
1790  bool validRecord = false;
1791  bool gtReadoutRecordValid = false;
1792 
1794  iEvent.getByLabel(l1GtRecordInputTag, gtRecord);
1795 
1796  if (gtRecord.isValid()) {
1797 
1798  validRecord = true;
1799 
1800  } else {
1801 
1802  iErrorRecord = 10;
1803  LogDebug("L1GtUtils") << "\nL1GlobalTriggerRecord with \n "
1804  << l1GtRecordInputTag << "\nnot found in the event."
1805  << std::endl;
1806  }
1807 
1809  iEvent.getByLabel(l1GtReadoutRecordInputTag, gtReadoutRecord);
1810 
1811  if (gtReadoutRecord.isValid()) {
1812 
1813  gtReadoutRecordValid = true;
1814  validRecord = true;
1815 
1816  } else {
1817 
1818  iErrorRecord = iErrorRecord + 100;
1819  LogDebug("L1GtUtils") << "\nL1GlobalTriggerReadoutRecord with \n "
1820  << l1GtReadoutRecordInputTag << "\nnot found in the event."
1821  << std::endl;
1822 
1823  }
1824 
1825  // get the prescale factor index from
1826  // L1GlobalTriggerReadoutRecord if valid
1827  // if not, from L1GlobalTriggerRecord if valid
1828  // else return an error
1829 
1830 
1831  int pfIndexTechTrig = -1;
1832  int pfIndexAlgoTrig = -1;
1833 
1834  if (validRecord) {
1835  if (gtReadoutRecordValid) {
1836 
1837  pfIndexTechTrig
1838  = (gtReadoutRecord->gtFdlWord()).gtPrescaleFactorIndexTech();
1839  pfIndexAlgoTrig
1840  = (gtReadoutRecord->gtFdlWord()).gtPrescaleFactorIndexAlgo();
1841 
1842  } else {
1843 
1844  pfIndexTechTrig
1845  = static_cast<int> (gtRecord->gtPrescaleFactorIndexTech());
1846  pfIndexAlgoTrig
1847  = static_cast<int> (gtRecord->gtPrescaleFactorIndexAlgo());
1848 
1849  }
1850 
1851  } else {
1852 
1853  LogDebug("L1GtUtils") << "\nError: "
1854  << "\nNo valid L1GlobalTriggerRecord with \n "
1855  << l1GtRecordInputTag << "\nfound in the event."
1856  << "\nNo valid L1GlobalTriggerReadoutRecord with \n "
1857  << l1GtReadoutRecordInputTag << "\nfound in the event."
1858  << std::endl;
1859 
1860  iError = l1ConfCode + iErrorRecord;
1861 
1862  errorCode = iError;
1863  return pfIndex;
1864 
1865  }
1866 
1867  // depending on trigger category (algorithm trigger or technical trigger)
1868  // get the correct quantities
1869 
1870  // number of sets of prescale factors
1871  // index of prescale factor set retrieved from data
1872  // pointer to the actual prescale factor set
1873  // pointer to the set of trigger masks
1874 
1875  size_t pfSetsSize = 0;
1876 
1877  switch (trigCategory) {
1878  case AlgorithmTrigger: {
1880  if (m_l1GtMenuLiteValid) {
1881  pfSetsSize = m_prescaleFactorsAlgoTrigLite->size();
1882 
1883  } else {
1884  // fall through: L1 trigger configuration from event setup
1885  pfSetsSize = m_prescaleFactorsAlgoTrig->size();
1886 
1887  }
1888 
1889  } else {
1890  // L1 trigger configuration from event setup only
1891  pfSetsSize = m_prescaleFactorsAlgoTrig->size();
1892 
1893  }
1894 
1895  pfIndex = pfIndexAlgoTrig;
1896 
1897  }
1898  break;
1899  case TechnicalTrigger: {
1901  if (m_l1GtMenuLiteValid) {
1902  pfSetsSize = m_prescaleFactorsTechTrigLite->size();
1903 
1904  } else {
1905  // fall through: L1 trigger configuration from event setup
1906  pfSetsSize = m_prescaleFactorsTechTrig->size();
1907 
1908  }
1909 
1910  } else {
1911  // L1 trigger configuration from event setup only
1912  pfSetsSize = m_prescaleFactorsTechTrig->size();
1913 
1914  }
1915 
1916  pfIndex = pfIndexTechTrig;
1917 
1918  }
1919  break;
1920  default: {
1921  // should not be the case
1922  iError = l1ConfCode + iErrorRecord + 3;
1923  return iError;
1924 
1925  }
1926  break;
1927  }
1928 
1929 
1930  // test prescale factor set index correctness, then retrieve the actual set of prescale factors
1931 
1932  if (pfIndex < 0) {
1933 
1934  iError = l1ConfCode + iErrorRecord + 1000;
1935  LogDebug("L1GtUtils")
1936  << "\nError: index of prescale factor set retrieved from the data \n"
1937  << "less than zero."
1938  << "\n Value of index retrieved from data = " << pfIndex
1939  << std::endl;
1940 
1941  errorCode = iError;
1942  return pfIndex;
1943 
1944  } else if (pfIndex >= (static_cast<int>(pfSetsSize))) {
1945  iError = l1ConfCode + iErrorRecord + 2000;
1946  LogDebug("L1GtUtils")
1947  << "\nError: index of prescale factor set retrieved from the data \n"
1948  << "greater than the size of the vector of prescale factor sets."
1949  << "\n Value of index retrieved from data = " << pfIndex
1950  << "\n Vector size = " << pfSetsSize << std::endl;
1951 
1952  errorCode = iError;
1953  return pfIndex;
1954 
1955  } else {
1956 
1957  errorCode = iError;
1958  return pfIndex;
1959  }
1960 
1961  errorCode = iError;
1962  return pfIndex;
1963 
1964 }
1965 
1966 
1968  const TriggerCategory& trigCategory, int& errorCode) const {
1969 
1970  // initialize error code and return value
1971  int iError = 0;
1972  int pfIndex = -1;
1973 
1975  m_provL1GtReadoutRecordInputTag, trigCategory, iError);
1976 
1977  // return the error code and the index value
1978  // if the error code is 0, the index returned is -1
1979  errorCode = iError;
1980  return pfIndex;
1981 
1982 }
1983 
1984 
1985 
1986 const std::vector<int>& L1GtUtils::prescaleFactorSet(const edm::Event& iEvent,
1987  const edm::InputTag& l1GtRecordInputTag,
1988  const edm::InputTag& l1GtReadoutRecordInputTag,
1989  const TriggerCategory& trigCategory, int& errorCode) {
1990 
1991  // clear the vector before filling it
1992  m_prescaleFactorSet.clear();
1993 
1994  // initialize error code
1995  int iError = 0;
1996 
1997  const int pfIndex = prescaleFactorSetIndex(iEvent, l1GtRecordInputTag,
1998  l1GtReadoutRecordInputTag, trigCategory, iError);
1999 
2000  if (iError == 0) {
2001 
2002  switch (trigCategory) {
2003  case AlgorithmTrigger: {
2005  if (m_l1GtMenuLiteValid) {
2007  = (*m_prescaleFactorsAlgoTrigLite).at(pfIndex);
2008 
2009  } else {
2010  // fall through: L1 trigger configuration from event setup
2011  m_prescaleFactorSet = (*m_prescaleFactorsAlgoTrig).at(
2012  pfIndex);
2013 
2014  }
2015 
2016  } else {
2017  // L1 trigger configuration from event setup only
2018  m_prescaleFactorSet = (*m_prescaleFactorsAlgoTrig).at(
2019  pfIndex);
2020 
2021  }
2022 
2023  }
2024  break;
2025  case TechnicalTrigger: {
2027  if (m_l1GtMenuLiteValid) {
2029  = (*m_prescaleFactorsTechTrigLite).at(pfIndex);
2030 
2031  } else {
2032  // fall through: L1 trigger configuration from event setup
2033  m_prescaleFactorSet = (*m_prescaleFactorsTechTrig).at(
2034  pfIndex);
2035 
2036  }
2037 
2038  } else {
2039  // L1 trigger configuration from event setup only
2040  m_prescaleFactorSet = (*m_prescaleFactorsTechTrig).at(
2041  pfIndex);
2042 
2043  }
2044 
2045  }
2046  break;
2047  default: {
2048  // do nothing - it was tested before, with return
2049 
2050  }
2051  break;
2052  }
2053 
2054  }
2055 
2056  errorCode = iError;
2057  return m_prescaleFactorSet;
2058 
2059 }
2060 
2061 const std::vector<int>& L1GtUtils::prescaleFactorSet(const edm::Event& iEvent,
2062  const TriggerCategory& trigCategory, int& errorCode) {
2063 
2064  // clear the vector before filling it
2065  m_prescaleFactorSet.clear();
2066 
2067  // initialize error code
2068  int iError = 0;
2069 
2071  m_provL1GtReadoutRecordInputTag, trigCategory, iError);
2072 
2073  errorCode = iError;
2074  return m_prescaleFactorSet;
2075 
2076 }
2077 
2078 
2079 
2080 
2081 const std::vector<unsigned int>& L1GtUtils::triggerMaskSet(
2082  const TriggerCategory& trigCategory, int& errorCode) {
2083 
2084  // clear the vector before filling it
2085  m_triggerMaskSet.clear();
2086 
2087  // initialize error code and L1 configuration code
2088  int iError = 0;
2089  int l1ConfCode = 0;
2090 
2091  // check if L1 configuration is available
2092 
2093  if (!availableL1Configuration(iError, l1ConfCode)) {
2094  errorCode = iError;
2095  return m_triggerMaskSet;
2096  }
2097 
2098  // at this point, a valid L1 configuration is available, so the if/else if/else
2099  // can be simplified
2100 
2101 
2102  // depending on trigger category (algorithm trigger or technical trigger)
2103  // get the correct quantities
2104 
2105  // pointer to the set of trigger masks
2106 
2107  switch (trigCategory) {
2108  case AlgorithmTrigger: {
2110  // L1GtTriggerMenuLite has masks for physics partition only
2111  // avoid copy to m_triggerMaskSet, return directly m_triggerMaskAlgoTrigLite
2112  if (m_l1GtMenuLiteValid) {
2113  errorCode = iError;
2114  return (*m_triggerMaskAlgoTrigLite);
2115 
2116  } else {
2117  // fall through: L1 trigger configuration from event setup
2118  for (unsigned i = 0; i < m_triggerMaskAlgoTrig->size(); i++) {
2119  m_triggerMaskSet.push_back(
2120  ((*m_triggerMaskAlgoTrig)[i]) & (1
2121  << m_physicsDaqPartition));
2122  }
2123 
2124  }
2125 
2126  } else {
2127  // L1 trigger configuration from event setup only
2128  for (unsigned i = 0; i < m_triggerMaskAlgoTrig->size(); i++) {
2129  m_triggerMaskSet.push_back(((*m_triggerMaskAlgoTrig)[i])
2130  & (1 << m_physicsDaqPartition));
2131  }
2132 
2133  }
2134  }
2135  break;
2136  case TechnicalTrigger: {
2138  if (m_l1GtMenuLiteValid) {
2139  errorCode = iError;
2140  return (*m_triggerMaskTechTrigLite);
2141 
2142  } else {
2143  // fall through: L1 trigger configuration from event setup
2144  for (unsigned i = 0; i < m_triggerMaskTechTrig->size(); i++) {
2145  m_triggerMaskSet.push_back(
2146  ((*m_triggerMaskTechTrig)[i]) & (1
2147  << m_physicsDaqPartition));
2148  }
2149 
2150  }
2151 
2152  } else {
2153  // L1 trigger configuration from event setup only
2154  for (unsigned i = 0; i < m_triggerMaskTechTrig->size(); i++) {
2155  m_triggerMaskSet.push_back(((*m_triggerMaskTechTrig)[i])
2156  & (1 << m_physicsDaqPartition));
2157  }
2158 
2159  }
2160  }
2161  break;
2162  default: {
2163  // should not be the case
2164  iError = l1ConfCode + 3;
2165 
2166  errorCode = iError;
2167  return m_triggerMaskSet;
2168 
2169  }
2170  break;
2171  }
2172 
2173  errorCode = iError;
2174  return m_triggerMaskSet;
2175 
2176 }
2177 
2178 
2179 
2180 const std::string& L1GtUtils::l1TriggerMenu() const {
2181 
2183  if (m_l1GtMenuLiteValid) {
2185 
2186  } else if (m_retrieveL1EventSetup) {
2187  return m_l1GtMenu->gtTriggerMenuName();
2188 
2189  } else {
2190  // only L1GtTriggerMenuLite requested, but it is not valid
2191  return EmptyString;
2192 
2193  }
2194  } else if (m_retrieveL1EventSetup) {
2195  return m_l1GtMenu->gtTriggerMenuName();
2196 
2197  } else {
2198  // L1 trigger configuration not retrieved
2199  return EmptyString;
2200 
2201  }
2202 
2203 }
2204 
2205 const std::string& L1GtUtils::l1TriggerMenuImplementation() const {
2206 
2208  if (m_l1GtMenuLiteValid) {
2210 
2211  } else if (m_retrieveL1EventSetup) {
2213 
2214  } else {
2215  // only L1GtTriggerMenuLite requested, but it is not valid
2216  return EmptyString;
2217 
2218  }
2219  } else if (m_retrieveL1EventSetup) {
2221 
2222  } else {
2223  // L1 trigger configuration not retrieved
2224  return EmptyString;
2225 
2226  }
2227 
2228 }
2229 
2231 
2232  // initialize error code and return value
2233  int iError = 0;
2234  int l1ConfCode = 0;
2235 
2236  // check if L1 configuration is available
2237 
2238  if (!availableL1Configuration(iError, l1ConfCode)) {
2239  errorCode = iError;
2240  return 0;
2241  }
2242 
2243  if (m_retrieveL1EventSetup) {
2244  errorCode = iError;
2245  return m_l1GtMenu;
2246  } else {
2247  iError = l1ConfCode;
2248 
2249  errorCode = iError;
2250  return 0;
2251 
2252  }
2253 
2254  errorCode = iError;
2255  return m_l1GtMenu;
2256 }
2257 
2259 
2260  // initialize error code and return value
2261  int iError = 0;
2262  int l1ConfCode = 0;
2263 
2264  // check if L1 configuration is available
2265 
2266  if (!availableL1Configuration(iError, l1ConfCode)) {
2267  errorCode = iError;
2268  return 0;
2269  }
2270 
2272  if (m_l1GtMenuLiteValid) {
2273 
2274  errorCode = iError;
2275  return m_l1GtMenuLite;
2276 
2277  } else {
2278  iError = l1ConfCode;
2279 
2280  errorCode = iError;
2281  return 0;
2282  }
2283  } else {
2284  iError = l1ConfCode;
2285 
2286  errorCode = iError;
2287  return 0;
2288  }
2289 
2290  errorCode = iError;
2291  return m_l1GtMenuLite;
2292 
2293 }
2294 
2295 const bool L1GtUtils::availableL1Configuration(int& errorCode, int& l1ConfCode) const {
2296 
2298  if (!m_retrieveL1EventSetup) {
2299  LogDebug("L1GtUtils")
2300  << "\nRetrieve L1 trigger configuration from L1GtTriggerMenuLite only.\n"
2301  << std::endl;
2302  l1ConfCode = 0;
2303  } else {
2304  LogDebug("L1GtUtils")
2305  << "\nFall through: retrieve L1 trigger configuration from L1GtTriggerMenuLite."
2306  << "\nIf L1GtTriggerMenuLite not valid, try to retrieve from event setup.\n"
2307  << std::endl;
2308  l1ConfCode = 100000;
2309  }
2310 
2311  if (m_l1GtMenuLiteValid) {
2312  LogDebug("L1GtUtils")
2313  << "\nRetrieve L1 trigger configuration from L1GtTriggerMenuLite, valid product.\n"
2314  << std::endl;
2315  l1ConfCode = l1ConfCode + 10000;
2316  errorCode = 0;
2317 
2318  return true;
2319 
2320  } else if (m_retrieveL1EventSetup) {
2321  if (m_l1EventSetupValid) {
2322  LogDebug("L1GtUtils")
2323  << "\nFall through: retrieve L1 trigger configuration from event setup."
2324  << "\nFirst option was L1GtTriggerMenuLite - but product is not valid.\n"
2325  << std::endl;
2326  l1ConfCode = l1ConfCode + 20000;
2327  errorCode = 0;
2328 
2329  return true;
2330 
2331  } else {
2332  LogDebug("L1GtUtils")
2333  << "\nFall through: L1GtTriggerMenuLite not valid, event setup not valid.\n"
2334  << std::endl;
2335  l1ConfCode = l1ConfCode + L1GtNotValidError;
2336  errorCode = l1ConfCode;
2337 
2338  return false;
2339 
2340 
2341  }
2342 
2343  } else {
2344  LogDebug("L1GtUtils")
2345  << "\nError: L1 trigger configuration requested from L1GtTriggerMenuLite only"
2346  << "\nbut L1GtTriggerMenuLite is not valid.\n" << std::endl;
2347  l1ConfCode = l1ConfCode + L1GtNotValidError;
2348  errorCode = l1ConfCode;
2349 
2350  return false;
2351 
2352  }
2353  } else if (m_retrieveL1EventSetup) {
2354 
2355  LogDebug("L1GtUtils")
2356  << "\nRetrieve L1 trigger configuration from event setup."
2357  << "\nL1GtTriggerMenuLite product was not requested.\n"
2358  << std::endl;
2359  l1ConfCode = 200000;
2360 
2361  if (m_l1EventSetupValid) {
2362  LogDebug("L1GtUtils")
2363  << "\nRetrieve L1 trigger configuration from event setup only."
2364  << "\nValid L1 trigger event setup.\n"
2365  << std::endl;
2366  l1ConfCode = l1ConfCode + 10000;
2367  errorCode = 0;
2368 
2369  return true;
2370 
2371  } else {
2372  LogDebug("L1GtUtils")
2373  << "\nRetrieve L1 trigger configuration from event setup only."
2374  << "\nNo valid L1 trigger event setup.\n"
2375  << std::endl;
2376  l1ConfCode = l1ConfCode + L1GtNotValidError;
2377  errorCode = l1ConfCode;
2378 
2379  return false;
2380 
2381 
2382  }
2383 
2384  } else {
2385  LogDebug("L1GtUtils")
2386  << "\nError: no L1 trigger configuration requested to be retrieved."
2387  << "\nMust call before getL1GtRunCache in beginRun and analyze.\n"
2388  << std::endl;
2389  l1ConfCode = 300000;
2390  errorCode = l1ConfCode;
2391 
2392  return false;
2393 
2394  }
2395 }
2396 
2397 // private methods
2398 
2399 const bool L1GtUtils::trigResult(const DecisionWord& decWord,
2400  const int bitNumber, const std::string& nameAlgoTechTrig,
2401  const TriggerCategory& trigCategory, int& errorCode) const {
2402 
2403  bool trigRes = false;
2404  errorCode = 0;
2405 
2406  if (bitNumber < (static_cast<int> (decWord.size()))) {
2407  trigRes = decWord[bitNumber];
2408  } else {
2409  errorCode = 3000;
2410  LogDebug("L1GtUtils") << "\nError: bit number " << bitNumber
2411  << " retrieved for " << triggerCategory(trigCategory) << "\n "
2412  << nameAlgoTechTrig
2413  << "\ngreater than size of L1 GT decision word: "
2414  << decWord.size()
2415  << "\nError: Inconsistent L1 trigger configuration!"
2416  << std::endl;
2417  }
2418 
2419  return trigRes;
2420 }
2421 
2423  const std::string& expression, L1GtUtils& l1GtUtils) :
2424 
2425  m_logicalExpression(expression),
2426 
2427  m_l1GtUtils(l1GtUtils),
2428 
2429  m_l1GtRecordInputTag(edm::InputTag()),
2430 
2431  m_l1GtReadoutRecordInputTag(edm::InputTag()),
2432 
2433  m_l1ConfCode(-1),
2434 
2435  m_validL1Configuration(false),
2436 
2437  m_validLogicalExpression(false),
2438 
2439  m_l1GtInputTagsFromProv(true),
2440 
2441  m_l1ResultsAlreadyCalled(false),
2442 
2443  m_expL1TriggersSize(0),
2444 
2445  m_expBitsTechTrigger(false) {
2446 
2447  initialize();
2448 }
2449 
2451  const std::string& expression, L1GtUtils& l1GtUtils,
2452  const edm::InputTag& l1GtRecordInputTag,
2453  const edm::InputTag& l1GtReadoutRecordInputTag) :
2454 
2455  m_logicalExpression(expression),
2456 
2457  m_l1GtUtils(l1GtUtils),
2458 
2459  m_l1GtRecordInputTag(l1GtRecordInputTag),
2460 
2461  m_l1GtReadoutRecordInputTag(l1GtReadoutRecordInputTag),
2462 
2463  m_l1ConfCode(-1),
2464 
2465  m_validL1Configuration(false),
2466 
2467  m_validLogicalExpression(false),
2468 
2469  m_l1GtInputTagsFromProv(false),
2470 
2471  m_l1ResultsAlreadyCalled(false),
2472 
2473  m_expL1TriggersSize(0),
2474 
2475  m_expBitsTechTrigger(false) {
2476 
2477  initialize();
2478 }
2479 
2480 // destructor
2482 
2483  // empty
2484 
2485 }
2486 
2488 
2489  // get the vector of triggers corresponding to the logical expression
2490  // check also the logical expression - add/remove spaces if needed
2491 
2492  try {
2493 
2494  L1GtLogicParser m_l1AlgoLogicParser = L1GtLogicParser(
2495  m_logicalExpression);
2496 
2497  // list of L1 triggers from the logical expression
2498  m_expL1Triggers = m_l1AlgoLogicParser.operandTokenVector();
2499  m_expL1TriggersSize = m_expL1Triggers.size();
2500 
2501  m_validLogicalExpression = true;
2502 
2503  } catch (cms::Exception & ex) {
2504  m_validLogicalExpression = false;
2505 
2506  edm::LogWarning("L1GtUtils") << ex;
2507  edm::LogWarning("L1GtUtils") << ex.what();
2508  edm::LogWarning("L1GtUtils") << ex.explainSelf();
2509  }
2510 
2511  // try to convert the string representing each L1 trigger to bit number,
2512  // to check if the logical expression is constructed from bit numbers
2513  // trade-off: cache it here, irrespective of the expression
2514  // when the conversion fails (normally for the first seed,
2515  // if not expression of technical trigger bits), stop and
2516  // set m_expBitsTechTrigger to false
2517 
2518  m_expBitsTechTrigger = true;
2519 
2520  for (size_t iTrig = 0; iTrig < m_expL1TriggersSize; ++iTrig) {
2521  const std::string& bitString = (m_expL1Triggers[iTrig]).tokenName;
2522  std::istringstream bitStream(bitString);
2523  int bitInt;
2524 
2525  if ((bitStream >> bitInt).fail()) {
2526 
2527  m_expBitsTechTrigger = false;
2528 
2529  break;
2530  }
2531 
2532  (m_expL1Triggers[iTrig]).tokenNumber = bitInt;
2533 
2534  }
2535 
2536  // resize and fill
2537  m_decisionsBeforeMask.resize(m_expL1TriggersSize);
2538  m_decisionsAfterMask.resize(m_expL1TriggersSize);
2539  m_prescaleFactors.resize(m_expL1TriggersSize);
2540  m_triggerMasks.resize(m_expL1TriggersSize);
2541  m_errorCodes.resize(m_expL1TriggersSize);
2542  m_expTriggerCategory.resize(m_expL1TriggersSize);
2543  m_expTriggerInMenu.resize(m_expL1TriggersSize);
2544 
2545  LogDebug("L1GtUtils") << std::endl;
2546  LogTrace("L1GtUtils") << "\nLogical expression\n " << m_logicalExpression
2547  << "\n has " << m_expL1TriggersSize << " L1 triggers" << std::endl;
2548  for (size_t iTrig = 0; iTrig < m_expL1TriggersSize; ++iTrig) {
2549 
2550  const std::string& trigNameOrAlias = (m_expL1Triggers[iTrig]).tokenName;
2551  LogTrace("L1GtUtils") << " " << trigNameOrAlias << std::endl;
2552 
2553  (m_decisionsBeforeMask[iTrig]).first = trigNameOrAlias;
2554  (m_decisionsBeforeMask[iTrig]).second = false;
2555 
2556  (m_decisionsAfterMask[iTrig]).first = trigNameOrAlias;
2557  (m_decisionsAfterMask[iTrig]).second = false;
2558 
2559  (m_prescaleFactors[iTrig]).first = trigNameOrAlias;
2560  (m_prescaleFactors[iTrig]).second = -1;
2561 
2562  (m_triggerMasks[iTrig]).first = trigNameOrAlias;
2563  (m_triggerMasks[iTrig]).second = -1;
2564 
2565  (m_errorCodes[iTrig]).first = trigNameOrAlias;
2566  (m_errorCodes[iTrig]).second = -1;
2567 
2568  m_expTriggerCategory[iTrig] = L1GtUtils::AlgorithmTrigger;
2569 
2570  m_expTriggerInMenu[iTrig] = false;
2571 
2572  }
2573  LogTrace("L1GtUtils") << std::endl;
2574 
2575  return true;
2576 
2577 }
2578 
2579 
2581  const edm::Run& iRun, const edm::EventSetup& evSetup,
2582  const std::string& logicExpression) {
2583 
2584  // initialize error code
2585  int errorCode = 0;
2586 
2587  // logical expression has changed - one must re-initialize all quantities related to the logical expression
2588  // and clear the vectors
2589 
2590  m_logicalExpression = logicExpression;
2591  m_validLogicalExpression = false;
2592 
2593  m_l1ResultsAlreadyCalled = false;
2594 
2595  m_expL1TriggersSize = 0;
2596  m_expBitsTechTrigger = false;
2597 
2598  //
2599  m_decisionsBeforeMask.clear();
2600  m_decisionsAfterMask.clear();
2601  m_prescaleFactors.clear();
2602  m_triggerMasks.clear();
2603  m_errorCodes.clear();
2604  m_expTriggerCategory.clear();
2605  m_expTriggerInMenu.clear();
2606 
2607 
2608  initialize();
2609 
2610  //
2611  errorCode = logicalExpressionRunUpdate(iRun, evSetup);
2612 
2613  return errorCode;
2614 
2615 }
2616 
2617 
2619  const edm::Run& iRun, const edm::EventSetup& evSetup) {
2620 
2621  // check first that a valid L1 configuration was retrieved,
2622  // to prevent also calls before the L1 configuration retrieval
2623 
2624  // initialize error code and L1 configuration code
2625  int errorCode = 0;
2626  int l1ConfCode = 0;
2627 
2628  if (!(m_l1GtUtils.availableL1Configuration(errorCode, l1ConfCode))) {
2629 
2630  m_validL1Configuration = false;
2631  return errorCode;
2632  } else {
2633 
2634  m_validL1Configuration = true;
2635  m_l1ConfCode = l1ConfCode;
2636  }
2637 
2638  // check if the trigger (name of alias) from the logical expression are in the menu,
2639  // if names are used, set tokenNumber to the corresponding bit number
2640  // if technical trigger bits, set tokenName to the corresponding technical trigger name, if
2641  // a technical trigger exists on that bit
2642  // for each trigger, set also the trigger category
2643 
2644  // initialization
2646  int bitNumber = -1;
2647 
2648  for (size_t iTrig = 0; iTrig < m_expL1TriggersSize; ++iTrig) {
2649 
2650  trigCategory = L1GtUtils::AlgorithmTrigger;
2651  bitNumber = -1;
2652  const std::string& trigNameOrAlias = (m_expL1Triggers[iTrig]).tokenName;
2653 
2654  if (!m_expBitsTechTrigger) {
2655  const bool triggerInMenu = m_l1GtUtils.l1AlgoTechTrigBitNumber(
2656  trigNameOrAlias, trigCategory, bitNumber);
2657 
2658  (m_expL1Triggers[iTrig]).tokenNumber = bitNumber;
2659  m_expTriggerCategory[iTrig] = trigCategory;
2660  m_expTriggerInMenu[iTrig] = triggerInMenu;
2661 
2662  } else {
2663 
2664  std::string aliasL1Trigger;
2665  std::string nameL1Trigger;
2666 
2667  trigCategory = L1GtUtils::TechnicalTrigger;
2668  bitNumber = (m_expL1Triggers[iTrig]).tokenNumber;
2669 
2670  const bool triggerInMenu = m_l1GtUtils.l1TriggerNameFromBit(
2671  bitNumber, trigCategory, aliasL1Trigger, nameL1Trigger);
2672 
2673  if (!triggerInMenu) {
2674  aliasL1Trigger = "Technical_trigger_bit_"
2675  + (m_expL1Triggers[iTrig]).tokenName + "_empty";
2676  }
2677 
2678  (m_expL1Triggers[iTrig]).tokenName = aliasL1Trigger;
2679  m_expTriggerCategory[iTrig] = trigCategory;
2680  m_expTriggerInMenu[iTrig] = triggerInMenu;
2681 
2682  // put the names of the technical triggers in the returned quantities
2683 
2684  (m_decisionsBeforeMask[iTrig]).first = aliasL1Trigger;
2685  (m_decisionsAfterMask[iTrig]).first = aliasL1Trigger;
2686  (m_prescaleFactors[iTrig]).first = aliasL1Trigger;
2687  (m_triggerMasks[iTrig]).first = aliasL1Trigger;
2688  (m_errorCodes[iTrig]).first = aliasL1Trigger;
2689 
2690  }
2691  }
2692 
2693  return errorCode;
2694 
2695 }
2696 
2697 const std::vector<std::pair<std::string, bool> >& L1GtUtils::LogicalExpressionL1Results::decisionsBeforeMask() {
2698 
2699  // throw an exception if the result is not computed once per event - user usage error
2700  if (!m_l1ResultsAlreadyCalled) {
2701  throw cms::Exception("FailModule") << "\nUsage error: "
2702  << "\n Method 'errorCodes' must be called in the event loop before attempting to use this method.\n"
2703  << std::endl;
2704  }
2705 
2706  return m_decisionsBeforeMask;
2707 
2708 }
2709 
2710 const std::vector<std::pair<std::string, bool> >& L1GtUtils::LogicalExpressionL1Results::decisionsAfterMask() {
2711 
2712  // throw an exception if the result is not computed once per event - user usage error
2713  if (!m_l1ResultsAlreadyCalled) {
2714  throw cms::Exception("FailModule") << "\nUsage error: "
2715  << "\n Method 'errorCodes' must be called in the event loop before attempting to use this method.\n"
2716  << std::endl;
2717  }
2718 
2719  return m_decisionsAfterMask;
2720 
2721 }
2722 
2723 const std::vector<std::pair<std::string, int> >& L1GtUtils::LogicalExpressionL1Results::prescaleFactors() {
2724 
2725  // throw an exception if the result is not computed once per event - user usage error
2726  if (!m_l1ResultsAlreadyCalled) {
2727  throw cms::Exception("FailModule") << "\nUsage error: "
2728  << "\n Method 'errorCodes' must be called in the event loop before attempting to use this method.\n"
2729  << std::endl;
2730  }
2731 
2732  return m_prescaleFactors;
2733 
2734 }
2735 
2736 const std::vector<std::pair<std::string, int> >& L1GtUtils::LogicalExpressionL1Results::triggerMasks() {
2737 
2738  // throw an exception if the result is not computed once per event - user usage error
2739  if (!m_l1ResultsAlreadyCalled) {
2740  throw cms::Exception("FailModule") << "\nUsage error: "
2741  << "\n Method 'errorCodes' must be called in the event loop before attempting to use this method.\n"
2742  << std::endl;
2743  }
2744 
2745  return m_triggerMasks;
2746 
2747 }
2748 
2749 const std::vector<std::pair<std::string, int> >& L1GtUtils::LogicalExpressionL1Results::errorCodes(
2750  const edm::Event& iEvent) {
2751 
2752  m_l1ResultsAlreadyCalled = false;
2753 
2754  // if not a valid L1 configuration, reset all quantities and return
2755  if (!m_validL1Configuration) {
2756  reset(m_decisionsBeforeMask);
2757  reset(m_decisionsAfterMask);
2758  reset(m_prescaleFactors);
2759  reset(m_triggerMasks);
2760  reset(m_errorCodes);
2761 
2762  m_l1ResultsAlreadyCalled = true;
2763  return m_errorCodes;
2764 
2765  }
2766 
2767  if (m_l1GtInputTagsFromProv) {
2768 
2769  l1Results(iEvent, m_l1GtUtils.provL1GtRecordInputTag(),
2770  m_l1GtUtils.provL1GtReadoutRecordInputTag());
2771 
2772  } else {
2773 
2774  l1Results(iEvent, m_l1GtRecordInputTag, m_l1GtReadoutRecordInputTag);
2775  }
2776 
2777  m_l1ResultsAlreadyCalled = true;
2778 
2779  return m_errorCodes;
2780 
2781 }
2782 
2784  std::vector<std::pair<std::string, bool> > pairVector) const {
2785 
2786  for (size_t iTrig = 0; iTrig < m_expL1TriggersSize; ++iTrig) {
2787  (pairVector[iTrig]).second = false;
2788  }
2789 }
2790 
2792  std::vector<std::pair<std::string, int> > pairVector) const {
2793 
2794  for (size_t iTrig = 0; iTrig < m_expL1TriggersSize; ++iTrig) {
2795  (pairVector[iTrig]).second = -1;
2796  }
2797 }
2798 
2800  const edm::InputTag& l1GtRecordInputTag,
2801  const edm::InputTag& l1GtReadoutRecordInputTag) {
2802 
2803  // reset the vectors before filling them
2804  reset(m_decisionsBeforeMask);
2805  reset(m_decisionsAfterMask);
2806  reset(m_prescaleFactors);
2807  reset(m_triggerMasks);
2808  reset(m_errorCodes);
2809 
2810  // initialization of actual values for each trigger
2811  bool decisionBeforeMaskValue = false;
2812  bool decisionAfterMaskValue = false;
2813  int prescaleFactorValue = -1;
2814  int triggerMaskValue = -1;
2815  int errorCode = -1;
2816 
2817  LogDebug("L1GtUtils") << std::endl;
2818  LogTrace("L1GtUtils") << "\nLogical expression\n " << m_logicalExpression
2819  << std::endl;
2820 
2821  // for each trigger, if it is in the L1 menu, get the prescale factor and trigger mask
2822 
2823  for (size_t iTrig = 0; iTrig < m_expL1TriggersSize; ++iTrig) {
2824 
2825  const std::string& trigNameOrAlias = (m_expL1Triggers[iTrig]).tokenName;
2826 
2827  if (m_expTriggerInMenu[iTrig]) {
2828  errorCode = m_l1GtUtils.l1Results(iEvent, l1GtRecordInputTag,
2829  l1GtReadoutRecordInputTag, trigNameOrAlias,
2830  decisionBeforeMaskValue, decisionAfterMaskValue,
2831  prescaleFactorValue, triggerMaskValue);
2832 
2833  if (errorCode != 0) {
2834 
2835  // error while retrieving the results
2836  // for this trigger: set prescale factor to -1, trigger mask to -1
2837 
2838  decisionBeforeMaskValue = false;
2839  decisionAfterMaskValue = false;
2840  prescaleFactorValue = -1;
2841  triggerMaskValue = -1;
2842 
2843  }
2844 
2845  } else {
2846  // no trigger name or trigger alias in the menu, no bits:
2847  // for this trigger: set prescale factor to -1, set the error code
2848 
2849  decisionBeforeMaskValue = false;
2850  decisionAfterMaskValue = false;
2851  prescaleFactorValue = -1;
2852  triggerMaskValue = -1;
2853  errorCode = m_l1ConfCode + 1;
2854 
2855  }
2856 
2857  LogTrace("L1GtUtils") << "\n" << trigNameOrAlias << ":" << std::endl;
2858 
2859  (m_decisionsBeforeMask[iTrig]).second = decisionBeforeMaskValue;
2860  LogTrace("L1GtUtils") << " decision before mask = "
2861  << decisionBeforeMaskValue << std::endl;
2862 
2863  (m_decisionsAfterMask[iTrig]).second = decisionAfterMaskValue;
2864  LogTrace("L1GtUtils") << " decision after mask = "
2865  << decisionAfterMaskValue << std::endl;
2866 
2867  (m_prescaleFactors[iTrig]).second = prescaleFactorValue;
2868  LogTrace("L1GtUtils") << " prescale factor = "
2869  << prescaleFactorValue << std::endl;
2870 
2871  (m_triggerMasks[iTrig]).second = triggerMaskValue;
2872  LogTrace("L1GtUtils") << " trigger mask = "
2873  << triggerMaskValue << std::endl;
2874 
2875  (m_errorCodes[iTrig]).second = errorCode;
2876  LogTrace("L1GtUtils") << " error code = " << errorCode
2877  << std::endl;
2878 
2879  }
2880 
2881  LogDebug("L1GtUtils") << std::endl;
2882 
2883 }
2884 
2885 const std::string L1GtUtils::EmptyString = "";
2886 const int L1GtUtils::L1GtNotValidError = 99999;
2887 
#define LogDebug(id)
bool m_retrieveL1GtTriggerMenuLite
Definition: L1GtUtils.h:535
virtual char const * what() const
Definition: Exception.cc:141
edm::RunID m_runIDCache
run cache ID
Definition: L1GtUtils.h:521
const std::string & gtTriggerMenuName() const
EventNumber_t event() const
Definition: EventID.h:44
bool getByLabel(std::string const &label, Handle< PROD > &result) const
Definition: Run.h:177
void getAllProvenance(std::vector< Provenance const * > &provenances) const
Definition: Event.cc:70
int i
Definition: DBlmapReader.cc:9
const bool l1TriggerNameFromBit(const int &bitNumber, const TriggerCategory &trigCategory, std::string &aliasL1Trigger, std::string &nameL1Trigger) const
Definition: L1GtUtils.cc:677
const bool decisionAfterMask(const edm::Event &iEvent, const edm::InputTag &l1GtRecordInputTag, const edm::InputTag &l1GtReadoutRecordInputTag, const std::string &nameAlgoTechTrig, int &errorCode) const
return decision after trigger mask for a given algorithm or technical trigger
Definition: L1GtUtils.cc:1413
LogicalExpressionL1Results(const std::string &, L1GtUtils &)
constructor(s)
Definition: L1GtUtils.cc:2422
const int l1Results(const edm::Event &iEvent, const edm::InputTag &l1GtRecordInputTag, const edm::InputTag &l1GtReadoutRecordInputTag, const std::string &nameAlgoTechTrig, bool &decisionBeforeMask, bool &decisionAfterMask, int &prescaleFactor, int &triggerMask) const
Definition: L1GtUtils.cc:887
std::vector< unsigned int > m_triggerMaskSet
Definition: L1GtUtils.h:530
unsigned long long m_l1GtMenuCacheID
Definition: L1GtUtils.h:485
const std::vector< unsigned int > * m_triggerMaskAlgoTrig
Definition: L1GtUtils.h:477
static const bool useL1GtTriggerMenuLite(false)
const int logicalExpressionRunUpdate(const edm::Run &, const edm::EventSetup &, const std::string &)
Definition: L1GtUtils.cc:2580
edm::InputTag m_provL1GtReadoutRecordInputTag
Definition: L1GtUtils.h:517
void retrieveL1GtTriggerMenuLite(const edm::Run &, const edm::InputTag &)
retrieve L1GtTriggerMenuLite (per run product) and cache it to improve the speed
Definition: L1GtUtils.cc:271
const std::vector< unsigned int > & gtTriggerMaskAlgoTrig() const
get the trigger mask for physics algorithms
const L1GtTriggerMenuLite * ptrL1GtTriggerMenuLite(int &errorCode)
return a pointer to the L1GtTriggerMenuLite product
Definition: L1GtUtils.cc:2258
const std::vector< unsigned int > * m_triggerMaskTechTrig
Definition: L1GtUtils.h:478
void l1Results(const edm::Event &iEvent, const edm::InputTag &l1GtRecordInputTag, const edm::InputTag &l1GtReadoutRecordInputTag)
Definition: L1GtUtils.cc:2799
virtual std::string explainSelf() const
Definition: Exception.cc:146
const L1GtTriggerMask * m_l1GtTmVetoTech
Definition: L1GtUtils.h:474
const bool l1AlgoTechTrigBitNumber(const std::string &nameAlgoTechTrig, TriggerCategory &trigCategory, int &bitNumber) const
Definition: L1GtUtils.cc:550
void getAllProvenance(std::vector< Provenance const * > &provenances) const
Definition: Run.cc:35
TriggerCategory
Definition: L1GtUtils.h:60
const bool availableL1Configuration(int &errorCode, int &l1ConfCode) const
Definition: L1GtUtils.cc:2295
edm::InputTag m_provL1GtTriggerMenuLiteInputTag
Definition: L1GtUtils.h:518
const std::vector< std::vector< int > > & gtPrescaleFactorsAlgoTrig() const
get the prescale factors by reference / set the prescale factors
const std::vector< std::vector< int > > * m_prescaleFactorsAlgoTrigLite
Definition: L1GtUtils.h:506
virtual ~L1GtUtils()
destructor
Definition: L1GtUtils.cc:86
const L1GtTriggerMask * m_l1GtTmAlgo
trigger masks &amp; veto masks
Definition: L1GtUtils.h:465
const AlgorithmMap * m_algorithmMap
Definition: L1GtUtils.h:487
const std::vector< std::pair< std::string, int > > & prescaleFactors()
Definition: L1GtUtils.cc:2723
const std::vector< std::vector< int > > * m_prescaleFactorsTechTrig
Definition: L1GtUtils.h:462
Run const & getRun() const
Definition: Event.cc:45
const L1GtStableParameters * m_l1GtStablePar
event setup cached stuff
Definition: L1GtUtils.h:445
const std::string & gtTriggerMenuImplementation() const
unsigned long long m_l1GtPfAlgoCacheID
Definition: L1GtUtils.h:456
const std::vector< unsigned int > & triggerMaskSet(const TriggerCategory &trigCategory, int &errorCode)
Definition: L1GtUtils.cc:2081
const std::vector< std::pair< std::string, int > > & triggerMasks()
Definition: L1GtUtils.cc:2736
const std::string & l1TriggerMenu() const
return the L1 trigger menu name
Definition: L1GtUtils.cc:2180
const std::vector< std::vector< int > > * m_prescaleFactorsAlgoTrig
Definition: L1GtUtils.h:461
const bool decisionBeforeMask(const edm::Event &iEvent, const edm::InputTag &l1GtRecordInputTag, const edm::InputTag &l1GtReadoutRecordInputTag, const std::string &nameAlgoTechTrig, int &errorCode) const
return decision before trigger mask for a given algorithm or technical trigger
Definition: L1GtUtils.cc:1376
const L1GtTriggerMenuLite::L1TriggerMap * m_algorithmAliasMapLite
Definition: L1GtUtils.h:500
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
const std::string & gtTriggerMenuName() const
U second(std::pair< T, U > const &p)
const L1GtTriggerMenuLite::L1TriggerMap * m_algorithmMapLite
Definition: L1GtUtils.h:499
unsigned int gtNumberTechnicalTriggers() const
get / set the number of technical triggers
RunID const & id() const
Definition: RunAuxiliary.h:37
unsigned long long m_l1GtTmVetoTechCacheID
Definition: L1GtUtils.h:475
const std::vector< std::pair< std::string, bool > > & decisionsAfterMask()
Definition: L1GtUtils.cc:2710
void getL1GtRecordInputTag(const edm::Event &iEvent, edm::InputTag &l1GtRecordInputTag, edm::InputTag &l1GtReadoutRecordInputTag) const
Definition: L1GtUtils.cc:429
unsigned int gtNumberPhysTriggers() const
get / set the number of physics trigger algorithms
const std::vector< std::pair< std::string, bool > > & decisionsBeforeMask()
Definition: L1GtUtils.cc:2697
int iEvent
Definition: GenABIO.cc:243
const bool decision(const edm::Event &iEvent, const edm::InputTag &l1GtRecordInputTag, const edm::InputTag &l1GtReadoutRecordInputTag, const std::string &nameAlgoTechTrig, int &errorCode) const
Definition: L1GtUtils.cc:1450
edm::InputTag m_provL1GtRecordInputTag
cached input tags from provenance - they are updated once per run only
Definition: L1GtUtils.h:516
edm::RunID m_provRunIDCache
Definition: L1GtUtils.h:522
const std::string & l1TriggerMenuImplementation() const
return the L1 trigger menu implementation
Definition: L1GtUtils.cc:2205
const AlgorithmMap * m_algorithmAliasMap
Definition: L1GtUtils.h:488
std::string friendlyName(std::string const &iFullName)
std::vector< OperandToken > & operandTokenVector()
return the vector of operand tokens
unsigned long long m_l1GtTmTechCacheID
Definition: L1GtUtils.h:469
const T & max(const T &a, const T &b)
const std::vector< unsigned int > & gtTriggerMask() const
get the trigger mask
const std::vector< std::vector< int > > * m_prescaleFactorsTechTrigLite
Definition: L1GtUtils.h:507
const L1GtTriggerMask * m_l1GtTmVetoAlgo
Definition: L1GtUtils.h:471
std::vector< bool > DecisionWord
typedefs
const std::vector< unsigned int > & gtTriggerMaskTechTrig() const
get the trigger mask for technical triggers
static const std::string EmptyString
Definition: L1GtUtils.h:430
const std::string triggerCategory(const TriggerCategory &) const
public methods
Definition: L1GtUtils.cc:92
const L1GtPrescaleFactors * m_l1GtPfAlgo
prescale factors
Definition: L1GtUtils.h:455
unsigned long long m_l1GtTmAlgoCacheID
Definition: L1GtUtils.h:466
const std::vector< int > & prescaleFactorSet(const edm::Event &iEvent, const edm::InputTag &l1GtRecordInputTag, const edm::InputTag &l1GtReadoutRecordInputTag, const TriggerCategory &trigCategory, int &errorCode)
Definition: L1GtUtils.cc:1986
unsigned int m_numberTechnicalTriggers
number of technical triggers
Definition: L1GtUtils.h:452
void getL1GtTriggerMenuLiteInputTag(const edm::Run &iRun, edm::InputTag &l1GtTriggerMenuLiteInputTag) const
get the input tag for L1GtTriggerMenuLite
Definition: L1GtUtils.cc:496
const L1TriggerMap & gtAlgorithmAliasMap() const
get / set the algorithm map (by alias)
bool m_retrieveL1EventSetup
flags to check which method was used to retrieve L1 trigger configuration
Definition: L1GtUtils.h:534
void retrieveL1EventSetup(const edm::EventSetup &)
retrieve all the relevant L1 trigger event setup records and cache them to improve the speed ...
Definition: L1GtUtils.cc:113
const std::vector< std::vector< int > > & gtPrescaleFactorsTechTrig() const
static const bool useL1EventSetup(true)
bool first
Definition: L1TdeRCT.cc:94
bool isValid() const
Definition: HandleBase.h:76
unsigned int m_physicsDaqPartition
index of physics DAQ partition
Definition: L1GtUtils.h:528
unsigned int m_numberAlgorithmTriggers
number of algorithm triggers
Definition: L1GtUtils.h:449
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
#define LogTrace(id)
L1TriggerMap::const_iterator CItL1Trig
iterators through map containing the physics algorithms or the technical triggers ...
void getL1GtRunCache(const edm::Run &, const edm::EventSetup &, const bool, const bool, const edm::InputTag &)
get all the run-constant quantities for L1 trigger and cache them
Definition: L1GtUtils.cc:313
const L1GtTriggerMask * m_l1GtTmTech
Definition: L1GtUtils.h:468
const L1GtTriggerMenuLite * m_l1GtMenuLite
L1GtTriggerMenuLite cached stuff.
Definition: L1GtUtils.h:497
const std::vector< std::vector< int > > & gtPrescaleFactors() const
get the prescale factors by reference
const L1GtPrescaleFactors * m_l1GtPfTech
Definition: L1GtUtils.h:458
const AlgorithmMap * m_technicalTriggerMap
Definition: L1GtUtils.h:489
void reset(std::vector< std::pair< std::string, bool > >) const
reset for each L1 trigger the value from pair.second
Definition: L1GtUtils.cc:2783
const T & get() const
Definition: EventSetup.h:55
const std::vector< unsigned int > * m_triggerMaskVetoAlgoTrig
Definition: L1GtUtils.h:480
T const * product() const
Definition: ESHandle.h:62
const std::vector< unsigned int > * m_triggerMaskTechTrigLite
Definition: L1GtUtils.h:504
RunAuxiliary const & runAuxiliary() const
Definition: Run.h:40
bool m_l1GtMenuLiteValid
Definition: L1GtUtils.h:509
T const * product() const
Definition: Handle.h:74
const std::vector< unsigned int > * m_triggerMaskAlgoTrigLite
Definition: L1GtUtils.h:503
bool m_beginRunCache
flag for call of getL1GtRunCache in beginRun
Definition: L1GtUtils.h:512
edm::EventID id() const
Definition: EventBase.h:56
const int prescaleFactorSetIndex(const edm::Event &iEvent, const edm::InputTag &l1GtRecordInputTag, const edm::InputTag &l1GtReadoutRecordInputTag, const TriggerCategory &trigCategory, int &errorCode) const
Definition: L1GtUtils.cc:1762
const int triggerMask(const edm::Event &iEvent, const edm::InputTag &l1GtRecordInputTag, const edm::InputTag &l1GtReadoutRecordInputTag, const std::string &nameAlgoTechTrig, int &errorCode) const
return trigger mask for a given algorithm or technical trigger
Definition: L1GtUtils.cc:1522
const bool trigResult(const DecisionWord &decWord, const int bitNumber, const std::string &nameAlgoTechTrig, const TriggerCategory &trigCategory, int &errorCode) const
Definition: L1GtUtils.cc:2399
const L1TriggerMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
const AlgorithmMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
const L1GtTriggerMenu * m_l1GtMenu
Definition: L1GtUtils.h:484
unsigned long long m_l1GtPfTechCacheID
Definition: L1GtUtils.h:459
static const int L1GtNotValidError
Definition: L1GtUtils.h:431
const AlgorithmMap & gtTechnicalTriggerMap() const
get / set the technical trigger map
bool m_l1EventSetupValid
Definition: L1GtUtils.h:491
unsigned long long m_l1GtTmVetoAlgoCacheID
Definition: L1GtUtils.h:472
std::vector< int > m_prescaleFactorSet
Definition: L1GtUtils.h:531
const AlgorithmMap & gtAlgorithmAliasMap() const
get / set the algorithm map (by alias)
const L1TriggerMap & gtTechnicalTriggerMap() const
get / set the technical trigger map
const L1GtTriggerMenu * ptrL1TriggerMenuEventSetup(int &errorCode)
return a pointer to the L1 trigger menu from event setup
Definition: L1GtUtils.cc:2230
const int prescaleFactor(const edm::Event &iEvent, const edm::InputTag &l1GtRecordInputTag, const edm::InputTag &l1GtReadoutRecordInputTag, const std::string &nameAlgoTechTrig, int &errorCode) const
return prescale factor for a given algorithm or technical trigger
Definition: L1GtUtils.cc:1487
void reset(double vett[256])
Definition: TPedValues.cc:11
const std::string & gtTriggerMenuImplementation() const
unsigned long long m_l1GtStableParCacheID
Definition: L1GtUtils.h:446
L1GtUtils()
constructor
Definition: L1GtUtils.cc:50
const L1GtTriggerMenuLite::L1TriggerMap * m_technicalTriggerMapLite
Definition: L1GtUtils.h:501
RunNumber_t run() const
Definition: RunAuxiliary.h:41
Definition: Run.h:33
const std::vector< unsigned int > * m_triggerMaskVetoTechTrig
Definition: L1GtUtils.h:481
const std::vector< std::pair< std::string, int > > & errorCodes(const edm::Event &)
Definition: L1GtUtils.cc:2749