Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include <stdexcept>
0002 #include <string>
0003 #include <iostream>
0004 #include <map>
0005 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/Framework/interface/MakerMacros.h"
0008 #include "FWCore/Framework/interface/EventSetup.h"
0009 #include "CondFormats/RunInfo/interface/RunInfo.h"
0010 #include "CondFormats/DataRecord/interface/RunSummaryRcd.h"
0011 
0012 using namespace std;
0013 
0014 namespace edmtest {
0015   class RunInfoESAnalyzer : public edm::one::EDAnalyzer<> {
0016   private:
0017     const edm::ESGetToken<RunInfo, RunInfoRcd> m_RunInfoToken;
0018 
0019   public:
0020     explicit RunInfoESAnalyzer(edm::ParameterSet const& p) : m_RunInfoToken(esConsumes()) {
0021       edm::LogPrint("RunInfoESAnalyzer") << "RunInfoESAnalyzer" << std::endl;
0022     }
0023     explicit RunInfoESAnalyzer(int i) { edm::LogPrint("RunInfoESAnalyzer") << "RunInfoESAnalyzer " << i << std::endl; }
0024     ~RunInfoESAnalyzer() override { edm::LogPrint("RunInfoESAnalyzer") << "~RunInfoESAnalyzer " << std::endl; }
0025     void analyze(const edm::Event& e, const edm::EventSetup& c) override;
0026   };
0027   void RunInfoESAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context) {
0028     using namespace edm::eventsetup;
0029     edm::LogPrint("RunInfoESAnalyzer") << "###RunInfoESAnalyzer::analyze" << std::endl;
0030 
0031     // Context is not used.
0032     edm::LogPrint("RunInfoESAnalyzer") << " I AM IN RUN NUMBER " << e.id().run() << std::endl;
0033     edm::LogPrint("RunInfoESAnalyzer") << " ---EVENT NUMBER " << e.id().event() << std::endl;
0034     edm::eventsetup::EventSetupRecordKey recordKey(
0035         edm::eventsetup::EventSetupRecordKey::TypeTag::findType("RunInfoRcd"));
0036     if (recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
0037       //record not found
0038       edm::LogPrint("RunInfoESAnalyzer") << "Record \"RunInfoRcd"
0039                                          << "\" does not exist " << std::endl;
0040     }
0041     edm::LogPrint("RunInfoESAnalyzer") << "got eshandle" << std::endl;
0042     edm::ESHandle<RunInfo> sum = context.getHandle(m_RunInfoToken);
0043     edm::LogPrint("RunInfoESAnalyzer") << "got context" << std::endl;
0044     const RunInfo* summary = sum.product();
0045     edm::LogPrint("RunInfoESAnalyzer") << "got RunInfo* " << std::endl;
0046     edm::LogPrint("RunInfoESAnalyzer") << "print  result" << std::endl;
0047     summary->printAllValues();
0048     /*
0049     std::vector<std::string> subdet = summary->getSubdtIn();
0050     edm::LogPrint("RunInfoESAnalyzer")<<"subdetector in the run "<< std::endl;
0051     for (size_t i=0; i<subdet.size(); i++){
0052       edm::LogPrint("RunInfoESAnalyzer")<<"--> " << subdet[i] << std::endl;
0053     }
0054     */
0055   }
0056   DEFINE_FWK_MODULE(RunInfoESAnalyzer);
0057 }  // namespace edmtest