CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FourVectorHLTOnline.cc
Go to the documentation of this file.
1 // $Id: FourVectorHLTOnline.cc,v 1.34 2010/08/07 14:55:56 wmtan Exp $
2 // See header file for information.
3 #include "TMath.h"
6 
7 #include <map>
8 #include <utility>
9 
10 
11 using namespace edm;
12 using namespace trigger;
13 using namespace std;
14 
16  resetMe_(true), currentRun_(-99)
17 {
18 
19  LogDebug("FourVectorHLTOnline") << "constructor...." ;
20 
22  if ( ! dbe_ ) {
23  LogInfo("FourVectorHLTOnline") << "unabel to get DQMStore service?";
24  }
25  if (iConfig.getUntrackedParameter < bool > ("DQMStore", false)) {
26  dbe_->setVerbose(0);
27  }
28 
29  dirname_ = iConfig.getUntrackedParameter("dirname", std::string("HLT/FourVector/"));
30  //dirname_ += iConfig.getParameter<std::string>("@module_label");
31 
32  if (dbe_ != 0 ) {
34  }
35 
36  processname_ = iConfig.getParameter<std::string>("processname");
37  fCustomBXPath = iConfig.getUntrackedParameter<std::string>("customBXPath", std::string("HLT_MinBiasBSC"));
38 
39  referenceBX_ = iConfig.getUntrackedParameter<unsigned int>("referenceBX",51);
40  Nbx_ = iConfig.getUntrackedParameter<unsigned int>("Nbx",3564);
41 
42  // plotting paramters
43  ptMin_ = iConfig.getUntrackedParameter<double>("ptMin",0.);
44  ptMax_ = iConfig.getUntrackedParameter<double>("ptMax",1000.);
45  nBins_ = iConfig.getUntrackedParameter<unsigned int>("Nbins",20);
46  nBinsOneOverEt_ = iConfig.getUntrackedParameter<unsigned int>("NbinsOneOverEt",10000);
47  nLS_ = iConfig.getUntrackedParameter<unsigned int>("NLuminositySegments",10);
48 
49 
50  plotAll_ = iConfig.getUntrackedParameter<bool>("plotAll", false);
51  // this is the list of paths to look at.
52  std::vector<edm::ParameterSet> paths =
53  iConfig.getParameter<std::vector<edm::ParameterSet> >("paths");
54 
55  for(std::vector<edm::ParameterSet>::iterator pathconf = paths.begin() ; pathconf != paths.end(); pathconf++) {
56 
57  //std::pair<std::string, std::string> custompathnamepair;
58  //custompathnamepair.first =pathconf->getParameter<std::string>("pathname");
59  //custompathnamepair.second = pathconf->getParameter<std::string>("denompathname");
60  //custompathnamepairs_.push_back(custompathnamepair);
61  custompathnamepairs_.push_back(
62  make_pair(
63  pathconf->getParameter<std::string>("pathname"),
64  pathconf->getParameter<std::string>("denompathname")
65  )
66  );
67 
68  }
69 
70  if (hltPaths_.size() > 0)
71  {
72  // book a histogram of scalers
73  scalersSelect = dbe_->book1D("selectedScalers","Selected Scalers", hltPaths_.size(), 0.0, (double)hltPaths_.size());
74 
75  }
76 
77  triggerSummaryLabel_ = iConfig.getParameter<edm::InputTag>("triggerSummaryLabel");
78  triggerResultsLabel_ = iConfig.getParameter<edm::InputTag>("triggerResultsLabel");
79  muonRecoCollectionName_ = iConfig.getUntrackedParameter("muonRecoCollectionName", std::string("muons"));
80 
81  electronEtaMax_ = iConfig.getUntrackedParameter<double>("electronEtaMax",2.5);
82  electronEtMin_ = iConfig.getUntrackedParameter<double>("electronEtMin",3.0);
83  electronDRMatch_ =iConfig.getUntrackedParameter<double>("electronDRMatch",0.3);
84 
85  muonEtaMax_ = iConfig.getUntrackedParameter<double>("muonEtaMax",2.1);
86  muonEtMin_ = iConfig.getUntrackedParameter<double>("muonEtMin",3.0);
87  muonDRMatch_ =iConfig.getUntrackedParameter<double>("muonDRMatch",0.3);
88 
89  tauEtaMax_ = iConfig.getUntrackedParameter<double>("tauEtaMax",2.5);
90  tauEtMin_ = iConfig.getUntrackedParameter<double>("tauEtMin",3.0);
91  tauDRMatch_ =iConfig.getUntrackedParameter<double>("tauDRMatch",0.3);
92 
93  jetEtaMax_ = iConfig.getUntrackedParameter<double>("jetEtaMax",5.0);
94  jetEtMin_ = iConfig.getUntrackedParameter<double>("jetEtMin",10.0);
95  jetDRMatch_ =iConfig.getUntrackedParameter<double>("jetDRMatch",0.3);
96 
97  bjetEtaMax_ = iConfig.getUntrackedParameter<double>("bjetEtaMax",2.5);
98  bjetEtMin_ = iConfig.getUntrackedParameter<double>("bjetEtMin",10.0);
99  bjetDRMatch_ =iConfig.getUntrackedParameter<double>("bjetDRMatch",0.3);
100 
101  photonEtaMax_ = iConfig.getUntrackedParameter<double>("photonEtaMax",2.5);
102  photonEtMin_ = iConfig.getUntrackedParameter<double>("photonEtMin",3.0);
103  photonDRMatch_ =iConfig.getUntrackedParameter<double>("photonDRMatch",0.3);
104 
105  trackEtaMax_ = iConfig.getUntrackedParameter<double>("trackEtaMax",2.5);
106  trackEtMin_ = iConfig.getUntrackedParameter<double>("trackEtMin",3.0);
107  trackDRMatch_ =iConfig.getUntrackedParameter<double>("trackDRMatch",0.3);
108 
109  metEtaMax_ = iConfig.getUntrackedParameter<double>("metEtaMax",5);
110  metMin_ = iConfig.getUntrackedParameter<double>("metMin",10.0);
111  metDRMatch_ =iConfig.getUntrackedParameter<double>("metDRMatch",0.5);
112 
113  htEtaMax_ = iConfig.getUntrackedParameter<double>("htEtaMax",5);
114  htMin_ = iConfig.getUntrackedParameter<double>("htMin",10.0);
115  htDRMatch_ =iConfig.getUntrackedParameter<double>("htDRMatch",0.5);
116 
117  sumEtMin_ = iConfig.getUntrackedParameter<double>("sumEtMin",10.0);
118 
119  specialPaths_ = iConfig.getParameter<std::vector<std::string > >("SpecialPaths");
120 
121  pathsSummaryFolder_ = iConfig.getUntrackedParameter ("pathsSummaryFolder",std::string("HLT/FourVector/PathsSummary/"));
122  pathsSummaryHLTCorrelationsFolder_ = iConfig.getUntrackedParameter ("hltCorrelationsFolder",std::string("HLT/FourVector/PathsSummary/HLT Correlations/"));
123  pathsSummaryFilterCountsFolder_ = iConfig.getUntrackedParameter ("filterCountsFolder",std::string("HLT/FourVector/PathsSummary/Filters Counts/"));
124 
125  pathsSummaryHLTPathsPerLSFolder_ = iConfig.getUntrackedParameter ("individualPathsPerLSFolder",std::string("HLT/FourVector/PathsSummary/HLT LS/"));
126  pathsIndividualHLTPathsPerLSFolder_ = iConfig.getUntrackedParameter ("individualPathsPerLSFolder",std::string("HLT/FourVector/PathsSummary/HLT LS/Paths/"));
127  pathsSummaryHLTPathsPerBXFolder_ = iConfig.getUntrackedParameter ("individualPathsPerBXFolder",std::string("HLT/FourVector/PathsSummary/HLT BX/"));
128 
129  fLumiFlag = true;
131  ME_HLT_BX_ = NULL;
133 
134 }
135 
136 
138 {
139 
140  // do anything here that needs to be done at desctruction time
141  // (e.g. close files, deallocate resources etc.)
142 
143 }
144 
145 
146 //
147 // member functions
148 //
149 
150 // ------------ method called to for each event ------------
151 void
153 {
154 
155  //if(! fLumiFlag ) return;
156 
157  using namespace edm;
158  using namespace trigger;
159  ++nev_;
160  LogDebug("FourVectorHLTOnline")<< " analyze...." ;
161 
162 
163 
164  /*
165  Handle<GenParticleCollection> genParticles;
166  iEvent.getByLabel("genParticles", genParticles);
167  if(!genParticles.isValid()) {
168  edm::LogInfo("FourVectorHLTOnline") << "genParticles not found, "
169  "skipping event";
170  return;
171  }
172 
173  Handle<GenJetCollection> genJets;
174  iEvent.getByLabel("iterativeCone5GenJets",genJets);
175  if(!genJets.isValid()) {
176  edm::LogInfo("FourVectorHLTOnline") << "genJets not found, "
177  "skipping event";
178  return;
179  }
180 
181  Handle<GenMETCollection> genMets;
182  iEvent.getByLabel("genMetTrue",genMets);
183  if(!genMets.isValid()) {
184  edm::LogInfo("FourVectorHLTOnline") << "genMets not found, "
185  "skipping event";
186  return;
187  }
188  */
189 
190  edm::Handle<TriggerResults> triggerResults;
191  iEvent.getByLabel(triggerResultsLabel_,triggerResults);
192  if(!triggerResults.isValid()) {
193  edm::InputTag triggerResultsLabelFU(triggerResultsLabel_.label(),triggerResultsLabel_.instance(), "FU");
194  iEvent.getByLabel(triggerResultsLabelFU,triggerResults);
195  if(!triggerResults.isValid()) {
196  edm::LogInfo("FourVectorHLTOnline") << "TriggerResults not found, "
197  "skipping event";
198  return;
199  }
200  }
201  triggerResults_ = triggerResults;
202  const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults);
203  int npath = triggerResults->size();
204 
206  if(!fTriggerObj.isValid()) {
207 
208  edm::InputTag triggerSummaryLabelFU(triggerSummaryLabel_.label(),triggerSummaryLabel_.instance(), "FU");
209  iEvent.getByLabel(triggerSummaryLabelFU,fTriggerObj);
210 
211  if(!fTriggerObj.isValid()) {
212 
213  edm::LogInfo("FourVectorHLTOnline") << "TriggerEvent not found, " "skipping event";
214  return;
215 
216  }
217 
218  }
219 
220  edm::Handle<TriggerResults> muonHandle;
221  iEvent.getByLabel(muonRecoCollectionName_,muonHandle);
222  if(!muonHandle.isValid()) {
223 
224  edm::LogInfo("FourVectorHLTOnline") << "muonHandle not found, ";
225  // "skipping event";
226  // return;
227 
228  }
229 
230 
232  iEvent.getByLabel("gsfElectrons",gsfElectrons);
233  if(!gsfElectrons.isValid())
234  edm::LogInfo("FourVectorHLTOnline") << "gsfElectrons not found, ";
235 
236  edm::Handle<TriggerResults> tauHandle;
237  iEvent.getByLabel("caloRecoTauProducer",tauHandle);
238  if(!tauHandle.isValid())
239  edm::LogInfo("FourVectorHLTOnline") << "tauHandle not found, ";
240 
241  edm::Handle<TriggerResults> jetHandle;
242  iEvent.getByLabel("iterativeCone5CaloJets",jetHandle);
243  if(!jetHandle.isValid())
244  edm::LogInfo("FourVectorHLTOnline") << "jetHandle not found, ";
245 
246  // Get b tag information
247  edm::Handle<TriggerResults> bTagIPHandle;
248  iEvent.getByLabel("jetProbabilityBJetTags", bTagIPHandle);
249  if (!bTagIPHandle.isValid())
250  edm::LogInfo("FourVectorHLTOnline") << "mTagIPHandle trackCountingHighEffJetTags not found, ";
251 
252  // Get b tag information
253  edm::Handle<TriggerResults> bTagMuHandle;
254  iEvent.getByLabel("softMuonBJetTags", bTagMuHandle);
255  if (!bTagMuHandle.isValid())
256  edm::LogInfo("FourVectorHLTOnline") << "bTagMuHandle not found, ";
257 
258  edm::Handle<TriggerResults> metHandle;
259  iEvent.getByLabel("met",metHandle);
260  if(!metHandle.isValid())
261  edm::LogInfo("FourVectorHLTOnline") << "metHandle not found, ";
262 
263  edm::Handle<TriggerResults> photonHandle;
264  iEvent.getByLabel("photons",photonHandle);
265  if(!photonHandle.isValid())
266  edm::LogInfo("FourVectorHLTOnline") << "photonHandle not found, ";
267 
268  edm::Handle<TriggerResults> trackHandle;
269  iEvent.getByLabel("pixelTracks",trackHandle);
270  if(!trackHandle.isValid())
271  edm::LogInfo("FourVectorHLTOnline") << "trackHandle not found, ";
272 
273  // ---------------------
274  // Monitors
275  // ---------------------
276 
277  // electron Monitor
279  eleMon.setReco(gsfElectrons);
280  eleMon.setLimits(electronEtaMax_, electronEtMin_, electronDRMatch_);
281 
282  eleMon.pushTriggerType(TriggerElectron);
283  eleMon.pushTriggerType(TriggerL1NoIsoEG);
284  eleMon.pushTriggerType(TriggerL1IsoEG);
285 
286  eleMon.pushL1TriggerType(TriggerL1NoIsoEG);
287  eleMon.pushL1TriggerType(TriggerL1IsoEG);
288 
289  // muon Monitor
291  muoMon.setReco(muonHandle);
292  muoMon.setLimits(muonEtaMax_, muonEtMin_, muonDRMatch_);
293 
294  muoMon.pushTriggerType(TriggerMuon);
295  muoMon.pushTriggerType(TriggerL1Mu);
296 
297  muoMon.pushL1TriggerType(TriggerL1Mu);
298 
299  // tau Monitor
301  tauMon.setReco(tauHandle);
302  tauMon.setLimits(tauEtaMax_, tauEtMin_, tauDRMatch_);
303 
304  tauMon.pushTriggerType(TriggerTau);
305  tauMon.pushTriggerType(TriggerL1TauJet);
306 
307  tauMon.pushL1TriggerType(TriggerL1TauJet);
308  tauMon.pushL1TriggerType(TriggerL1ForJet);
309 
310  // photon Monitor
312  phoMon.setReco(photonHandle);
313  phoMon.setLimits(photonEtaMax_, photonEtMin_, photonDRMatch_);
314 
315  phoMon.pushTriggerType(TriggerPhoton);
316 
317  phoMon.pushL1TriggerType(TriggerL1NoIsoEG);
318  phoMon.pushL1TriggerType(TriggerL1IsoEG);
319 
320  // jet Monitor - NOTICE: we use genJets for MC
322  jetMon.setReco(jetHandle);
323  jetMon.setLimits(jetEtaMax_, jetEtMin_, jetDRMatch_);
324 
325  jetMon.pushTriggerType(TriggerJet);
326  jetMon.pushTriggerType(TriggerL1CenJet);
327  jetMon.pushTriggerType(TriggerL1ForJet);
328 
329  jetMon.pushL1TriggerType(TriggerL1CenJet);
330  jetMon.pushL1TriggerType(TriggerL1ForJet);
331  jetMon.pushL1TriggerType(TriggerL1TauJet);
332 
333  // bjet Monitor - NOTICE: we use genJets for MC
334  objMonData<TriggerResults> btagIPMon; // CaloJet will not be used, this is only place holder
335  //btagIPMon.setReco(jetHandle);
336  btagIPMon.setBJetsFlag(true);
337  btagIPMon.setLimits(bjetEtaMax_, bjetEtMin_, bjetDRMatch_);
338 
339  btagIPMon.pushTriggerType(TriggerBJet);
340  btagIPMon.pushTriggerType(TriggerJet);
341 
342  btagIPMon.pushL1TriggerType(TriggerL1CenJet);
343  btagIPMon.pushL1TriggerType(TriggerL1ForJet);
344  btagIPMon.pushL1TriggerType(TriggerL1TauJet);
345 
346  objMonData<TriggerResults> btagMuMon; // CaloJet will not be used, this is only place holder
347  //btagMuMon.setReco(jetHandle);
348  btagMuMon.setBJetsFlag(true);
349  btagMuMon.setLimits(bjetEtaMax_, bjetEtMin_, bjetDRMatch_);
350 
351  btagMuMon.pushTriggerType(TriggerBJet);
352  btagMuMon.pushTriggerType(TriggerJet);
353 
354  btagMuMon.pushL1TriggerType(TriggerL1CenJet);
355  btagMuMon.pushL1TriggerType(TriggerL1ForJet);
356  btagMuMon.pushL1TriggerType(TriggerL1TauJet);
357 
358 
359  objMonData<TriggerResults> btagMon; // Generic btagMon
360 
361  // met Monitor
363  metMon.setReco(metHandle);
364  metMon.setLimits(metEtaMax_, metMin_, metDRMatch_);
365 
366  metMon.pushTriggerType(TriggerMET);
367 
368  metMon.pushL1TriggerType(TriggerL1ETM);
369 
370  // tet Monitor
372  tetMon.setReco(metHandle);
373  //tetMon.setLimits(tetEtaMax_=999., tetEtMin_=10, tetDRMatch_=999);
374  tetMon.setLimits(999., 10., 999.);
375 
376  tetMon.pushTriggerType(TriggerTET);
377 
378  tetMon.pushL1TriggerType(TriggerL1ETT);
379 
380  // default Monitor
381  //objMonData<trigger::TriggerEvent> defMon;
383  defMon.setLimits(999., 3., 999.);
384 
385  // vector to hold monitors
386  // interface is through virtual class BaseMonitor
387  std::vector<BaseMonitor*> monitors;
388 
389  //monitors.push_back(&jetMon);
390 
391  monitors.push_back(&muoMon);
392  monitors.push_back(&eleMon);
393  monitors.push_back(&tauMon);
394  monitors.push_back(&phoMon);
395  monitors.push_back(&jetMon);
396  monitors.push_back(&btagMon);
397  monitors.push_back(&metMon);
398  monitors.push_back(&tetMon);
399 
400  int bx = iEvent.bunchCrossing();
401  /*
402  // Fill HLTPassed_Correlation Matrix bin (i,j) = (Any,Any)
403  // --------------------------------------------------------
404  int anyBinNumber = ME_HLTPassPass_->getTH2F()->GetXaxis()->FindBin("HLT_Any");
405  // any triger accepted
406  if(triggerResults->accept()){
407 
408  ME_HLTPassPass_->Fill(anyBinNumber-1,anyBinNumber-1);//binNumber1 = 0 = first filter
409 
410  }
411  */
412 
413  fillHltMatrix(triggerNames);
414 
415 
416  // Loop over paths
417  // --------------------
418  for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) {
419 
420  LogTrace("FourVectorHLTOnline") << " unique path " << v->getPath() << std::endl;
421 
422  unsigned int pathByIndex = triggerNames.triggerIndex(v->getPath());
423 
424  // path must be in the menu
425  if(pathByIndex >= triggerResults_->size() ) continue;
426 
427 
428  // Fill HLTPassed Matrix and HLTPassFail Matrix
429  // --------------------------------------------------------
430 
431  if(triggerResults->accept(pathByIndex)){
432 
433  int pathBinNumber = ME_HLT_BX_->getTH2F()->GetYaxis()->FindBin(v->getPath().c_str());
434  ME_HLT_BX_->Fill(bx,pathBinNumber-1);
435 
436  if(hasHLTPassed(fCustomBXPath,triggerNames)) {
437 
438  ME_HLT_CUSTOM_BX_->Fill(bx,pathBinNumber-1);
439 
440  }
441 
442  } // end if accept
443 
444  // Fill histogram of filter ocupancy for each HLT path
445  // ---------------------------------
446  unsigned int lastModule = triggerResults->index(pathByIndex);
447 
448  //check if hlt passed
449  bool hltPathPassed = triggerResults->accept(pathByIndex);
450 
451  //go through the list of filters
452  for(unsigned int filt = 0; filt < v->filtersAndIndices.size(); filt++){
453 
454  int binNumber = v->getFiltersHisto()->getTH1()->GetXaxis()->FindBin(v->filtersAndIndices[filt].first.c_str());
455 
456  // if hlt path passed, then all the modules passed
457  // otherwise the module that issued the decision is the first fail
458  // this means that all modules before it passed
459  if(hltPathPassed) {
460 
461  v->getFiltersHisto()->Fill(binNumber-1);//binNumber1 = 0 = first filter
462  }
463  else if(v->filtersAndIndices[filt].second < lastModule){
464  v->getFiltersHisto()->Fill(binNumber-1);//binNumber1 = 0 = first filter
465  }
466 
467  } // end for filt
468 
469  } // end for diag paths
470 
471 
472  // Main loop over paths
473  // --------------------
474  for(PathInfoCollection::iterator v = hltPaths_.begin(); v!= hltPaths_.end(); ++v ) {
475 
476  LogTrace("FourVectorHLTOnline") << " path " << v->getPath() << std::endl;
477 
478  if (v->getPath().find("BTagIP") != std::string::npos ) btagMon = btagIPMon;
479  else btagMon = btagMuMon;
480 
481  //if(*v != "HLT_L1Jet6U") continue;
482 
483  unsigned int pathByIndex = triggerNames.triggerIndex(v->getPath());
484 
485  if(pathByIndex >= triggerResults_->size() ) continue;
486 
487  // did we pass the denomPath?
488  bool denompassed = false;
489 
490  for(int i = 0; i < npath; ++i) {
491 
492  if (triggerNames.triggerName(i).find(v->getDenomPath()) != std::string::npos && triggerResults->accept(i))
493  {
494  denompassed = true;
495  break;
496  }
497  }
498 
499  if (denompassed)
500  {
501 
502  //LogTrace("FourVectorHLTOnline") << " denominator path " << v->getPath() << std::endl;
503 
504 
505  // Get the righe monitor for this path
506  // -----------------------------------
507  BaseMonitor* mon = NULL;
508 
509  for(std::vector<BaseMonitor*>::iterator mit = monitors.begin(); mit!= monitors.end(); ++mit ) {
510 
511  if((*mit)->isTriggerType(v->getObjectType())) {
512 
513  mon = *mit;
514  break;
515 
516  }
517 
518  }
519 
520  // if cannot find moniotor for the path, go to next path
521  //if(!mon) continue;
522 
523  // if cannot find moniotor for the path, assign the default
524  if(!mon) mon = &defMon;
525 
526  // attach this path to mon
527  mon->setPath(v);
528 
529  // clear sets of matched objects
530  mon->clearSets();
531 
532  int triggertype = 0;
533  triggertype = v->getObjectType();
534 
535  // monitor L1 (only if L1 passed and can find GTSeed)
537  bool l1accept = false;
538  edm::InputTag l1testTag(v->getl1Path(),"",processname_);
539  const int l1Index = fTriggerObj->filterIndex(l1testTag);
540 
541  if ( l1Index >= fTriggerObj->sizeFilters() ) {
542 
543  LogTrace("FourVectorHLTOnline") << "Cannot find L1GTSeed of the path " << v->getPath() << std::endl;
544  LogTrace("FourVectorHLTOnline") << "\t L1GTSeed name = " << v->getl1Path() << std::endl;
545  LogTrace("FourVectorHLTOnline") << "\t tried with tag " << l1testTag << std::endl;
546  LogTrace("FourVectorHLTOnline") <<"\t module index = "<< l1Index << std::endl;
547 
548  }
549 
550  // monitor L1 object
551  mon->monitorL1(l1Index, this);
552 
553  // monitor Online (only if HLT passed)
555  bool numpassed = false;
556 
557  // did we pass the numerator path, i.e. HLT path?
558  for(int i = 0; i < npath; ++i) {
559 
560  if (triggerNames.triggerName(i) == v->getPath() && triggerResults->accept(i)) numpassed = true;
561 
562  }
563 
564  if (!numpassed) continue;
565 
566  if (!l1accept) {
567 
568  LogDebug("FourVectorHLTOnline")
569  << "This should not happen. HLT passed, but L1 Seed not passed for hlt path "<< std::endl
570  << "HLT path: " << v->getPath() << "\t HLTLevel1GTSeed: " << v->getl1Path();
571 
572  }
573 
574  // fill scaler histograms
575  edm::InputTag filterTag = v->getTag();
576 
577  // loop through indices and see if the filter is
578  // on the list of filters used by this path
579  //----------------------------------------------
580  if (v->getLabel() == "dummy"){
581  const std::vector<std::string> filterLabels = hltConfig_.moduleLabels(v->getPath());
582 
583  //loop over labels
584  for (std::vector<std::string>::const_iterator labelIter= filterLabels.begin(); labelIter!=filterLabels.end(); labelIter++) {
585 
586  edm::InputTag testTag(*labelIter,"",processname_);
587 
588  int testindex = fTriggerObj->filterIndex(testTag);
589 
590  // last match wins...
591  if ( !(testindex >= fTriggerObj->sizeFilters()) ) {
592 
593  filterTag = testTag;
594  v->setLabel(*labelIter);}
595 
596  }
597 
598  } // end for
599 
600  const int hltIndex = fTriggerObj->filterIndex(filterTag);
601  if ( hltIndex >= fTriggerObj->sizeFilters() ) {
602 
603  LogTrace("FourVectorHLTOnline") << "WTF no index "<< index << " of that name " << filterTag << std::endl;
604  continue; // not in this event
605 
606  }
607 
608  mon->monitorOnline(hltIndex, l1Index, this);
609 
610  mon->fillOnlineMatch(l1Index, this);
611 
612  } //denompassed
613 
614 
615  } //pathinfo loop
616 
617 }
618 
619 
620 
621 // -- method called once each job just before starting event loop --------
622 void
624 {
625  nev_ = 0;
626  DQMStore *dbe = 0;
627  dbe = Service<DQMStore>().operator->();
628 
629  if (dbe) {
631  dbe->rmdir(dirname_);
632  }
633 
634 
635  if (dbe) {
637  }
638 }
639 
640 // - method called once each job just after ending the event loop ------------
641 void
643 {
644  LogInfo("FourVectorHLTOnline") << "analyzed " << nev_ << " events";
645  return;
646 }
647 
648 
649 // BeginRun
651 {
652 
653  LogDebug("FourVectorHLTOnline") << "beginRun, run " << run.id();
654 
655  // HLT config does not change within runs!
656  bool changed=false;
657 
658  if (!hltConfig_.init(run, c, processname_, changed)) {
659 
660  processname_ = "FU";
661 
662  if (!hltConfig_.init(run, c, processname_, changed)){
663 
664  LogDebug("FourVectorHLTOnline") << "HLTConfigProvider failed to initialize.";
665 
666  }
667 
668  // check if trigger name in (new) config
669  // std::cout << "Available TriggerNames are: " << std::endl;
670  // hltConfig_.dump("Triggers");
671  }
672 
673  if (1) {
674 
675  DQMStore *dbe = 0;
676  dbe = Service<DQMStore>().operator->();
677 
678  if (dbe) {
680  }
681 
682  const unsigned int n(hltConfig_.size());
683  if (plotAll_){
684 
685  for (unsigned int j=0; j!=n; ++j) {
686 
687  std::string pathname = hltConfig_.triggerName(j);
688 
689  std::string l1pathname = getL1ConditionModuleName(pathname);
690 
691  int objectType = getTriggerTypeParsePathName(pathname);
692 
693  for (unsigned int i=0; i!=n; ++i) {
694 
695  std::string denompathname = hltConfig_.triggerName(i);
696  int denomobjectType = getTriggerTypeParsePathName(denompathname);
697 
698 
699 
700  std::string filtername("dummy");
701  float ptMin = 0.0;
702  float ptMax = 100.0;
703  if (plotAll_ && denomobjectType == objectType && objectType != 0)
704 
705  hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, filtername, processname_, objectType, ptMin, ptMax));
706 
707  }
708  }
709 
710  } // end if plotAll
711  else {
712 
713  // plot all diagonal combinations plus any other specified pairs
714  for (unsigned int i=0; i!=n; ++i) {
715 
716  std::string denompathname = "";
717  std::string pathname = hltConfig_.triggerName(i);
718  //parse pathname to guess object type
719  int objectType = getTriggerTypeParsePathName(pathname);
720 
721  std::string l1pathname = getL1ConditionModuleName(pathname);
722 
723  std::string filtername("dummy");
724  float ptMin = 0.0;
725  float ptMax = 100.0;
726 
727  if (objectType == trigger::TriggerPhoton) ptMax = 100.0;
728  if (objectType == trigger::TriggerElectron) ptMax = 100.0;
729  if (objectType == trigger::TriggerMuon) ptMax = 150.0;
730  if (objectType == trigger::TriggerTau) ptMax = 100.0;
731  if (objectType == trigger::TriggerJet) ptMax = 300.0;
732  if (objectType == trigger::TriggerBJet) ptMax = 300.0;
733  if (objectType == trigger::TriggerMET) ptMax = 300.0;
734  if (objectType == trigger::TriggerTET) ptMax = 300.0;
735  if (objectType == trigger::TriggerTrack) ptMax = 100.0;
736 
737  // keep track of all paths, except for FinalPath
738  if (objectType != -1 && pathname.find("FinalPath") == std::string::npos){
739 
740  hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, filtername, processname_, objectType, ptMin, ptMax));
741 
742  hltPathsDiagonal_.push_back(PathInfo(denompathname, pathname, l1pathname, filtername, processname_, objectType, ptMin, ptMax));
743 
744  }
745 
746  } // end for i
747 
748 
749  // now loop over denom/num path pairs specified in cfg,
750  // recording the off-diagonal ones
751  for (std::vector<std::pair<std::string, std::string> >::iterator custompathnamepair = custompathnamepairs_.begin(); custompathnamepair != custompathnamepairs_.end(); ++custompathnamepair) {
752 
753  std::string numpathname = custompathnamepair->first;
754  std::string denompathname = custompathnamepair->second;
755 
756  if (numpathname != denompathname) {
757 
758  // check that denominator exists
759  bool founddenominator = false;
760  for (unsigned int k=0; k!=n; ++k) {
761 
762  std::string n_pathname = hltConfig_.triggerName(k);
763 
764  if (n_pathname.find(denompathname) != std::string::npos) {
765 
766  LogDebug("FourVectorHLTOnline") << "denompathname is selected to be = " << n_pathname << std::endl;;
767  founddenominator = true;
768 
769  break;
770 
771  }
772  }
773 
774  if (!founddenominator) {
775 
776  edm::LogInfo("FourVectorHLTOnline") << "denompathname not found, go to the next pair numearator-denominator" << std::endl;
777 
778  // go to the next pair
779  continue;
780 
781  }
782 
783  // check that numerator exists
784  bool foundnumerator = false;
785  for (unsigned int j=0; j!=n; ++j) {
786 
787  std::string pathname = hltConfig_.triggerName(j);
788 
789  LogDebug("FourVectorHLTOnline") << "check if path " << pathname << " is numpathname = " << numpathname << std::endl;
790  if (hltConfig_.triggerName(j).find(numpathname)!= std::string::npos) {
791 
792  LogDebug("FourVectorHLTOnline") << "pathname is selected to be = " << denompathname << std::endl;;
793  foundnumerator = true;
794 
795  }
796 
797 
798  if (!foundnumerator) {
799 
800  edm::LogInfo("FourVectorHLTOnline") << "pathname not found, ignoring " << pathname;
801  continue;
802 
803  }
804 
805 
806  std::string l1pathname = getL1ConditionModuleName(pathname);
807  int objectType = getTriggerTypeParsePathName(pathname);
808 
809  std::string filtername("dummy");
810  float ptMin = 0.0;
811  float ptMax = 100.0;
812  if (objectType == trigger::TriggerPhoton) ptMax = 100.0;
813  if (objectType == trigger::TriggerElectron) ptMax = 100.0;
814  if (objectType == trigger::TriggerMuon) ptMax = 150.0;
815  if (objectType == trigger::TriggerTau) ptMax = 100.0;
816  if (objectType == trigger::TriggerJet) ptMax = 300.0;
817  if (objectType == trigger::TriggerBJet) ptMax = 300.0;
818  if (objectType == trigger::TriggerMET) ptMax = 300.0;
819  if (objectType == trigger::TriggerTET) ptMax = 300.0;
820  if (objectType == trigger::TriggerTrack) ptMax = 100.0;
821 
822  // monitor regardless of the objectType of the path
823  if (objectType != 0)
824  hltPaths_.push_back(PathInfo(denompathname, pathname, l1pathname, filtername, processname_, objectType, ptMin, ptMax));
825 
826  } // end for j, loop over paths
827 
828  } // end if not same num and denominator
829 
830  } // end for pair
831 
832  } // end else
833 
834 
835  std::vector<std::string> muonPaths;
836  std::vector<std::string> egammaPaths;
837  std::vector<std::string> tauPaths;
838  std::vector<std::string> jetmetPaths;
839  std::vector<std::string> restPaths;
840  std::vector<std::string> allPaths;
841  // fill vectors of Muon, Egamma, JetMet, Rest, and Special paths
842  for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) {
843 
844  std::string pathName = v->getPath();
845  int objectType = v->getObjectType();
846 
847  std::vector<int> tempCount(5,0);
848 
849  fPathTempCountPair.push_back(make_pair(pathName,0));
850  fPathBxTempCountPair.push_back(make_pair(pathName,tempCount));
851 
852  allPaths.push_back(pathName);
853 
854  switch (objectType) {
855  case trigger::TriggerMuon :
856  muonPaths.push_back(pathName);
857  break;
858 
861  egammaPaths.push_back(pathName);
862  break;
863 
864  case trigger::TriggerTau :
865  tauPaths.push_back(pathName);
866  break;
867 
868  case trigger::TriggerJet :
869  case trigger::TriggerMET :
870  jetmetPaths.push_back(pathName);
871  break;
872 
873  default:
874  restPaths.push_back(pathName);
875  }
876 
877  }
878 
879  fPathTempCountPair.push_back(make_pair("HLT_Any",0));
880 
881  fGroupName.push_back("All");
882  fGroupName.push_back("Muon");
883  fGroupName.push_back("Egamma");
884  fGroupName.push_back("Tau");
885  fGroupName.push_back("JetMet");
886  fGroupName.push_back("Rest");
887  fGroupName.push_back("Special");
888 
889  for(unsigned int g=0; g<fGroupName.size(); g++) {
890 
891  //fGroupTempCountPair.push_back(make_pair(fGroupName[g],0));
892  //fGroupL1TempCountPair.push_back(make_pair(fGroupName[g],0));
893 
894  }
895 
897 
898 
899 
900  fGroupNamePathsPair.push_back(make_pair("All",allPaths));
901 
902  fGroupNamePathsPair.push_back(make_pair("Muon",muonPaths));
903 
904  fGroupNamePathsPair.push_back(make_pair("Egamma",egammaPaths));
905 
906  fGroupNamePathsPair.push_back(make_pair("Tau",tauPaths));
907 
908  fGroupNamePathsPair.push_back(make_pair("JetMet",jetmetPaths));
909 
910  fGroupNamePathsPair.push_back(make_pair("Rest",restPaths));
911 
912  fGroupNamePathsPair.push_back(make_pair("Special",specialPaths_));
913 
915  std::vector<std::string> datasetNames = hltConfig_.datasetNames() ;
916  for (unsigned int i=0;i<datasetNames.size();i++) {
917 
918  std::vector<std::string> datasetPaths = hltConfig_.datasetContent(datasetNames[i]);
919  fGroupNamePathsPair.push_back(make_pair(datasetNames[i],datasetPaths));
920  //setupHltMatrix(datasetNames[i],datasetPaths);
921 
922  }
923 
924  /*
925  setupHltMatrix("All", allPaths);
926  setupHltMatrix("Muon", muonPaths);
927  setupHltMatrix("Egamma", egammaPaths);
928  setupHltMatrix("Tau", tauPaths);
929  setupHltMatrix("JetMET", jetmetPaths);
930  setupHltMatrix("Rest", restPaths);
931  setupHltMatrix("Special", specialPaths_);
932  */
933 
934  for (unsigned int g=0;g<fGroupNamePathsPair.size();g++) {
935 
936  fGroupTempCountPair.push_back(make_pair(fGroupNamePathsPair[g].first,0));
937  fGroupL1TempCountPair.push_back(make_pair(fGroupNamePathsPair[g].first,0));
939 
940  }
941  /*
942  */
943 
944  setupHltLsPlots();
945 
946  setupHltBxPlots();
947 
948 
949  for(PathInfoCollection::iterator v = hltPathsDiagonal_.begin(); v!= hltPathsDiagonal_.end(); ++v ) {
950 
951  // -------------------------
952  //
953  // Filters for each path
954  //
955  // -------------------------
956 
957  // get all modules in this HLT path
958  std::vector<std::string> moduleNames = hltConfig_.moduleLabels( v->getPath() );
959 
960  int numModule = 0;
961  std::string moduleName, moduleType;
962  unsigned int moduleIndex;
963 
964  //print module name
965  std::vector<std::string>::const_iterator iDumpModName;
966  for (iDumpModName = moduleNames.begin();iDumpModName != moduleNames.end();iDumpModName++) {
967 
968  moduleName = *iDumpModName;
969  moduleType = hltConfig_.moduleType(moduleName);
970  moduleIndex = hltConfig_.moduleIndex(v->getPath(), moduleName);
971 
972  LogTrace ("FourVectorHLTOnline") << "Module " << numModule
973  << " is called " << moduleName
974  << " , type = " << moduleType
975  << " , index = " << moduleIndex
976  << std::endl;
977 
978  numModule++;
979 
980  if((moduleType.find("Filter") != std::string::npos && moduleType.find("HLTTriggerTypeFilter") == std::string::npos ) ||
981  (moduleType.find("Associator") != std::string::npos) ||
982  (moduleType.find("HLTLevel1GTSeed") != std::string::npos) ||
983  (moduleType.find("HLTGlobalSumsCaloMET") != std::string::npos) ||
984  (moduleType.find("HLTPrescaler") != std::string::npos) ) {
985 
986  //std::pair<std::string, int> filterIndexPair;
987  //filterIndexPair.first = moduleName;
988  //filterIndexPair.second = moduleIndex;
989  //v->filtersAndIndices.push_back(filterIndexPair);
990  v->filtersAndIndices.push_back(make_pair(moduleName,moduleIndex));
991 
992  }
993 
994 
995  }//end for modulesName
996 
998 
999  //int nbin_sub = 5;
1000  int nbin_sub = v->filtersAndIndices.size()+2;
1001 
1002  // count plots for subfilter
1003  MonitorElement* filters = dbe_->book1D("Filters_" + v->getPath(),
1004  "Filters_" + v->getPath(),
1005  nbin_sub+1, -0.5, 0.5+(double)nbin_sub);
1006 
1007  for(unsigned int filt = 0; filt < v->filtersAndIndices.size(); filt++){
1008 
1009  filters->setBinLabel(filt+1, (v->filtersAndIndices[filt]).first);
1010 
1011  }
1012 
1013  // book Count vs LS
1015  MonitorElement* tempME = dbe_->book1D(v->getPath() + "_count_per_LS",
1016  v->getPath() + " count per LS",
1017  nLS_, 0,nLS_);
1018  tempME->setAxisTitle("Luminosity Section");
1019 
1020  v->setFilterHistos(filters);
1021 
1022  } // end for paths
1023 
1024  // now set up all of the histos for each path-denom
1025  for(PathInfoCollection::iterator v = hltPaths_.begin(); v!= hltPaths_.end(); ++v ) {
1026 
1027  MonitorElement *NOn, *onEtOn, *onOneOverEtOn, *onEtavsonPhiOn=0;
1028  MonitorElement *NOff, *offEtOff, *offEtavsoffPhiOff=0;
1029  MonitorElement *NL1, *l1EtL1, *l1Etavsl1PhiL1=0;
1030  MonitorElement *NL1On, *l1EtL1On, *l1Etavsl1PhiL1On=0;
1031  MonitorElement *NL1Off, *offEtL1Off, *offEtavsoffPhiL1Off=0;
1032  MonitorElement *NOnOff, *offEtOnOff, *offEtavsoffPhiOnOff=0;
1033  MonitorElement *NL1OnUM, *l1EtL1OnUM, *l1Etavsl1PhiL1OnUM=0;
1034  MonitorElement *NL1OffUM, *offEtL1OffUM, *offEtavsoffPhiL1OffUM=0;
1035  MonitorElement *NOnOffUM, *offEtOnOffUM, *offEtavsoffPhiOnOffUM=0;
1036  MonitorElement *offDRL1Off, *offDROnOff, *l1DRL1On=0;
1037 
1038 
1039  std::string labelname("dummy");
1040  labelname = v->getPath() + "_wrt_" + v->getDenomPath();
1041  std::string histoname(labelname+"_NOn");
1042  std::string title(labelname+" N online");
1043  double histEtaMax = 2.5;
1044 
1045  if (v->getObjectType() == trigger::TriggerMuon || v->getObjectType() == trigger::TriggerL1Mu) {
1046 
1047  histEtaMax = muonEtaMax_;
1048 
1049  }
1050  else if (v->getObjectType() == trigger::TriggerElectron || v->getObjectType() == trigger::TriggerL1NoIsoEG || v->getObjectType() == trigger::TriggerL1IsoEG )
1051  {
1052  histEtaMax = electronEtaMax_;
1053  }
1054  else if (v->getObjectType() == trigger::TriggerTau || v->getObjectType() == trigger::TriggerL1TauJet )
1055  {
1056  histEtaMax = tauEtaMax_;
1057  }
1058  else if (v->getObjectType() == trigger::TriggerJet || v->getObjectType() == trigger::TriggerL1CenJet || v->getObjectType() == trigger::TriggerL1ForJet )
1059  {
1060  histEtaMax = jetEtaMax_;
1061  }
1062  else if (v->getObjectType() == trigger::TriggerBJet)
1063  {
1064  histEtaMax = bjetEtaMax_;
1065  }
1066  else if (v->getObjectType() == trigger::TriggerMET || v->getObjectType() == trigger::TriggerL1ETM )
1067  {
1068  histEtaMax = metEtaMax_;
1069  }
1070  else if (v->getObjectType() == trigger::TriggerPhoton)
1071  {
1072  histEtaMax = photonEtaMax_;
1073  }
1074  else if (v->getObjectType() == trigger::TriggerTrack)
1075  {
1076  histEtaMax = trackEtaMax_;
1077  }
1078 
1079  TString pathfolder = dirname_ + TString("/") + v->getPath();
1080  dbe_->setCurrentFolder(pathfolder.Data());
1081 
1082  NOn = dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
1083 
1084 
1085  histoname = labelname+"_NOff";
1086  title = labelname+" N Off";
1087  NOff = dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
1088 
1089  histoname = labelname+"_NL1";
1090  title = labelname+" N L1";
1091  NL1 = dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
1092 
1093  histoname = labelname+"_NL1On";
1094  title = labelname+" N L1On";
1095  NL1On = dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
1096 
1097  histoname = labelname+"_NL1Off";
1098  title = labelname+" N L1Off";
1099  NL1Off = dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
1100 
1101  histoname = labelname+"_NOnOff";
1102  title = labelname+" N OnOff";
1103  NOnOff = dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
1104 
1105 
1106  histoname = labelname+"_NL1OnUM";
1107  title = labelname+" N L1OnUM";
1108  NL1OnUM = dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
1109 
1110  histoname = labelname+"_NL1OffUM";
1111  title = labelname+" N L1OffUM";
1112  NL1OffUM = dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
1113 
1114  histoname = labelname+"_NOnOffUM";
1115  title = labelname+" N OnOffUM";
1116  NOnOffUM = dbe->book1D(histoname.c_str(), title.c_str(),10, 0.5, 10.5);
1117 
1118 
1119  histoname = labelname+"_onEtOn";
1120  title = labelname+" onE_t online";
1121  onEtOn = dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
1122 
1123  histoname = labelname+"_onOneOverEtOn";
1124  title = labelname+" 1 / onE_t online";
1125  onOneOverEtOn = dbe->book1D(histoname.c_str(), title.c_str(),nBinsOneOverEt_, 0, 1);
1126  onOneOverEtOn->setAxisTitle("HLT 1/Et [1/GeV]");
1127 
1128  histoname = labelname+"_offEtOff";
1129  title = labelname+" offE_t offline";
1130  offEtOff = dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
1131 
1132  histoname = labelname+"_l1EtL1";
1133  title = labelname+" l1E_t L1";
1134  l1EtL1 = dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
1135 
1136  int nBins2D = 10;
1137 
1138 
1139  histoname = labelname+"_onEtaonPhiOn";
1140  title = labelname+" on#eta vs on#phi online";
1141  onEtavsonPhiOn = dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
1142 
1143  histoname = labelname+"_offEtaoffPhiOff";
1144  title = labelname+" off#eta vs off#phi offline";
1145  offEtavsoffPhiOff = dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
1146 
1147  histoname = labelname+"_l1Etal1PhiL1";
1148  title = labelname+" l1#eta vs l1#phi L1";
1149  l1Etavsl1PhiL1 = dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
1150 
1151  histoname = labelname+"_l1EtL1On";
1152  title = labelname+" l1E_t L1+online";
1153  l1EtL1On = dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
1154 
1155  histoname = labelname+"_offEtL1Off";
1156  title = labelname+" offE_t L1+offline";
1157  offEtL1Off = dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
1158 
1159  histoname = labelname+"_offEtOnOff";
1160  title = labelname+" offE_t online+offline";
1161  offEtOnOff = dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
1162 
1163  histoname = labelname+"_l1Etal1PhiL1On";
1164  title = labelname+" l1#eta vs l1#phi L1+online";
1165  l1Etavsl1PhiL1On = dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
1166 
1167  histoname = labelname+"_offEtaoffPhiL1Off";
1168  title = labelname+" off#eta vs off#phi L1+offline";
1169  offEtavsoffPhiL1Off = dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
1170 
1171  histoname = labelname+"_offEtaoffPhiOnOff";
1172  title = labelname+" off#eta vs off#phi online+offline";
1173  offEtavsoffPhiOnOff = dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
1174 
1175  histoname = labelname+"_l1EtL1OnUM";
1176  title = labelname+" l1E_t L1+onlineUM";
1177  l1EtL1OnUM = dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
1178 
1179  histoname = labelname+"_offEtL1OffUM";
1180  title = labelname+" offE_t L1+offlineUM";
1181  offEtL1OffUM = dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
1182 
1183  histoname = labelname+"_offEtOnOffUM";
1184  title = labelname+" offE_t online+offlineUM";
1185  offEtOnOffUM = dbe->book1D(histoname.c_str(), title.c_str(),nBins_, v->getPtMin(), v->getPtMax());
1186 
1187  histoname = labelname+"_l1Etal1PhiL1OnUM";
1188  title = labelname+" l1#eta vs l1#phi L1+onlineUM";
1189  l1Etavsl1PhiL1OnUM = dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
1190 
1191  histoname = labelname+"_offEtaoffPhiL1OffUM";
1192  title = labelname+" off#eta vs off#phi L1+offlineUM";
1193  offEtavsoffPhiL1OffUM = dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
1194 
1195  histoname = labelname+"_offEtaoffPhiOnOffUM";
1196  title = labelname+" off#eta vs off#phi online+offlineUM";
1197  offEtavsoffPhiOnOffUM = dbe->book2D(histoname.c_str(), title.c_str(), nBins2D,-histEtaMax,histEtaMax, nBins2D,-TMath::Pi(), TMath::Pi());
1198 
1199 
1200 
1201 
1202  histoname = labelname+"_l1DRL1On";
1203  title = labelname+" l1DR L1+online";
1204  l1DRL1On = dbe->book1D(histoname.c_str(), title.c_str(),nBins_, 0, 1.);
1205 
1206  histoname = labelname+"_offDRL1Off";
1207  title = labelname+" offDR L1+offline";
1208  offDRL1Off = dbe->book1D(histoname.c_str(), title.c_str(),nBins_, 0, 1.);
1209 
1210  histoname = labelname+"_offDROnOff";
1211  title = labelname+" offDR online+offline";
1212  offDROnOff = dbe->book1D(histoname.c_str(), title.c_str(),nBins_, 0, 1.);
1213 
1214 
1215  v->setHistos( NOn, onEtOn, onOneOverEtOn, onEtavsonPhiOn, NOff, offEtOff, offEtavsoffPhiOff, NL1, l1EtL1, l1Etavsl1PhiL1, NL1On, l1EtL1On, l1Etavsl1PhiL1On, NL1Off, offEtL1Off, offEtavsoffPhiL1Off, NOnOff, offEtOnOff, offEtavsoffPhiOnOff, NL1OnUM, l1EtL1OnUM, l1Etavsl1PhiL1OnUM, NL1OffUM, offEtL1OffUM, offEtavsoffPhiL1OffUM, NOnOffUM, offEtOnOffUM, offEtavsoffPhiOnOffUM, offDRL1Off, offDROnOff, l1DRL1On
1216 );
1217 
1218 
1219  } // end for hltPath
1220 
1221  // HLT_Any
1222  // book Count vs LS
1224  MonitorElement* tempME = dbe_->book1D("HLT_Any_count_per_LS",
1225  "HLT_Any count per LS",
1226  nLS_, 0,nLS_);
1227  tempME->setAxisTitle("Luminosity Section");
1228 
1229  } // end if(1) dummy
1230 
1231  return;
1232 
1233 }
1234 
1237 {
1238 
1239  LogDebug("FourVectorHLTOnline") << "endRun, run " << run.id();
1240 
1241 }
1242 
1245 {
1246 
1247  LogDebug("FourVectorHLTOnline") << "cleanDRMatchSet(mmset& tempSet) " << "size of the set (before CLEANING) = " << tempSet.size() << " maps." << std::endl;
1248 
1249  if(tempSet.size() < 2) return;
1250 
1251  if(tempSet.size() > 10) {
1252 
1253  LogDebug("FourVectorHLTOnline") << "size of the set is too large. It will be truncated to 10." << std::endl;
1254  mmset::iterator it = tempSet.begin();
1255  for (int i=0;i<10;i++) { it++; }
1256  tempSet.erase( it, tempSet.end());
1257  LogDebug("FourVectorHLTOnline") << "size of the set is now = " << tempSet.size() << " maps." << std::endl;
1258 
1259  }
1260 
1261  bool cleanedOneMap = false;
1262 
1263  // cleaning needed if the set has at least two maps
1264 
1265  while(! cleanedOneMap && tempSet.size() > 1) {
1266 
1267  cleanedOneMap=false;
1268 
1269  //LogTrace("FourVectorHLTOnline") << "cleaning: size of the set = " << tempSet.size() << " maps." << std::endl;
1270 
1271  int imap = 0;
1272  for ( mmset::iterator setIter_i = tempSet.begin( ); setIter_i != tempSet.end( ); setIter_i++ ) {
1273 
1274  fimmap tempMap_j = *setIter_i;
1275 
1276  //LogTrace("FourVectorHLTOnline") << " map " << imap << std::endl;
1277  //LogTrace("FourVectorHLTOnline") << " --------" << std::endl;
1278 
1279  for (fimmap::iterator it = tempMap_j.begin(); it != tempMap_j.end(); ++it) {
1280 
1281  //LogTrace("FourVectorHLTOnline") << " " << (*it).first << " : " << (*it).second << std::endl;
1282 
1283  }
1284 
1285  imap++;
1286 
1287  }
1288 
1289  // loop i
1290  for ( mmset::iterator setIter_i = tempSet.begin( ); setIter_i != tempSet.end( ); setIter_i++ ) {
1291 
1292  fimmap tempMap_i = *setIter_i;
1293  fimmap::iterator it = tempMap_i.begin();
1294  int topValue = (*it).second;
1295  //LogTrace("FourVectorHLTOnline") << " topValue = " << topValue << std::endl;
1296 
1297 
1298  mmset::iterator tempIter_i = setIter_i;
1299 
1300  // from all the other maps, clean entries that have mapped value "topValue"
1301  // loop j
1302  for ( mmset::iterator setIter_j = ++tempIter_i; setIter_j != tempSet.end( ); setIter_j++ ) {
1303 
1304  fimmap tempMap_j = *setIter_j;
1305  //LogTrace("FourVectorHLTOnline") << " size of the map = " << tempMap_j.size() << std::endl;
1306 
1307  for (fimmap::iterator it = tempMap_j.begin(); it != tempMap_j.end(); ++it)
1308  {
1309 
1310  if(topValue == (*it).second) {
1311 
1312  //LogTrace("FourVectorHLTOnline") << " Ridding map of a doubly-matched object." << std::endl;
1313  tempMap_j.erase(it);
1314  cleanedOneMap = true;
1315 
1316  }
1317 
1318  } //end for
1319 
1320  if(cleanedOneMap) {
1321 
1322  //remove the old map from the set
1323  tempSet.erase(setIter_j);
1324 
1325  // insert in the set the new map if it is not an empty map
1326  if(! tempMap_j.empty()) tempSet.insert(tempMap_j);
1327 
1328  break; // break from loop j
1329 
1330  } // end if
1331 
1332  }// end loop j
1333 
1334  if(cleanedOneMap) break; // break from loop i
1335 
1336  } // end loop i
1337 
1338  if(cleanedOneMap) {
1339 
1340  // continue cleaning (in while loop)
1341  // but reset flag first
1342  cleanedOneMap=false;
1343  continue;
1344 
1345  }
1346  else {
1347 
1348  // finished cleaing (break from while loop)
1349  break;
1350 
1351  }
1352 
1353  } // end while
1354 
1355  //LogTrace("FourVectorHLTOnline") << "cleaned: size of the set = " << tempSet.size() << " maps." << std::endl;
1356  int jmap = 0;
1357 
1358  for ( mmset::iterator setIter_i = tempSet.begin( ); setIter_i != tempSet.end( ); setIter_i++ )
1359  {
1360 
1361  fimmap tempMap_j = *setIter_i;
1362 
1363  //LogTrace("FourVectorHLTOnline") << " map " << jmap << std::endl;
1364  //LogTrace("FourVectorHLTOnline") << " --------" << std::endl;
1365 
1366  for (fimmap::iterator it = tempMap_j.begin(); it != tempMap_j.end(); ++it) {
1367 
1368  //LogTrace("FourVectorHLTOnline") << " " << (*it).first << " : " << (*it).second << std::endl;
1369 
1370  }
1371 
1372  jmap++;
1373 
1374  } // end for
1375 
1376  return;
1377 
1378 }
1379 
1380 void FourVectorHLTOnline::setupHltMatrix(std::string label, std::vector<std::string> paths) {
1381 
1382  //string groupLabelAny = "HLT_"+label+"_Any";
1383  //paths.push_back(groupLabelAny.c_str());
1384  paths.push_back("HLT_"+label+"_L1_Any");
1385  paths.push_back("HLT_"+label+"_Any");
1386  paths.push_back("HLT_Any");
1387 
1388  std::string h_name;
1389  std::string h_title;
1390 
1392 
1393  h_name= "HLT_"+label+"_PassPass";
1394  h_title = "HLT_"+label+"_PassPass (x=Pass, y=Pass)";
1395  MonitorElement* ME = dbe_->book2D(h_name.c_str(), h_title.c_str(),
1396  paths.size(), -0.5, paths.size()-0.5, paths.size(), -0.5, paths.size()-0.5);
1397 
1398  h_name= "HLT_"+label+"_Pass_Any";
1399  h_title = "HLT_"+label+"_Pass (x=Pass, Any=Pass) normalized to HLT_Any Pass";
1400  MonitorElement* ME_Any = dbe_->book1D(h_name.c_str(), h_title.c_str(),
1401  paths.size(), -0.5, paths.size()-0.5);
1402 
1404  h_name= "HLT_"+label+"_PassPass_Normalized";
1405  h_title = "HLT_"+label+"_PassPass (x=Pass, y=Pass) normalized to xBin=Pass";
1406  MonitorElement* ME_Normalized = dbe_->book2D(h_name.c_str(), h_title.c_str(),
1407  paths.size(), -0.5, paths.size()-0.5, paths.size(), -0.5, paths.size()-0.5);
1408  h_name= "HLT_"+label+"_Pass_Normalized_Any";
1409  h_title = "HLT_"+label+"_Pass (x=Pass, Any=Pass) normalized to HLT_Any Pass";
1410  MonitorElement* ME_Normalized_Any = dbe_->book1D(h_name.c_str(), h_title.c_str(),
1411  paths.size(), -0.5, paths.size()-0.5);
1412 
1414  h_name= "HLT_"+label+"_Total_LS";
1415  h_title = label+" HLT paths total count combined per LS ";
1416  MonitorElement* ME_Total_LS = dbe_->book1D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_);
1417  ME_Total_LS->setAxisTitle("LS");
1418 
1419  h_name= "HLT_"+label+"_LS";
1420  h_title = label+" HLT paths count per LS ";
1421  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);
1422  ME_Group_LS->setAxisTitle("LS");
1424  v_ME_HLTAll_LS_.push_back(ME_Group_LS);
1425 
1426  h_name= "HLT_"+label+"_L1_Total_LS";
1427  h_title = label+" HLT paths total count combined per LS ";
1428  MonitorElement* ME_Total_L1_LS = dbe_->book1D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_);
1429  ME_Total_L1_LS->setAxisTitle("LS");
1430 
1431  h_name= "HLT_"+label+"_L1_LS";
1432  h_title = label+" HLT L1s count per LS ";
1433  MonitorElement* ME_Group_L1_LS = dbe_->book2D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_, paths.size(), -0.5, paths.size()-0.5);
1434  ME_Group_L1_LS->setAxisTitle("LS");
1435 
1437  h_name= "HLT_"+label+"_BX_LS";
1438  h_title = label+" HLT paths total count combined per BX ";
1439  MonitorElement* ME_Total_BX = dbe_->book2D(h_name.c_str(), h_title.c_str(), nLS_, 0, nLS_, 5, -2.5, 2.5);
1440  ME_Total_BX->setAxisTitle("LS",1);
1441 
1442  for(unsigned int i = 0; i < paths.size(); i++){
1443 
1444  ME->getTH2F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
1445  ME->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
1446  ME_Group_LS->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
1447 
1448  ME_Normalized->getTH2F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
1449  ME_Normalized->getTH2F()->GetYaxis()->SetBinLabel(i+1, (paths[i]).c_str());
1450  ME_Normalized_Any->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
1451  ME_Any->getTH1F()->GetXaxis()->SetBinLabel(i+1, (paths[i]).c_str());
1452 
1453  }
1454 
1455 }
1456 
1458 
1459  std::string fullPathToME;
1460 
1461  //for (unsigned int mi=0;mi<fGroupName.size();mi++) {
1462  for (unsigned int mi=0;mi<fGroupNamePathsPair.size();mi++) {
1463 
1464 
1465  fullPathToME = "HLT/FourVector/PathsSummary/HLT_"+fGroupNamePathsPair[mi].first+"_PassPass";
1466  MonitorElement* ME_2d = dbe_->get(fullPathToME);
1467  fullPathToME = "HLT/FourVector/PathsSummary/HLT_"+fGroupNamePathsPair[mi].first+"_Pass_Any";
1468  MonitorElement* ME_1d = dbe_->get(fullPathToME);
1469  if(!ME_2d || !ME_1d) {
1470 
1471  LogTrace("FourVectorHLTOnline") << " ME not valid although I gave full path" << std::endl;
1472  continue;
1473 
1474  }
1475 
1476  TH2F * hist_2d = ME_2d->getTH2F();
1477  TH1F * hist_1d = ME_1d->getTH1F();
1478 
1479  // Fill HLTPassed Matrix bin (i,j) = (Any,Any)
1480  // --------------------------------------------------------
1481  int anyBinNumber = hist_2d->GetXaxis()->FindBin("HLT_Any");
1482  // any triger accepted
1483  if(triggerResults_->accept()){
1484 
1485  hist_2d->Fill(anyBinNumber-1,anyBinNumber-1);//binNumber1 = 0 = first filter
1486  hist_1d->Fill(anyBinNumber-1);//binNumber1 = 0 = first filter
1487 
1488  }
1489 
1490  bool groupPassed = false;
1491  bool groupL1Passed = false;
1492 
1493  // Main loop over paths
1494  // --------------------
1495 
1496  for (int i=1; i< hist_2d->GetNbinsX();i++) {
1497 
1498  std::string hltpathname = hist_2d->GetXaxis()->GetBinLabel(i);
1499 
1500 
1501  // check if this is hlt path name
1502  unsigned int pathByIndex = triggerNames.triggerIndex(hltpathname);
1503  if(pathByIndex >= triggerResults_->size() ) continue;
1504 
1505  // check if its L1 passed
1506  if(hasL1Passed(hltpathname,triggerNames)) groupL1Passed = true;
1507 
1508  // Fill HLTPassed Matrix and HLTPassFail Matrix
1509  // --------------------------------------------------------
1510 
1511  if(triggerResults_->accept(pathByIndex)){
1512 
1513  groupPassed = true;
1514  //groupL1Passed = true;
1515 
1516  if(groupPassed && !groupL1Passed)
1517 
1518  hist_2d->Fill(i-1,anyBinNumber-1);//binNumber1 = 0 = first filter
1519  hist_2d->Fill(anyBinNumber-1,i-1);//binNumber1 = 0 = first filter
1520 
1521  hist_1d->Fill(i-1);//binNumber1 = 0 = first filter
1522 
1523  for (int j=1; j< hist_2d->GetNbinsY();j++) {
1524 
1525  unsigned int crosspathByIndex = triggerNames.triggerIndex(hist_2d->GetXaxis()->GetBinLabel(j));
1526  if(crosspathByIndex >= triggerResults_->size() ) continue;
1527 
1528  if(triggerResults_->accept(crosspathByIndex)){
1529 
1530  hist_2d->Fill(i-1,j-1);//binNumber1 = 0 = first filter
1531 
1532  } // end if j path passed
1533 
1534  } // end for j
1535 
1536  } // end if i passed
1537 
1538 
1539  } // end for i
1540 
1541  std::string groupBinLabel = "HLT_"+fGroupNamePathsPair[mi].first+"_Any";
1542  int groupBinNumber = hist_2d->GetXaxis()->FindBin(groupBinLabel.c_str());
1543  if(groupPassed) hist_1d->Fill(groupBinNumber-1);//binNumber1 = 0 = first filter
1544 
1545  std::string groupL1BinLabel = "HLT_"+fGroupNamePathsPair[mi].first+"_L1_Any";
1546  int groupL1BinNumber = hist_2d->GetXaxis()->FindBin(groupL1BinLabel.c_str());
1547 
1548  if(groupL1Passed) hist_1d->Fill(groupL1BinNumber-1);//binNumber1 = 0 = first filter
1549  } // end for mi
1550 
1551 }
1552 
1554 {
1555 
1556  //pathsSummaryFolder_ = TString("HLT/FourVector/PathsSummary/");
1557  //dbe_->setCurrentFolder(pathsSummaryFolder_.c_str());
1559 
1560  // setup HLT bx plot
1561  unsigned int npaths = hltPathsDiagonal_.size();
1562 
1563  ME_HLT_BX_ = dbe_->book2D("HLT_bx",
1564  "HLT counts vs Event bx",
1565  Nbx_+1, -0.5, Nbx_+1-0.5, npaths, -0.5, npaths-0.5);
1566  ME_HLT_CUSTOM_BX_ = dbe_->book2D("HLT_Custom_bx",
1567  "HLT counts vs Event bx",
1568  Nbx_+1, -0.5, Nbx_+1-0.5, npaths, -0.5, npaths-0.5);
1569  ME_HLT_BX_->setAxisTitle("Bunch Crossing");
1570  ME_HLT_CUSTOM_BX_->setAxisTitle("Bunch Crossing");
1571 
1572 
1573  // Set up bin labels on Y axis continuing to cover all npaths
1574  for(unsigned int i = 0; i < npaths; i++){
1575 
1576  ME_HLT_BX_->getTH2F()->GetYaxis()->SetBinLabel(i+1, (hltPathsDiagonal_[i]).getPath().c_str());
1577  ME_HLT_CUSTOM_BX_->getTH2F()->GetYaxis()->SetBinLabel(i+1, (hltPathsDiagonal_[i]).getPath().c_str());
1578 
1579  }
1580 
1581 
1582 }
1583 
1585 {
1586 
1587  unsigned int npaths = hltPathsDiagonal_.size();
1588 
1589  //pathsSummaryHLTPathsPerLSFolder_ = TString("HLT/FourVector/PathsSummary/HLT LS/");
1590  //dbe_->setCurrentFolder(pathsSummaryHLTPathsPerLSFolder_.c_str());
1592 
1593  ME_HLTAll_LS_ = dbe_->book2D("All_count_LS",
1594  "All paths per LS ",
1595  nLS_, 0, nLS_, npaths+1, -0.5, npaths+1-0.5);
1596  ME_HLTAll_LS_->setAxisTitle("Luminosity Section");
1597 
1598  // Set up bin labels on Y axis continuing to cover all npaths
1599  for(unsigned int i = 0; i < npaths; i++){
1600 
1601  ME_HLTAll_LS_->getTH2F()->GetYaxis()->SetBinLabel(i+1, (hltPathsDiagonal_[i]).getPath().c_str());
1602 
1603  }
1604 
1605  unsigned int i = npaths;
1606  ME_HLTAll_LS_->getTH2F()->GetYaxis()->SetBinLabel(i+1, "HLT_Any");
1607 
1608  int nBinsPerLSHisto = 20;
1609  int nLSHistos = npaths/nBinsPerLSHisto;
1610  for (int nh=0;nh<nLSHistos+1;nh++) {
1611 
1612  char name[200];
1613  char title[200];
1614 
1615  sprintf(name, "Group_%d_paths_count_LS",nLSHistos-nh);
1616  sprintf(title, "Group %d, paths count per LS",nLSHistos-nh);
1617 
1618  MonitorElement* tempME = dbe_->book2D(name,title,
1619  nLS_, 0, nLS_, nBinsPerLSHisto+3, -0.5, nBinsPerLSHisto+3-0.5);
1620 
1621  tempME->setAxisTitle("LS");
1622 
1623  // Set up bin labels on Y axis continuing to cover all npaths
1624  for(int i = nh*nBinsPerLSHisto; i < (nh+1)*nBinsPerLSHisto; i++){
1625 
1626  if (i == int(npaths)) break;
1627 
1628  int bin;
1629  if(nh == 0){
1630 
1631  bin = i;
1632 
1633  }
1634  else {
1635 
1636  bin = i % nBinsPerLSHisto;
1637 
1638  }
1639 
1640  tempME->setBinLabel(bin+1, hltPathsDiagonal_[i].getPath().c_str(), 2);
1641 
1642  }
1643 
1644  tempME->setBinLabel(nBinsPerLSHisto+3, "HLT_Any", 2);
1645  tempME->setBinLabel(nBinsPerLSHisto+2, "HLT_PhysicsDeclared", 2);
1646 
1647  v_ME_HLTAll_LS_.push_back(tempME);
1648 
1649  }
1650 
1651 
1652 }
1653 
1654 
1656 
1657  //int lumi = int(lumiSeg.id().luminosityBlock());
1658  //if(lumi < 74 || lumi > 77) fLumiFlag = false;
1659  //else fLumiFlag = true;
1660 
1661 }
1662 
1664 {
1665 
1666  int lumi = int(lumiSeg.id().luminosityBlock());
1667  LogTrace("FourVectorHLTOnline") << " end lumiSection number " << lumi << std::endl;
1668 
1672 
1674 
1675 }
1676 
1678 {
1679 
1680  LogTrace("FourVectorHLTOnline") << " countHLTGroupBXHitsEndLumiBlock() lumiSection number " << lumi << std::endl;
1681 
1682  TH2F * hist_2d_bx = ME_HLT_BX_->getTH2F();
1683 
1684  for (std::vector<std::pair<std::string, std::vector<int> > >::iterator ip = fPathBxTempCountPair.begin(); ip != fPathBxTempCountPair.end(); ++ip) {
1685 
1686  // get the path and its previous count
1687  std::string pathname = ip->first;
1688  std::vector<int> prevCount = ip->second;
1689 
1690  // vector of 5 zeros
1691  std::vector<int> currCount (5,0);
1692  std::vector<int> diffCount (5,0);
1693 
1694  // get the current count of path up to now
1695  int pathBin = hist_2d_bx->GetYaxis()->FindBin(pathname.c_str());
1696 
1697  if(pathBin > hist_2d_bx->GetNbinsY()) {
1698 
1699  LogTrace("FourVectorHLTOnline") << " Cannot find the bin for path " << pathname << std::endl;
1700  continue;
1701 
1702  }
1703 
1704  for (unsigned int j =0;j<currCount.size();j++) {
1705 
1706  int bxOffset = j-2;
1707  int bunch = referenceBX_+bxOffset;
1708  if(bunch < 1) bunch += Nbx_ ;
1709  int bxBin = bunch +1; // add one to get the right bin
1710 
1711 
1712  currCount[j] = int(hist_2d_bx->GetBinContent(bxBin, pathBin)); // add one to get the right bin
1713 
1714  LogTrace("FourVectorHLTOnline") << "currCount = " << currCount[j] << std::endl;
1715 
1716  // count due to prev lumi sec is a difference bw current and previous
1717  diffCount[j] = currCount[j] - prevCount[j];
1718 
1719  LogTrace("FourVectorHLTOnline") << " lumi = " << lumi << " path " << pathname << "bxOffset = " << bxOffset << " count = " << diffCount[j] << std::endl;
1720 
1721  // set the counter in the pair to current count
1722  ip->second = currCount;
1723 
1724  } // end for bx j
1725 
1727  // fill the 2D Group paths' BX count per LS
1729  LogTrace("FourVectorHLTOnline") << "Find " << pathname << std::endl;
1730  for(unsigned int i=0; i<fGroupName.size(); i++){
1731 
1732  bool isMember = false;
1733  //check if the path is in this group
1734  for (unsigned int j=0;j<fGroupNamePathsPair.size();j++) {
1735 
1736  LogTrace("FourVectorHLTOnline") << " ---- Group " << fGroupNamePathsPair[j].first << std::endl;
1737  if(fGroupNamePathsPair[j].first != fGroupName[i]) continue;
1738 
1739  for (unsigned int k = 0; k<(fGroupNamePathsPair[j].second).size();k++) {
1740 
1741  LogTrace("FourVectorHLTOnline") << " comparing to " << fGroupNamePathsPair[j].second[k] << std::endl;
1742 
1743  if(fGroupNamePathsPair[j].second[k] == pathname) {
1744 
1745  isMember = true;
1746  break;
1747 
1748  }
1749 
1750  } // end for k
1751  } // end for j
1752 
1753 
1754  if(!isMember) {
1755 
1756  LogTrace("FourVectorHLTOnline") << "Could not find a group to which the path belongs, path = " << pathname << " group = " << fGroupName[i] << std::endl;
1757  continue;
1758 
1759  }
1760 
1761  std::string fullPathToME = pathsSummaryHLTPathsPerBXFolder_ + "HLT_"+fGroupName[i] + "_BX_LS";
1762  MonitorElement* ME_2d = dbe_->get(fullPathToME);
1763 
1764  if ( ME_2d) {
1765 
1766  TH2F* hist_All = ME_2d->getTH2F();
1767 
1768  for (unsigned int j = 0; j<diffCount.size();j++) {
1769 
1770  // find the bin
1771  int binNumber = j+1; // add one to get right bin
1772 
1773  // update the bin content (must do that since events don't ncessarily come in the order
1774  int currentLumiCount = int(hist_All->GetBinContent(lumi+1,binNumber));
1775  int updatedLumiCount = currentLumiCount + diffCount[j];
1776  hist_All->SetBinContent(lumi+1,binNumber,updatedLumiCount);
1777  } // end for bx j
1778 
1779  }
1780  else {
1781 
1782  LogDebug("FourVectorHLTOnline") << " cannot find ME_2d" << ME_2d->getName() << std::endl;
1783 
1784  }
1785 
1786 
1787  } // end for group i
1788 
1789  } // end for ip
1790 
1791 }
1792 
1794 {
1795 
1796  LogTrace("FourVectorHLTOnline") << " countHLTGroupL1HitsEndLumiBlock() lumiSection number " << lumi << std::endl;
1797 
1798  //for(unsigned int i=0; i<fGroupName.size(); i++){
1799  for(unsigned int i=0; i<fGroupNamePathsPair.size(); i++){
1800 
1801  // get the count of path up to now
1802  std::string fullPathToME = "HLT/FourVector/PathsSummary/HLT_" + fGroupNamePathsPair[i].first+ "_Pass_Any";
1803  MonitorElement* ME_1d = dbe_->get(fullPathToME);
1804 
1805  if(! ME_1d) {
1806 
1807  LogTrace("FourVectorHLTOnline") << " could not find 1d matrix " << fullPathToME << std::endl;
1808 
1809  continue;
1810 
1811  }
1812 
1813  LogTrace("FourVectorHLTOnline") << " Looking in histogram " << fullPathToME << std::endl;
1814 
1815  TH1F * hist_1d = ME_1d->getTH1F();
1816 
1817  for (std::vector<std::pair<std::string, int> >::iterator ip = fGroupL1TempCountPair.begin(); ip != fGroupL1TempCountPair.end(); ++ip) {
1818 
1819  // get the path and its previous count
1820  std::string pathname = ip->first;
1821  int prevCount = ip->second;
1822 
1823  std::string binLabel = "HLT_"+pathname+"_L1_Any";
1824 
1825  LogTrace("FourVectorHLTOnline") << " Looking for binLabel = " << binLabel << std::endl;
1826  // get the current count of path up to now
1827  int pathBin = hist_1d->GetXaxis()->FindBin(binLabel.c_str());
1828 
1829  LogTrace("FourVectorHLTOnline") << " pathBin = " << pathBin << " out of histogram total number of bins " << hist_1d->GetNbinsX() << std::endl;
1830  if(pathBin == -1) {
1831 
1832  LogTrace("FourVectorHLTOnline") << " Cannot find the bin for path " << pathname << std::endl;
1833  continue;
1834 
1835  }
1836 
1837  int currCount = int(hist_1d->GetBinContent(pathBin));
1838 
1839  // count due to prev lumi sec is a difference bw current and previous
1840  int diffCount = currCount - prevCount;
1841 
1842  LogTrace("FourVectorHLTOnline") << " lumi = " << lumi << " path " << pathname << " count " << diffCount << std::endl;
1843 
1844  // set the counter in the pair to current count
1845  ip->second = currCount;
1846 
1847 
1849  // fill the 1D individual path count per LS
1851  std::string fullPathToME_count = pathsSummaryHLTPathsPerLSFolder_ +"HLT_" + pathname + "_L1_Total_LS";
1852  MonitorElement* ME_1d = dbe_->get(fullPathToME_count);
1853  if ( ME_1d) {
1854 
1855  // update the bin content (must do that since events don't ncessarily come in the order
1856  int currentLumiCount = int(ME_1d->getTH1()->GetBinContent(lumi+1));
1857  int updatedLumiCount = currentLumiCount + diffCount;
1858  ME_1d->getTH1()->SetBinContent(lumi+1,updatedLumiCount);
1859 
1860  }
1861  else {
1862 
1863  LogDebug("FourVectorHLTOnline") << " cannot find ME " << fullPathToME_count << std::endl;
1864 
1865  }
1866 
1867  } // end for ip
1868 
1869  } // end for i
1870 
1871 }
1872 
1873 
1875 {
1876 
1877  LogTrace("FourVectorHLTOnline") << " countHLTGroupHitsEndLumiBlock() lumiSection number " << lumi << std::endl;
1878  //for(unsigned int i=0; i<fGroupName.size(); i++){
1879  for(unsigned int i=0; i<fGroupNamePathsPair.size(); i++){
1880 
1881  // get the count of path up to now
1882  //string fullPathToME = "HLT/FourVector/PathsSummary/HLT_" + fGroupName[i] + "_Pass_Any";
1883  std::string fullPathToME = "HLT/FourVector/PathsSummary/HLT_" + fGroupNamePathsPair[i].first + "_Pass_Any";
1884  MonitorElement* ME_1d = dbe_->get(fullPathToME);
1885 
1886  if(! ME_1d) {
1887 
1888  LogTrace("FourVectorHLTOnline") << " could not find 1d matrix " << fullPathToME << std::endl;
1889 
1890  continue;
1891 
1892  }
1893 
1894  LogTrace("FourVectorHLTOnline") << " Looking in histogram " << fullPathToME << std::endl;
1895 
1896  TH1F * hist_1d = ME_1d->getTH1F();
1897 
1898  for (std::vector<std::pair<std::string, int> >::iterator ip = fGroupTempCountPair.begin(); ip != fGroupTempCountPair.end(); ++ip) {
1899 
1900  // get the path and its previous count
1901  std::string pathname = ip->first;
1902  int prevCount = ip->second;
1903 
1904  std::string binLabel = "HLT_"+pathname+"_Any";
1905 
1906  LogTrace("FourVectorHLTOnline") << " Looking for binLabel = " << binLabel << std::endl;
1907  // get the current count of path up to now
1908  int pathBin = hist_1d->GetXaxis()->FindBin(binLabel.c_str());
1909 
1910  LogTrace("FourVectorHLTOnline") << " pathBin = " << pathBin << " out of histogram total number of bins " << hist_1d->GetNbinsX() << std::endl;
1911  if(pathBin == -1) {
1912 
1913  LogTrace("FourVectorHLTOnline") << " Cannot find the bin for path " << pathname << std::endl;
1914  continue;
1915 
1916  }
1917 
1918  int currCount = int(hist_1d->GetBinContent(pathBin));
1919 
1920  // count due to prev lumi sec is a difference bw current and previous
1921  int diffCount = currCount - prevCount;
1922 
1923  LogTrace("FourVectorHLTOnline") << " lumi = " << lumi << " path " << pathname << " count " << diffCount << std::endl;
1924 
1925  // set the counter in the pair to current count
1926  ip->second = currCount;
1927 
1928 
1930  // fill the 1D individual path count per LS
1932  std::string fullPathToME_count = pathsSummaryHLTPathsPerLSFolder_ +"HLT_" + pathname + "_Total_LS";
1933  MonitorElement* ME_1d = dbe_->get(fullPathToME_count);
1934  if ( ME_1d) {
1935 
1936  // update the bin content (must do that since events don't ncessarily come in the order
1937  int currentLumiCount = int(ME_1d->getTH1()->GetBinContent(lumi+1));
1938  int updatedLumiCount = currentLumiCount + diffCount;
1939  ME_1d->getTH1()->SetBinContent(lumi+1,updatedLumiCount);
1940 
1941  }
1942  else {
1943 
1944  LogDebug("FourVectorHLTOnline") << " cannot find ME " << fullPathToME_count << std::endl;
1945 
1946  }
1947 
1948  } // end for ip
1949 
1950  } // end for i
1951 
1952 }
1953 
1954 
1956 {
1957 
1958  LogTrace("FourVectorHLTOnline") << " countHLTPathHitsEndLumiBlock() lumiSection number " << lumi << std::endl;
1959  // get the count of path up to now
1960  std::string fullPathToME = "HLT/FourVector/PathsSummary/HLT_All_PassPass";
1961  MonitorElement* ME_2d = dbe_->get(fullPathToME);
1962 
1963  if(! ME_2d) {
1964 
1965  LogTrace("FourVectorHLTOnline") << " could not fine 2d matrix " << fullPathToME << std::endl;
1966 
1967  return;
1968 
1969  }
1970 
1971  TH2F * hist_2d = ME_2d->getTH2F();
1972 
1973  for (std::vector<std::pair<std::string, int> >::iterator ip = fPathTempCountPair.begin(); ip != fPathTempCountPair.end(); ++ip) {
1974 
1975  // get the path and its previous count
1976  std::string pathname = ip->first;
1977  int prevCount = ip->second;
1978 
1979  // get the current count of path up to now
1980  int pathBin = hist_2d->GetXaxis()->FindBin(pathname.c_str());
1981 
1982  if(pathBin > hist_2d->GetNbinsX()) {
1983 
1984  LogTrace("FourVectorHLTOnline") << " Cannot find the bin for path " << pathname << std::endl;
1985  continue;
1986 
1987  }
1988 
1989  int currCount = int(hist_2d->GetBinContent(pathBin, pathBin));
1990 
1991  // count due to prev lumi sec is a difference bw current and previous
1992  int diffCount = currCount - prevCount;
1993 
1994  LogTrace("FourVectorHLTOnline") << " lumi = " << lumi << " path " << pathname << " count " << diffCount << std::endl;
1995 
1996  // set the counter in the pair to current count
1997  ip->second = currCount;
1998 
2000  // fill the 2D All paths' count per LS
2002  if ( ME_HLTAll_LS_) {
2003 
2004  TH2F* hist_All = ME_HLTAll_LS_->getTH2F();
2005 
2006  // find the bin
2007  int pathBinNumber = hist_All->GetYaxis()->FindBin(pathname.c_str());
2008 
2009  // update the bin content (must do that since events don't ncessarily come in the order
2010  int currentLumiCount = int(hist_All->GetBinContent(lumi+1,pathBinNumber));
2011  int updatedLumiCount = currentLumiCount + diffCount;
2012  hist_All->SetBinContent(lumi+1,pathBinNumber,updatedLumiCount);
2013 
2014  }
2015  else {
2016 
2017  LogDebug("FourVectorHLTOnline") << " cannot find ME_HLTAll_LS_" << std::endl;
2018 
2019  }
2020 
2021  for (unsigned int i=0 ; i< v_ME_HLTAll_LS_.size(); i++) {
2022 
2023  MonitorElement* tempME = v_ME_HLTAll_LS_[i];
2024 
2025  if ( tempME ) {
2026 
2027  TH2F* hist_All = tempME->getTH2F();
2028 
2029  // find the bin
2030  int pathBinNumber = hist_All->GetYaxis()->FindBin(pathname.c_str());
2031  // update the bin content (must do that since events don't ncessarily come in the order
2032  int currentLumiCount = int(hist_All->GetBinContent(lumi+1,pathBinNumber));
2033  int updatedLumiCount = currentLumiCount + diffCount;
2034  hist_All->SetBinContent(lumi+1,pathBinNumber,updatedLumiCount);
2035 
2036  }
2037  else {
2038 
2039  LogDebug("FourVectorHLTOnline") << " cannot find tempME " << std::endl;
2040 
2041  }
2042 
2043  }
2044 
2045 
2047  // fill the 1D individual path count per LS
2049  std::string fullPathToME_count = pathsIndividualHLTPathsPerLSFolder_ + pathname + "_count_per_LS";
2050  MonitorElement* ME_1d = dbe_->get(fullPathToME_count);
2051  if ( ME_1d) {
2052 
2053  // update the bin content (must do that since events don't ncessarily come in the order
2054  int currentLumiCount = int(ME_1d->getTH1()->GetBinContent(lumi+1));
2055  int updatedLumiCount = currentLumiCount + diffCount;
2056  ME_1d->getTH1()->SetBinContent(lumi+1,updatedLumiCount);
2057 
2058  }
2059  else {
2060 
2061  LogDebug("FourVectorHLTOnline") << " cannot find ME " << fullPathToME_count << std::endl;
2062 
2063  }
2064 
2065  } // end for ip
2066 
2067 }
2068 
2070 {
2071 
2072  int objectType = 0;
2073 
2074  if (pathname.find("MET") != std::string::npos)
2075  objectType = trigger::TriggerMET;
2076  if (pathname.find("SumET") != std::string::npos)
2077  objectType = trigger::TriggerTET;
2078  if (pathname.find("HT") != std::string::npos)
2079  objectType = trigger::TriggerTET;
2080  if (pathname.find("Jet") != std::string::npos)
2081  objectType = trigger::TriggerJet;
2082  if (pathname.find("Mu") != std::string::npos)
2083  objectType = trigger::TriggerMuon;
2084  if (pathname.find("Ele") != std::string::npos)
2085  objectType = trigger::TriggerElectron;
2086  if (pathname.find("Photon") != std::string::npos)
2087  objectType = trigger::TriggerPhoton;
2088  if (pathname.find("Tau") != std::string::npos)
2089  objectType = trigger::TriggerTau;
2090  if (pathname.find("IsoTrack") != std::string::npos)
2091  objectType = trigger::TriggerTrack;
2092  if (pathname.find("BTag") != std::string::npos)
2093  objectType = trigger::TriggerBJet;
2094 
2095  return objectType;
2096 }
2097 
2098 const std::string FourVectorHLTOnline::getL1ConditionModuleName(const std::string& pathname)
2099 {
2100 
2101  // find L1 condition for numpath with numpath objecttype
2102  // find PSet for L1 global seed for numpath,
2103  // list module labels for numpath
2104  std::string l1pathname = "dummy";
2105 
2106  std::vector<std::string> numpathmodules = hltConfig_.moduleLabels(pathname);
2107 
2108  for(std::vector<std::string>::iterator numpathmodule = numpathmodules.begin();
2109  numpathmodule!= numpathmodules.end(); ++numpathmodule ) {
2110 
2111  if (hltConfig_.moduleType(*numpathmodule) == "HLTLevel1GTSeed") {
2112 
2113  l1pathname = *numpathmodule;
2114  break;
2115 
2116  }
2117 
2118  } // end for
2119 
2120  return l1pathname;
2121 
2122 }
2123 
2124 
2125 bool FourVectorHLTOnline::hasL1Passed(const std::string& pathname, const edm::TriggerNames & triggerNames)
2126 {
2127 
2128  bool rc = false;
2129 
2130  std::string l1ModuleName = getL1ConditionModuleName(pathname);
2131  int l1ModuleIndex = hltConfig_.moduleIndex(pathname, l1ModuleName);
2132 
2133  unsigned int pathByIndex = triggerNames.triggerIndex(pathname);
2134  if(pathByIndex >= triggerResults_->size() ) return rc; // path is not in the menu
2135 
2136  // get index of the last module that issued the decision
2137  int lastModule = triggerResults_->index(pathByIndex);
2138 
2139  // if L1 passed, then it must not be the module that
2140  // issued the last decision
2141  rc = (l1ModuleIndex < lastModule);
2142 
2143  return rc;
2144 
2145 }
2146 
2147 bool FourVectorHLTOnline::hasHLTPassed(const std::string& pathname, const edm::TriggerNames & triggerNames)
2148 {
2149 
2150  bool rc = false;
2151 
2152  unsigned int pathByIndex = triggerNames.triggerIndex(pathname);
2153  if(pathByIndex >= triggerResults_->size() ) return rc; // path is not in the menu
2154 
2155  rc = triggerResults_->accept(pathByIndex);
2156 
2157  return rc;
2158 
2159 }
#define LogDebug(id)
unsigned int size() const
number of trigger paths in trigger table
LuminosityBlockID id() const
const double Pi
T getParameter(std::string const &) const
edm::Handle< trigger::TriggerEvent > fTriggerObj
T getUntrackedParameter(std::string const &, T const &) const
const std::string & getName(void) const
get name of ME
PathInfoCollection hltPathsDiagonal_
int i
Definition: DBlmapReader.cc:9
const std::string getL1ConditionModuleName(const std::string &pathname)
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:208
edm::InputTag triggerSummaryLabel_
std::string pathsSummaryHLTPathsPerBXFolder_
RunID const & id() const
Definition: RunBase.h:43
const std::string moduleType(const std::string &module) const
C++ class name of module.
virtual void monitorOnline(const int hltIndex, const int l1Index, FourVectorHLTOnline *fv)=0
MonitorElement * scalersSelect
const std::string & label
Definition: MVAComputer.cc:186
const std::string & triggerName(unsigned int triggerIndex) const
std::vector< std::pair< std::string, std::vector< int > > > fPathBxTempCountPair
virtual void fillOnlineMatch(const int l1Index, FourVectorHLTOnline *fv)=0
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:519
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2296
void setupHltMatrix(std::string label, std::vector< std::string > paths)
enum start value shifted to 81 so as to avoid clashes with PDG codes
tuple lumi
Definition: fjr2json.py:41
std::vector< std::pair< std::string, std::string > > custompathnamepairs_
void countHLTGroupBXHitsEndLumiBlock(const int &lumi)
void fillHltMatrix(const edm::TriggerNames &triggerNames)
int bunchCrossing() const
Definition: EventBase.h:62
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
std::multimap< float, int > fimmap
edm::Handle< edm::TriggerResults > triggerResults_
void countHLTPathHitsEndLumiBlock(const int &lumi)
#define NULL
Definition: scimark2.h:8
Strings::size_type size() const
Definition: TriggerNames.cc:39
std::vector< std::pair< std::string, int > > fPathTempCountPair
void cleanDRMatchSet(mmset &tempSet)
Clean DR Match Set.
void endRun(const edm::Run &run, const edm::EventSetup &c)
EndRun.
std::vector< TPRegexp > filters
Definition: eve_filter.cc:25
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
std::string pathsIndividualHLTPathsPerLSFolder_
PathInfoCollection hltPaths_
std::set< fimmap, std::less< fimmap > > mmset
void Fill(long long x)
U second(std::pair< T, U > const &p)
const std::string * pathName() const
Definition: HLTadd.h:31
Definition: ME.h:11
std::string pathsSummaryHLTPathsPerLSFolder_
int iEvent
Definition: GenABIO.cc:243
unsigned int moduleIndex(unsigned int trigger, const std::string &module) const
slot position of module on trigger path (0 to size-1)
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
virtual void analyze(const edm::Event &, const edm::EventSetup &)
void setLimits(float etaMax, float etMin, float drMatch)
std::vector< std::pair< std::string, int > > fGroupTempCountPair
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
int j
Definition: DBlmapReader.cc:9
TH1 * getTH1(void) const
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
std::vector< MonitorElement * > v_ME_HLTAll_LS_
MonitorElement * ME_HLT_BX_
void setVerbose(unsigned level)
Definition: DQMStore.cc:201
MonitorElement * ME_HLT_CUSTOM_BX_
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1270
bool first
Definition: L1TdeRCT.cc:79
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
#define LogTrace(id)
int k[5][pyjets_maxn]
const std::vector< std::string > & moduleLabels(unsigned int trigger) const
label(s) of module(s) on a trigger path
const std::vector< std::string > & datasetContent(unsigned int dataset) const
names of trigger paths in dataset with index i
virtual void clearSets(void)=0
void countHLTGroupL1HitsEndLumiBlock(const int &lumi)
HLTConfigProvider hltConfig_
std::string muonRecoCollectionName_
std::string pathsSummaryFilterCountsFolder_
MonitorElement * ME_HLTAll_LS_
std::vector< std::string > specialPaths_
bool hasL1Passed(const std::string &pathname, const edm::TriggerNames &triggerNames)
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
TH1F * getTH1F(void) const
LuminosityBlockNumber_t luminosityBlock() const
std::vector< std::string > fGroupName
std::string const & label() const
Definition: InputTag.h:25
std::vector< std::pair< std::string, std::vector< std::string > > > fGroupNamePathsPair
virtual void setPath(FourVectorHLTOnline::PathInfoCollection::iterator v)=0
std::vector< std::pair< std::string, int > > fGroupL1TempCountPair
bool hasHLTPassed(const std::string &pathname, const edm::TriggerNames &triggerNames)
FourVectorHLTOnline(const edm::ParameterSet &)
void beginRun(const edm::Run &run, const edm::EventSetup &c)
int getTriggerTypeParsePathName(const std::string &pathname)
void countHLTGroupHitsEndLumiBlock(const int &lumi)
virtual void monitorL1(const int l1Index, FourVectorHLTOnline *fv)=0
TH2F * getTH2F(void) const
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:647
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void setReco(edm::Handle< T > offColl)
std::string const & instance() const
Definition: InputTag.h:26
tuple size
Write out results.
mathSSE::Vec4< T > v
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237
std::string pathsSummaryHLTCorrelationsFolder_
Definition: Run.h:31
const std::vector< std::string > & datasetNames() const
edm::InputTag triggerResultsLabel_
void setBJetsFlag(bool flag)