CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/L1Trigger/GlobalTriggerAnalyzer/src/L1GtUtils.cc

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