CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/L1TriggerConfig/L1GtConfigProducers/src/L1GtPrescaleFactorsAndMasksTester.cc

Go to the documentation of this file.
00001 
00017 // this class header
00018 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtPrescaleFactorsAndMasksTester.h"
00019 
00020 // system include files
00021 #include <iomanip>
00022 
00023 // user include files
00024 //   base class
00025 #include "FWCore/Framework/interface/EDAnalyzer.h"
00026 
00027 #include "FWCore/Framework/interface/Event.h"
00028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00029 
00030 #include "FWCore/Framework/interface/EventSetup.h"
00031 #include "FWCore/Framework/interface/ESHandle.h"
00032 
00033 #include "CondFormats/L1TObjects/interface/L1GtPrescaleFactors.h"
00034 
00035 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsAlgoTrigRcd.h"
00036 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsTechTrigRcd.h"
00037 
00038 #include "CondFormats/L1TObjects/interface/L1GtTriggerMask.h"
00039 
00040 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskAlgoTrigRcd.h"
00041 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskTechTrigRcd.h"
00042 
00043 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskVetoAlgoTrigRcd.h"
00044 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskVetoTechTrigRcd.h"
00045 
00046 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00047 #include "FWCore/MessageLogger/interface/MessageDrop.h"
00048 
00049 // forward declarations
00050 
00051 // constructor(s)
00052 L1GtPrescaleFactorsAndMasksTester::L1GtPrescaleFactorsAndMasksTester(
00053         const edm::ParameterSet& parSet) :
00054             m_testerPrescaleFactors(
00055                     parSet.getParameter<bool> ("TesterPrescaleFactors")),
00056             m_testerTriggerMask(parSet.getParameter<bool> ("TesterTriggerMask")),
00057             m_testerTriggerVetoMask(
00058                     parSet.getParameter<bool> ("TesterTriggerVetoMask")),
00059             m_retrieveInBeginRun(
00060                     parSet.getParameter<bool> ("RetrieveInBeginRun")),
00061             m_retrieveInBeginLuminosityBlock(
00062                     parSet.getParameter<bool> ("RetrieveInBeginLuminosityBlock")),
00063             m_retrieveInAnalyze(parSet.getParameter<bool> ("RetrieveInAnalyze")),
00064             m_printInBeginRun(parSet.getParameter<bool> ("PrintInBeginRun")),
00065             m_printInBeginLuminosityBlock(
00066                     parSet.getParameter<bool> ("PrintInBeginLuminosityBlock")),
00067             m_printInAnalyze(parSet.getParameter<bool> ("PrintInAnalyze")),
00068             m_printOutput(parSet.getUntrackedParameter<int> ("PrintOutput", 3)) {
00069     // empty
00070 }
00071 
00072 // destructor
00073 L1GtPrescaleFactorsAndMasksTester::~L1GtPrescaleFactorsAndMasksTester() {
00074     // empty
00075 }
00076 
00077 // begin job
00078 void L1GtPrescaleFactorsAndMasksTester::beginJob() {
00079 
00080 }
00081 
00082 // begin run
00083 void L1GtPrescaleFactorsAndMasksTester::beginRun(const edm::Run& iRun,
00084         const edm::EventSetup& evSetup) {
00085 
00086     if (m_retrieveInBeginRun) {
00087         retrieveL1EventSetup(evSetup);
00088     }
00089 
00090     if (m_printInBeginRun) {
00091         printL1EventSetup(evSetup);
00092     }
00093 
00094 }
00095 
00096 // begin luminosity block
00097 void L1GtPrescaleFactorsAndMasksTester::beginLuminosityBlock(
00098         const edm::LuminosityBlock& iLumiBlock, const edm::EventSetup& evSetup) {
00099 
00100     if (m_retrieveInBeginLuminosityBlock) {
00101         retrieveL1EventSetup(evSetup);
00102     }
00103 
00104     if (m_printInBeginLuminosityBlock) {
00105         printL1EventSetup(evSetup);
00106     }
00107 
00108 }
00109 
00110 // loop over events
00111 void L1GtPrescaleFactorsAndMasksTester::analyze(const edm::Event& iEvent,
00112         const edm::EventSetup& evSetup) {
00113 
00114     if (m_retrieveInAnalyze) {
00115         retrieveL1EventSetup(evSetup);
00116     }
00117 
00118     if (m_printInAnalyze) {
00119         printL1EventSetup(evSetup);
00120     }
00121 
00122 }
00123 
00124 // end luminosity block
00125 void L1GtPrescaleFactorsAndMasksTester::endLuminosityBlock(
00126         const edm::LuminosityBlock& iLumiBlock, const edm::EventSetup& evSetup) {
00127 
00128 }
00129 
00130 // end run
00131 void L1GtPrescaleFactorsAndMasksTester::endRun(const edm::Run& iRun,
00132         const edm::EventSetup& evSetup) {
00133 
00134 }
00135 
00136 // end job
00137 void L1GtPrescaleFactorsAndMasksTester::endJob() {
00138 
00139 }
00140 
00141 void L1GtPrescaleFactorsAndMasksTester::retrieveL1EventSetup(
00142         const edm::EventSetup& evSetup) {
00143 
00144     if (m_testerPrescaleFactors) {
00145 
00146         // get / update the prescale factors from the EventSetup
00147 
00148         edm::ESHandle<L1GtPrescaleFactors> l1GtPfAlgo;
00149         evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd> ().get(l1GtPfAlgo);
00150         m_l1GtPfAlgo = l1GtPfAlgo.product();
00151 
00152         edm::ESHandle<L1GtPrescaleFactors> l1GtPfTech;
00153         evSetup.get<L1GtPrescaleFactorsTechTrigRcd> ().get(l1GtPfTech);
00154         m_l1GtPfTech = l1GtPfTech.product();
00155     }
00156 
00157     if (m_testerTriggerMask) {
00158         // get / update the trigger mask from the EventSetup
00159 
00160         edm::ESHandle<L1GtTriggerMask> l1GtTmAlgo;
00161         evSetup.get<L1GtTriggerMaskAlgoTrigRcd> ().get(l1GtTmAlgo);
00162         m_l1GtTmAlgo = l1GtTmAlgo.product();
00163 
00164         edm::ESHandle<L1GtTriggerMask> l1GtTmTech;
00165         evSetup.get<L1GtTriggerMaskTechTrigRcd> ().get(l1GtTmTech);
00166         m_l1GtTmTech = l1GtTmTech.product();
00167     }
00168 
00169     if (m_testerTriggerVetoMask) {
00170         edm::ESHandle<L1GtTriggerMask> l1GtTmVetoAlgo;
00171         evSetup.get<L1GtTriggerMaskVetoAlgoTrigRcd> ().get(l1GtTmVetoAlgo);
00172         m_l1GtTmVetoAlgo = l1GtTmVetoAlgo.product();
00173 
00174         edm::ESHandle<L1GtTriggerMask> l1GtTmVetoTech;
00175         evSetup.get<L1GtTriggerMaskVetoTechTrigRcd> ().get(l1GtTmVetoTech);
00176         m_l1GtTmVetoTech = l1GtTmVetoTech.product();
00177     }
00178 
00179 }
00180 
00181 void L1GtPrescaleFactorsAndMasksTester::printL1EventSetup(
00182         const edm::EventSetup& evSetup) {
00183 
00184     // define an output stream to print into
00185     // it can then be directed to whatever log level is desired
00186     std::ostringstream myCout;
00187 
00188     if (m_testerPrescaleFactors) {
00189 
00190         myCout << "\nL1 GT prescale factors for algorithm triggers"
00191                 << std::endl;
00192         m_l1GtPfAlgo->print(myCout);
00193 
00194         myCout << "\nL1 GT prescale factors for technical triggers"
00195                 << std::endl;
00196         m_l1GtPfTech->print(myCout);
00197     }
00198 
00199     // 
00200     if (m_testerTriggerMask) {
00201         myCout << "\nL1 GT trigger masks for algorithm triggers" << std::endl;
00202         m_l1GtTmAlgo->print(myCout);
00203 
00204         myCout << "\nL1 GT trigger masks for technical triggers" << std::endl;
00205         m_l1GtTmTech->print(myCout);
00206 
00207     }
00208 
00209     // 
00210     if (m_testerTriggerVetoMask) {
00211         myCout << "\nL1 GT trigger veto masks for algorithm triggers"
00212                 << std::endl;
00213         m_l1GtTmVetoAlgo->print(myCout);
00214 
00215         myCout << "\nL1 GT trigger veto masks for technical triggers"
00216                 << std::endl;
00217         m_l1GtTmVetoTech->print(myCout);
00218 
00219     }
00220 
00221     switch (m_printOutput) {
00222         case 0: {
00223 
00224             std::cout << myCout.str() << std::endl;
00225 
00226         }
00227 
00228             break;
00229         case 1: {
00230 
00231             LogTrace("L1GtPrescaleFactorsAndMasksTester") << myCout.str()
00232                     << std::endl;
00233 
00234         }
00235             break;
00236 
00237         case 2: {
00238 
00239             edm::LogVerbatim("L1GtPrescaleFactorsAndMasksTester")
00240                     << myCout.str() << std::endl;
00241 
00242         }
00243 
00244             break;
00245         case 3: {
00246 
00247             edm::LogInfo("L1GtPrescaleFactorsAndMasksTester") << myCout.str();
00248 
00249         }
00250 
00251             break;
00252         default: {
00253             myCout
00254                     << "\n\n  L1GtPrescaleFactorsAndMasksTester: Error - no print output = "
00255                     << m_printOutput
00256                     << " defined! \n  Check available values in the cfi file."
00257                     << "\n" << std::endl;
00258 
00259         }
00260             break;
00261     }
00262 
00263 }