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