CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/CondTools/RunInfo/plugins/RunSummaryESAnalyzer.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/RunSummary.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 RunSummaryESAnalyzer : public edm::EDAnalyzer
00025   {
00026   public:
00027     explicit  RunSummaryESAnalyzer(edm::ParameterSet const& p) 
00028     { 
00029       std::cout<<"RunSummaryESAnalyzer"<<std::endl;
00030     }
00031     explicit  RunSummaryESAnalyzer(int i) 
00032     { std::cout<<"RunSummaryESAnalyzer "<<i<<std::endl; }
00033     virtual ~RunSummaryESAnalyzer() {  
00034       std::cout<<"~RunSummaryESAnalyzer "<<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   RunSummaryESAnalyzer::beginRun(const edm::Run&, const edm::EventSetup& context){
00045     std::cout<<"###RunSummaryESAnalyzer::beginRun"<<std::endl;
00046     edm::ESHandle<RunSummary> RunSummary_lumiarray;
00047     std::cout<<"got eshandle"<<std::endl;
00048     context.get<RunSummaryRcd>().get(RunSummary_lumiarray);
00049     std::cout<<"got data"<<std::endl;
00050   }
00051   
00052   void
00053   RunSummaryESAnalyzer::beginJob(){
00054     std::cout<<"###RunSummaryESAnalyzer::beginJob"<<std::endl;
00055    
00056   }
00057  
00058   */
00059   void
00060    RunSummaryESAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context){
00061     using namespace edm::eventsetup;
00062     std::cout<<"###RunSummaryESAnalyzer::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("RunSummaryRcd"));
00068     if( recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
00069       //record not found
00070       std::cout <<"Record \"RunSummaryRcd"<<"\" does not exist "<<std::endl;
00071     }
00072     edm::ESHandle<RunSummary> sum;
00073     std::cout<<"got eshandle"<<std::endl;
00074     context.get<RunSummaryRcd>().get(sum);
00075     std::cout<<"got context"<<std::endl;
00076     const RunSummary* summary=sum.product();
00077     std::cout<<"got RunSummary* "<< 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   DEFINE_FWK_MODULE(RunSummaryESAnalyzer);
00089 }
00090 
00091