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