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