Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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