CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/CondTools/RunInfo/plugins/L1TriggerScalerESAnalyzer.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/L1TriggerScaler.h"
00013 
00014 #include "CondFormats/DataRecord/interface/L1TriggerScalerRcd.h"
00015 
00016 using namespace std;
00017 
00018 
00019 
00020 
00021 
00022 namespace edmtest
00023 {
00024   class L1TriggerScalerESAnalyzer : public edm::EDAnalyzer
00025   {
00026   public:
00027     explicit  L1TriggerScalerESAnalyzer(edm::ParameterSet const& p) 
00028     { 
00029       std::cout<<"L1TriggerScalerESAnalyzer"<<std::endl;
00030     }
00031     explicit  L1TriggerScalerESAnalyzer(int i) 
00032     { std::cout<<"L1TriggerScalerESAnalyzer "<<i<<std::endl; }
00033     virtual ~L1TriggerScalerESAnalyzer() {  
00034       std::cout<<"~L1TriggerScalerESAnalyzer "<<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   L1TriggerScalerESAnalyzer::beginRun(const edm::Run&, const edm::EventSetup& context){
00045     std::cout<<"###L1TriggerScalerESAnalyzer::beginRun"<<std::endl;
00046     edm::ESHandle<L1TriggerScaler> L1TriggerScaler_lumiarray;
00047     std::cout<<"got eshandle"<<std::endl;
00048     context.get<L1TriggerScalerRcd>().get(L1TriggerScaler_lumiarray);
00049     std::cout<<"got data"<<std::endl;
00050   }
00051   
00052   void
00053   L1TriggerScalerESAnalyzer::beginJob(){
00054     std::cout<<"###L1TriggerScalerESAnalyzer::beginJob"<<std::endl;
00055    
00056   }
00057  
00058  
00059   void
00060    L1TriggerScalerESAnalyzer::analyze(const edm::Event& e, const edm::EventSetup& context){
00061     using namespace edm::eventsetup;
00062     std::cout<<"###L1TriggerScalerESAnalyzer::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("L1TriggerScalerRcd"));
00068     if( recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
00069       //record not found
00070       std::cout <<"Record \"L1TriggerScalerRcd"<<"\" does not exist "<<std::endl;
00071     }
00072     edm::ESHandle<L1TriggerScaler> l1tr;
00073     std::cout<<"got eshandle"<<std::endl;
00074     context.get<L1TriggerScalerRcd>().get(l1tr);
00075     std::cout<<"got context"<<std::endl;
00076     const L1TriggerScaler* l1lumiscaler=l1tr.product();
00077     std::cout<<"got L1TriggerScaler* "<< std::endl;
00078 
00079     /* let's user the printValues method
00080     std::cout<< "print result" << std::endl;
00081     l1lumiscaler->printAllValues();
00082     std::cout<< "print finished" << std::endl;
00083     */
00084 std::cout<< "print  result" << std::endl;
00085     l1lumiscaler->printRunValue();
00086     l1lumiscaler->printLumiSegmentValues();
00087     l1lumiscaler->printFormat();
00088     l1lumiscaler->printGTAlgoCounts();
00089     l1lumiscaler->printGTAlgoRates();
00090     l1lumiscaler->printGTAlgoPrescaling();
00091     l1lumiscaler->printGTTechCounts();
00092     l1lumiscaler->printGTTechRates();
00093     l1lumiscaler->printGTTechPrescaling();
00094     l1lumiscaler->printGTPartition0TriggerCounts();
00095     l1lumiscaler->printGTPartition0TriggerRates();
00096     l1lumiscaler->printGTPartition0DeadTime();
00097     l1lumiscaler->printGTPartition0DeadTimeRatio();
00098     std::cout<<  "print  finished" << std::endl;
00099  
00100 
00101 
00102    /*
00103     for(std::vector<L1TriggerScaler::Lumi>::const_iterator it=l1lumiscaler->m_run.begin(); it!=l1lumiscaler->m_run.end(); ++it){
00104       std::cout << "  run:  " <<it->m_rn<<
00105         "\nlumisegment: "  << it->m_lumisegment<<std::endl;  
00106 
00107 
00108 
00109       for(size_t i=0; i<it->m_GTAlgoRates.size(); i++ ){ 
00110         std::cout << "m_GTAlgoRates["<<i<<"] = "<< it->m_GTAlgoRates[i]<<std::endl;  
00111       }
00112      for(size_t i=0; i<it->m_GTAlgoPrescaling.size(); i++ ){ 
00113        std::cout << "m_GTAlgoPrescaling["<<i<<"] = "<< it->m_GTAlgoPrescaling[i]<<std::endl;  
00114       } 
00115 for(size_t i=0; i<it->m_GTTechCounts.size(); i++ ){ 
00116        std::cout << " m_GTTechCounts["<<i<<"] = "<< it->m_GTTechCounts[i]<<std::endl;  
00117       } 
00118 
00119 for(size_t i=0; i<it->m_GTTechRates.size(); i++ ){ 
00120        std::cout << " m_GTTechRates["<<i<<"] = "<< it->m_GTTechRates[i]<<std::endl;  
00121       } 
00122 for(size_t i=0; i<it->m_GTTechPrescaling.size(); i++ ){ 
00123        std::cout << " m_GTTechPrescaling["<<i<<"] = "<< it->m_GTTechPrescaling[i]<<std::endl;  
00124       } 
00125 for(size_t i=0; i<it->m_GTPartition0TriggerCounts.size(); i++ ){ 
00126        std::cout << " m_GTPartition0TriggerCounts["<<i<<"] = "<< it->m_GTPartition0TriggerCounts[i]<<std::endl;  
00127       } 
00128 for(size_t i=0; i<it->m_GTPartition0TriggerRates.size(); i++ ){ 
00129        std::cout << " m_GTPartition0TriggerRates["<<i<<"] = "<< it->m_GTPartition0TriggerRates[i]<<std::endl;  
00130       } 
00131 
00132 for(size_t i=0; i<it->m_GTPartition0DeadTime.size(); i++ ){ 
00133        std::cout << " m_GTPartition0DeadTime["<<i<<"] = "<< it->m_GTPartition0DeadTime[i]<<std::endl;  
00134       }
00135 for(size_t i=0; i<it->m_GTPartition0DeadTimeRatio.size(); i++ ){ 
00136        std::cout << " m_GTPartition0DeadTimeRatio["<<i<<"] = "<< it->m_GTPartition0DeadTimeRatio[i]<<std::endl;  
00137       }
00138    }
00139     */
00140   }
00141   DEFINE_FWK_MODULE(L1TriggerScalerESAnalyzer);
00142 }
00143 
00144