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_physicsDaqPartition(0),
69 
70  m_retrieveL1EventSetup(false),
71 
72  m_retrieveL1GtTriggerMenuLite(false)
73 
74  {
75 
76  // empty
77 }
78 
79 // destructor
81 
82  // empty
83 
84 }
85 
86 const std::string L1GtUtils::triggerCategory(
87  const TriggerCategory& trigCategory) const {
88 
89  switch (trigCategory) {
90  case AlgorithmTrigger: {
91  return "Algorithm Trigger";
92  }
93  break;
94  case TechnicalTrigger: {
95  return "Technical Trigger";
96  }
97 
98  break;
99  default: {
100  return EmptyString;
101  }
102  break;
103  }
104 }
105 
106 
108 
109  //
110  m_retrieveL1EventSetup = true;
111 
112  m_l1EventSetupValid = true;
113  // FIXME test for each record if valid; if not set m_l1EventSetupValid = false;
114 
115  // get / update the stable parameters from the EventSetup
116  // local cache & check on cacheIdentifier
117 
118  unsigned long long l1GtStableParCacheID =
119  evSetup.get<L1GtStableParametersRcd>().cacheIdentifier();
120 
121  if (m_l1GtStableParCacheID != l1GtStableParCacheID) {
122 
124  evSetup.get<L1GtStableParametersRcd>().get(l1GtStablePar);
125  m_l1GtStablePar = l1GtStablePar.product();
126 
127  // number of algorithm triggers
129 
130  // number of technical triggers
133 
134  int maxNumberTrigger = std::max(m_numberAlgorithmTriggers,
136 
137  m_triggerMaskSet.reserve(maxNumberTrigger);
138  m_prescaleFactorSet.reserve(maxNumberTrigger);
139 
140  //
141  m_l1GtStableParCacheID = l1GtStableParCacheID;
142 
143  }
144 
145  // get / update the prescale factors from the EventSetup
146  // local cache & check on cacheIdentifier
147 
148  unsigned long long l1GtPfAlgoCacheID =
149  evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().cacheIdentifier();
150 
151  if (m_l1GtPfAlgoCacheID != l1GtPfAlgoCacheID) {
152 
154  evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().get(l1GtPfAlgo);
155  m_l1GtPfAlgo = l1GtPfAlgo.product();
156 
158 
159  m_l1GtPfAlgoCacheID = l1GtPfAlgoCacheID;
160 
161  }
162 
163  unsigned long long l1GtPfTechCacheID = evSetup.get<
164  L1GtPrescaleFactorsTechTrigRcd>().cacheIdentifier();
165 
166  if (m_l1GtPfTechCacheID != l1GtPfTechCacheID) {
167 
169  evSetup.get<L1GtPrescaleFactorsTechTrigRcd>().get(l1GtPfTech);
170  m_l1GtPfTech = l1GtPfTech.product();
171 
173 
174  m_l1GtPfTechCacheID = l1GtPfTechCacheID;
175 
176  }
177 
178  // get / update the trigger mask from the EventSetup
179  // local cache & check on cacheIdentifier
180 
181  unsigned long long l1GtTmAlgoCacheID =
182  evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().cacheIdentifier();
183 
184  if (m_l1GtTmAlgoCacheID != l1GtTmAlgoCacheID) {
185 
187  evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().get(l1GtTmAlgo);
188  m_l1GtTmAlgo = l1GtTmAlgo.product();
189 
191 
192  m_l1GtTmAlgoCacheID = l1GtTmAlgoCacheID;
193 
194  }
195 
196  unsigned long long l1GtTmTechCacheID =
197  evSetup.get<L1GtTriggerMaskTechTrigRcd>().cacheIdentifier();
198 
199  if (m_l1GtTmTechCacheID != l1GtTmTechCacheID) {
200 
202  evSetup.get<L1GtTriggerMaskTechTrigRcd>().get(l1GtTmTech);
203  m_l1GtTmTech = l1GtTmTech.product();
204 
206 
207  m_l1GtTmTechCacheID = l1GtTmTechCacheID;
208 
209  }
210 
211  unsigned long long l1GtTmVetoAlgoCacheID =
212  evSetup.get<L1GtTriggerMaskVetoAlgoTrigRcd>().cacheIdentifier();
213 
214  if (m_l1GtTmVetoAlgoCacheID != l1GtTmVetoAlgoCacheID) {
215 
216  edm::ESHandle<L1GtTriggerMask> l1GtTmVetoAlgo;
217  evSetup.get<L1GtTriggerMaskVetoAlgoTrigRcd>().get(l1GtTmVetoAlgo);
218  m_l1GtTmVetoAlgo = l1GtTmVetoAlgo.product();
219 
221 
222  m_l1GtTmVetoAlgoCacheID = l1GtTmVetoAlgoCacheID;
223 
224  }
225 
226  unsigned long long l1GtTmVetoTechCacheID =
227  evSetup.get<L1GtTriggerMaskVetoTechTrigRcd>().cacheIdentifier();
228 
229  if (m_l1GtTmVetoTechCacheID != l1GtTmVetoTechCacheID) {
230 
231  edm::ESHandle<L1GtTriggerMask> l1GtTmVetoTech;
232  evSetup.get<L1GtTriggerMaskVetoTechTrigRcd>().get(l1GtTmVetoTech);
233  m_l1GtTmVetoTech = l1GtTmVetoTech.product();
234 
236 
237  m_l1GtTmVetoTechCacheID = l1GtTmVetoTechCacheID;
238 
239  }
240 
241  // get / update the trigger menu from the EventSetup
242  // local cache & check on cacheIdentifier
243 
244  unsigned long long l1GtMenuCacheID =
245  evSetup.get<L1GtTriggerMenuRcd>().cacheIdentifier();
246 
247  if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
248 
250  evSetup.get<L1GtTriggerMenuRcd>().get(l1GtMenu);
251  m_l1GtMenu = l1GtMenu.product();
252 
255 
257 
258  m_l1GtMenuCacheID = l1GtMenuCacheID;
259 
260  }
261 
262 }
263 
265 
266  // cache the L1GtTriggerMenuLite
267 
268  const edm::Run& iRun = iEvent.getRun();
269  const edm::RunID* runID = &(iRun.runAuxiliary().id());
270 
271  if (runID != m_provRunIDCache) {
272 
273  edm::InputTag l1GtTriggerMenuLiteInputTag;
274  getL1GtTriggerMenuLiteInputTag(iEvent, l1GtTriggerMenuLiteInputTag);
275 
276  retrieveL1GtTriggerMenuLite(iEvent, l1GtTriggerMenuLiteInputTag);
277 
278  m_provRunIDCache = runID;
279 
280  }
281 }
282 
284  edm::InputTag& l1GtMenuLiteInputTag) {
285 
286  //
288 
289  // get Run Data - the same code can be run in beginRun, with getByLabel from edm::Run
290  const edm::Run& iRun = iEvent.getRun();
291  const edm::RunID* runID = &(iRun.runAuxiliary().id());
292 
293  if (runID != m_runIDCache) {
294 
295  // get L1GtTriggerMenuLite
297  iRun.getByLabel(l1GtMenuLiteInputTag, l1GtMenuLite);
298 
299  if (!l1GtMenuLite.isValid()) {
300 
301  LogDebug("L1GtUtils") << "\nL1GtTriggerMenuLite with \n "
302  << l1GtMenuLiteInputTag
303  << "\nrequested in configuration, but not found in the event."
304  << std::endl;
305 
306  m_l1GtMenuLiteValid = false;
307  } else {
308  m_l1GtMenuLite = l1GtMenuLite.product();
309  m_l1GtMenuLiteValid = true;
310 
311  LogDebug("L1GtUtils") << "\nL1GtTriggerMenuLite with \n "
312  << l1GtMenuLiteInputTag << "\nretrieved for run "
313  << iRun.runAuxiliary().run() << std::endl;
314 
319 
324 
329 
330  }
331 
332  m_runIDCache = runID;
333  }
334 
335 }
336 
337 
338 
340  edm::InputTag& l1GtRecordInputTag,
341  edm::InputTag& l1GtReadoutRecordInputTag) const {
342 
343  typedef std::vector<edm::Provenance const*> Provenances;
344  Provenances provenances;
345  std::string friendlyName;
346  std::string modLabel;
347  std::string instanceName;
348  std::string processName;
349 
350  // to be sure that the input tags are correctly initialized
351  edm::InputTag l1GtRecordInputTagVal;
352  edm::InputTag l1GtReadoutRecordInputTagVal;
353 
354  bool foundL1GtRecord = false;
355  bool foundL1GtReadoutRecord = false;
356 
357  //edm::LogVerbatim("L1GtUtils") << "\nTry to get AllProvenance for event "
358  // << iEvent.id().event() << std::endl;
359 
360  iEvent.getAllProvenance(provenances);
361 
362  //edm::LogVerbatim("L1GtUtils") << "\n" << "Event contains "
363  // << provenances.size() << " product" << (provenances.size()==1 ? "" : "s")
364  // << " with friendlyClassName, moduleLabel, productInstanceName and processName:"
365  // << std::endl;
366 
367  for (Provenances::iterator itProv = provenances.begin(), itProvEnd =
368  provenances.end(); itProv != itProvEnd; ++itProv) {
369 
370  friendlyName = (*itProv)->friendlyClassName();
371  modLabel = (*itProv)->moduleLabel();
372  instanceName = (*itProv)->productInstanceName();
373  processName = (*itProv)->processName();
374 
375  //edm::LogVerbatim("L1GtUtils") << friendlyName << " \"" << modLabel
376  // << "\" \"" << instanceName << "\" \"" << processName << "\""
377  // << std::endl;
378 
379  if (friendlyName == "L1GlobalTriggerRecord") {
380  l1GtRecordInputTagVal = edm::InputTag(modLabel, instanceName,
381  processName);
382  foundL1GtRecord = true;
383  } else if (friendlyName == "L1GlobalTriggerReadoutRecord") {
384 
385  l1GtReadoutRecordInputTagVal = edm::InputTag(modLabel, instanceName,
386  processName);
387  foundL1GtReadoutRecord = true;
388  }
389  }
390 
391  // copy the input tags found to the returned arguments
392  l1GtRecordInputTag = l1GtRecordInputTagVal;
393  l1GtReadoutRecordInputTag = l1GtReadoutRecordInputTagVal;
394 
395  //if (foundL1GtRecord) {
396  // edm::LogVerbatim("L1GtUtils")
397  // << "\nL1GlobalTriggerRecord found in the event with \n "
398  // << l1GtRecordInputTag << std::endl;
399  //
400  //}
401 
402  //if (foundL1GtReadoutRecord) {
403  // edm::LogVerbatim("L1GtUtils")
404  // << "\nL1GlobalTriggerReadoutRecord found in the event with \n "
405  // << l1GtReadoutRecordInputTag << std::endl;
406  //}
407 
408 }
409 
411  edm::InputTag& l1GtTriggerMenuLiteInputTag) const {
412 
413  typedef std::vector<edm::Provenance const*> Provenances;
414  Provenances provenances;
415  std::string friendlyName;
416  std::string modLabel;
417  std::string instanceName;
418  std::string processName;
419 
420  // to be sure that the input tag is correctly initialized
421  edm::InputTag l1GtTriggerMenuLiteInputTagVal;
422  bool foundL1GtTriggerMenuLite = false;
423 
424  // get Run Data
425  const edm::Run& iRun = iEvent.getRun();
426 
427  //edm::LogVerbatim("L1GtUtils") << "\nTry to get AllProvenance for run "
428  // << iRun.runAuxiliary().run() << " event " << iEvent.id().event()
429  // << std::endl;
430 
431  iRun.getAllProvenance(provenances);
432 
433  //edm::LogVerbatim("L1GtUtils") << "\n" << "Run contains "
434  // << provenances.size() << " product"
435  // << (provenances.size() == 1 ? "" : "s")
436  // << " with friendlyClassName, moduleLabel, productInstanceName and processName:"
437  // << std::endl;
438 
439  for (Provenances::iterator itProv = provenances.begin(), itProvEnd =
440  provenances.end(); itProv != itProvEnd; ++itProv) {
441 
442  friendlyName = (*itProv)->friendlyClassName();
443  modLabel = (*itProv)->moduleLabel();
444  instanceName = (*itProv)->productInstanceName();
445  processName = (*itProv)->processName();
446 
447  //edm::LogVerbatim("L1GtUtils") << friendlyName << " \"" << modLabel
448  // << "\" \"" << instanceName << "\" \"" << processName << "\""
449  // << std::endl;
450 
451  if (friendlyName == "L1GtTriggerMenuLite") {
452  l1GtTriggerMenuLiteInputTagVal = edm::InputTag(modLabel,
453  instanceName, processName);
454  foundL1GtTriggerMenuLite = true;
455  }
456 
457  }
458 
459  // copy the input tags found to the returned arguments
460  l1GtTriggerMenuLiteInputTag = l1GtTriggerMenuLiteInputTagVal;
461 
462  //if (foundL1GtTriggerMenuLite) {
463  // edm::LogVerbatim("L1GtUtils")
464  // << "\nL1GtTriggerMenuLite found in the event with \n "
465  // << l1GtTriggerMenuLiteInputTag << std::endl;
466  //}
467 
468 }
469 
471  const std::string& nameAlgoTechTrig, TriggerCategory& trigCategory,
472  int& bitNumber) const {
473 
474  trigCategory = AlgorithmTrigger;
475  bitNumber = -1;
476 
478  if (m_l1GtMenuLiteValid) {
479 
480  // test if the name is an algorithm alias
481  for (L1GtTriggerMenuLite::CItL1Trig itTrig =
482  m_algorithmAliasMapLite->begin(); itTrig
483  != m_algorithmAliasMapLite->end(); itTrig++) {
484 
485  if (itTrig->second == nameAlgoTechTrig) {
486 
487  trigCategory = AlgorithmTrigger;
488  bitNumber = itTrig->first;
489 
490  return true;
491  }
492  }
493 
494  // test if the name is an algorithm name
495  for (L1GtTriggerMenuLite::CItL1Trig itTrig =
496  m_algorithmMapLite->begin(); itTrig
497  != m_algorithmMapLite->end(); itTrig++) {
498 
499  if (itTrig->second == nameAlgoTechTrig) {
500 
501  trigCategory = AlgorithmTrigger;
502  bitNumber = itTrig->first;
503 
504  return true;
505  }
506  }
507 
508  // test if the name is a technical trigger
509  for (L1GtTriggerMenuLite::CItL1Trig itTrig =
510  m_technicalTriggerMapLite->begin(); itTrig
511  != m_technicalTriggerMapLite->end(); itTrig++) {
512 
513  if (itTrig->second == nameAlgoTechTrig) {
514 
515  trigCategory = TechnicalTrigger;
516  bitNumber = itTrig->first;
517 
518  return true;
519  }
520  }
521 
522  } else if (m_retrieveL1EventSetup) {
523 
524  // test if the name is an algorithm alias
525  CItAlgo itAlgo = m_algorithmAliasMap->find(nameAlgoTechTrig);
526  if (itAlgo != m_algorithmAliasMap->end()) {
527  trigCategory = AlgorithmTrigger;
528  bitNumber = (itAlgo->second).algoBitNumber();
529 
530  return true;
531  }
532 
533  // test if the name is an algorithm name
534  itAlgo = m_algorithmMap->find(nameAlgoTechTrig);
535  if (itAlgo != m_algorithmMap->end()) {
536  trigCategory = AlgorithmTrigger;
537  bitNumber = (itAlgo->second).algoBitNumber();
538 
539  return true;
540  }
541 
542  // test if the name is a technical trigger
543  itAlgo = m_technicalTriggerMap->find(nameAlgoTechTrig);
544  if (itAlgo != m_technicalTriggerMap->end()) {
545  trigCategory = TechnicalTrigger;
546  bitNumber = (itAlgo->second).algoBitNumber();
547 
548  return true;
549  }
550 
551  } else {
552  // only L1GtTriggerMenuLite requested, but it is not valid
553  return false;
554 
555  }
556  } else if (m_retrieveL1EventSetup) {
557 
558  // test if the name is an algorithm alias
559  CItAlgo itAlgo = m_algorithmAliasMap->find(nameAlgoTechTrig);
560  if (itAlgo != m_algorithmAliasMap->end()) {
561  trigCategory = AlgorithmTrigger;
562  bitNumber = (itAlgo->second).algoBitNumber();
563 
564  return true;
565  }
566 
567  // test if the name is an algorithm name
568  itAlgo = m_algorithmMap->find(nameAlgoTechTrig);
569  if (itAlgo != m_algorithmMap->end()) {
570  trigCategory = AlgorithmTrigger;
571  bitNumber = (itAlgo->second).algoBitNumber();
572 
573  return true;
574  }
575 
576  // test if the name is a technical trigger
577  itAlgo = m_technicalTriggerMap->find(nameAlgoTechTrig);
578  if (itAlgo != m_technicalTriggerMap->end()) {
579  trigCategory = TechnicalTrigger;
580  bitNumber = (itAlgo->second).algoBitNumber();
581 
582  return true;
583  }
584 
585  } else {
586  // L1 trigger configuration not retrieved
587  return false;
588 
589  }
590 
591  // all possibilities already tested, so it should not arrive here
592  return false;
593 
594 
595 }
596 
597 // deprecated
599  const std::string& nameAlgoTechTrig, int& triggerAlgoTechTrig,
600  int& bitNumber) const {
601 
602  TriggerCategory trigCategory = AlgorithmTrigger;
603  bitNumber = -1;
604 
605  const bool trigCategBitNr = l1AlgoTechTrigBitNumber(nameAlgoTechTrig,
606  trigCategory, bitNumber);
607  triggerAlgoTechTrig = trigCategory;
608 
609  return trigCategBitNr;
610 
611 }
612 
613 
615  const edm::InputTag& l1GtRecordInputTag,
616  const edm::InputTag& l1GtReadoutRecordInputTag,
617  const std::string& nameAlgoTechTrig, bool& decisionBeforeMask,
618  bool& decisionAfterMask, int& prescaleFactor, int& triggerMask) const {
619 
620  // initial values for returned results
621  decisionBeforeMask = false;
622  decisionAfterMask = false;
623  prescaleFactor = -1;
624  triggerMask = -1;
625 
626  // initialize error code and L1 configuration code
627  int iError = 0;
628  int l1ConfCode = 0;
629 
630  // check if L1 configuration is available
631 
632  if (!availableL1Configuration(iError, l1ConfCode)) {
633  return iError;
634  }
635 
636  // at this point, a valid L1 configuration is available, so the if/else if/else
637  // can be simplified
638 
639  // if the given name is not an algorithm trigger alias, an algorithm trigger name
640  // or a technical trigger in the current menu, return with error code 1
641 
642  TriggerCategory trigCategory = AlgorithmTrigger;
643  int bitNumber = -1;
644 
645 
646  if (!l1AlgoTechTrigBitNumber(nameAlgoTechTrig, trigCategory, bitNumber)) {
647 
648  iError = l1ConfCode + 1;
649 
651  if (m_l1GtMenuLiteValid) {
652 
653  LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
654  << nameAlgoTechTrig
655  << "\not found in the trigger menu \n "
657  << "\nretrieved from L1GtTriggerMenuLite" << std::endl;
658 
659  } else {
660 
661  // fall through: L1 trigger configuration from event setup
662  LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
663  << nameAlgoTechTrig
664  << "\not found in the trigger menu \n "
666  << "\nretrieved from Event Setup" << std::endl;
667 
668  }
669 
670  } else {
671  // L1 trigger configuration from event setup only
672  LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
673  << nameAlgoTechTrig
674  << "\not found in the trigger menu \n "
676  << "\nretrieved from Event Setup" << std::endl;
677 
678  }
679 
680  return iError;
681 
682  }
683 
684  // check here if a positive bit number was retrieved
685  // exit in case of negative bit number, before retrieving L1 GT products, saving time
686 
687  if (bitNumber < 0) {
688 
689  iError = l1ConfCode + 2;
690 
692  if (m_l1GtMenuLiteValid) {
693  LogDebug("L1GtUtils") << "\nNegative bit number for "
694  << triggerCategory(trigCategory) << "\n "
695  << nameAlgoTechTrig << "\nfrom menu \n "
697  << "\nretrieved from L1GtTriggerMenuLite" << std::endl;
698 
699  } else {
700  // fall through: L1 trigger configuration from event setup
701  LogDebug("L1GtUtils") << "\nNegative bit number for "
702  << triggerCategory(trigCategory) << "\n "
703  << nameAlgoTechTrig << "\nfrom menu \n "
705  << "\nretrieved from Event Setup" << std::endl;
706 
707  }
708 
709  } else {
710  // L1 trigger configuration from event setup only
711  LogDebug("L1GtUtils") << "\nNegative bit number for "
712  << triggerCategory(trigCategory) << "\n "
713  << nameAlgoTechTrig << "\nfrom menu \n "
715  << "\nretrieved from Event Setup" << std::endl;
716 
717  }
718 
719  return iError;
720  }
721 
722 
723  // retrieve L1GlobalTriggerRecord and 1GlobalTriggerReadoutRecord product
724  // intermediate error code for the records
725  // the module returns an error code only if both the lite and the readout record are missing
726 
727  int iErrorRecord = 0;
728 
729  bool validRecord = false;
730  bool gtRecordValid = false;
731  bool gtReadoutRecordValid = false;
732 
734  iEvent.getByLabel(l1GtRecordInputTag, gtRecord);
735 
736  if (gtRecord.isValid()) {
737 
738  gtRecordValid = true;
739  validRecord = true;
740 
741  } else {
742 
743  iErrorRecord = 10;
744  LogDebug("L1GtUtils") << "\nL1GlobalTriggerRecord with \n "
745  << l1GtRecordInputTag << "\nnot found in the event."
746  << std::endl;
747  }
748 
750  iEvent.getByLabel(l1GtReadoutRecordInputTag, gtReadoutRecord);
751 
752  if (gtReadoutRecord.isValid()) {
753 
754  gtReadoutRecordValid = true;
755  validRecord = true;
756 
757  } else {
758 
759  iErrorRecord = iErrorRecord + 100;
760  LogDebug("L1GtUtils") << "\nL1GlobalTriggerReadoutRecord with \n "
761  << l1GtReadoutRecordInputTag << "\nnot found in the event."
762  << std::endl;
763 
764  }
765 
766  // get the prescale factor index from
767  // L1GlobalTriggerReadoutRecord if valid
768  // if not, from L1GlobalTriggerRecord if valid
769  // else return an error
770 
771 
772  int pfIndexTechTrig = -1;
773  int pfIndexAlgoTrig = -1;
774 
775  if (validRecord) {
776  if (gtReadoutRecordValid) {
777 
778  pfIndexTechTrig
779  = (gtReadoutRecord->gtFdlWord()).gtPrescaleFactorIndexTech();
780  pfIndexAlgoTrig
781  = (gtReadoutRecord->gtFdlWord()).gtPrescaleFactorIndexAlgo();
782 
783  } else {
784 
785  pfIndexTechTrig
786  = static_cast<int> (gtRecord->gtPrescaleFactorIndexTech());
787  pfIndexAlgoTrig
788  = static_cast<int> (gtRecord->gtPrescaleFactorIndexAlgo());
789 
790  }
791 
792  } else {
793 
794  LogDebug("L1GtUtils") << "\nError: "
795  << "\nNo valid L1GlobalTriggerRecord with \n "
796  << l1GtRecordInputTag << "\nfound in the event."
797  << "\nNo valid L1GlobalTriggerReadoutRecord with \n "
798  << l1GtReadoutRecordInputTag << "\nfound in the event."
799  << std::endl;
800 
801  iError = l1ConfCode + iErrorRecord;
802  return iError;
803 
804  }
805 
806  // depending on trigger category (algorithm trigger or technical trigger)
807  // get the correct quantities
808 
809  // number of sets of prescale factors
810  // index of prescale factor set retrieved from data
811  // pointer to the actual prescale factor set
812  // pointer to the set of trigger masks
813 
814  size_t pfSetsSize = 0;
815  int pfIndex = -1;
816  const std::vector<int>* prescaleFactorsSubset = 0;
817  const std::vector<unsigned int>* triggerMasksSet = 0;
818 
819  switch (trigCategory) {
820  case AlgorithmTrigger: {
822  if (m_l1GtMenuLiteValid) {
823  pfSetsSize = m_prescaleFactorsAlgoTrigLite->size();
824  triggerMasksSet = m_triggerMaskAlgoTrigLite;
825 
826  } else {
827  // fall through: L1 trigger configuration from event setup
828  pfSetsSize = m_prescaleFactorsAlgoTrig->size();
829  triggerMasksSet = m_triggerMaskAlgoTrig;
830 
831  }
832 
833  } else {
834  // L1 trigger configuration from event setup only
835  pfSetsSize = m_prescaleFactorsAlgoTrig->size();
836  triggerMasksSet = m_triggerMaskAlgoTrig;
837 
838  }
839 
840  pfIndex = pfIndexAlgoTrig;
841 
842  }
843  break;
844  case TechnicalTrigger: {
846  if (m_l1GtMenuLiteValid) {
847  pfSetsSize = m_prescaleFactorsTechTrigLite->size();
848  triggerMasksSet = m_triggerMaskTechTrigLite;
849 
850  } else {
851  // fall through: L1 trigger configuration from event setup
852  pfSetsSize = m_prescaleFactorsTechTrig->size();
853  triggerMasksSet = m_triggerMaskTechTrig;
854 
855  }
856 
857  } else {
858  // L1 trigger configuration from event setup only
859  pfSetsSize = m_prescaleFactorsTechTrig->size();
860  triggerMasksSet = m_triggerMaskTechTrig;
861 
862  }
863 
864  pfIndex = pfIndexTechTrig;
865 
866  }
867  break;
868  default: {
869  // should not be the case
870  iError = l1ConfCode + iErrorRecord + 3;
871  return iError;
872 
873  }
874  break;
875  }
876 
877 
878  // test prescale factor set index correctness, then retrieve the actual set of prescale factors
879 
880  if (pfIndex < 0) {
881 
882  iError = l1ConfCode + iErrorRecord + 1000;
883  LogDebug("L1GtUtils")
884  << "\nError: index of prescale factor set retrieved from the data \n"
885  << "less than zero."
886  << "\n Value of index retrieved from data = " << pfIndex
887  << std::endl;
888 
889  return iError;
890 
891  } else if (pfIndex >= (static_cast<int>(pfSetsSize))) {
892  iError = l1ConfCode + iErrorRecord + 2000;
893  LogDebug("L1GtUtils")
894  << "\nError: index of prescale factor set retrieved from the data \n"
895  << "greater than the size of the vector of prescale factor sets."
896  << "\n Value of index retrieved from data = " << pfIndex
897  << "\n Vector size = " << pfSetsSize << std::endl;
898 
899  return iError;
900 
901  } else {
902  switch (trigCategory) {
903  case AlgorithmTrigger: {
905  if (m_l1GtMenuLiteValid) {
906  prescaleFactorsSubset
907  = &((*m_prescaleFactorsAlgoTrigLite).at(pfIndex));
908 
909  } else {
910  // fall through: L1 trigger configuration from event setup
911  prescaleFactorsSubset
912  = &((*m_prescaleFactorsAlgoTrig).at(pfIndex));
913 
914  }
915 
916  } else {
917  // L1 trigger configuration from event setup only
918  prescaleFactorsSubset
919  = &((*m_prescaleFactorsAlgoTrig).at(pfIndex));
920 
921  }
922 
923  }
924  break;
925  case TechnicalTrigger: {
927  if (m_l1GtMenuLiteValid) {
928  prescaleFactorsSubset
929  = &((*m_prescaleFactorsTechTrigLite).at(pfIndex));
930 
931  } else {
932  // fall through: L1 trigger configuration from event setup
933  prescaleFactorsSubset
934  = &((*m_prescaleFactorsTechTrig).at(pfIndex));
935 
936  }
937 
938  } else {
939  // L1 trigger configuration from event setup only
940  prescaleFactorsSubset
941  = &((*m_prescaleFactorsTechTrig).at(pfIndex));
942 
943  }
944 
945  }
946  break;
947  default: {
948  // do nothing - it was tested before, with return
949 
950  }
951  break;
952  }
953 
954  }
955 
956 
957  // algorithm result before applying the trigger masks
958  // the bit number is positive (tested previously)
959 
960  switch (trigCategory) {
961  case AlgorithmTrigger: {
962  if (gtReadoutRecordValid) {
963  const DecisionWord& decWord = gtReadoutRecord->decisionWord();
964  decisionBeforeMask = trigResult(decWord, bitNumber,
965  nameAlgoTechTrig, trigCategory, iError);
966  if (iError) {
967  return (iError + l1ConfCode + iErrorRecord);
968  }
969 
970  } else {
971 
972  const DecisionWord& decWord =
973  gtRecord->decisionWordBeforeMask();
974  decisionBeforeMask = trigResult(decWord, bitNumber,
975  nameAlgoTechTrig, trigCategory, iError);
976  if (iError) {
977  return (iError + l1ConfCode + iErrorRecord);
978  }
979 
980  }
981 
982  }
983  break;
984  case TechnicalTrigger: {
985  if (gtReadoutRecordValid) {
986  const DecisionWord& decWord =
987  gtReadoutRecord->technicalTriggerWord();
988  decisionBeforeMask = trigResult(decWord, bitNumber,
989  nameAlgoTechTrig, trigCategory, iError);
990  if (iError) {
991  return (iError + l1ConfCode + iErrorRecord);
992  }
993 
994  } else {
995 
996  const DecisionWord& decWord =
997  gtRecord->technicalTriggerWordBeforeMask();
998  decisionBeforeMask = trigResult(decWord, bitNumber,
999  nameAlgoTechTrig, trigCategory, iError);
1000  if (iError) {
1001  return (iError + l1ConfCode + iErrorRecord);
1002  }
1003 
1004  }
1005 
1006  }
1007  break;
1008  default: {
1009  // do nothing - it was tested before, with return
1010 
1011  }
1012  break;
1013  }
1014 
1015  // prescale factor
1016  // the bit number is positive (tested previously)
1017 
1018  if (bitNumber < (static_cast<int> (prescaleFactorsSubset->size()))) {
1019  prescaleFactor = (*prescaleFactorsSubset)[bitNumber];
1020  } else {
1021  iError = l1ConfCode + iErrorRecord + 4000;
1022  LogDebug("L1GtUtils") << "\nError: bit number " << bitNumber
1023  << " retrieved for " << triggerCategory(trigCategory) << "\n "
1024  << nameAlgoTechTrig
1025  << "\ngreater than size of actual L1 GT prescale factor set: "
1026  << prescaleFactorsSubset->size()
1027  << "\nError: Inconsistent L1 trigger configuration!"
1028  << std::endl;
1029 
1030  return iError;
1031  }
1032 
1033  // trigger mask and trigger result after applying the trigger masks
1034 
1035  if (bitNumber < (static_cast<int> ((*triggerMasksSet).size()))) {
1036 
1038  if (m_l1GtMenuLiteValid) {
1039  triggerMask = (*triggerMasksSet)[bitNumber];
1040 
1041  } else {
1042  // fall through: L1 trigger configuration from event setup
1043  // masks in event setup are for all partitions
1044  triggerMask = ((*triggerMasksSet)[bitNumber]) & (1
1046 
1047  }
1048 
1049  } else {
1050  // L1 trigger configuration from event setup only
1051  // masks in event setup are for all partitions
1052  triggerMask = ((*triggerMasksSet)[bitNumber]) & (1
1054 
1055  }
1056 
1057 
1058  } else {
1059  iError = l1ConfCode + iErrorRecord + 5000;
1060  LogDebug("L1GtUtils") << "\nError: bit number " << bitNumber
1061  << " retrieved for " << triggerCategory(trigCategory) << "\n "
1062  << nameAlgoTechTrig
1063  << "\ngreater than size of L1 GT trigger mask set: "
1064  << (*triggerMasksSet).size()
1065  << "\nError: Inconsistent L1 trigger configuration!"
1066  << std::endl;
1067 
1068  return iError;
1069 
1070  }
1071 
1072  decisionAfterMask = decisionBeforeMask;
1073 
1074  if (triggerMask) {
1075  decisionAfterMask = false;
1076  }
1077 
1078  return iError;
1079 
1080 }
1081 
1082 
1084  const std::string& nameAlgoTechTrig, bool& decisionBeforeMask,
1085  bool& decisionAfterMask, int& prescaleFactor, int& triggerMask) const {
1086 
1087  edm::InputTag l1GtRecordInputTag;
1088  edm::InputTag l1GtReadoutRecordInputTag;
1089 
1090  // initial values for returned results
1091  decisionBeforeMask = false;
1092  decisionAfterMask = false;
1093  prescaleFactor = -1;
1094  triggerMask = -1;
1095 
1096  getInputTag(iEvent, l1GtRecordInputTag, l1GtReadoutRecordInputTag);
1097 
1098  int l1ErrorCode = 0;
1099 
1100  l1ErrorCode = l1Results(iEvent, l1GtRecordInputTag,
1101  l1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
1102  decisionAfterMask, prescaleFactor, triggerMask);
1103 
1104  return l1ErrorCode;
1105 
1106 }
1107 
1108 //
1109 
1111  const edm::InputTag& l1GtRecordInputTag,
1112  const edm::InputTag& l1GtReadoutRecordInputTag,
1113  const std::string& nameAlgoTechTrig, int& errorCode) const {
1114 
1115  // initial values
1116  bool decisionBeforeMask = false;
1117  bool decisionAfterMask = false;
1118  int prescaleFactor = -1;
1119  int triggerMask = -1;
1120 
1121  errorCode = l1Results(iEvent, l1GtRecordInputTag,
1122  l1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
1123  decisionAfterMask, prescaleFactor, triggerMask);
1124 
1125  return decisionBeforeMask;
1126 
1127 }
1128 
1130  const std::string& nameAlgoTechTrig, int& errorCode) const {
1131 
1132  // initial values
1133  bool decisionBeforeMask = false;
1134  bool decisionAfterMask = false;
1135  int prescaleFactor = -1;
1136  int triggerMask = -1;
1137 
1138  errorCode = l1Results(iEvent, nameAlgoTechTrig, decisionBeforeMask,
1139  decisionAfterMask, prescaleFactor, triggerMask);
1140 
1141  return decisionBeforeMask;
1142 
1143 }
1144 
1145 //
1146 
1148  const edm::InputTag& l1GtRecordInputTag,
1149  const edm::InputTag& l1GtReadoutRecordInputTag,
1150  const std::string& nameAlgoTechTrig, int& errorCode) const {
1151 
1152  // initial values
1153  bool decisionBeforeMask = false;
1154  bool decisionAfterMask = false;
1155  int prescaleFactor = -1;
1156  int triggerMask = -1;
1157 
1158  errorCode = l1Results(iEvent, l1GtRecordInputTag,
1159  l1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
1160  decisionAfterMask, prescaleFactor, triggerMask);
1161 
1162  return decisionAfterMask;
1163 
1164 }
1165 
1167  const std::string& nameAlgoTechTrig, int& errorCode) const {
1168 
1169  // initial values
1170  bool decisionBeforeMask = false;
1171  bool decisionAfterMask = false;
1172  int prescaleFactor = -1;
1173  int triggerMask = -1;
1174 
1175  errorCode = l1Results(iEvent, nameAlgoTechTrig, decisionBeforeMask,
1176  decisionAfterMask, prescaleFactor, triggerMask);
1177 
1178  return decisionAfterMask;
1179 
1180 }
1181 
1182 //
1183 
1185  const edm::InputTag& l1GtRecordInputTag,
1186  const edm::InputTag& l1GtReadoutRecordInputTag,
1187  const std::string& nameAlgoTechTrig, int& errorCode) const {
1188 
1189  // initial values
1190  bool decisionBeforeMask = false;
1191  bool decisionAfterMask = false;
1192  int prescaleFactor = -1;
1193  int triggerMask = -1;
1194 
1195  errorCode = l1Results(iEvent, l1GtRecordInputTag,
1196  l1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
1197  decisionAfterMask, prescaleFactor, triggerMask);
1198 
1199  return decisionAfterMask;
1200 
1201 }
1202 
1204  const std::string& nameAlgoTechTrig, int& errorCode) const {
1205 
1206  // initial values
1207  bool decisionBeforeMask = false;
1208  bool decisionAfterMask = false;
1209  int prescaleFactor = -1;
1210  int triggerMask = -1;
1211 
1212  errorCode = l1Results(iEvent, nameAlgoTechTrig, decisionBeforeMask,
1213  decisionAfterMask, prescaleFactor, triggerMask);
1214 
1215  return decisionAfterMask;
1216 
1217 }
1218 
1219 //
1220 
1222  const edm::InputTag& l1GtRecordInputTag,
1223  const edm::InputTag& l1GtReadoutRecordInputTag,
1224  const std::string& nameAlgoTechTrig, int& errorCode) const {
1225 
1226  // initial values
1227  bool decisionBeforeMask = false;
1228  bool decisionAfterMask = false;
1229  int prescaleFactor = -1;
1230  int triggerMask = -1;
1231 
1232  errorCode = l1Results(iEvent, l1GtRecordInputTag,
1233  l1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
1234  decisionAfterMask, prescaleFactor, triggerMask);
1235 
1236  return prescaleFactor;
1237 
1238 }
1239 
1241  const std::string& nameAlgoTechTrig, int& errorCode) const {
1242 
1243  // initial values
1244  bool decisionBeforeMask = false;
1245  bool decisionAfterMask = false;
1246  int prescaleFactor = -1;
1247  int triggerMask = -1;
1248 
1249  errorCode = l1Results(iEvent, nameAlgoTechTrig, decisionBeforeMask,
1250  decisionAfterMask, prescaleFactor, triggerMask);
1251 
1252  return prescaleFactor;
1253 
1254 }
1255 
1257  const edm::InputTag& l1GtRecordInputTag,
1258  const edm::InputTag& l1GtReadoutRecordInputTag,
1259  const std::string& nameAlgoTechTrig, int& errorCode) const {
1260 
1261  // initial values
1262  bool decisionBeforeMask = false;
1263  bool decisionAfterMask = false;
1264  int prescaleFactor = -1;
1265  int triggerMask = -1;
1266 
1267  errorCode = l1Results(iEvent, l1GtRecordInputTag,
1268  l1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
1269  decisionAfterMask, prescaleFactor, triggerMask);
1270 
1271  return triggerMask;
1272 
1273 }
1274 
1276  const std::string& nameAlgoTechTrig, int& errorCode) const {
1277 
1278  // initial values
1279  bool decisionBeforeMask = false;
1280  bool decisionAfterMask = false;
1281  int prescaleFactor = -1;
1282  int triggerMask = -1;
1283 
1284  errorCode = l1Results(iEvent, nameAlgoTechTrig, decisionBeforeMask,
1285  decisionAfterMask, prescaleFactor, triggerMask);
1286 
1287  return triggerMask;
1288 
1289 }
1290 
1291 const int L1GtUtils::triggerMask(const std::string& nameAlgoTechTrig,
1292  int& errorCode) const {
1293 
1294  // initial values for returned results
1295  int triggerMaskValue = -1;
1296 
1297  // initialize error code and L1 configuration code
1298  int iError = 0;
1299  int l1ConfCode = 0;
1300 
1301  // check if L1 configuration is available
1302 
1303  if (!availableL1Configuration(iError, l1ConfCode)) {
1304  errorCode = iError;
1305  return triggerMaskValue;
1306  }
1307 
1308  // at this point, a valid L1 configuration is available, so the if/else if/else
1309  // can be simplified
1310 
1311  // if the given name is not an algorithm trigger alias, an algorithm trigger name
1312  // or a technical trigger in the current menu, return with error code 1
1313 
1314  TriggerCategory trigCategory = AlgorithmTrigger;
1315  int bitNumber = -1;
1316 
1317  if (!l1AlgoTechTrigBitNumber(nameAlgoTechTrig, trigCategory, bitNumber)) {
1318 
1319  iError = l1ConfCode + 1;
1320 
1322  if (m_l1GtMenuLiteValid) {
1323 
1324  LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
1325  << nameAlgoTechTrig
1326  << "\not found in the trigger menu \n "
1328  << "\nretrieved from L1GtTriggerMenuLite" << std::endl;
1329 
1330  } else {
1331 
1332  // fall through: L1 trigger configuration from event setup
1333  LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
1334  << nameAlgoTechTrig
1335  << "\not found in the trigger menu \n "
1337  << "\nretrieved from Event Setup" << std::endl;
1338 
1339  }
1340 
1341  } else {
1342  // L1 trigger configuration from event setup only
1343  LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
1344  << nameAlgoTechTrig
1345  << "\not found in the trigger menu \n "
1347  << "\nretrieved from Event Setup" << std::endl;
1348 
1349  }
1350 
1351  errorCode = iError;
1352  return triggerMaskValue;
1353 
1354  }
1355 
1356  // check here if a positive bit number was retrieved
1357  // exit in case of negative bit number, before retrieving L1 GT products, saving time
1358 
1359  if (bitNumber < 0) {
1360 
1361  iError = l1ConfCode + 2;
1362 
1364  if (m_l1GtMenuLiteValid) {
1365  LogDebug("L1GtUtils") << "\nNegative bit number for "
1366  << triggerCategory(trigCategory) << "\n "
1367  << nameAlgoTechTrig << "\nfrom menu \n "
1369  << "\nretrieved from L1GtTriggerMenuLite" << std::endl;
1370 
1371  } else {
1372  // fall through: L1 trigger configuration from event setup
1373  LogDebug("L1GtUtils") << "\nNegative bit number for "
1374  << triggerCategory(trigCategory) << "\n "
1375  << nameAlgoTechTrig << "\nfrom menu \n "
1377  << "\nretrieved from Event Setup" << std::endl;
1378 
1379  }
1380 
1381  } else {
1382  // L1 trigger configuration from event setup only
1383  LogDebug("L1GtUtils") << "\nNegative bit number for "
1384  << triggerCategory(trigCategory) << "\n "
1385  << nameAlgoTechTrig << "\nfrom menu \n "
1387  << "\nretrieved from Event Setup" << std::endl;
1388 
1389  }
1390 
1391  errorCode = iError;
1392  return triggerMaskValue;
1393  }
1394 
1395  // depending on trigger category (algorithm trigger or technical trigger)
1396  // get the correct quantities
1397 
1398  // pointer to the set of trigger masks
1399 
1400  const std::vector<unsigned int>* triggerMasksSet = 0;
1401 
1402  switch (trigCategory) {
1403  case AlgorithmTrigger: {
1405  if (m_l1GtMenuLiteValid) {
1406  triggerMasksSet = m_triggerMaskAlgoTrigLite;
1407 
1408  } else {
1409  // fall through: L1 trigger configuration from event setup
1410  triggerMasksSet = m_triggerMaskAlgoTrig;
1411 
1412  }
1413 
1414  } else {
1415  // L1 trigger configuration from event setup only
1416  triggerMasksSet = m_triggerMaskAlgoTrig;
1417 
1418  }
1419 
1420  }
1421  break;
1422  case TechnicalTrigger: {
1424  if (m_l1GtMenuLiteValid) {
1425  triggerMasksSet = m_triggerMaskTechTrigLite;
1426 
1427  } else {
1428  // fall through: L1 trigger configuration from event setup
1429  triggerMasksSet = m_triggerMaskTechTrig;
1430 
1431  }
1432 
1433  } else {
1434  // L1 trigger configuration from event setup only
1435  triggerMasksSet = m_triggerMaskTechTrig;
1436 
1437  }
1438 
1439  }
1440  break;
1441  default: {
1442  // should not be the case
1443  iError = l1ConfCode + 3;
1444 
1445  errorCode = iError;
1446  return triggerMaskValue;
1447 
1448  }
1449  break;
1450  }
1451 
1452  // trigger mask
1453 
1454  if (bitNumber < (static_cast<int> ((*triggerMasksSet).size()))) {
1455 
1457  if (m_l1GtMenuLiteValid) {
1458  triggerMaskValue = (*triggerMasksSet)[bitNumber];
1459 
1460  } else {
1461  // fall through: L1 trigger configuration from event setup
1462  // masks in event setup are for all partitions
1463  triggerMaskValue = ((*triggerMasksSet)[bitNumber]) & (1
1465 
1466  }
1467 
1468  } else {
1469  // L1 trigger configuration from event setup only
1470  // masks in event setup are for all partitions
1471  triggerMaskValue = ((*triggerMasksSet)[bitNumber]) & (1
1473 
1474  }
1475 
1476  } else {
1477  iError = l1ConfCode + 5000;
1478  LogDebug("L1GtUtils") << "\nError: bit number " << bitNumber
1479  << " retrieved for " << triggerCategory(trigCategory) << "\n "
1480  << nameAlgoTechTrig
1481  << "\ngreater than size of L1 GT trigger mask set: "
1482  << (*triggerMasksSet).size()
1483  << "\nError: Inconsistent L1 trigger configuration!"
1484  << std::endl;
1485 
1486  errorCode = iError;
1487  return triggerMaskValue;
1488 
1489  }
1490 
1491  errorCode = iError;
1492  return triggerMaskValue;
1493 
1494 }
1495 
1497  const edm::InputTag& l1GtRecordInputTag,
1498  const edm::InputTag& l1GtReadoutRecordInputTag,
1499  const TriggerCategory& trigCategory, int& errorCode) const {
1500 
1501  // initialize the index to a negative value
1502  int pfIndex = -1;
1503 
1504  // initialize error code and L1 configuration code
1505  int iError = 0;
1506  int l1ConfCode = 0;
1507 
1508  // check if L1 configuration is available
1509 
1510  if (!availableL1Configuration(iError, l1ConfCode)) {
1511  errorCode = iError;
1512  return pfIndex;
1513  }
1514 
1515  // at this point, a valid L1 configuration is available, so the if/else if/else
1516  // can be simplified
1517 
1518  // retrieve L1GlobalTriggerRecord and 1GlobalTriggerReadoutRecord product
1519  // intermediate error code for the records
1520  // the module returns an error code only if both the lite and the readout record are missing
1521 
1522  int iErrorRecord = 0;
1523 
1524  bool validRecord = false;
1525  bool gtRecordValid = false;
1526  bool gtReadoutRecordValid = false;
1527 
1529  iEvent.getByLabel(l1GtRecordInputTag, gtRecord);
1530 
1531  if (gtRecord.isValid()) {
1532 
1533  gtRecordValid = true;
1534  validRecord = true;
1535 
1536  } else {
1537 
1538  iErrorRecord = 10;
1539  LogDebug("L1GtUtils") << "\nL1GlobalTriggerRecord with \n "
1540  << l1GtRecordInputTag << "\nnot found in the event."
1541  << std::endl;
1542  }
1543 
1545  iEvent.getByLabel(l1GtReadoutRecordInputTag, gtReadoutRecord);
1546 
1547  if (gtReadoutRecord.isValid()) {
1548 
1549  gtReadoutRecordValid = true;
1550  validRecord = true;
1551 
1552  } else {
1553 
1554  iErrorRecord = iErrorRecord + 100;
1555  LogDebug("L1GtUtils") << "\nL1GlobalTriggerReadoutRecord with \n "
1556  << l1GtReadoutRecordInputTag << "\nnot found in the event."
1557  << std::endl;
1558 
1559  }
1560 
1561  // get the prescale factor index from
1562  // L1GlobalTriggerReadoutRecord if valid
1563  // if not, from L1GlobalTriggerRecord if valid
1564  // else return an error
1565 
1566 
1567  int pfIndexTechTrig = -1;
1568  int pfIndexAlgoTrig = -1;
1569 
1570  if (validRecord) {
1571  if (gtReadoutRecordValid) {
1572 
1573  pfIndexTechTrig
1574  = (gtReadoutRecord->gtFdlWord()).gtPrescaleFactorIndexTech();
1575  pfIndexAlgoTrig
1576  = (gtReadoutRecord->gtFdlWord()).gtPrescaleFactorIndexAlgo();
1577 
1578  } else {
1579 
1580  pfIndexTechTrig
1581  = static_cast<int> (gtRecord->gtPrescaleFactorIndexTech());
1582  pfIndexAlgoTrig
1583  = static_cast<int> (gtRecord->gtPrescaleFactorIndexAlgo());
1584 
1585  }
1586 
1587  } else {
1588 
1589  LogDebug("L1GtUtils") << "\nError: "
1590  << "\nNo valid L1GlobalTriggerRecord with \n "
1591  << l1GtRecordInputTag << "\nfound in the event."
1592  << "\nNo valid L1GlobalTriggerReadoutRecord with \n "
1593  << l1GtReadoutRecordInputTag << "\nfound in the event."
1594  << std::endl;
1595 
1596  iError = l1ConfCode + iErrorRecord;
1597 
1598  errorCode = iError;
1599  return pfIndex;
1600 
1601  }
1602 
1603  // depending on trigger category (algorithm trigger or technical trigger)
1604  // get the correct quantities
1605 
1606  // number of sets of prescale factors
1607  // index of prescale factor set retrieved from data
1608  // pointer to the actual prescale factor set
1609  // pointer to the set of trigger masks
1610 
1611  size_t pfSetsSize = 0;
1612 
1613  switch (trigCategory) {
1614  case AlgorithmTrigger: {
1616  if (m_l1GtMenuLiteValid) {
1617  pfSetsSize = m_prescaleFactorsAlgoTrigLite->size();
1618 
1619  } else {
1620  // fall through: L1 trigger configuration from event setup
1621  pfSetsSize = m_prescaleFactorsAlgoTrig->size();
1622 
1623  }
1624 
1625  } else {
1626  // L1 trigger configuration from event setup only
1627  pfSetsSize = m_prescaleFactorsAlgoTrig->size();
1628 
1629  }
1630 
1631  pfIndex = pfIndexAlgoTrig;
1632 
1633  }
1634  break;
1635  case TechnicalTrigger: {
1637  if (m_l1GtMenuLiteValid) {
1638  pfSetsSize = m_prescaleFactorsTechTrigLite->size();
1639 
1640  } else {
1641  // fall through: L1 trigger configuration from event setup
1642  pfSetsSize = m_prescaleFactorsTechTrig->size();
1643 
1644  }
1645 
1646  } else {
1647  // L1 trigger configuration from event setup only
1648  pfSetsSize = m_prescaleFactorsTechTrig->size();
1649 
1650  }
1651 
1652  pfIndex = pfIndexTechTrig;
1653 
1654  }
1655  break;
1656  default: {
1657  // should not be the case
1658  iError = l1ConfCode + iErrorRecord + 3;
1659  return iError;
1660 
1661  }
1662  break;
1663  }
1664 
1665 
1666  // test prescale factor set index correctness, then retrieve the actual set of prescale factors
1667 
1668  if (pfIndex < 0) {
1669 
1670  iError = l1ConfCode + iErrorRecord + 1000;
1671  LogDebug("L1GtUtils")
1672  << "\nError: index of prescale factor set retrieved from the data \n"
1673  << "less than zero."
1674  << "\n Value of index retrieved from data = " << pfIndex
1675  << std::endl;
1676 
1677  errorCode = iError;
1678  return pfIndex;
1679 
1680  } else if (pfIndex >= (static_cast<int>(pfSetsSize))) {
1681  iError = l1ConfCode + iErrorRecord + 2000;
1682  LogDebug("L1GtUtils")
1683  << "\nError: index of prescale factor set retrieved from the data \n"
1684  << "greater than the size of the vector of prescale factor sets."
1685  << "\n Value of index retrieved from data = " << pfIndex
1686  << "\n Vector size = " << pfSetsSize << std::endl;
1687 
1688  errorCode = iError;
1689  return pfIndex;
1690 
1691  } else {
1692 
1693  errorCode = iError;
1694  return pfIndex;
1695  }
1696 
1697  errorCode = iError;
1698  return pfIndex;
1699 
1700 }
1701 
1702 
1704  const TriggerCategory& trigCategory, int& errorCode) const {
1705 
1706  // initialize error code and return value
1707  int iError = 0;
1708  int pfIndex = -1;
1709 
1710  edm::InputTag l1GtRecordInputTag;
1711  edm::InputTag l1GtReadoutRecordInputTag;
1712 
1713  getInputTag(iEvent, l1GtRecordInputTag, l1GtReadoutRecordInputTag);
1714 
1715  pfIndex = prescaleFactorSetIndex(iEvent, l1GtRecordInputTag,
1716  l1GtReadoutRecordInputTag, trigCategory, iError);
1717 
1718  // return the error code and the index value
1719  // if the error code is 0, the index returned is -1
1720  errorCode = iError;
1721  return pfIndex;
1722 
1723 }
1724 
1725 
1726 // deprecated
1728  const edm::InputTag& l1GtRecordInputTag,
1729  const edm::InputTag& l1GtReadoutRecordInputTag,
1730  const std::string& triggerAlgoTechTrig, int& errorCode) const {
1731 
1732  // initialize error code and return value
1733  int iError = 0;
1734  int l1ConfCode = 0;
1735  int pfIndex = -1;
1736 
1737  // check if L1 configuration is available
1738 
1739  if (!availableL1Configuration(iError, l1ConfCode)) {
1740  errorCode = iError;
1741  return pfIndex;
1742  }
1743 
1744  // test if the argument for the "trigger algorithm type" is correct
1745  TriggerCategory trigCategory = AlgorithmTrigger;
1746 
1747  if (triggerAlgoTechTrig == "TechnicalTriggers") {
1748  trigCategory = TechnicalTrigger;
1749 
1750  } else if (triggerAlgoTechTrig == "PhysicsAlgorithms") {
1751  trigCategory = AlgorithmTrigger;
1752 
1753  } else {
1754 
1755  LogDebug("L1GtUtils")
1756  << "\nErrr : prescale factor set index cannot be retrieved for the argument "
1757  << triggerAlgoTechTrig
1758  << "\n Supported arguments: 'PhysicsAlgorithms' or 'TechnicalTriggers'"
1759  << "\nWarning: this method is deprecated, please use method with TriggerCategory."
1760  << std::endl;
1761 
1762  iError = l1ConfCode + 6000;
1763 
1764  errorCode = iError;
1765  return pfIndex;
1766 
1767  }
1768 
1769  pfIndex = prescaleFactorSetIndex(iEvent, l1GtRecordInputTag,
1770  l1GtReadoutRecordInputTag, trigCategory, errorCode);
1771 
1772  errorCode = iError;
1773  return pfIndex;
1774 
1775 }
1776 
1777 // deprecated
1779  const std::string& triggerAlgoTechTrig, int& errorCode) const {
1780 
1781  // initialize error code and return value
1782  int iError = 0;
1783  int pfIndex = -1;
1784 
1785  edm::InputTag l1GtRecordInputTag;
1786  edm::InputTag l1GtReadoutRecordInputTag;
1787 
1788  getInputTag(iEvent, l1GtRecordInputTag, l1GtReadoutRecordInputTag);
1789 
1790  pfIndex = prescaleFactorSetIndex(iEvent, l1GtRecordInputTag,
1791  l1GtReadoutRecordInputTag, triggerAlgoTechTrig, iError);
1792 
1793  // return the error code and the index value
1794  // if the error code is not 0, the index returned is -1
1795  errorCode = iError;
1796  return pfIndex;
1797 
1798 }
1799 
1800 const std::vector<int>& L1GtUtils::prescaleFactorSet(const edm::Event& iEvent,
1801  const edm::InputTag& l1GtRecordInputTag,
1802  const edm::InputTag& l1GtReadoutRecordInputTag,
1803  const TriggerCategory& trigCategory, int& errorCode) {
1804 
1805  // clear the vector before filling it
1806  m_prescaleFactorSet.clear();
1807 
1808  // initialize error code
1809  int iError = 0;
1810 
1811  const int pfIndex = prescaleFactorSetIndex(iEvent, l1GtRecordInputTag,
1812  l1GtReadoutRecordInputTag, trigCategory, iError);
1813 
1814  if (iError == 0) {
1815 
1816  switch (trigCategory) {
1817  case AlgorithmTrigger: {
1819  if (m_l1GtMenuLiteValid) {
1821  = (*m_prescaleFactorsAlgoTrigLite).at(pfIndex);
1822 
1823  } else {
1824  // fall through: L1 trigger configuration from event setup
1825  m_prescaleFactorSet = (*m_prescaleFactorsAlgoTrig).at(
1826  pfIndex);
1827 
1828  }
1829 
1830  } else {
1831  // L1 trigger configuration from event setup only
1832  m_prescaleFactorSet = (*m_prescaleFactorsAlgoTrig).at(
1833  pfIndex);
1834 
1835  }
1836 
1837  }
1838  break;
1839  case TechnicalTrigger: {
1841  if (m_l1GtMenuLiteValid) {
1843  = (*m_prescaleFactorsTechTrigLite).at(pfIndex);
1844 
1845  } else {
1846  // fall through: L1 trigger configuration from event setup
1847  m_prescaleFactorSet = (*m_prescaleFactorsTechTrig).at(
1848  pfIndex);
1849 
1850  }
1851 
1852  } else {
1853  // L1 trigger configuration from event setup only
1854  m_prescaleFactorSet = (*m_prescaleFactorsTechTrig).at(
1855  pfIndex);
1856 
1857  }
1858 
1859  }
1860  break;
1861  default: {
1862  // do nothing - it was tested before, with return
1863 
1864  }
1865  break;
1866  }
1867 
1868  }
1869 
1870  errorCode = iError;
1871  return m_prescaleFactorSet;
1872 
1873 }
1874 
1875 const std::vector<int>& L1GtUtils::prescaleFactorSet(const edm::Event& iEvent,
1876  const TriggerCategory& trigCategory, int& errorCode) {
1877 
1878  // clear the vector before filling it
1879  m_prescaleFactorSet.clear();
1880 
1881  // initialize error code
1882  int iError = 0;
1883 
1884  edm::InputTag l1GtRecordInputTag;
1885  edm::InputTag l1GtReadoutRecordInputTag;
1886 
1887  getInputTag(iEvent, l1GtRecordInputTag, l1GtReadoutRecordInputTag);
1888 
1889  m_prescaleFactorSet = prescaleFactorSet(iEvent, l1GtRecordInputTag,
1890  l1GtReadoutRecordInputTag, trigCategory, iError);
1891 
1892  errorCode = iError;
1893  return m_prescaleFactorSet;
1894 
1895 }
1896 
1897 
1898 // deprecated
1899 const std::vector<int>& L1GtUtils::prescaleFactorSet(const edm::Event& iEvent,
1900  const edm::InputTag& l1GtRecordInputTag,
1901  const edm::InputTag& l1GtReadoutRecordInputTag,
1902  const std::string& triggerAlgoTechTrig, int& errorCode) {
1903 
1904  // clear the vector before filling it
1905  m_prescaleFactorSet.clear();
1906 
1907  // initialize error code and return value
1908  int iError = 0;
1909  int l1ConfCode = 0;
1910 
1911  // check if L1 configuration is available
1912 
1913  if (!availableL1Configuration(iError, l1ConfCode)) {
1914  errorCode = iError;
1915  return m_prescaleFactorSet;
1916  }
1917 
1918  // test if the argument for the "trigger algorithm type" is correct
1919  TriggerCategory trigCategory = AlgorithmTrigger;
1920 
1921  if (triggerAlgoTechTrig == "TechnicalTriggers") {
1922  trigCategory = TechnicalTrigger;
1923 
1924  } else if (triggerAlgoTechTrig == "PhysicsAlgorithms") {
1925  trigCategory = AlgorithmTrigger;
1926 
1927  } else {
1928 
1929  LogDebug("L1GtUtils")
1930  << "\nErrr : prescale factor set cannot be retrieved for the argument "
1931  << triggerAlgoTechTrig
1932  << "\n Supported arguments: 'PhysicsAlgorithms' or 'TechnicalTriggers'"
1933  << "\nWarning: this method is deprecated, please use method with TriggerCategory."
1934  << std::endl;
1935 
1936  iError = l1ConfCode + 6000;
1937 
1938  errorCode = iError;
1939  return m_prescaleFactorSet;
1940 
1941  }
1942 
1943  m_prescaleFactorSet = prescaleFactorSet(iEvent, l1GtRecordInputTag,
1944  l1GtReadoutRecordInputTag, trigCategory, iError);
1945 
1946  errorCode = iError;
1947  return m_prescaleFactorSet;
1948 }
1949 
1950 
1951 // deprecated
1952 const std::vector<int>& L1GtUtils::prescaleFactorSet(const edm::Event& iEvent,
1953  const std::string& triggerAlgoTechTrig, int& errorCode) {
1954 
1955  // initialize error code
1956  int iError = 0;
1957 
1958  edm::InputTag l1GtRecordInputTag;
1959  edm::InputTag l1GtReadoutRecordInputTag;
1960 
1961  getInputTag(iEvent, l1GtRecordInputTag, l1GtReadoutRecordInputTag);
1962 
1963  m_prescaleFactorSet = prescaleFactorSet(iEvent, l1GtRecordInputTag,
1964  l1GtReadoutRecordInputTag, triggerAlgoTechTrig, iError);
1965 
1966  errorCode = iError;
1967  return m_prescaleFactorSet;
1968 
1969 }
1970 
1971 
1972 const std::vector<unsigned int>& L1GtUtils::triggerMaskSet(
1973  const TriggerCategory& trigCategory, int& errorCode) {
1974 
1975  // clear the vector before filling it
1976  m_triggerMaskSet.clear();
1977 
1978  // initialize error code and L1 configuration code
1979  int iError = 0;
1980  int l1ConfCode = 0;
1981 
1982  // check if L1 configuration is available
1983 
1984  if (!availableL1Configuration(iError, l1ConfCode)) {
1985  errorCode = iError;
1986  return m_triggerMaskSet;
1987  }
1988 
1989  // at this point, a valid L1 configuration is available, so the if/else if/else
1990  // can be simplified
1991 
1992 
1993  // depending on trigger category (algorithm trigger or technical trigger)
1994  // get the correct quantities
1995 
1996  // pointer to the set of trigger masks
1997 
1998  switch (trigCategory) {
1999  case AlgorithmTrigger: {
2001  // L1GtTriggerMenuLite has masks for physics partition only
2002  // avoid copy to m_triggerMaskSet, return directly m_triggerMaskAlgoTrigLite
2003  if (m_l1GtMenuLiteValid) {
2004  errorCode = iError;
2005  return (*m_triggerMaskAlgoTrigLite);
2006 
2007  } else {
2008  // fall through: L1 trigger configuration from event setup
2009  for (unsigned i = 0; i < m_triggerMaskAlgoTrig->size(); i++) {
2010  m_triggerMaskSet.push_back(
2011  ((*m_triggerMaskAlgoTrig)[i]) & (1
2012  << m_physicsDaqPartition));
2013  }
2014 
2015  }
2016 
2017  } else {
2018  // L1 trigger configuration from event setup only
2019  for (unsigned i = 0; i < m_triggerMaskAlgoTrig->size(); i++) {
2020  m_triggerMaskSet.push_back(((*m_triggerMaskAlgoTrig)[i])
2021  & (1 << m_physicsDaqPartition));
2022  }
2023 
2024  }
2025  }
2026  break;
2027  case TechnicalTrigger: {
2029  if (m_l1GtMenuLiteValid) {
2030  errorCode = iError;
2031  return (*m_triggerMaskTechTrigLite);
2032 
2033  } else {
2034  // fall through: L1 trigger configuration from event setup
2035  for (unsigned i = 0; i < m_triggerMaskTechTrig->size(); i++) {
2036  m_triggerMaskSet.push_back(
2037  ((*m_triggerMaskTechTrig)[i]) & (1
2038  << m_physicsDaqPartition));
2039  }
2040 
2041  }
2042 
2043  } else {
2044  // L1 trigger configuration from event setup only
2045  for (unsigned i = 0; i < m_triggerMaskTechTrig->size(); i++) {
2046  m_triggerMaskSet.push_back(((*m_triggerMaskTechTrig)[i])
2047  & (1 << m_physicsDaqPartition));
2048  }
2049 
2050  }
2051  }
2052  break;
2053  default: {
2054  // should not be the case
2055  iError = l1ConfCode + 3;
2056 
2057  errorCode = iError;
2058  return m_triggerMaskSet;
2059 
2060  }
2061  break;
2062  }
2063 
2064  errorCode = iError;
2065  return m_triggerMaskSet;
2066 
2067 }
2068 
2069 
2070 //deprecated
2071 const std::vector<unsigned int>& L1GtUtils::triggerMaskSet(
2072  const std::string& triggerAlgoTechTrig, int& errorCode) {
2073 
2074  // clear the vector before filling it
2075  m_triggerMaskSet.clear();
2076 
2077  // initialize error code and return value
2078  int iError = 0;
2079  int l1ConfCode = 0;
2080 
2081  // check if L1 configuration is available
2082 
2083  if (!availableL1Configuration(iError, l1ConfCode)) {
2084  errorCode = iError;
2085  return m_triggerMaskSet;
2086  }
2087 
2088  // test if the argument for the "trigger algorithm type" is correct
2089  TriggerCategory trigCategory = AlgorithmTrigger;
2090 
2091  if (triggerAlgoTechTrig == "TechnicalTriggers") {
2092  trigCategory = TechnicalTrigger;
2093 
2094  } else if (triggerAlgoTechTrig == "PhysicsAlgorithms") {
2095  trigCategory = AlgorithmTrigger;
2096 
2097  } else {
2098 
2099  LogDebug("L1GtUtils")
2100  << "\nErrr : trigger mask set cannot be retrieved for the argument "
2101  << triggerAlgoTechTrig
2102  << "\n Supported arguments: 'PhysicsAlgorithms' or 'TechnicalTriggers'"
2103  << "\nWarning: this method is deprecated, please use method with TriggerCategory."
2104  << std::endl;
2105 
2106  iError = l1ConfCode + 6000;
2107 
2108  errorCode = iError;
2109  return m_triggerMaskSet;
2110 
2111  }
2112 
2113  m_triggerMaskSet = triggerMaskSet(trigCategory, iError);
2114 
2115  errorCode = iError;
2116  return m_triggerMaskSet;
2117 
2118 }
2119 
2120 const std::string& L1GtUtils::l1TriggerMenu() const {
2121 
2123  if (m_l1GtMenuLiteValid) {
2125 
2126  } else if (m_retrieveL1EventSetup) {
2127  return m_l1GtMenu->gtTriggerMenuName();
2128 
2129  } else {
2130  // only L1GtTriggerMenuLite requested, but it is not valid
2131  return EmptyString;
2132 
2133  }
2134  } else if (m_retrieveL1EventSetup) {
2135  return m_l1GtMenu->gtTriggerMenuName();
2136 
2137  } else {
2138  // L1 trigger configuration not retrieved
2139  return EmptyString;
2140 
2141  }
2142 
2143 }
2144 
2145 const std::string& L1GtUtils::l1TriggerMenuImplementation() const {
2146 
2148  if (m_l1GtMenuLiteValid) {
2150 
2151  } else if (m_retrieveL1EventSetup) {
2153 
2154  } else {
2155  // only L1GtTriggerMenuLite requested, but it is not valid
2156  return EmptyString;
2157 
2158  }
2159  } else if (m_retrieveL1EventSetup) {
2161 
2162  } else {
2163  // L1 trigger configuration not retrieved
2164  return EmptyString;
2165 
2166  }
2167 
2168 }
2169 
2171 
2172  // initialize error code and return value
2173  int iError = 0;
2174  int l1ConfCode = 0;
2175 
2176  // check if L1 configuration is available
2177 
2178  if (!availableL1Configuration(iError, l1ConfCode)) {
2179  errorCode = iError;
2180  return 0;
2181  }
2182 
2183  if (m_retrieveL1EventSetup) {
2184  errorCode = iError;
2185  return m_l1GtMenu;
2186  } else {
2187  iError = l1ConfCode;
2188 
2189  errorCode = iError;
2190  return 0;
2191 
2192  }
2193 
2194  errorCode = iError;
2195  return m_l1GtMenu;
2196 }
2197 
2199 
2200  // initialize error code and return value
2201  int iError = 0;
2202  int l1ConfCode = 0;
2203 
2204  // check if L1 configuration is available
2205 
2206  if (!availableL1Configuration(iError, l1ConfCode)) {
2207  errorCode = iError;
2208  return 0;
2209  }
2210 
2212  if (m_l1GtMenuLiteValid) {
2213 
2214  errorCode = iError;
2215  return m_l1GtMenuLite;
2216 
2217  } else {
2218  iError = l1ConfCode;
2219 
2220  errorCode = iError;
2221  return 0;
2222  }
2223  } else {
2224  iError = l1ConfCode;
2225 
2226  errorCode = iError;
2227  return 0;
2228  }
2229 
2230  errorCode = iError;
2231  return m_l1GtMenuLite;
2232 
2233 }
2234 
2235 const bool L1GtUtils::availableL1Configuration(int& errorCode, int& l1ConfCode) const {
2236 
2238  if (!m_retrieveL1EventSetup) {
2239  LogDebug("L1GtUtils")
2240  << "\nRetrieve L1 trigger configuration from L1GtTriggerMenuLite only\n"
2241  << std::endl;
2242  l1ConfCode = 0;
2243  } else {
2244  LogDebug("L1GtUtils")
2245  << "\nFall through: retrieve L1 trigger configuration from L1GtTriggerMenuLite"
2246  << "\n if L1GtTriggerMenuLite not valid, try to retrieve from event setup "
2247  << std::endl;
2248  l1ConfCode = 100000;
2249  }
2250 
2251  if (m_l1GtMenuLiteValid) {
2252  LogDebug("L1GtUtils")
2253  << "\nRetrieve L1 trigger configuration from L1GtTriggerMenuLite, valid product\n"
2254  << std::endl;
2255  l1ConfCode = l1ConfCode + 10000;
2256  errorCode = 0;
2257 
2258  return true;
2259 
2260  } else if (m_retrieveL1EventSetup) {
2261  if (m_l1EventSetupValid) {
2262  LogDebug("L1GtUtils")
2263  << "\nFall through: retrieve L1 trigger configuration from event setup."
2264  << "\nFirst option was L1GtTriggerMenuLite - but product is not valid.\n"
2265  << std::endl;
2266  l1ConfCode = l1ConfCode + 20000;
2267  errorCode = 0;
2268 
2269  return true;
2270 
2271  } else {
2272  LogDebug("L1GtUtils")
2273  << "\nFall through: L1GtTriggerMenuLite not valid, event setup not valid.\n"
2274  << std::endl;
2275  l1ConfCode = l1ConfCode + L1GtNotValidError;
2276  errorCode = l1ConfCode;
2277 
2278  return false;
2279 
2280 
2281  }
2282 
2283  } else {
2284  LogDebug("L1GtUtils")
2285  << "\nError: L1 trigger configuration requested from L1GtTriggerMenuLite only"
2286  << "\nbut L1GtTriggerMenuLite is not valid.\n" << std::endl;
2287  l1ConfCode = l1ConfCode + L1GtNotValidError;
2288  errorCode = l1ConfCode;
2289 
2290  return false;
2291 
2292  }
2293  } else if (m_retrieveL1EventSetup) {
2294 
2295  LogDebug("L1GtUtils")
2296  << "\nRetrieve L1 trigger configuration from event setup."
2297  << "\nL1GtTriggerMenuLite product was not requested.\n"
2298  << std::endl;
2299  l1ConfCode = 200000;
2300 
2301  if (m_l1EventSetupValid) {
2302  LogDebug("L1GtUtils")
2303  << "\nRetrieve L1 trigger configuration from event setup only."
2304  << "\nValid L1 trigger event setup.\n"
2305  << std::endl;
2306  l1ConfCode = l1ConfCode + 10000;
2307  errorCode = 0;
2308 
2309  return true;
2310 
2311  } else {
2312  LogDebug("L1GtUtils")
2313  << "\nRetrieve L1 trigger configuration from event setup only."
2314  << "\nNo valid L1 trigger event setup.\n"
2315  << std::endl;
2316  l1ConfCode = l1ConfCode + L1GtNotValidError;
2317  errorCode = l1ConfCode;
2318 
2319  return false;
2320 
2321 
2322  }
2323 
2324  } else {
2325  LogDebug("L1GtUtils")
2326  << "\nError: no L1 trigger configuration requested to be retrieved."
2327  << "\nMust call before either retrieveL1GtTriggerMenuLite or retrieveL1EventSetup.\n"
2328  << std::endl;
2329  l1ConfCode = 300000;
2330  errorCode = l1ConfCode;
2331 
2332  return false;
2333 
2334  }
2335 }
2336 
2337 // private methods
2338 
2339 const bool L1GtUtils::trigResult(const DecisionWord& decWord,
2340  const int bitNumber, const std::string& nameAlgoTechTrig,
2341  const TriggerCategory& trigCategory, int& errorCode) const {
2342 
2343  bool trigRes = false;
2344  errorCode = 0;
2345 
2346  if (bitNumber < (static_cast<int> (decWord.size()))) {
2347  trigRes = decWord[bitNumber];
2348  } else {
2349  errorCode = 3000;
2350  LogDebug("L1GtUtils") << "\nError: bit number " << bitNumber
2351  << " retrieved for " << triggerCategory(trigCategory) << "\n "
2352  << nameAlgoTechTrig
2353  << "\ngreater than size of L1 GT decision word: "
2354  << decWord.size()
2355  << "\nError: Inconsistent L1 trigger configuration!"
2356  << std::endl;
2357  }
2358 
2359  return trigRes;
2360 }
2361 
2362 
2363 const std::string L1GtUtils::EmptyString = "";
2364 const int L1GtUtils::L1GtNotValidError = 99999;
2365 
#define LogDebug(id)
bool m_retrieveL1GtTriggerMenuLite
Definition: L1GtUtils.h:374
const std::string & gtTriggerMenuName() const
bool getByLabel(std::string const &label, Handle< PROD > &result) const
Definition: Run.h:174
void getAllProvenance(std::vector< Provenance const * > &provenances) const
Definition: Event.cc:71
int i
Definition: DBlmapReader.cc:9
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:1147
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:614
std::vector< unsigned int > m_triggerMaskSet
Definition: L1GtUtils.h:369
unsigned long long m_l1GtMenuCacheID
Definition: L1GtUtils.h:332
const std::vector< unsigned int > * m_triggerMaskAlgoTrig
Definition: L1GtUtils.h:324
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:2198
const std::vector< unsigned int > * m_triggerMaskTechTrig
Definition: L1GtUtils.h:325
const L1GtTriggerMask * m_l1GtTmVetoTech
Definition: L1GtUtils.h:321
void getInputTag(const edm::Event &iEvent, edm::InputTag &l1GtRecordInputTag, edm::InputTag &l1GtReadoutRecordInputTag) const
get the input tags for L1GlobalTriggerRecord and L1GlobalTriggerReadoutRecord
Definition: L1GtUtils.cc:339
const bool l1AlgoTechTrigBitNumber(const std::string &nameAlgoTechTrig, TriggerCategory &trigCategory, int &bitNumber) const
Definition: L1GtUtils.cc:470
void getAllProvenance(std::vector< Provenance const * > &provenances) const
Definition: Run.cc:35
TriggerCategory
Definition: L1GtUtils.h:59
const bool availableL1Configuration(int &errorCode, int &l1ConfCode) const
Definition: L1GtUtils.cc:2235
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:353
virtual ~L1GtUtils()
destructor
Definition: L1GtUtils.cc:80
const L1GtTriggerMask * m_l1GtTmAlgo
trigger masks &amp; veto masks
Definition: L1GtUtils.h:312
const AlgorithmMap * m_algorithmMap
Definition: L1GtUtils.h:334
const std::vector< std::vector< int > > * m_prescaleFactorsTechTrig
Definition: L1GtUtils.h:309
Run const & getRun() const
Definition: Event.cc:44
const L1GtStableParameters * m_l1GtStablePar
event setup cached stuff
Definition: L1GtUtils.h:292
const std::string & gtTriggerMenuImplementation() const
unsigned long long m_l1GtPfAlgoCacheID
Definition: L1GtUtils.h:303
const std::vector< unsigned int > & triggerMaskSet(const TriggerCategory &trigCategory, int &errorCode)
Definition: L1GtUtils.cc:1972
void getL1GtTriggerMenuLiteInputTag(const edm::Event &iEvent, edm::InputTag &l1GtTriggerMenuLiteInputTag) const
get the input tags for L1GtTriggerMenuLite
Definition: L1GtUtils.cc:410
const std::string & l1TriggerMenu() const
return the L1 trigger menu name
Definition: L1GtUtils.cc:2120
const std::vector< std::vector< int > > * m_prescaleFactorsAlgoTrig
Definition: L1GtUtils.h:308
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:1110
const L1GtTriggerMenuLite::L1TriggerMap * m_algorithmAliasMapLite
Definition: L1GtUtils.h:347
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
const std::string & gtTriggerMenuName() const
const L1GtTriggerMenuLite::L1TriggerMap * m_algorithmMapLite
Definition: L1GtUtils.h:346
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:322
const edm::RunID * m_runIDCache
Definition: L1GtUtils.h:356
unsigned int gtNumberPhysTriggers() const
get / set the number of physics trigger algorithms
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:1184
const std::string & l1TriggerMenuImplementation() const
return the L1 trigger menu implementation
Definition: L1GtUtils.cc:2145
const AlgorithmMap * m_algorithmAliasMap
Definition: L1GtUtils.h:335
const bool l1AlgTechTrigBitNumber(const std::string &nameAlgoTechTrig, int &triggerAlgoTechTrig, int &bitNumber) const
deprecated version - use l1AlgoTechTrigBitNumber
Definition: L1GtUtils.cc:598
std::string friendlyName(std::string const &iFullName)
unsigned long long m_l1GtTmTechCacheID
Definition: L1GtUtils.h:316
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:354
const L1GtTriggerMask * m_l1GtTmVetoAlgo
Definition: L1GtUtils.h:318
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:277
const edm::RunID * m_provRunIDCache
Definition: L1GtUtils.h:359
const std::string triggerCategory(const TriggerCategory &) const
public methods
Definition: L1GtUtils.cc:86
const L1GtPrescaleFactors * m_l1GtPfAlgo
prescale factors
Definition: L1GtUtils.h:302
unsigned long long m_l1GtTmAlgoCacheID
Definition: L1GtUtils.h:313
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:1800
unsigned int m_numberTechnicalTriggers
number of technical triggers
Definition: L1GtUtils.h:299
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:373
void retrieveL1EventSetup(const edm::EventSetup &)
retrieve all the relevant L1 trigger event setup records and cache them to improve the speed ...
Definition: L1GtUtils.cc:107
const std::vector< std::vector< int > > & gtPrescaleFactorsTechTrig() const
bool isValid() const
Definition: HandleBase.h:76
unsigned int m_physicsDaqPartition
index of physics DAQ partition
Definition: L1GtUtils.h:367
unsigned int m_numberAlgorithmTriggers
number of algorithm triggers
Definition: L1GtUtils.h:296
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
L1TriggerMap::const_iterator CItL1Trig
iterators through map containing the physics algorithms or the technical triggers ...
const L1GtTriggerMask * m_l1GtTmTech
Definition: L1GtUtils.h:315
const L1GtTriggerMenuLite * m_l1GtMenuLite
L1GtTriggerMenuLite cached stuff.
Definition: L1GtUtils.h:344
void retrieveL1GtTriggerMenuLite(const edm::Event &, edm::InputTag &)
Definition: L1GtUtils.cc:283
const std::vector< std::vector< int > > & gtPrescaleFactors() const
get the prescale factors by reference
const L1GtPrescaleFactors * m_l1GtPfTech
Definition: L1GtUtils.h:305
const AlgorithmMap * m_technicalTriggerMap
Definition: L1GtUtils.h:336
const T & get() const
Definition: EventSetup.h:55
const std::vector< unsigned int > * m_triggerMaskVetoAlgoTrig
Definition: L1GtUtils.h:327
T const * product() const
Definition: ESHandle.h:62
const std::vector< unsigned int > * m_triggerMaskTechTrigLite
Definition: L1GtUtils.h:351
RunAuxiliary const & runAuxiliary() const
Definition: Run.h:38
bool m_l1GtMenuLiteValid
Definition: L1GtUtils.h:362
T const * product() const
Definition: Handle.h:74
const std::vector< unsigned int > * m_triggerMaskAlgoTrigLite
Definition: L1GtUtils.h:350
const int prescaleFactorSetIndex(const edm::Event &iEvent, const edm::InputTag &l1GtRecordInputTag, const edm::InputTag &l1GtReadoutRecordInputTag, const TriggerCategory &trigCategory, int &errorCode) const
Definition: L1GtUtils.cc:1496
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:1256
const bool trigResult(const DecisionWord &decWord, const int bitNumber, const std::string &nameAlgoTechTrig, const TriggerCategory &trigCategory, int &errorCode) const
Definition: L1GtUtils.cc:2339
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:331
unsigned long long m_l1GtPfTechCacheID
Definition: L1GtUtils.h:306
static const int L1GtNotValidError
Definition: L1GtUtils.h:278
const AlgorithmMap & gtTechnicalTriggerMap() const
get / set the technical trigger map
bool m_l1EventSetupValid
Definition: L1GtUtils.h:338
unsigned long long m_l1GtTmVetoAlgoCacheID
Definition: L1GtUtils.h:319
std::vector< int > m_prescaleFactorSet
Definition: L1GtUtils.h:370
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:2170
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:1221
const std::string & gtTriggerMenuImplementation() const
unsigned long long m_l1GtStableParCacheID
Definition: L1GtUtils.h:293
L1GtUtils()
constructor
Definition: L1GtUtils.cc:50
const L1GtTriggerMenuLite::L1TriggerMap * m_technicalTriggerMapLite
Definition: L1GtUtils.h:348
RunNumber_t run() const
Definition: RunAuxiliary.h:41
Definition: Run.h:31
const std::vector< unsigned int > * m_triggerMaskVetoTechTrig
Definition: L1GtUtils.h:328