Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:14

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/one/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::one::EDAnalyzer<> {
0034 public:
0035   explicit CSCTFConfigTestAnalyzer(const edm::ParameterSet&);
0036 
0037 private:
0038   void analyze(const edm::Event&, const edm::EventSetup&) override;
0039 
0040   // ----------member data ---------------------------
0041   edm::ESGetToken<L1TriggerKeyList, L1TriggerKeyListRcd> keyListToken_;
0042   edm::ESGetToken<L1TriggerKey, L1TriggerKeyRcd> keyToken_;
0043 };
0044 
0045 //
0046 // constants, enums and typedefs
0047 //
0048 
0049 //
0050 // static data member definitions
0051 //
0052 
0053 //
0054 // constructors and destructor
0055 //
0056 CSCTFConfigTestAnalyzer::CSCTFConfigTestAnalyzer(const edm::ParameterSet& iConfig) : keyToken_(esConsumes()) {
0057   //now do what ever initialization is needed
0058 }
0059 
0060 //
0061 // member functions
0062 //
0063 
0064 // ------------ method called to for each event  ------------
0065 void CSCTFConfigTestAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0066   using namespace edm;
0067 
0068   ESHandle<L1TriggerKeyList> pList = iSetup.getHandle(keyListToken_);
0069 
0070   std::cout << "Found " << pList->tscKeyToTokenMap().size() << " TSC keys:" << std::endl;
0071 
0072   L1TriggerKeyList::KeyToToken::const_iterator iTSCKey = pList->tscKeyToTokenMap().begin();
0073   L1TriggerKeyList::KeyToToken::const_iterator eTSCKey = pList->tscKeyToTokenMap().end();
0074   for (; iTSCKey != eTSCKey; ++iTSCKey) {
0075     std::cout << iTSCKey->first << " " << iTSCKey->second << std::endl;
0076   }
0077   std::cout << std::endl;
0078 
0079   L1TriggerKeyList::RecordToKeyToToken::const_iterator iRec = pList->recordTypeToKeyToTokenMap().begin();
0080   L1TriggerKeyList::RecordToKeyToToken::const_iterator eRec = pList->recordTypeToKeyToTokenMap().end();
0081   for (; iRec != eRec; ++iRec) {
0082     const L1TriggerKeyList::KeyToToken& keyTokenMap = iRec->second;
0083     std::cout << "For record@type " << iRec->first << ", found " << keyTokenMap.size() << " keys:" << std::endl;
0084 
0085     L1TriggerKeyList::KeyToToken::const_iterator iKey = keyTokenMap.begin();
0086     L1TriggerKeyList::KeyToToken::const_iterator eKey = keyTokenMap.end();
0087     for (; iKey != eKey; ++iKey) {
0088       std::cout << iKey->first << " " << iKey->second << std::endl;
0089     }
0090     std::cout << std::endl;
0091   }
0092 
0093   try {
0094     ESHandle<L1TriggerKey> pKey = iSetup.getHandle(keyToken_);
0095 
0096     // std::cout << "Current TSC key = " << pKey->getTSCKey() << std::endl ;
0097     std::cout << "Current TSC key = " << pKey->tscKey() << std::endl;
0098 
0099     std::cout << "Current subsystem keys:" << std::endl;
0100     std::cout << "CSCTF " << pKey->subsystemKey(L1TriggerKey::kCSCTF) << std::endl;
0101     std::cout << "DTTF " << pKey->subsystemKey(L1TriggerKey::kDTTF) << std::endl;
0102     std::cout << "RPC " << pKey->subsystemKey(L1TriggerKey::kRPC) << std::endl;
0103     std::cout << "GMT " << pKey->subsystemKey(L1TriggerKey::kGMT) << std::endl;
0104     std::cout << "RCT " << pKey->subsystemKey(L1TriggerKey::kRCT) << std::endl;
0105     std::cout << "GCT " << pKey->subsystemKey(L1TriggerKey::kGCT) << std::endl;
0106     std::cout << "TSP0 " << pKey->subsystemKey(L1TriggerKey::kTSP0) << std::endl;
0107 
0108     const L1TriggerKey::RecordToKey& recKeyMap = pKey->recordToKeyMap();
0109     L1TriggerKey::RecordToKey::const_iterator iRec = recKeyMap.begin();
0110     L1TriggerKey::RecordToKey::const_iterator eRec = recKeyMap.end();
0111     for (; iRec != eRec; ++iRec) {
0112       std::cout << iRec->first << " " << iRec->second << std::endl;
0113     }
0114   } catch (cms::Exception& ex) {
0115     std::cout << "No L1TriggerKey found." << std::endl;
0116   }
0117 }
0118 
0119 //define this as a plug-in
0120 DEFINE_FWK_MODULE(CSCTFConfigTestAnalyzer);