00001
00017
00018 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtUtils.h"
00019
00020
00021 #include <iomanip>
00022
00023
00024 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00025 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00026 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerRecord.h"
00027
00028 #include "FWCore/Framework/interface/ESHandle.h"
00029
00030 #include "CondFormats/L1TObjects/interface/L1GtStableParameters.h"
00031 #include "CondFormats/DataRecord/interface/L1GtStableParametersRcd.h"
00032
00033 #include "CondFormats/L1TObjects/interface/L1GtPrescaleFactors.h"
00034 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsAlgoTrigRcd.h"
00035 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsTechTrigRcd.h"
00036
00037 #include "CondFormats/L1TObjects/interface/L1GtTriggerMask.h"
00038 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskAlgoTrigRcd.h"
00039 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskTechTrigRcd.h"
00040
00041 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskVetoAlgoTrigRcd.h"
00042 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskVetoTechTrigRcd.h"
00043
00044 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00045 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
00046
00047 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00048
00049
00050 L1GtUtils::L1GtUtils() :
00051
00052 m_l1GtStableParCacheID(0ULL), m_numberAlgorithmTriggers(0),
00053
00054 m_numberTechnicalTriggers(0),
00055
00056 m_l1GtPfAlgoCacheID(0ULL), m_l1GtPfTechCacheID(0ULL),
00057
00058 m_l1GtTmAlgoCacheID(0ULL), m_l1GtTmTechCacheID(0ULL),
00059
00060 m_l1GtTmVetoAlgoCacheID(0ULL), m_l1GtTmVetoTechCacheID(0ULL),
00061
00062 m_l1GtMenuCacheID(0ULL),
00063
00064 m_l1EventSetupValid(false),
00065
00066 m_runIDCache(0),
00067
00068 m_provRunIDCache(0),
00069
00070 m_l1GtMenuLiteValid(false),
00071
00072 m_beginRunCache(false),
00073
00074 m_physicsDaqPartition(0),
00075
00076 m_retrieveL1EventSetup(false),
00077
00078 m_retrieveL1GtTriggerMenuLite(false)
00079
00080 {
00081
00082
00083 }
00084
00085
00086 L1GtUtils::~L1GtUtils() {
00087
00088
00089
00090 }
00091
00092 const std::string L1GtUtils::triggerCategory(
00093 const TriggerCategory& trigCategory) const {
00094
00095 switch (trigCategory) {
00096 case AlgorithmTrigger: {
00097 return "Algorithm Trigger";
00098 }
00099 break;
00100 case TechnicalTrigger: {
00101 return "Technical Trigger";
00102 }
00103
00104 break;
00105 default: {
00106 return EmptyString;
00107 }
00108 break;
00109 }
00110 }
00111
00112
00113 void L1GtUtils::retrieveL1EventSetup(const edm::EventSetup& evSetup) {
00114
00115
00116 m_retrieveL1EventSetup = true;
00117
00118 m_l1EventSetupValid = true;
00119
00120
00121
00122
00123
00124 unsigned long long l1GtStableParCacheID =
00125 evSetup.get<L1GtStableParametersRcd>().cacheIdentifier();
00126
00127 if (m_l1GtStableParCacheID != l1GtStableParCacheID) {
00128
00129 edm::ESHandle<L1GtStableParameters> l1GtStablePar;
00130 evSetup.get<L1GtStableParametersRcd>().get(l1GtStablePar);
00131 m_l1GtStablePar = l1GtStablePar.product();
00132
00133
00134 m_numberAlgorithmTriggers = m_l1GtStablePar->gtNumberPhysTriggers();
00135
00136
00137 m_numberTechnicalTriggers =
00138 m_l1GtStablePar->gtNumberTechnicalTriggers();
00139
00140 int maxNumberTrigger = std::max(m_numberAlgorithmTriggers,
00141 m_numberTechnicalTriggers);
00142
00143 m_triggerMaskSet.reserve(maxNumberTrigger);
00144 m_prescaleFactorSet.reserve(maxNumberTrigger);
00145
00146
00147 m_l1GtStableParCacheID = l1GtStableParCacheID;
00148
00149 }
00150
00151
00152
00153
00154 unsigned long long l1GtPfAlgoCacheID =
00155 evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().cacheIdentifier();
00156
00157 if (m_l1GtPfAlgoCacheID != l1GtPfAlgoCacheID) {
00158
00159 edm::ESHandle<L1GtPrescaleFactors> l1GtPfAlgo;
00160 evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().get(l1GtPfAlgo);
00161 m_l1GtPfAlgo = l1GtPfAlgo.product();
00162
00163 m_prescaleFactorsAlgoTrig = &(m_l1GtPfAlgo->gtPrescaleFactors());
00164
00165 m_l1GtPfAlgoCacheID = l1GtPfAlgoCacheID;
00166
00167 }
00168
00169 unsigned long long l1GtPfTechCacheID = evSetup.get<
00170 L1GtPrescaleFactorsTechTrigRcd>().cacheIdentifier();
00171
00172 if (m_l1GtPfTechCacheID != l1GtPfTechCacheID) {
00173
00174 edm::ESHandle<L1GtPrescaleFactors> l1GtPfTech;
00175 evSetup.get<L1GtPrescaleFactorsTechTrigRcd>().get(l1GtPfTech);
00176 m_l1GtPfTech = l1GtPfTech.product();
00177
00178 m_prescaleFactorsTechTrig = &(m_l1GtPfTech->gtPrescaleFactors());
00179
00180 m_l1GtPfTechCacheID = l1GtPfTechCacheID;
00181
00182 }
00183
00184
00185
00186
00187 unsigned long long l1GtTmAlgoCacheID =
00188 evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().cacheIdentifier();
00189
00190 if (m_l1GtTmAlgoCacheID != l1GtTmAlgoCacheID) {
00191
00192 edm::ESHandle<L1GtTriggerMask> l1GtTmAlgo;
00193 evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().get(l1GtTmAlgo);
00194 m_l1GtTmAlgo = l1GtTmAlgo.product();
00195
00196 m_triggerMaskAlgoTrig = &(m_l1GtTmAlgo->gtTriggerMask());
00197
00198 m_l1GtTmAlgoCacheID = l1GtTmAlgoCacheID;
00199
00200 }
00201
00202 unsigned long long l1GtTmTechCacheID =
00203 evSetup.get<L1GtTriggerMaskTechTrigRcd>().cacheIdentifier();
00204
00205 if (m_l1GtTmTechCacheID != l1GtTmTechCacheID) {
00206
00207 edm::ESHandle<L1GtTriggerMask> l1GtTmTech;
00208 evSetup.get<L1GtTriggerMaskTechTrigRcd>().get(l1GtTmTech);
00209 m_l1GtTmTech = l1GtTmTech.product();
00210
00211 m_triggerMaskTechTrig = &(m_l1GtTmTech->gtTriggerMask());
00212
00213 m_l1GtTmTechCacheID = l1GtTmTechCacheID;
00214
00215 }
00216
00217 unsigned long long l1GtTmVetoAlgoCacheID =
00218 evSetup.get<L1GtTriggerMaskVetoAlgoTrigRcd>().cacheIdentifier();
00219
00220 if (m_l1GtTmVetoAlgoCacheID != l1GtTmVetoAlgoCacheID) {
00221
00222 edm::ESHandle<L1GtTriggerMask> l1GtTmVetoAlgo;
00223 evSetup.get<L1GtTriggerMaskVetoAlgoTrigRcd>().get(l1GtTmVetoAlgo);
00224 m_l1GtTmVetoAlgo = l1GtTmVetoAlgo.product();
00225
00226 m_triggerMaskVetoAlgoTrig = &(m_l1GtTmVetoAlgo->gtTriggerMask());
00227
00228 m_l1GtTmVetoAlgoCacheID = l1GtTmVetoAlgoCacheID;
00229
00230 }
00231
00232 unsigned long long l1GtTmVetoTechCacheID =
00233 evSetup.get<L1GtTriggerMaskVetoTechTrigRcd>().cacheIdentifier();
00234
00235 if (m_l1GtTmVetoTechCacheID != l1GtTmVetoTechCacheID) {
00236
00237 edm::ESHandle<L1GtTriggerMask> l1GtTmVetoTech;
00238 evSetup.get<L1GtTriggerMaskVetoTechTrigRcd>().get(l1GtTmVetoTech);
00239 m_l1GtTmVetoTech = l1GtTmVetoTech.product();
00240
00241 m_triggerMaskVetoTechTrig = &(m_l1GtTmVetoTech->gtTriggerMask());
00242
00243 m_l1GtTmVetoTechCacheID = l1GtTmVetoTechCacheID;
00244
00245 }
00246
00247
00248
00249
00250 unsigned long long l1GtMenuCacheID =
00251 evSetup.get<L1GtTriggerMenuRcd>().cacheIdentifier();
00252
00253 if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
00254
00255 edm::ESHandle<L1GtTriggerMenu> l1GtMenu;
00256 evSetup.get<L1GtTriggerMenuRcd>().get(l1GtMenu);
00257 m_l1GtMenu = l1GtMenu.product();
00258
00259 m_algorithmMap = &(m_l1GtMenu->gtAlgorithmMap());
00260 m_algorithmAliasMap = &(m_l1GtMenu->gtAlgorithmAliasMap());
00261
00262 m_technicalTriggerMap = &(m_l1GtMenu->gtTechnicalTriggerMap());
00263
00264 m_l1GtMenuCacheID = l1GtMenuCacheID;
00265
00266 }
00267
00268 }
00269
00270
00271 void L1GtUtils::retrieveL1GtTriggerMenuLite(const edm::Run& iRun,
00272 const edm::InputTag& l1GtMenuLiteInputTag) {
00273
00274
00275 m_retrieveL1GtTriggerMenuLite = true;
00276
00277
00278 edm::Handle<L1GtTriggerMenuLite> l1GtMenuLite;
00279 iRun.getByLabel(l1GtMenuLiteInputTag, l1GtMenuLite);
00280
00281 if (!l1GtMenuLite.isValid()) {
00282
00283 LogDebug("L1GtUtils") << "\nL1GtTriggerMenuLite with \n "
00284 << l1GtMenuLiteInputTag
00285 << "\nrequested in configuration, but not found in the event."
00286 << std::endl;
00287
00288 m_l1GtMenuLiteValid = false;
00289 } else {
00290 m_l1GtMenuLite = l1GtMenuLite.product();
00291 m_l1GtMenuLiteValid = true;
00292
00293 LogDebug("L1GtUtils") << "\nL1GtTriggerMenuLite with \n "
00294 << l1GtMenuLiteInputTag << "\nretrieved for run "
00295 << iRun.runAuxiliary().run() << std::endl;
00296
00297 m_algorithmMapLite = &(m_l1GtMenuLite->gtAlgorithmMap());
00298 m_algorithmAliasMapLite = &(m_l1GtMenuLite->gtAlgorithmAliasMap());
00299 m_technicalTriggerMapLite = &(m_l1GtMenuLite->gtTechnicalTriggerMap());
00300
00301 m_triggerMaskAlgoTrigLite = &(m_l1GtMenuLite->gtTriggerMaskAlgoTrig());
00302 m_triggerMaskTechTrigLite = &(m_l1GtMenuLite->gtTriggerMaskTechTrig());
00303
00304 m_prescaleFactorsAlgoTrigLite
00305 = &(m_l1GtMenuLite->gtPrescaleFactorsAlgoTrig());
00306 m_prescaleFactorsTechTrigLite
00307 = &(m_l1GtMenuLite->gtPrescaleFactorsTechTrig());
00308
00309 }
00310
00311 }
00312
00313 void L1GtUtils::getL1GtRunCache(const edm::Run& iRun,
00314 const edm::EventSetup& evSetup, const bool useL1EventSetup,
00315 const bool useL1GtTriggerMenuLite, const edm::InputTag& l1GtTmLInputTag) {
00316
00317
00318
00319 m_beginRunCache = true;
00320
00321
00322
00323 if (useL1EventSetup) {
00324 retrieveL1EventSetup(evSetup);
00325 }
00326
00327
00328
00329
00330
00331
00332 if (useL1GtTriggerMenuLite) {
00333 retrieveL1GtTriggerMenuLite(iRun, l1GtTmLInputTag);
00334 }
00335
00336 }
00337
00338
00339 void L1GtUtils::getL1GtRunCache(const edm::Run& iRun,
00340 const edm::EventSetup& evSetup, bool useL1EventSetup,
00341 bool useL1GtTriggerMenuLite) {
00342
00343 if (useL1GtTriggerMenuLite) {
00344 getL1GtTriggerMenuLiteInputTag(iRun, m_provL1GtTriggerMenuLiteInputTag);
00345
00346 }
00347
00348 getL1GtRunCache(iRun, evSetup, useL1EventSetup, useL1GtTriggerMenuLite,
00349 m_provL1GtTriggerMenuLiteInputTag);
00350
00351 }
00352
00353
00354
00355 void L1GtUtils::getL1GtRunCache(const edm::Event& iEvent,
00356 const edm::EventSetup& evSetup, const bool useL1EventSetup,
00357 const bool useL1GtTriggerMenuLite, const edm::InputTag& l1GtTmLInputTag) {
00358
00359
00360 if (!m_beginRunCache) {
00361
00362
00363
00364 if (useL1EventSetup) {
00365 retrieveL1EventSetup(evSetup);
00366 }
00367 }
00368
00369
00370
00371 const edm::Run& iRun = iEvent.getRun();
00372 edm::RunID runID = iRun.runAuxiliary().id();
00373
00374 if (runID != m_runIDCache) {
00375
00376 if (!m_beginRunCache) {
00377
00378
00379
00380 if (useL1GtTriggerMenuLite) {
00381 retrieveL1GtTriggerMenuLite(iRun, l1GtTmLInputTag);
00382 }
00383 }
00384
00385
00386
00387 getL1GtRecordInputTag(iEvent, m_provL1GtRecordInputTag,
00388 m_provL1GtReadoutRecordInputTag);
00389
00390
00391 m_runIDCache = runID;
00392
00393 }
00394
00395 }
00396
00397
00398 void L1GtUtils::getL1GtRunCache(const edm::Event& iEvent,
00399 const edm::EventSetup& evSetup, const bool useL1EventSetup,
00400 const bool useL1GtTriggerMenuLite) {
00401
00402
00403 if (!m_beginRunCache) {
00404
00405 const edm::Run& iRun = iEvent.getRun();
00406 edm::RunID runID = iRun.runAuxiliary().id();
00407
00408 if (runID != m_provRunIDCache) {
00409
00410 if (useL1GtTriggerMenuLite) {
00411
00412 getL1GtTriggerMenuLiteInputTag(iRun,
00413 m_provL1GtTriggerMenuLiteInputTag);
00414 }
00415
00416
00417 m_provRunIDCache = runID;
00418 }
00419
00420 }
00421
00422
00423 getL1GtRunCache(iEvent, evSetup, useL1EventSetup, useL1GtTriggerMenuLite,
00424 m_provL1GtTriggerMenuLiteInputTag);
00425
00426 }
00427
00428
00429 void L1GtUtils::getL1GtRecordInputTag(const edm::Event& iEvent,
00430 edm::InputTag& l1GtRecordInputTag,
00431 edm::InputTag& l1GtReadoutRecordInputTag) const {
00432
00433 typedef std::vector<edm::Provenance const*> Provenances;
00434 Provenances provenances;
00435 std::string friendlyName;
00436 std::string modLabel;
00437 std::string instanceName;
00438 std::string processName;
00439
00440 bool foundL1GtRecord = false;
00441 bool foundL1GtReadoutRecord = false;
00442
00443 LogDebug("L1GtUtils") << "\nTry to get AllProvenance for event "
00444 << iEvent.id().event() << std::endl;
00445
00446 iEvent.getAllProvenance(provenances);
00447
00448 LogTrace("L1GtUtils") << "\n" << "Event contains " << provenances.size()
00449 << " product" << (provenances.size() == 1 ? "" : "s")
00450 << " with friendlyClassName, moduleLabel, productInstanceName and processName:\n"
00451 << std::endl;
00452
00453 for (Provenances::iterator itProv = provenances.begin(), itProvEnd =
00454 provenances.end(); itProv != itProvEnd; ++itProv) {
00455
00456 friendlyName = (*itProv)->friendlyClassName();
00457 modLabel = (*itProv)->moduleLabel();
00458 instanceName = (*itProv)->productInstanceName();
00459 processName = (*itProv)->processName();
00460
00461 LogTrace("L1GtUtils") << friendlyName << "\t \"" << modLabel
00462 << "\" \t \"" << instanceName << "\" \t \"" << processName
00463 << "\"" << std::endl;
00464
00465 if (friendlyName == "L1GlobalTriggerRecord") {
00466 l1GtRecordInputTag = edm::InputTag(modLabel, instanceName,
00467 processName);
00468 foundL1GtRecord = true;
00469 } else if (friendlyName == "L1GlobalTriggerReadoutRecord") {
00470
00471 l1GtReadoutRecordInputTag = edm::InputTag(modLabel, instanceName,
00472 processName);
00473 foundL1GtReadoutRecord = true;
00474 }
00475 }
00476
00477
00478 if (!foundL1GtRecord) {
00479 l1GtRecordInputTag = edm::InputTag();
00480 } else {
00481 LogTrace("L1GtUtils")
00482 << "\nL1GlobalTriggerRecord found in the event with \n "
00483 << l1GtRecordInputTag << std::endl;
00484 }
00485
00486 if (!foundL1GtReadoutRecord) {
00487 l1GtReadoutRecordInputTag = edm::InputTag();
00488 } else {
00489 LogTrace("L1GtUtils")
00490 << "\nL1GlobalTriggerReadoutRecord found in the event with \n "
00491 << l1GtReadoutRecordInputTag << std::endl;
00492 }
00493
00494 }
00495
00496 void L1GtUtils::getL1GtTriggerMenuLiteInputTag(const edm::Run& iRun,
00497 edm::InputTag& l1GtTriggerMenuLiteInputTag) const {
00498
00499 typedef std::vector<edm::Provenance const*> Provenances;
00500 Provenances provenances;
00501 std::string friendlyName;
00502 std::string modLabel;
00503 std::string instanceName;
00504 std::string processName;
00505
00506 bool foundL1GtTriggerMenuLite = false;
00507
00508 LogDebug("L1GtUtils") << "\nTry to get AllProvenance for run "
00509 << iRun.runAuxiliary().run() << std::endl;
00510
00511 iRun.getAllProvenance(provenances);
00512
00513 LogTrace("L1GtUtils") << "\n" << "Run contains " << provenances.size()
00514 << " product" << (provenances.size() == 1 ? "" : "s")
00515 << " with friendlyClassName, moduleLabel, productInstanceName and processName:\n"
00516 << std::endl;
00517
00518 for (Provenances::iterator itProv = provenances.begin(), itProvEnd =
00519 provenances.end(); itProv != itProvEnd; ++itProv) {
00520
00521 friendlyName = (*itProv)->friendlyClassName();
00522 modLabel = (*itProv)->moduleLabel();
00523 instanceName = (*itProv)->productInstanceName();
00524 processName = (*itProv)->processName();
00525
00526 LogTrace("L1GtUtils") << friendlyName << "\t \"" << modLabel
00527 << "\" \t \"" << instanceName << "\" \t \"" << processName
00528 << "\"" << std::endl;
00529
00530 if (friendlyName == "L1GtTriggerMenuLite") {
00531 l1GtTriggerMenuLiteInputTag = edm::InputTag(modLabel, instanceName,
00532 processName);
00533 foundL1GtTriggerMenuLite = true;
00534 }
00535
00536 }
00537
00538 if (!foundL1GtTriggerMenuLite) {
00539 l1GtTriggerMenuLiteInputTag = edm::InputTag();
00540 LogTrace("L1GtUtils") << "\nL1GtTriggerMenuLite not found in Run"
00541 << std::endl;
00542 } else {
00543 LogTrace("L1GtUtils") << "\nL1GtTriggerMenuLite found in Run with \n "
00544 << l1GtTriggerMenuLiteInputTag << std::endl;
00545 }
00546
00547 }
00548
00549
00550 const bool L1GtUtils::l1AlgoTechTrigBitNumber(
00551 const std::string& nameAlgoTechTrig, TriggerCategory& trigCategory,
00552 int& bitNumber) const {
00553
00554 trigCategory = AlgorithmTrigger;
00555 bitNumber = -1;
00556
00557 if (m_retrieveL1GtTriggerMenuLite) {
00558 if (m_l1GtMenuLiteValid) {
00559
00560
00561 for (L1GtTriggerMenuLite::CItL1Trig itTrig =
00562 m_algorithmAliasMapLite->begin(); itTrig
00563 != m_algorithmAliasMapLite->end(); itTrig++) {
00564
00565 if (itTrig->second == nameAlgoTechTrig) {
00566
00567 trigCategory = AlgorithmTrigger;
00568 bitNumber = itTrig->first;
00569
00570 return true;
00571 }
00572 }
00573
00574
00575 for (L1GtTriggerMenuLite::CItL1Trig itTrig =
00576 m_algorithmMapLite->begin(); itTrig
00577 != m_algorithmMapLite->end(); itTrig++) {
00578
00579 if (itTrig->second == nameAlgoTechTrig) {
00580
00581 trigCategory = AlgorithmTrigger;
00582 bitNumber = itTrig->first;
00583
00584 return true;
00585 }
00586 }
00587
00588
00589 for (L1GtTriggerMenuLite::CItL1Trig itTrig =
00590 m_technicalTriggerMapLite->begin(); itTrig
00591 != m_technicalTriggerMapLite->end(); itTrig++) {
00592
00593 if (itTrig->second == nameAlgoTechTrig) {
00594
00595 trigCategory = TechnicalTrigger;
00596 bitNumber = itTrig->first;
00597
00598 return true;
00599 }
00600 }
00601
00602 } else if (m_retrieveL1EventSetup) {
00603
00604
00605 CItAlgo itAlgo = m_algorithmAliasMap->find(nameAlgoTechTrig);
00606 if (itAlgo != m_algorithmAliasMap->end()) {
00607 trigCategory = AlgorithmTrigger;
00608 bitNumber = (itAlgo->second).algoBitNumber();
00609
00610 return true;
00611 }
00612
00613
00614 itAlgo = m_algorithmMap->find(nameAlgoTechTrig);
00615 if (itAlgo != m_algorithmMap->end()) {
00616 trigCategory = AlgorithmTrigger;
00617 bitNumber = (itAlgo->second).algoBitNumber();
00618
00619 return true;
00620 }
00621
00622
00623 itAlgo = m_technicalTriggerMap->find(nameAlgoTechTrig);
00624 if (itAlgo != m_technicalTriggerMap->end()) {
00625 trigCategory = TechnicalTrigger;
00626 bitNumber = (itAlgo->second).algoBitNumber();
00627
00628 return true;
00629 }
00630
00631 } else {
00632
00633 return false;
00634
00635 }
00636 } else if (m_retrieveL1EventSetup) {
00637
00638
00639 CItAlgo itAlgo = m_algorithmAliasMap->find(nameAlgoTechTrig);
00640 if (itAlgo != m_algorithmAliasMap->end()) {
00641 trigCategory = AlgorithmTrigger;
00642 bitNumber = (itAlgo->second).algoBitNumber();
00643
00644 return true;
00645 }
00646
00647
00648 itAlgo = m_algorithmMap->find(nameAlgoTechTrig);
00649 if (itAlgo != m_algorithmMap->end()) {
00650 trigCategory = AlgorithmTrigger;
00651 bitNumber = (itAlgo->second).algoBitNumber();
00652
00653 return true;
00654 }
00655
00656
00657 itAlgo = m_technicalTriggerMap->find(nameAlgoTechTrig);
00658 if (itAlgo != m_technicalTriggerMap->end()) {
00659 trigCategory = TechnicalTrigger;
00660 bitNumber = (itAlgo->second).algoBitNumber();
00661
00662 return true;
00663 }
00664
00665 } else {
00666
00667 return false;
00668
00669 }
00670
00671
00672 return false;
00673
00674
00675 }
00676
00677
00678
00679 const int L1GtUtils::l1Results(const edm::Event& iEvent,
00680 const edm::InputTag& l1GtRecordInputTag,
00681 const edm::InputTag& l1GtReadoutRecordInputTag,
00682 const std::string& nameAlgoTechTrig, bool& decisionBeforeMask,
00683 bool& decisionAfterMask, int& prescaleFactor, int& triggerMask) const {
00684
00685
00686 decisionBeforeMask = false;
00687 decisionAfterMask = false;
00688 prescaleFactor = -1;
00689 triggerMask = -1;
00690
00691
00692 int iError = 0;
00693 int l1ConfCode = 0;
00694
00695
00696
00697 if (!availableL1Configuration(iError, l1ConfCode)) {
00698 return iError;
00699 }
00700
00701
00702
00703
00704
00705
00706
00707 TriggerCategory trigCategory = AlgorithmTrigger;
00708 int bitNumber = -1;
00709
00710
00711 if (!l1AlgoTechTrigBitNumber(nameAlgoTechTrig, trigCategory, bitNumber)) {
00712
00713 iError = l1ConfCode + 1;
00714
00715 if (m_retrieveL1GtTriggerMenuLite) {
00716 if (m_l1GtMenuLiteValid) {
00717
00718 LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
00719 << nameAlgoTechTrig
00720 << "\not found in the trigger menu \n "
00721 << m_l1GtMenuLite->gtTriggerMenuImplementation()
00722 << "\nretrieved from L1GtTriggerMenuLite" << std::endl;
00723
00724 } else {
00725
00726
00727 LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
00728 << nameAlgoTechTrig
00729 << "\not found in the trigger menu \n "
00730 << m_l1GtMenu->gtTriggerMenuImplementation()
00731 << "\nretrieved from Event Setup" << std::endl;
00732
00733 }
00734
00735 } else {
00736
00737 LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
00738 << nameAlgoTechTrig
00739 << "\not found in the trigger menu \n "
00740 << m_l1GtMenu->gtTriggerMenuImplementation()
00741 << "\nretrieved from Event Setup" << std::endl;
00742
00743 }
00744
00745 return iError;
00746
00747 }
00748
00749
00750
00751
00752 if (bitNumber < 0) {
00753
00754 iError = l1ConfCode + 2;
00755
00756 if (m_retrieveL1GtTriggerMenuLite) {
00757 if (m_l1GtMenuLiteValid) {
00758 LogDebug("L1GtUtils") << "\nNegative bit number for "
00759 << triggerCategory(trigCategory) << "\n "
00760 << nameAlgoTechTrig << "\nfrom menu \n "
00761 << m_l1GtMenuLite->gtTriggerMenuImplementation()
00762 << "\nretrieved from L1GtTriggerMenuLite" << std::endl;
00763
00764 } else {
00765
00766 LogDebug("L1GtUtils") << "\nNegative bit number for "
00767 << triggerCategory(trigCategory) << "\n "
00768 << nameAlgoTechTrig << "\nfrom menu \n "
00769 << m_l1GtMenu->gtTriggerMenuImplementation()
00770 << "\nretrieved from Event Setup" << std::endl;
00771
00772 }
00773
00774 } else {
00775
00776 LogDebug("L1GtUtils") << "\nNegative bit number for "
00777 << triggerCategory(trigCategory) << "\n "
00778 << nameAlgoTechTrig << "\nfrom menu \n "
00779 << m_l1GtMenu->gtTriggerMenuImplementation()
00780 << "\nretrieved from Event Setup" << std::endl;
00781
00782 }
00783
00784 return iError;
00785 }
00786
00787
00788
00789
00790
00791
00792 int iErrorRecord = 0;
00793
00794 bool validRecord = false;
00795 bool gtReadoutRecordValid = false;
00796
00797 edm::Handle<L1GlobalTriggerRecord> gtRecord;
00798 iEvent.getByLabel(l1GtRecordInputTag, gtRecord);
00799
00800 if (gtRecord.isValid()) {
00801
00802 validRecord = true;
00803
00804 } else {
00805
00806 iErrorRecord = 10;
00807 LogDebug("L1GtUtils") << "\nL1GlobalTriggerRecord with \n "
00808 << l1GtRecordInputTag << "\nnot found in the event."
00809 << std::endl;
00810 }
00811
00812 edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecord;
00813 iEvent.getByLabel(l1GtReadoutRecordInputTag, gtReadoutRecord);
00814
00815 if (gtReadoutRecord.isValid()) {
00816
00817 gtReadoutRecordValid = true;
00818 validRecord = true;
00819
00820 } else {
00821
00822 iErrorRecord = iErrorRecord + 100;
00823 LogDebug("L1GtUtils") << "\nL1GlobalTriggerReadoutRecord with \n "
00824 << l1GtReadoutRecordInputTag << "\nnot found in the event."
00825 << std::endl;
00826
00827 }
00828
00829
00830
00831
00832
00833
00834
00835 int pfIndexTechTrig = -1;
00836 int pfIndexAlgoTrig = -1;
00837
00838 if (validRecord) {
00839 if (gtReadoutRecordValid) {
00840
00841 pfIndexTechTrig
00842 = (gtReadoutRecord->gtFdlWord()).gtPrescaleFactorIndexTech();
00843 pfIndexAlgoTrig
00844 = (gtReadoutRecord->gtFdlWord()).gtPrescaleFactorIndexAlgo();
00845
00846 } else {
00847
00848 pfIndexTechTrig
00849 = static_cast<int> (gtRecord->gtPrescaleFactorIndexTech());
00850 pfIndexAlgoTrig
00851 = static_cast<int> (gtRecord->gtPrescaleFactorIndexAlgo());
00852
00853 }
00854
00855 } else {
00856
00857 LogDebug("L1GtUtils") << "\nError: "
00858 << "\nNo valid L1GlobalTriggerRecord with \n "
00859 << l1GtRecordInputTag << "\nfound in the event."
00860 << "\nNo valid L1GlobalTriggerReadoutRecord with \n "
00861 << l1GtReadoutRecordInputTag << "\nfound in the event."
00862 << std::endl;
00863
00864 iError = l1ConfCode + iErrorRecord;
00865 return iError;
00866
00867 }
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877 size_t pfSetsSize = 0;
00878 int pfIndex = -1;
00879 const std::vector<int>* prescaleFactorsSubset = 0;
00880 const std::vector<unsigned int>* triggerMasksSet = 0;
00881
00882 switch (trigCategory) {
00883 case AlgorithmTrigger: {
00884 if (m_retrieveL1GtTriggerMenuLite) {
00885 if (m_l1GtMenuLiteValid) {
00886 pfSetsSize = m_prescaleFactorsAlgoTrigLite->size();
00887 triggerMasksSet = m_triggerMaskAlgoTrigLite;
00888
00889 } else {
00890
00891 pfSetsSize = m_prescaleFactorsAlgoTrig->size();
00892 triggerMasksSet = m_triggerMaskAlgoTrig;
00893
00894 }
00895
00896 } else {
00897
00898 pfSetsSize = m_prescaleFactorsAlgoTrig->size();
00899 triggerMasksSet = m_triggerMaskAlgoTrig;
00900
00901 }
00902
00903 pfIndex = pfIndexAlgoTrig;
00904
00905 }
00906 break;
00907 case TechnicalTrigger: {
00908 if (m_retrieveL1GtTriggerMenuLite) {
00909 if (m_l1GtMenuLiteValid) {
00910 pfSetsSize = m_prescaleFactorsTechTrigLite->size();
00911 triggerMasksSet = m_triggerMaskTechTrigLite;
00912
00913 } else {
00914
00915 pfSetsSize = m_prescaleFactorsTechTrig->size();
00916 triggerMasksSet = m_triggerMaskTechTrig;
00917
00918 }
00919
00920 } else {
00921
00922 pfSetsSize = m_prescaleFactorsTechTrig->size();
00923 triggerMasksSet = m_triggerMaskTechTrig;
00924
00925 }
00926
00927 pfIndex = pfIndexTechTrig;
00928
00929 }
00930 break;
00931 default: {
00932
00933 iError = l1ConfCode + iErrorRecord + 3;
00934 return iError;
00935
00936 }
00937 break;
00938 }
00939
00940
00941
00942
00943 if (pfIndex < 0) {
00944
00945 iError = l1ConfCode + iErrorRecord + 1000;
00946 LogDebug("L1GtUtils")
00947 << "\nError: index of prescale factor set retrieved from the data \n"
00948 << "less than zero."
00949 << "\n Value of index retrieved from data = " << pfIndex
00950 << std::endl;
00951
00952 return iError;
00953
00954 } else if (pfIndex >= (static_cast<int>(pfSetsSize))) {
00955 iError = l1ConfCode + iErrorRecord + 2000;
00956 LogDebug("L1GtUtils")
00957 << "\nError: index of prescale factor set retrieved from the data \n"
00958 << "greater than the size of the vector of prescale factor sets."
00959 << "\n Value of index retrieved from data = " << pfIndex
00960 << "\n Vector size = " << pfSetsSize << std::endl;
00961
00962 return iError;
00963
00964 } else {
00965 switch (trigCategory) {
00966 case AlgorithmTrigger: {
00967 if (m_retrieveL1GtTriggerMenuLite) {
00968 if (m_l1GtMenuLiteValid) {
00969 prescaleFactorsSubset
00970 = &((*m_prescaleFactorsAlgoTrigLite).at(pfIndex));
00971
00972 } else {
00973
00974 prescaleFactorsSubset
00975 = &((*m_prescaleFactorsAlgoTrig).at(pfIndex));
00976
00977 }
00978
00979 } else {
00980
00981 prescaleFactorsSubset
00982 = &((*m_prescaleFactorsAlgoTrig).at(pfIndex));
00983
00984 }
00985
00986 }
00987 break;
00988 case TechnicalTrigger: {
00989 if (m_retrieveL1GtTriggerMenuLite) {
00990 if (m_l1GtMenuLiteValid) {
00991 prescaleFactorsSubset
00992 = &((*m_prescaleFactorsTechTrigLite).at(pfIndex));
00993
00994 } else {
00995
00996 prescaleFactorsSubset
00997 = &((*m_prescaleFactorsTechTrig).at(pfIndex));
00998
00999 }
01000
01001 } else {
01002
01003 prescaleFactorsSubset
01004 = &((*m_prescaleFactorsTechTrig).at(pfIndex));
01005
01006 }
01007
01008 }
01009 break;
01010 default: {
01011
01012
01013 }
01014 break;
01015 }
01016
01017 }
01018
01019
01020
01021
01022
01023 switch (trigCategory) {
01024 case AlgorithmTrigger: {
01025 if (gtReadoutRecordValid) {
01026 const DecisionWord& decWord = gtReadoutRecord->decisionWord();
01027 decisionBeforeMask = trigResult(decWord, bitNumber,
01028 nameAlgoTechTrig, trigCategory, iError);
01029 if (iError) {
01030 return (iError + l1ConfCode + iErrorRecord);
01031 }
01032
01033 } else {
01034
01035 const DecisionWord& decWord =
01036 gtRecord->decisionWordBeforeMask();
01037 decisionBeforeMask = trigResult(decWord, bitNumber,
01038 nameAlgoTechTrig, trigCategory, iError);
01039 if (iError) {
01040 return (iError + l1ConfCode + iErrorRecord);
01041 }
01042
01043 }
01044
01045 }
01046 break;
01047 case TechnicalTrigger: {
01048 if (gtReadoutRecordValid) {
01049 const DecisionWord& decWord =
01050 gtReadoutRecord->technicalTriggerWord();
01051 decisionBeforeMask = trigResult(decWord, bitNumber,
01052 nameAlgoTechTrig, trigCategory, iError);
01053 if (iError) {
01054 return (iError + l1ConfCode + iErrorRecord);
01055 }
01056
01057 } else {
01058
01059 const DecisionWord& decWord =
01060 gtRecord->technicalTriggerWordBeforeMask();
01061 decisionBeforeMask = trigResult(decWord, bitNumber,
01062 nameAlgoTechTrig, trigCategory, iError);
01063 if (iError) {
01064 return (iError + l1ConfCode + iErrorRecord);
01065 }
01066
01067 }
01068
01069 }
01070 break;
01071 default: {
01072
01073
01074 }
01075 break;
01076 }
01077
01078
01079
01080
01081 if (bitNumber < (static_cast<int> (prescaleFactorsSubset->size()))) {
01082 prescaleFactor = (*prescaleFactorsSubset)[bitNumber];
01083 } else {
01084 iError = l1ConfCode + iErrorRecord + 4000;
01085 LogDebug("L1GtUtils") << "\nError: bit number " << bitNumber
01086 << " retrieved for " << triggerCategory(trigCategory) << "\n "
01087 << nameAlgoTechTrig
01088 << "\ngreater than size of actual L1 GT prescale factor set: "
01089 << prescaleFactorsSubset->size()
01090 << "\nError: Inconsistent L1 trigger configuration!"
01091 << std::endl;
01092
01093 return iError;
01094 }
01095
01096
01097
01098 if (bitNumber < (static_cast<int> ((*triggerMasksSet).size()))) {
01099
01100 if (m_retrieveL1GtTriggerMenuLite) {
01101 if (m_l1GtMenuLiteValid) {
01102 triggerMask = (*triggerMasksSet)[bitNumber];
01103
01104 } else {
01105
01106
01107 triggerMask = ((*triggerMasksSet)[bitNumber]) & (1
01108 << m_physicsDaqPartition);
01109
01110 }
01111
01112 } else {
01113
01114
01115 triggerMask = ((*triggerMasksSet)[bitNumber]) & (1
01116 << m_physicsDaqPartition);
01117
01118 }
01119
01120
01121 } else {
01122 iError = l1ConfCode + iErrorRecord + 5000;
01123 LogDebug("L1GtUtils") << "\nError: bit number " << bitNumber
01124 << " retrieved for " << triggerCategory(trigCategory) << "\n "
01125 << nameAlgoTechTrig
01126 << "\ngreater than size of L1 GT trigger mask set: "
01127 << (*triggerMasksSet).size()
01128 << "\nError: Inconsistent L1 trigger configuration!"
01129 << std::endl;
01130
01131 return iError;
01132
01133 }
01134
01135 decisionAfterMask = decisionBeforeMask;
01136
01137 if (triggerMask) {
01138 decisionAfterMask = false;
01139 }
01140
01141 return iError;
01142
01143 }
01144
01145
01146 const int L1GtUtils::l1Results(const edm::Event& iEvent,
01147 const std::string& nameAlgoTechTrig, bool& decisionBeforeMask,
01148 bool& decisionAfterMask, int& prescaleFactor, int& triggerMask) const {
01149
01150
01151 decisionBeforeMask = false;
01152 decisionAfterMask = false;
01153 prescaleFactor = -1;
01154 triggerMask = -1;
01155
01156
01157
01158 int l1ErrorCode = 0;
01159
01160 l1ErrorCode = l1Results(iEvent, m_provL1GtRecordInputTag,
01161 m_provL1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
01162 decisionAfterMask, prescaleFactor, triggerMask);
01163
01164 return l1ErrorCode;
01165
01166 }
01167
01168
01169
01170 const bool L1GtUtils::decisionBeforeMask(const edm::Event& iEvent,
01171 const edm::InputTag& l1GtRecordInputTag,
01172 const edm::InputTag& l1GtReadoutRecordInputTag,
01173 const std::string& nameAlgoTechTrig, int& errorCode) const {
01174
01175
01176 bool decisionBeforeMask = false;
01177 bool decisionAfterMask = false;
01178 int prescaleFactor = -1;
01179 int triggerMask = -1;
01180
01181 errorCode = l1Results(iEvent, l1GtRecordInputTag,
01182 l1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
01183 decisionAfterMask, prescaleFactor, triggerMask);
01184
01185 return decisionBeforeMask;
01186
01187 }
01188
01189 const bool L1GtUtils::decisionBeforeMask(const edm::Event& iEvent,
01190 const std::string& nameAlgoTechTrig, int& errorCode) const {
01191
01192
01193 bool decisionBeforeMask = false;
01194 bool decisionAfterMask = false;
01195 int prescaleFactor = -1;
01196 int triggerMask = -1;
01197
01198 errorCode = l1Results(iEvent, nameAlgoTechTrig, decisionBeforeMask,
01199 decisionAfterMask, prescaleFactor, triggerMask);
01200
01201 return decisionBeforeMask;
01202
01203 }
01204
01205
01206
01207 const bool L1GtUtils::decisionAfterMask(const edm::Event& iEvent,
01208 const edm::InputTag& l1GtRecordInputTag,
01209 const edm::InputTag& l1GtReadoutRecordInputTag,
01210 const std::string& nameAlgoTechTrig, int& errorCode) const {
01211
01212
01213 bool decisionBeforeMask = false;
01214 bool decisionAfterMask = false;
01215 int prescaleFactor = -1;
01216 int triggerMask = -1;
01217
01218 errorCode = l1Results(iEvent, l1GtRecordInputTag,
01219 l1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
01220 decisionAfterMask, prescaleFactor, triggerMask);
01221
01222 return decisionAfterMask;
01223
01224 }
01225
01226 const bool L1GtUtils::decisionAfterMask(const edm::Event& iEvent,
01227 const std::string& nameAlgoTechTrig, int& errorCode) const {
01228
01229
01230 bool decisionBeforeMask = false;
01231 bool decisionAfterMask = false;
01232 int prescaleFactor = -1;
01233 int triggerMask = -1;
01234
01235 errorCode = l1Results(iEvent, nameAlgoTechTrig, decisionBeforeMask,
01236 decisionAfterMask, prescaleFactor, triggerMask);
01237
01238 return decisionAfterMask;
01239
01240 }
01241
01242
01243
01244 const bool L1GtUtils::decision(const edm::Event& iEvent,
01245 const edm::InputTag& l1GtRecordInputTag,
01246 const edm::InputTag& l1GtReadoutRecordInputTag,
01247 const std::string& nameAlgoTechTrig, int& errorCode) const {
01248
01249
01250 bool decisionBeforeMask = false;
01251 bool decisionAfterMask = false;
01252 int prescaleFactor = -1;
01253 int triggerMask = -1;
01254
01255 errorCode = l1Results(iEvent, l1GtRecordInputTag,
01256 l1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
01257 decisionAfterMask, prescaleFactor, triggerMask);
01258
01259 return decisionAfterMask;
01260
01261 }
01262
01263 const bool L1GtUtils::decision(const edm::Event& iEvent,
01264 const std::string& nameAlgoTechTrig, int& errorCode) const {
01265
01266
01267 bool decisionBeforeMask = false;
01268 bool decisionAfterMask = false;
01269 int prescaleFactor = -1;
01270 int triggerMask = -1;
01271
01272 errorCode = l1Results(iEvent, nameAlgoTechTrig, decisionBeforeMask,
01273 decisionAfterMask, prescaleFactor, triggerMask);
01274
01275 return decisionAfterMask;
01276
01277 }
01278
01279
01280
01281 const int L1GtUtils::prescaleFactor(const edm::Event& iEvent,
01282 const edm::InputTag& l1GtRecordInputTag,
01283 const edm::InputTag& l1GtReadoutRecordInputTag,
01284 const std::string& nameAlgoTechTrig, int& errorCode) const {
01285
01286
01287 bool decisionBeforeMask = false;
01288 bool decisionAfterMask = false;
01289 int prescaleFactor = -1;
01290 int triggerMask = -1;
01291
01292 errorCode = l1Results(iEvent, l1GtRecordInputTag,
01293 l1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
01294 decisionAfterMask, prescaleFactor, triggerMask);
01295
01296 return prescaleFactor;
01297
01298 }
01299
01300 const int L1GtUtils::prescaleFactor(const edm::Event& iEvent,
01301 const std::string& nameAlgoTechTrig, int& errorCode) const {
01302
01303
01304 bool decisionBeforeMask = false;
01305 bool decisionAfterMask = false;
01306 int prescaleFactor = -1;
01307 int triggerMask = -1;
01308
01309 errorCode = l1Results(iEvent, nameAlgoTechTrig, decisionBeforeMask,
01310 decisionAfterMask, prescaleFactor, triggerMask);
01311
01312 return prescaleFactor;
01313
01314 }
01315
01316 const int L1GtUtils::triggerMask(const edm::Event& iEvent,
01317 const edm::InputTag& l1GtRecordInputTag,
01318 const edm::InputTag& l1GtReadoutRecordInputTag,
01319 const std::string& nameAlgoTechTrig, int& errorCode) const {
01320
01321
01322 bool decisionBeforeMask = false;
01323 bool decisionAfterMask = false;
01324 int prescaleFactor = -1;
01325 int triggerMask = -1;
01326
01327 errorCode = l1Results(iEvent, l1GtRecordInputTag,
01328 l1GtReadoutRecordInputTag, nameAlgoTechTrig, decisionBeforeMask,
01329 decisionAfterMask, prescaleFactor, triggerMask);
01330
01331 return triggerMask;
01332
01333 }
01334
01335 const int L1GtUtils::triggerMask(const edm::Event& iEvent,
01336 const std::string& nameAlgoTechTrig, int& errorCode) const {
01337
01338
01339 bool decisionBeforeMask = false;
01340 bool decisionAfterMask = false;
01341 int prescaleFactor = -1;
01342 int triggerMask = -1;
01343
01344 errorCode = l1Results(iEvent, nameAlgoTechTrig, decisionBeforeMask,
01345 decisionAfterMask, prescaleFactor, triggerMask);
01346
01347 return triggerMask;
01348
01349 }
01350
01351 const int L1GtUtils::triggerMask(const std::string& nameAlgoTechTrig,
01352 int& errorCode) const {
01353
01354
01355 int triggerMaskValue = -1;
01356
01357
01358 int iError = 0;
01359 int l1ConfCode = 0;
01360
01361
01362
01363 if (!availableL1Configuration(iError, l1ConfCode)) {
01364 errorCode = iError;
01365 return triggerMaskValue;
01366 }
01367
01368
01369
01370
01371
01372
01373
01374 TriggerCategory trigCategory = AlgorithmTrigger;
01375 int bitNumber = -1;
01376
01377 if (!l1AlgoTechTrigBitNumber(nameAlgoTechTrig, trigCategory, bitNumber)) {
01378
01379 iError = l1ConfCode + 1;
01380
01381 if (m_retrieveL1GtTriggerMenuLite) {
01382 if (m_l1GtMenuLiteValid) {
01383
01384 LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
01385 << nameAlgoTechTrig
01386 << "\not found in the trigger menu \n "
01387 << m_l1GtMenuLite->gtTriggerMenuImplementation()
01388 << "\nretrieved from L1GtTriggerMenuLite" << std::endl;
01389
01390 } else {
01391
01392
01393 LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
01394 << nameAlgoTechTrig
01395 << "\not found in the trigger menu \n "
01396 << m_l1GtMenu->gtTriggerMenuImplementation()
01397 << "\nretrieved from Event Setup" << std::endl;
01398
01399 }
01400
01401 } else {
01402
01403 LogDebug("L1GtUtils") << "\nAlgorithm/technical trigger \n "
01404 << nameAlgoTechTrig
01405 << "\not found in the trigger menu \n "
01406 << m_l1GtMenu->gtTriggerMenuImplementation()
01407 << "\nretrieved from Event Setup" << std::endl;
01408
01409 }
01410
01411 errorCode = iError;
01412 return triggerMaskValue;
01413
01414 }
01415
01416
01417
01418
01419 if (bitNumber < 0) {
01420
01421 iError = l1ConfCode + 2;
01422
01423 if (m_retrieveL1GtTriggerMenuLite) {
01424 if (m_l1GtMenuLiteValid) {
01425 LogDebug("L1GtUtils") << "\nNegative bit number for "
01426 << triggerCategory(trigCategory) << "\n "
01427 << nameAlgoTechTrig << "\nfrom menu \n "
01428 << m_l1GtMenuLite->gtTriggerMenuImplementation()
01429 << "\nretrieved from L1GtTriggerMenuLite" << std::endl;
01430
01431 } else {
01432
01433 LogDebug("L1GtUtils") << "\nNegative bit number for "
01434 << triggerCategory(trigCategory) << "\n "
01435 << nameAlgoTechTrig << "\nfrom menu \n "
01436 << m_l1GtMenu->gtTriggerMenuImplementation()
01437 << "\nretrieved from Event Setup" << std::endl;
01438
01439 }
01440
01441 } else {
01442
01443 LogDebug("L1GtUtils") << "\nNegative bit number for "
01444 << triggerCategory(trigCategory) << "\n "
01445 << nameAlgoTechTrig << "\nfrom menu \n "
01446 << m_l1GtMenu->gtTriggerMenuImplementation()
01447 << "\nretrieved from Event Setup" << std::endl;
01448
01449 }
01450
01451 errorCode = iError;
01452 return triggerMaskValue;
01453 }
01454
01455
01456
01457
01458
01459
01460 const std::vector<unsigned int>* triggerMasksSet = 0;
01461
01462 switch (trigCategory) {
01463 case AlgorithmTrigger: {
01464 if (m_retrieveL1GtTriggerMenuLite) {
01465 if (m_l1GtMenuLiteValid) {
01466 triggerMasksSet = m_triggerMaskAlgoTrigLite;
01467
01468 } else {
01469
01470 triggerMasksSet = m_triggerMaskAlgoTrig;
01471
01472 }
01473
01474 } else {
01475
01476 triggerMasksSet = m_triggerMaskAlgoTrig;
01477
01478 }
01479
01480 }
01481 break;
01482 case TechnicalTrigger: {
01483 if (m_retrieveL1GtTriggerMenuLite) {
01484 if (m_l1GtMenuLiteValid) {
01485 triggerMasksSet = m_triggerMaskTechTrigLite;
01486
01487 } else {
01488
01489 triggerMasksSet = m_triggerMaskTechTrig;
01490
01491 }
01492
01493 } else {
01494
01495 triggerMasksSet = m_triggerMaskTechTrig;
01496
01497 }
01498
01499 }
01500 break;
01501 default: {
01502
01503 iError = l1ConfCode + 3;
01504
01505 errorCode = iError;
01506 return triggerMaskValue;
01507
01508 }
01509 break;
01510 }
01511
01512
01513
01514 if (bitNumber < (static_cast<int> ((*triggerMasksSet).size()))) {
01515
01516 if (m_retrieveL1GtTriggerMenuLite) {
01517 if (m_l1GtMenuLiteValid) {
01518 triggerMaskValue = (*triggerMasksSet)[bitNumber];
01519
01520 } else {
01521
01522
01523 triggerMaskValue = ((*triggerMasksSet)[bitNumber]) & (1
01524 << m_physicsDaqPartition);
01525
01526 }
01527
01528 } else {
01529
01530
01531 triggerMaskValue = ((*triggerMasksSet)[bitNumber]) & (1
01532 << m_physicsDaqPartition);
01533
01534 }
01535
01536 } else {
01537 iError = l1ConfCode + 5000;
01538 LogDebug("L1GtUtils") << "\nError: bit number " << bitNumber
01539 << " retrieved for " << triggerCategory(trigCategory) << "\n "
01540 << nameAlgoTechTrig
01541 << "\ngreater than size of L1 GT trigger mask set: "
01542 << (*triggerMasksSet).size()
01543 << "\nError: Inconsistent L1 trigger configuration!"
01544 << std::endl;
01545
01546 errorCode = iError;
01547 return triggerMaskValue;
01548
01549 }
01550
01551 errorCode = iError;
01552 return triggerMaskValue;
01553
01554 }
01555
01556 const int L1GtUtils::prescaleFactorSetIndex(const edm::Event& iEvent,
01557 const edm::InputTag& l1GtRecordInputTag,
01558 const edm::InputTag& l1GtReadoutRecordInputTag,
01559 const TriggerCategory& trigCategory, int& errorCode) const {
01560
01561
01562 int pfIndex = -1;
01563
01564
01565 int iError = 0;
01566 int l1ConfCode = 0;
01567
01568
01569
01570 if (!availableL1Configuration(iError, l1ConfCode)) {
01571 errorCode = iError;
01572 return pfIndex;
01573 }
01574
01575
01576
01577
01578
01579
01580
01581
01582 int iErrorRecord = 0;
01583
01584 bool validRecord = false;
01585 bool gtReadoutRecordValid = false;
01586
01587 edm::Handle<L1GlobalTriggerRecord> gtRecord;
01588 iEvent.getByLabel(l1GtRecordInputTag, gtRecord);
01589
01590 if (gtRecord.isValid()) {
01591
01592 validRecord = true;
01593
01594 } else {
01595
01596 iErrorRecord = 10;
01597 LogDebug("L1GtUtils") << "\nL1GlobalTriggerRecord with \n "
01598 << l1GtRecordInputTag << "\nnot found in the event."
01599 << std::endl;
01600 }
01601
01602 edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecord;
01603 iEvent.getByLabel(l1GtReadoutRecordInputTag, gtReadoutRecord);
01604
01605 if (gtReadoutRecord.isValid()) {
01606
01607 gtReadoutRecordValid = true;
01608 validRecord = true;
01609
01610 } else {
01611
01612 iErrorRecord = iErrorRecord + 100;
01613 LogDebug("L1GtUtils") << "\nL1GlobalTriggerReadoutRecord with \n "
01614 << l1GtReadoutRecordInputTag << "\nnot found in the event."
01615 << std::endl;
01616
01617 }
01618
01619
01620
01621
01622
01623
01624
01625 int pfIndexTechTrig = -1;
01626 int pfIndexAlgoTrig = -1;
01627
01628 if (validRecord) {
01629 if (gtReadoutRecordValid) {
01630
01631 pfIndexTechTrig
01632 = (gtReadoutRecord->gtFdlWord()).gtPrescaleFactorIndexTech();
01633 pfIndexAlgoTrig
01634 = (gtReadoutRecord->gtFdlWord()).gtPrescaleFactorIndexAlgo();
01635
01636 } else {
01637
01638 pfIndexTechTrig
01639 = static_cast<int> (gtRecord->gtPrescaleFactorIndexTech());
01640 pfIndexAlgoTrig
01641 = static_cast<int> (gtRecord->gtPrescaleFactorIndexAlgo());
01642
01643 }
01644
01645 } else {
01646
01647 LogDebug("L1GtUtils") << "\nError: "
01648 << "\nNo valid L1GlobalTriggerRecord with \n "
01649 << l1GtRecordInputTag << "\nfound in the event."
01650 << "\nNo valid L1GlobalTriggerReadoutRecord with \n "
01651 << l1GtReadoutRecordInputTag << "\nfound in the event."
01652 << std::endl;
01653
01654 iError = l1ConfCode + iErrorRecord;
01655
01656 errorCode = iError;
01657 return pfIndex;
01658
01659 }
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669 size_t pfSetsSize = 0;
01670
01671 switch (trigCategory) {
01672 case AlgorithmTrigger: {
01673 if (m_retrieveL1GtTriggerMenuLite) {
01674 if (m_l1GtMenuLiteValid) {
01675 pfSetsSize = m_prescaleFactorsAlgoTrigLite->size();
01676
01677 } else {
01678
01679 pfSetsSize = m_prescaleFactorsAlgoTrig->size();
01680
01681 }
01682
01683 } else {
01684
01685 pfSetsSize = m_prescaleFactorsAlgoTrig->size();
01686
01687 }
01688
01689 pfIndex = pfIndexAlgoTrig;
01690
01691 }
01692 break;
01693 case TechnicalTrigger: {
01694 if (m_retrieveL1GtTriggerMenuLite) {
01695 if (m_l1GtMenuLiteValid) {
01696 pfSetsSize = m_prescaleFactorsTechTrigLite->size();
01697
01698 } else {
01699
01700 pfSetsSize = m_prescaleFactorsTechTrig->size();
01701
01702 }
01703
01704 } else {
01705
01706 pfSetsSize = m_prescaleFactorsTechTrig->size();
01707
01708 }
01709
01710 pfIndex = pfIndexTechTrig;
01711
01712 }
01713 break;
01714 default: {
01715
01716 iError = l1ConfCode + iErrorRecord + 3;
01717 return iError;
01718
01719 }
01720 break;
01721 }
01722
01723
01724
01725
01726 if (pfIndex < 0) {
01727
01728 iError = l1ConfCode + iErrorRecord + 1000;
01729 LogDebug("L1GtUtils")
01730 << "\nError: index of prescale factor set retrieved from the data \n"
01731 << "less than zero."
01732 << "\n Value of index retrieved from data = " << pfIndex
01733 << std::endl;
01734
01735 errorCode = iError;
01736 return pfIndex;
01737
01738 } else if (pfIndex >= (static_cast<int>(pfSetsSize))) {
01739 iError = l1ConfCode + iErrorRecord + 2000;
01740 LogDebug("L1GtUtils")
01741 << "\nError: index of prescale factor set retrieved from the data \n"
01742 << "greater than the size of the vector of prescale factor sets."
01743 << "\n Value of index retrieved from data = " << pfIndex
01744 << "\n Vector size = " << pfSetsSize << std::endl;
01745
01746 errorCode = iError;
01747 return pfIndex;
01748
01749 } else {
01750
01751 errorCode = iError;
01752 return pfIndex;
01753 }
01754
01755 errorCode = iError;
01756 return pfIndex;
01757
01758 }
01759
01760
01761 const int L1GtUtils::prescaleFactorSetIndex(const edm::Event& iEvent,
01762 const TriggerCategory& trigCategory, int& errorCode) const {
01763
01764
01765 int iError = 0;
01766 int pfIndex = -1;
01767
01768
01769
01770 pfIndex = prescaleFactorSetIndex(iEvent, m_provL1GtRecordInputTag,
01771 m_provL1GtReadoutRecordInputTag, trigCategory, iError);
01772
01773
01774
01775 errorCode = iError;
01776 return pfIndex;
01777
01778 }
01779
01780
01781
01782 const std::vector<int>& L1GtUtils::prescaleFactorSet(const edm::Event& iEvent,
01783 const edm::InputTag& l1GtRecordInputTag,
01784 const edm::InputTag& l1GtReadoutRecordInputTag,
01785 const TriggerCategory& trigCategory, int& errorCode) {
01786
01787
01788 m_prescaleFactorSet.clear();
01789
01790
01791 int iError = 0;
01792
01793 const int pfIndex = prescaleFactorSetIndex(iEvent, l1GtRecordInputTag,
01794 l1GtReadoutRecordInputTag, trigCategory, iError);
01795
01796 if (iError == 0) {
01797
01798 switch (trigCategory) {
01799 case AlgorithmTrigger: {
01800 if (m_retrieveL1GtTriggerMenuLite) {
01801 if (m_l1GtMenuLiteValid) {
01802 m_prescaleFactorSet
01803 = (*m_prescaleFactorsAlgoTrigLite).at(pfIndex);
01804
01805 } else {
01806
01807 m_prescaleFactorSet = (*m_prescaleFactorsAlgoTrig).at(
01808 pfIndex);
01809
01810 }
01811
01812 } else {
01813
01814 m_prescaleFactorSet = (*m_prescaleFactorsAlgoTrig).at(
01815 pfIndex);
01816
01817 }
01818
01819 }
01820 break;
01821 case TechnicalTrigger: {
01822 if (m_retrieveL1GtTriggerMenuLite) {
01823 if (m_l1GtMenuLiteValid) {
01824 m_prescaleFactorSet
01825 = (*m_prescaleFactorsTechTrigLite).at(pfIndex);
01826
01827 } else {
01828
01829 m_prescaleFactorSet = (*m_prescaleFactorsTechTrig).at(
01830 pfIndex);
01831
01832 }
01833
01834 } else {
01835
01836 m_prescaleFactorSet = (*m_prescaleFactorsTechTrig).at(
01837 pfIndex);
01838
01839 }
01840
01841 }
01842 break;
01843 default: {
01844
01845
01846 }
01847 break;
01848 }
01849
01850 }
01851
01852 errorCode = iError;
01853 return m_prescaleFactorSet;
01854
01855 }
01856
01857 const std::vector<int>& L1GtUtils::prescaleFactorSet(const edm::Event& iEvent,
01858 const TriggerCategory& trigCategory, int& errorCode) {
01859
01860
01861 m_prescaleFactorSet.clear();
01862
01863
01864 int iError = 0;
01865
01866
01867
01868 m_prescaleFactorSet = prescaleFactorSet(iEvent, m_provL1GtRecordInputTag,
01869 m_provL1GtReadoutRecordInputTag, trigCategory, iError);
01870
01871 errorCode = iError;
01872 return m_prescaleFactorSet;
01873
01874 }
01875
01876
01877
01878
01879 const std::vector<unsigned int>& L1GtUtils::triggerMaskSet(
01880 const TriggerCategory& trigCategory, int& errorCode) {
01881
01882
01883 m_triggerMaskSet.clear();
01884
01885
01886 int iError = 0;
01887 int l1ConfCode = 0;
01888
01889
01890
01891 if (!availableL1Configuration(iError, l1ConfCode)) {
01892 errorCode = iError;
01893 return m_triggerMaskSet;
01894 }
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905 switch (trigCategory) {
01906 case AlgorithmTrigger: {
01907 if (m_retrieveL1GtTriggerMenuLite) {
01908
01909
01910 if (m_l1GtMenuLiteValid) {
01911 errorCode = iError;
01912 return (*m_triggerMaskAlgoTrigLite);
01913
01914 } else {
01915
01916 for (unsigned i = 0; i < m_triggerMaskAlgoTrig->size(); i++) {
01917 m_triggerMaskSet.push_back(
01918 ((*m_triggerMaskAlgoTrig)[i]) & (1
01919 << m_physicsDaqPartition));
01920 }
01921
01922 }
01923
01924 } else {
01925
01926 for (unsigned i = 0; i < m_triggerMaskAlgoTrig->size(); i++) {
01927 m_triggerMaskSet.push_back(((*m_triggerMaskAlgoTrig)[i])
01928 & (1 << m_physicsDaqPartition));
01929 }
01930
01931 }
01932 }
01933 break;
01934 case TechnicalTrigger: {
01935 if (m_retrieveL1GtTriggerMenuLite) {
01936 if (m_l1GtMenuLiteValid) {
01937 errorCode = iError;
01938 return (*m_triggerMaskTechTrigLite);
01939
01940 } else {
01941
01942 for (unsigned i = 0; i < m_triggerMaskTechTrig->size(); i++) {
01943 m_triggerMaskSet.push_back(
01944 ((*m_triggerMaskTechTrig)[i]) & (1
01945 << m_physicsDaqPartition));
01946 }
01947
01948 }
01949
01950 } else {
01951
01952 for (unsigned i = 0; i < m_triggerMaskTechTrig->size(); i++) {
01953 m_triggerMaskSet.push_back(((*m_triggerMaskTechTrig)[i])
01954 & (1 << m_physicsDaqPartition));
01955 }
01956
01957 }
01958 }
01959 break;
01960 default: {
01961
01962 iError = l1ConfCode + 3;
01963
01964 errorCode = iError;
01965 return m_triggerMaskSet;
01966
01967 }
01968 break;
01969 }
01970
01971 errorCode = iError;
01972 return m_triggerMaskSet;
01973
01974 }
01975
01976
01977
01978 const std::string& L1GtUtils::l1TriggerMenu() const {
01979
01980 if (m_retrieveL1GtTriggerMenuLite) {
01981 if (m_l1GtMenuLiteValid) {
01982 return m_l1GtMenuLite->gtTriggerMenuName();
01983
01984 } else if (m_retrieveL1EventSetup) {
01985 return m_l1GtMenu->gtTriggerMenuName();
01986
01987 } else {
01988
01989 return EmptyString;
01990
01991 }
01992 } else if (m_retrieveL1EventSetup) {
01993 return m_l1GtMenu->gtTriggerMenuName();
01994
01995 } else {
01996
01997 return EmptyString;
01998
01999 }
02000
02001 }
02002
02003 const std::string& L1GtUtils::l1TriggerMenuImplementation() const {
02004
02005 if (m_retrieveL1GtTriggerMenuLite) {
02006 if (m_l1GtMenuLiteValid) {
02007 return m_l1GtMenuLite->gtTriggerMenuImplementation();
02008
02009 } else if (m_retrieveL1EventSetup) {
02010 return m_l1GtMenu->gtTriggerMenuImplementation();
02011
02012 } else {
02013
02014 return EmptyString;
02015
02016 }
02017 } else if (m_retrieveL1EventSetup) {
02018 return m_l1GtMenu->gtTriggerMenuImplementation();
02019
02020 } else {
02021
02022 return EmptyString;
02023
02024 }
02025
02026 }
02027
02028 const L1GtTriggerMenu* L1GtUtils::ptrL1TriggerMenuEventSetup(int& errorCode) {
02029
02030
02031 int iError = 0;
02032 int l1ConfCode = 0;
02033
02034
02035
02036 if (!availableL1Configuration(iError, l1ConfCode)) {
02037 errorCode = iError;
02038 return 0;
02039 }
02040
02041 if (m_retrieveL1EventSetup) {
02042 errorCode = iError;
02043 return m_l1GtMenu;
02044 } else {
02045 iError = l1ConfCode;
02046
02047 errorCode = iError;
02048 return 0;
02049
02050 }
02051
02052 errorCode = iError;
02053 return m_l1GtMenu;
02054 }
02055
02056 const L1GtTriggerMenuLite* L1GtUtils::ptrL1GtTriggerMenuLite(int& errorCode) {
02057
02058
02059 int iError = 0;
02060 int l1ConfCode = 0;
02061
02062
02063
02064 if (!availableL1Configuration(iError, l1ConfCode)) {
02065 errorCode = iError;
02066 return 0;
02067 }
02068
02069 if (m_retrieveL1GtTriggerMenuLite) {
02070 if (m_l1GtMenuLiteValid) {
02071
02072 errorCode = iError;
02073 return m_l1GtMenuLite;
02074
02075 } else {
02076 iError = l1ConfCode;
02077
02078 errorCode = iError;
02079 return 0;
02080 }
02081 } else {
02082 iError = l1ConfCode;
02083
02084 errorCode = iError;
02085 return 0;
02086 }
02087
02088 errorCode = iError;
02089 return m_l1GtMenuLite;
02090
02091 }
02092
02093 const bool L1GtUtils::availableL1Configuration(int& errorCode, int& l1ConfCode) const {
02094
02095 if (m_retrieveL1GtTriggerMenuLite) {
02096 if (!m_retrieveL1EventSetup) {
02097 LogDebug("L1GtUtils")
02098 << "\nRetrieve L1 trigger configuration from L1GtTriggerMenuLite only.\n"
02099 << std::endl;
02100 l1ConfCode = 0;
02101 } else {
02102 LogDebug("L1GtUtils")
02103 << "\nFall through: retrieve L1 trigger configuration from L1GtTriggerMenuLite."
02104 << "\nIf L1GtTriggerMenuLite not valid, try to retrieve from event setup.\n"
02105 << std::endl;
02106 l1ConfCode = 100000;
02107 }
02108
02109 if (m_l1GtMenuLiteValid) {
02110 LogDebug("L1GtUtils")
02111 << "\nRetrieve L1 trigger configuration from L1GtTriggerMenuLite, valid product.\n"
02112 << std::endl;
02113 l1ConfCode = l1ConfCode + 10000;
02114 errorCode = 0;
02115
02116 return true;
02117
02118 } else if (m_retrieveL1EventSetup) {
02119 if (m_l1EventSetupValid) {
02120 LogDebug("L1GtUtils")
02121 << "\nFall through: retrieve L1 trigger configuration from event setup."
02122 << "\nFirst option was L1GtTriggerMenuLite - but product is not valid.\n"
02123 << std::endl;
02124 l1ConfCode = l1ConfCode + 20000;
02125 errorCode = 0;
02126
02127 return true;
02128
02129 } else {
02130 LogDebug("L1GtUtils")
02131 << "\nFall through: L1GtTriggerMenuLite not valid, event setup not valid.\n"
02132 << std::endl;
02133 l1ConfCode = l1ConfCode + L1GtNotValidError;
02134 errorCode = l1ConfCode;
02135
02136 return false;
02137
02138
02139 }
02140
02141 } else {
02142 LogDebug("L1GtUtils")
02143 << "\nError: L1 trigger configuration requested from L1GtTriggerMenuLite only"
02144 << "\nbut L1GtTriggerMenuLite is not valid.\n" << std::endl;
02145 l1ConfCode = l1ConfCode + L1GtNotValidError;
02146 errorCode = l1ConfCode;
02147
02148 return false;
02149
02150 }
02151 } else if (m_retrieveL1EventSetup) {
02152
02153 LogDebug("L1GtUtils")
02154 << "\nRetrieve L1 trigger configuration from event setup."
02155 << "\nL1GtTriggerMenuLite product was not requested.\n"
02156 << std::endl;
02157 l1ConfCode = 200000;
02158
02159 if (m_l1EventSetupValid) {
02160 LogDebug("L1GtUtils")
02161 << "\nRetrieve L1 trigger configuration from event setup only."
02162 << "\nValid L1 trigger event setup.\n"
02163 << std::endl;
02164 l1ConfCode = l1ConfCode + 10000;
02165 errorCode = 0;
02166
02167 return true;
02168
02169 } else {
02170 LogDebug("L1GtUtils")
02171 << "\nRetrieve L1 trigger configuration from event setup only."
02172 << "\nNo valid L1 trigger event setup.\n"
02173 << std::endl;
02174 l1ConfCode = l1ConfCode + L1GtNotValidError;
02175 errorCode = l1ConfCode;
02176
02177 return false;
02178
02179
02180 }
02181
02182 } else {
02183 LogDebug("L1GtUtils")
02184 << "\nError: no L1 trigger configuration requested to be retrieved."
02185 << "\nMust call before getL1GtRunCache in beginRun and analyze.\n"
02186 << std::endl;
02187 l1ConfCode = 300000;
02188 errorCode = l1ConfCode;
02189
02190 return false;
02191
02192 }
02193 }
02194
02195
02196
02197 const bool L1GtUtils::trigResult(const DecisionWord& decWord,
02198 const int bitNumber, const std::string& nameAlgoTechTrig,
02199 const TriggerCategory& trigCategory, int& errorCode) const {
02200
02201 bool trigRes = false;
02202 errorCode = 0;
02203
02204 if (bitNumber < (static_cast<int> (decWord.size()))) {
02205 trigRes = decWord[bitNumber];
02206 } else {
02207 errorCode = 3000;
02208 LogDebug("L1GtUtils") << "\nError: bit number " << bitNumber
02209 << " retrieved for " << triggerCategory(trigCategory) << "\n "
02210 << nameAlgoTechTrig
02211 << "\ngreater than size of L1 GT decision word: "
02212 << decWord.size()
02213 << "\nError: Inconsistent L1 trigger configuration!"
02214 << std::endl;
02215 }
02216
02217 return trigRes;
02218 }
02219
02220
02221 const std::string L1GtUtils::EmptyString = "";
02222 const int L1GtUtils::L1GtNotValidError = 99999;
02223