CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/L1TriggerConfig/CSCTFConfigProducers/src/CSCTFConfigTestAnalyzer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    CSCTFConfigTestAnalyzer
00004 // Class:      CSCTFConfigTestAnalyzer
00005 // 
00006 
00007 
00008 
00009 // system include files
00010 #include <memory>
00011 
00012 // user include files
00013 #include "FWCore/Framework/interface/Frameworkfwd.h"
00014 #include "FWCore/Framework/interface/EDAnalyzer.h"
00015 
00016 #include "FWCore/Framework/interface/Event.h"
00017 #include "FWCore/Framework/interface/MakerMacros.h"
00018 #include "FWCore/Framework/interface/EventSetup.h"
00019 #include "FWCore/Framework/interface/ESHandle.h"
00020 
00021 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00022 
00023 #include "CondFormats/L1TObjects/interface/L1TriggerKey.h"
00024 #include "CondFormats/L1TObjects/interface/L1TriggerKeyList.h"
00025 #include "CondFormats/DataRecord/interface/L1TriggerKeyRcd.h"
00026 #include "CondFormats/DataRecord/interface/L1TriggerKeyListRcd.h"
00027 
00028 #include "CondTools/L1Trigger/interface/Exception.h"
00029 
00030 
00031 //
00032 // class decleration
00033 //
00034 
00035 class CSCTFConfigTestAnalyzer : public edm::EDAnalyzer {
00036    public:
00037       explicit CSCTFConfigTestAnalyzer(const edm::ParameterSet&);
00038       ~CSCTFConfigTestAnalyzer();
00039 
00040 
00041    private:
00042       virtual void beginJob() ;
00043       virtual void analyze(const edm::Event&, const edm::EventSetup&);
00044       virtual void endJob() ;
00045 
00046       // ----------member data ---------------------------
00047 };
00048 
00049 //
00050 // constants, enums and typedefs
00051 //
00052 
00053 //
00054 // static data member definitions
00055 //
00056 
00057 //
00058 // constructors and destructor
00059 //
00060 CSCTFConfigTestAnalyzer::CSCTFConfigTestAnalyzer(const edm::ParameterSet& iConfig)
00061 
00062 {
00063    //now do what ever initialization is needed
00064 
00065 }
00066 
00067 
00068 CSCTFConfigTestAnalyzer::~CSCTFConfigTestAnalyzer()
00069 {
00070  
00071    // do anything here that needs to be done at desctruction time
00072    // (e.g. close files, deallocate resources etc.)
00073 
00074 }
00075 
00076 
00077 //
00078 // member functions
00079 //
00080 
00081 // ------------ method called to for each event  ------------
00082 void
00083 CSCTFConfigTestAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00084 {
00085    using namespace edm;
00086 
00087    ESHandle< L1TriggerKeyList > pList ;
00088    iSetup.get< L1TriggerKeyListRcd >().get( pList ) ;
00089 
00090    std::cout << "Found " << pList->tscKeyToTokenMap().size() << " TSC keys:"
00091              << std::endl ;
00092 
00093    L1TriggerKeyList::KeyToToken::const_iterator iTSCKey =
00094      pList->tscKeyToTokenMap().begin() ;
00095    L1TriggerKeyList::KeyToToken::const_iterator eTSCKey =
00096      pList->tscKeyToTokenMap().end() ;
00097    for( ; iTSCKey != eTSCKey ; ++iTSCKey )
00098      {
00099        std::cout << iTSCKey->first << " " << iTSCKey->second << std::endl ;
00100      }
00101    std::cout << std::endl ;
00102 
00103    L1TriggerKeyList::RecordToKeyToToken::const_iterator iRec =
00104      pList->recordTypeToKeyToTokenMap().begin() ;
00105    L1TriggerKeyList::RecordToKeyToToken::const_iterator eRec =
00106      pList->recordTypeToKeyToTokenMap().end() ;
00107    for( ; iRec != eRec ; ++iRec )
00108      {
00109        const L1TriggerKeyList::KeyToToken& keyTokenMap = iRec->second ;
00110        std::cout << "For record@type " << iRec->first << ", found "
00111                  << keyTokenMap.size() << " keys:" << std::endl ;
00112 
00113        L1TriggerKeyList::KeyToToken::const_iterator iKey = keyTokenMap.begin();
00114        L1TriggerKeyList::KeyToToken::const_iterator eKey = keyTokenMap.end() ;
00115        for( ; iKey != eKey ; ++iKey )
00116          {
00117            std::cout << iKey->first << " " << iKey->second << std::endl ;
00118          }
00119        std::cout << std::endl ;
00120      }
00121 
00122    try
00123      {
00124        ESHandle< L1TriggerKey > pKey ;
00125        iSetup.get< L1TriggerKeyRcd >().get( pKey ) ;
00126 
00127        // std::cout << "Current TSC key = " << pKey->getTSCKey() << std::endl ;
00128        std::cout << "Current TSC key = " << pKey->tscKey() << std::endl ;
00129 
00130        std::cout << "Current subsystem keys:" << std::endl ;
00131        std::cout << "CSCTF " << pKey->subsystemKey( L1TriggerKey::kCSCTF )
00132                  << std::endl ;
00133        std::cout << "DTTF " << pKey->subsystemKey( L1TriggerKey::kDTTF )
00134                  << std::endl ;
00135        std::cout << "RPC " << pKey->subsystemKey( L1TriggerKey::kRPC )
00136                  << std::endl ;
00137        std::cout << "GMT " << pKey->subsystemKey( L1TriggerKey::kGMT )
00138                  << std::endl ;
00139        std::cout << "RCT " << pKey->subsystemKey( L1TriggerKey::kRCT )
00140                  << std::endl ;
00141        std::cout << "GCT " << pKey->subsystemKey( L1TriggerKey::kGCT )
00142                  << std::endl ;
00143        std::cout << "TSP0 " << pKey->subsystemKey( L1TriggerKey::kTSP0 )
00144                  << std::endl ;
00145 
00146        const L1TriggerKey::RecordToKey& recKeyMap = pKey->recordToKeyMap() ;
00147        L1TriggerKey::RecordToKey::const_iterator iRec = recKeyMap.begin() ;
00148        L1TriggerKey::RecordToKey::const_iterator eRec = recKeyMap.end() ;
00149        for( ; iRec != eRec ; ++iRec )
00150          {
00151            std::cout << iRec->first << " " << iRec->second << std::endl ;
00152          }
00153      }
00154    catch( cms::Exception& ex )
00155      {
00156        std::cout << "No L1TriggerKey found." << std::endl ;
00157      }
00158 
00159 }
00160 
00161 
00162 // ------------ method called once each job just before starting event loop  ------------
00163 void 
00164 CSCTFConfigTestAnalyzer::beginJob()
00165 {
00166 }
00167 
00168 // ------------ method called once each job just after ending the event loop  ------------
00169 void 
00170 CSCTFConfigTestAnalyzer::endJob() {
00171 }
00172 
00173 //define this as a plug-in
00174 DEFINE_FWK_MODULE(CSCTFConfigTestAnalyzer);