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