Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:19

0001 /**
0002  * \class L1GtPrescaleFactorsAndMasksTester
0003  * 
0004  * 
0005  * Description: test analyzer for L1 GT prescale factors and masks.  
0006  *
0007  * Implementation:
0008  *    <TODO: enter implementation details>
0009  *   
0010  * \author: Vasile Mihai Ghete - HEPHY Vienna
0011  * 
0012  *
0013  */
0014 
0015 // this class header
0016 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtPrescaleFactorsAndMasksTester.h"
0017 
0018 // system include files
0019 #include <iomanip>
0020 #include <iostream>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/Event.h"
0024 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0025 
0026 #include "FWCore/Framework/interface/EventSetup.h"
0027 #include "FWCore/Framework/interface/ESHandle.h"
0028 #include "FWCore/Framework/interface/ConsumesCollector.h"
0029 
0030 #include "CondFormats/L1TObjects/interface/L1GtPrescaleFactors.h"
0031 
0032 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsAlgoTrigRcd.h"
0033 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsTechTrigRcd.h"
0034 
0035 #include "CondFormats/L1TObjects/interface/L1GtTriggerMask.h"
0036 
0037 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskAlgoTrigRcd.h"
0038 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskTechTrigRcd.h"
0039 
0040 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskVetoAlgoTrigRcd.h"
0041 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskVetoTechTrigRcd.h"
0042 
0043 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0044 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0045 
0046 // forward declarations
0047 
0048 namespace {
0049   template <edm::Transition iTrans>
0050   L1GtPrescaleFactorsAndMasksTester::Tokens tokens(edm::ConsumesCollector iCC,
0051                                                    bool prescales,
0052                                                    bool masks,
0053                                                    bool vetoMasks) {
0054     L1GtPrescaleFactorsAndMasksTester::Tokens tokens;
0055     if (prescales) {
0056       tokens.m_l1GtPfAlgo = iCC.esConsumes<iTrans>();
0057       tokens.m_l1GtPfTech = iCC.esConsumes<iTrans>();
0058     }
0059     if (masks) {
0060       tokens.m_l1GtTmAlgo = iCC.esConsumes<iTrans>();
0061       tokens.m_l1GtTmTech = iCC.esConsumes<iTrans>();
0062     }
0063     if (vetoMasks) {
0064       tokens.m_l1GtTmVetoAlgo = iCC.esConsumes<iTrans>();
0065       tokens.m_l1GtTmVetoTech = iCC.esConsumes<iTrans>();
0066     }
0067     return tokens;
0068   }
0069 }  // namespace
0070 // constructor(s)
0071 L1GtPrescaleFactorsAndMasksTester::L1GtPrescaleFactorsAndMasksTester(const edm::ParameterSet& parSet)
0072     : m_testerPrescaleFactors(parSet.getParameter<bool>("TesterPrescaleFactors")),
0073       m_testerTriggerMask(parSet.getParameter<bool>("TesterTriggerMask")),
0074       m_testerTriggerVetoMask(parSet.getParameter<bool>("TesterTriggerVetoMask")),
0075       m_retrieveInBeginRun(parSet.getParameter<bool>("RetrieveInBeginRun")),
0076       m_retrieveInBeginLuminosityBlock(parSet.getParameter<bool>("RetrieveInBeginLuminosityBlock")),
0077       m_retrieveInAnalyze(parSet.getParameter<bool>("RetrieveInAnalyze")),
0078       m_printInBeginRun(parSet.getParameter<bool>("PrintInBeginRun")),
0079       m_printInBeginLuminosityBlock(parSet.getParameter<bool>("PrintInBeginLuminosityBlock")),
0080       m_printInAnalyze(parSet.getParameter<bool>("PrintInAnalyze")),
0081       m_printOutput(parSet.getUntrackedParameter<int>("PrintOutput", 3)),
0082       m_run(tokens<edm::Transition::BeginRun>(
0083           consumesCollector(), m_testerPrescaleFactors, m_testerTriggerMask, m_testerTriggerVetoMask)),
0084       m_lumi(tokens<edm::Transition::BeginLuminosityBlock>(
0085           consumesCollector(), m_testerPrescaleFactors, m_testerTriggerMask, m_testerTriggerVetoMask)),
0086       m_event(tokens<edm::Transition::Event>(
0087           consumesCollector(), m_testerPrescaleFactors, m_testerTriggerMask, m_testerTriggerVetoMask)) {
0088   // empty
0089 }
0090 
0091 // begin run
0092 void L1GtPrescaleFactorsAndMasksTester::beginRun(const edm::Run& iRun, const edm::EventSetup& evSetup) {
0093   if (m_retrieveInBeginRun) {
0094     retrieveL1EventSetup(evSetup, m_run);
0095   }
0096 
0097   if (m_printInBeginRun) {
0098     printL1EventSetup();
0099   }
0100 }
0101 
0102 // begin luminosity block
0103 void L1GtPrescaleFactorsAndMasksTester::beginLuminosityBlock(const edm::LuminosityBlock& iLumiBlock,
0104                                                              const edm::EventSetup& evSetup) {
0105   if (m_retrieveInBeginLuminosityBlock) {
0106     retrieveL1EventSetup(evSetup, m_lumi);
0107   }
0108 
0109   if (m_printInBeginLuminosityBlock) {
0110     printL1EventSetup();
0111   }
0112 }
0113 
0114 // loop over events
0115 void L1GtPrescaleFactorsAndMasksTester::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
0116   if (m_retrieveInAnalyze) {
0117     retrieveL1EventSetup(evSetup, m_event);
0118   }
0119 
0120   if (m_printInAnalyze) {
0121     printL1EventSetup();
0122   }
0123 }
0124 
0125 // end luminosity block
0126 void L1GtPrescaleFactorsAndMasksTester::endLuminosityBlock(const edm::LuminosityBlock& iLumiBlock,
0127                                                            const edm::EventSetup& evSetup) {}
0128 
0129 // end run
0130 void L1GtPrescaleFactorsAndMasksTester::endRun(const edm::Run& iRun, const edm::EventSetup& evSetup) {}
0131 
0132 void L1GtPrescaleFactorsAndMasksTester::retrieveL1EventSetup(const edm::EventSetup& evSetup, const Tokens& tokens) {
0133   if (m_testerPrescaleFactors) {
0134     // get / update the prescale factors from the EventSetup
0135 
0136     m_l1GtPfAlgo = &evSetup.getData(tokens.m_l1GtPfAlgo);
0137     m_l1GtPfTech = &evSetup.getData(tokens.m_l1GtPfTech);
0138   }
0139 
0140   if (m_testerTriggerMask) {
0141     // get / update the trigger mask from the EventSetup
0142 
0143     m_l1GtTmAlgo = &evSetup.getData(tokens.m_l1GtTmAlgo);
0144     m_l1GtTmTech = &evSetup.getData(tokens.m_l1GtTmTech);
0145   }
0146 
0147   if (m_testerTriggerVetoMask) {
0148     m_l1GtTmVetoAlgo = &evSetup.getData(tokens.m_l1GtTmVetoAlgo);
0149     m_l1GtTmVetoTech = &evSetup.getData(tokens.m_l1GtTmVetoTech);
0150   }
0151 }
0152 
0153 void L1GtPrescaleFactorsAndMasksTester::printL1EventSetup() {
0154   // define an output stream to print into
0155   // it can then be directed to whatever log level is desired
0156   std::ostringstream myCout;
0157 
0158   if (m_testerPrescaleFactors) {
0159     myCout << "\nL1 GT prescale factors for algorithm triggers" << std::endl;
0160     m_l1GtPfAlgo->print(myCout);
0161 
0162     myCout << "\nL1 GT prescale factors for technical triggers" << std::endl;
0163     m_l1GtPfTech->print(myCout);
0164   }
0165 
0166   //
0167   if (m_testerTriggerMask) {
0168     myCout << "\nL1 GT trigger masks for algorithm triggers" << std::endl;
0169     m_l1GtTmAlgo->print(myCout);
0170 
0171     myCout << "\nL1 GT trigger masks for technical triggers" << std::endl;
0172     m_l1GtTmTech->print(myCout);
0173   }
0174 
0175   //
0176   if (m_testerTriggerVetoMask) {
0177     myCout << "\nL1 GT trigger veto masks for algorithm triggers" << std::endl;
0178     m_l1GtTmVetoAlgo->print(myCout);
0179 
0180     myCout << "\nL1 GT trigger veto masks for technical triggers" << std::endl;
0181     m_l1GtTmVetoTech->print(myCout);
0182   }
0183 
0184   switch (m_printOutput) {
0185     case 0: {
0186       std::cout << myCout.str() << std::endl;
0187 
0188     }
0189 
0190     break;
0191     case 1: {
0192       LogTrace("L1GtPrescaleFactorsAndMasksTester") << myCout.str() << std::endl;
0193 
0194     } break;
0195 
0196     case 2: {
0197       edm::LogVerbatim("L1GtPrescaleFactorsAndMasksTester") << myCout.str() << std::endl;
0198 
0199     }
0200 
0201     break;
0202     case 3: {
0203       edm::LogInfo("L1GtPrescaleFactorsAndMasksTester") << myCout.str();
0204 
0205     }
0206 
0207     break;
0208     default: {
0209       myCout << "\n\n  L1GtPrescaleFactorsAndMasksTester: Error - no print output = " << m_printOutput
0210              << " defined! \n  Check available values in the cfi file."
0211              << "\n"
0212              << std::endl;
0213 
0214     } break;
0215   }
0216 }