Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:03

0001 // -*- C++ -*-
0002 //
0003 // Package:    CSCTFConfigTestAnalyzer
0004 // Class:      CSCTFConfigTestAnalyzer
0005 //
0006 
0007 // system include files
0008 #include <iostream>
0009 #include <memory>
0010 
0011 // user include files
0012 #include "FWCore/Framework/interface/Frameworkfwd.h"
0013 #include "FWCore/Framework/interface/EDAnalyzer.h"
0014 
0015 #include "FWCore/Framework/interface/Event.h"
0016 #include "FWCore/Framework/interface/MakerMacros.h"
0017 #include "FWCore/Framework/interface/EventSetup.h"
0018 #include "FWCore/Framework/interface/ESHandle.h"
0019 
0020 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0021 
0022 #include "CondFormats/L1TObjects/interface/L1TriggerKey.h"
0023 #include "CondFormats/L1TObjects/interface/L1TriggerKeyList.h"
0024 #include "CondFormats/DataRecord/interface/L1TriggerKeyRcd.h"
0025 #include "CondFormats/DataRecord/interface/L1TriggerKeyListRcd.h"
0026 
0027 #include "CondTools/L1Trigger/interface/Exception.h"
0028 
0029 //
0030 // class decleration
0031 //
0032 
0033 class CSCTFConfigTestAnalyzer : public edm::EDAnalyzer {
0034 public:
0035   explicit CSCTFConfigTestAnalyzer(const edm::ParameterSet&);
0036   ~CSCTFConfigTestAnalyzer() override;
0037 
0038 private:
0039   void beginJob() override;
0040   void analyze(const edm::Event&, const edm::EventSetup&) override;
0041   void endJob() override;
0042 
0043   // ----------member data ---------------------------
0044 };
0045 
0046 //
0047 // constants, enums and typedefs
0048 //
0049 
0050 //
0051 // static data member definitions
0052 //
0053 
0054 //
0055 // constructors and destructor
0056 //
0057 CSCTFConfigTestAnalyzer::CSCTFConfigTestAnalyzer(const edm::ParameterSet& iConfig)
0058 
0059 {
0060   //now do what ever initialization is needed
0061 }
0062 
0063 CSCTFConfigTestAnalyzer::~CSCTFConfigTestAnalyzer() {
0064   // do anything here that needs to be done at desctruction time
0065   // (e.g. close files, deallocate resources etc.)
0066 }
0067 
0068 //
0069 // member functions
0070 //
0071 
0072 // ------------ method called to for each event  ------------
0073 void CSCTFConfigTestAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0074   using namespace edm;
0075 
0076   ESHandle<L1TriggerKeyList> pList;
0077   iSetup.get<L1TriggerKeyListRcd>().get(pList);
0078 
0079   std::cout << "Found " << pList->tscKeyToTokenMap().size() << " TSC keys:" << std::endl;
0080 
0081   L1TriggerKeyList::KeyToToken::const_iterator iTSCKey = pList->tscKeyToTokenMap().begin();
0082   L1TriggerKeyList::KeyToToken::const_iterator eTSCKey = pList->tscKeyToTokenMap().end();
0083   for (; iTSCKey != eTSCKey; ++iTSCKey) {
0084     std::cout << iTSCKey->first << " " << iTSCKey->second << std::endl;
0085   }
0086   std::cout << std::endl;
0087 
0088   L1TriggerKeyList::RecordToKeyToToken::const_iterator iRec = pList->recordTypeToKeyToTokenMap().begin();
0089   L1TriggerKeyList::RecordToKeyToToken::const_iterator eRec = pList->recordTypeToKeyToTokenMap().end();
0090   for (; iRec != eRec; ++iRec) {
0091     const L1TriggerKeyList::KeyToToken& keyTokenMap = iRec->second;
0092     std::cout << "For record@type " << iRec->first << ", found " << keyTokenMap.size() << " keys:" << std::endl;
0093 
0094     L1TriggerKeyList::KeyToToken::const_iterator iKey = keyTokenMap.begin();
0095     L1TriggerKeyList::KeyToToken::const_iterator eKey = keyTokenMap.end();
0096     for (; iKey != eKey; ++iKey) {
0097       std::cout << iKey->first << " " << iKey->second << std::endl;
0098     }
0099     std::cout << std::endl;
0100   }
0101 
0102   try {
0103     ESHandle<L1TriggerKey> pKey;
0104     iSetup.get<L1TriggerKeyRcd>().get(pKey);
0105 
0106     // std::cout << "Current TSC key = " << pKey->getTSCKey() << std::endl ;
0107     std::cout << "Current TSC key = " << pKey->tscKey() << std::endl;
0108 
0109     std::cout << "Current subsystem keys:" << std::endl;
0110     std::cout << "CSCTF " << pKey->subsystemKey(L1TriggerKey::kCSCTF) << std::endl;
0111     std::cout << "DTTF " << pKey->subsystemKey(L1TriggerKey::kDTTF) << std::endl;
0112     std::cout << "RPC " << pKey->subsystemKey(L1TriggerKey::kRPC) << std::endl;
0113     std::cout << "GMT " << pKey->subsystemKey(L1TriggerKey::kGMT) << std::endl;
0114     std::cout << "RCT " << pKey->subsystemKey(L1TriggerKey::kRCT) << std::endl;
0115     std::cout << "GCT " << pKey->subsystemKey(L1TriggerKey::kGCT) << std::endl;
0116     std::cout << "TSP0 " << pKey->subsystemKey(L1TriggerKey::kTSP0) << std::endl;
0117 
0118     const L1TriggerKey::RecordToKey& recKeyMap = pKey->recordToKeyMap();
0119     L1TriggerKey::RecordToKey::const_iterator iRec = recKeyMap.begin();
0120     L1TriggerKey::RecordToKey::const_iterator eRec = recKeyMap.end();
0121     for (; iRec != eRec; ++iRec) {
0122       std::cout << iRec->first << " " << iRec->second << std::endl;
0123     }
0124   } catch (cms::Exception& ex) {
0125     std::cout << "No L1TriggerKey found." << std::endl;
0126   }
0127 }
0128 
0129 // ------------ method called once each job just before starting event loop  ------------
0130 void CSCTFConfigTestAnalyzer::beginJob() {}
0131 
0132 // ------------ method called once each job just after ending the event loop  ------------
0133 void CSCTFConfigTestAnalyzer::endJob() {}
0134 
0135 //define this as a plug-in
0136 DEFINE_FWK_MODULE(CSCTFConfigTestAnalyzer);