Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-07 04:53:55

0001 #include <string>
0002 #include <iostream>
0003 #include <map>
0004 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "FWCore/Framework/interface/MakerMacros.h"
0008 #include "CondFormats/RunInfo/interface/LHCInfo.h"
0009 #include "CondFormats/DataRecord/interface/LHCInfoRcd.h"
0010 
0011 namespace edmtest {
0012   class LHCInfoESAnalyzer : public edm::one::EDAnalyzer<> {
0013   private:
0014     const edm::ESGetToken<LHCInfo, LHCInfoRcd> m_LHCInfoToken;
0015 
0016   public:
0017     explicit LHCInfoESAnalyzer(edm::ParameterSet const& p) : m_LHCInfoToken(esConsumes()) {
0018       edm::LogPrint("LHCInfoESAnalyzer") << "LHCInfoESAnalyzer" << std::endl;
0019     }
0020     explicit LHCInfoESAnalyzer(int i) { edm::LogPrint("LHCInfoESAnalyzer") << "LHCInfoESAnalyzer " << i << std::endl; }
0021     ~LHCInfoESAnalyzer() override { edm::LogPrint("LHCInfoESAnalyzer") << "~LHCInfoESAnalyzer " << std::endl; }
0022     void analyze(const edm::Event& e, const edm::EventSetup& c) override;
0023   };
0024 
0025   void LHCInfoESAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) {
0026     edm::LogPrint("LHCInfoESAnalyzer") << "###LHCInfoESAnalyzer::analyze" << std::endl;
0027     edm::LogPrint("LHCInfoESAnalyzer") << " I AM IN RUN NUMBER " << e.id().run() << std::endl;
0028     edm::LogPrint("LHCInfoESAnalyzer") << " ---EVENT NUMBER " << e.id().event() << std::endl;
0029     edm::eventsetup::EventSetupRecordKey recordKey(
0030         edm::eventsetup::EventSetupRecordKey::TypeTag::findType("LHCInfoRcd"));
0031     if (recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
0032       //record not found
0033       edm::LogPrint("LHCInfoESAnalyzer") << "Record \"LHCInfoRcd"
0034                                          << "\" does not exist " << std::endl;
0035     }
0036     edm::LogPrint("LHCInfoESAnalyzer") << "got eshandle" << std::endl;
0037     edm::ESHandle<LHCInfo> sum = context.getHandle(m_LHCInfoToken);
0038     edm::LogPrint("LHCInfoESAnalyzer") << "got context" << std::endl;
0039     const LHCInfo* summary = sum.product();
0040     edm::LogPrint("LHCInfoESAnalyzer") << "got LHCInfo* " << std::endl;
0041     edm::LogPrint("LHCInfoESAnalyzer") << "print  result" << std::endl;
0042     edm::LogPrint("LHCInfoESAnalyzer") << *summary;
0043   }
0044   DEFINE_FWK_MODULE(LHCInfoESAnalyzer);
0045 }  // namespace edmtest