00001 // -*- C++ -*- 00002 // 00003 // Package: MuonTriggerRateTimeAnalyzer 00004 // Class: MuonTriggerRateTimeAnalyzer 00005 // 00013 // 00014 // Original Author: Muriel Vander Donckt 00015 // Created: Tue Jul 24 12:17:12 CEST 2007 00016 // $Id: MuonTriggerRateTimeAnalyzer.cc,v 1.11 2009/01/06 19:22:27 klukas Exp $ 00017 // 00018 // 00019 00020 // system include files 00021 #include <memory> 00022 00023 // user include files 00024 #include "FWCore/Framework/interface/Frameworkfwd.h" 00025 #include "FWCore/Framework/interface/EDAnalyzer.h" 00026 #include "FWCore/Framework/interface/Event.h" 00027 #include "FWCore/Framework/interface/MakerMacros.h" 00028 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00029 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00030 00031 #include "HLTriggerOffline/Muon/interface/HLTMuonGenericRate.h" 00032 #include "HLTriggerOffline/Muon/interface/HLTMuonOverlap.h" 00033 00034 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h" 00035 00036 #include "TFile.h" 00037 #include "TDirectory.h" 00038 00039 class MuonTriggerRateTimeAnalyzer : public edm::EDAnalyzer { 00040 00041 public: 00042 explicit MuonTriggerRateTimeAnalyzer(const edm::ParameterSet&); 00043 ~MuonTriggerRateTimeAnalyzer(); 00044 00045 private: 00046 virtual void beginJob(const edm::EventSetup&) ; 00047 virtual void analyze(const edm::Event&, const edm::EventSetup&); 00048 virtual void endJob() ; 00049 00050 int theNumberOfTriggers; 00051 std::vector<HLTMuonGenericRate*> theTriggerAnalyzers; 00052 HLTMuonOverlap *theOverlapAnalyzer; 00053 00054 }; 00055 00056 using namespace std; 00057 using namespace edm; 00058 00059 00060 00061 MuonTriggerRateTimeAnalyzer::MuonTriggerRateTimeAnalyzer(const ParameterSet& pset) 00062 { 00063 vector<string> triggerNames = pset.getParameter< vector<string> > 00064 ("TriggerNames"); 00065 string theHltProcessName = pset.getParameter<string>("HltProcessName"); 00066 00067 HLTConfigProvider hltConfig; 00068 hltConfig.init(theHltProcessName); 00069 vector<string> validTriggerNames = hltConfig.triggerNames(); 00070 00071 for( size_t i = 0; i < triggerNames.size(); i++) { 00072 bool isValidTriggerName = false; 00073 for ( size_t j = 0; j < validTriggerNames.size(); j++ ) 00074 if ( triggerNames[i] == validTriggerNames[j] ) isValidTriggerName = true; 00075 if ( !isValidTriggerName ) {} 00076 else { 00077 vector<string> moduleNames = hltConfig.moduleLabels( triggerNames[i] ); 00078 HLTMuonGenericRate *analyzer; 00079 analyzer = new HLTMuonGenericRate( pset, triggerNames[i], moduleNames ); 00080 theTriggerAnalyzers.push_back( analyzer ); 00081 } 00082 } 00083 theOverlapAnalyzer = new HLTMuonOverlap( pset ); 00084 00085 theNumberOfTriggers = theTriggerAnalyzers.size(); 00086 } 00087 00088 00089 MuonTriggerRateTimeAnalyzer::~MuonTriggerRateTimeAnalyzer() 00090 { 00091 vector<HLTMuonGenericRate *>::iterator thisAnalyzer; 00092 for ( thisAnalyzer = theTriggerAnalyzers.begin(); 00093 thisAnalyzer != theTriggerAnalyzers.end(); 00094 ++thisAnalyzer ) 00095 { 00096 delete *thisAnalyzer; 00097 } 00098 theTriggerAnalyzers.clear(); 00099 delete theOverlapAnalyzer; 00100 } 00101 00102 00103 // 00104 // member functions 00105 // 00106 00107 void 00108 MuonTriggerRateTimeAnalyzer::analyze(const Event& iEvent, const EventSetup& iSetup) 00109 { 00110 vector<HLTMuonGenericRate *>::iterator thisAnalyzer; 00111 for ( thisAnalyzer = theTriggerAnalyzers.begin(); 00112 thisAnalyzer != theTriggerAnalyzers.end(); ++thisAnalyzer ) 00113 { 00114 (*thisAnalyzer)->analyze(iEvent); 00115 } 00116 theOverlapAnalyzer ->analyze(iEvent); 00117 } 00118 00119 00120 00121 void 00122 MuonTriggerRateTimeAnalyzer::beginJob(const EventSetup&) 00123 { 00124 vector<HLTMuonGenericRate *>::iterator thisAnalyzer; 00125 for ( thisAnalyzer = theTriggerAnalyzers.begin(); 00126 thisAnalyzer != theTriggerAnalyzers.end(); 00127 ++thisAnalyzer ) 00128 { 00129 (*thisAnalyzer)->begin(); 00130 } 00131 theOverlapAnalyzer ->begin(); 00132 } 00133 00134 00135 00136 void 00137 MuonTriggerRateTimeAnalyzer::endJob() { 00138 vector<HLTMuonGenericRate *>::iterator thisAnalyzer; 00139 for ( thisAnalyzer = theTriggerAnalyzers.begin(); 00140 thisAnalyzer != theTriggerAnalyzers.end(); 00141 ++thisAnalyzer ) 00142 { 00143 (*thisAnalyzer)->finish(); 00144 } 00145 theOverlapAnalyzer ->finish(); 00146 } 00147 00148 //define this as a plug-in 00149 DEFINE_FWK_MODULE(MuonTriggerRateTimeAnalyzer);