CMS 3D CMS Logo

EmDQMReco.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 #include <memory>
4 
5 #include <fmt/printf.h>
6 
8 // Root include files //
10 #include <TDirectory.h>
11 #include <TFile.h>
12 #include <TH1F.h>
13 #include <Math/VectorUtil.h>
14 
16 // Header file for this //
19 
21 // Collaborating Class Header //
41 
42 using namespace ROOT::Math::VectorUtil;
43 
44 //----------------------------------------------------------------------
45 // class EmDQMReco::FourVectorMonitorElements
46 //----------------------------------------------------------------------
48  DQMStore::IBooker &iBooker,
49  const std::string &histogramNameTemplate,
50  const std::string &histogramTitleTemplate)
51  : parent(_parent) {
52  // introducing variables for better code readability later on
53  std::string histName;
55 
56  // et
57  histName = fmt::sprintf(histogramNameTemplate, "et");
58  histTitle = fmt::sprintf(histogramTitleTemplate, "E_{T}");
60  iBooker.book1D(histName.c_str(), histTitle.c_str(), parent->plotBins, parent->plotPtMin, parent->plotPtMax);
61 
62  // eta
63  histName = fmt::sprintf(histogramNameTemplate, "eta");
64  histTitle = fmt::sprintf(histogramTitleTemplate, "#eta");
66  iBooker.book1D(histName.c_str(), histTitle.c_str(), parent->plotBins, -parent->plotEtaMax, parent->plotEtaMax);
67 
68  // phi
69  histName = fmt::sprintf(histogramNameTemplate, "phi");
70  histTitle = fmt::sprintf(histogramTitleTemplate, "#phi");
72  iBooker.book1D(histName.c_str(), histTitle.c_str(), parent->plotBins, -parent->plotPhiMax, parent->plotPhiMax);
73 }
74 
75 //----------------------------------------------------------------------
76 
78  etMonitorElement->Fill(momentum.Et());
79  etaMonitorElement->Fill(momentum.eta());
80  phiMonitorElement->Fill(momentum.phi());
81 }
82 
83 //----------------------------------------------------------------------
84 
86 // Constructor //
90  // Read from configuration file //
92  dirname_ = "HLT/HLTEgammaValidation/" + pset.getParameter<std::string>("@module_label");
93 
94  // parameters for generator study
95  reqNum = pset.getParameter<unsigned int>("reqNum");
96  pdgGen = pset.getParameter<int>("pdgGen");
97  recoEtaAcc = pset.getParameter<double>("genEtaAcc");
98  recoEtAcc = pset.getParameter<double>("genEtAcc");
99  // plotting parameters (untracked because they don't affect the physics)
100  plotPtMin = pset.getUntrackedParameter<double>("PtMin", 0.);
101  plotPtMax = pset.getUntrackedParameter<double>("PtMax", 1000.);
102  plotEtaMax = pset.getUntrackedParameter<double>("EtaMax", 2.7);
103  plotPhiMax = pset.getUntrackedParameter<double>("PhiMax", 3.15);
104  plotBins = pset.getUntrackedParameter<unsigned int>("Nbins", 50);
105  useHumanReadableHistTitles = pset.getUntrackedParameter<bool>("useHumanReadableHistTitles", false);
106 
107  triggerNameRecoMonPath = pset.getUntrackedParameter<std::string>("triggerNameRecoMonPath", "HLT_MinBias");
108  processNameRecoMonPath = pset.getUntrackedParameter<std::string>("processNameRecoMonPath", "HLT");
109 
110  recoElectronsInput = consumes<reco::GsfElectronCollection>(
111  pset.getUntrackedParameter<edm::InputTag>("recoElectrons", edm::InputTag("gsfElectrons")));
112  recoObjectsEBT = consumes<std::vector<reco::SuperCluster>>(edm::InputTag("correctedHybridSuperClusters"));
114  consumes<std::vector<reco::SuperCluster>>(edm::InputTag("correctedMulti5x5SuperClustersWithPreshower"));
115  hltResultsT = consumes<edm::TriggerResults>(edm::InputTag("TriggerResults", "", processNameRecoMonPath));
116  triggerObjT = consumes<trigger::TriggerEventWithRefs>(edm::InputTag("hltTriggerSummaryRAW"));
117 
118  // preselction cuts
119  // recocutCollection_= pset.getParameter<edm::InputTag>("cutcollection");
120  recocut_ = pset.getParameter<int>("cutnum");
121 
122  // prescale = 10;
123  eventnum = 0;
124 
125  // just init
126  isHltConfigInitialized_ = false;
127 
129  // Read in the Vector of Parameter Sets. //
130  // Information for each filter-step //
132  std::vector<edm::ParameterSet> filters = pset.getParameter<std::vector<edm::ParameterSet>>("filters");
133 
134  int i = 0;
135  for (std::vector<edm::ParameterSet>::iterator filterconf = filters.begin(); filterconf != filters.end();
136  filterconf++) {
137  theHLTCollectionLabels.push_back(filterconf->getParameter<edm::InputTag>("HLTCollectionLabels"));
138  theHLTOutputTypes.push_back(filterconf->getParameter<int>("theHLTOutputTypes"));
139  // Grab the human-readable name, if it is not specified, use the Collection
140  // Label
141  theHLTCollectionHumanNames.push_back(
142  filterconf->getUntrackedParameter<std::string>("HLTCollectionHumanName", theHLTCollectionLabels[i].label()));
143 
144  std::vector<double> bounds = filterconf->getParameter<std::vector<double>>("PlotBounds");
145  // If the size of plot "bounds" vector != 2, abort
146  assert(bounds.size() == 2);
147  plotBounds.push_back(std::pair<double, double>(bounds[0], bounds[1]));
148  isoNames.push_back(filterconf->getParameter<std::vector<edm::InputTag>>("IsoCollections"));
149 
150  for (unsigned int i = 0; i < isoNames.back().size(); i++) {
151  switch (theHLTOutputTypes.back()) {
155  isoNames.back()[i]));
156  break;
157  case trigger::TriggerL1IsoEG: // Isolated Level 1
158  histoFillerL1Iso->isoNameTokens_.push_back(
160  isoNames.back()[i]));
161  break;
162  case trigger::TriggerPhoton: // Photon
163  histoFillerPho->isoNameTokens_.push_back(
165  isoNames.back()[i]));
166  break;
167  case trigger::TriggerElectron: // Electron
168  histoFillerEle->isoNameTokens_.push_back(
170  break;
171  case trigger::TriggerCluster: // TriggerCluster
172  histoFillerClu->isoNameTokens_.push_back(
174  isoNames.back()[i]));
175  break;
176  default:
177  throw(cms::Exception("Release Validation Error") << "HLT output type not implemented: theHLTOutputTypes[n]");
178  }
179  }
180 
181  // If the size of the isoNames vector is not greater than zero, abort
182  assert(!isoNames.back().empty());
183  if (isoNames.back().at(0).label() == "none") {
184  plotiso.push_back(false);
185  } else {
186  plotiso.push_back(true);
187  }
188  i++;
189  } // END of loop over parameter sets
190 
191  // Record number of HLTCollectionLabels
193 }
194 
198 void EmDQMReco::dqmBeginRun(const edm::Run &iRun, const edm::EventSetup &iSetup) {
199  bool isHltConfigChanged = false; // change of cfg at run boundaries?
200  isHltConfigInitialized_ = hltConfig_.init(iRun, iSetup, "HLT", isHltConfigChanged);
201 }
202 
204 // book DQM histograms //
206 void EmDQMReco::bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &iRun, edm::EventSetup const &iSetup) {
207  iBooker.setCurrentFolder(dirname_);
208 
210  // Set up Histogram of Effiency vs Step. //
211  // theHLTCollectionLabels is a vector of InputTags //
212  // from the configuration file. //
214 
215  std::string histName = "total_eff";
216  std::string histTitle = "total events passing";
217  // This plot will have bins equal to 2+(number of
218  // HLTCollectionLabels in the config file)
219  totalreco = iBooker.book1D(
220  histName.c_str(), histTitle.c_str(), numOfHLTCollectionLabels + 2, 0, numOfHLTCollectionLabels + 2);
223  for (unsigned int u = 0; u < numOfHLTCollectionLabels; u++) {
225  }
226 
227  histName = "total_eff_RECO_matched";
228  histTitle = "total events passing (Reco matched)";
229  totalmatchreco = iBooker.book1D(
230  histName.c_str(), histTitle.c_str(), numOfHLTCollectionLabels + 2, 0, numOfHLTCollectionLabels + 2);
233  for (unsigned int u = 0; u < numOfHLTCollectionLabels; u++) {
235  }
236 
237  // MonitorElement* tmphisto;
238  MonitorElement *tmpiso;
239 
241  // Set up generator-level histograms //
243  std::string pdgIdString;
244  switch (pdgGen) {
245  case 11:
246  pdgIdString = "Electron";
247  break;
248  case 22:
249  pdgIdString = "Photon";
250  break;
251  default:
252  pdgIdString = "Particle";
253  }
254 
255  //--------------------
256 
257  // reco
258  // (note that reset(..) must be used to set the value of the scoped_ptr...)
259  histReco = std::make_unique<FourVectorMonitorElements>(this,
260  iBooker,
261  "reco_%s", // pattern for histogram name
262  "%s of " + pdgIdString + "s");
263 
264  //--------------------
265 
266  // monpath
267  histRecoMonpath = std::make_unique<FourVectorMonitorElements>(this,
268  iBooker,
269  "reco_%s_monpath", // pattern for histogram name
270  "%s of " + pdgIdString + "s monpath");
271 
272  //--------------------
273 
274  // TODO: WHAT ARE THESE HISTOGRAMS FOR ? THEY SEEM NEVER REFERENCED ANYWHERE
275  // IN THIS FILE... final X monpath
276  histMonpath = std::make_unique<FourVectorMonitorElements>(this,
277  iBooker,
278  "final_%s_monpath", // pattern for histogram name
279  "Final %s Monpath");
280 
281  //--------------------
282 
284  // Set up histograms of HLT objects //
286 
287  // Determine what strings to use for histogram titles
288  std::vector<std::string> HltHistTitle;
290  HltHistTitle = theHLTCollectionHumanNames;
291  } else {
292  for (unsigned int i = 0; i < numOfHLTCollectionLabels; i++) {
293  HltHistTitle.push_back(theHLTCollectionLabels[i].label());
294  }
295  }
296 
297  for (unsigned int i = 0; i < numOfHLTCollectionLabels; i++) {
298  //--------------------
299  // distributions of HLT objects passing filter i
300  //--------------------
301 
302  // // Et
303  // histName = theHLTCollectionLabels[i].label()+"et_all";
304  // histTitle = HltHistTitle[i]+" Et (ALL)";
305  // tmphisto =
306  // iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax);
307  // ethist.push_back(tmphisto);
308  //
309  // // Eta
310  // histName = theHLTCollectionLabels[i].label()+"eta_all";
311  // histTitle = HltHistTitle[i]+" #eta (ALL)";
312  // tmphisto =
313  // iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax);
314  // etahist.push_back(tmphisto);
315  //
316  // // phi
317  // histName = theHLTCollectionLabels[i].label()+"phi_all";
318  // histTitle = HltHistTitle[i]+" #phi (ALL)";
319  // tmphisto =
320  // iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax);
321  // phiHist.push_back(tmphisto);
322 
323  standardHist.push_back(std::make_unique<FourVectorMonitorElements>(
324  this,
325  iBooker,
326  theHLTCollectionLabels[i].label() + "%s_all", // histogram name
327  HltHistTitle[i] + " %s (ALL)" // histogram title
328  ));
329 
330  //--------------------
331  // distributions of reco object matching HLT object passing filter i
332  //--------------------
333 
334  // Et
335  // histName = theHLTCollectionLabels[i].label()+"et_RECO_matched";
336  // histTitle = HltHistTitle[i]+" Et (RECO matched)";
337  // tmphisto =
338  // iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax);
339  // ethistmatchreco.push_back(tmphisto);
340 
341  // // Eta
342  // histName = theHLTCollectionLabels[i].label()+"eta_RECO_matched";
343  // histTitle = HltHistTitle[i]+" #eta (RECO matched)";
344  // tmphisto =
345  // iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax);
346  // etahistmatchreco.push_back(tmphisto);
347  //
348  // // phi
349  // histName = theHLTCollectionLabels[i].label()+"phi_RECO_matched";
350  // histTitle = HltHistTitle[i]+" #phi (RECO matched)";
351  // tmphisto =
352  // iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax);
353  // phiHistMatchReco.push_back(tmphisto);
354  histMatchReco.push_back(std::make_unique<FourVectorMonitorElements>(
355  this,
356  iBooker,
357  theHLTCollectionLabels[i].label() + "%s_RECO_matched", // histogram name
358  HltHistTitle[i] + " %s (RECO matched)" // histogram title
359  ));
360 
361  //--------------------
362  // distributions of reco object matching HLT object passing filter i
363  //--------------------
364 
365  // // Et
366  // histName =
367  // theHLTCollectionLabels[i].label()+"et_RECO_matched_monpath"; histTitle
368  // = HltHistTitle[i]+" Et (RECO matched, monpath)"; tmphisto =
369  // iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax);
370  // ethistmatchrecomonpath.push_back(tmphisto);
371  //
372  // // Eta
373  // histName =
374  // theHLTCollectionLabels[i].label()+"eta_RECO_matched_monpath";
375  // histTitle = HltHistTitle[i]+" #eta (RECO matched, monpath)";
376  // tmphisto =
377  // iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax);
378  // etahistmatchrecomonpath.push_back(tmphisto);
379  //
380  // // phi
381  // histName =
382  // theHLTCollectionLabels[i].label()+"phi_RECO_matched_monpath";
383  // histTitle = HltHistTitle[i]+" #phi (RECO matched, monpath)";
384  // tmphisto =
385  // iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax);
386  // phiHistMatchRecoMonPath.push_back(tmphisto);
387 
388  histMatchRecoMonPath.push_back(std::make_unique<FourVectorMonitorElements>(
389  this,
390  iBooker,
391  theHLTCollectionLabels[i].label() + "%s_RECO_matched_monpath", // histogram name
392  HltHistTitle[i] + " %s (RECO matched, monpath)" // histogram title
393  ));
394  //--------------------
395  // distributions of HLT object that is closest delta-R match to sorted reco
396  // particle(s)
397  //--------------------
398 
399  // Et
400  // histName = theHLTCollectionLabels[i].label()+"et_reco";
401  // histTitle = HltHistTitle[i]+" Et (reco)";
402  // tmphisto =
403  // iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,plotPtMin,plotPtMax);
404  // histEtOfHltObjMatchToReco.push_back(tmphisto);
405  //
406  // // eta
407  // histName = theHLTCollectionLabels[i].label()+"eta_reco";
408  // histTitle = HltHistTitle[i]+" eta (reco)";
409  // tmphisto =
410  // iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotEtaMax,plotEtaMax);
411  // histEtaOfHltObjMatchToReco.push_back(tmphisto);
412  //
413  // // phi
414  // histName = theHLTCollectionLabels[i].label()+"phi_reco";
415  // histTitle = HltHistTitle[i]+" phi (reco)";
416  // tmphisto =
417  // iBooker.book1D(histName.c_str(),histTitle.c_str(),plotBins,-plotPhiMax,plotPhiMax);
418  // histPhiOfHltObjMatchToReco.push_back(tmphisto);
419 
420  histHltObjMatchToReco.push_back(std::make_unique<FourVectorMonitorElements>(
421  this,
422  iBooker,
423  theHLTCollectionLabels[i].label() + "%s_reco", // histogram name
424  HltHistTitle[i] + " %s (reco)" // histogram title
425  ));
426 
427  //--------------------
428 
429  if (!plotiso[i]) {
430  tmpiso = nullptr;
431  etahistiso.push_back(tmpiso);
432  ethistiso.push_back(tmpiso);
433  phiHistIso.push_back(tmpiso);
434 
435  etahistisomatchreco.push_back(tmpiso);
436  ethistisomatchreco.push_back(tmpiso);
437  phiHistIsoMatchReco.push_back(tmpiso);
438 
439  histEtaIsoOfHltObjMatchToReco.push_back(tmpiso);
440  histEtIsoOfHltObjMatchToReco.push_back(tmpiso);
441  histPhiIsoOfHltObjMatchToReco.push_back(tmpiso);
442 
443  } else {
444  //--------------------
445  // 2D plot: Isolation values vs X for all objects
446  //--------------------
447 
448  // X = eta
449  histName = theHLTCollectionLabels[i].label() + "eta_isolation_all";
450  histTitle = HltHistTitle[i] + " isolation vs #eta (all)";
451  tmpiso = iBooker.book2D(histName.c_str(),
452  histTitle.c_str(),
453  plotBins,
454  -plotEtaMax,
455  plotEtaMax,
456  plotBins,
457  plotBounds[i].first,
458  plotBounds[i].second);
459  etahistiso.push_back(tmpiso);
460 
461  // X = et
462  histName = theHLTCollectionLabels[i].label() + "et_isolation_all";
463  histTitle = HltHistTitle[i] + " isolation vs Et (all)";
464  tmpiso = iBooker.book2D(histName.c_str(),
465  histTitle.c_str(),
466  plotBins,
467  plotPtMin,
468  plotPtMax,
469  plotBins,
470  plotBounds[i].first,
471  plotBounds[i].second);
472  ethistiso.push_back(tmpiso);
473 
474  // X = phi
475  histName = theHLTCollectionLabels[i].label() + "phi_isolation_all";
476  histTitle = HltHistTitle[i] + " isolation vs #phi (all)";
477  tmpiso = iBooker.book2D(histName.c_str(),
478  histTitle.c_str(),
479  plotBins,
480  -plotPhiMax,
481  plotPhiMax,
482  plotBins,
483  plotBounds[i].first,
484  plotBounds[i].second);
485  phiHistIso.push_back(tmpiso);
486 
487  //--------------------
488  // 2D plot: Isolation values vs X for reco matched objects
489  //--------------------
490 
491  // X = eta
492  histName = theHLTCollectionLabels[i].label() + "eta_isolation_RECO_matched";
493  histTitle = HltHistTitle[i] + " isolation vs #eta (reco matched)";
494  tmpiso = iBooker.book2D(histName.c_str(),
495  histTitle.c_str(),
496  plotBins,
497  -plotEtaMax,
498  plotEtaMax,
499  plotBins,
500  plotBounds[i].first,
501  plotBounds[i].second);
502  etahistisomatchreco.push_back(tmpiso);
503 
504  // X = et
505  histName = theHLTCollectionLabels[i].label() + "et_isolation_RECO_matched";
506  histTitle = HltHistTitle[i] + " isolation vs Et (reco matched)";
507  tmpiso = iBooker.book2D(histName.c_str(),
508  histTitle.c_str(),
509  plotBins,
510  plotPtMin,
511  plotPtMax,
512  plotBins,
513  plotBounds[i].first,
514  plotBounds[i].second);
515  ethistisomatchreco.push_back(tmpiso);
516 
517  // X = eta
518  histName = theHLTCollectionLabels[i].label() + "phi_isolation_RECO_matched";
519  histTitle = HltHistTitle[i] + " isolation vs #phi (reco matched)";
520  tmpiso = iBooker.book2D(histName.c_str(),
521  histTitle.c_str(),
522  plotBins,
523  -plotPhiMax,
524  plotPhiMax,
525  plotBins,
526  plotBounds[i].first,
527  plotBounds[i].second);
528  phiHistIsoMatchReco.push_back(tmpiso);
529 
530  //--------------------
531  // 2D plot: Isolation values vs X for HLT object that
532  // is closest delta-R match to sorted reco particle(s)
533  //--------------------
534 
535  // X = eta
536  histName = theHLTCollectionLabels[i].label() + "eta_isolation_reco";
537  histTitle = HltHistTitle[i] + " isolation vs #eta (reco)";
538  tmpiso = iBooker.book2D(histName.c_str(),
539  histTitle.c_str(),
540  plotBins,
541  -plotEtaMax,
542  plotEtaMax,
543  plotBins,
544  plotBounds[i].first,
545  plotBounds[i].second);
546  histEtaIsoOfHltObjMatchToReco.push_back(tmpiso);
547 
548  // X = et
549  histName = theHLTCollectionLabels[i].label() + "et_isolation_reco";
550  histTitle = HltHistTitle[i] + " isolation vs Et (reco)";
551  tmpiso = iBooker.book2D(histName.c_str(),
552  histTitle.c_str(),
553  plotBins,
554  plotPtMin,
555  plotPtMax,
556  plotBins,
557  plotBounds[i].first,
558  plotBounds[i].second);
559  histEtIsoOfHltObjMatchToReco.push_back(tmpiso);
560 
561  // X = phi
562  histName = theHLTCollectionLabels[i].label() + "phi_isolation_reco";
563  histTitle = HltHistTitle[i] + " isolation vs #phi (reco)";
564  tmpiso = iBooker.book2D(histName.c_str(),
565  histTitle.c_str(),
566  plotBins,
567  -plotPhiMax,
568  plotPhiMax,
569  plotBins,
570  plotBounds[i].first,
571  plotBounds[i].second);
572  histPhiIsoOfHltObjMatchToReco.push_back(tmpiso);
573  //--------------------
574 
575  } // END of HLT histograms
576  }
577 }
578 
580 // Destructor //
583 
585 // method called to for each event //
588  // protect from hlt config failure
590  return;
591 
592  eventnum++;
593  bool plotMonpath = false;
594  bool plotReco = true;
595 
599 
600  if (pdgGen == 11) {
601  event.getByToken(recoElectronsInput, recoObjects);
602 
603  if (recoObjects->size() < (unsigned int)recocut_) {
604  // edm::LogWarning("EmDQMReco") << "Less than "<< recocut_ <<" Reco
605  // particles with pdgId=" << pdgGen << ". Only " <<
606  // cutRecoCounter->size() << " particles.";
607  return;
608  }
609  } else if (pdgGen == 22) {
610  event.getByToken(recoObjectsEBT, recoObjectsEB);
611  event.getByToken(recoObjectsEET, recoObjectsEE);
612 
613  if (recoObjectsEB->size() + recoObjectsEE->size() < (unsigned int)recocut_) {
614  // edm::LogWarning("EmDQMReco") << "Less than "<< recocut_ <<" Reco
615  // particles with pdgId=" << pdgGen << ". Only " << cutRecoCounter.size()
616  // << " particles.";
617  return;
618  }
619  }
620 
622  event.getByToken(hltResultsT, HLTR);
623 
628 
629  /* if (theHLTCollectionHumanNames[0] == "hltL1sRelaxedSingleEgammaEt8"){
630  triggerIndex = hltConfig.triggerIndex("HLT_L1SingleEG8");
631  } else if (theHLTCollectionHumanNames[0] == "hltL1sRelaxedSingleEgammaEt5") {
632  triggerIndex = hltConfig.triggerIndex("HLT_L1SingleEG5");
633  } else if (theHLTCollectionHumanNames[0] == "hltL1sRelaxedDoubleEgammaEt5") {
634  triggerIndex = hltConfig.triggerIndex("HLT_L1DoubleEG5");
635  } else {
636  triggerIndex = hltConfig.triggerIndex("");
637  } */
638 
639  unsigned int triggerIndex;
641 
642  // triggerIndex must be less than the size of HLTR or you get a CMSException
643  bool isFired = false;
644  if (triggerIndex < HLTR->size()) {
645  isFired = HLTR->accept(triggerIndex);
646  }
647 
648  // fill L1 and HLT info
649  // get objects possed by each filter
651  event.getByToken(triggerObjT, triggerObj);
652 
653  if (!triggerObj.isValid()) {
654  edm::LogWarning("EmDQMReco") << "RAW-type HLT results not found, skipping event";
655  return;
656  }
657 
659  // Fill the bin labeled "Total" //
660  // This will be the number of events looked at. //
664 
666  // Fill the bin labeled "Total" //
667  // This will be the number of events looked at. //
669  // total->Fill(numOfHLTCollectionLabels+0.5);
670  // totalmatch->Fill(numOfHLTCollectionLabels+0.5);
671 
673  // Fill reconstruction info //
675  // the recocut_ highest Et generator objects of the preselected type are our
676  // matches
677 
678  std::vector<reco::Particle> sortedReco;
679  if (plotReco == true) {
680  if (pdgGen == 11) {
681  for (edm::View<reco::Candidate>::const_iterator recopart = recoObjects->begin(); recopart != recoObjects->end();
682  recopart++) {
683  reco::Particle tmpcand(
684  recopart->charge(), recopart->p4(), recopart->vertex(), recopart->pdgId(), recopart->status());
685  sortedReco.push_back(tmpcand);
686  }
687  } else if (pdgGen == 22) {
688  for (std::vector<reco::SuperCluster>::const_iterator recopart2 = recoObjectsEB->begin();
689  recopart2 != recoObjectsEB->end();
690  recopart2++) {
691  float en = recopart2->energy();
692  float er = sqrt(pow(recopart2->x(), 2) + pow(recopart2->y(), 2) + pow(recopart2->z(), 2));
693  float px = recopart2->energy() * recopart2->x() / er;
694  float py = recopart2->energy() * recopart2->y() / er;
695  float pz = recopart2->energy() * recopart2->z() / er;
696  reco::Candidate::LorentzVector thisLV(px, py, pz, en);
697  reco::Particle tmpcand(0, thisLV, math::XYZPoint(0., 0., 0.), 22, 1);
698  sortedReco.push_back(tmpcand);
699  }
700  for (std::vector<reco::SuperCluster>::const_iterator recopart2 = recoObjectsEE->begin();
701  recopart2 != recoObjectsEE->end();
702  recopart2++) {
703  float en = recopart2->energy();
704  float er = sqrt(pow(recopart2->x(), 2) + pow(recopart2->y(), 2) + pow(recopart2->z(), 2));
705  float px = recopart2->energy() * recopart2->x() / er;
706  float py = recopart2->energy() * recopart2->y() / er;
707  float pz = recopart2->energy() * recopart2->z() / er;
708  reco::Candidate::LorentzVector thisLV(px, py, pz, en);
709  reco::Particle tmpcand(0, thisLV, math::XYZPoint(0., 0., 0.), 22, 1);
710  sortedReco.push_back(tmpcand);
711  }
712  }
713 
714  std::sort(sortedReco.begin(), sortedReco.end(), pTComparator_);
715 
716  // Now the collection of gen particles is sorted by pt.
717  // So, remove all particles from the collection so that we
718  // only have the top "1 thru recocut_" particles in it
719 
720  sortedReco.erase(sortedReco.begin() + recocut_, sortedReco.end());
721 
722  for (unsigned int i = 0; i < recocut_; i++) {
723  // validity has been implicitily checked by the cut on recocut_ above
724  histReco->fill(sortedReco[i].p4());
725 
726  // etreco ->Fill( sortedReco[i].et() );
727  // etareco->Fill( sortedReco[i].eta() );
728  // phiReco->Fill( sortedReco[i].phi() );
729 
730  if (isFired) {
731  histRecoMonpath->fill(sortedReco[i].p4());
732  plotMonpath = true;
733  }
734 
735  } // END of loop over Reconstructed particles
736 
737  if (recocut_ >= reqNum)
738  totalreco->Fill(numOfHLTCollectionLabels + 1.5); // this isn't really needed anymore keep for backward comp.
739  if (recocut_ >= reqNum)
740  totalmatchreco->Fill(numOfHLTCollectionLabels + 1.5); // this isn't really needed anymore keep for backward comp.
741  }
742 
744  // Loop over filter modules //
746  for (unsigned int n = 0; n < numOfHLTCollectionLabels; n++) {
747  // These numbers are from the Parameter Set, such as:
748  // theHLTOutputTypes = cms.uint32(100)
749  switch (theHLTOutputTypes[n]) {
750  case trigger::TriggerL1NoIsoEG: // Non-isolated Level 1
751  histoFillerL1NonIso->fillHistos(triggerObj, event, n, sortedReco, plotReco, plotMonpath);
752  break;
753  case trigger::TriggerL1IsoEG: // Isolated Level 1
754  histoFillerL1Iso->fillHistos(triggerObj, event, n, sortedReco, plotReco, plotMonpath);
755  break;
756  case trigger::TriggerPhoton: // Photon
757  histoFillerPho->fillHistos(triggerObj, event, n, sortedReco, plotReco, plotMonpath);
758  break;
759  case trigger::TriggerElectron: // Electron
760  histoFillerEle->fillHistos(triggerObj, event, n, sortedReco, plotReco, plotMonpath);
761  break;
762  case trigger::TriggerCluster: // TriggerCluster
763  histoFillerClu->fillHistos(triggerObj, event, n, sortedReco, plotReco, plotMonpath);
764  break;
765  default:
766  throw(cms::Exception("Release Validation Error") << "HLT output type not implemented: theHLTOutputTypes[n]");
767  }
768  } // END of loop over filter modules
769 }
770 
772 // fillHistos //
773 // Called by analyze method. //
775 template <class T>
777  const edm::Event &iEvent,
778  unsigned int n,
779  std::vector<reco::Particle> &sortedReco,
780  bool plotReco,
781  bool plotMonpath) {
782  std::vector<edm::Ref<T>> recoecalcands;
783  if ((triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]) >= triggerObj->size())) { // only process if available
784  return;
785  }
786 
788  // Retrieve saved filter objects //
790  triggerObj->getObjects(
791  triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]), dqm->theHLTOutputTypes[n], recoecalcands);
792  // Danger: special case, L1 non-isolated
793  // needs to be merged with L1 iso
794  if (dqm->theHLTOutputTypes[n] == trigger::TriggerL1NoIsoEG) {
795  std::vector<edm::Ref<T>> isocands;
796  triggerObj->getObjects(triggerObj->filterIndex(dqm->theHLTCollectionLabels[n]), trigger::TriggerL1IsoEG, isocands);
797  if (!isocands.empty()) {
798  for (unsigned int i = 0; i < isocands.size(); i++)
799  recoecalcands.push_back(isocands[i]);
800  }
801  } // END of if theHLTOutputTypes == 82
802 
803  if (recoecalcands.empty()) { // stop if no object passed the previous filter
804  return;
805  }
806 
807  if (recoecalcands.size() >= dqm->reqNum)
808  dqm->totalreco->Fill(n + 0.5);
809 
811  // check for validity //
812  // prevents crash in CMSSW_3_1_0_pre6 //
814  for (unsigned int j = 0; j < recoecalcands.size(); j++) {
815  if (!(recoecalcands.at(j).isAvailable())) {
816  edm::LogError("EmDQMReco") << "Event content inconsistent: TriggerEventWithRefs contains "
817  "invalid Refs"
818  << std::endl
819  << "invalid refs for: " << dqm->theHLTCollectionLabels[n].label();
820  return;
821  }
822  }
823 
825  // Loop over all HLT objects in this filter step, and //
826  // fill histograms. //
828  // bool foundAllMatches = false;
829  // unsigned int numOfHLTobjectsMatched = 0;
830  for (unsigned int i = 0; i < recoecalcands.size(); i++) {
831  dqm->standardHist[n]->fill(recoecalcands[i]->p4());
832 
834  // Plot isolation variables (show the not-yet-cut //
835  // isolation, i.e. associated to next filter) //
837  if (n + 1 < dqm->numOfHLTCollectionLabels) { // can't plot beyond last
838  if (dqm->plotiso[n + 1]) {
839  for (unsigned int j = 0; j < isoNameTokens_.size(); j++) {
841  iEvent.getByToken(isoNameTokens_.at(j), depMap);
842  if (depMap.isValid()) { // Map may not exist if only one candidate
843  // passes a double filter
844  typename edm::AssociationMap<edm::OneToValue<T, float>>::const_iterator mapi =
845  depMap->find(recoecalcands[i]);
846  if (mapi != depMap->end()) { // found candidate in isolation map!
847  dqm->etahistiso[n + 1]->Fill(recoecalcands[i]->eta(), mapi->val);
848  dqm->ethistiso[n + 1]->Fill(recoecalcands[i]->et(), mapi->val);
849  dqm->phiHistIso[n + 1]->Fill(recoecalcands[i]->phi(), mapi->val);
850  }
851  }
852  }
853  }
854  } // END of if n+1 < then the number of hlt collections
855  }
856 
858  // Loop over the Reconstructed Particles, and find the //
859  // closest HLT object match. //
861  if (plotReco == true) {
862  for (unsigned int i = 0; i < dqm->recocut_; i++) {
863  math::XYZVector currentRecoParticleMomentum = sortedReco[i].momentum();
864 
865  // float closestRecoDeltaR = 0.5;
866  float closestRecoDeltaR = 1000.;
867  int closestRecoEcalCandIndex = -1;
868  for (unsigned int j = 0; j < recoecalcands.size(); j++) {
869  float deltaR = DeltaR(recoecalcands[j]->momentum(), currentRecoParticleMomentum);
870 
871  if (deltaR < closestRecoDeltaR) {
872  closestRecoDeltaR = deltaR;
873  closestRecoEcalCandIndex = j;
874  }
875  }
876 
877  // If an HLT object was found within some delta-R
878  // of this reco particle, store it in a histogram
879  if (closestRecoEcalCandIndex >= 0) {
880  // histEtOfHltObjMatchToReco[n] ->Fill(
881  // recoecalcands[closestRecoEcalCandIndex]->et() );
882  // histEtaOfHltObjMatchToReco[n]->Fill(
883  // recoecalcands[closestRecoEcalCandIndex]->eta() );
884  // histPhiOfHltObjMatchToReco[n]->Fill(
885  // recoecalcands[closestRecoEcalCandIndex]->phi() );
886 
887  dqm->histHltObjMatchToReco[n]->fill(recoecalcands[closestRecoEcalCandIndex]->p4());
888 
889  // Also store isolation info
890  if (n + 1 < dqm->numOfHLTCollectionLabels) { // can't plot beyond last
891  if (dqm->plotiso[n + 1]) { // only plot if requested in config
892  for (unsigned int j = 0; j < isoNameTokens_.size(); j++) {
894  iEvent.getByToken(isoNameTokens_.at(j), depMap);
895  if (depMap.isValid()) { // Map may not exist if only one candidate
896  // passes a double filter
897  typename edm::AssociationMap<edm::OneToValue<T, float>>::const_iterator mapi =
898  depMap->find(recoecalcands[closestRecoEcalCandIndex]);
899  if (mapi != depMap->end()) { // found candidate in isolation map!
900  dqm->histEtaIsoOfHltObjMatchToReco[n + 1]->Fill(recoecalcands[closestRecoEcalCandIndex]->eta(),
901  mapi->val);
902  dqm->histEtIsoOfHltObjMatchToReco[n + 1]->Fill(recoecalcands[closestRecoEcalCandIndex]->et(),
903  mapi->val);
904  dqm->histPhiIsoOfHltObjMatchToReco[n + 1]->Fill(recoecalcands[closestRecoEcalCandIndex]->phi(),
905  mapi->val);
906  }
907  }
908  }
909  }
910  }
911  } // END of if closestEcalCandIndex >= 0
912  }
913 
915  // Fill reco matched objects into histograms //
917  unsigned int mtachedRecoParts = 0;
918  float minrecodist = 0.3;
919  if (n == 0)
920  minrecodist = 0.5; // low L1-resolution => allow wider matching
921  for (unsigned int i = 0; i < dqm->recocut_; i++) {
922  // match generator candidate
923  bool matchThis = false;
924  math::XYZVector candDir = sortedReco[i].momentum();
925  unsigned int closest = 0;
926  double closestDr = 1000.;
927  for (unsigned int trigOb = 0; trigOb < recoecalcands.size(); trigOb++) {
928  double dr = DeltaR(recoecalcands[trigOb]->momentum(), candDir);
929  if (dr < closestDr) {
930  closestDr = dr;
931  closest = trigOb;
932  }
933  if (closestDr > minrecodist) { // it's not really a "match" if it's that far away
934  closest = -1;
935  } else {
936  mtachedRecoParts++;
937  matchThis = true;
938  }
939  }
940  if (!matchThis)
941  continue; // only plot matched candidates
942  // fill coordinates of mc particle matching trigger object
943  // ethistmatchreco[n] ->Fill( sortedReco[i].et() );
944  // etahistmatchreco[n]->Fill( sortedReco[i].eta() );
945  // phiHistMatchReco[n]->Fill( sortedReco[i].phi() );
946  dqm->histMatchReco[n]->fill(sortedReco[i].p4());
947 
948  if (plotMonpath) {
949  // ethistmatchrecomonpath[n]->Fill( sortedReco[i].et() );
950  // etahistmatchrecomonpath[n]->Fill( sortedReco[i].eta() );
951  // phiHistMatchRecoMonPath[n]->Fill( sortedReco[i].phi() );
952  dqm->histMatchRecoMonPath[n]->fill(sortedReco[i].p4());
953  }
955  // Plot isolation variables (show the not-yet-cut //
956  // isolation, i.e. associated to next filter) //
958  if (n + 1 < dqm->numOfHLTCollectionLabels) { // can't plot beyond last
959  if (dqm->plotiso[n + 1]) { // only plot if requested in config
960  for (unsigned int j = 0; j < isoNameTokens_.size(); j++) {
962  iEvent.getByToken(isoNameTokens_.at(j), depMapReco);
963  if (depMapReco.isValid()) { // Map may not exist if only one
964  // candidate passes a double filter
965  typename edm::AssociationMap<edm::OneToValue<T, float>>::const_iterator mapi =
966  depMapReco->find(recoecalcands[closest]);
967  if (mapi != depMapReco->end()) { // found candidate in isolation map!
968  dqm->etahistisomatchreco[n + 1]->Fill(sortedReco[i].eta(), mapi->val);
969  dqm->ethistisomatchreco[n + 1]->Fill(sortedReco[i].et(), mapi->val);
970  dqm->phiHistIsoMatchReco[n + 1]->Fill(sortedReco[i].eta(), mapi->val);
971  }
972  }
973  }
974  }
975  } // END of if n+1 < then the number of hlt collections
976  }
977  // fill total reco matched efficiency
978  if (mtachedRecoParts >= dqm->reqNum)
979  dqm->totalmatchreco->Fill(n + 0.5);
980  }
981 }
982 
std::vector< MonitorElement * > histEtIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:191
size
Write out results.
int pdgGen
Definition: EmDQMReco.h:119
bool accept() const
Has at least one path accepted the event?
void fill(const math::XYZTLorentzVector &momentum)
Definition: EmDQMReco.cc:77
std::vector< std::unique_ptr< FourVectorMonitorElements > > histMatchReco
Definition: EmDQMReco.h:167
std::vector< std::vector< edm::InputTag > > isoNames
Definition: EmDQMReco.h:108
double energy() const
energy
Definition: Particle.h:99
std::vector< std::unique_ptr< FourVectorMonitorElements > > standardHist
Definition: EmDQMReco.h:162
std::unique_ptr< FourVectorMonitorElements > histReco
Definition: EmDQMReco.h:206
std::vector< MonitorElement * > etahistisomatchreco
Definition: EmDQMReco.h:187
HistoFillerReco< reco::RecoEcalCandidateCollection > * histoFillerPho
Definition: EmDQMReco.h:228
HistoFillerReco< reco::ElectronCollection > * histoFillerEle
Definition: EmDQMReco.h:225
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
std::string dirname_
Definition: EmDQMReco.h:223
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
Definition: EmDQMReco.cc:198
int closest(std::vector< int > const &vec, int value)
int eventnum
Definition: EmDQMReco.h:219
std::vector< MonitorElement * > etahistiso
Definition: EmDQMReco.h:183
EmDQMReco(const edm::ParameterSet &pset)
Constructor.
Definition: EmDQMReco.cc:88
std::vector< int > theHLTOutputTypes
Definition: EmDQMReco.h:106
constexpr int pow(int x)
Definition: conifer.h:24
void fillHistos(edm::Handle< trigger::TriggerEventWithRefs > &triggerObj, const edm::Event &iEvent, unsigned int n, std::vector< reco::Particle > &sortedReco, bool plotReco, bool plotMonpath)
Definition: EmDQMReco.cc:776
std::vector< edm::EDGetTokenT< edm::AssociationMap< edm::OneToValue< T, float > > > > isoNameTokens_
Definition: EmDQMReco.h:39
Log< level::Error, false > LogError
edm::EDGetTokenT< std::vector< reco::SuperCluster > > recoObjectsEET
Definition: EmDQMReco.h:149
assert(be >=bs)
unsigned int plotBins
Definition: EmDQMReco.h:129
std::vector< MonitorElement * > phiHistIsoMatchReco
Definition: EmDQMReco.h:189
std::vector< TPRegexp > filters
Definition: eve_filter.cc:22
bool isHltConfigInitialized_
Definition: EmDQMReco.h:112
double recoEtaAcc
Definition: EmDQMReco.h:120
HLTConfigProvider hltConfig_
Definition: EmDQMReco.h:111
FourVectorMonitorElements(EmDQMReco *_parent, DQMStore::IBooker &iBooker, const std::string &histogramNameTemplate, const std::string &histogramTitleTemplate)
Definition: EmDQMReco.cc:47
void Fill(long long x)
std::unique_ptr< FourVectorMonitorElements > histRecoMonpath
Definition: EmDQMReco.h:211
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
std::vector< std::unique_ptr< FourVectorMonitorElements > > histMatchRecoMonPath
Definition: EmDQMReco.h:172
char const * label
double recoEtAcc
Definition: EmDQMReco.h:121
std::vector< MonitorElement * > ethistiso
Definition: EmDQMReco.h:184
GreaterByPt< reco::Particle > pTComparator_
Definition: EmDQMReco.h:234
int iEvent
Definition: GenABIO.cc:224
std::vector< std::string > theHLTCollectionHumanNames
Definition: EmDQMReco.h:104
unsigned int numOfHLTCollectionLabels
Definition: EmDQMReco.h:101
size_type filterIndex(const edm::InputTag &filterTag) const
index from tag
HistoFillerReco< l1extra::L1EmParticleCollection > * histoFillerL1Iso
Definition: EmDQMReco.h:229
T sqrt(T t)
Definition: SSEVec.h:19
MonitorElement * totalreco
Definition: EmDQMReco.h:198
std::vector< std::unique_ptr< FourVectorMonitorElements > > histHltObjMatchToReco
Definition: EmDQMReco.h:177
MonitorElement * etaMonitorElement
Definition: EmDQMReco.h:74
edm::EDGetTokenT< std::vector< reco::SuperCluster > > recoObjectsEBT
Definition: EmDQMReco.h:148
void analyze(const edm::Event &event, const edm::EventSetup &) override
Definition: EmDQMReco.cc:587
MonitorElement * totalmatchreco
Definition: EmDQMReco.h:199
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
std::vector< MonitorElement * > histPhiIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:193
std::vector< MonitorElement * > phiHistIso
Definition: EmDQMReco.h:185
unsigned int recocut_
Definition: EmDQMReco.h:133
virtual 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::string triggerNameRecoMonPath
Definition: EmDQMReco.h:137
std::vector< bool > plotiso
Definition: EmDQMReco.h:107
edm::EDGetTokenT< reco::GsfElectronCollection > recoElectronsInput
Definition: EmDQMReco.h:147
bool useHumanReadableHistTitles
Definition: EmDQMReco.h:103
double plotPhiMax
Definition: EmDQMReco.h:126
edm::EDGetTokenT< trigger::TriggerEventWithRefs > triggerObjT
Definition: EmDQMReco.h:151
HistoFillerReco< l1extra::L1EmParticleCollection > * histoFillerL1NonIso
Definition: EmDQMReco.h:227
MonitorElement * phiMonitorElement
Definition: EmDQMReco.h:75
unsigned int reqNum
Definition: EmDQMReco.h:118
std::vector< MonitorElement * > ethistisomatchreco
Definition: EmDQMReco.h:188
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
std::vector< edm::InputTag > theHLTCollectionLabels
Definition: EmDQMReco.h:99
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
size_type size() const
number of filters
bool isValid() const
Definition: HandleBase.h:70
std::vector< std::pair< double, double > > plotBounds
Definition: EmDQMReco.h:109
edm::EDGetTokenT< edm::TriggerResults > hltResultsT
Definition: EmDQMReco.h:150
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
std::vector< MonitorElement * > histEtaIsoOfHltObjMatchToReco
Definition: EmDQMReco.h:192
double plotPtMin
Definition: EmDQMReco.h:124
double plotPtMax
Definition: EmDQMReco.h:125
~EmDQMReco() override
Destructor.
Definition: EmDQMReco.cc:582
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
double plotEtaMax
Definition: EmDQMReco.h:123
Definition: DQMStore.h:18
std::string processNameRecoMonPath
Definition: EmDQMReco.h:142
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Definition: EmDQMReco.cc:206
std::unique_ptr< FourVectorMonitorElements > histMonpath
Definition: EmDQMReco.h:216
Definition: event.py:1
Definition: Run.h:45
void getObjects(size_type filter, Vids &ids, VRphoton &photons) const
extract Ref<C>s for a specific filter and of specific physics type
HistoFillerReco< reco::RecoEcalCandidateCollection > * histoFillerClu
Definition: EmDQMReco.h:226