Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-13 01:32:14

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