Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:18

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