CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/CondTools/RunInfo/plugins/RunInfoESAnalyzer.cc

Go to the documentation of this file.
00001 #include <stdexcept>
00002 #include <string>
00003 #include <iostream>
00004 #include <map>
00005 #include "FWCore/Framework/interface/EDAnalyzer.h"
00006 #include "FWCore/Framework/interface/Event.h"
00007 #include "FWCore/Framework/interface/ESHandle.h"
00008 #include "FWCore/Framework/interface/MakerMacros.h"
00009 
00010 #include "FWCore/Framework/interface/EventSetup.h"
00011 
00012 #include "CondFormats/RunInfo/interface/RunInfo.h"
00013 
00014 #include "CondFormats/DataRecord/interface/RunSummaryRcd.h"
00015 
00016 using namespace std;
00017 
00018 
00019 
00020 
00021 
00022 namespace edmtest
00023 {
00024   class RunInfoESAnalyzer : public edm::EDAnalyzer
00025   {
00026   public:
00027     explicit  RunInfoESAnalyzer(edm::ParameterSet const& p) 
00028     { 
00029       std::cout<<"RunInfoESAnalyzer"<<std::endl;
00030     }
00031     explicit  RunInfoESAnalyzer(int i) 
00032     { std::cout<<"RunInfoESAnalyzer "<<i<<std::endl; }
00033     virtual ~RunInfoESAnalyzer() {  
00034       std::cout<<"~RunInfoESAnalyzer "<<std::endl;
00035     }
00036     //     virtual void beginJob();
00037     //  virtual void beginRun(const edm::Run&, const edm::EventSetup& context);
00038     virtual void analyze(const edm::Event& e, const edm::EventSetup& c);
00039   private:
00040   };
00041    
00042   
00043   /* void
00044   RunInfoESAnalyzer::beginRun(const edm::Run&, const edm::EventSetup& context){
00045     std::cout<<"###RunInfoESAnalyzer::beginRun"<<std::endl;
00046     edm::ESHandle<RunInfo> RunInfo_lumiarray;
00047     std::cout<<"got eshandle"<<std::endl;
00048     context.get<RunInfoRcd>().get(RunInfo_lumiarray);
00049     std::cout<<"got data"<<std::endl;
00050   }
00051   
00052   void
00053   RunInfoESAnalyzer::beginJob(){
00054     std::cout<<"###RunInfoESAnalyzer::beginJob"<<std::endl;
00055    
00056   }
00057  
00058   */
00059   void
00060    RunInfoESAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context){
00061     using namespace edm::eventsetup;
00062     std::cout<<"###RunInfoESAnalyzer::analyze"<<std::endl;
00063      
00064     // Context is not used.
00065     std::cout <<" I AM IN RUN NUMBER "<<e.id().run() <<std::endl;
00066     std::cout <<" ---EVENT NUMBER "<<e.id().event() <<std::endl;
00067     edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType("RunInfoRcd"));
00068     if( recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
00069       //record not found
00070       std::cout <<"Record \"RunInfoRcd"<<"\" does not exist "<<std::endl;
00071     }
00072     edm::ESHandle<RunInfo> sum;
00073     std::cout<<"got eshandle"<<std::endl;
00074     context.get<RunInfoRcd>().get(sum);
00075     std::cout<<"got context"<<std::endl;
00076     const RunInfo* summary=sum.product();
00077     std::cout<<"got RunInfo* "<< std::endl;
00078 
00079   
00080     std::cout<< "print  result" << std::endl;
00081     summary->printAllValues();
00082     /*  std::vector<std::string> subdet = summary->getSubdtIn();
00083     std::cout<<"subdetector in the run "<< std::endl;
00084     for (size_t i=0; i<subdet.size(); i++){
00085         std::cout<<"--> " << subdet[i] << std::endl;
00086     }
00087     */
00088   }
00089   DEFINE_FWK_MODULE(RunInfoESAnalyzer);
00090 }
00091