Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <memory>
00022
00023
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/Run.h"
00028 #include "FWCore/Framework/interface/EventSetup.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032
00033 #include "DQMOffline/Trigger/interface/HLTMuonMatchAndPlot.h"
00034 #include "DQMOffline/Trigger/interface/HLTTopPlotter.h"
00035
00036
00037 #include "HLTrigger/HLTcore/interface/HLTConfigProvider.h"
00038 #include "FWCore/ServiceRegistry/interface/Service.h"
00039
00040 #include "CommonTools/Utils/interface/StringCutObjectSelector.h"
00041
00042 #include "TFile.h"
00043 #include "TDirectory.h"
00044
00045
00046 using namespace std;
00047 using namespace edm;
00048 using reco::Muon;
00049
00050
00051
00052 class TopTrigAnalyzer : public edm::EDAnalyzer {
00053
00054 public:
00055 explicit TopTrigAnalyzer(const edm::ParameterSet&);
00056 ~TopTrigAnalyzer();
00057
00058 private:
00059 virtual void beginJob() ;
00060 virtual void beginRun(edm::Run const& currentRun, edm::EventSetup const& currentEventSetup);
00061 virtual void analyze(const edm::Event&, const edm::EventSetup&);
00062 virtual void endJob() ;
00063
00064 virtual void endRun (const edm::Run& r, const edm::EventSetup& c);
00065 int theNumberOfTriggers;
00066
00067 std::vector<HLTMuonMatchAndPlot*> theTriggerAnalyzers;
00068 std::vector<HLTTopPlotter*> theTopPlotters;
00069
00070
00071
00072
00073 bool weHaveProcessedTheFirstRun;
00074 bool useDQMStore;
00075
00076
00077 vector<string> triggerNames;
00078 string theHltProcessName;
00079 vector<edm::ParameterSet> customCollection;
00080
00081 const ParameterSet& initialPset;
00082
00083
00084
00085 };
00086
00087
00088
00089 TopTrigAnalyzer::TopTrigAnalyzer(const ParameterSet& pset) :
00090 initialPset(pset)
00091 {
00092
00093
00094
00095 LogTrace ("HLTMuonVal") << "\n\n Inside MuonTriggerRate Constructor\n\n";
00096
00097 triggerNames = initialPset.getParameter< vector<string> >
00098 ("TriggerNames");
00099 theHltProcessName = initialPset.getParameter<string>("HltProcessName");
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 customCollection = initialPset.getParameter<vector<edm::ParameterSet> > ("customCollection");
00113 useDQMStore = initialPset.getUntrackedParameter<bool>("DQMStore", false);
00114
00115
00116
00117
00118
00119
00120 weHaveProcessedTheFirstRun = false;
00121
00122 LogTrace("HLTMuonVal") << "Finished with the constructor " << endl;
00123
00124 }
00125
00126
00127 void TopTrigAnalyzer::beginRun(Run const& currentRun, EventSetup const& currentEventSetup) {
00128
00129
00130 if(!weHaveProcessedTheFirstRun) {
00131 weHaveProcessedTheFirstRun = true;
00132
00133 vector<edm::ParameterSet>::iterator iPSet;
00134
00135 LogTrace ("HLTMuonVal") << "customCollection is a vector of size = " << customCollection.size() << std::endl
00136 << "looping over entries... and storing descriptions in a root file" << std::endl;
00137
00138
00139 DQMStore * dbe_ = 0;
00140 if ( useDQMStore ) {
00141 dbe_ = Service<DQMStore>().operator->();
00142 dbe_->setVerbose(0);
00143 }
00144
00146
00147
00148
00150
00151 vector < MuonSelectionStruct > customSelectors;
00152 vector < string > customNames;
00153
00154 for ( iPSet = customCollection.begin();
00155 iPSet != customCollection.end();
00156 iPSet++) {
00157 string customCuts = iPSet->getUntrackedParameter<string> ("recoCuts");
00158 string customName = iPSet->getUntrackedParameter<string> ("collectionName");
00159 string hltCuts = iPSet->getUntrackedParameter<string> ("hltCuts");
00160 string targetTrackCollection = iPSet->getUntrackedParameter<string> ("trackCollection");
00161 double customD0Cut = iPSet->getUntrackedParameter<double> ("d0cut");
00162 double customZ0Cut = iPSet->getUntrackedParameter<double> ("z0cut");
00163
00164
00165
00166 double customChi2Cut = iPSet->getUntrackedParameter<double> ("chi2cut", 30.0);
00167 int customNHitsCut = iPSet->getUntrackedParameter<int> ("nHits", 10);
00168
00169
00170 vector<string> requiredTriggers = iPSet->getUntrackedParameter< vector<string> > ("requiredTriggers");
00171
00172 LogTrace("HLTMuonVal") << "customTargetCollection = " << customName << std::endl
00173 << "customCuts = " << customCuts << std::endl
00174 << "targetTrackCollection = " << targetTrackCollection << std::endl
00175 << "d0 cut = " << customD0Cut << std::endl
00176 << "z0 cut = " << customZ0Cut << std:: endl
00177 << "nHits cut = " << customNHitsCut << std::endl
00178 << "chi2 cut = " << customChi2Cut <<std::endl;
00179
00180 if (dbe_) {
00181
00182 string description = customName + ", reco cuts = " + customCuts
00183 + ", hlt cuts = " + hltCuts + ", trackCollection = " + targetTrackCollection
00184 + ", required triggers, ";
00185
00186
00187 for (vector <string>::const_iterator trigit = requiredTriggers.begin();
00188 trigit != requiredTriggers.end();
00189 trigit++){
00190 description += (*trigit) + ", ";
00191 }
00192
00193
00194 ostringstream ossd0, ossz0, osschi2, osshits;
00195
00196
00197 ossd0 << customD0Cut;
00198 ossz0 << customZ0Cut;
00199 osschi2 << customChi2Cut;
00200 osshits << customNHitsCut;
00201
00202 description += "|d0| < " + ossd0.str() + ", |z0| < " + ossz0.str()
00203 + ", chi2 < " + osschi2.str() + ", nHits > " + osshits.str();
00204
00205 LogTrace ("HLTMuonVal") << "Storing description = " << description << endl;
00206
00207 dbe_->setCurrentFolder("HLT/Muon/Distributions/");
00208
00209 dbe_->bookString (customName, description);
00210
00211
00212
00213 }
00214
00215
00216 StringCutObjectSelector<Muon> tempRecoSelector(customCuts);
00217 StringCutObjectSelector<trigger::TriggerObject> tempHltSelector(hltCuts);
00218
00219
00220 MuonSelectionStruct tempStruct(tempRecoSelector, tempHltSelector,
00221 customName, customD0Cut, customZ0Cut,
00222
00223 targetTrackCollection, requiredTriggers);
00224
00225
00226 customNames.push_back ( customName);
00227 customSelectors.push_back(tempStruct);
00228 }
00229
00230
00231
00232
00233
00234 HLTConfigProvider hltConfig;
00235
00236
00237
00238
00239
00240 bool hltConfigChanged;
00241 bool hltConfigInitSuccess = hltConfig.init(currentRun, currentEventSetup, theHltProcessName, hltConfigChanged);
00242
00243 vector<string> validTriggerNames;
00244
00245 if (hltConfigInitSuccess)
00246 validTriggerNames = hltConfig.triggerNames();
00247
00248 if (validTriggerNames.size() < 1) {
00249 LogTrace ("HLTMuonVal") << endl << endl << endl
00250 << "---> WARNING: The HLT Config Provider gave you an empty list of valid trigger names" << endl
00251 << "Could be a problem with the HLT Process Name (you provided " << theHltProcessName <<")" << endl
00252 << "W/o valid triggers we can't produce plots, exiting..."
00253 << endl << endl << endl;
00254 return;
00255 }
00256
00257 vector<string>::const_iterator iDumpName;
00258 unsigned int numTriggers = 0;
00259 for (iDumpName = validTriggerNames.begin();
00260 iDumpName != validTriggerNames.end();
00261 iDumpName++) {
00262
00263 LogTrace ("HLTMuonVal") << "Trigger " << numTriggers
00264 << " is called " << (*iDumpName)
00265 << endl;
00266 numTriggers++;
00267 }
00268
00269
00271
00272
00273
00275
00276 vector<MuonSelectionStruct>::iterator iMuonSelector;
00277 vector<string>::iterator iName = customNames.begin();
00278 for ( iMuonSelector = customSelectors.begin();
00279 iMuonSelector != customSelectors.end();
00280 iMuonSelector++) {
00281
00282 for( size_t i = 0; i < triggerNames.size(); i++) {
00283 bool isValidTriggerName = false;
00284 for ( size_t j = 0; j < validTriggerNames.size(); j++ )
00285 if ( triggerNames[i] == validTriggerNames[j] ) isValidTriggerName = true;
00286 if ( !isValidTriggerName ) {}
00287 else {
00288 vector<string> moduleNames = hltConfig.moduleLabels( triggerNames[i] );
00289
00290
00291 HLTTopPlotter * tempTop;
00292 tempTop = new HLTTopPlotter ( initialPset, triggerNames[i], moduleNames, (*iMuonSelector), (*iName), validTriggerNames, currentRun, currentEventSetup);
00293
00294 theTopPlotters.push_back (tempTop);
00295 }
00296 }
00297 iName++;
00298 }
00299
00300
00301
00302 theNumberOfTriggers = theTopPlotters.size();
00303
00304
00305
00306
00307
00308 vector<HLTTopPlotter *>::iterator thisAnalyzer;
00309
00310
00311
00312 LogTrace ("HLTMuonVal") << "Inside begin job " << endl
00313 << "Looping over analyzers"
00314 << endl;
00315
00316 for ( thisAnalyzer = theTopPlotters.begin();
00317 thisAnalyzer != theTopPlotters.end();
00318 ++thisAnalyzer )
00319 {
00320 (*thisAnalyzer)->begin();
00321 }
00322
00323
00324
00325 }
00326
00327
00328 }
00329
00330
00331 TopTrigAnalyzer::~TopTrigAnalyzer()
00332 {
00333
00334
00335
00336
00337
00338
00339
00340
00341 vector<HLTTopPlotter *>::iterator iTopAna;
00342 for ( iTopAna = theTopPlotters.begin();
00343 iTopAna != theTopPlotters.end();
00344 ++iTopAna )
00345 {
00346 delete *iTopAna;
00347 }
00348
00349 theTopPlotters.clear();
00350
00351
00352 }
00353
00354
00355
00356
00357
00358
00359 void
00360 TopTrigAnalyzer::analyze(const Event& iEvent, const EventSetup& iSetup)
00361 {
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373 vector<HLTTopPlotter *>::iterator iTopAna;
00374 for ( iTopAna = theTopPlotters.begin();
00375 iTopAna != theTopPlotters.end();
00376 ++iTopAna )
00377 {
00378 (*iTopAna)->analyze(iEvent);
00379 }
00380
00381
00382
00383
00384 }
00385
00386
00387
00388 void
00389 TopTrigAnalyzer::beginJob()
00390 {
00391
00392
00393
00394 LogTrace ("HLTMuonVal") << "Inside begin job " << endl
00395 << "Looping over analyzers"
00396 << endl;
00397
00398
00399
00400 }
00401
00402 void
00403 TopTrigAnalyzer::endRun( const edm::Run& theRun, const edm::EventSetup& theEventSetup ) {
00404 vector<HLTTopPlotter *>::iterator thisAnalyzer;
00405
00406
00407 LogTrace ("HLTMuonVal") << "Inside end job, looping over analyzers"
00408 << endl;
00409 for ( thisAnalyzer = theTopPlotters.begin();
00410 thisAnalyzer != theTopPlotters.end();
00411 ++thisAnalyzer )
00412 {
00413 (*thisAnalyzer)->endRun(theRun, theEventSetup);
00414 }
00415
00416 }
00417
00418
00419 void
00420 TopTrigAnalyzer::endJob() {
00421 vector<HLTTopPlotter *>::iterator thisAnalyzer;
00422
00423
00424 LogTrace ("HLTMuonVal") << "Inside end job, looping over analyzers"
00425 << endl;
00426 for ( thisAnalyzer = theTopPlotters.begin();
00427 thisAnalyzer != theTopPlotters.end();
00428 ++thisAnalyzer )
00429 {
00430 (*thisAnalyzer)->finish();
00431 }
00432
00433 }
00434
00435
00436 DEFINE_FWK_MODULE(TopTrigAnalyzer);