CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/L1Trigger/GlobalTriggerAnalyzer/src/L1GtAnalyzer.cc

Go to the documentation of this file.
00001 
00017 // this class header
00018 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtAnalyzer.h"
00019 
00020 // system include files
00021 #include <memory>
00022 #include <iomanip>
00023 
00024 // user include files
00025 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00026 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
00027 
00028 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00029 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerRecord.h"
00030 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMapRecord.h"
00031 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMaps.h"
00032 
00033 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMap.h"
00034 
00035 #include "DataFormats/L1GlobalTrigger/interface/L1GtTriggerMenuLite.h"
00036 
00037 #include "DataFormats/Common/interface/ConditionsInEdm.h"
00038 
00039 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
00040 
00041 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTrigger.h"
00042 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerPSB.h"
00043 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerGTL.h"
00044 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerFDL.h"
00045 
00046 #include "FWCore/Framework/interface/ESHandle.h"
00047 #include "FWCore/Framework/interface/LuminosityBlock.h"
00048 
00049 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00050 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
00051 
00052 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00053 
00054 // constructor(s)
00055 L1GtAnalyzer::L1GtAnalyzer(const edm::ParameterSet& parSet) :
00056 
00057             m_retrieveL1Extra(
00058                     parSet.getParameter<edm::ParameterSet> ("L1ExtraInputTags")),
00059 
00060             m_printOutput(parSet.getUntrackedParameter<int>("PrintOutput", 3)),
00061 
00062             m_analyzeDecisionReadoutRecordEnable(parSet.getParameter<bool> ("analyzeDecisionReadoutRecordEnable")),
00063             //
00064             m_analyzeL1GtUtilsMenuLiteEnable(parSet.getParameter<bool> ("analyzeL1GtUtilsMenuLiteEnable")),
00065             m_analyzeL1GtUtilsEventSetupEnable(parSet.getParameter<bool> ("analyzeL1GtUtilsEventSetupEnable")),
00066             m_analyzeL1GtUtilsEnable(parSet.getParameter<bool> ("analyzeL1GtUtilsEnable")),
00067             m_analyzeTriggerEnable(parSet.getParameter<bool> ("analyzeTriggerEnable")),
00068             //
00069             m_analyzeObjectMapEnable(parSet.getParameter<bool> ("analyzeObjectMapEnable")),
00070             //
00071             m_analyzeL1GtTriggerMenuLiteEnable(parSet.getParameter<bool> ("analyzeL1GtTriggerMenuLiteEnable")),
00072             //
00073             m_analyzeConditionsInRunBlockEnable(parSet.getParameter<bool> ("analyzeConditionsInRunBlockEnable")),
00074             m_analyzeConditionsInLumiBlockEnable(parSet.getParameter<bool> ("analyzeConditionsInLumiBlockEnable")),
00075             m_analyzeConditionsInEventBlockEnable(parSet.getParameter<bool> ("analyzeConditionsInEventBlockEnable")),
00076 
00077 
00078             // input tag for GT DAQ product
00079             m_l1GtDaqReadoutRecordInputTag(parSet.getParameter<edm::InputTag>(
00080                     "L1GtDaqReadoutRecordInputTag")),
00081 
00082             // input tag for L1GlobalTriggerRecord
00083             m_l1GtRecordInputTag(parSet.getParameter<edm::InputTag>(
00084                     "L1GtRecordInputTag")),
00085 
00086             // input tag for GT object map collection L1GlobalTriggerObjectMapRecord
00087             m_l1GtObjectMapTag(parSet.getParameter<edm::InputTag>(
00088                     "L1GtObjectMapTag")),
00089 
00090             // input tag for GT object map collection L1GlobalTriggerObjectMaps
00091             m_l1GtObjectMapsInputTag(parSet.getParameter<edm::InputTag>(
00092                     "L1GtObjectMapsInputTag")),
00093 
00094             // input tag for muon collection from GMT
00095             m_l1GmtInputTag(parSet.getParameter<edm::InputTag>(
00096                     "L1GmtInputTag")),
00097 
00098             // input tag for L1GtTriggerMenuLite
00099             m_l1GtTmLInputTag(parSet.getParameter<edm::InputTag> (
00100                     "L1GtTmLInputTag")),
00101 
00102             // input tag for ConditionInEdm products
00103             m_condInEdmInputTag(parSet.getParameter<edm::InputTag> (
00104                             "CondInEdmInputTag")),
00105 
00106             // an algorithm and a condition in that algorithm to test the object maps
00107             m_nameAlgTechTrig(parSet.getParameter<std::string> ("AlgorithmName")),
00108             m_condName(parSet.getParameter<std::string> ("ConditionName")),
00109             m_bitNumber(parSet.getParameter<unsigned int> ("BitNumber")),
00110 
00111             m_l1GtUtilsConfiguration(parSet.getParameter<unsigned int> ("L1GtUtilsConfiguration")),
00112             m_l1GtTmLInputTagProv(parSet.getParameter<bool> ("L1GtTmLInputTagProv")),
00113             m_l1GtRecordsInputTagProv(parSet.getParameter<bool> ("L1GtRecordsInputTagProv")),
00114             m_l1GtUtilsConfigureBeginRun(parSet.getParameter<bool> ("L1GtUtilsConfigureBeginRun")), 
00115             m_l1GtUtilsLogicalExpression(parSet.getParameter<std::string>("L1GtUtilsLogicalExpression")), 
00116             m_logicalExpressionL1ResultsProv(m_l1GtUtilsLogicalExpression, m_l1GtUtils),
00117             m_logicalExpressionL1Results(m_l1GtUtilsLogicalExpression, m_l1GtUtils, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag)
00118 
00119 {
00120 
00121 
00122     LogDebug("L1GtAnalyzer")
00123             << "\n Input parameters for L1 GT test analyzer"
00124             << "\n   L1 GT DAQ product:            "
00125             << m_l1GtDaqReadoutRecordInputTag
00126             << "\n   L1GlobalTriggerRecord product:           "
00127             << m_l1GtRecordInputTag
00128             << "\n   L1 GT object map collection:  "
00129             << m_l1GtObjectMapTag
00130             << "\n   Muon collection from GMT:     "
00131             << m_l1GmtInputTag
00132             << "\n   L1 trigger menu lite product: "
00133             << m_l1GtTmLInputTag
00134             << "\n   Algorithm name or alias, technical trigger name:  " << m_nameAlgTechTrig
00135             << "\n   Condition, if an algorithm trigger is requested:   " << m_condName
00136             << "\n   Bit number for an algorithm or technical trigger: " << m_bitNumber
00137             << "\n   Requested L1 trigger configuration: " << m_l1GtUtilsConfiguration
00138             << "\n   Retrieve input tag from provenance for L1GtTriggerMenuLite in the L1GtUtils: "
00139             << m_l1GtTmLInputTagProv
00140             << "\n   Retrieve input tag from provenance for L1GlobalTriggerReadoutRecord "
00141             << "\n   and / or L1GlobalTriggerRecord in the L1GtUtils: "
00142             << m_l1GtRecordsInputTagProv
00143             << "\n   Configure L1GtUtils in beginRun(...): "
00144             << m_l1GtUtilsConfigureBeginRun
00145             << " \n" << std::endl;
00146     
00147 }
00148 
00149 // destructor
00150 L1GtAnalyzer::~L1GtAnalyzer() {
00151 
00152     // empty
00153 
00154 }
00155 
00156 // method called once each job just before starting event loop
00157 void L1GtAnalyzer::beginJob()
00158 {
00159 
00160     // empty
00161 
00162 }
00163 
00164 void L1GtAnalyzer::beginRun(const edm::Run& iRun,
00165         const edm::EventSetup& evSetup) {
00166 
00167     if (m_analyzeConditionsInRunBlockEnable) {
00168         analyzeConditionsInRunBlock(iRun, evSetup);
00169     }
00170 
00171     // L1GtUtils
00172 
00173     if (m_l1GtUtilsConfigureBeginRun) {
00174 
00175         //   for tests, use only one of the following methods for m_l1GtUtilsConfiguration
00176 
00177         bool useL1EventSetup = false;
00178         bool useL1GtTriggerMenuLite = false;
00179 
00180         switch (m_l1GtUtilsConfiguration) {
00181             case 0: {
00182                 useL1EventSetup = false;
00183                 useL1GtTriggerMenuLite = true;
00184 
00185             }
00186                 break;
00187             case 100000: {
00188                 useL1EventSetup = true;
00189                 useL1GtTriggerMenuLite = true;
00190 
00191             }
00192                 break;
00193             case 200000: {
00194                 useL1EventSetup = true;
00195                 useL1GtTriggerMenuLite = false;
00196 
00197             }
00198                 break;
00199             default: {
00200                 // do nothing
00201             }
00202                 break;
00203         }
00204 
00205         if (m_l1GtTmLInputTagProv) {
00206             // L1GtTriggerMenuLite input tag from provenance
00207             m_l1GtUtils.getL1GtRunCache(iRun, evSetup, useL1EventSetup,
00208                     useL1GtTriggerMenuLite);
00209 
00210         } else {
00211 
00212             // L1GtTriggerMenuLite input tag given in configuration file
00213             m_l1GtUtils.getL1GtRunCache(iRun, evSetup, useL1EventSetup,
00214                     useL1GtTriggerMenuLite, m_l1GtTmLInputTag);
00215         }
00216 
00217         // check if the parsing of the logical expression was successful
00218 
00219         if (m_logicalExpressionL1ResultsProv.isValid()) {
00220             m_logicalExpressionL1ResultsProv.logicalExpressionRunUpdate(iRun,
00221                     evSetup);
00222         } else {
00223             // do whatever is necessary if parsing fails - the size of all vectors with L1 results is zero in this case
00224             // a LogWarning message is written in L1GtUtils
00225         }
00226 
00227 //        if (m_logicalExpressionL1Results.isValid()) {
00228 //            m_logicalExpressionL1Results.logicalExpressionRunUpdate(iRun,
00229 //                    evSetup);
00230 //        } else {
00231 //            // do whatever is necessary if parsing fails - the size of all vectors with L1 results is zero in this case
00232 //            // a LogWarning message is written in L1GtUtils
00233 //        }
00234 
00235         // if the logical expression is changed, one has to check it's validity after the logicalExpressionRunUpdate call
00236         // (...dirty testing with the same logical expression)
00237         m_logicalExpressionL1Results.logicalExpressionRunUpdate(iRun, evSetup,
00238                 m_l1GtUtilsLogicalExpression);
00239         if (!(m_logicalExpressionL1Results.isValid())) {
00240             // do whatever is necessary if parsing fails - the size of all vectors with L1 results is zero in this case
00241             // a LogWarning message is written in L1GtUtils
00242         } 
00243 
00244     }
00245 
00246 }
00247 
00248 
00249 void L1GtAnalyzer::beginLuminosityBlock(const edm::LuminosityBlock& iLumi,
00250         const edm::EventSetup& evSetup) {
00251 
00252     if (m_analyzeConditionsInLumiBlockEnable) {
00253         analyzeConditionsInLumiBlock(iLumi, evSetup);
00254     }
00255 
00256 }
00257 
00258 
00259 // member functions
00260 
00261 // analyze: decision and decision word
00262 //   bunch cross in event BxInEvent = 0 - L1Accept event
00263 void L1GtAnalyzer::analyzeDecisionReadoutRecord(const edm::Event& iEvent, const edm::EventSetup& evSetup)
00264 {
00265 
00266     LogDebug("L1GtAnalyzer")
00267     << "\n**** L1GtAnalyzer::analyzeDecisionReadoutRecord ****\n"
00268     << std::endl;
00269 
00270     // define an output stream to print into
00271     // it can then be directed to whatever log level is desired
00272     std::ostringstream myCoutStream;
00273 
00274     // get L1GlobalTriggerReadoutRecord
00275     edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecord;
00276     iEvent.getByLabel(m_l1GtDaqReadoutRecordInputTag, gtReadoutRecord);
00277 
00278     if (!gtReadoutRecord.isValid()) {
00279 
00280         LogDebug("L1GtAnalyzer") << "\nL1GlobalTriggerReadoutRecord with \n  "
00281                 << m_l1GtDaqReadoutRecordInputTag
00282                 << "\nrequested in configuration, but not found in the event."
00283                 << "\nExit the method.\n" << std::endl;
00284 
00285         return;
00286     }
00287 
00288     // get Global Trigger decision and the decision word
00289     bool gtDecision = gtReadoutRecord->decision();
00290     DecisionWord gtDecisionWord = gtReadoutRecord->decisionWord();
00291 
00292     // print Global Trigger decision and the decision word
00293     edm::LogVerbatim("L1GtAnalyzer")
00294     << "\n GlobalTrigger decision: " << gtDecision << std::endl;
00295 
00296     // print via supplied "print" function (
00297     gtReadoutRecord->printGtDecision(myCoutStream);
00298 
00299     // print technical trigger word via supplied "print" function
00300     gtReadoutRecord->printTechnicalTrigger(myCoutStream);
00301 
00302     printOutput(myCoutStream);
00303 
00304 }
00305 
00306 
00307 void L1GtAnalyzer::analyzeL1GtUtilsCore(const edm::Event& iEvent,
00308         const edm::EventSetup& evSetup) {
00309 
00310 
00311     // define an output stream to print into
00312     // it can then be directed to whatever log level is desired
00313     std::ostringstream myCoutStream;
00314 
00315 
00316     // example to access L1 trigger results using public methods from L1GtUtils
00317     // methods must be called after retrieving the L1 configuration
00318 
00319     // testing which environment is used
00320 
00321     int iErrorCode = -1;
00322     int l1ConfCode = -1;
00323 
00324     const bool l1Conf = m_l1GtUtils.availableL1Configuration(iErrorCode, l1ConfCode);
00325 
00326     myCoutStream << "\nL1 configuration code: \n"
00327             << "\n Legend: "
00328             << "\n      0 - Retrieve L1 trigger configuration from L1GtTriggerMenuLite only"
00329             << "\n  10000     L1GtTriggerMenuLite product is valid"
00330             << "\n  99999     L1GtTriggerMenuLite product not valid. Error."
00331             << "\n"
00332             << "\n 100000 - Fall through: try first L1GtTriggerMenuLite; if not valid,try event setup."
00333             << "\n 110000     L1GtTriggerMenuLite product is valid"
00334             << "\n 120000     L1GtTriggerMenuLite product not valid, event setup valid."
00335             << "\n 199999     L1GtTriggerMenuLite product not valid, event setup not valid. Error."
00336             << "\n"
00337             << "\n 200000 - Retrieve L1 trigger configuration from event setup only."
00338             << "\n 210000     Event setup valid."
00339             << "\n 299999     Event setup not valid. Error."
00340             << "\n"
00341             << "\n 300000 - No L1 trigger configuration requested to be retrieved. Error"
00342             << "\n            Must call before using L1GtUtils methods: "
00343             << "\n                getL1GtRunCache(const edm::Event& iEvent, const edm::EventSetup& evSetup,"
00344             << "\n                                const bool useL1EventSetup, const bool useL1GtTriggerMenuLite)"
00345             << "\n"
00346             << std::endl;
00347 
00348 
00349     if (l1Conf) {
00350         myCoutStream << "\nL1 configuration code:" << l1ConfCode
00351                 << "\nValid L1 trigger configuration." << std::endl;
00352 
00353         myCoutStream << "\nL1 trigger menu name and implementation:" << "\n"
00354                 << m_l1GtUtils.l1TriggerMenu() << "\n"
00355                 << m_l1GtUtils.l1TriggerMenuImplementation() << std::endl;
00356 
00357     } else {
00358         myCoutStream << "\nL1 configuration code:" << l1ConfCode
00359                 << "\nNo valid L1 trigger configuration available."
00360                 << "\nSee text above for error code interpretation"
00361                 << "\nNo return here, in order to test each method, protected against configuration error."
00362                 << std::endl;
00363     }
00364 
00365 
00366 
00367     myCoutStream
00368             << "\n******** Results found with input tags retrieved from provenance ******** \n"
00369             << std::endl;
00370 
00371     //
00372     // no input tags; for the appropriate EDM product, it will be found
00373     // from provenance
00374 
00375     // the following methods share the same error code, therefore one can check only once
00376     // the validity of the result
00377 
00378     iErrorCode = -1;
00379 
00380     bool decisionBeforeMaskAlgTechTrig = m_l1GtUtils.decisionBeforeMask(iEvent,
00381             m_nameAlgTechTrig, iErrorCode);
00382 
00383     bool decisionAfterMaskAlgTechTrig = m_l1GtUtils.decisionAfterMask(iEvent,
00384             m_nameAlgTechTrig, iErrorCode);
00385 
00386     bool decisionAlgTechTrig = m_l1GtUtils.decision(iEvent, m_nameAlgTechTrig,
00387             iErrorCode);
00388 
00389     int prescaleFactorAlgTechTrig = m_l1GtUtils.prescaleFactor(iEvent,
00390             m_nameAlgTechTrig, iErrorCode);
00391 
00392     int triggerMaskAlgTechTrig = m_l1GtUtils.triggerMask(iEvent,
00393             m_nameAlgTechTrig, iErrorCode);
00394 
00395     myCoutStream << "\n\nMethods:"
00396             << "\n  decisionBeforeMask(iEvent, m_nameAlgTechTrig, iErrorCode)"
00397             << "\n  decisionAfterMask(iEvent, m_nameAlgTechTrig, iErrorCode)"
00398             << "\n  decision(iEvent, m_nameAlgTechTrig, iErrorCode)"
00399             << "\n  prescaleFactor(iEvent, m_nameAlgTechTrig, iErrorCode)"
00400             << "\n  triggerMask(iEvent, m_nameAlgTechTrig, iErrorCode)"
00401             << "\n  triggerMask(m_nameAlgTechTrig,iErrorCode)"
00402             << "\n\n" << std::endl;
00403 
00404 
00405     if (iErrorCode == 0) {
00406         myCoutStream << "\nDecision before trigger mask for "
00407                 << m_nameAlgTechTrig << ":   " << decisionBeforeMaskAlgTechTrig
00408                 << std::endl;
00409         myCoutStream << "Decision after trigger mask for " << m_nameAlgTechTrig
00410                 << ":    " << decisionAfterMaskAlgTechTrig << std::endl;
00411         myCoutStream << "Decision (after trigger mask) for "
00412                 << m_nameAlgTechTrig << ":  " << decisionAlgTechTrig
00413                 << std::endl;
00414 
00415         myCoutStream << "Prescale factor for " << m_nameAlgTechTrig
00416                 << ":                " << prescaleFactorAlgTechTrig
00417                 << std::endl;
00418 
00419         myCoutStream << "Trigger mask for " << m_nameAlgTechTrig
00420                 << ":                   " << triggerMaskAlgTechTrig
00421                 << std::endl;
00422 
00423     } else if (iErrorCode == 1) {
00424         myCoutStream << "\n" << m_nameAlgTechTrig
00425                 << " does not exist in the L1 menu "
00426                 << m_l1GtUtils.l1TriggerMenu() << "\n" << std::endl;
00427 
00428     } else {
00429         myCoutStream << "\nError: "
00430                 << "\n  An error was encountered when retrieving decision, mask and prescale factor for "
00431                 << m_nameAlgTechTrig << "\n  L1 Menu: "
00432                 << m_l1GtUtils.l1TriggerMenu() << "\n  Error code: "
00433                 << iErrorCode << std::endl;
00434 
00435     }
00436 
00437     // another method to get the trigger mask (no common errorCode)
00438 
00439     iErrorCode = -1;
00440     triggerMaskAlgTechTrig = m_l1GtUtils.triggerMask(m_nameAlgTechTrig,
00441             iErrorCode);
00442 
00443     if (iErrorCode == 0) {
00444         myCoutStream << "\nTrigger mask for " << m_nameAlgTechTrig
00445                 << "(faster method):    " << triggerMaskAlgTechTrig
00446                 << std::endl;
00447 
00448     } else if (iErrorCode == 1) {
00449         myCoutStream << "\n" << m_nameAlgTechTrig
00450                 << " does not exist in the L1 menu "
00451                 << m_l1GtUtils.l1TriggerMenu() << "\n" << std::endl;
00452 
00453     } else {
00454         myCoutStream << "\nError: "
00455                 << "\n  An error was encountered when fast retrieving trigger mask for "
00456                 << m_nameAlgTechTrig << "\n  L1 Menu: "
00457                 << m_l1GtUtils.l1TriggerMenu() << "\n  Error code: "
00458                 << iErrorCode << std::endl;
00459 
00460     }
00461 
00462     // index of the actual prescale factor set, and the actual prescale
00463     // factor set for algorithm triggers
00464 
00465 
00466 
00467     L1GtUtils::TriggerCategory trigCategory = L1GtUtils::AlgorithmTrigger;
00468 
00469     myCoutStream << "\nMethods:"
00470             << "\n  prescaleFactorSetIndex(iEvent, trigCategory, iErrorCode)"
00471             << "\n  prescaleFactorSet(iEvent, trigCategory,iErrorCode)\n"
00472             << std::endl;
00473 
00474     iErrorCode = -1;
00475     const int pfSetIndexAlgorithmTrigger = m_l1GtUtils.prescaleFactorSetIndex(
00476             iEvent, trigCategory, iErrorCode);
00477 
00478     if (iErrorCode == 0) {
00479         myCoutStream
00480                 << "\nAlgorithm triggers: index for prescale factor set = "
00481                 << pfSetIndexAlgorithmTrigger << "\nfor run " << iEvent.run()
00482                 << ", luminosity block " << iEvent.luminosityBlock()
00483                 << ", with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00484                 << std::endl;
00485 
00486 
00487     } else {
00488         myCoutStream
00489                 << "\nError encountered when retrieving the prescale factor set index"
00490                 << "\n  for algorithm triggers, for run " << iEvent.run()
00491                 << ", luminosity block " << iEvent.luminosityBlock()
00492                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00493                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00494     }
00495 
00496     iErrorCode = -1;
00497     const std::vector<int>& pfSetAlgorithmTrigger =
00498             m_l1GtUtils.prescaleFactorSet(iEvent, trigCategory, iErrorCode);
00499 
00500     if (iErrorCode == 0) {
00501         myCoutStream << "\nAlgorithm triggers: prescale factor set index = "
00502                 << pfSetIndexAlgorithmTrigger << "\nfor run " << iEvent.run()
00503                 << ", luminosity block " << iEvent.luminosityBlock()
00504                 << ", with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00505                 << std::endl;
00506 
00507         int iBit = -1;
00508         for (std::vector<int>::const_iterator cItBit =
00509                 pfSetAlgorithmTrigger.begin(); cItBit
00510                 != pfSetAlgorithmTrigger.end(); ++cItBit) {
00511 
00512             iBit++;
00513             myCoutStream << "Bit number " << std::right << std::setw(4) << iBit
00514                     << ": prescale factor = " << (*cItBit) << std::endl;
00515 
00516         }
00517 
00518     } else {
00519         myCoutStream
00520                 << "\nError encountered when retrieving the prescale factor set "
00521                 << "\n  for algorithm triggers, for run " << iEvent.run()
00522                 << ", luminosity block " << iEvent.luminosityBlock()
00523                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00524                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00525     }
00526 
00527     // the actual trigger mask set for algorithm triggers
00528 
00529     myCoutStream << "\nMethod:"
00530             << "\n  triggerMaskSet(trigCategory, iErrorCode)"
00531             << std::endl;
00532 
00533     iErrorCode = -1;
00534     const std::vector<unsigned int>& tmSetAlgorithmTrigger =
00535             m_l1GtUtils.triggerMaskSet(trigCategory, iErrorCode);
00536 
00537     if (iErrorCode == 0) {
00538         myCoutStream << "\nAlgorithm triggers: trigger mask set for run "
00539                 << iEvent.run() << ", luminosity block "
00540                 << iEvent.luminosityBlock() << ", with L1 menu \n  "
00541                 << m_l1GtUtils.l1TriggerMenu() << "\n" << std::endl;
00542 
00543         int iBit = -1;
00544         for (std::vector<unsigned int>::const_iterator cItBit =
00545                 tmSetAlgorithmTrigger.begin(); cItBit
00546                 != tmSetAlgorithmTrigger.end(); ++cItBit) {
00547 
00548             iBit++;
00549             myCoutStream << "Bit number " << std::right << std::setw(4) << iBit
00550                     << ": trigger mask = " << (*cItBit) << std::endl;
00551 
00552         }
00553 
00554     } else {
00555         myCoutStream
00556                 << "\nError encountered when retrieving the trigger mask set "
00557                 << "\n  for algorithm triggers, for run " << iEvent.run()
00558                 << ", luminosity block " << iEvent.luminosityBlock()
00559                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00560                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00561     }
00562 
00563 
00564 
00565 
00566     // index of the actual prescale factor set, and the actual prescale
00567     // factor set for technical triggers
00568 
00569     trigCategory = L1GtUtils::TechnicalTrigger;
00570 
00571     myCoutStream << "\nMethods:"
00572             << "\n  prescaleFactorSetIndex(iEvent, trigCategory, iErrorCode)"
00573             << "\n  prescaleFactorSet(iEvent, trigCategory,iErrorCode)\n"
00574             << std::endl;
00575 
00576     iErrorCode = -1;
00577     const int pfSetIndexTechnicalTrigger = m_l1GtUtils.prescaleFactorSetIndex(
00578             iEvent, trigCategory, iErrorCode);
00579 
00580     if (iErrorCode == 0) {
00581         myCoutStream
00582                 << "\nTechnical triggers: index for prescale factor set = "
00583                 << pfSetIndexTechnicalTrigger << "\nfor run " << iEvent.run()
00584                 << ", luminosity block " << iEvent.luminosityBlock()
00585                 << ", with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00586                 << "\nMethod: prescaleFactorSetIndex(iEvent, trigCategory, iErrorCode)\n"
00587                 << std::endl;
00588 
00589     } else {
00590         myCoutStream
00591                 << "\nError encountered when retrieving the prescale factor set index"
00592                 << "\n  for technical triggers, for run " << iEvent.run()
00593                 << ", luminosity block " << iEvent.luminosityBlock()
00594                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00595                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00596     }
00597 
00598     iErrorCode = -1;
00599     const std::vector<int>& pfSetTechnicalTrigger =
00600             m_l1GtUtils.prescaleFactorSet(iEvent, trigCategory, iErrorCode);
00601 
00602     if (iErrorCode == 0) {
00603         myCoutStream << "\nTechnical triggers: prescale factor set index = "
00604                 << pfSetIndexTechnicalTrigger << "\nfor run " << iEvent.run()
00605                 << ", luminosity block " << iEvent.luminosityBlock()
00606                 << ", with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00607                 << "\nMethod: prescaleFactorSet(iEvent, trigCategory,iErrorCode)\n"
00608                 << std::endl;
00609 
00610         int iBit = -1;
00611         for (std::vector<int>::const_iterator cItBit =
00612                 pfSetTechnicalTrigger.begin(); cItBit
00613                 != pfSetTechnicalTrigger.end(); ++cItBit) {
00614 
00615             iBit++;
00616             myCoutStream << "Bit number " << std::right << std::setw(4) << iBit
00617                     << ": prescale factor = " << (*cItBit) << std::endl;
00618 
00619         }
00620 
00621     } else {
00622         myCoutStream
00623                 << "\nError encountered when retrieving the prescale factor set "
00624                 << "\n  for technical triggers, for run " << iEvent.run()
00625                 << ", luminosity block " << iEvent.luminosityBlock()
00626                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00627                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00628     }
00629 
00630     // the actual trigger mask set for technical triggers
00631 
00632     myCoutStream << "\nMethod:"
00633             << "\n  triggerMaskSet(trigCategory, iErrorCode)"
00634             << std::endl;
00635 
00636     iErrorCode = -1;
00637     const std::vector<unsigned int>& tmSetTechnicalTrigger =
00638             m_l1GtUtils.triggerMaskSet(trigCategory, iErrorCode);
00639 
00640     if (iErrorCode == 0) {
00641         myCoutStream << "\nTechnical triggers: trigger mask set for run "
00642                 << iEvent.run() << ", luminosity block "
00643                 << iEvent.luminosityBlock() << ", with L1 menu \n  "
00644                 << m_l1GtUtils.l1TriggerMenu() << "\n" << std::endl;
00645 
00646         int iBit = -1;
00647         for (std::vector<unsigned int>::const_iterator cItBit =
00648                 tmSetTechnicalTrigger.begin(); cItBit
00649                 != tmSetTechnicalTrigger.end(); ++cItBit) {
00650 
00651             iBit++;
00652             myCoutStream << "Bit number " << std::right << std::setw(4) << iBit
00653                     << ": trigger mask = " << (*cItBit) << std::endl;
00654 
00655         }
00656 
00657     } else {
00658         myCoutStream
00659                 << "\nError encountered when retrieving the trigger mask set "
00660                 << "\n  for technical triggers, for run " << iEvent.run()
00661                 << ", luminosity block " << iEvent.luminosityBlock()
00662                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00663                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00664     }
00665 
00666 
00667     // results for logical expressions
00668 
00669     // errorCodes must be called before any other method is used
00670     const std::vector<std::pair<std::string, int> >& errorCodesProv =
00671             m_logicalExpressionL1ResultsProv.errorCodes(iEvent);
00672 
00673     const std::vector<L1GtLogicParser::OperandToken>& expL1TriggersProv =
00674             m_logicalExpressionL1ResultsProv.expL1Triggers();
00675 
00676     const std::vector<std::pair<std::string, bool> >& decisionsBeforeMaskProv =
00677             m_logicalExpressionL1ResultsProv.decisionsBeforeMask();
00678     const std::vector<std::pair<std::string, bool> >& decisionsAfterMaskProv =
00679             m_logicalExpressionL1ResultsProv.decisionsAfterMask();
00680     const std::vector<std::pair<std::string, int> >& prescaleFactorsProv =
00681             m_logicalExpressionL1ResultsProv.prescaleFactors();
00682     const std::vector<std::pair<std::string, int> >& triggerMasksProv =
00683             m_logicalExpressionL1ResultsProv.triggerMasks();
00684 
00685     myCoutStream << std::endl;
00686     myCoutStream << "\nLogical expression\n  "
00687             << m_l1GtUtilsLogicalExpression << std::endl;
00688 
00689     for (size_t iTrig = 0; iTrig < errorCodesProv.size(); ++iTrig) {
00690         if ((errorCodesProv[iTrig]).second != 0) {
00691             myCoutStream
00692                     << "\nError encountered when retrieving L1 results for trigger "
00693                     << (errorCodesProv[iTrig]).first << " (bit number "
00694                     << (expL1TriggersProv[iTrig]).tokenNumber << ")\n  for run "
00695                     << iEvent.run() << ", luminosity block "
00696                     << iEvent.luminosityBlock() << " with L1 menu \n  "
00697                     << m_l1GtUtils.l1TriggerMenu() << "\n  Error code: "
00698                     << (errorCodesProv[iTrig]).second << "\n" << std::endl;
00699 
00700         } else {
00701 
00702             myCoutStream << "\n" << (errorCodesProv[iTrig]).first
00703                     << " - bit number " << (expL1TriggersProv[iTrig]).tokenNumber
00704                     << std::endl;
00705 
00706             myCoutStream << "    decision before mask = "
00707                     << (decisionsBeforeMaskProv[iTrig]).second << std::endl;
00708 
00709             myCoutStream << "    decision after mask  = "
00710                     << (decisionsAfterMaskProv[iTrig]).second << std::endl;
00711 
00712             myCoutStream << "    prescale factor      = "
00713                     << (prescaleFactorsProv[iTrig]).second << std::endl;
00714 
00715             myCoutStream << "    trigger mask         = "
00716                     << (triggerMasksProv[iTrig]).second << std::endl;
00717 
00718             myCoutStream << "    error code           = "
00719                     << (errorCodesProv[iTrig]).second << std::endl;
00720 
00721         }
00722     }
00723 
00724     //
00725     // same methods as above, but with input tag given explicitly, allowing to select
00726     // the EDM products used to get the results
00727     
00728     
00729 
00730     myCoutStream
00731             << "\n******** Results found with input tags provided in the configuration file ******** \n"
00732             << "\n  L1GlobalTriggerRecord: " << m_l1GtRecordInputTag
00733             << "\n  L1GlobalTriggerReadoutRecord: "
00734             << m_l1GtDaqReadoutRecordInputTag << std::endl;
00735 
00736 
00737     // the following methods share the same error code, therefore one can check only once
00738     // the validity of the result
00739 
00740     iErrorCode = -1;
00741 
00742     bool decisionBeforeMaskAlgTechTrigITag = m_l1GtUtils.decisionBeforeMask(iEvent,
00743             m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
00744             m_nameAlgTechTrig, iErrorCode);
00745 
00746     bool decisionAfterMaskAlgTechTrigITag = m_l1GtUtils.decisionAfterMask(iEvent,
00747             m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
00748             m_nameAlgTechTrig, iErrorCode);
00749 
00750     bool decisionAlgTechTrigITag = m_l1GtUtils.decision(iEvent,
00751             m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
00752             m_nameAlgTechTrig, iErrorCode);
00753 
00754     int prescaleFactorAlgTechTrigITag = m_l1GtUtils.prescaleFactor(iEvent,
00755             m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
00756             m_nameAlgTechTrig, iErrorCode);
00757 
00758     int triggerMaskAlgTechTrigITag = m_l1GtUtils.triggerMask(iEvent,
00759             m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
00760             m_nameAlgTechTrig, iErrorCode);
00761 
00762     myCoutStream << "\n\nMethods:"
00763             << "\n  decisionBeforeMask(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, m_nameAlgTechTrig, iErrorCode)"
00764             << "\n  decisionAfterMask(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, m_nameAlgTechTrig, iErrorCode)"
00765             << "\n  decision(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, m_nameAlgTechTrig, iErrorCode)"
00766             << "\n  prescaleFactor(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, m_nameAlgTechTrig, iErrorCode)"
00767             << "\n  triggerMask(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, m_nameAlgTechTrig, iErrorCode)"
00768             << "\n\n"
00769             << std::endl;
00770 
00771 
00772     if (iErrorCode == 0) {
00773         myCoutStream << "\nDecision before trigger mask for "
00774                 << m_nameAlgTechTrig << ":   " << decisionBeforeMaskAlgTechTrigITag
00775                 << std::endl;
00776         myCoutStream << "Decision after trigger mask for " << m_nameAlgTechTrig
00777                 << ":    " << decisionAfterMaskAlgTechTrigITag << std::endl;
00778         myCoutStream << "Decision (after trigger mask) for "
00779                 << m_nameAlgTechTrig << ":  " << decisionAlgTechTrigITag
00780                 << std::endl;
00781 
00782         myCoutStream << "Prescale factor for " << m_nameAlgTechTrig
00783                 << ":                " << prescaleFactorAlgTechTrigITag
00784                 << std::endl;
00785 
00786         myCoutStream << "Trigger mask for " << m_nameAlgTechTrig
00787                 << ":                   " << triggerMaskAlgTechTrigITag
00788                 << std::endl;
00789 
00790     } else if (iErrorCode == 1) {
00791         myCoutStream << "\n" << m_nameAlgTechTrig
00792                 << " does not exist in the L1 menu "
00793                 << m_l1GtUtils.l1TriggerMenu() << "\n" << std::endl;
00794 
00795     } else {
00796         myCoutStream << "\nError: "
00797                 << "\n  An error was encountered when retrieving decision, mask and prescale factor for "
00798                 << m_nameAlgTechTrig << "\n  L1 Menu: "
00799                 << m_l1GtUtils.l1TriggerMenu() << "\n  Error code: "
00800                 << iErrorCode << std::endl;
00801 
00802     }
00803 
00804 
00805     // index of the actual prescale factor set, and the actual prescale
00806     // factor set for algorithm triggers
00807 
00808 
00809 
00810     trigCategory = L1GtUtils::AlgorithmTrigger;
00811 
00812     myCoutStream << "\nMethods:"
00813             << "\n  prescaleFactorSetIndex(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, trigCategory, iErrorCode)"
00814             << "\n  prescaleFactorSet(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, trigCategory,iErrorCode)\n"
00815             << std::endl;
00816 
00817     iErrorCode = -1;
00818     const int pfSetIndexAlgorithmTriggerITag = m_l1GtUtils.prescaleFactorSetIndex(
00819             iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
00820             trigCategory, iErrorCode);
00821 
00822     if (iErrorCode == 0) {
00823         myCoutStream
00824                 << "\nAlgorithm triggers: index for prescale factor set = "
00825                 << pfSetIndexAlgorithmTriggerITag << "\nfor run " << iEvent.run()
00826                 << ", luminosity block " << iEvent.luminosityBlock()
00827                 << ", with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00828                 << std::endl;
00829 
00830 
00831     } else {
00832         myCoutStream
00833                 << "\nError encountered when retrieving the prescale factor set index"
00834                 << "\n  for algorithm triggers, for run " << iEvent.run()
00835                 << ", luminosity block " << iEvent.luminosityBlock()
00836                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00837                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00838     }
00839 
00840     iErrorCode = -1;
00841     const std::vector<int>& pfSetAlgorithmTriggerITag =
00842             m_l1GtUtils.prescaleFactorSet(iEvent, m_l1GtRecordInputTag,
00843                     m_l1GtDaqReadoutRecordInputTag, trigCategory, iErrorCode);
00844 
00845     if (iErrorCode == 0) {
00846         myCoutStream << "\nAlgorithm triggers: prescale factor set index = "
00847                 << pfSetIndexAlgorithmTriggerITag << "\nfor run " << iEvent.run()
00848                 << ", luminosity block " << iEvent.luminosityBlock()
00849                 << ", with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00850                 << std::endl;
00851 
00852         int iBit = -1;
00853         for (std::vector<int>::const_iterator cItBit =
00854                 pfSetAlgorithmTriggerITag.begin(); cItBit
00855                 != pfSetAlgorithmTriggerITag.end(); ++cItBit) {
00856 
00857             iBit++;
00858             myCoutStream << "Bit number " << std::right << std::setw(4) << iBit
00859                     << ": prescale factor = " << (*cItBit) << std::endl;
00860 
00861         }
00862 
00863     } else {
00864         myCoutStream
00865                 << "\nError encountered when retrieving the prescale factor set "
00866                 << "\n  for algorithm triggers, for run " << iEvent.run()
00867                 << ", luminosity block " << iEvent.luminosityBlock()
00868                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00869                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00870     }
00871 
00872 
00873 
00874 
00875 
00876 
00877     // index of the actual prescale factor set, and the actual prescale
00878     // factor set for technical triggers
00879 
00880     trigCategory = L1GtUtils::TechnicalTrigger;
00881 
00882     myCoutStream << "\nMethods:"
00883             << "\n  prescaleFactorSetIndex(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, trigCategory, iErrorCode)"
00884             << "\n  prescaleFactorSet(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, trigCategory,iErrorCode)\n"
00885             << std::endl;
00886 
00887     iErrorCode = -1;
00888     const int pfSetIndexTechnicalTriggerITag = m_l1GtUtils.prescaleFactorSetIndex(
00889             iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
00890             trigCategory, iErrorCode);
00891 
00892     if (iErrorCode == 0) {
00893         myCoutStream
00894                 << "\nTechnical triggers: index for prescale factor set = "
00895                 << pfSetIndexTechnicalTriggerITag << "\nfor run " << iEvent.run()
00896                 << ", luminosity block " << iEvent.luminosityBlock()
00897                 << ", with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00898                 << std::endl;
00899 
00900     } else {
00901         myCoutStream
00902                 << "\nError encountered when retrieving the prescale factor set index"
00903                 << "\n  for technical triggers, for run " << iEvent.run()
00904                 << ", luminosity block " << iEvent.luminosityBlock()
00905                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00906                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00907     }
00908 
00909     iErrorCode = -1;
00910     const std::vector<int>& pfSetTechnicalTriggerITag =
00911             m_l1GtUtils.prescaleFactorSet(iEvent, m_l1GtRecordInputTag,
00912                     m_l1GtDaqReadoutRecordInputTag, trigCategory, iErrorCode);
00913 
00914     if (iErrorCode == 0) {
00915         myCoutStream << "\nTechnical triggers: prescale factor set index = "
00916                 << pfSetIndexTechnicalTriggerITag << "\nfor run " << iEvent.run()
00917                 << ", luminosity block " << iEvent.luminosityBlock()
00918                 << ", with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00919                 << std::endl;
00920 
00921         int iBit = -1;
00922         for (std::vector<int>::const_iterator cItBit =
00923                 pfSetTechnicalTriggerITag.begin(); cItBit
00924                 != pfSetTechnicalTriggerITag.end(); ++cItBit) {
00925 
00926             iBit++;
00927             myCoutStream << "Bit number " << std::right << std::setw(4) << iBit
00928                     << ": prescale factor = " << (*cItBit) << std::endl;
00929 
00930         }
00931 
00932     } else {
00933         myCoutStream
00934                 << "\nError encountered when retrieving the prescale factor set "
00935                 << "\n  for technical triggers, for run " << iEvent.run()
00936                 << ", luminosity block " << iEvent.luminosityBlock()
00937                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00938                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00939     }
00940 
00941 
00942     // results for logical expressions
00943 
00944     // errorCodes must be called before any other method is used
00945     const std::vector<std::pair<std::string, int> >& errorCodes =
00946             m_logicalExpressionL1Results.errorCodes(iEvent);
00947 
00948     const std::vector<L1GtLogicParser::OperandToken>& expL1Triggers =
00949             m_logicalExpressionL1Results.expL1Triggers();
00950 
00951 
00952     const std::vector<std::pair<std::string, bool> >& decisionsBeforeMask =
00953             m_logicalExpressionL1Results.decisionsBeforeMask();
00954     const std::vector<std::pair<std::string, bool> >& decisionsAfterMask =
00955             m_logicalExpressionL1Results.decisionsAfterMask();
00956     const std::vector<std::pair<std::string, int> >& prescaleFactors =
00957             m_logicalExpressionL1Results.prescaleFactors();
00958     const std::vector<std::pair<std::string, int> >& triggerMasks =
00959             m_logicalExpressionL1Results.triggerMasks();
00960 
00961     myCoutStream << std::endl;
00962     myCoutStream << "\nLogical expression\n  "
00963             << m_l1GtUtilsLogicalExpression << std::endl;
00964 
00965     for (size_t iTrig = 0; iTrig < errorCodes.size(); ++iTrig) {
00966         if ((errorCodes[iTrig]).second != 0) {
00967             myCoutStream
00968                     << "\nError encountered when retrieving L1 results for trigger "
00969                     << (errorCodes[iTrig]).first << " (bit number "
00970                     << (expL1Triggers[iTrig]).tokenNumber << ")\n  for run "
00971                     << iEvent.run() << ", luminosity block "
00972                     << iEvent.luminosityBlock() << " with L1 menu \n  "
00973                     << m_l1GtUtils.l1TriggerMenu() << "\n  Error code: "
00974                     << (errorCodes[iTrig]).second << "\n" << std::endl;
00975 
00976         } else {
00977 
00978             myCoutStream << "\n" << (errorCodes[iTrig]).first
00979                     << " - bit number " << (expL1Triggers[iTrig]).tokenNumber
00980                     << std::endl;
00981 
00982             myCoutStream << "    decision before mask = "
00983                     << (decisionsBeforeMask[iTrig]).second << std::endl;
00984 
00985             myCoutStream << "    decision after mask  = "
00986                     << (decisionsAfterMask[iTrig]).second << std::endl;
00987 
00988             myCoutStream << "    prescale factor      = "
00989                     << (prescaleFactors[iTrig]).second << std::endl;
00990 
00991             myCoutStream << "    trigger mask         = "
00992                     << (triggerMasks[iTrig]).second << std::endl;
00993 
00994             myCoutStream << "    error code           = "
00995                     << (errorCodes[iTrig]).second << std::endl;
00996 
00997         }
00998     }
00999 
01000 
01001     printOutput(myCoutStream);
01002 }
01003 
01004 void L1GtAnalyzer::analyzeL1GtUtilsMenuLite(const edm::Event& iEvent,
01005         const edm::EventSetup& evSetup) {
01006 
01007     LogDebug("L1GtAnalyzer")
01008             << "\n**** L1GtAnalyzer::analyzeL1GtUtilsMenuLite ****\n"
01009             << std::endl;
01010 
01011     // before accessing any result from L1GtUtils, one must retrieve and cache
01012     // the L1GtTriggerMenuLite product
01013     // add this call in the analyze / produce / filter method of your
01014     // analyzer / producer / filter
01015 
01016     bool useL1EventSetup = false;
01017     bool useL1GtTriggerMenuLite = true;
01018 
01019     if (m_l1GtTmLInputTagProv) {
01020 
01021         // input tag for L1GtTriggerMenuLite retrieved from provenance
01022         m_l1GtUtils.getL1GtRunCache(iEvent, evSetup, useL1EventSetup,
01023                 useL1GtTriggerMenuLite);
01024 
01025     } else {
01026 
01027         // input tag for L1GtTriggerMenuLite explicitly given
01028         m_l1GtUtils.getL1GtRunCache(iEvent, evSetup, useL1EventSetup,
01029                 useL1GtTriggerMenuLite, m_l1GtTmLInputTag);
01030     }
01031 
01032     analyzeL1GtUtilsCore(iEvent, evSetup);
01033 
01034 }
01035 
01036 void L1GtAnalyzer::analyzeL1GtUtilsEventSetup(const edm::Event& iEvent,
01037         const edm::EventSetup& evSetup) {
01038 
01039     LogDebug("L1GtAnalyzer")
01040             << "\n**** L1GtAnalyzer::analyzeL1GtUtilsEventSetup ****\n"
01041             << std::endl;
01042 
01043     // before accessing any result from L1GtUtils, one must retrieve and cache
01044     // the L1 trigger event setup
01045     // add this call in the analyze / produce / filter method of your
01046     // analyzer / producer / filter
01047 
01048     bool useL1EventSetup = true;
01049     bool useL1GtTriggerMenuLite = false;
01050 
01051     m_l1GtUtils.getL1GtRunCache(iEvent, evSetup, useL1EventSetup,
01052             useL1GtTriggerMenuLite);
01053 
01054     analyzeL1GtUtilsCore(iEvent, evSetup);
01055 
01056 }
01057 
01058 void L1GtAnalyzer::analyzeL1GtUtils(const edm::Event& iEvent,
01059         const edm::EventSetup& evSetup) {
01060 
01061     LogDebug("L1GtAnalyzer")
01062             << "\n**** L1GtAnalyzer::analyzeL1GtUtils: fall-through case ****\n"
01063             << std::endl;
01064 
01065     // before accessing any result from L1GtUtils, one must retrieve and cache
01066     // the L1 trigger event setup and the L1GtTriggerMenuLite product
01067     // add this call in the analyze / produce / filter method of your
01068     // analyzer / producer / filter
01069 
01070     bool useL1EventSetup = true;
01071     bool useL1GtTriggerMenuLite = true;
01072 
01073     if (m_l1GtTmLInputTagProv) {
01074 
01075         // input tag for L1GtTriggerMenuLite retrieved from provenance
01076         m_l1GtUtils.getL1GtRunCache(iEvent, evSetup, useL1EventSetup,
01077                 useL1GtTriggerMenuLite);
01078 
01079     } else {
01080 
01081         // input tag for L1GtTriggerMenuLite explicitly given
01082         m_l1GtUtils.getL1GtRunCache(iEvent, evSetup, useL1EventSetup,
01083                 useL1GtTriggerMenuLite, m_l1GtTmLInputTag);
01084 
01085     }
01086 
01087     analyzeL1GtUtilsCore(iEvent, evSetup);
01088 
01089 }
01090 
01091 void L1GtAnalyzer::analyzeTrigger(const edm::Event& iEvent,
01092         const edm::EventSetup& evSetup) {
01093 
01094     LogDebug("L1GtAnalyzer") << "\n**** L1GtAnalyzer::analyzeTrigger ****\n"
01095             << std::endl;
01096 
01097     // define an output stream to print into
01098     // it can then be directed to whatever log level is desired
01099     std::ostringstream myCoutStream;
01100 
01101     // print all the stuff if at LogDebug level
01102     myCoutStream << "\n\nFull analysis of an algorithm or technical trigger"
01103             << "\nMethod:  L1GtAnalyzer::analyzeTrigger" << "\nTrigger: "
01104             << m_nameAlgTechTrig << "\n" << std::endl;
01105 
01106     const unsigned int runNumber = iEvent.run();
01107     const unsigned int lsNumber = iEvent.luminosityBlock();
01108     const unsigned int eventNumber = iEvent.id().event();
01109 
01110     myCoutStream << "Run: " << runNumber << " LS: " << lsNumber << " Event: "
01111             << eventNumber << "\n\n" << std::endl;
01112 
01113 
01114     // before accessing any result from L1GtUtils, one must retrieve and cache
01115     // the L1 trigger event setup and the L1GtTriggerMenuLite product
01116     // add this call in the analyze / produce / filter method of your
01117     // analyzer / producer / filter
01118 
01119     bool useL1EventSetup = false;
01120     bool useL1GtTriggerMenuLite = false;
01121 
01122     switch (m_l1GtUtilsConfiguration) {
01123         case 0: {
01124             useL1EventSetup = false;
01125             useL1GtTriggerMenuLite = true;
01126 
01127         }
01128             break;
01129         case 100000: {
01130             useL1EventSetup = true;
01131             useL1GtTriggerMenuLite = true;
01132 
01133         }
01134             break;
01135         case 200000: {
01136             useL1EventSetup = true;
01137             useL1GtTriggerMenuLite = false;
01138 
01139         }
01140             break;
01141         default: {
01142             // do nothing
01143         }
01144             break;
01145     }
01146 
01147     if (m_l1GtTmLInputTagProv) {
01148 
01149         // input tag for L1GtTriggerMenuLite retrieved from provenance
01150         m_l1GtUtils.getL1GtRunCache(iEvent, evSetup, useL1EventSetup,
01151                 useL1GtTriggerMenuLite);
01152 
01153     } else {
01154 
01155         // input tag for L1GtTriggerMenuLite explicitly given
01156         m_l1GtUtils.getL1GtRunCache(iEvent, evSetup, useL1EventSetup,
01157                 useL1GtTriggerMenuLite, m_l1GtTmLInputTag);
01158 
01159     }
01160 
01161     // testing which environment is used
01162 
01163     int iErrorCode = -1;
01164     int l1ConfCode = -1;
01165 
01166     const bool l1Conf = m_l1GtUtils.availableL1Configuration(iErrorCode,
01167             l1ConfCode);
01168 
01169     if (l1Conf) {
01170         LogDebug("L1GtAnalyzer") << "\nL1 configuration code:" << l1ConfCode
01171                 << "\nValid L1 trigger configuration.\n" << std::endl;
01172 
01173         LogTrace("L1GtAnalyzer") << "\nL1 trigger menu name and implementation:"
01174                 << "\n" << m_l1GtUtils.l1TriggerMenu() << "\n"
01175                 << m_l1GtUtils.l1TriggerMenuImplementation() << "\n"
01176                 << std::endl;
01177 
01178     } else {
01179         myCoutStream << "\nL1 configuration code:" << l1ConfCode
01180                 << "\nNo valid L1 trigger configuration available."
01181                 << "\nCheck L1GtUtils wiki page for error code interpretation\n"
01182                 << std::endl;
01183         return;
01184     }
01185 
01186     // the following methods share the same error code, therefore one can check only once
01187     // the validity of the result
01188 
01189     iErrorCode = -1;
01190 
01191     bool decisionBeforeMaskAlgTechTrig = false;
01192     bool decisionAfterMaskAlgTechTrig = false;
01193     bool decisionAlgTechTrig = false;
01194     int prescaleFactorAlgTechTrig = -1;
01195     int triggerMaskAlgTechTrig = -1;
01196 
01197     if (m_l1GtRecordsInputTagProv) {
01198         decisionBeforeMaskAlgTechTrig = m_l1GtUtils.decisionBeforeMask(iEvent,
01199                 m_nameAlgTechTrig, iErrorCode);
01200 
01201         decisionAfterMaskAlgTechTrig = m_l1GtUtils.decisionAfterMask(iEvent,
01202                 m_nameAlgTechTrig, iErrorCode);
01203 
01204         decisionAlgTechTrig = m_l1GtUtils.decision(iEvent, m_nameAlgTechTrig,
01205                 iErrorCode);
01206 
01207         prescaleFactorAlgTechTrig = m_l1GtUtils.prescaleFactor(iEvent,
01208                 m_nameAlgTechTrig, iErrorCode);
01209 
01210         triggerMaskAlgTechTrig = m_l1GtUtils.triggerMask(iEvent,
01211                 m_nameAlgTechTrig, iErrorCode);
01212 
01213     } else {
01214         decisionBeforeMaskAlgTechTrig = m_l1GtUtils.decisionBeforeMask(iEvent,
01215                 m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
01216                 m_nameAlgTechTrig, iErrorCode);
01217 
01218         decisionAfterMaskAlgTechTrig = m_l1GtUtils.decisionAfterMask(iEvent,
01219                 m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
01220                 m_nameAlgTechTrig, iErrorCode);
01221 
01222         decisionAlgTechTrig = m_l1GtUtils.decision(iEvent,
01223                 m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
01224                 m_nameAlgTechTrig, iErrorCode);
01225 
01226         prescaleFactorAlgTechTrig = m_l1GtUtils.prescaleFactor(iEvent,
01227                 m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
01228                 m_nameAlgTechTrig, iErrorCode);
01229 
01230         triggerMaskAlgTechTrig = m_l1GtUtils.triggerMask(iEvent,
01231                 m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
01232                 m_nameAlgTechTrig, iErrorCode);
01233 
01234     }
01235 
01236     switch (iErrorCode) {
01237         case 0: {
01238             // do nothing here
01239         }
01240             break;
01241         case 1: {
01242             myCoutStream << "\n" << m_nameAlgTechTrig
01243                     << " does not exist in the L1 menu "
01244                     << m_l1GtUtils.l1TriggerMenu() << "\n" << std::endl;
01245             return;
01246         }
01247             break;
01248         default: {
01249             myCoutStream << "\nError: "
01250                     << "\n  An error was encountered when retrieving decision, mask and prescale factor for "
01251                     << m_nameAlgTechTrig << "\n  L1 Menu: "
01252                     << m_l1GtUtils.l1TriggerMenu() << "\n  Error code: "
01253                     << iErrorCode
01254                     << "\n  Check L1GtUtils wiki page for error code interpretation"
01255                     << std::endl;
01256         }
01257             break;
01258     }
01259 
01260     // retrieve L1Extra
01261     // for object maps, only BxInEvent = 0 (aka L1A bunch cross) is relevant
01262 
01263     m_retrieveL1Extra.retrieveL1ExtraObjects(iEvent, evSetup);
01264 
01265     // print all L1Extra collections from all BxInEvent
01266     myCoutStream << "\nL1Extra collections from all BxInEvent" << std::endl;
01267     m_retrieveL1Extra.printL1Extra(myCoutStream);
01268 
01269     int bxInEvent = 0;
01270     myCoutStream << "\nL1Extra collections from BxInEvent = 0 (BX for L1A)" << std::endl;
01271     m_retrieveL1Extra.printL1Extra(myCoutStream, bxInEvent);
01272 
01273     // retrieve L1GlobalTriggerObjectMapRecord and L1GlobalTriggerObjectMaps products
01274     // the module returns an error code only if both payloads are missing
01275 
01276     int iErrorRecord = 0;
01277 
01278     bool validRecord = false;
01279     bool gtObjectMapRecordValid = false;
01280 
01281     edm::Handle<L1GlobalTriggerObjectMaps> gtObjectMaps;
01282     iEvent.getByLabel(m_l1GtObjectMapsInputTag, gtObjectMaps);
01283 
01284     if (gtObjectMaps.isValid()) {
01285 
01286         validRecord = true;
01287 
01288     } else {
01289 
01290         iErrorRecord = 10;
01291         LogDebug("L1GtAnalyzer") << "\nL1GlobalTriggerObjectMaps with \n  "
01292                 << m_l1GtObjectMapsInputTag << "\nnot found in the event."
01293                 << std::endl;
01294     }
01295 
01296     edm::Handle<L1GlobalTriggerObjectMapRecord> gtObjectMapRecord;
01297     iEvent.getByLabel(m_l1GtObjectMapTag, gtObjectMapRecord);
01298 
01299     if (gtObjectMapRecord.isValid()) {
01300 
01301         gtObjectMapRecordValid = true;
01302         validRecord = true;
01303 
01304     } else {
01305 
01306         iErrorRecord = iErrorRecord + 100;
01307         LogDebug("L1GtAnalyzer") << "\nL1GlobalTriggerObjectMapRecord with \n  "
01308                 << m_l1GtObjectMapTag << "\nnot found in the event."
01309                 << std::endl;
01310 
01311     }
01312     
01313     //FIXME remove when validRecord and gtObjectMapRecordValid are used - avoid warning here :-)
01314     if (validRecord && gtObjectMapRecordValid) {
01315         // do nothing
01316     }
01317 
01318 
01319     // get the RPN vector
01320 
01321 
01322 //    int pfIndexTechTrig = -1;
01323 //    int pfIndexAlgoTrig = -1;
01324 //
01325 //    if (validRecord) {
01326 //        if (gtObjectMapRecordValid) {
01327 //
01328 //            pfIndexTechTrig
01329 //                    = (gtObjectMapRecord->gtFdlWord()).gtPrescaleFactorIndexTech();
01330 //            pfIndexAlgoTrig
01331 //                    = (gtObjectMapRecord->gtFdlWord()).gtPrescaleFactorIndexAlgo();
01332 //
01333 //        } else {
01334 //
01335 //            pfIndexTechTrig
01336 //                    = static_cast<int> (gtObjectMaps->gtPrescaleFactorIndexTech());
01337 //            pfIndexAlgoTrig
01338 //                    = static_cast<int> (gtObjectMaps->gtPrescaleFactorIndexAlgo());
01339 //
01340 //        }
01341 //
01342 //    } else {
01343 //
01344 //        LogDebug("L1GtAnalyzer") << "\nError: "
01345 //                << "\nNo valid L1GlobalTriggerRecord with \n  "
01346 //                << l1GtRecordInputTag << "\nfound in the event."
01347 //                << "\nNo valid L1GlobalTriggerReadoutRecord with \n  "
01348 //                << l1GtReadoutRecordInputTag << "\nfound in the event."
01349 //                << std::endl;
01350 //
01351 //        iError = l1ConfCode + iErrorRecord;
01352 //        return;
01353 //
01354 //    }
01355 
01356     // 
01357     myCoutStream << "\nResults for trigger " << m_nameAlgTechTrig
01358             << "\n  Trigger mask:          " << triggerMaskAlgTechTrig
01359             << "\n  Prescale factor:       " << prescaleFactorAlgTechTrig
01360             << "\n  Decision before mask:  " << decisionBeforeMaskAlgTechTrig
01361             << "\n  Decision after mask:   " << decisionAfterMaskAlgTechTrig
01362             << "\n  Decision (after mask): " << decisionAlgTechTrig << "\n"
01363             << std::endl;
01364     
01365 
01366     printOutput(myCoutStream);
01367 }
01368 
01369 // analyze: object map product
01370 void L1GtAnalyzer::analyzeObjectMap(const edm::Event& iEvent,
01371         const edm::EventSetup& evSetup) {
01372 
01373     LogDebug("L1GtAnalyzer")
01374             << "\n**** L1GtAnalyzer::analyzeObjectMap object map product ****\n"
01375             << std::endl;
01376 
01377     // define an output stream to print into
01378     // it can then be directed to whatever log level is desired
01379     std::ostringstream myCoutStream;
01380 
01381     // get a handle to the object map product
01382     // the product can come only from emulator - no hardware ObjectMapRecord
01383     edm::Handle<L1GlobalTriggerObjectMapRecord> gtObjectMapRecord;
01384     iEvent.getByLabel(m_l1GtObjectMapTag, gtObjectMapRecord);
01385 
01386     if (!gtObjectMapRecord.isValid()) {
01387         LogDebug("L1GtAnalyzer")
01388                 << "\nWarning: L1GlobalTriggerObjectMapRecord with input tag "
01389                 << m_l1GtObjectMapTag
01390                 << "\nrequested in configuration, but not found in the event."
01391                 << "\nExit the method.\n" << std::endl;
01392 
01393         return;
01394     }
01395 
01396     // get all object maps
01397     const std::vector<L1GlobalTriggerObjectMap>& objMapVec =
01398             gtObjectMapRecord->gtObjectMap();
01399 
01400     // print every object map via the implemented print
01401     for (std::vector<L1GlobalTriggerObjectMap>::const_iterator it =
01402             objMapVec.begin(); it != objMapVec.end(); ++it) {
01403 
01404         (*it).print(myCoutStream);
01405     }
01406 
01407     //
01408     const CombinationsInCond* comb = gtObjectMapRecord->getCombinationsInCond(
01409             m_nameAlgTechTrig, m_condName);
01410 
01411     // number of combinations
01412     if (comb != 0) {
01413         myCoutStream << "\n  Number of combinations passing ("
01414                 << m_nameAlgTechTrig << ", " << m_condName << "): "
01415                 << comb->size() << std::endl;
01416     } else {
01417         myCoutStream << "\n  No combination passes (" << m_nameAlgTechTrig
01418                 << ", " << m_condName << ") " << std::endl;
01419 
01420     }
01421 
01422     // condition result
01423     const bool result = gtObjectMapRecord->getConditionResult(
01424             m_nameAlgTechTrig, m_condName);
01425 
01426     myCoutStream << "\n  Result for condition " << m_condName
01427             << " in algorithm " << m_nameAlgTechTrig << ": " << result
01428             << std::endl;
01429 
01430     printOutput(myCoutStream);
01431 
01432 }
01433 
01434 // analyze: usage of L1GtTriggerMenuLite
01435 void L1GtAnalyzer::analyzeL1GtTriggerMenuLite(const edm::Event& iEvent,
01436         const edm::EventSetup& evSetup) {
01437 
01438     LogDebug("L1GtAnalyzer")
01439     << "\n**** L1GtAnalyzer::analyzeL1GtTriggerMenuLite ****\n"
01440     << std::endl;
01441 
01442     // define an output stream to print into
01443     // it can then be directed to whatever log level is desired
01444     std::ostringstream myCoutStream;
01445 
01446     // get Run Data - the same code can be run in beginRun, with getByLabel from edm::Run
01447     const edm::Run& iRun = iEvent.getRun();
01448 
01449 
01450     // get L1GtTriggerMenuLite
01451     edm::Handle<L1GtTriggerMenuLite> triggerMenuLite;
01452     iRun.getByLabel(m_l1GtTmLInputTag, triggerMenuLite);
01453 
01454     if (!triggerMenuLite.isValid()) {
01455 
01456         LogDebug("L1GtAnalyzer") << "\nL1GtTriggerMenuLite with \n  "
01457                 << m_l1GtTmLInputTag
01458                 << "\nrequested in configuration, but not found in the event."
01459                 << "\nExit the method.\n" << std::endl;
01460 
01461         return;
01462     }
01463 
01464     // print via supplied "print" function
01465     myCoutStream << (*triggerMenuLite);
01466 
01467     // test the individual methods
01468 
01469     const std::string& triggerMenuInterface =
01470             triggerMenuLite->gtTriggerMenuInterface();
01471     const std::string& triggerMenuName = triggerMenuLite->gtTriggerMenuName();
01472     const std::string& triggerMenuImplementation =
01473             triggerMenuLite->gtTriggerMenuImplementation();
01474     const std::string& scaleDbKey = triggerMenuLite->gtScaleDbKey();
01475 
01476     const L1GtTriggerMenuLite::L1TriggerMap& algorithmMap = triggerMenuLite->gtAlgorithmMap();
01477     const L1GtTriggerMenuLite::L1TriggerMap& algorithmAliasMap =
01478             triggerMenuLite->gtAlgorithmAliasMap();
01479     const L1GtTriggerMenuLite::L1TriggerMap& technicalTriggerMap =
01480             triggerMenuLite->gtTechnicalTriggerMap();
01481 
01482     const std::vector<unsigned int>& triggerMaskAlgoTrig =
01483             triggerMenuLite->gtTriggerMaskAlgoTrig();
01484     const std::vector<unsigned int>& triggerMaskTechTrig =
01485             triggerMenuLite->gtTriggerMaskTechTrig();
01486 
01487     const std::vector<std::vector<int> >& prescaleFactorsAlgoTrig =
01488             triggerMenuLite->gtPrescaleFactorsAlgoTrig();
01489     const std::vector<std::vector<int> >& prescaleFactorsTechTrig =
01490             triggerMenuLite->gtPrescaleFactorsTechTrig();
01491 
01492     // print in the same format as in L1GtTriggerMenuLite definition
01493 
01494     size_t nrDefinedAlgo = algorithmMap.size();
01495     size_t nrDefinedTech = technicalTriggerMap.size();
01496 
01497     // header for printing algorithms
01498 
01499     myCoutStream << "\n   ********** L1 Trigger Menu - printing   ********** \n"
01500     << "\nL1 Trigger Menu Interface: " << triggerMenuInterface
01501     << "\nL1 Trigger Menu Name:      " << triggerMenuName
01502     << "\nL1 Trigger Menu Implementation: " << triggerMenuImplementation
01503     << "\nAssociated Scale DB Key: " << scaleDbKey << "\n\n"
01504     << "\nL1 Physics Algorithms: " << nrDefinedAlgo << " algorithms defined." << "\n\n"
01505     << "Bit Number "
01506     << std::right << std::setw(35) << "Algorithm Name" << "  "
01507     << std::right << std::setw(35) << "Algorithm Alias" << "  "
01508     << std::right << std::setw(12) << "Trigger Mask";
01509     for (unsigned iSet = 0; iSet < prescaleFactorsAlgoTrig.size(); iSet++) {
01510         myCoutStream << std::right << std::setw(10) << "PF Set "
01511                << std::right << std::setw(2)  << iSet;
01512     }
01513 
01514     myCoutStream << std::endl;
01515 
01516 
01517     for (L1GtTriggerMenuLite::CItL1Trig itTrig = algorithmMap.begin(); itTrig
01518             != algorithmMap.end(); itTrig++) {
01519 
01520         const unsigned int bitNumber = itTrig->first;
01521         const std::string& aName = itTrig->second;
01522 
01523         std::string aAlias;
01524         L1GtTriggerMenuLite::CItL1Trig itAlias = algorithmAliasMap.find(bitNumber);
01525         if (itAlias != algorithmAliasMap.end()) {
01526             aAlias = itAlias->second;
01527         }
01528 
01529         myCoutStream << std::setw(6) << bitNumber << "     "
01530             << std::right << std::setw(35) << aName << "  "
01531             << std::right << std::setw(35) << aAlias << "  "
01532             << std::right << std::setw(12) << triggerMaskAlgoTrig[bitNumber];
01533         for (unsigned iSet = 0; iSet < prescaleFactorsAlgoTrig.size(); iSet++) {
01534             myCoutStream << std::right << std::setw(12) << prescaleFactorsAlgoTrig[iSet][bitNumber];
01535         }
01536 
01537         myCoutStream << std::endl;
01538     }
01539 
01540     myCoutStream << "\nL1 Technical Triggers: " << nrDefinedTech
01541             << " technical triggers defined." << "\n\n" << std::endl;
01542     if (nrDefinedTech) {
01543         myCoutStream
01544             << std::right << std::setw(6) << "Bit Number "
01545             << std::right << std::setw(45) << " Technical trigger name " << "  "
01546             << std::right << std::setw(12) << "Trigger Mask";
01547         for (unsigned iSet = 0; iSet < prescaleFactorsTechTrig.size(); iSet++) {
01548             myCoutStream << std::right << std::setw(10) << "PF Set "
01549                     << std::right << std::setw(2) << iSet;
01550         }
01551 
01552         myCoutStream << std::endl;
01553     }
01554 
01555     for (L1GtTriggerMenuLite::CItL1Trig itTrig = technicalTriggerMap.begin(); itTrig
01556             != technicalTriggerMap.end(); itTrig++) {
01557 
01558         unsigned int bitNumber = itTrig->first;
01559         std::string aName = itTrig->second;
01560 
01561         myCoutStream << std::setw(6) << bitNumber << "       "
01562         << std::right << std::setw(45) << aName
01563         << std::right << std::setw(12) << triggerMaskTechTrig[bitNumber];
01564         for (unsigned iSet = 0; iSet < prescaleFactorsTechTrig.size(); iSet++) {
01565             myCoutStream << std::right << std::setw(12) << prescaleFactorsTechTrig[iSet][bitNumber];
01566         }
01567 
01568         myCoutStream << std::endl;
01569 
01570     }
01571 
01572     // individual methods
01573 
01574     int errorCode = -1;
01575     const std::string* algorithmAlias = triggerMenuLite->gtAlgorithmAlias(
01576             m_bitNumber, errorCode);
01577     if (errorCode) {
01578         myCoutStream
01579                 << "\nError code retrieving alias for algorithm with bit number "
01580                 << m_bitNumber << ": " << errorCode << std::endl;
01581     } else {
01582         myCoutStream << "\nAlias for algorithm with bit number " << m_bitNumber
01583                 << ": " << (*algorithmAlias) << std::endl;
01584     }
01585 
01586     errorCode = -1;
01587     const std::string* algorithmName = triggerMenuLite->gtAlgorithmName(
01588             m_bitNumber, errorCode);
01589     if (errorCode) {
01590         myCoutStream
01591                 << "\nError code retrieving name for algorithm with bit number "
01592                 << m_bitNumber << ": " << errorCode << std::endl;
01593     } else {
01594         myCoutStream << "\nName for algorithm with bit number " << m_bitNumber
01595                 << ": " << (*algorithmName) << std::endl;
01596     }
01597 
01598     errorCode = -1;
01599     const std::string* techTrigName = triggerMenuLite->gtTechTrigName(
01600             m_bitNumber, errorCode);
01601     if (errorCode) {
01602         myCoutStream
01603                 << "\nError code retrieving name for technical trigger with bit number "
01604                 << m_bitNumber << ": " << errorCode << std::endl;
01605     } else {
01606         myCoutStream << "\nName for technical trigger with bit number "
01607                 << m_bitNumber << ": " << (*techTrigName) << std::endl;
01608     }
01609 
01610     errorCode = -1;
01611     const unsigned int bitNumber = triggerMenuLite->gtBitNumber(
01612             m_nameAlgTechTrig, errorCode);
01613     if (errorCode) {
01614         myCoutStream
01615                 << "\nError code retrieving bit number for algorithm/technical trigger "
01616                 << m_nameAlgTechTrig << ": " << errorCode << std::endl;
01617     } else {
01618         myCoutStream << "\nBit number for algorithm/technical trigger "
01619                 << m_nameAlgTechTrig << ": " << bitNumber << std::endl;
01620     }
01621 
01622     // not tested
01623     //errorCode = -1;
01624     //const bool triggerMenuLite->gtTriggerResult( m_nameAlgTechTrig,
01625     //        const std::vector<bool>& decWord,  errorCode);
01626 
01627 
01628     printOutput(myCoutStream);
01629 
01630 }
01631 
01632 // analyze: usage of ConditionsInEdm
01633 void L1GtAnalyzer::analyzeConditionsInRunBlock(const edm::Run& iRun,
01634         const edm::EventSetup& evSetup) {
01635 
01636     LogDebug("L1GtAnalyzer")
01637             << "\n**** L1GtAnalyzer::analyzeConditionsInRunBlock ****\n"
01638             << std::endl;
01639 
01640     // define an output stream to print into
01641     // it can then be directed to whatever log level is desired
01642     std::ostringstream myCoutStream;
01643 
01644     // get ConditionsInRunBlock
01645     edm::Handle<edm::ConditionsInRunBlock> condInRunBlock;
01646     iRun.getByLabel(m_condInEdmInputTag, condInRunBlock);
01647 
01648     if (!condInRunBlock.isValid()) {
01649 
01650         LogDebug("L1GtAnalyzer") << "\nConditionsInRunBlock with \n  "
01651                 << m_condInEdmInputTag
01652                 << "\nrequested in configuration, but not found in the event."
01653                 << "\nExit the method.\n" << std::endl;
01654 
01655         return;
01656     }
01657 
01658     const boost::uint16_t beamModeVal = condInRunBlock->beamMode;
01659     const boost::uint16_t beamMomentumVal = condInRunBlock->beamMomentum;
01660     const boost::uint32_t lhcFillNumberVal = condInRunBlock->lhcFillNumber;
01661 
01662     // print via supplied "print" function
01663     myCoutStream << "\nLHC quantities in run " << iRun.run()
01664             << "\n  Beam Mode = " << beamModeVal
01665             << "\n  Beam Momentum = " << beamMomentumVal << " GeV"
01666             << "\n  LHC Fill Number = " << lhcFillNumberVal
01667             << std::endl;
01668 
01669     printOutput(myCoutStream);
01670 
01671 }
01672 
01673 
01674 void L1GtAnalyzer::analyzeConditionsInLumiBlock(
01675         const edm::LuminosityBlock& iLumi, const edm::EventSetup& evSetup) {
01676     LogDebug("L1GtAnalyzer")
01677             << "\n**** L1GtAnalyzer::analyzeConditionsInLumiBlock ****\n"
01678             << std::endl;
01679 
01680     // define an output stream to print into
01681     // it can then be directed to whatever log level is desired
01682     std::ostringstream myCoutStream;
01683 
01684     // get ConditionsInLumiBlock
01685     edm::Handle<edm::ConditionsInLumiBlock> condInLumiBlock;
01686     iLumi.getByLabel(m_condInEdmInputTag, condInLumiBlock);
01687 
01688     if (!condInLumiBlock.isValid()) {
01689 
01690         LogDebug("L1GtAnalyzer") << "\nConditionsInLumiBlock with \n  "
01691                 << m_condInEdmInputTag
01692                 << "\nrequested in configuration, but not found in the event."
01693                 << "\nExit the method.\n" << std::endl;
01694 
01695         return;
01696     }
01697 
01698     const boost::uint32_t totalIntensityBeam1Val =
01699             condInLumiBlock->totalIntensityBeam1;
01700     const boost::uint32_t totalIntensityBeam2Val =
01701             condInLumiBlock->totalIntensityBeam2;
01702 
01703     myCoutStream << "\nLHC quantities in luminosity section "
01704 
01705             << iLumi.luminosityBlock() << " from run " << iLumi.run()
01706             << "\n  Total Intensity Beam 1 (Integer × 10E10 charges)  = "
01707             << totalIntensityBeam1Val
01708             << "\n  Total Intensity Beam 2 (Integer × 10E10 charges)  = "
01709             << totalIntensityBeam2Val << std::endl;
01710 
01711     printOutput(myCoutStream);
01712 
01713 }
01714 
01715 void L1GtAnalyzer::analyzeConditionsInEventBlock(const edm::Event& iEvent,
01716         const edm::EventSetup& evSetup) {
01717     // define an output stream to print into
01718     // it can then be directed to whatever log level is desired
01719     std::ostringstream myCoutStream;
01720 
01721     // get ConditionsInEventBlock
01722     edm::Handle<edm::ConditionsInEventBlock> condInEventBlock;
01723     iEvent.getByLabel(m_condInEdmInputTag, condInEventBlock);
01724 
01725     if (!condInEventBlock.isValid()) {
01726 
01727         LogDebug("L1GtAnalyzer") << "\nConditionsInEventBlock with \n  "
01728                 << m_condInEdmInputTag
01729                 << "\nrequested in configuration, but not found in the event."
01730                 << "\nExit the method.\n" << std::endl;
01731 
01732         return;
01733     }
01734 
01735     const boost::uint16_t bstMasterStatusVal =
01736             condInEventBlock->bstMasterStatus;
01737     const boost::uint32_t turnCountNumberVal =
01738             condInEventBlock->turnCountNumber;
01739 
01740     myCoutStream << "\nLHC quantities in event " << iEvent.id().event()
01741             << " from luminosity section " << iEvent.luminosityBlock()
01742             << " from run " << iEvent.run() << "\n  BST Master Status = "
01743             << bstMasterStatusVal << "\n  Turn count number = "
01744             << turnCountNumberVal << std::endl;
01745 
01746     printOutput(myCoutStream);
01747 
01748 }
01749 
01750 void L1GtAnalyzer::printOutput(std::ostringstream& myCout) {
01751 
01752     switch (m_printOutput) {
01753         case 0: {
01754 
01755             std::cout << myCout.str() << std::endl;
01756 
01757         }
01758 
01759             break;
01760         case 1: {
01761 
01762             LogTrace("L1GtAnalyzer") << myCout.str() << std::endl;
01763 
01764         }
01765             break;
01766 
01767         case 2: {
01768 
01769             edm::LogVerbatim("L1GtAnalyzer") << myCout.str() << std::endl;
01770 
01771         }
01772 
01773             break;
01774         case 3: {
01775 
01776             edm::LogInfo("L1GtAnalyzer") << myCout.str();
01777 
01778         }
01779 
01780             break;
01781         default: {
01782             std::cout << "\n\n  L1GtAnalyzer: Error - no print output = "
01783                     << m_printOutput
01784                     << " defined! \n  Check available values in the cfi file."
01785                     << "\n" << std::endl;
01786 
01787         }
01788             break;
01789     }
01790 
01791     myCout.str("");
01792     myCout.clear();
01793 
01794 }
01795 
01796 // analyze each event: event loop
01797 void L1GtAnalyzer::analyze(const edm::Event& iEvent,
01798         const edm::EventSetup& evSetup) {
01799 
01800     // analyze: decision and decision word
01801     //   bunch cross in event BxInEvent = 0 - L1Accept event
01802     if (m_analyzeDecisionReadoutRecordEnable) {
01803         analyzeDecisionReadoutRecord(iEvent, evSetup);
01804     }
01805 
01806     // analyze: decision for a given algorithm using L1GtUtils functions
01807     //   for tests, use only one of the following methods
01808 
01809     switch (m_l1GtUtilsConfiguration) {
01810         case 0: {
01811             if (m_analyzeL1GtUtilsMenuLiteEnable) {
01812                 analyzeL1GtUtilsMenuLite(iEvent, evSetup);
01813             }
01814 
01815             // full analysis of an algorithm or technical trigger
01816             if (m_analyzeTriggerEnable) {
01817                 analyzeTrigger(iEvent, evSetup);
01818             }
01819 
01820         }
01821             break;
01822         case 100000: {
01823             if (m_analyzeL1GtUtilsEnable) {
01824                 analyzeL1GtUtils(iEvent, evSetup);
01825             }
01826 
01827             // full analysis of an algorithm or technical trigger
01828             if (m_analyzeTriggerEnable) {
01829                 analyzeTrigger(iEvent, evSetup);
01830             }
01831 
01832         }
01833             break;
01834         case 200000: {
01835             if (m_analyzeL1GtUtilsEventSetupEnable) {
01836                 analyzeL1GtUtilsEventSetup(iEvent, evSetup);
01837             }
01838 
01839             // full analysis of an algorithm or technical trigger
01840             if (m_analyzeTriggerEnable) {
01841                 analyzeTrigger(iEvent, evSetup);
01842             }
01843 
01844         }
01845             break;
01846         default: {
01847             // do nothing
01848         }
01849             break;
01850     }
01851 
01852     // analyze: object map product
01853     if (m_analyzeObjectMapEnable) {
01854         analyzeObjectMap(iEvent, evSetup);
01855     }
01856 
01857     // analyze: L1GtTriggerMenuLite
01858     if (m_analyzeL1GtUtilsMenuLiteEnable) {
01859         analyzeL1GtTriggerMenuLite(iEvent, evSetup);
01860     }
01861 
01862     // analyze: usage of ConditionsInEdm
01863     if (m_analyzeConditionsInEventBlockEnable) {
01864         analyzeConditionsInEventBlock(iEvent, evSetup);
01865     }
01866 
01867 }
01868 
01869 // end section
01870 void L1GtAnalyzer::endLuminosityBlock(const edm::LuminosityBlock& iLumi,
01871         const edm::EventSetup& evSetup) {
01872 
01873     // empty
01874 
01875 }
01876 void L1GtAnalyzer::endRun(const edm::Run& iRun, const edm::EventSetup& evSetup) {
01877 
01878     // empty
01879 
01880 }
01881 
01882 // method called once each job just after ending the event loop
01883 void L1GtAnalyzer::endJob() {
01884 
01885     // empty
01886 
01887 }
01888