CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/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 
00032 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMap.h"
00033 
00034 #include "DataFormats/L1GlobalTrigger/interface/L1GtTriggerMenuLite.h"
00035 
00036 #include "DataFormats/Common/interface/ConditionsInEdm.h"
00037 
00038 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
00039 
00040 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTrigger.h"
00041 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerPSB.h"
00042 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerGTL.h"
00043 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerFDL.h"
00044 
00045 #include "FWCore/Framework/interface/ESHandle.h"
00046 #include "FWCore/Framework/interface/LuminosityBlock.h"
00047 
00048 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
00049 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
00050 
00051 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00052 
00053 #include "L1Trigger/GlobalTriggerAnalyzer/interface/L1GtUtils.h"
00054 
00055 // constructor(s)
00056 L1GtAnalyzer::L1GtAnalyzer(const edm::ParameterSet& parSet) :
00057 
00058             // input tag for GT DAQ product
00059             m_l1GtDaqReadoutRecordInputTag(parSet.getParameter<edm::InputTag>(
00060                     "L1GtDaqReadoutRecordInputTag")),
00061 
00062             // input tag for GT lite product
00063             m_l1GtRecordInputTag(parSet.getParameter<edm::InputTag>(
00064                     "L1GtRecordInputTag")),
00065 
00066             // input tag for GT object map collection
00067             m_l1GtObjectMapTag(parSet.getParameter<edm::InputTag>(
00068                     "L1GtObjectMapTag")),
00069 
00070             // input tag for muon collection from GMT
00071             m_l1GmtInputTag(parSet.getParameter<edm::InputTag>(
00072                     "L1GmtInputTag")),
00073 
00074             // input tag for L1GtTriggerMenuLite
00075             m_l1GtTmLInputTag(parSet.getParameter<edm::InputTag> (
00076                     "L1GtTmLInputTag")),
00077 
00078             // input tag for ConditionInEdm products
00079             m_condInEdmInputTag(parSet.getParameter<edm::InputTag> (
00080                             "CondInEdmInputTag")),
00081 
00082             // an algorithm and a condition in that algorithm to test the object maps
00083             m_nameAlgTechTrig(parSet.getParameter<std::string> ("AlgorithmName")),
00084             m_condName(parSet.getParameter<std::string> ("ConditionName")),
00085             m_bitNumber(parSet.getParameter<unsigned int> ("BitNumber")),
00086 
00087             m_l1GtUtilsConfiguration(parSet.getParameter<unsigned int> ("L1GtUtilsConfiguration")),
00088             m_l1GtTmLInputTagProv(parSet.getParameter<bool> ("L1GtTmLInputTagProv")),
00089             m_l1GtUtilsConfigureBeginRun(parSet.getParameter<bool> ("L1GtUtilsConfigureBeginRun"))
00090 
00091 {
00092     LogDebug("L1GtAnalyzer")
00093             << "\n Input parameters for L1 GT test analyzer"
00094             << "\n   L1 GT DAQ product:            "
00095             << m_l1GtDaqReadoutRecordInputTag
00096             << "\n   L1 GT lite product:           "
00097             << m_l1GtRecordInputTag
00098             << "\n   L1 GT object map collection:  "
00099             << m_l1GtObjectMapTag
00100             << "\n   Muon collection from GMT:     "
00101             << m_l1GmtInputTag
00102             << "\n   L1 trigger menu lite product: "
00103             << m_l1GtTmLInputTag
00104             << "\n   Algorithm name or alias, technical trigger name:  " << m_nameAlgTechTrig
00105             << "\n   Condition, if a physics algorithm is requested:   " << m_condName
00106             << "\n   Bit number for an algorithm or technical trigger: " << m_bitNumber
00107             << "\n   Requested L1 trigger configuration: " << m_l1GtUtilsConfiguration
00108             << "\n   Retrieve input tag from provenance for L1 trigger menu lite in the L1GtUtils: "
00109             << m_l1GtTmLInputTagProv
00110             << "\n   Configure L1GtUtils in beginRun(...): "
00111             << m_l1GtUtilsConfigureBeginRun
00112             << " \n" << std::endl;
00113 
00114 }
00115 
00116 // destructor
00117 L1GtAnalyzer::~L1GtAnalyzer() {
00118 
00119     // empty
00120 
00121 }
00122 
00123 // method called once each job just before starting event loop
00124 void L1GtAnalyzer::beginJob()
00125 {
00126 
00127     // empty
00128 
00129 }
00130 
00131 void L1GtAnalyzer::beginRun(const edm::Run& iRun,
00132         const edm::EventSetup& evSetup) {
00133 
00134     analyzeConditionsInRunBlock(iRun, evSetup);
00135 
00136     // L1GtUtils
00137 
00138     if (m_l1GtUtilsConfigureBeginRun) {
00139 
00140         //   for tests, use only one of the following methods for m_l1GtUtilsConfiguration
00141 
00142         bool useL1EventSetup = false;
00143         bool useL1GtTriggerMenuLite = false;
00144 
00145         switch (m_l1GtUtilsConfiguration) {
00146             case 0: {
00147                 useL1EventSetup = false;
00148                 useL1GtTriggerMenuLite = true;
00149 
00150             }
00151                 break;
00152             case 100000: {
00153                 useL1EventSetup = true;
00154                 useL1GtTriggerMenuLite = true;
00155 
00156             }
00157                 break;
00158             case 200000: {
00159                 useL1EventSetup = true;
00160                 useL1GtTriggerMenuLite = false;
00161 
00162             }
00163                 break;
00164             default: {
00165                 // do nothing
00166             }
00167                 break;
00168         }
00169 
00170         if (m_l1GtTmLInputTagProv) {
00171             // L1GtTriggerMenuLite input tag from provenance
00172             m_l1GtUtils.getL1GtRunCache(iRun, evSetup, useL1EventSetup,
00173                     useL1GtTriggerMenuLite);
00174 
00175         } else {
00176 
00177             // L1GtTriggerMenuLite input tag given in configuration file
00178             m_l1GtUtils.getL1GtRunCache(iRun, evSetup, useL1EventSetup,
00179                     useL1GtTriggerMenuLite, m_l1GtTmLInputTag);
00180         }
00181 
00182     }
00183 
00184 }
00185 
00186 
00187 void L1GtAnalyzer::beginLuminosityBlock(const edm::LuminosityBlock& iLumi,
00188         const edm::EventSetup& evSetup) {
00189 
00190     analyzeConditionsInLumiBlock(iLumi, evSetup);
00191 
00192 }
00193 
00194 
00195 // member functions
00196 
00197 // analyze: decision and decision word
00198 //   bunch cross in event BxInEvent = 0 - L1Accept event
00199 void L1GtAnalyzer::analyzeDecisionReadoutRecord(const edm::Event& iEvent, const edm::EventSetup& evSetup)
00200 {
00201 
00202     LogDebug("L1GtAnalyzer")
00203     << "\n**** L1GtAnalyzer::analyzeDecisionReadoutRecord ****\n"
00204     << std::endl;
00205 
00206     // define an output stream to print into
00207     // it can then be directed to whatever log level is desired
00208     std::ostringstream myCoutStream;
00209 
00210     // get L1GlobalTriggerReadoutRecord
00211     edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecord;
00212     iEvent.getByLabel(m_l1GtDaqReadoutRecordInputTag, gtReadoutRecord);
00213 
00214     if (!gtReadoutRecord.isValid()) {
00215 
00216         LogDebug("L1GtAnalyzer") << "\nL1GlobalTriggerReadoutRecord with \n  "
00217                 << m_l1GtDaqReadoutRecordInputTag
00218                 << "\nrequested in configuration, but not found in the event."
00219                 << "\nExit the method.\n" << std::endl;
00220 
00221         return;
00222     }
00223 
00224     // get Global Trigger decision and the decision word
00225     bool gtDecision = gtReadoutRecord->decision();
00226     DecisionWord gtDecisionWord = gtReadoutRecord->decisionWord();
00227 
00228     // print Global Trigger decision and the decision word
00229     edm::LogVerbatim("L1GtAnalyzer")
00230     << "\n GlobalTrigger decision: " << gtDecision << std::endl;
00231 
00232     // print via supplied "print" function (
00233     gtReadoutRecord->printGtDecision(myCoutStream);
00234 
00235     // print technical trigger word via supplied "print" function
00236     gtReadoutRecord->printTechnicalTrigger(myCoutStream);
00237 
00238     LogDebug("L1GtAnalyzer") << myCoutStream.str() << std::endl;
00239 
00240     myCoutStream.str("");
00241     myCoutStream.clear();
00242 
00243 }
00244 
00245 // analyze: decision for a given algorithm via trigger menu
00246 void L1GtAnalyzer::analyzeDecisionLiteRecord(const edm::Event& iEvent,
00247         const edm::EventSetup& evSetup) {
00248 
00249     LogDebug("L1GtAnalyzer")
00250     << "\n**** L1GtAnalyzer::analyzeDecisionLiteRecord ****\n"
00251     << std::endl;
00252 
00253     edm::Handle<L1GlobalTriggerRecord> gtRecord;
00254     iEvent.getByLabel(m_l1GtRecordInputTag, gtRecord);
00255 
00256     if (!gtRecord.isValid()) {
00257 
00258         LogDebug("L1GtAnalyzer") << "\nL1GlobalTriggerRecord with \n  "
00259                 << m_l1GtRecordInputTag
00260                 << "\nrequested in configuration, but not found in the event."
00261                 << "\nExit the method.\n" << std::endl;
00262 
00263         return;
00264 
00265     }
00266 
00267     // FIXME - un-comment when new tag for CondFormats ready
00268 //    const DecisionWord gtDecisionWord = gtRecord->decisionWord();
00269 //
00270 //    edm::ESHandle<L1GtTriggerMenu> l1GtMenu;
00271 //    evSetup.get<L1GtTriggerMenuRcd>().get(l1GtMenu) ;
00272 //    const L1GtTriggerMenu* m_l1GtMenu = l1GtMenu.product();
00273 //
00274 
00275 //    bool trigResult = false;
00276 //
00277 //    if (m_l1GtMenu->gtTriggerResult(m_nameAlgTechTrig, gtDecisionWord,
00278 //            trigResult)) {
00279 //
00280 //        edm::LogVerbatim("L1GtAnalyzer") << "\nResult for trigger "
00281 //                << m_nameAlgTechTrig << ": " << trigResult << "\n" << std::endl;
00282 //    } else {
00283 //        edm::LogVerbatim("L1GtAnalyzer")
00284 //                << "\nError retrieving result for trigger " << m_nameAlgTechTrig
00285 //                << ": " << trigResult << "\n" << std::endl;
00286 //
00287 //    }
00288 
00289 }
00290 
00291 void L1GtAnalyzer::analyzeL1GtUtilsCore(const edm::Event& iEvent,
00292         const edm::EventSetup& evSetup) {
00293 
00294 
00295     // define an output stream to print into
00296     // it can then be directed to whatever log level is desired
00297     std::ostringstream myCoutStream;
00298 
00299 
00300     // example to access L1 trigger results using public methods from L1GtUtils
00301     // all must be called after one or both of the commands retrieving the L1 configuration
00302     //   m_l1GtUtils.retrieveL1EventSetup(evSetup);
00303     //   m_l1GtUtils.retrieveL1GtTriggerMenuLite(iEvent, m_l1GtTmLInputTag);
00304     //
00305     //
00306 
00307     // testing which environment is used
00308 
00309     int iErrorCode = -1;
00310     int l1ConfCode = -1;
00311 
00312     const bool l1Conf = m_l1GtUtils.availableL1Configuration(iErrorCode, l1ConfCode);
00313 
00314     myCoutStream << "\nL1 configuration code: \n"
00315             << "\n Legend: "
00316             << "\n      0 - Retrieve L1 trigger configuration from L1GtTriggerMenuLite only"
00317             << "\n  10000     L1GtTriggerMenuLite product is valid"
00318             << "\n  99999     L1GtTriggerMenuLite product not valid. Error."
00319             << "\n"
00320             << "\n 100000 - Fall through: try first L1GtTriggerMenuLite; if not valid,try event setup."
00321             << "\n 110000     L1GtTriggerMenuLite product is valid"
00322             << "\n 120000     L1GtTriggerMenuLite product not valid, event setup valid."
00323             << "\n 199999     L1GtTriggerMenuLite product not valid, event setup not valid. Error."
00324             << "\n"
00325             << "\n 200000 - Retrieve L1 trigger configuration from event setup only."
00326             << "\n 210000     Event setup valid."
00327             << "\n 299999     Event setup not valid. Error."
00328             << "\n"
00329             << "\n 300000 - No L1 trigger configuration requested to be retrieved. Error"
00330             << "\n            Must call before using L1GtUtils methods: "
00331             << "\n                getL1GtRunCache(const edm::Event& iEvent, const edm::EventSetup& evSetup,"
00332             << "\n                                const bool useL1EventSetup, const bool useL1GtTriggerMenuLite)"
00333             << "\n"
00334             << std::endl;
00335 
00336 
00337     if (l1Conf) {
00338         myCoutStream << "\nL1 configuration code:" << l1ConfCode
00339                 << "\nValid L1 trigger configuration." << std::endl;
00340 
00341         myCoutStream << "\nL1 trigger menu name and implementation:" << "\n"
00342                 << m_l1GtUtils.l1TriggerMenu() << "\n"
00343                 << m_l1GtUtils.l1TriggerMenuImplementation() << std::endl;
00344 
00345     } else {
00346         myCoutStream << "\nL1 configuration code:" << l1ConfCode
00347                 << "\nNo valid L1 trigger configuration available."
00348                 << "\nSee text above for error code interpretation"
00349                 << "\nNo return here, in order to test each method, protected against configuration error."
00350                 << std::endl;
00351     }
00352 
00353 
00354 
00355     myCoutStream
00356             << "\n******** Results found with input tags retrieved from provenance ******** \n"
00357             << std::endl;
00358 
00359     //
00360     // no input tags; for the appropriate EDM product, it will be found
00361     // from provenance
00362 
00363     // the following methods share the same error code, therefore one can check only once
00364     // the validity of the result
00365 
00366     iErrorCode = -1;
00367 
00368     bool decisionBeforeMaskAlgTechTrig = m_l1GtUtils.decisionBeforeMask(iEvent,
00369             m_nameAlgTechTrig, iErrorCode);
00370 
00371     bool decisionAfterMaskAlgTechTrig = m_l1GtUtils.decisionAfterMask(iEvent,
00372             m_nameAlgTechTrig, iErrorCode);
00373 
00374     bool decisionAlgTechTrig = m_l1GtUtils.decision(iEvent, m_nameAlgTechTrig,
00375             iErrorCode);
00376 
00377     int prescaleFactorAlgTechTrig = m_l1GtUtils.prescaleFactor(iEvent,
00378             m_nameAlgTechTrig, iErrorCode);
00379 
00380     int triggerMaskAlgTechTrig = m_l1GtUtils.triggerMask(iEvent,
00381             m_nameAlgTechTrig, iErrorCode);
00382 
00383     myCoutStream << "\n\nMethods:"
00384             << "\n  decisionBeforeMask(iEvent, m_nameAlgTechTrig, iErrorCode)"
00385             << "\n  decisionAfterMask(iEvent, m_nameAlgTechTrig, iErrorCode)"
00386             << "\n  decision(iEvent, m_nameAlgTechTrig, iErrorCode)"
00387             << "\n  prescaleFactor(iEvent, m_nameAlgTechTrig, iErrorCode)"
00388             << "\n  triggerMask(iEvent, m_nameAlgTechTrig, iErrorCode)"
00389             << "\n  triggerMask(m_nameAlgTechTrig,iErrorCode)"
00390             << "\n\n" << std::endl;
00391 
00392 
00393     if (iErrorCode == 0) {
00394         myCoutStream << "\nDecision before trigger mask for "
00395                 << m_nameAlgTechTrig << ":   " << decisionBeforeMaskAlgTechTrig
00396                 << std::endl;
00397         myCoutStream << "Decision after trigger mask for " << m_nameAlgTechTrig
00398                 << ":    " << decisionAfterMaskAlgTechTrig << std::endl;
00399         myCoutStream << "Decision (after trigger mask) for "
00400                 << m_nameAlgTechTrig << ":  " << decisionAlgTechTrig
00401                 << std::endl;
00402 
00403         myCoutStream << "Prescale factor for " << m_nameAlgTechTrig
00404                 << ":                " << prescaleFactorAlgTechTrig
00405                 << std::endl;
00406 
00407         myCoutStream << "Trigger mask for " << m_nameAlgTechTrig
00408                 << ":                   " << triggerMaskAlgTechTrig
00409                 << std::endl;
00410 
00411     } else if (iErrorCode == 1) {
00412         myCoutStream << "\n" << m_nameAlgTechTrig
00413                 << " does not exist in the L1 menu "
00414                 << m_l1GtUtils.l1TriggerMenu() << "\n" << std::endl;
00415 
00416     } else {
00417         myCoutStream << "\nError: "
00418                 << "\n  An error was encountered when retrieving decision, mask and prescale factor for "
00419                 << m_nameAlgTechTrig << "\n  L1 Menu: "
00420                 << m_l1GtUtils.l1TriggerMenu() << "\n  Error code: "
00421                 << iErrorCode << std::endl;
00422 
00423     }
00424 
00425     // another method to get the trigger mask (no common errorCode)
00426 
00427     iErrorCode = -1;
00428     triggerMaskAlgTechTrig = m_l1GtUtils.triggerMask(m_nameAlgTechTrig,
00429             iErrorCode);
00430 
00431     if (iErrorCode == 0) {
00432         myCoutStream << "\nTrigger mask for " << m_nameAlgTechTrig
00433                 << "(faster method):    " << triggerMaskAlgTechTrig
00434                 << std::endl;
00435 
00436     } else if (iErrorCode == 1) {
00437         myCoutStream << "\n" << m_nameAlgTechTrig
00438                 << " does not exist in the L1 menu "
00439                 << m_l1GtUtils.l1TriggerMenu() << "\n" << std::endl;
00440 
00441     } else {
00442         myCoutStream << "\nError: "
00443                 << "\n  An error was encountered when fast retrieving trigger mask for "
00444                 << m_nameAlgTechTrig << "\n  L1 Menu: "
00445                 << m_l1GtUtils.l1TriggerMenu() << "\n  Error code: "
00446                 << iErrorCode << std::endl;
00447 
00448     }
00449 
00450     // index of the actual prescale factor set, and the actual prescale
00451     // factor set for algorithm triggers
00452 
00453 
00454 
00455     L1GtUtils::TriggerCategory trigCategory = L1GtUtils::AlgorithmTrigger;
00456 
00457     myCoutStream << "\nMethods:"
00458             << "\n  prescaleFactorSetIndex(iEvent, trigCategory, iErrorCode)"
00459             << "\n  prescaleFactorSet(iEvent, trigCategory,iErrorCode)\n"
00460             << std::endl;
00461 
00462     iErrorCode = -1;
00463     const int pfSetIndexAlgorithmTrigger = m_l1GtUtils.prescaleFactorSetIndex(
00464             iEvent, trigCategory, iErrorCode);
00465 
00466     if (iErrorCode == 0) {
00467         myCoutStream
00468                 << "\nAlgorithm triggers: index for prescale factor set = "
00469                 << pfSetIndexAlgorithmTrigger << "\nfor run " << iEvent.run()
00470                 << ", luminosity block " << iEvent.luminosityBlock()
00471                 << ", with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00472                 << std::endl;
00473 
00474 
00475     } else {
00476         myCoutStream
00477                 << "\nError encountered when retrieving the prescale factor set index"
00478                 << "\n  for algorithm triggers, for run " << iEvent.run()
00479                 << ", luminosity block " << iEvent.luminosityBlock()
00480                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00481                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00482     }
00483 
00484     iErrorCode = -1;
00485     const std::vector<int>& pfSetAlgorithmTrigger =
00486             m_l1GtUtils.prescaleFactorSet(iEvent, trigCategory, iErrorCode);
00487 
00488     if (iErrorCode == 0) {
00489         myCoutStream << "\nAlgorithm triggers: prescale factor set index = "
00490                 << pfSetIndexAlgorithmTrigger << "\nfor run " << iEvent.run()
00491                 << ", luminosity block " << iEvent.luminosityBlock()
00492                 << ", with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00493                 << std::endl;
00494 
00495         int iBit = -1;
00496         for (std::vector<int>::const_iterator cItBit =
00497                 pfSetAlgorithmTrigger.begin(); cItBit
00498                 != pfSetAlgorithmTrigger.end(); ++cItBit) {
00499 
00500             iBit++;
00501             myCoutStream << "Bit number " << std::right << std::setw(4) << iBit
00502                     << ": prescale factor = " << (*cItBit) << std::endl;
00503 
00504         }
00505 
00506     } else {
00507         myCoutStream
00508                 << "\nError encountered when retrieving the prescale factor set "
00509                 << "\n  for algorithm triggers, for run " << iEvent.run()
00510                 << ", luminosity block " << iEvent.luminosityBlock()
00511                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00512                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00513     }
00514 
00515     // the actual trigger mask set for algorithm triggers
00516 
00517     myCoutStream << "\nMethod:"
00518             << "\n  triggerMaskSet(trigCategory, iErrorCode)"
00519             << std::endl;
00520 
00521     iErrorCode = -1;
00522     const std::vector<unsigned int>& tmSetAlgorithmTrigger =
00523             m_l1GtUtils.triggerMaskSet(trigCategory, iErrorCode);
00524 
00525     if (iErrorCode == 0) {
00526         myCoutStream << "\nAlgorithm triggers: trigger mask set for run "
00527                 << iEvent.run() << ", luminosity block "
00528                 << iEvent.luminosityBlock() << ", with L1 menu \n  "
00529                 << m_l1GtUtils.l1TriggerMenu() << "\n" << std::endl;
00530 
00531         int iBit = -1;
00532         for (std::vector<unsigned int>::const_iterator cItBit =
00533                 tmSetAlgorithmTrigger.begin(); cItBit
00534                 != tmSetAlgorithmTrigger.end(); ++cItBit) {
00535 
00536             iBit++;
00537             myCoutStream << "Bit number " << std::right << std::setw(4) << iBit
00538                     << ": trigger mask = " << (*cItBit) << std::endl;
00539 
00540         }
00541 
00542     } else {
00543         myCoutStream
00544                 << "\nError encountered when retrieving the trigger mask set "
00545                 << "\n  for algorithm triggers, for run " << iEvent.run()
00546                 << ", luminosity block " << iEvent.luminosityBlock()
00547                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00548                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00549     }
00550 
00551 
00552 
00553 
00554     // index of the actual prescale factor set, and the actual prescale
00555     // factor set for technical triggers
00556 
00557     trigCategory = L1GtUtils::TechnicalTrigger;
00558 
00559     myCoutStream << "\nMethods:"
00560             << "\n  prescaleFactorSetIndex(iEvent, trigCategory, iErrorCode)"
00561             << "\n  prescaleFactorSet(iEvent, trigCategory,iErrorCode)\n"
00562             << std::endl;
00563 
00564     iErrorCode = -1;
00565     const int pfSetIndexTechnicalTrigger = m_l1GtUtils.prescaleFactorSetIndex(
00566             iEvent, trigCategory, iErrorCode);
00567 
00568     if (iErrorCode == 0) {
00569         myCoutStream
00570                 << "\nTechnical triggers: index for prescale factor set = "
00571                 << pfSetIndexTechnicalTrigger << "\nfor run " << iEvent.run()
00572                 << ", luminosity block " << iEvent.luminosityBlock()
00573                 << ", with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00574                 << "\nMethod: prescaleFactorSetIndex(iEvent, trigCategory, iErrorCode)\n"
00575                 << std::endl;
00576 
00577     } else {
00578         myCoutStream
00579                 << "\nError encountered when retrieving the prescale factor set index"
00580                 << "\n  for technical triggers, for run " << iEvent.run()
00581                 << ", luminosity block " << iEvent.luminosityBlock()
00582                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00583                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00584     }
00585 
00586     iErrorCode = -1;
00587     const std::vector<int>& pfSetTechnicalTrigger =
00588             m_l1GtUtils.prescaleFactorSet(iEvent, trigCategory, iErrorCode);
00589 
00590     if (iErrorCode == 0) {
00591         myCoutStream << "\nTechnical triggers: prescale factor set index = "
00592                 << pfSetIndexTechnicalTrigger << "\nfor run " << iEvent.run()
00593                 << ", luminosity block " << iEvent.luminosityBlock()
00594                 << ", with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00595                 << "\nMethod: prescaleFactorSet(iEvent, trigCategory,iErrorCode)\n"
00596                 << std::endl;
00597 
00598         int iBit = -1;
00599         for (std::vector<int>::const_iterator cItBit =
00600                 pfSetTechnicalTrigger.begin(); cItBit
00601                 != pfSetTechnicalTrigger.end(); ++cItBit) {
00602 
00603             iBit++;
00604             myCoutStream << "Bit number " << std::right << std::setw(4) << iBit
00605                     << ": prescale factor = " << (*cItBit) << std::endl;
00606 
00607         }
00608 
00609     } else {
00610         myCoutStream
00611                 << "\nError encountered when retrieving the prescale factor set "
00612                 << "\n  for technical triggers, for run " << iEvent.run()
00613                 << ", luminosity block " << iEvent.luminosityBlock()
00614                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00615                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00616     }
00617 
00618     // the actual trigger mask set for technical triggers
00619 
00620     myCoutStream << "\nMethod:"
00621             << "\n  triggerMaskSet(trigCategory, iErrorCode)"
00622             << std::endl;
00623 
00624     iErrorCode = -1;
00625     const std::vector<unsigned int>& tmSetTechnicalTrigger =
00626             m_l1GtUtils.triggerMaskSet(trigCategory, iErrorCode);
00627 
00628     if (iErrorCode == 0) {
00629         myCoutStream << "\nTechnical triggers: trigger mask set for run "
00630                 << iEvent.run() << ", luminosity block "
00631                 << iEvent.luminosityBlock() << ", with L1 menu \n  "
00632                 << m_l1GtUtils.l1TriggerMenu() << "\n" << std::endl;
00633 
00634         int iBit = -1;
00635         for (std::vector<unsigned int>::const_iterator cItBit =
00636                 tmSetTechnicalTrigger.begin(); cItBit
00637                 != tmSetTechnicalTrigger.end(); ++cItBit) {
00638 
00639             iBit++;
00640             myCoutStream << "Bit number " << std::right << std::setw(4) << iBit
00641                     << ": trigger mask = " << (*cItBit) << std::endl;
00642 
00643         }
00644 
00645     } else {
00646         myCoutStream
00647                 << "\nError encountered when retrieving the trigger mask set "
00648                 << "\n  for technical triggers, for run " << iEvent.run()
00649                 << ", luminosity block " << iEvent.luminosityBlock()
00650                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00651                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00652     }
00653 
00654 
00655 
00656 
00657 
00658     //
00659     // same methods as above, but with input tag given explicitly, allowing to select
00660     // the EDM products used to get the results
00661 
00662     myCoutStream
00663             << "\n******** Results found with input tags provided in the configuration file ******** \n"
00664             << "\n  L1GlobalTriggerRecord: " << m_l1GtRecordInputTag
00665             << "\n  L1GlobalTriggerReadoutRecord: "
00666             << m_l1GtDaqReadoutRecordInputTag << std::endl;
00667 
00668 
00669     // the following methods share the same error code, therefore one can check only once
00670     // the validity of the result
00671 
00672     iErrorCode = -1;
00673 
00674     bool decisionBeforeMaskAlgTechTrigITag = m_l1GtUtils.decisionBeforeMask(iEvent,
00675             m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
00676             m_nameAlgTechTrig, iErrorCode);
00677 
00678     bool decisionAfterMaskAlgTechTrigITag = m_l1GtUtils.decisionAfterMask(iEvent,
00679             m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
00680             m_nameAlgTechTrig, iErrorCode);
00681 
00682     bool decisionAlgTechTrigITag = m_l1GtUtils.decision(iEvent,
00683             m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
00684             m_nameAlgTechTrig, iErrorCode);
00685 
00686     int prescaleFactorAlgTechTrigITag = m_l1GtUtils.prescaleFactor(iEvent,
00687             m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
00688             m_nameAlgTechTrig, iErrorCode);
00689 
00690     int triggerMaskAlgTechTrigITag = m_l1GtUtils.triggerMask(iEvent,
00691             m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
00692             m_nameAlgTechTrig, iErrorCode);
00693 
00694     myCoutStream << "\n\nMethods:"
00695             << "\n  decisionBeforeMask(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, m_nameAlgTechTrig, iErrorCode)"
00696             << "\n  decisionAfterMask(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, m_nameAlgTechTrig, iErrorCode)"
00697             << "\n  decision(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, m_nameAlgTechTrig, iErrorCode)"
00698             << "\n  prescaleFactor(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, m_nameAlgTechTrig, iErrorCode)"
00699             << "\n  triggerMask(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, m_nameAlgTechTrig, iErrorCode)"
00700             << "\n\n"
00701             << std::endl;
00702 
00703 
00704     if (iErrorCode == 0) {
00705         myCoutStream << "\nDecision before trigger mask for "
00706                 << m_nameAlgTechTrig << ":   " << decisionBeforeMaskAlgTechTrigITag
00707                 << std::endl;
00708         myCoutStream << "Decision after trigger mask for " << m_nameAlgTechTrig
00709                 << ":    " << decisionAfterMaskAlgTechTrigITag << std::endl;
00710         myCoutStream << "Decision (after trigger mask) for "
00711                 << m_nameAlgTechTrig << ":  " << decisionAlgTechTrigITag
00712                 << std::endl;
00713 
00714         myCoutStream << "Prescale factor for " << m_nameAlgTechTrig
00715                 << ":                " << prescaleFactorAlgTechTrigITag
00716                 << std::endl;
00717 
00718         myCoutStream << "Trigger mask for " << m_nameAlgTechTrig
00719                 << ":                   " << triggerMaskAlgTechTrigITag
00720                 << std::endl;
00721 
00722     } else if (iErrorCode == 1) {
00723         myCoutStream << "\n" << m_nameAlgTechTrig
00724                 << " does not exist in the L1 menu "
00725                 << m_l1GtUtils.l1TriggerMenu() << "\n" << std::endl;
00726 
00727     } else {
00728         myCoutStream << "\nError: "
00729                 << "\n  An error was encountered when retrieving decision, mask and prescale factor for "
00730                 << m_nameAlgTechTrig << "\n  L1 Menu: "
00731                 << m_l1GtUtils.l1TriggerMenu() << "\n  Error code: "
00732                 << iErrorCode << std::endl;
00733 
00734     }
00735 
00736 
00737     // index of the actual prescale factor set, and the actual prescale
00738     // factor set for algorithm triggers
00739 
00740 
00741 
00742     trigCategory = L1GtUtils::AlgorithmTrigger;
00743 
00744     myCoutStream << "\nMethods:"
00745             << "\n  prescaleFactorSetIndex(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, trigCategory, iErrorCode)"
00746             << "\n  prescaleFactorSet(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, trigCategory,iErrorCode)\n"
00747             << std::endl;
00748 
00749     iErrorCode = -1;
00750     const int pfSetIndexAlgorithmTriggerITag = m_l1GtUtils.prescaleFactorSetIndex(
00751             iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
00752             trigCategory, iErrorCode);
00753 
00754     if (iErrorCode == 0) {
00755         myCoutStream
00756                 << "\nAlgorithm triggers: index for prescale factor set = "
00757                 << pfSetIndexAlgorithmTriggerITag << "\nfor run " << iEvent.run()
00758                 << ", luminosity block " << iEvent.luminosityBlock()
00759                 << ", with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00760                 << std::endl;
00761 
00762 
00763     } else {
00764         myCoutStream
00765                 << "\nError encountered when retrieving the prescale factor set index"
00766                 << "\n  for algorithm triggers, for run " << iEvent.run()
00767                 << ", luminosity block " << iEvent.luminosityBlock()
00768                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00769                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00770     }
00771 
00772     iErrorCode = -1;
00773     const std::vector<int>& pfSetAlgorithmTriggerITag =
00774             m_l1GtUtils.prescaleFactorSet(iEvent, m_l1GtRecordInputTag,
00775                     m_l1GtDaqReadoutRecordInputTag, trigCategory, iErrorCode);
00776 
00777     if (iErrorCode == 0) {
00778         myCoutStream << "\nAlgorithm triggers: prescale factor set index = "
00779                 << pfSetIndexAlgorithmTriggerITag << "\nfor run " << iEvent.run()
00780                 << ", luminosity block " << iEvent.luminosityBlock()
00781                 << ", with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00782                 << std::endl;
00783 
00784         int iBit = -1;
00785         for (std::vector<int>::const_iterator cItBit =
00786                 pfSetAlgorithmTriggerITag.begin(); cItBit
00787                 != pfSetAlgorithmTriggerITag.end(); ++cItBit) {
00788 
00789             iBit++;
00790             myCoutStream << "Bit number " << std::right << std::setw(4) << iBit
00791                     << ": prescale factor = " << (*cItBit) << std::endl;
00792 
00793         }
00794 
00795     } else {
00796         myCoutStream
00797                 << "\nError encountered when retrieving the prescale factor set "
00798                 << "\n  for algorithm triggers, for run " << iEvent.run()
00799                 << ", luminosity block " << iEvent.luminosityBlock()
00800                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00801                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00802     }
00803 
00804 
00805 
00806 
00807 
00808 
00809     // index of the actual prescale factor set, and the actual prescale
00810     // factor set for technical triggers
00811 
00812     trigCategory = L1GtUtils::TechnicalTrigger;
00813 
00814     myCoutStream << "\nMethods:"
00815             << "\n  prescaleFactorSetIndex(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, trigCategory, iErrorCode)"
00816             << "\n  prescaleFactorSet(iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag, trigCategory,iErrorCode)\n"
00817             << std::endl;
00818 
00819     iErrorCode = -1;
00820     const int pfSetIndexTechnicalTriggerITag = m_l1GtUtils.prescaleFactorSetIndex(
00821             iEvent, m_l1GtRecordInputTag, m_l1GtDaqReadoutRecordInputTag,
00822             trigCategory, iErrorCode);
00823 
00824     if (iErrorCode == 0) {
00825         myCoutStream
00826                 << "\nTechnical triggers: index for prescale factor set = "
00827                 << pfSetIndexTechnicalTriggerITag << "\nfor run " << iEvent.run()
00828                 << ", luminosity block " << iEvent.luminosityBlock()
00829                 << ", with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00830                 << std::endl;
00831 
00832     } else {
00833         myCoutStream
00834                 << "\nError encountered when retrieving the prescale factor set index"
00835                 << "\n  for technical triggers, for run " << iEvent.run()
00836                 << ", luminosity block " << iEvent.luminosityBlock()
00837                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00838                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00839     }
00840 
00841     iErrorCode = -1;
00842     const std::vector<int>& pfSetTechnicalTriggerITag =
00843             m_l1GtUtils.prescaleFactorSet(iEvent, m_l1GtRecordInputTag,
00844                     m_l1GtDaqReadoutRecordInputTag, trigCategory, iErrorCode);
00845 
00846     if (iErrorCode == 0) {
00847         myCoutStream << "\nTechnical triggers: prescale factor set index = "
00848                 << pfSetIndexTechnicalTriggerITag << "\nfor run " << iEvent.run()
00849                 << ", luminosity block " << iEvent.luminosityBlock()
00850                 << ", with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00851                 << std::endl;
00852 
00853         int iBit = -1;
00854         for (std::vector<int>::const_iterator cItBit =
00855                 pfSetTechnicalTriggerITag.begin(); cItBit
00856                 != pfSetTechnicalTriggerITag.end(); ++cItBit) {
00857 
00858             iBit++;
00859             myCoutStream << "Bit number " << std::right << std::setw(4) << iBit
00860                     << ": prescale factor = " << (*cItBit) << std::endl;
00861 
00862         }
00863 
00864     } else {
00865         myCoutStream
00866                 << "\nError encountered when retrieving the prescale factor set "
00867                 << "\n  for technical triggers, for run " << iEvent.run()
00868                 << ", luminosity block " << iEvent.luminosityBlock()
00869                 << " with L1 menu \n  " << m_l1GtUtils.l1TriggerMenu()
00870                 << "\n  Error code: " << iErrorCode << "\n" << std::endl;
00871     }
00872 
00873 
00874 
00875     //
00876     // dump the stream in some Log tag (LogDebug here)
00877 
00878 
00879     LogDebug("L1GtAnalyzer") << myCoutStream.str() << std::endl;
00880 
00881     myCoutStream.str("");
00882     myCoutStream.clear();
00883 
00884 }
00885 
00886 void L1GtAnalyzer::analyzeL1GtUtilsMenuLite(const edm::Event& iEvent,
00887         const edm::EventSetup& evSetup) {
00888 
00889     LogDebug("L1GtAnalyzer")
00890             << "\n**** L1GtAnalyzer::analyzeL1GtUtilsMenuLite ****\n"
00891             << std::endl;
00892 
00893     // before accessing any result from L1GtUtils, one must retrieve and cache
00894     // the L1GtTriggerMenuLite product
00895     // add this call in the analyze / produce / filter method of your
00896     // analyzer / producer / filter
00897 
00898     bool useL1EventSetup = false;
00899     bool useL1GtTriggerMenuLite = true;
00900 
00901     if (m_l1GtTmLInputTagProv) {
00902 
00903         // input tag for L1GtTriggerMenuLite retrieved from provenance
00904         m_l1GtUtils.getL1GtRunCache(iEvent, evSetup, useL1EventSetup,
00905                 useL1GtTriggerMenuLite);
00906 
00907     } else {
00908 
00909         // input tag for L1GtTriggerMenuLite explicitly given
00910         m_l1GtUtils.getL1GtRunCache(iEvent, evSetup, useL1EventSetup,
00911                 useL1GtTriggerMenuLite, m_l1GtTmLInputTag);
00912     }
00913 
00914     analyzeL1GtUtilsCore(iEvent, evSetup);
00915 
00916 }
00917 
00918 void L1GtAnalyzer::analyzeL1GtUtilsEventSetup(const edm::Event& iEvent,
00919         const edm::EventSetup& evSetup) {
00920 
00921     LogDebug("L1GtAnalyzer")
00922             << "\n**** L1GtAnalyzer::analyzeL1GtUtilsEventSetup ****\n"
00923             << std::endl;
00924 
00925     // before accessing any result from L1GtUtils, one must retrieve and cache
00926     // the L1 trigger event setup
00927     // add this call in the analyze / produce / filter method of your
00928     // analyzer / producer / filter
00929 
00930     bool useL1EventSetup = true;
00931     bool useL1GtTriggerMenuLite = false;
00932 
00933     m_l1GtUtils.getL1GtRunCache(iEvent, evSetup, useL1EventSetup,
00934             useL1GtTriggerMenuLite);
00935 
00936     analyzeL1GtUtilsCore(iEvent, evSetup);
00937 
00938 }
00939 
00940 void L1GtAnalyzer::analyzeL1GtUtils(const edm::Event& iEvent,
00941         const edm::EventSetup& evSetup) {
00942 
00943     LogDebug("L1GtAnalyzer")
00944             << "\n**** L1GtAnalyzer::analyzeL1GtUtils: fall-through case ****\n"
00945             << std::endl;
00946 
00947     // before accessing any result from L1GtUtils, one must retrieve and cache
00948     // the L1 trigger event setup and the L1GtTriggerMenuLite product
00949     // add this call in the analyze / produce / filter method of your
00950     // analyzer / producer / filter
00951 
00952     bool useL1EventSetup = true;
00953     bool useL1GtTriggerMenuLite = true;
00954 
00955     if (m_l1GtTmLInputTagProv) {
00956 
00957         // input tag for L1GtTriggerMenuLite retrieved from provenance
00958         m_l1GtUtils.getL1GtRunCache(iEvent, evSetup, useL1EventSetup,
00959                 useL1GtTriggerMenuLite);
00960 
00961     } else {
00962 
00963         // input tag for L1GtTriggerMenuLite explicitly given
00964         m_l1GtUtils.getL1GtRunCache(iEvent, evSetup, useL1EventSetup,
00965                 useL1GtTriggerMenuLite, m_l1GtTmLInputTag);
00966 
00967     }
00968 
00969     analyzeL1GtUtilsCore(iEvent, evSetup);
00970 
00971 }
00972 
00973 // analyze: object map product
00974 void L1GtAnalyzer::analyzeObjectMap(const edm::Event& iEvent,
00975         const edm::EventSetup& evSetup) {
00976 
00977     LogDebug("L1GtAnalyzer")
00978             << "\n**** L1GtAnalyzer::analyzeObjectMap object map product ****\n"
00979             << std::endl;
00980 
00981     // define an output stream to print into
00982     // it can then be directed to whatever log level is desired
00983     std::ostringstream myCoutStream;
00984 
00985     // get a handle to the object map product
00986     // the product can come only from emulator - no hardware ObjectMapRecord
00987     edm::Handle<L1GlobalTriggerObjectMapRecord> gtObjectMapRecord;
00988     iEvent.getByLabel(m_l1GtObjectMapTag, gtObjectMapRecord);
00989 
00990     if (!gtObjectMapRecord.isValid()) {
00991         LogDebug("L1GtAnalyzer")
00992                 << "\nWarning: L1GlobalTriggerObjectMapRecord with input tag "
00993                 << m_l1GtObjectMapTag
00994                 << "\nrequested in configuration, but not found in the event."
00995                 << "\nExit the method.\n" << std::endl;
00996 
00997         return;
00998     }
00999 
01000     // get all object maps
01001     const std::vector<L1GlobalTriggerObjectMap>& objMapVec =
01002             gtObjectMapRecord->gtObjectMap();
01003 
01004     // print every object map via the implemented print
01005     for (std::vector<L1GlobalTriggerObjectMap>::const_iterator it =
01006             objMapVec.begin(); it != objMapVec.end(); ++it) {
01007 
01008         (*it).print(myCoutStream);
01009     }
01010 
01011     //
01012     const CombinationsInCond* comb = gtObjectMapRecord->getCombinationsInCond(
01013             m_nameAlgTechTrig, m_condName);
01014 
01015     // number of combinations
01016     if (comb != 0) {
01017         myCoutStream << "\n  Number of combinations passing ("
01018                 << m_nameAlgTechTrig << ", " << m_condName << "): "
01019                 << comb->size() << std::endl;
01020     } else {
01021         myCoutStream << "\n  No combination passes (" << m_nameAlgTechTrig
01022                 << ", " << m_condName << ") " << std::endl;
01023 
01024     }
01025 
01026     // condition result
01027     const bool result = gtObjectMapRecord->getConditionResult(
01028             m_nameAlgTechTrig, m_condName);
01029 
01030     myCoutStream << "\n  Result for condition " << m_condName
01031             << " in algorithm " << m_nameAlgTechTrig << ": " << result
01032             << std::endl;
01033 
01034     // print all the stuff if at LogDebug level
01035     LogDebug("L1GtAnalyzer")
01036             << "Test gtObjectMapRecord in L1GlobalTrigger \n\n"
01037             << myCoutStream.str() << "\n\n" << std::endl;
01038     myCoutStream.str("");
01039     myCoutStream.clear();
01040 
01041 }
01042 
01043 // analyze: usage of L1GtTriggerMenuLite
01044 void L1GtAnalyzer::analyzeL1GtTriggerMenuLite(const edm::Event& iEvent,
01045         const edm::EventSetup& evSetup) {
01046 
01047     LogDebug("L1GtAnalyzer")
01048     << "\n**** L1GtAnalyzer::analyzeL1GtTriggerMenuLite ****\n"
01049     << std::endl;
01050 
01051     // define an output stream to print into
01052     // it can then be directed to whatever log level is desired
01053     std::ostringstream myCoutStream;
01054 
01055     // get Run Data - the same code can be run in beginRun, with getByLabel from edm::Run
01056     const edm::Run& iRun = iEvent.getRun();
01057 
01058 
01059     // get L1GtTriggerMenuLite
01060     edm::Handle<L1GtTriggerMenuLite> triggerMenuLite;
01061     iRun.getByLabel(m_l1GtTmLInputTag, triggerMenuLite);
01062 
01063     if (!triggerMenuLite.isValid()) {
01064 
01065         LogDebug("L1GtAnalyzer") << "\nL1GtTriggerMenuLite with \n  "
01066                 << m_l1GtTmLInputTag
01067                 << "\nrequested in configuration, but not found in the event."
01068                 << "\nExit the method.\n" << std::endl;
01069 
01070         return;
01071     }
01072 
01073     // print via supplied "print" function
01074     myCoutStream << (*triggerMenuLite);
01075 
01076     // test the individual methods
01077 
01078     const std::string& triggerMenuInterface =
01079             triggerMenuLite->gtTriggerMenuInterface();
01080     const std::string& triggerMenuName = triggerMenuLite->gtTriggerMenuName();
01081     const std::string& triggerMenuImplementation =
01082             triggerMenuLite->gtTriggerMenuImplementation();
01083     const std::string& scaleDbKey = triggerMenuLite->gtScaleDbKey();
01084 
01085     const L1GtTriggerMenuLite::L1TriggerMap& algorithmMap = triggerMenuLite->gtAlgorithmMap();
01086     const L1GtTriggerMenuLite::L1TriggerMap& algorithmAliasMap =
01087             triggerMenuLite->gtAlgorithmAliasMap();
01088     const L1GtTriggerMenuLite::L1TriggerMap& technicalTriggerMap =
01089             triggerMenuLite->gtTechnicalTriggerMap();
01090 
01091     const std::vector<unsigned int>& triggerMaskAlgoTrig =
01092             triggerMenuLite->gtTriggerMaskAlgoTrig();
01093     const std::vector<unsigned int>& triggerMaskTechTrig =
01094             triggerMenuLite->gtTriggerMaskTechTrig();
01095 
01096     const std::vector<std::vector<int> >& prescaleFactorsAlgoTrig =
01097             triggerMenuLite->gtPrescaleFactorsAlgoTrig();
01098     const std::vector<std::vector<int> >& prescaleFactorsTechTrig =
01099             triggerMenuLite->gtPrescaleFactorsTechTrig();
01100 
01101     // print in the same format as in L1GtTriggerMenuLite definition
01102 
01103     size_t nrDefinedAlgo = algorithmMap.size();
01104     size_t nrDefinedTech = technicalTriggerMap.size();
01105 
01106     // header for printing algorithms
01107 
01108     myCoutStream << "\n   ********** L1 Trigger Menu - printing   ********** \n"
01109     << "\nL1 Trigger Menu Interface: " << triggerMenuInterface
01110     << "\nL1 Trigger Menu Name:      " << triggerMenuName
01111     << "\nL1 Trigger Menu Implementation: " << triggerMenuImplementation
01112     << "\nAssociated Scale DB Key: " << scaleDbKey << "\n\n"
01113     << "\nL1 Physics Algorithms: " << nrDefinedAlgo << " algorithms defined." << "\n\n"
01114     << "Bit Number "
01115     << std::right << std::setw(35) << "Algorithm Name" << "  "
01116     << std::right << std::setw(35) << "Algorithm Alias" << "  "
01117     << std::right << std::setw(12) << "Trigger Mask";
01118     for (unsigned iSet = 0; iSet < prescaleFactorsAlgoTrig.size(); iSet++) {
01119         myCoutStream << std::right << std::setw(10) << "PF Set "
01120                << std::right << std::setw(2)  << iSet;
01121     }
01122 
01123     myCoutStream << std::endl;
01124 
01125 
01126     for (L1GtTriggerMenuLite::CItL1Trig itTrig = algorithmMap.begin(); itTrig
01127             != algorithmMap.end(); itTrig++) {
01128 
01129         const unsigned int bitNumber = itTrig->first;
01130         const std::string& aName = itTrig->second;
01131 
01132         std::string aAlias;
01133         L1GtTriggerMenuLite::CItL1Trig itAlias = algorithmAliasMap.find(bitNumber);
01134         if (itAlias != algorithmAliasMap.end()) {
01135             aAlias = itAlias->second;
01136         }
01137 
01138         myCoutStream << std::setw(6) << bitNumber << "     "
01139             << std::right << std::setw(35) << aName << "  "
01140             << std::right << std::setw(35) << aAlias << "  "
01141             << std::right << std::setw(12) << triggerMaskAlgoTrig[bitNumber];
01142         for (unsigned iSet = 0; iSet < prescaleFactorsAlgoTrig.size(); iSet++) {
01143             myCoutStream << std::right << std::setw(12) << prescaleFactorsAlgoTrig[iSet][bitNumber];
01144         }
01145 
01146         myCoutStream << std::endl;
01147     }
01148 
01149     myCoutStream << "\nL1 Technical Triggers: " << nrDefinedTech
01150             << " technical triggers defined." << "\n\n" << std::endl;
01151     if (nrDefinedTech) {
01152         myCoutStream
01153             << std::right << std::setw(6) << "Bit Number "
01154             << std::right << std::setw(45) << " Technical trigger name " << "  "
01155             << std::right << std::setw(12) << "Trigger Mask";
01156         for (unsigned iSet = 0; iSet < prescaleFactorsTechTrig.size(); iSet++) {
01157             myCoutStream << std::right << std::setw(10) << "PF Set "
01158                     << std::right << std::setw(2) << iSet;
01159         }
01160 
01161         myCoutStream << std::endl;
01162     }
01163 
01164     for (L1GtTriggerMenuLite::CItL1Trig itTrig = technicalTriggerMap.begin(); itTrig
01165             != technicalTriggerMap.end(); itTrig++) {
01166 
01167         unsigned int bitNumber = itTrig->first;
01168         std::string aName = itTrig->second;
01169 
01170         myCoutStream << std::setw(6) << bitNumber << "       "
01171         << std::right << std::setw(45) << aName
01172         << std::right << std::setw(12) << triggerMaskTechTrig[bitNumber];
01173         for (unsigned iSet = 0; iSet < prescaleFactorsTechTrig.size(); iSet++) {
01174             myCoutStream << std::right << std::setw(12) << prescaleFactorsTechTrig[iSet][bitNumber];
01175         }
01176 
01177         myCoutStream << std::endl;
01178 
01179     }
01180 
01181     // individual methods
01182 
01183     int errorCode = -1;
01184     const std::string* algorithmAlias = triggerMenuLite->gtAlgorithmAlias(
01185             m_bitNumber, errorCode);
01186     if (errorCode) {
01187         myCoutStream
01188                 << "\nError code retrieving alias for algorithm with bit number "
01189                 << m_bitNumber << ": " << errorCode << std::endl;
01190     } else {
01191         myCoutStream << "\nAlias for algorithm with bit number " << m_bitNumber
01192                 << ": " << (*algorithmAlias) << std::endl;
01193     }
01194 
01195     errorCode = -1;
01196     const std::string* algorithmName = triggerMenuLite->gtAlgorithmName(
01197             m_bitNumber, errorCode);
01198     if (errorCode) {
01199         myCoutStream
01200                 << "\nError code retrieving name for algorithm with bit number "
01201                 << m_bitNumber << ": " << errorCode << std::endl;
01202     } else {
01203         myCoutStream << "\nName for algorithm with bit number " << m_bitNumber
01204                 << ": " << (*algorithmName) << std::endl;
01205     }
01206 
01207     errorCode = -1;
01208     const std::string* techTrigName = triggerMenuLite->gtTechTrigName(
01209             m_bitNumber, errorCode);
01210     if (errorCode) {
01211         myCoutStream
01212                 << "\nError code retrieving name for technical trigger with bit number "
01213                 << m_bitNumber << ": " << errorCode << std::endl;
01214     } else {
01215         myCoutStream << "\nName for technical trigger with bit number "
01216                 << m_bitNumber << ": " << (*techTrigName) << std::endl;
01217     }
01218 
01219     errorCode = -1;
01220     const unsigned int bitNumber = triggerMenuLite->gtBitNumber(
01221             m_nameAlgTechTrig, errorCode);
01222     if (errorCode) {
01223         myCoutStream
01224                 << "\nError code retrieving bit number for algorithm/technical trigger "
01225                 << m_nameAlgTechTrig << ": " << errorCode << std::endl;
01226     } else {
01227         myCoutStream << "\nBit number for algorithm/technical trigger "
01228                 << m_nameAlgTechTrig << ": " << bitNumber << std::endl;
01229     }
01230 
01231     // not tested
01232     //errorCode = -1;
01233     //const bool triggerMenuLite->gtTriggerResult( m_nameAlgTechTrig,
01234     //        const std::vector<bool>& decWord,  errorCode);
01235 
01236 
01237     LogDebug("L1GtAnalyzer") << myCoutStream.str() << std::endl;
01238 
01239     myCoutStream.str("");
01240     myCoutStream.clear();
01241 
01242 }
01243 
01244 // analyze: usage of ConditionsInEdm
01245 void L1GtAnalyzer::analyzeConditionsInRunBlock(const edm::Run& iRun,
01246         const edm::EventSetup& evSetup) {
01247 
01248     LogDebug("L1GtAnalyzer")
01249             << "\n**** L1GtAnalyzer::analyzeConditionsInRunBlock ****\n"
01250             << std::endl;
01251 
01252     // define an output stream to print into
01253     // it can then be directed to whatever log level is desired
01254     std::ostringstream myCoutStream;
01255 
01256     // get ConditionsInRunBlock
01257     edm::Handle<edm::ConditionsInRunBlock> condInRunBlock;
01258     iRun.getByLabel(m_condInEdmInputTag, condInRunBlock);
01259 
01260     if (!condInRunBlock.isValid()) {
01261 
01262         LogDebug("L1GtAnalyzer") << "\nConditionsInRunBlock with \n  "
01263                 << m_condInEdmInputTag
01264                 << "\nrequested in configuration, but not found in the event."
01265                 << "\nExit the method.\n" << std::endl;
01266 
01267         return;
01268     }
01269 
01270     const boost::uint16_t beamModeVal = condInRunBlock->beamMode;
01271     const boost::uint16_t beamMomentumVal = condInRunBlock->beamMomentum;
01272     const boost::uint32_t lhcFillNumberVal = condInRunBlock->lhcFillNumber;
01273 
01274     // print via supplied "print" function
01275     myCoutStream << "\nLHC quantities in run " << iRun.run()
01276             << "\n  Beam Mode = " << beamModeVal
01277             << "\n  Beam Momentum = " << beamMomentumVal << " GeV"
01278             << "\n  LHC Fill Number = " << lhcFillNumberVal
01279             << std::endl;
01280 
01281     LogDebug("L1GtAnalyzer") << myCoutStream.str() << std::endl;
01282 
01283     myCoutStream.str("");
01284     myCoutStream.clear();
01285 
01286 }
01287 
01288 
01289 void L1GtAnalyzer::analyzeConditionsInLumiBlock(
01290         const edm::LuminosityBlock& iLumi, const edm::EventSetup& evSetup) {
01291     LogDebug("L1GtAnalyzer")
01292             << "\n**** L1GtAnalyzer::analyzeConditionsInLumiBlock ****\n"
01293             << std::endl;
01294 
01295     // define an output stream to print into
01296     // it can then be directed to whatever log level is desired
01297     std::ostringstream myCoutStream;
01298 
01299     // get ConditionsInLumiBlock
01300     edm::Handle<edm::ConditionsInLumiBlock> condInLumiBlock;
01301     iLumi.getByLabel(m_condInEdmInputTag, condInLumiBlock);
01302 
01303     if (!condInLumiBlock.isValid()) {
01304 
01305         LogDebug("L1GtAnalyzer") << "\nConditionsInLumiBlock with \n  "
01306                 << m_condInEdmInputTag
01307                 << "\nrequested in configuration, but not found in the event."
01308                 << "\nExit the method.\n" << std::endl;
01309 
01310         return;
01311     }
01312 
01313     const boost::uint32_t totalIntensityBeam1Val =
01314             condInLumiBlock->totalIntensityBeam1;
01315     const boost::uint32_t totalIntensityBeam2Val =
01316             condInLumiBlock->totalIntensityBeam2;
01317 
01318     myCoutStream << "\nLHC quantities in luminosity section "
01319 
01320             << iLumi.luminosityBlock() << " from run " << iLumi.run()
01321             << "\n  Total Intensity Beam 1 (Integer × 10E10 charges)  = "
01322             << totalIntensityBeam1Val
01323             << "\n  Total Intensity Beam 2 (Integer × 10E10 charges)  = "
01324             << totalIntensityBeam2Val << std::endl;
01325 
01326     LogDebug("L1GtAnalyzer") << myCoutStream.str() << std::endl;
01327 
01328     myCoutStream.str("");
01329     myCoutStream.clear();
01330 
01331 }
01332 
01333 void L1GtAnalyzer::analyzeConditionsInEventBlock(const edm::Event& iEvent,
01334         const edm::EventSetup& evSetup) {
01335     // define an output stream to print into
01336     // it can then be directed to whatever log level is desired
01337     std::ostringstream myCoutStream;
01338 
01339     // get ConditionsInEventBlock
01340     edm::Handle<edm::ConditionsInEventBlock> condInEventBlock;
01341     iEvent.getByLabel(m_condInEdmInputTag, condInEventBlock);
01342 
01343     if (!condInEventBlock.isValid()) {
01344 
01345         LogDebug("L1GtAnalyzer") << "\nConditionsInEventBlock with \n  "
01346                 << m_condInEdmInputTag
01347                 << "\nrequested in configuration, but not found in the event."
01348                 << "\nExit the method.\n" << std::endl;
01349 
01350         return;
01351     }
01352 
01353     const boost::uint16_t bstMasterStatusVal =
01354             condInEventBlock->bstMasterStatus;
01355     const boost::uint32_t turnCountNumberVal =
01356             condInEventBlock->turnCountNumber;
01357 
01358     myCoutStream << "\nLHC quantities in event " << iEvent.id().event()
01359             << " from luminosity section " << iEvent.luminosityBlock()
01360             << " from run " << iEvent.run() << "\n  BST Master Status = "
01361             << bstMasterStatusVal << "\n  Turn count number = "
01362             << turnCountNumberVal << std::endl;
01363 
01364     LogDebug("L1GtAnalyzer") << myCoutStream.str() << std::endl;
01365 
01366     myCoutStream.str("");
01367     myCoutStream.clear();
01368 
01369 }
01370 
01371 // analyze each event: event loop
01372 void L1GtAnalyzer::analyze(const edm::Event& iEvent,
01373         const edm::EventSetup& evSetup) {
01374 
01375     // analyze: usage of ConditionsInEdm
01376     analyzeConditionsInEventBlock(iEvent, evSetup);
01377 
01378     // analyze: decision and decision word
01379     //   bunch cross in event BxInEvent = 0 - L1Accept event
01380     analyzeDecisionReadoutRecord(iEvent, evSetup);
01381 
01382     // analyze: decision for a given algorithm via trigger menu
01383     analyzeDecisionLiteRecord(iEvent, evSetup);
01384 
01385     // analyze: decision for a given algorithm using L1GtUtils functions
01386     //   for tests, use only one of the following methods
01387 
01388     switch (m_l1GtUtilsConfiguration) {
01389         case 0: {
01390             analyzeL1GtUtilsMenuLite(iEvent, evSetup);
01391 
01392         }
01393             break;
01394         case 100000: {
01395             analyzeL1GtUtils(iEvent, evSetup);
01396 
01397         }
01398             break;
01399         case 200000: {
01400             analyzeL1GtUtilsEventSetup(iEvent, evSetup);
01401 
01402         }
01403             break;
01404         default: {
01405             // do nothing
01406         }
01407             break;
01408     }
01409 
01410 
01411     // analyze: object map product
01412     analyzeObjectMap(iEvent, evSetup);
01413 
01414     // analyze: L1GtTriggerMenuLite
01415     analyzeL1GtTriggerMenuLite(iEvent, evSetup);
01416 
01417 }
01418 
01419 // end section
01420 void L1GtAnalyzer::endLuminosityBlock(const edm::LuminosityBlock& iLumi,
01421         const edm::EventSetup& evSetup) {
01422 
01423     // empty
01424 
01425 }
01426 void L1GtAnalyzer::endRun(const edm::Run& iRun, const edm::EventSetup& evSetup) {
01427 
01428     // empty
01429 
01430 }
01431 
01432 // method called once each job just after ending the event loop
01433 void L1GtAnalyzer::endJob() {
01434 
01435     // empty
01436 
01437 }
01438