CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/CondTools/L1Trigger/plugins/L1GtRunSettingsViewer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    L1GtRunSettingsViewer
00004 // Class:      L1GtRunSettingsViewer
00005 // 
00013 //
00014 // Original Author:  Werner Man-Li Sun
00015 //         Created:  Thu May 19 04:32:54 CEST 2011
00016 //
00017 //
00018 
00019 
00020 // system include files
00021 #include <memory>
00022 #include <sstream>
00023 
00024 // user include files
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDAnalyzer.h"
00027 
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030 #include "FWCore/Framework/interface/EventSetup.h"
00031 #include "FWCore/Framework/interface/ESHandle.h"
00032 
00033 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00034 
00035 #include "CondFormats/L1TObjects/interface/L1TriggerKey.h"
00036 #include "CondFormats/L1TObjects/interface/L1TriggerKeyList.h"
00037 #include "CondFormats/DataRecord/interface/L1TriggerKeyRcd.h"
00038 #include "CondFormats/DataRecord/interface/L1TriggerKeyListRcd.h"
00039 
00040 #include "CondFormats/L1TObjects/interface/L1GtPrescaleFactors.h"
00041 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsAlgoTrigRcd.h"
00042 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsTechTrigRcd.h"
00043 #include "CondFormats/L1TObjects/interface/L1GtTriggerMask.h"
00044 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskAlgoTrigRcd.h"
00045 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskTechTrigRcd.h"
00046 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskVetoAlgoTrigRcd.h"
00047 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskVetoTechTrigRcd.h"
00048 
00049 #include "CondTools/L1Trigger/interface/Exception.h"
00050 #include "CondTools/L1Trigger/interface/DataWriter.h"
00051 
00052 //
00053 // class decleration
00054 //
00055 
00056 class L1GtRunSettingsViewer : public edm::EDAnalyzer {
00057    public:
00058       explicit L1GtRunSettingsViewer(const edm::ParameterSet&);
00059       ~L1GtRunSettingsViewer();
00060 
00061 
00062    private:
00063       virtual void beginJob() ;
00064       virtual void analyze(const edm::Event&, const edm::EventSetup&);
00065       virtual void endJob() ;
00066 
00067       // ----------member data ---------------------------
00068   std::string m_prescalesKey ;
00069   std::string m_maskAlgoKey ;
00070   std::string m_maskTechKey ;
00071   std::string m_maskVetoAlgoKey ;
00072   std::string m_maskVetoTechKey ;
00073 };
00074 
00075 //
00076 // constants, enums and typedefs
00077 //
00078 
00079 //
00080 // static data member definitions
00081 //
00082 
00083 //
00084 // constructors and destructor
00085 //
00086 L1GtRunSettingsViewer::L1GtRunSettingsViewer(const edm::ParameterSet& iConfig)
00087   : m_prescalesKey( iConfig.getParameter< std::string >( "prescalesKey" ) ),
00088     m_maskAlgoKey( iConfig.getParameter< std::string >( "maskAlgoKey" ) ),
00089     m_maskTechKey( iConfig.getParameter< std::string >( "maskTechKey" ) ),
00090     m_maskVetoAlgoKey( iConfig.getParameter< std::string >( "maskVetoAlgoKey" ) ),
00091     m_maskVetoTechKey( iConfig.getParameter< std::string >( "maskVetoTechKey" ) )
00092 {
00093    //now do what ever initialization is needed
00094 }
00095 
00096 
00097 L1GtRunSettingsViewer::~L1GtRunSettingsViewer()
00098 {
00099  
00100    // do anything here that needs to be done at desctruction time
00101    // (e.g. close files, deallocate resources etc.)
00102 
00103 }
00104 
00105 
00106 //
00107 // member functions
00108 //
00109 
00110 // ------------ method called to for each event  ------------
00111 void
00112 L1GtRunSettingsViewer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00113 {
00114    using namespace edm;
00115 
00116    // Utility class
00117    l1t::DataWriter dataWriter ;
00118 
00119    // Get most recent L1TriggerKeyList
00120    L1TriggerKeyList keyList ;
00121    dataWriter.fillLastTriggerKeyList( keyList ) ;
00122 
00123    // For the given GTRS key, find the corresponding payload tokens.
00124    // Use the payload tokens to retrieve the corresponding objects.
00125    // Call the print functions for these objects.
00126 
00127    if( !m_prescalesKey.empty() )
00128      {
00129        std::string pfAlgoToken = keyList.token( "L1GtPrescaleFactorsAlgoTrigRcd",
00130                                                 "L1GtPrescaleFactors",
00131                                                 m_prescalesKey ) ;
00132        if( pfAlgoToken.empty() )
00133          {
00134            edm::LogError( "L1-O2O" ) << "No payload for L1GtPrescaleFactorsAlgoTrigRcd with key "
00135                                      << m_prescalesKey ;
00136          }
00137        else
00138          {
00139            L1GtPrescaleFactors pfAlgo ;
00140            dataWriter.readObject( pfAlgoToken, pfAlgo ) ;
00141            pfAlgo.print( std::cout ) ;
00142          }
00143 
00144        std::string pfTechToken = keyList.token( "L1GtPrescaleFactorsTechTrigRcd",
00145                                                 "L1GtPrescaleFactors",
00146                                                 m_prescalesKey ) ;
00147        if( pfTechToken.empty() )
00148          {
00149            edm::LogError( "L1-O2O" ) << "No payload for L1GtPrescaleFactorsTechTrigRcd with key "
00150                                      << m_prescalesKey ;
00151          }
00152        else
00153          {
00154            L1GtPrescaleFactors pfTech ;
00155            dataWriter.readObject( pfTechToken, pfTech ) ;
00156            pfTech.print( std::cout ) ;
00157          }
00158      }
00159 
00160    if( !m_maskAlgoKey.empty() )
00161      {
00162        std::string token = keyList.token( "L1GtTriggerMaskAlgoTrigRcd",
00163                                           "L1GtTriggerMask",
00164                                           m_maskAlgoKey ) ;
00165        if( token.empty() )
00166          {
00167            edm::LogError( "L1-O2O" ) << "No payload for L1GtTriggerMaskAlgoTrigRcd with key "
00168                                      << m_maskAlgoKey ;
00169          }
00170        else
00171          {
00172            L1GtTriggerMask mask ;
00173            dataWriter.readObject( token, mask ) ;
00174            mask.print( std::cout ) ;
00175          }
00176      }
00177 
00178    if( !m_maskTechKey.empty() )
00179      {
00180        std::string token = keyList.token( "L1GtTriggerMaskTechTrigRcd",
00181                                           "L1GtTriggerMask",
00182                                           m_maskTechKey ) ;
00183        if( token.empty() )
00184          {
00185            edm::LogError( "L1-O2O" ) << "No payload for L1GtTriggerMaskTechTrigRcd with key "
00186                                      << m_maskTechKey ;
00187          }
00188        else
00189          {
00190            L1GtTriggerMask mask ;
00191            dataWriter.readObject( token, mask ) ;
00192            mask.print( std::cout ) ;
00193          }
00194      }
00195 
00196    if( !m_maskVetoAlgoKey.empty() )
00197      {
00198        std::string token = keyList.token( "L1GtTriggerMaskVetoAlgoTrigRcd",
00199                                           "L1GtTriggerMask",
00200                                           m_maskVetoAlgoKey ) ;
00201        if( token.empty() )
00202          {
00203            edm::LogError( "L1-O2O" ) << "No payload for L1GtTriggerMaskVetoAlgoTrigRcd with key "
00204                                      << m_maskVetoAlgoKey ;
00205          }
00206        else
00207          {
00208            L1GtTriggerMask mask ;
00209            dataWriter.readObject( token, mask ) ;
00210            mask.print( std::cout ) ;
00211          }
00212      }
00213 
00214    if( !m_maskVetoTechKey.empty() )
00215      {
00216        std::string token = keyList.token( "L1GtTriggerMaskVetoTechTrigRcd",
00217                                           "L1GtTriggerMask",
00218                                           m_maskVetoTechKey ) ;
00219        if( token.empty() )
00220          {
00221            edm::LogError( "L1-O2O" ) << "No payload for L1GtTriggerMaskVetoTechTrigRcd with key "
00222                                      << m_maskVetoTechKey ;
00223          }
00224        else
00225          {
00226            L1GtTriggerMask mask ;
00227            dataWriter.readObject( token, mask ) ;
00228            mask.print( std::cout ) ;
00229          }
00230      }
00231 }
00232 
00233 
00234 // ------------ method called once each job just before starting event loop  ------------
00235 void 
00236 L1GtRunSettingsViewer::beginJob()
00237 {
00238 }
00239 
00240 // ------------ method called once each job just after ending the event loop  ------------
00241 void 
00242 L1GtRunSettingsViewer::endJob() {
00243 }
00244 
00245 //define this as a plug-in
00246 DEFINE_FWK_MODULE(L1GtRunSettingsViewer);