00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <iostream>
00025
00026
00027
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/Run.h"
00030
00031 #include "FWCore/ServiceRegistry/interface/Service.h"
00032 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00033
00034 #include "FWCore/Framework/interface/LuminosityBlock.h"
00035
00036
00037 #include "DataFormats/Common/interface/TriggerResults.h"
00038 #include "DataFormats/Common/interface/HLTenums.h"
00039 #include "FWCore/Framework/interface/TriggerNames.h"
00040
00041
00042 #include "DQM/TrigXMonitor/interface/HLTScalers.h"
00043 #include "DataFormats/Common/interface/Handle.h"
00044 #include "DQMServices/Core/interface/DQMStore.h"
00045 #include "DQMServices/Core/interface/MonitorElement.h"
00046
00047 using namespace edm;
00048
00049
00050
00051 HLTScalers::HLTScalers(const edm::ParameterSet &ps):
00052 dbe_(0),
00053 scalersException_(0),
00054 hltCorrelations_(0),
00055 detailedScalers_(0),
00056 folderName_( ps.getUntrackedParameter< std::string>("dqmFolder",
00057 std::string("HLT/HLTScalers_EvF"))),
00058 nProc_(0),
00059 nLumiBlock_(0),
00060 trigResultsSource_( ps.getParameter< edm::InputTag >("triggerResults")),
00061 resetMe_(true),
00062 monitorDaemon_(ps.getUntrackedParameter<bool>("MonitorDaemon", false)),
00063 nev_(0),
00064 nLumi_(0),
00065 currentRun_(-1)
00066 {
00067
00068
00069
00070 LogDebug("Status") << "HLTScalers: constructor...." ;
00071
00072 dbe_ = Service<DQMStore>().operator->();
00073 dbe_->setVerbose(0);
00074 if (dbe_ ) {
00075 dbe_->setCurrentFolder(folderName_);
00076 }
00077
00078
00079 }
00080
00081
00082
00083 void HLTScalers::beginJob(const edm::EventSetup& c)
00084 {
00085 LogDebug("Status") << "HLTScalers::beginJob()..." << std::endl;
00086
00087 if (dbe_) {
00088 dbe_->setCurrentFolder(folderName_);
00089
00090
00091 nProc_ = dbe_->bookInt("nProcessed");
00092 nLumiBlock_ = dbe_->bookInt("nLumiBlock");
00093
00094
00095
00096
00097 }
00098 return;
00099 }
00100
00101 void HLTScalers::analyze(const edm::Event &e, const edm::EventSetup &c)
00102 {
00103 nProc_->Fill(++nev_);
00104
00105 edm::Handle<TriggerResults> hltResults;
00106 bool b = e.getByLabel(trigResultsSource_, hltResults);
00107 if ( !b ) {
00108 edm::LogInfo("Product") << "getByLabel for TriggerResults failed"
00109 << " with label " << trigResultsSource_;
00110 return;
00111 }
00112 TriggerNames names(*hltResults);
00113
00114
00115 int npath = hltResults->size();
00116
00117
00118 if (resetMe_ ) {
00119 LogInfo("Parameter") << "analyze(): new run. dump path for this evt "
00120 << e.id() << ", \n"
00121 << *hltResults ;
00122
00123 int maxModules = 200;
00124
00125
00126 dbe_->setCurrentFolder(folderName_);
00127
00128
00129 detailedScalers_ = dbe_->book2D("detailedHltScalers", "HLT Scalers",
00130 npath, -0.5, npath-0.5,
00131 maxModules, 0, maxModules-1);
00132 scalers_ = dbe_->book1D("hltScalers", "HLT scalers",
00133 npath, -0.5, npath-0.5);
00134
00135
00136 scalersException_ = dbe_->book1D("hltExceptions", "HLT Exception scalers",
00137 npath, -0.5, npath-0.5);
00138
00139
00140 hltCorrelations_ = dbe_->book2D("hltCorrelations", "HLT Scalers",
00141 npath, -0.5, npath-0.5,
00142 npath, -0.5, npath-0.5);
00143
00144 resetMe_ = false;
00145
00146 int q =0;
00147 for ( TriggerNames::Strings::const_iterator
00148 j = names.triggerNames().begin();
00149 j !=names.triggerNames().end(); ++j ) {
00150
00151 LogDebug("Parameter") << q << ": " << *j ;
00152 char pname[256];
00153 snprintf(pname, 256, "path%03d", q);
00154 ++q;
00155 MonitorElement *e = dbe_->bookString(pname, *j);
00156 hltPathNames_.push_back(e);
00157 }
00158 }
00159
00160
00161
00162 for ( int i = 0; i < npath; ++i ) {
00163
00164
00165 for ( unsigned int j = 0; j < hltResults->index(i); ++j ) {
00166 detailedScalers_->Fill(i,j);
00167 }
00168 if ( hltResults->state(i) == hlt::Pass) {
00169 scalers_->Fill(i);
00170 for ( int j = i + 1; j < npath; ++j ) {
00171 if ( hltResults->state(j) == hlt::Pass) {
00172 hltCorrelations_->Fill(i,j);
00173 hltCorrelations_->Fill(j,i);
00174 }
00175 }
00176 }
00177 else if ( hltResults->state(i) == hlt::Exception) {
00178 scalersException_->Fill(i);
00179 }
00180 }
00181
00182 }
00183
00184
00185 void HLTScalers::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
00186 const edm::EventSetup& c)
00187 {
00188
00189
00190 nLumiBlock_->Fill(lumiSeg.id().luminosityBlock());
00191
00192 LogDebug("Status") << "End of luminosity block." ;
00193
00194 }
00195
00196
00198 void HLTScalers::beginRun(const edm::Run& run, const edm::EventSetup& c)
00199 {
00200 LogDebug("Status") << "HLTScalers::beginRun, run "
00201 << run.id();
00202 if ( currentRun_ != int(run.id().run()) ) {
00203 resetMe_ = true;
00204 currentRun_ = run.id().run();
00205 }
00206 }
00207
00209 void HLTScalers::endRun(const edm::Run& run, const edm::EventSetup& c)
00210 {
00211 LogDebug("Status") << "HLTScalers::endRun , run "
00212 << run.id();
00213 if ( currentRun_ != int(run.id().run()) ) {
00214 resetMe_ = true;
00215 currentRun_ = run.id().run();
00216 }
00217 }