00001
00002
00003 #include "TMath.h"
00004 #include "DQM/HLTEvF/interface/TrigResRateMon.h"
00005 #include "FWCore/Common/interface/TriggerNames.h"
00006
00007 #include <map>
00008 #include <utility>
00009
00010
00011 using namespace edm;
00012 using namespace trigger;
00013 using namespace std;
00014
00015 TrigResRateMon::TrigResRateMon(const edm::ParameterSet& iConfig): currentRun_(-99)
00016 {
00017
00018 LogDebug("TrigResRateMon") << "constructor...." ;
00019
00020 fIsSetup = false;
00021
00022 dbe_ = Service < DQMStore > ().operator->();
00023 if ( ! dbe_ ) {
00024 LogInfo("TrigResRateMon") << "unabel to get DQMStore service?";
00025 }
00026 if (iConfig.getUntrackedParameter < bool > ("DQMStore", false)) {
00027 dbe_->setVerbose(0);
00028 }
00029
00030 dirname_ = iConfig.getUntrackedParameter("dirname", std::string("HLT/TrigResults/"));
00031
00032
00033 if (dbe_ != 0 ) {
00034 dbe_->setCurrentFolder(dirname_);
00035 }
00036
00037 doCombineRuns_ = iConfig.getUntrackedParameter<bool>("doCombineRuns", false);
00038 doVBTFMuon_ = iConfig.getUntrackedParameter<bool>("doVBTFMuon", true);
00039
00040 processname_ = iConfig.getParameter<std::string>("processname");
00041 fCustomBXPath = iConfig.getUntrackedParameter<std::string>("customBXPath", std::string("HLT_MinBiasBSC"));
00042
00043 referenceBX_ = iConfig.getUntrackedParameter<unsigned int>("referenceBX",51);
00044 Nbx_ = iConfig.getUntrackedParameter<unsigned int>("Nbx",3564);
00045
00046
00047 ptMin_ = iConfig.getUntrackedParameter<double>("ptMin",0.);
00048 ptMax_ = iConfig.getUntrackedParameter<double>("ptMax",1000.);
00049 nBins_ = iConfig.getUntrackedParameter<unsigned int>("Nbins",20);
00050 nBins2D_ = iConfig.getUntrackedParameter<unsigned int>("Nbins2D",40);
00051 dRMax_ = iConfig.getUntrackedParameter<double>("dRMax",1.0);
00052 dRMaxElectronMuon_ = iConfig.getUntrackedParameter<double>("dRMaxElectronMuon",0.3);
00053 nBinsDR_ = iConfig.getUntrackedParameter<unsigned int>("NbinsDR",10);
00054 nBinsOneOverEt_ = iConfig.getUntrackedParameter<unsigned int>("NbinsOneOverEt",10000);
00055 nLS_ = iConfig.getUntrackedParameter<unsigned int>("NLuminositySegments",10);
00056 LSsize_ = iConfig.getUntrackedParameter<double>("LuminositySegmentSize",23);
00057 thresholdFactor_ = iConfig.getUntrackedParameter<double>("thresholdFactor",1.0);
00058
00059
00060 plotAll_ = iConfig.getUntrackedParameter<bool>("plotAll", false);
00061
00062 std::vector<edm::ParameterSet> paths =
00063 iConfig.getParameter<std::vector<edm::ParameterSet> >("paths");
00064
00065 for(std::vector<edm::ParameterSet>::iterator pathconf = paths.begin() ; pathconf != paths.end(); pathconf++) {
00066
00067 custompathnamepairs_.push_back(
00068 make_pair(
00069 pathconf->getParameter<std::string>("pathname"),
00070 pathconf->getParameter<std::string>("denompathname")
00071 )
00072 );
00073
00074 }
00075
00076 if (hltPaths_.size() > 0)
00077 {
00078
00079 scalersSelect = dbe_->book1D("selectedScalers","Selected Scalers", hltPaths_.size(), 0.0, (double)hltPaths_.size());
00080
00081 }
00082
00083 triggerSummaryLabel_ = iConfig.getParameter<edm::InputTag>("triggerSummaryLabel");
00084 triggerResultsLabel_ = iConfig.getParameter<edm::InputTag>("triggerResultsLabel");
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 sumEtMin_ = iConfig.getUntrackedParameter<double>("sumEtMin",10.0);
00137
00138
00139 dxyCut_ = iConfig.getUntrackedParameter<double>("DxyCut", 0.2);
00140 normalizedChi2Cut_ = iConfig.getUntrackedParameter<double>("NormalizedChi2Cut", 10.);
00141 trackerHitsCut_ = iConfig.getUntrackedParameter<int>("TrackerHitsCut", 11);
00142 pixelHitsCut_ = iConfig.getUntrackedParameter<int>("PixelHitsCut", 1);
00143 muonHitsCut_ = iConfig.getUntrackedParameter<int>("MuonHitsCut", 1);
00144 isAlsoTrackerMuon_ = iConfig.getUntrackedParameter<bool>("IsAlsoTrackerMuon", true);
00145 nMatchesCut_ = iConfig.getUntrackedParameter<int>("NMatchesCut", 2);
00146
00147 specialPaths_ = iConfig.getParameter<std::vector<std::string > >("SpecialPaths");
00148
00149 pathsSummaryFolder_ = iConfig.getUntrackedParameter ("pathsSummaryFolder",std::string("HLT/TrigResults/PathsSummary/HLT Counts/"));
00150 pathsSummaryStreamsFolder_ = iConfig.getUntrackedParameter ("pathsSummaryFolder",std::string("HLT/TrigResults/PathsSummary/"));
00151
00152 pathsSummaryHLTCorrelationsFolder_ = iConfig.getUntrackedParameter ("hltCorrelationsFolder",std::string("HLT/TrigResults/PathsSummary/HLT Correlations/"));
00153 pathsSummaryFilterCountsFolder_ = iConfig.getUntrackedParameter ("filterCountsFolder",std::string("HLT/TrigResults/PathsSummary/Filters Counts/"));
00154
00155 pathsSummaryHLTPathsPerLSFolder_ = iConfig.getUntrackedParameter ("individualPathsPerLSFolder",std::string("HLT/TrigResults/PathsSummary/HLT LS/"));
00156 pathsIndividualHLTPathsPerLSFolder_ = iConfig.getUntrackedParameter ("individualPathsPerLSFolder",std::string("HLT/TrigResults/PathsSummary/HLT LS/Paths/"));
00157 pathsSummaryHLTPathsPerBXFolder_ = iConfig.getUntrackedParameter ("individualPathsPerBXFolder",std::string("HLT/TrigResults/PathsSummary/HLT BX/"));
00158
00159 fLumiFlag = true;
00160 ME_HLTAll_LS = NULL;
00161 ME_HLT_BX = NULL;
00162 ME_HLT_CUSTOM_BX = NULL;
00163
00164
00165
00166 recHitsEBTag_ = iConfig.getUntrackedParameter<edm::InputTag>("RecHitsEBTag",edm::InputTag("reducedEcalRecHitsEB"));
00167 recHitsEETag_ = iConfig.getUntrackedParameter<edm::InputTag>("RecHitsEETag",edm::InputTag("reducedEcalRecHitsEE"));
00168
00169
00170 }
00171
00172
00173 TrigResRateMon::~TrigResRateMon()
00174 {
00175
00176
00177
00178
00179 }
00180
00181
00182
00183
00184
00185
00186
00187 void
00188 TrigResRateMon::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00189 {
00190
00191
00192
00193 using namespace edm;
00194 using namespace trigger;
00195 ++nev_;
00196 LogDebug("TrigResRateMon")<< " analyze...." ;
00197
00198
00199
00200
00201 edm::Handle<TriggerResults> triggerResults;
00202 iEvent.getByLabel(triggerResultsLabel_,triggerResults);
00203 if(!triggerResults.isValid()) {
00204 edm::InputTag triggerResultsLabelFU(triggerResultsLabel_.label(),triggerResultsLabel_.instance(), "FU");
00205 iEvent.getByLabel(triggerResultsLabelFU,triggerResults);
00206 if(!triggerResults.isValid()) {
00207 edm::LogInfo("TrigResRateMon") << "TriggerResults not found, "
00208 "skipping event";
00209 return;
00210 }
00211 }
00212 triggerResults_ = triggerResults;
00213 const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults);
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231 fillHltMatrix(triggerNames);
00232
00233 return;
00234
00235
00236
00237
00238 for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) {
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294 }
00295
00296 }
00297
00298
00299
00300
00301 void
00302 TrigResRateMon::beginJob()
00303 {
00304 nev_ = 0;
00305 DQMStore *dbe = 0;
00306 dbe = Service<DQMStore>().operator->();
00307
00308 if (dbe) {
00309 dbe->setCurrentFolder(dirname_);
00310 }
00311
00312
00313 MonitorElement* reportSummaryME = dbe->book1D("reportSummaryMap","report Summary Map",2,0,2);
00314 if(reportSummaryME) reportSummaryME->Fill(1);
00315
00316
00317 }
00318
00319
00320 void
00321 TrigResRateMon::endJob()
00322 {
00323 LogInfo("TrigResRateMon") << "analyzed " << nev_ << " events";
00324 return;
00325 }
00326
00327
00328
00329 void TrigResRateMon::beginRun(const edm::Run& run, const edm::EventSetup& c)
00330 {
00331
00332 LogDebug("TrigResRateMon") << "beginRun, run " << run.id();
00333
00334 if(fIsSetup) return;
00335
00336
00337 bool changed=false;
00338
00339 if (!hltConfig_.init(run, c, processname_, changed)) {
00340
00341 processname_ = "FU";
00342
00343 if (!hltConfig_.init(run, c, processname_, changed)){
00344
00345 LogDebug("TrigResRateMon") << "HLTConfigProvider failed to initialize.";
00346
00347 }
00348
00349
00350
00351
00352 }
00353
00354 if (1) {
00355
00356 DQMStore *dbe = 0;
00357 dbe = Service<DQMStore>().operator->();
00358
00359 if (dbe) {
00360 dbe->setCurrentFolder(dirname_);
00361 }
00362
00363
00364 const unsigned int n(hltConfig_.size());
00365
00366
00367 if (plotAll_){
00368
00369 for (unsigned int j=0; j!=n; ++j) {
00370
00371 std::string pathname = hltConfig_.triggerName(j);
00372
00373 string l1pathname = getL1ConditionModuleName(pathname);
00374
00375 int l1ModuleIndex = hltConfig_.moduleIndex(pathname, l1pathname);
00376
00377 int objectType = getTriggerTypeParsePathName(pathname);
00378
00379 for (unsigned int i=0; i!=n; ++i) {
00380
00381 std::string denompathname = hltConfig_.triggerName(i);
00382 int denomobjectType = getTriggerTypeParsePathName(denompathname);
00383
00384
00385
00386 std::string filtername("dummy");
00387 float ptMin = 0.0;
00388 float ptMax = 100.0;
00389 if (plotAll_ && denomobjectType == objectType && objectType != 0) {
00390
00391 int hltThreshold = getThresholdFromName(pathname);
00392 int l1Threshold = getThresholdFromName(l1pathname);
00393 hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, l1ModuleIndex, filtername, processname_, objectType, ptMin, ptMax, hltThreshold, l1Threshold));
00394
00395 }
00396
00397 }
00398 }
00399
00400 }
00401 else {
00402
00403
00404 for (unsigned int i=0; i!=n; ++i) {
00405
00406 std::string denompathname = "";
00407 std::string pathname = hltConfig_.triggerName(i);
00408
00409 int objectType = getTriggerTypeParsePathName(pathname);
00410
00411 string l1pathname = getL1ConditionModuleName(pathname);
00412 int l1ModuleIndex = hltConfig_.moduleIndex(pathname, l1pathname);
00413
00414 std::string filtername("dummy");
00415 float ptMin = 0.0;
00416 float ptMax = 100.0;
00417
00418 if (objectType == trigger::TriggerPhoton) ptMax = 100.0;
00419 if (objectType == trigger::TriggerElectron) ptMax = 100.0;
00420 if (objectType == trigger::TriggerMuon) ptMax = 150.0;
00421 if (objectType == trigger::TriggerTau) ptMax = 100.0;
00422 if (objectType == trigger::TriggerJet) ptMax = 300.0;
00423 if (objectType == trigger::TriggerBJet) ptMax = 300.0;
00424 if (objectType == trigger::TriggerMET) ptMax = 300.0;
00425 if (objectType == trigger::TriggerTET) ptMax = 300.0;
00426 if (objectType == trigger::TriggerTrack) ptMax = 100.0;
00427
00428
00429 if (objectType != -1 && pathname.find("FinalPath") == std::string::npos){
00430
00431 int hltThreshold = getThresholdFromName(pathname);
00432 int l1Threshold = getThresholdFromName(l1pathname);
00433
00434 hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, l1ModuleIndex, filtername, processname_, objectType, ptMin, ptMax, hltThreshold, l1Threshold));
00435
00436 hltPathsDiagonal_.push_back(PathInfo(denompathname, pathname, l1pathname, l1ModuleIndex, filtername, processname_, objectType, ptMin, ptMax, hltThreshold, l1Threshold));
00437
00438 }
00439
00440 }
00441
00442
00443
00444
00445 for (std::vector<std::pair<std::string, std::string> >::iterator custompathnamepair = custompathnamepairs_.begin(); custompathnamepair != custompathnamepairs_.end(); ++custompathnamepair) {
00446
00447 std::string numpathname = custompathnamepair->first;
00448 std::string denompathname = custompathnamepair->second;
00449
00450 if (numpathname != denompathname) {
00451
00452
00453 bool founddenominator = false;
00454 for (unsigned int k=0; k!=n; ++k) {
00455
00456 string n_pathname = hltConfig_.triggerName(k);
00457
00458 if (n_pathname.find(denompathname) != std::string::npos) {
00459
00460 LogDebug("TrigResRateMon") << "denompathname is selected to be = " << n_pathname << endl;;
00461 founddenominator = true;
00462
00463 break;
00464
00465 }
00466 }
00467
00468 if (!founddenominator) {
00469
00470 edm::LogInfo("TrigResRateMon") << "denompathname not found, go to the next pair numearator-denominator" << endl;
00471
00472
00473 continue;
00474
00475 }
00476
00477
00478 bool foundnumerator = false;
00479 for (unsigned int j=0; j!=n; ++j) {
00480
00481 string pathname = hltConfig_.triggerName(j);
00482
00483 LogDebug("TrigResRateMon") << "check if path " << pathname << " is numpathname = " << numpathname << endl;
00484 if (hltConfig_.triggerName(j).find(numpathname)!= std::string::npos) {
00485
00486 LogDebug("TrigResRateMon") << "pathname is selected to be = " << denompathname << endl;;
00487 foundnumerator = true;
00488
00489 }
00490
00491
00492 if (!foundnumerator) {
00493
00494 edm::LogInfo("TrigResRateMon") << "pathname not found, ignoring " << pathname;
00495 continue;
00496
00497 }
00498
00499
00500 string l1pathname = getL1ConditionModuleName(pathname);
00501 int l1ModuleIndex = hltConfig_.moduleIndex(pathname, l1pathname);
00502 int objectType = getTriggerTypeParsePathName(pathname);
00503
00504 std::string filtername("dummy");
00505 float ptMin = 0.0;
00506 float ptMax = 100.0;
00507 if (objectType == trigger::TriggerPhoton) ptMax = 100.0;
00508 if (objectType == trigger::TriggerElectron) ptMax = 100.0;
00509 if (objectType == trigger::TriggerMuon) ptMax = 150.0;
00510 if (objectType == trigger::TriggerTau) ptMax = 100.0;
00511 if (objectType == trigger::TriggerJet) ptMax = 300.0;
00512 if (objectType == trigger::TriggerBJet) ptMax = 300.0;
00513 if (objectType == trigger::TriggerMET) ptMax = 300.0;
00514 if (objectType == trigger::TriggerTET) ptMax = 300.0;
00515 if (objectType == trigger::TriggerTrack) ptMax = 100.0;
00516
00517
00518 if (objectType != 0) {
00519 int hltThreshold = getThresholdFromName(pathname);
00520 int l1Threshold = getThresholdFromName(l1pathname);
00521 hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, l1ModuleIndex, filtername, processname_, objectType, ptMin, ptMax, hltThreshold, l1Threshold));
00522
00523 }
00524
00525 }
00526
00527 }
00528
00529 }
00530
00531 }
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541 vector<string> allPaths;
00542
00543
00544 for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) {
00545
00546 std::string pathName = v->getPath();
00547
00548
00549 vector<int> tempCount(5,0);
00550
00551 fPathTempCountPair.push_back(make_pair(pathName,0));
00552 fPathBxTempCountPair.push_back(make_pair(pathName,tempCount));
00553
00554 allPaths.push_back(pathName);
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581 }
00582
00583 fPathTempCountPair.push_back(make_pair("HLT_Any",0));
00584
00585 fGroupName.push_back("AllSelectedPaths");
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595 for(unsigned int g=0; g<fGroupName.size(); g++) {
00596
00597
00598
00599
00600 }
00601
00602 dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());
00603
00604
00605
00606 fGroupNamePathsPair.push_back(make_pair("AllSelectedPaths",allPaths));
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00623
00624 vector<string> datasetNames = hltConfig_.streamContent("A") ;
00625 for (unsigned int i=0;i<datasetNames.size();i++) {
00626
00627 vector<string> datasetPaths = hltConfig_.datasetContent(datasetNames[i]);
00628 fGroupNamePathsPair.push_back(make_pair(datasetNames[i],datasetPaths));
00629
00630 }
00631
00632
00633 fGroupNamePathsPair.push_back(make_pair("A",datasetNames));
00634
00635
00636 for (unsigned int g=0;g<fGroupNamePathsPair.size();g++) {
00637
00638 fGroupTempCountPair.push_back(make_pair(fGroupNamePathsPair[g].first,0));
00639 fGroupL1TempCountPair.push_back(make_pair(fGroupNamePathsPair[g].first,0));
00640 setupHltMatrix(fGroupNamePathsPair[g].first,fGroupNamePathsPair[g].second);
00641
00642 }
00643
00644
00645
00646
00647
00648
00649
00651
00652
00653
00654
00655
00656
00657 setupHltLsPlots();
00658
00659 setupHltBxPlots();
00660
00661
00662 for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) {
00663
00664
00665
00666
00667
00668
00669
00670
00671 vector<string> moduleNames = hltConfig_.moduleLabels( v->getPath() );
00672
00673 int numModule = 0;
00674 string moduleName, moduleType;
00675 unsigned int moduleIndex;
00676
00677
00678 vector<string>::const_iterator iDumpModName;
00679 for (iDumpModName = moduleNames.begin();iDumpModName != moduleNames.end();iDumpModName++) {
00680
00681 moduleName = *iDumpModName;
00682 moduleType = hltConfig_.moduleType(moduleName);
00683 moduleIndex = hltConfig_.moduleIndex(v->getPath(), moduleName);
00684
00685 LogTrace ("TrigResRateMon") << "Module " << numModule
00686 << " is called " << moduleName
00687 << " , type = " << moduleType
00688 << " , index = " << moduleIndex
00689 << endl;
00690
00691 numModule++;
00692
00693 if((moduleType.find("Filter") != string::npos && moduleType.find("HLTTriggerTypeFilter") == string::npos ) ||
00694 (moduleType.find("Associator") != string::npos) ||
00695 (moduleType.find("HLTLevel1GTSeed") != string::npos) ||
00696 (moduleType.find("HLTGlobalSumsCaloMET") != string::npos) ||
00697 (moduleType.find("HLTPrescaler") != string::npos) ) {
00698
00699
00700
00701
00702
00703 v->filtersAndIndices.push_back(make_pair(moduleName,moduleIndex));
00704
00705 }
00706
00707
00708 }
00709
00710 dbe_->setCurrentFolder(pathsSummaryFilterCountsFolder_.c_str());
00711
00712
00713 int nbin_sub = v->filtersAndIndices.size()+2;
00714
00715
00716 MonitorElement* filters = dbe_->book1D("Filters_" + v->getPath(),
00717 "Filters_" + v->getPath(),
00718 nbin_sub+1, -0.5, 0.5+(double)nbin_sub);
00719
00720 for(unsigned int filt = 0; filt < v->filtersAndIndices.size(); filt++){
00721
00722 filters->setBinLabel(filt+1, (v->filtersAndIndices[filt]).first);
00723
00724 }
00725
00726
00727 dbe_->setCurrentFolder(pathsIndividualHLTPathsPerLSFolder_.c_str());
00728 MonitorElement* tempME = dbe_->book1D(v->getPath() + "_count_per_LS",
00729 v->getPath() + " rate [Hz]",
00730 nLS_, 0,nLS_);
00731 tempME->setAxisTitle("Luminosity Section");
00732
00733 v->setFilterHistos(filters);
00734
00735 }
00736
00737
00738 for(PathInfoCollection::iterator v = hltPaths_.begin(); v!= hltPaths_.end(); ++v ) {
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754 std::string labelname("dummy");
00755 labelname = v->getPath() + "_wrt_" + v->getDenomPath();
00756 std::string histoname(labelname+"_NOn");
00757 std::string title(labelname+" N online");
00758 double histEtaMax = 2.5;
00759
00760 if (v->getObjectType() == trigger::TriggerMuon || v->getObjectType() == trigger::TriggerL1Mu) {
00761
00762 histEtaMax = muonEtaMax_;
00763
00764 }
00765 else if (v->getObjectType() == trigger::TriggerElectron || v->getObjectType() == trigger::TriggerL1NoIsoEG || v->getObjectType() == trigger::TriggerL1IsoEG )
00766 {
00767 histEtaMax = electronEtaMax_;
00768 }
00769 else if (v->getObjectType() == trigger::TriggerTau || v->getObjectType() == trigger::TriggerL1TauJet )
00770 {
00771 histEtaMax = tauEtaMax_;
00772 }
00773 else if (v->getObjectType() == trigger::TriggerJet || v->getObjectType() == trigger::TriggerL1CenJet || v->getObjectType() == trigger::TriggerL1ForJet )
00774 {
00775 histEtaMax = jetEtaMax_;
00776 }
00777 else if (v->getObjectType() == trigger::TriggerBJet)
00778 {
00779 histEtaMax = bjetEtaMax_;
00780 }
00781 else if (v->getObjectType() == trigger::TriggerMET || v->getObjectType() == trigger::TriggerL1ETM )
00782 {
00783 histEtaMax = metEtaMax_;
00784 }
00785 else if (v->getObjectType() == trigger::TriggerPhoton)
00786 {
00787 histEtaMax = photonEtaMax_;
00788 }
00789 else if (v->getObjectType() == trigger::TriggerTrack)
00790 {
00791 histEtaMax = trackEtaMax_;
00792 }
00793
00794 TString pathfolder = dirname_ + TString("/FourVector/") + v->getPath();
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933 }
00934
00935
00936
00937 dbe_->setCurrentFolder(pathsIndividualHLTPathsPerLSFolder_.c_str());
00938 MonitorElement* tempME = dbe_->book1D("HLT_Any_count_per_LS",
00939 "HLT_Any rate [Hz]",
00940 nLS_, 0,nLS_);
00941 tempME->setAxisTitle("Luminosity Section");
00942
00943 }
00944
00945 if(doCombineRuns_) fIsSetup = true;
00946
00947 return;
00948
00949 }
00950
00952 void TrigResRateMon::endRun(const edm::Run& run, const edm::EventSetup& c)
00953 {
00954
00955 LogDebug("TrigResRateMon") << "endRun, run " << run.id();
00956
00957 }
00958
00959
00960 void TrigResRateMon::setupHltMatrix(const std::string& label, vector<std::string>& paths) {
00961
00962
00963
00964
00965 paths.push_back("");
00966 paths.push_back("Total "+label);
00967
00968
00969 string h_name;
00970 string h_title;
00971
00972 dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());
00973
00974 h_name= "HLT_"+label+"_PassPass";
00975 h_title = "HLT_"+label+"_PassPass (x=Pass, y=Pass)";
00976 MonitorElement* ME = dbe_->book2D(h_name.c_str(), h_title.c_str(),
00977 paths.size(), -0.5, paths.size()-0.5, paths.size(), -0.5, paths.size()-0.5);
00978
00979 h_name= "HLT_"+label+"_Pass_Any";
00980 h_title = "HLT_"+label+"_Pass (x=Pass, Any=Pass) normalized to HLT_Any Pass";
00981 MonitorElement* ME_Any = dbe_->book1D(h_name.c_str(), h_title.c_str(),
00982 paths.size(), -0.5, paths.size()-0.5);
00983
00984 dbe_->setCurrentFolder(pathsSummaryHLTCorrelationsFolder_.c_str());
00985 h_name= "HLT_"+label+"_PassPass_Normalized";
00986 h_title = "HLT_"+label+"_PassPass (x=Pass, y=Pass) normalized to xBin=Pass";
00987 MonitorElement* ME_Normalized = dbe_->book2D(h_name.c_str(), h_title.c_str(),
00988 paths.size(), -0.5, paths.size()-0.5, paths.size(), -0.5, paths.size()-0.5);
00989 h_name= "HLT_"+label+"_Pass_Normalized_Any";
00990 h_title = "HLT_"+label+"_Pass (x=Pass, Any=Pass) normalized to HLT_Any Pass";
00991 MonitorElement* ME_Normalized_Any = dbe_->book1D(h_name.c_str(), h_title.c_str(),
00992 paths.size(), -0.5, paths.size()-0.5);
00993
00994 dbe_->setCurrentFolder(pathsSummaryHLTPathsPerLSFolder_.c_str());
00995 h_name= "HLT_"+label+"_Total_LS";
00996 h_title = label+" HLT paths total combined rate [Hz]";
00997 MonitorElement* ME_Total_LS = dbe_->book1D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_);
00998 ME_Total_LS->setAxisTitle("LS");
00999
01000 h_name= "HLT_"+label+"_LS";
01001 h_title = label+" HLT paths rate [Hz]";
01002 MonitorElement* ME_Group_LS = dbe_->book2D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_, paths.size(), -0.5, paths.size()-0.5);
01003 ME_Group_LS->setAxisTitle("LS");
01005 v_ME_HLTAll_LS.push_back(ME_Group_LS);
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032 for(unsigned int i = 0; i < paths.size(); i++){
01033
01034 ME->getTH2F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01035 ME->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01036 ME_Group_LS->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01037
01038 ME_Normalized->getTH2F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01039 ME_Normalized->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01040 ME_Normalized_Any->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01041 ME_Any->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01042
01043 }
01044
01045 }
01046
01047
01048 void TrigResRateMon::setupStreamMatrix(const std::string& label, vector<std::string>& paths) {
01049
01050
01051 paths.push_back("");
01052 paths.push_back("HLT_"+label+"_Any");
01053
01054 string h_name;
01055 string h_title;
01056
01057 dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());
01058
01059 h_name= "HLT_"+label+"_PassPass";
01060 h_title = "HLT_"+label+"_PassPass (x=Pass, y=Pass)";
01061 MonitorElement* ME = dbe_->book2D(h_name.c_str(), h_title.c_str(),
01062 paths.size(), -0.5, paths.size()-0.5, paths.size(), -0.5, paths.size()-0.5);
01063
01064 h_name= "HLT_"+label+"_Pass_Any";
01065 h_title = "HLT_"+label+"_Pass (x=Pass, Any=Pass) normalized to HLT_Any Pass";
01066 MonitorElement* ME_Any = dbe_->book1D(h_name.c_str(), h_title.c_str(),
01067 paths.size(), -0.5, paths.size()-0.5);
01068
01069 dbe_->setCurrentFolder(pathsSummaryHLTCorrelationsFolder_.c_str());
01070 h_name= "HLT_"+label+"_PassPass_Normalized";
01071 h_title = "HLT_"+label+"_PassPass (x=Pass, y=Pass) normalized to xBin=Pass";
01072 MonitorElement* ME_Normalized = dbe_->book2D(h_name.c_str(), h_title.c_str(),
01073 paths.size(), -0.5, paths.size()-0.5, paths.size(), -0.5, paths.size()-0.5);
01074 h_name= "HLT_"+label+"_Pass_Normalized_Any";
01075 h_title = "HLT_"+label+"_Pass (x=Pass, Any=Pass) normalized to HLT_Any Pass";
01076 MonitorElement* ME_Normalized_Any = dbe_->book1D(h_name.c_str(), h_title.c_str(),
01077 paths.size(), -0.5, paths.size()-0.5);
01078
01079 for(unsigned int i = 0; i < paths.size(); i++){
01080
01081 ME->getTH2F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01082 ME->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01083
01084 ME_Normalized->getTH2F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01085 ME_Normalized->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01086
01087 ME_Any->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01088 ME_Normalized_Any->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
01089
01090 }
01091
01092 }
01093
01094 void TrigResRateMon::fillHltMatrix(const edm::TriggerNames & triggerNames) {
01095
01096 string fullPathToME;
01097 std::vector <std::pair<std::string, bool> > groupAcceptPair;
01098
01099 for (unsigned int mi=0;mi<fGroupNamePathsPair.size();mi++) {
01100
01101
01102 fullPathToME = pathsSummaryFolder_ + "HLT_"+fGroupNamePathsPair[mi].first+"_PassPass";
01103 MonitorElement* ME_2d = dbe_->get(fullPathToME);
01104 fullPathToME = pathsSummaryFolder_ + "HLT_"+fGroupNamePathsPair[mi].first+"_Pass_Any";
01105 MonitorElement* ME_1d = dbe_->get(fullPathToME);
01106 if(!ME_2d || !ME_1d) {
01107
01108 LogTrace("TrigResRateMon") << " ME not valid although I gave full path" << endl;
01109 continue;
01110
01111 }
01112
01113 TH2F * hist_2d = ME_2d->getTH2F();
01114 TH1F * hist_1d = ME_1d->getTH1F();
01115
01116
01117
01118 int anyBinNumber = hist_2d->GetXaxis()->FindBin("HLT_Any");
01119
01120
01121 string groupBinLabel = "Total "+fGroupNamePathsPair[mi].first;
01122 int groupBinNumber = hist_2d->GetXaxis()->FindBin(groupBinLabel.c_str());
01123
01124
01125 if(triggerResults_->accept()){
01126
01127 hist_2d->Fill(anyBinNumber-1,anyBinNumber-1);
01128 hist_1d->Fill(anyBinNumber-1);
01129
01130 }
01131
01132 bool groupPassed = false;
01133 bool groupL1Passed = false;
01134
01135
01136
01137
01138
01139 for (unsigned int i=0; i< fGroupNamePathsPair[mi].second.size(); i++)
01140 {
01141
01142
01143 string hltPathName = fGroupNamePathsPair[mi].second[i];
01144
01145
01146
01147 unsigned int pathByIndex = triggerNames.triggerIndex(fGroupNamePathsPair[mi].second[i]);
01148 if(pathByIndex >= triggerResults_->size() ) continue;
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158 if(triggerResults_->accept(pathByIndex)){
01159
01160 groupPassed = true;
01161 groupL1Passed = true;
01162
01163 hist_2d->Fill(i,anyBinNumber-1);
01164 hist_2d->Fill(anyBinNumber-1,i);
01165
01166 hist_2d->Fill(i,groupBinNumber-1);
01167 hist_2d->Fill(groupBinNumber-1,i);
01168
01169 hist_1d->Fill(i);
01170
01171
01172
01173 for (unsigned int j=0; j< fGroupNamePathsPair[mi].second.size(); j++)
01174 {
01175
01176 string crossHltPathName = fGroupNamePathsPair[mi].second[j];
01177
01178
01179
01180 unsigned int crosspathByIndex = triggerNames.triggerIndex(fGroupNamePathsPair[mi].second[j]);
01181
01182 if(crosspathByIndex >= triggerResults_->size() ) continue;
01183
01184 if(triggerResults_->accept(crosspathByIndex)){
01185
01186 hist_2d->Fill(i,j);
01187
01188 }
01189
01190 }
01191
01192 }
01193
01194
01195 }
01196
01197 if(groupPassed) {
01198
01199 hist_1d->Fill(groupBinNumber-1);
01200 hist_2d->Fill(groupBinNumber-1,groupBinNumber-1);
01201 hist_2d->Fill(anyBinNumber-1,groupBinNumber-1);
01202 hist_2d->Fill(groupBinNumber-1,anyBinNumber-1);
01203
01204 }
01205
01206
01207
01208 bool isGroupFromStreamA = false;
01209
01210 vector<string> streamDatasetNames = hltConfig_.streamContent("A") ;
01211 for (unsigned int g=0;g<streamDatasetNames.size();g++) {
01212
01213 if(streamDatasetNames[g] == fGroupNamePathsPair[mi].first)
01214 {
01215
01216 isGroupFromStreamA = true;
01217 break;
01218
01219 }
01220 }
01221
01222 if(isGroupFromStreamA) groupAcceptPair.push_back(make_pair(fGroupNamePathsPair[mi].first,groupPassed));
01223
01224
01225
01226 string groupL1BinLabel = "HLT_"+fGroupNamePathsPair[mi].first+"_L1_Any";
01227 int groupL1BinNumber = hist_2d->GetXaxis()->FindBin(groupL1BinLabel.c_str());
01228
01229 if(groupL1Passed) hist_1d->Fill(groupL1BinNumber-1);
01230
01231 }
01232
01233 fullPathToME = pathsSummaryFolder_ + "HLT_A_PassPass";
01234 MonitorElement* ME_2d_Stream = dbe_->get(fullPathToME);
01235 fullPathToME = pathsSummaryFolder_ + "HLT_A_Pass_Any";
01236 MonitorElement* ME_1d_Stream = dbe_->get(fullPathToME);
01237 if(!ME_2d_Stream || !ME_1d_Stream) {
01238
01239 LogTrace("TrigResRateMon") << " ME not valid although I gave full path" << endl;
01240 return;
01241
01242 }
01243 else {
01244
01245 TH2F * hist_2d_Stream = ME_2d_Stream->getTH2F();
01246 TH1F * hist_1d_Stream = ME_1d_Stream->getTH1F();
01247
01248 int streamBinNumber = hist_1d_Stream->GetXaxis()->GetLast();
01249
01250 bool acceptedStreamA = false;
01251
01252
01253 for (unsigned int i=0;i<groupAcceptPair.size();i++) {
01254
01255 if(groupAcceptPair[i].second) {
01256
01257 acceptedStreamA = true;
01258
01259 int groupBinNumber_i = hist_2d_Stream->GetXaxis()->FindBin(groupAcceptPair[i].first.c_str());
01260
01261 hist_1d_Stream->Fill(groupBinNumber_i-1);
01262 hist_2d_Stream->Fill(groupBinNumber_i-1,streamBinNumber-1);
01263 hist_2d_Stream->Fill(streamBinNumber-1,groupBinNumber_i-1);
01264
01265 for (unsigned int j=0;j<groupAcceptPair.size();j++) {
01266
01267
01268 if(groupAcceptPair[j].second) {
01269
01270 int groupBinNumber_j = hist_2d_Stream->GetXaxis()->FindBin(groupAcceptPair[j].first.c_str());
01271
01272
01273
01274 hist_2d_Stream->Fill(groupBinNumber_i-1,groupBinNumber_j-1);
01275
01276 }
01277
01278 }
01279
01280 }
01281
01282 }
01283
01284 if(acceptedStreamA) {
01285
01286 hist_2d_Stream->Fill(streamBinNumber-1,streamBinNumber-1);
01287 hist_1d_Stream->Fill(streamBinNumber-1);
01288
01289 }
01290
01291 }
01292
01293 }
01294
01295 void TrigResRateMon::setupHltBxPlots()
01296 {
01297
01298
01299
01300 dbe_->setCurrentFolder(pathsSummaryFolder_);
01301
01302
01303 unsigned int npaths = hltPathsDiagonal_.size();
01304
01305 ME_HLT_BX = dbe_->book2D("HLT_bx",
01306 "HLT counts vs Event bx",
01307 Nbx_+1, -0.5, Nbx_+1-0.5, npaths, -0.5, npaths-0.5);
01308 ME_HLT_CUSTOM_BX = dbe_->book2D("HLT_Custom_bx",
01309 "HLT counts vs Event bx",
01310 Nbx_+1, -0.5, Nbx_+1-0.5, npaths, -0.5, npaths-0.5);
01311 ME_HLT_BX->setAxisTitle("Bunch Crossing");
01312 ME_HLT_CUSTOM_BX->setAxisTitle("Bunch Crossing");
01313
01314
01315
01316 for(unsigned int i = 0; i < npaths; i++){
01317
01318 ME_HLT_BX->getTH2F()->GetYaxis()->SetBinLabel(i+1, (hltPathsDiagonal_[i]).getPath().c_str());
01319 ME_HLT_CUSTOM_BX->getTH2F()->GetYaxis()->SetBinLabel(i+1, (hltPathsDiagonal_[i]).getPath().c_str());
01320
01321 }
01322
01323
01324 }
01325
01326 void TrigResRateMon::setupHltLsPlots()
01327 {
01328
01329 unsigned int npaths = hltPathsDiagonal_.size();
01330
01331
01332
01333 dbe_->setCurrentFolder(pathsSummaryHLTPathsPerLSFolder_);
01334
01335 ME_HLTAll_LS = dbe_->book2D("AllSelectedPaths_count_LS",
01336 "AllSelectedPaths paths rate [Hz]",
01337 nLS_, 0, nLS_, npaths+1, -0.5, npaths+1-0.5);
01338 ME_HLTAll_LS->setAxisTitle("Luminosity Section");
01339
01340
01341 for(unsigned int i = 0; i < npaths; i++){
01342
01343 ME_HLTAll_LS->getTH2F()->GetYaxis()->SetBinLabel(i+1, (hltPathsDiagonal_[i]).getPath().c_str());
01344
01345 }
01346
01347 unsigned int i = npaths;
01348 ME_HLTAll_LS->getTH2F()->GetYaxis()->SetBinLabel(i+1, "HLT_Any");
01349
01350 int nBinsPerLSHisto = 20;
01351 int nLSHistos = npaths/nBinsPerLSHisto;
01352 for (int nh=0;nh<nLSHistos+1;nh++) {
01353
01354 char name[200];
01355 char title[200];
01356
01357 sprintf(name, "Group_%d_paths_count_LS",nLSHistos-nh);
01358 sprintf(title, "Group %d, paths rate [Hz]",nLSHistos-nh);
01359
01360 MonitorElement* tempME = dbe_->book2D(name,title,
01361 nLS_, 0, nLS_, nBinsPerLSHisto+3, -0.5, nBinsPerLSHisto+3-0.5);
01362
01363 tempME->setAxisTitle("LS");
01364
01365
01366 for(int i = nh*nBinsPerLSHisto; i < (nh+1)*nBinsPerLSHisto; i++){
01367
01368 if (i == int(npaths)) break;
01369
01370 int bin;
01371 if(nh == 0){
01372
01373 bin = i;
01374
01375 }
01376 else {
01377
01378 bin = i % nBinsPerLSHisto;
01379
01380 }
01381
01382 tempME->setBinLabel(bin+1, hltPathsDiagonal_[i].getPath().c_str(), 2);
01383
01384 }
01385
01386 tempME->setBinLabel(nBinsPerLSHisto+3, "HLT_Any", 2);
01387 tempME->setBinLabel(nBinsPerLSHisto+2, "HLT_PhysicsDeclared", 2);
01388
01389 v_ME_HLTAll_LS.push_back(tempME);
01390
01391 }
01392
01393
01394 }
01395
01396
01397 void TrigResRateMon::beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c){
01398
01399
01400
01401
01402
01403 }
01404
01405 void TrigResRateMon::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& c)
01406 {
01407
01408 int lumi = int(lumiSeg.id().luminosityBlock());
01409 LogTrace("TrigResRateMon") << " end lumiSection number " << lumi << endl;
01410
01411 countHLTPathHitsEndLumiBlock(lumi);
01412 countHLTGroupHitsEndLumiBlock(lumi);
01413
01414
01415
01416 normalizeHLTMatrix();
01417
01418 }
01419
01420 void TrigResRateMon::countHLTGroupBXHitsEndLumiBlock(const int& lumi)
01421 {
01422
01423 LogTrace("TrigResRateMon") << " countHLTGroupBXHitsEndLumiBlock() lumiSection number " << lumi << endl;
01424
01425 if(! ME_HLT_BX) return;
01426
01427 TH2F * hist_2d_bx = ME_HLT_BX->getTH2F();
01428
01429 for (std::vector<std::pair<std::string, vector<int> > >::iterator ip = fPathBxTempCountPair.begin(); ip != fPathBxTempCountPair.end(); ++ip) {
01430
01431
01432 std::string pathname = ip->first;
01433 vector<int> prevCount = ip->second;
01434
01435
01436 vector<int> currCount (5,0);
01437 vector<int> diffCount (5,0);
01438
01439
01440 int pathBin = hist_2d_bx->GetYaxis()->FindBin(pathname.c_str());
01441
01442 if(pathBin > hist_2d_bx->GetNbinsY()) {
01443
01444 LogTrace("TrigResRateMon") << " Cannot find the bin for path " << pathname << endl;
01445 continue;
01446
01447 }
01448
01449 for (unsigned int b =0;b<currCount.size();b++) {
01450
01451 int bxOffset = b-2;
01452 int bunch = referenceBX_+bxOffset;
01453 if(bunch < 1) bunch += Nbx_ ;
01454 int bxBin = bunch +1;
01455
01456
01457 currCount[b] = int(hist_2d_bx->GetBinContent(bxBin, pathBin));
01458
01459 LogTrace("TrigResRateMon") << "currCount = " << currCount[b] << endl;
01460
01461
01462 diffCount[b] = currCount[b] - prevCount[b];
01463
01464 LogTrace("TrigResRateMon") << " lumi = " << lumi << " path " << pathname << "bxOffset = " << bxOffset << " count = " << diffCount[b] << endl;
01465
01466 }
01467
01468
01469 ip->second = currCount;
01470
01472
01474 LogTrace("TrigResRateMon") << "Find " << pathname << endl;
01475
01476
01477
01478 for (unsigned int j=0;j<v_ME_Total_BX.size();j++)
01479 {
01480
01481 bool isMember = false;
01482
01483 LogTrace("TrigResRateMon") << " ---- Group " << fGroupNamePathsPair[j].first << endl;
01484
01485
01486 for (unsigned int k = 0; k<(fGroupNamePathsPair[j].second).size();k++) {
01487
01488 LogTrace("TrigResRateMon") << " comparing to " << fGroupNamePathsPair[j].second[k] << endl;
01489
01490 if(fGroupNamePathsPair[j].second[k] == pathname) {
01491
01492 isMember = true;
01493 break;
01494
01495 }
01496
01497 }
01498
01499 if(!isMember) {
01500
01501 LogTrace("TrigResRateMon") << "Could not find a group to which the path belongs, path = " << pathname << " group = " << fGroupNamePathsPair[j].first << endl;
01502 continue;
01503
01504 }
01505
01506 MonitorElement* ME_2d = v_ME_Total_BX[j];
01507
01508 if (! ME_2d) {
01509
01510 LogDebug("TrigResRateMon") << " cannot find ME_2d for group " << fGroupNamePathsPair[j].first << endl;
01511 continue;
01512
01513 }
01514
01515 vector<int> updatedLumiCount(5,0);
01516
01517 float entireBXWindowUpdatedLumiCount = 0;
01518
01519 TH2F* hist_All = ME_2d->getTH2F();
01520
01521 for (unsigned int b = 0; b<diffCount.size();b++) {
01522
01523
01524 int binNumber = b+1;
01525
01526
01527 int currentLumiCount = int(hist_All->GetBinContent(lumi+1,binNumber));
01528 updatedLumiCount[b] = currentLumiCount + diffCount[b];
01529 hist_All->SetBinContent(lumi+1,binNumber,updatedLumiCount[b]);
01530
01531 entireBXWindowUpdatedLumiCount += updatedLumiCount[b];
01532
01533 }
01534
01535 MonitorElement* ME_2d_Norm = v_ME_Total_BX_Norm[j];
01536
01537 if (! ME_2d_Norm) {
01538
01539 LogDebug("TrigResRateMon") << " cannot find ME_2d_Norm for group " << fGroupNamePathsPair[j].first << endl;
01540 continue;
01541
01542 }
01543
01544 TH2F* hist_All_Norm = ME_2d_Norm->getTH2F();
01545
01546 for (unsigned int b = 0; b<diffCount.size();b++) {
01547
01548
01549 int binNumber = b+1;
01550
01551
01552 hist_All_Norm->SetBinContent(lumi+1,binNumber,float(updatedLumiCount[b])/entireBXWindowUpdatedLumiCount);
01553
01554 }
01555
01556 }
01557
01558 }
01559
01560 }
01561
01562 void TrigResRateMon::countHLTGroupL1HitsEndLumiBlock(const int& lumi)
01563 {
01564
01565 LogTrace("TrigResRateMon") << " countHLTGroupL1HitsEndLumiBlock() lumiSection number " << lumi << endl;
01566
01567 for(unsigned int i=0; i<fGroupNamePathsPair.size(); i++){
01568
01569
01570 string fullPathToME = pathsSummaryFolder_ + "HLT_" + fGroupNamePathsPair[i].first+ "_Pass_Any";
01571 MonitorElement* ME_1d = dbe_->get(fullPathToME);
01572
01573 if(! ME_1d) {
01574
01575 LogTrace("TrigResRateMon") << " could not find 1d matrix " << fullPathToME << endl;
01576
01577 continue;
01578
01579 }
01580
01581 LogTrace("TrigResRateMon") << " Looking in histogram " << fullPathToME << endl;
01582
01583 TH1F * hist_1d = ME_1d->getTH1F();
01584
01585 for (std::vector<std::pair<std::string, float> >::iterator ip = fGroupL1TempCountPair.begin(); ip != fGroupL1TempCountPair.end(); ++ip) {
01586
01587
01588 string pathname = ip->first;
01589 float prevCount = ip->second;
01590
01591 string binLabel = "HLT_"+pathname+"_L1_Any";
01592
01593 LogTrace("TrigResRateMon") << " Looking for binLabel = " << binLabel << endl;
01594
01595 int pathBin = hist_1d->GetXaxis()->FindBin(binLabel.c_str());
01596
01597 LogTrace("TrigResRateMon") << " pathBin = " << pathBin << " out of histogram total number of bins " << hist_1d->GetNbinsX() << endl;
01598 if(pathBin == -1) {
01599
01600 LogTrace("TrigResRateMon") << " Cannot find the bin for path " << pathname << endl;
01601 continue;
01602
01603 }
01604
01605 float currCount = hist_1d->GetBinContent(pathBin)/LSsize_;
01606
01607
01608 float diffCount = currCount - prevCount;
01609
01610 LogTrace("TrigResRateMon") << " lumi = " << lumi << " path " << pathname << " count " << diffCount << endl;
01611
01612
01613 ip->second = currCount;
01614
01615
01617
01619 string fullPathToME_count = pathsSummaryHLTPathsPerLSFolder_ +"HLT_" + pathname + "_L1_Total_LS";
01620 MonitorElement* ME_1d = dbe_->get(fullPathToME_count);
01621 if ( ME_1d) {
01622
01623
01624 float currentLumiCount = ME_1d->getTH1()->GetBinContent(lumi+1);
01625 float updatedLumiCount = currentLumiCount + diffCount;
01626 ME_1d->getTH1()->SetBinContent(lumi+1,updatedLumiCount);
01627
01628 }
01629 else {
01630
01631 LogDebug("TrigResRateMon") << " cannot find ME " << fullPathToME_count << endl;
01632
01633 }
01634
01635 }
01636
01637 }
01638
01639 }
01640
01641
01642 void TrigResRateMon::countHLTGroupHitsEndLumiBlock(const int& lumi)
01643 {
01644
01645 LogTrace("TrigResRateMon") << " countHLTGroupHitsEndLumiBlock() lumiSection number " << lumi << endl;
01646 for(unsigned int i=0; i<fGroupNamePathsPair.size(); i++){
01647
01648
01649 string fullPathToME = pathsSummaryFolder_ + "HLT_" + fGroupNamePathsPair[i].first + "_Pass_Any";
01650 MonitorElement* ME_1d = dbe_->get(fullPathToME);
01651
01652 if(! ME_1d) {
01653
01654 LogTrace("TrigResRateMon") << " could not find 1d matrix " << fullPathToME << endl;
01655
01656 continue;
01657
01658 }
01659
01660 LogTrace("TrigResRateMon") << " Looking in histogram " << fullPathToME << endl;
01661
01662 TH1F * hist_1d = ME_1d->getTH1F();
01663
01664 for (std::vector<std::pair<std::string, float> >::iterator ip = fGroupTempCountPair.begin(); ip != fGroupTempCountPair.end(); ++ip) {
01665
01666
01667 string pathname = ip->first;
01668 float prevCount = ip->second;
01669
01670 string binLabel = "Total "+pathname;
01671
01672 LogTrace("TrigResRateMon") << " Looking for binLabel = " << binLabel << endl;
01673
01674
01675 int pathBin = hist_1d->GetXaxis()->FindBin(binLabel.c_str());
01676
01677 LogTrace("TrigResRateMon") << " pathBin = " << pathBin << " out of histogram total number of bins " << hist_1d->GetNbinsX() << endl;
01678 if(pathBin == -1) {
01679
01680 binLabel = pathname;
01681 int alternativePathBin = hist_1d->GetXaxis()->FindBin(binLabel.c_str());
01682
01683 if(alternativePathBin == -1) {
01684
01685 LogTrace("TrigResRateMon") << " Cannot find the bin for path " << pathname << endl;
01686
01687 continue;
01688
01689 }
01690 else {
01691
01692 pathBin = alternativePathBin;
01693
01694 }
01695
01696 }
01697
01698 float currCount = hist_1d->GetBinContent(pathBin)/LSsize_;
01699
01700
01701 float diffCount = currCount - prevCount;
01702
01703 LogTrace("TrigResRateMon") << " lumi = " << lumi << " path " << pathname << " diffCount " << diffCount << endl;
01704
01705
01706 ip->second = currCount;
01707
01709
01711 string fullPathToME_count = pathsSummaryHLTPathsPerLSFolder_ +"HLT_" + pathname + "_Total_LS";
01712 MonitorElement* ME_1d = dbe_->get(fullPathToME_count);
01713
01714 string fullPathToME_2D_count = pathsSummaryHLTPathsPerLSFolder_ +"HLT_" + pathname + "_LS";
01715 MonitorElement* ME_2d = dbe_->get(fullPathToME_2D_count);
01716
01717 string fullPathToME_Stream_A_2D_count = pathsSummaryHLTPathsPerLSFolder_ +"HLT_A_LS";
01718 MonitorElement* ME_Stream_A_2d = dbe_->get(fullPathToME_Stream_A_2D_count);
01719
01720 if ( ME_1d && ME_2d && ME_Stream_A_2d) {
01721
01722
01723
01724 float currentLumiCount = ME_1d->getTH1()->GetBinContent(lumi+1);
01725 float updatedLumiCount = currentLumiCount + diffCount;
01726 ME_1d->getTH1()->SetBinContent(lumi+1,updatedLumiCount);
01727
01728 string groupBinLabel = "Total " + fGroupNamePathsPair[i].first;
01729 int groupBin = ME_2d->getTH2F()->GetYaxis()->FindBin(groupBinLabel.c_str());
01730 if(groupBin != -1) ME_2d->getTH2F()->SetBinContent(lumi+1,groupBin,updatedLumiCount);
01731
01732
01733 groupBinLabel = fGroupNamePathsPair[i].first;
01734 groupBin = ME_Stream_A_2d->getTH2F()->GetYaxis()->FindBin(groupBinLabel.c_str());
01735 if(groupBin != -1) ME_Stream_A_2d->getTH2F()->SetBinContent(lumi+1,groupBin,updatedLumiCount);
01736
01737 }
01738 else {
01739
01740 LogDebug("TrigResRateMon") << " cannot find ME " << fullPathToME_count << endl;
01741
01742 }
01743
01744 }
01745
01746 }
01747
01748 }
01749
01750
01751 void TrigResRateMon::countHLTPathHitsEndLumiBlock(const int& lumi)
01752 {
01753
01754 LogTrace("TrigResRateMon") << " countHLTPathHitsEndLumiBlock() lumiSection number " << lumi << endl;
01755
01756 string fullPathToME = pathsSummaryFolder_ + "HLT_AllSelectedPaths_PassPass";
01757 MonitorElement* ME_2d = dbe_->get(fullPathToME);
01758
01759 if(! ME_2d) {
01760
01761 LogTrace("TrigResRateMon") << " could not fine 2d matrix " << fullPathToME << endl;
01762
01763 return;
01764
01765 }
01766
01767 TH2F * hist_2d = ME_2d->getTH2F();
01768
01769 for (std::vector<std::pair<std::string, float> >::iterator ip = fPathTempCountPair.begin(); ip != fPathTempCountPair.end(); ++ip) {
01770
01771
01772 std::string pathname = ip->first;
01773 float prevCount = ip->second;
01774
01775
01776 float pathBin = hist_2d->GetXaxis()->FindBin(pathname.c_str());
01777
01778 if(pathBin > hist_2d->GetNbinsX()) {
01779
01780 LogTrace("TrigResRateMon") << " Cannot find the bin for path " << pathname << endl;
01781 continue;
01782
01783 }
01784
01785 float currCount = hist_2d->GetBinContent(pathBin, pathBin)/LSsize_;
01786
01787
01788 float diffCount = currCount - prevCount;
01789
01790 LogTrace("TrigResRateMon") << " lumi = " << lumi << " path " << pathname << " count " << diffCount << endl;
01791
01792
01793 ip->second = currCount;
01794
01796
01798 if ( ME_HLTAll_LS) {
01799
01800 TH2F* hist_All = ME_HLTAll_LS->getTH2F();
01801
01802
01803 int pathBinNumber = hist_All->GetYaxis()->FindBin(pathname.c_str());
01804
01805
01806 float currentLumiCount = hist_All->GetBinContent(lumi+1,pathBinNumber);
01807 float updatedLumiCount = currentLumiCount + diffCount;
01808 hist_All->SetBinContent(lumi+1,pathBinNumber,updatedLumiCount);
01809
01810 }
01811 else {
01812
01813 LogDebug("TrigResRateMon") << " cannot find ME_HLTAll_LS" << endl;
01814
01815 }
01816
01817 for (unsigned int i=0 ; i< v_ME_HLTAll_LS.size(); i++) {
01818
01819 MonitorElement* tempME = v_ME_HLTAll_LS[i];
01820
01821 if ( tempME ) {
01822
01823 TH2F* hist_All = tempME->getTH2F();
01824
01825
01826 int pathBinNumber = hist_All->GetYaxis()->FindBin(pathname.c_str());
01827
01828 float currentLumiCount = hist_All->GetBinContent(lumi+1,pathBinNumber);
01829 float updatedLumiCount = currentLumiCount + diffCount;
01830 hist_All->SetBinContent(lumi+1,pathBinNumber,updatedLumiCount);
01831
01832 }
01833 else {
01834
01835 LogDebug("TrigResRateMon") << " cannot find tempME " << endl;
01836
01837 }
01838
01839 }
01840
01841
01843
01845 string fullPathToME_count = pathsIndividualHLTPathsPerLSFolder_ + pathname + "_count_per_LS";
01846 MonitorElement* ME_1d = dbe_->get(fullPathToME_count);
01847 if ( ME_1d) {
01848
01849
01850 float currentLumiCount = ME_1d->getTH1()->GetBinContent(lumi+1);
01851 float updatedLumiCount = currentLumiCount + diffCount;
01852 ME_1d->getTH1()->SetBinContent(lumi+1,updatedLumiCount);
01853
01854 }
01855 else {
01856
01857 LogDebug("TrigResRateMon") << " cannot find ME " << fullPathToME_count << endl;
01858
01859 }
01860
01861 }
01862
01863 }
01864
01865 int TrigResRateMon::getTriggerTypeParsePathName(const string& pathname)
01866 {
01867
01868 int objectType = 0;
01869
01870 if (pathname.find("MET") != std::string::npos)
01871 objectType = trigger::TriggerMET;
01872 if (pathname.find("SumET") != std::string::npos)
01873 objectType = trigger::TriggerTET;
01874 if (pathname.find("HT") != std::string::npos)
01875 objectType = trigger::TriggerTET;
01876 if (pathname.find("Jet") != std::string::npos)
01877 objectType = trigger::TriggerJet;
01878 if (pathname.find("Mu") != std::string::npos)
01879 objectType = trigger::TriggerMuon;
01880 if (pathname.find("Ele") != std::string::npos)
01881 objectType = trigger::TriggerElectron;
01882 if (pathname.find("Photon") != std::string::npos)
01883 objectType = trigger::TriggerPhoton;
01884 if (pathname.find("EG") != std::string::npos)
01885 objectType = trigger::TriggerPhoton;
01886 if (pathname.find("Tau") != std::string::npos)
01887 objectType = trigger::TriggerTau;
01888 if (pathname.find("IsoTrack") != std::string::npos)
01889 objectType = trigger::TriggerTrack;
01890 if (pathname.find("BTag") != std::string::npos)
01891 objectType = trigger::TriggerBJet;
01892
01893 return objectType;
01894 }
01895
01896 const string TrigResRateMon::getL1ConditionModuleName(const string& pathname)
01897 {
01898
01899
01900
01901
01902 string l1pathname = "dummy";
01903
01904 vector<string> numpathmodules = hltConfig_.moduleLabels(pathname);
01905
01906 for(vector<string>::iterator numpathmodule = numpathmodules.begin();
01907 numpathmodule!= numpathmodules.end(); ++numpathmodule ) {
01908
01909 if (hltConfig_.moduleType(*numpathmodule) == "HLTLevel1GTSeed") {
01910
01911 l1pathname = *numpathmodule;
01912 break;
01913
01914 }
01915
01916 }
01917
01918 return l1pathname;
01919
01920 }
01921
01922
01923 bool TrigResRateMon::hasL1Passed(const string& pathname, const edm::TriggerNames & triggerNames)
01924 {
01925
01926 bool rc = false;
01927 int l1ModuleIndex = 999;
01928
01929 for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) {
01930
01931 if(v->getPath() == pathname ) l1ModuleIndex = v->getL1ModuleIndex();
01932
01933 }
01934
01935 unsigned int pathByIndex = triggerNames.triggerIndex(pathname);
01936 if(pathByIndex >= triggerResults_->size() ) return rc;
01937
01938
01939 int lastModule = triggerResults_->index(pathByIndex);
01940
01941
01942
01943 rc = (l1ModuleIndex < lastModule);
01944
01945 return rc;
01946
01947 }
01948
01949 bool TrigResRateMon::hasHLTPassed(const string& pathname, const edm::TriggerNames & triggerNames)
01950 {
01951
01952 bool rc = false;
01953
01954 unsigned int pathByIndex = triggerNames.triggerIndex(pathname);
01955 if(pathByIndex >= triggerResults_->size() ) return rc;
01956
01957 rc = triggerResults_->accept(pathByIndex);
01958
01959 return rc;
01960
01961 }
01962
01963
01964 int TrigResRateMon::getThresholdFromName(const string & name)
01965 {
01966
01967 std::string pathname = name;
01968
01969
01970
01971
01972 if(pathname.find("L1") != std::string::npos) pathname.replace(pathname.find("L1"),2,"");
01973
01974 if(pathname.find("L2") != std::string::npos) pathname.replace(pathname.find("L2"),2,"");
01975
01976 if(pathname.find("8E29") != std::string::npos) pathname.replace(pathname.find("8E29"),4,"");
01977
01978 int digitLocation=0;
01979 for (unsigned int i=0; i < pathname.length(); i++)
01980 {
01981 if (isdigit(pathname.at(i))) {
01982
01983 digitLocation = i;
01984 break;
01985
01986 }
01987 }
01988
01989
01990 string hltThresholdString = pathname.substr(digitLocation);
01991
01992 int hltThreshold = 0;
01993
01994
01995 sscanf (hltThresholdString.c_str(),"%d%*s",&hltThreshold);
01996
01997
01998 return hltThreshold;
01999
02000 }
02001
02002 void TrigResRateMon::normalizeHLTMatrix() {
02003
02004 string fullPathToME;
02005
02006
02007
02008 vector<string> datasetNames = hltConfig_.streamContent("A") ;
02009
02010
02011 for (unsigned int i=0;i<datasetNames.size();i++) {
02012
02013 fullPathToME = pathsSummaryFolder_ +"HLT_"+datasetNames[i]+"_PassPass";
02014 v_ME_HLTPassPass.push_back( dbe_->get(fullPathToME));
02015
02016 fullPathToME = pathsSummaryHLTCorrelationsFolder_+"HLT_"+datasetNames[i]+"_PassPass_Normalized";
02017 v_ME_HLTPassPass_Normalized.push_back( dbe_->get(fullPathToME));
02018
02019 fullPathToME = pathsSummaryHLTCorrelationsFolder_+"HLT_"+datasetNames[i]+"_Pass_Normalized_Any";
02020 v_ME_HLTPass_Normalized_Any.push_back( dbe_->get(fullPathToME));
02021
02022 }
02023
02024
02025 fullPathToME = pathsSummaryFolder_ +"HLT_A_PassPass";
02026 v_ME_HLTPassPass.push_back( dbe_->get(fullPathToME));
02027
02028 fullPathToME = pathsSummaryHLTCorrelationsFolder_+"HLT_A_PassPass_Normalized";
02029 v_ME_HLTPassPass_Normalized.push_back( dbe_->get(fullPathToME));
02030
02031 fullPathToME = pathsSummaryHLTCorrelationsFolder_+"HLT_A_Pass_Normalized_Any";
02032 v_ME_HLTPass_Normalized_Any.push_back( dbe_->get(fullPathToME));
02033
02034 for (unsigned int i =0;i<v_ME_HLTPassPass.size();i++) {
02035
02036 MonitorElement* ME_HLTPassPass = v_ME_HLTPassPass[i];
02037 MonitorElement* ME_HLTPassPass_Normalized = v_ME_HLTPassPass_Normalized[i];
02038 MonitorElement* ME_HLTPass_Normalized_Any = v_ME_HLTPass_Normalized_Any[i];
02039
02040 if(!ME_HLTPassPass || !ME_HLTPassPass_Normalized || !ME_HLTPass_Normalized_Any) return;
02041
02042 float passCount = 0;
02043 unsigned int nBinsX = ME_HLTPassPass->getTH2F()->GetNbinsX();
02044 unsigned int nBinsY = ME_HLTPassPass->getTH2F()->GetNbinsY();
02045
02046 for(unsigned int binX = 0; binX < nBinsX+1; binX++) {
02047
02048 passCount = ME_HLTPassPass->getTH2F()->GetBinContent(binX,binX);
02049
02050
02051 for(unsigned int binY = 0; binY < nBinsY+1; binY++) {
02052
02053 if(passCount != 0) {
02054
02055
02056 float normalizedBinContentPassPass = (ME_HLTPassPass->getTH2F()->GetBinContent(binX,binY))/passCount;
02057
02058
02059 ME_HLTPassPass_Normalized->getTH2F()->SetBinContent(binX,binY,normalizedBinContentPassPass);
02060
02061
02062 if(binX == nBinsX) {
02063
02064 ME_HLTPass_Normalized_Any->getTH1F()->SetBinContent(binY,normalizedBinContentPassPass);
02065
02066 }
02067
02068 }
02069 else {
02070
02071 ME_HLTPassPass_Normalized->getTH2F()->SetBinContent(binX,binY,0);
02072
02073
02074 }
02075
02076 }
02077
02078 }
02079
02080 }
02081
02082 }