Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-28 23:48:17

0001 // -*- C++ -*-
0002 //
0003 // Package:    L1GtRunSettingsViewer
0004 // Class:      L1GtRunSettingsViewer
0005 //
0006 /**\class L1GtRunSettingsViewer L1GtRunSettingsViewer.cc CondTools/L1GtRunSettingsViewer/src/L1GtRunSettingsViewer.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Werner Man-Li Sun
0015 //         Created:  Thu May 19 04:32:54 CEST 2011
0016 //
0017 //
0018 
0019 // system include files
0020 #include <iostream>
0021 #include <memory>
0022 #include <sstream>
0023 
0024 // user include files
0025 #include "FWCore/Framework/interface/Frameworkfwd.h"
0026 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0027 
0028 #include "FWCore/Framework/interface/Event.h"
0029 #include "FWCore/Framework/interface/MakerMacros.h"
0030 #include "FWCore/Framework/interface/EventSetup.h"
0031 #include "FWCore/Framework/interface/ESHandle.h"
0032 
0033 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0034 
0035 #include "CondFormats/L1TObjects/interface/L1TriggerKey.h"
0036 #include "CondFormats/L1TObjects/interface/L1TriggerKeyList.h"
0037 #include "CondFormats/DataRecord/interface/L1TriggerKeyRcd.h"
0038 #include "CondFormats/DataRecord/interface/L1TriggerKeyListRcd.h"
0039 
0040 #include "CondFormats/L1TObjects/interface/L1GtPrescaleFactors.h"
0041 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsAlgoTrigRcd.h"
0042 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsTechTrigRcd.h"
0043 #include "CondFormats/L1TObjects/interface/L1GtTriggerMask.h"
0044 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskAlgoTrigRcd.h"
0045 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskTechTrigRcd.h"
0046 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskVetoAlgoTrigRcd.h"
0047 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskVetoTechTrigRcd.h"
0048 
0049 #include "CondTools/L1Trigger/interface/Exception.h"
0050 #include "CondTools/L1Trigger/interface/DataWriter.h"
0051 
0052 //
0053 // class decleration
0054 //
0055 
0056 class L1GtRunSettingsViewer : public edm::one::EDAnalyzer<> {
0057 public:
0058   explicit L1GtRunSettingsViewer(const edm::ParameterSet&);
0059   ~L1GtRunSettingsViewer() override;
0060 
0061 private:
0062   void beginJob() override;
0063   void analyze(const edm::Event&, const edm::EventSetup&) override;
0064   void endJob() override;
0065 
0066   // ----------member data ---------------------------
0067   std::string m_prescalesKey;
0068   std::string m_maskAlgoKey;
0069   std::string m_maskTechKey;
0070   std::string m_maskVetoAlgoKey;
0071   std::string m_maskVetoTechKey;
0072 };
0073 
0074 //
0075 // constants, enums and typedefs
0076 //
0077 
0078 //
0079 // static data member definitions
0080 //
0081 
0082 //
0083 // constructors and destructor
0084 //
0085 L1GtRunSettingsViewer::L1GtRunSettingsViewer(const edm::ParameterSet& iConfig)
0086     : m_prescalesKey(iConfig.getParameter<std::string>("prescalesKey")),
0087       m_maskAlgoKey(iConfig.getParameter<std::string>("maskAlgoKey")),
0088       m_maskTechKey(iConfig.getParameter<std::string>("maskTechKey")),
0089       m_maskVetoAlgoKey(iConfig.getParameter<std::string>("maskVetoAlgoKey")),
0090       m_maskVetoTechKey(iConfig.getParameter<std::string>("maskVetoTechKey")) {
0091   //now do what ever initialization is needed
0092 }
0093 
0094 L1GtRunSettingsViewer::~L1GtRunSettingsViewer() {
0095   // do anything here that needs to be done at desctruction time
0096   // (e.g. close files, deallocate resources etc.)
0097 }
0098 
0099 //
0100 // member functions
0101 //
0102 
0103 // ------------ method called to for each event  ------------
0104 void L1GtRunSettingsViewer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0105   using namespace edm;
0106 
0107   // Utility class
0108   l1t::DataWriter dataWriter;
0109 
0110   // Get most recent L1TriggerKeyList
0111   L1TriggerKeyList keyList;
0112   dataWriter.fillLastTriggerKeyList(keyList);
0113 
0114   // For the given GTRS key, find the corresponding payload tokens.
0115   // Use the payload tokens to retrieve the corresponding objects.
0116   // Call the print functions for these objects.
0117 
0118   if (!m_prescalesKey.empty()) {
0119     std::string pfAlgoToken = keyList.token("L1GtPrescaleFactorsAlgoTrigRcd", "L1GtPrescaleFactors", m_prescalesKey);
0120     if (pfAlgoToken.empty()) {
0121       edm::LogError("L1-O2O") << "No payload for L1GtPrescaleFactorsAlgoTrigRcd with key " << m_prescalesKey;
0122     } else {
0123       L1GtPrescaleFactors pfAlgo;
0124       dataWriter.readObject(pfAlgoToken, pfAlgo);
0125       pfAlgo.print(std::cout);
0126     }
0127 
0128     std::string pfTechToken = keyList.token("L1GtPrescaleFactorsTechTrigRcd", "L1GtPrescaleFactors", m_prescalesKey);
0129     if (pfTechToken.empty()) {
0130       edm::LogError("L1-O2O") << "No payload for L1GtPrescaleFactorsTechTrigRcd with key " << m_prescalesKey;
0131     } else {
0132       L1GtPrescaleFactors pfTech;
0133       dataWriter.readObject(pfTechToken, pfTech);
0134       pfTech.print(std::cout);
0135     }
0136   }
0137 
0138   if (!m_maskAlgoKey.empty()) {
0139     std::string token = keyList.token("L1GtTriggerMaskAlgoTrigRcd", "L1GtTriggerMask", m_maskAlgoKey);
0140     if (token.empty()) {
0141       edm::LogError("L1-O2O") << "No payload for L1GtTriggerMaskAlgoTrigRcd with key " << m_maskAlgoKey;
0142     } else {
0143       L1GtTriggerMask mask;
0144       dataWriter.readObject(token, mask);
0145       mask.print(std::cout);
0146     }
0147   }
0148 
0149   if (!m_maskTechKey.empty()) {
0150     std::string token = keyList.token("L1GtTriggerMaskTechTrigRcd", "L1GtTriggerMask", m_maskTechKey);
0151     if (token.empty()) {
0152       edm::LogError("L1-O2O") << "No payload for L1GtTriggerMaskTechTrigRcd with key " << m_maskTechKey;
0153     } else {
0154       L1GtTriggerMask mask;
0155       dataWriter.readObject(token, mask);
0156       mask.print(std::cout);
0157     }
0158   }
0159 
0160   if (!m_maskVetoAlgoKey.empty()) {
0161     std::string token = keyList.token("L1GtTriggerMaskVetoAlgoTrigRcd", "L1GtTriggerMask", m_maskVetoAlgoKey);
0162     if (token.empty()) {
0163       edm::LogError("L1-O2O") << "No payload for L1GtTriggerMaskVetoAlgoTrigRcd with key " << m_maskVetoAlgoKey;
0164     } else {
0165       L1GtTriggerMask mask;
0166       dataWriter.readObject(token, mask);
0167       mask.print(std::cout);
0168     }
0169   }
0170 
0171   if (!m_maskVetoTechKey.empty()) {
0172     std::string token = keyList.token("L1GtTriggerMaskVetoTechTrigRcd", "L1GtTriggerMask", m_maskVetoTechKey);
0173     if (token.empty()) {
0174       edm::LogError("L1-O2O") << "No payload for L1GtTriggerMaskVetoTechTrigRcd with key " << m_maskVetoTechKey;
0175     } else {
0176       L1GtTriggerMask mask;
0177       dataWriter.readObject(token, mask);
0178       mask.print(std::cout);
0179     }
0180   }
0181 }
0182 
0183 // ------------ method called once each job just before starting event loop  ------------
0184 void L1GtRunSettingsViewer::beginJob() {}
0185 
0186 // ------------ method called once each job just after ending the event loop  ------------
0187 void L1GtRunSettingsViewer::endJob() {}
0188 
0189 //define this as a plug-in
0190 DEFINE_FWK_MODULE(L1GtRunSettingsViewer);