CMS 3D CMS Logo

L1TEGammaOffline.cc
Go to the documentation of this file.
4 
7 // Geometry
12 #include "TLorentzVector.h"
13 
14 #include <iostream>
15 #include <iomanip>
16 #include <cstdio>
17 #include <string>
18 #include <sstream>
19 #include <cmath>
20 #include <algorithm>
21 
22 
23 const std::map<std::string, unsigned int> L1TEGammaOffline::PlotConfigNames = {
24  {"nVertex", PlotConfig::nVertex},
25  {"ETvsET", PlotConfig::ETvsET},
26  {"PHIvsPHI", PlotConfig::PHIvsPHI}
27 };
28 
29 //
30 // -------------------------------------- Constructor --------------------------------------------
31 //
33  theGsfElectronCollection_(
34  consumes < reco::GsfElectronCollection > (ps.getParameter < edm::InputTag > ("electronCollection"))),
35  thePhotonCollection_(
36  consumes < std::vector<reco::Photon> > (ps.getParameter < edm::InputTag > ("photonCollection"))),
37  thePVCollection_(consumes < reco::VertexCollection > (ps.getParameter < edm::InputTag > ("PVCollection"))),
38  theBSCollection_(consumes < reco::BeamSpot > (ps.getParameter < edm::InputTag > ("beamSpotCollection"))),
39  triggerInputTag_(consumes < trigger::TriggerEvent > (ps.getParameter < edm::InputTag > ("triggerInputTag"))),
40  triggerResultsInputTag_(consumes<edm::TriggerResults>(ps.getParameter<edm::InputTag>("triggerResults"))),
41  triggerProcess_(ps.getParameter < std::string > ("triggerProcess")),
42  triggerNames_(ps.getParameter < std::vector<std::string> > ("triggerNames")),
43  histFolder_(ps.getParameter < std::string > ("histFolder")),
44  efficiencyFolder_(histFolder_ + "/efficiency_raw"),
45  stage2CaloLayer2EGammaToken_(
46  consumes < l1t::EGammaBxCollection > (ps.getParameter < edm::InputTag > ("stage2CaloLayer2EGammaSource"))),
47  electronEfficiencyThresholds_(ps.getParameter < std::vector<double> > ("electronEfficiencyThresholds")),
48  electronEfficiencyBins_(ps.getParameter < std::vector<double> > ("electronEfficiencyBins")),
49  probeToL1Offset_(ps.getParameter <double> ("probeToL1Offset")),
50  deepInspectionElectronThresholds_(ps.getParameter < std::vector<double> > ("deepInspectionElectronThresholds")),
51  photonEfficiencyThresholds_(ps.getParameter < std::vector<double> > ("photonEfficiencyThresholds")),
52  photonEfficiencyBins_(ps.getParameter < std::vector<double> > ("photonEfficiencyBins")),
53  maxDeltaRForL1Matching_(ps.getParameter <double> ("maxDeltaRForL1Matching")),
54  maxDeltaRForHLTMatching_(ps.getParameter <double> ("maxDeltaRForHLTMatching")),
55  recoToL1TThresholdFactor_(ps.getParameter <double> ("recoToL1TThresholdFactor")),
56  tagElectron_(),
57  probeElectron_(),
58  tagAndProbleInvariantMass_(-1.),
59  hltConfig_(),
60  triggerIndices_(),
61  triggerResults_(),
62  triggerEvent_(),
63  histDefinitions_(dqmoffline::l1t::readHistDefinitions(ps.getParameterSet("histDefinitions"), PlotConfigNames)),
64  h_nVertex_(),
65  h_tagAndProbeMass_(),
66  h_L1EGammaETvsElectronET_EB_(),
67  h_L1EGammaETvsElectronET_EE_(),
68  h_L1EGammaETvsElectronET_EB_EE_(),
69  h_L1EGammaPhivsElectronPhi_EB_(),
70  h_L1EGammaPhivsElectronPhi_EE_(),
71  h_L1EGammaPhivsElectronPhi_EB_EE_(),
72  h_L1EGammaEtavsElectronEta_(),
73  h_resolutionElectronET_EB_(),
74  h_resolutionElectronET_EE_(),
75  h_resolutionElectronET_EB_EE_(),
76  h_resolutionElectronPhi_EB_(),
77  h_resolutionElectronPhi_EE_(),
78  h_resolutionElectronPhi_EB_EE_(),
79  h_resolutionElectronEta_(),
80  h_efficiencyElectronET_EB_pass_(),
81  h_efficiencyElectronET_EE_pass_(),
82  h_efficiencyElectronET_EB_EE_pass_(),
83  h_efficiencyElectronPhi_vs_Eta_pass_(),
84  h_efficiencyElectronEta_pass_(),
85  h_efficiencyElectronPhi_pass_(),
86  h_efficiencyElectronNVertex_pass_(),
87  h_efficiencyElectronET_EB_total_(),
88  h_efficiencyElectronET_EE_total_(),
89  h_efficiencyElectronET_EB_EE_total_(),
90  h_efficiencyElectronPhi_vs_Eta_total_(),
91  h_efficiencyElectronEta_total_(),
92  h_efficiencyElectronPhi_total_(),
93  h_efficiencyElectronNVertex_total_(),
94  h_L1EGammaETvsPhotonET_EB_(),
95  h_L1EGammaETvsPhotonET_EE_(),
96  h_L1EGammaETvsPhotonET_EB_EE_(),
97  h_L1EGammaPhivsPhotonPhi_EB_(),
98  h_L1EGammaPhivsPhotonPhi_EE_(),
99  h_L1EGammaPhivsPhotonPhi_EB_EE_(),
100  h_L1EGammaEtavsPhotonEta_(),
101  h_resolutionPhotonEta_(),
102  h_efficiencyPhotonET_EB_pass_(),
103  h_efficiencyPhotonET_EE_pass_(),
104  h_efficiencyPhotonET_EB_EE_pass_(),
105  h_efficiencyPhotonET_EB_total_(),
106  h_efficiencyPhotonET_EE_total_(),
107  h_efficiencyPhotonET_EB_EE_total_()
108 {
109  edm::LogInfo("L1TEGammaOffline") << "Constructor " << "L1TEGammaOffline::L1TEGammaOffline " << std::endl;
110 }
111 
112 //
113 // -- Destructor
114 //
116 {
117  edm::LogInfo("L1TEGammaOffline") << "Destructor L1TEGammaOffline::~L1TEGammaOffline " << std::endl;
118 }
119 
120 //
121 // -------------------------------------- beginRun --------------------------------------------
122 //
123 void L1TEGammaOffline::dqmBeginRun(edm::Run const & iRun, edm::EventSetup const & iSetup)
124 {
125  edm::LogInfo("L1TEGammaOffline") << "L1TEGammaOffline::beginRun" << std::endl;
126  bool changed(true);
127  if (!hltConfig_.init(iRun, iSetup, triggerProcess_, changed)) {
128  edm::LogError("L1TEGammaOffline")
129  << " HLT config extraction failure with process name "
130  << triggerProcess_<< std::endl;
131  triggerNames_.clear();
132  } else {
134  }
135 }
136 
137 //
138 // -------------------------------------- bookHistos --------------------------------------------
139 //
141 {
142  edm::LogInfo("L1TEGammaOffline") << "L1TEGammaOffline::bookHistograms" << std::endl;
143 
144  //book at beginRun
145  bookElectronHistos(ibooker);
146  // bookPhotonHistos(ibooker);
147 }
148 
149 //
150 // -------------------------------------- Analyze --------------------------------------------
151 //
153 {
154  edm::LogInfo("L1TEGammaOffline") << "L1TEGammaOffline::analyze" << std::endl;
155 
156  edm::Handle<edm::TriggerResults> triggerResultHandle;
157  e.getByToken(triggerResultsInputTag_, triggerResultHandle);
158  if (!triggerResultHandle.isValid()) {
159  edm::LogWarning("L1TEGammaOffline") << "invalid edm::TriggerResults handle" << std::endl;
160  return;
161  }
162  triggerResults_ = *triggerResultHandle;
163 
164  edm::Handle<trigger::TriggerEvent> triggerEventHandle;
165  e.getByToken(triggerInputTag_, triggerEventHandle);
166  if (!triggerEventHandle.isValid()) {
167  edm::LogWarning("L1TEGammaOffline") << "invalid trigger::TriggerEvent handle" << std::endl;
168  return;
169  }
170  triggerEvent_ = *triggerEventHandle;
171 
173  e.getByToken(thePVCollection_, vertexHandle);
174  if (!vertexHandle.isValid()) {
175  edm::LogWarning("L1TEGammaOffline") << "invalid collection: vertex " << std::endl;
176  return;
177  }
178 
179  unsigned int nVertex = vertexHandle->size();
181 
183  return;
184  }
185  // L1T
186  fillElectrons(e, nVertex);
187  // fillPhotons(e, nVertex);
188 }
189 
190 void L1TEGammaOffline::fillElectrons(edm::Event const& e, const unsigned int nVertex)
191 {
194 
196  e.getByToken(theGsfElectronCollection_, gsfElectrons);
197 
198  if (!gsfElectrons.isValid()) {
199  edm::LogWarning("L1TEGammaOffline") << "invalid collection: GSF electrons " << std::endl;
200  return;
201  }
202  if (gsfElectrons->empty()) {
203  LogDebug("L1TEGammaOffline") << "empty collection: GSF electrons " << std::endl;
204  return;
205  }
206  if (!l1EGamma.isValid()) {
207  edm::LogWarning("L1TEGammaOffline") << "invalid collection: L1 EGamma " << std::endl;
208  return;
209  }
210  if (!findTagAndProbePair(gsfElectrons)) {
211  LogDebug("L1TEGammaOffline") << "Could not find a tag & probe pair" << std::endl;
212  return; //continue to next event
213  }
214 
215  auto probeElectron = probeElectron_;
216 
217  // find corresponding L1 EG
218  double minDeltaR = maxDeltaRForL1Matching_;
219  l1t::EGamma closestL1EGamma;
220  bool foundMatch = false;
221 
222  int bunchCrossing = 0;
223  for (auto egamma = l1EGamma->begin(bunchCrossing); egamma != l1EGamma->end(bunchCrossing); ++egamma) {
224  double currentDeltaR = deltaR(egamma->eta(), egamma->phi(), probeElectron.eta(), probeElectron.phi());
225  if (currentDeltaR > minDeltaR) {
226  continue;
227  } else {
228  minDeltaR = currentDeltaR;
229  closestL1EGamma = *egamma;
230  foundMatch = true;
231  }
232 
233  }
234 
235  if (!foundMatch) {
236  LogDebug("L1TEGammaOffline") << "Could not find a matching L1 EGamma " << std::endl;
237  return;
238  }
239 
240  double recoEt = probeElectron.et();
241  double recoEta = probeElectron.eta();
242  double recoPhi = probeElectron.phi();
243 
244  double l1Et = closestL1EGamma.et();
245  double l1Eta = closestL1EGamma.eta();
246  double l1Phi = closestL1EGamma.phi();
247 
248  // if no reco value, relative resolution does not make sense -> sort to overflow
249  double outOfBounds = 9999;
250  double resolutionEt = recoEt > 0 ? (l1Et - recoEt) / recoEt : outOfBounds;
251  double resolutionEta = l1Eta - recoEta;
252  double resolutionPhi = reco::deltaPhi(l1Phi, recoPhi);
253 
254  using namespace dqmoffline::l1t;
255  // eta
258 
259  // plots for deeper inspection
261  if (recoEt > threshold * recoToL1TThresholdFactor_) {
265  if (l1Et > threshold + probeToL1Offset_) {
266  fillWithinLimits(h_efficiencyElectronEta_pass_[threshold], recoEta);
267  fillWithinLimits(h_efficiencyElectronPhi_pass_[threshold], recoPhi);
269  }
270  }
271 }
272 
274  if (recoEt > threshold * recoToL1TThresholdFactor_) {
276  if (l1Et > threshold + probeToL1Offset_) {
277  fill2DWithinLimits(h_efficiencyElectronPhi_vs_Eta_pass_[threshold], recoEta, recoPhi);
278  }
279  }
280 }
281 
282  if (std::abs(recoEta) <= 1.479) { // barrel
283  // et
286  //resolution
289  // phi
292  // resolution
295 
296  // turn-ons
297  for (auto threshold : electronEfficiencyThresholds_) {
300  if (l1Et > threshold) {
303  }
304  }
305  } else { // end-cap
306  // et
309  //resolution
312  // phi
315  // resolution
318 
319  // turn-ons
320  for (auto threshold : electronEfficiencyThresholds_) {
323  if (l1Et > threshold) {
326  }
327  }
328  }
329 }
330 
350 {
351  bool foundBoth(false);
352  auto nElectrons = electrons->size();
353  if (nElectrons < 2)
354  return false;
355 
356  for (auto tagElectron : *electrons) {
357  for (auto probeElectron : *electrons) {
358  if (tagElectron.p4() == probeElectron.p4())
359  continue;
360 
361  auto combined(tagElectron.p4() + probeElectron.p4());
362  auto tagAbsEta = std::abs(tagElectron.eta());
363  auto probeAbsEta = std::abs(probeElectron.eta());
364 
365  // EB-EE transition region
366  bool isEBEEGap = tagElectron.isEBEEGap() || probeElectron.isEBEEGap();
367  bool passesEta = !isEBEEGap && tagAbsEta < 2.5 && probeAbsEta < 2.5;
368  bool passesCharge = tagElectron.charge() == -probeElectron.charge();
369 
370  // https://github.com/ikrav/cmssw/blob/egm_id_80X_v1/RecoEgamma/ElectronIdentification/plugins/cuts/GsfEleFull5x5SigmaIEtaIEtaCut.cc#L45
371  bool tagPassesMediumID = passesMediumEleId(tagElectron) && tagElectron.et() > 30.;
372  bool probePassesLooseID = passesLooseEleId(probeElectron);
373  bool passesInvariantMass = combined.M() > 60 && combined.M() < 120;
374  bool tagMatchesHLTObject = matchesAnHLTObject(tagElectron.eta(), tagElectron.phi());
375 
376  if (passesEta && passesInvariantMass && passesCharge && tagPassesMediumID &&
377  probePassesLooseID && tagMatchesHLTObject) {
378  foundBoth = true;
379  tagElectron_ = tagElectron;
380  probeElectron_ = probeElectron;
381  // plot tag & probe invariant mass
383  return foundBoth;
384  }
385  }
386 
387  }
388  return foundBoth;
389 }
390 
398 {
399  const float ecal_energy_inverse = 1.0 / electron.ecalEnergy();
400  const float eSCoverP = electron.eSuperClusterOverP();
401  const float eOverP = std::abs(1.0 - eSCoverP) * ecal_energy_inverse;
402 
403  if (electron.isEB() && eOverP > 0.241)
404  return false;
405  if (electron.isEE() && eOverP > 0.14)
406  return false;
407  if (electron.isEB() && std::abs(electron.deltaEtaSuperClusterTrackAtVtx()) > 0.00477)
408  return false;
409  if (electron.isEE() && std::abs(electron.deltaEtaSuperClusterTrackAtVtx()) > 0.00868)
410  return false;
411  if (electron.isEB() && std::abs(electron.deltaPhiSuperClusterTrackAtVtx()) > 0.222)
412  return false;
413  if (electron.isEE() && std::abs(electron.deltaPhiSuperClusterTrackAtVtx()) > 0.213)
414  return false;
415  if (electron.isEB() && electron.scSigmaIEtaIEta() > 0.011)
416  return false;
417  if (electron.isEE() && electron.scSigmaIEtaIEta() > 0.0314)
418  return false;
419  if (electron.isEB() && electron.hadronicOverEm() > 0.298)
420  return false;
421  if (electron.isEE() && electron.hadronicOverEm() > 0.101)
422  return false;
423  return true;
424 }
425 
426 /*
427  * Structure from
428  * https://github.com/cms-sw/cmssw/blob/CMSSW_9_0_X/DQMOffline/EGamma/plugins/ElectronAnalyzer.cc
429  * Values from
430  * https://twiki.cern.ch/twiki/bin/view/CMS/CutBasedElectronIdentificationRun2
431  */
433 {
434  const float ecal_energy_inverse = 1.0 / electron.ecalEnergy();
435  const float eSCoverP = electron.eSuperClusterOverP();
436  const float eOverP = std::abs(1.0 - eSCoverP) * ecal_energy_inverse;
437 
438  if (electron.isEB() && eOverP < 0.134)
439  return false;
440  if (electron.isEE() && eOverP > 0.13)
441  return false;
442  if (electron.isEB() && std::abs(electron.deltaEtaSuperClusterTrackAtVtx()) > 0.00311)
443  return false;
444  if (electron.isEE() && std::abs(electron.deltaEtaSuperClusterTrackAtVtx()) > 0.00609)
445  return false;
446  if (electron.isEB() && std::abs(electron.deltaPhiSuperClusterTrackAtVtx()) > 0.103)
447  return false;
448  if (electron.isEE() && std::abs(electron.deltaPhiSuperClusterTrackAtVtx()) > 0.045)
449  return false;
450  if (electron.isEB() && electron.scSigmaIEtaIEta() > 0.00998)
451  return false;
452  if (electron.isEE() && electron.scSigmaIEtaIEta() > 0.0298)
453  return false;
454  if (electron.isEB() && electron.hadronicOverEm() > 0.253)
455  return false;
456  if (electron.isEE() && electron.hadronicOverEm() > 0.0878)
457  return false;
458  return true;
459 }
460 
461 bool L1TEGammaOffline::matchesAnHLTObject(double eta, double phi) const{
462  // get HLT objects of fired triggers
463  using namespace dqmoffline::l1t;
464  std::vector<bool> results = getTriggerResults(triggerIndices_, triggerResults_);
465  std::vector<unsigned int> firedTriggers = getFiredTriggerIndices(triggerIndices_, results);
466  std::vector<edm::InputTag> hltFilters = getHLTFilters(firedTriggers, hltConfig_, triggerProcess_);
467  const trigger::TriggerObjectCollection hltObjects = getTriggerObjects(hltFilters, triggerEvent_);
468  const trigger::TriggerObjectCollection matchedObjects = getMatchedTriggerObjects(eta, phi, maxDeltaRForHLTMatching_, hltObjects);
469 
470  return !matchedObjects.empty();
471 }
472 
473 void L1TEGammaOffline::fillPhotons(edm::Event const& e, const unsigned int nVertex)
474 {
475  // TODO - just an example here
478 
480  e.getByToken(thePhotonCollection_, photons);
481 
482  if (!photons.isValid()) {
483  edm::LogWarning("L1TEGammaOffline") << "invalid collection: reco::Photons " << std::endl;
484  return;
485  }
486  if (!l1EGamma.isValid()) {
487  edm::LogWarning("L1TEGammaOffline") << "invalid collection: L1 EGamma " << std::endl;
488  return;
489  }
490 
491  if(photons->empty()){
492  LogDebug("L1TEGammaOffline") << "No photons found in event." << std::endl;
493  return;
494  }
495 
496  auto probePhoton = photons->at(0);
497 
498  double minDeltaR = 0.3;
499  l1t::EGamma closestL1EGamma;
500  bool foundMatch = false;
501 
502  int bunchCrossing = 0;
503  for (auto egamma = l1EGamma->begin(bunchCrossing); egamma != l1EGamma->end(bunchCrossing); ++egamma) {
504  double currentDeltaR = deltaR(egamma->eta(), egamma->phi(), probePhoton.eta(), probePhoton.phi());
505  if (currentDeltaR > minDeltaR) {
506  continue;
507  } else {
508  minDeltaR = currentDeltaR;
509  closestL1EGamma = *egamma;
510  foundMatch = true;
511  }
512 
513  }
514 
515  if (!foundMatch) {
516  LogDebug("L1TEGammaOffline") << "Could not find a matching L1 EGamma " << std::endl;
517  return;
518  }
519 
520  double recoEt = probePhoton.et();
521  double recoEta = probePhoton.eta();
522  double recoPhi = probePhoton.phi();
523 
524  double l1Et = closestL1EGamma.et();
525  double l1Eta = closestL1EGamma.eta();
526  double l1Phi = closestL1EGamma.phi();
527 
528  // if no reco value, relative resolution does not make sense -> sort to overflow
529  double outOfBounds = 9999;
530  double resolutionEt = recoEt > 0 ? (l1Et - recoEt) / recoEt : outOfBounds;
531  double resolutionEta = l1Eta - recoEta;
532  double resolutionPhi = reco::deltaPhi(l1Phi, recoPhi);
533 
534  using namespace dqmoffline::l1t;
535  // eta
538 
539  if (std::abs(recoEta) <= 1.479) { // barrel
540  // et
543  //resolution
546  // phi
549  // resolution
552 
553  // turn-ons
557  if (l1Et > threshold) {
560  }
561  }
562  } else { // end-cap
563  // et
566  //resolution
569  // phi
572  // resolution
575 
576  // turn-ons
580  if (l1Et > threshold) {
583  }
584  }
585  }
586 }
587 
588 //
589 // -------------------------------------- endRun --------------------------------------------
590 //
592 {
593  edm::LogInfo("L1TEGammaOffline") << "L1TEGammaOffline::endRun" << std::endl;
594 }
595 
596 //
597 // -------------------------------------- book histograms --------------------------------------------
598 //
600 {
601  ibooker.cd();
602  ibooker.setCurrentFolder(histFolder_);
603 
604  dqmoffline::l1t::HistDefinition nVertexDef = histDefinitions_[PlotConfig::nVertex];
605  h_nVertex_ = ibooker.book1D(
606  nVertexDef.name, nVertexDef.title, nVertexDef.nbinsX, nVertexDef.xmin, nVertexDef.xmax
607  );
608  h_tagAndProbeMass_ = ibooker.book1D("tagAndProbeMass", "Invariant mass of tag & probe pair", 100, 40, 140);
609  // electron reco vs L1
610  dqmoffline::l1t::HistDefinition templateETvsET = histDefinitions_[PlotConfig::ETvsET];
611  h_L1EGammaETvsElectronET_EB_ = ibooker.book2D("L1EGammaETvsElectronET_EB",
612  "L1 EGamma E_{T} vs GSF Electron E_{T} (EB); GSF Electron E_{T} (GeV); L1 EGamma E_{T} (GeV)",
613  templateETvsET.nbinsX, &templateETvsET.binsX[0], templateETvsET.nbinsY, &templateETvsET.binsY[0]);
614  h_L1EGammaETvsElectronET_EE_ = ibooker.book2D("L1EGammaETvsElectronET_EE",
615  "L1 EGamma E_{T} vs GSF Electron E_{T} (EE); GSF Electron E_{T} (GeV); L1 EGamma E_{T} (GeV)",
616  templateETvsET.nbinsX, &templateETvsET.binsX[0], templateETvsET.nbinsY, &templateETvsET.binsY[0]);
617  h_L1EGammaETvsElectronET_EB_EE_ = ibooker.book2D("L1EGammaETvsElectronET_EB_EE",
618  "L1 EGamma E_{T} vs GSF Electron E_{T} (EB+EE); GSF Electron E_{T} (GeV); L1 EGamma E_{T} (GeV)",
619  templateETvsET.nbinsX, &templateETvsET.binsX[0], templateETvsET.nbinsY, &templateETvsET.binsY[0]);
620 
621  dqmoffline::l1t::HistDefinition templatePHIvsPHI = histDefinitions_[PlotConfig::PHIvsPHI];
622  h_L1EGammaPhivsElectronPhi_EB_ = ibooker.book2D("L1EGammaPhivsElectronPhi_EB",
623  "#phi_{electron}^{L1} vs #phi_{electron}^{offline} (EB); #phi_{electron}^{offline}; #phi_{electron}^{L1}",
624  templatePHIvsPHI.nbinsX, templatePHIvsPHI.xmin, templatePHIvsPHI.xmax,
625  templatePHIvsPHI.nbinsY, templatePHIvsPHI.ymin, templatePHIvsPHI.ymax);
626  h_L1EGammaPhivsElectronPhi_EE_ = ibooker.book2D("L1EGammaPhivsElectronPhi_EE",
627  "#phi_{electron}^{L1} vs #phi_{electron}^{offline} (EE); #phi_{electron}^{offline}; #phi_{electron}^{L1}",
628  templatePHIvsPHI.nbinsX, templatePHIvsPHI.xmin, templatePHIvsPHI.xmax,
629  templatePHIvsPHI.nbinsY, templatePHIvsPHI.ymin, templatePHIvsPHI.ymax);
630  h_L1EGammaPhivsElectronPhi_EB_EE_ = ibooker.book2D("L1EGammaPhivsElectronPhi_EB_EE",
631  "#phi_{electron}^{L1} vs #phi_{electron}^{offline} (EB+EE); #phi_{electron}^{offline}; #phi_{electron}^{L1}",
632  templatePHIvsPHI.nbinsX, templatePHIvsPHI.xmin, templatePHIvsPHI.xmax,
633  templatePHIvsPHI.nbinsY, templatePHIvsPHI.ymin, templatePHIvsPHI.ymax);
634 
635  h_L1EGammaEtavsElectronEta_ = ibooker.book2D("L1EGammaEtavsElectronEta",
636  "L1 EGamma #eta vs GSF Electron #eta; GSF Electron #eta; L1 EGamma #eta", 100, -3, 3, 100, -3, 3);
637 
638  // electron resolutions
639  h_resolutionElectronET_EB_ = ibooker.book1D("resolutionElectronET_EB",
640  "electron ET resolution (EB); (L1 EGamma E_{T} - GSF Electron E_{T})/GSF Electron E_{T}; events", 50, -1, 1.5);
641  h_resolutionElectronET_EE_ = ibooker.book1D("resolutionElectronET_EE",
642  "electron ET resolution (EE); (L1 EGamma E_{T} - GSF Electron E_{T})/GSF Electron E_{T}; events", 50, -1, 1.5);
643  h_resolutionElectronET_EB_EE_ = ibooker.book1D("resolutionElectronET_EB_EE",
644  "electron ET resolution (EB+EE); (L1 EGamma E_{T} - GSF Electron E_{T})/GSF Electron E_{T}; events", 50, -1, 1.5);
645 
647  ibooker.book1D("resolutionElectronPhi_EB",
648  "#phi_{electron} resolution (EB); #phi_{electron}^{L1} - #phi_{electron}^{offline}; events",
649  120, -0.3, 0.3);
651  ibooker.book1D("resolutionElectronPhi_EE",
652  "electron #phi resolution (EE); #phi_{electron}^{L1} - #phi_{electron}^{offline}; events",
653  120, -0.3, 0.3);
655  ibooker.book1D("resolutionElectronPhi_EB_EE",
656  "electron #phi resolution (EB+EE); #phi_{electron}^{L1} - #phi_{electron}^{offline}; events",
657  120, -0.3, 0.3);
658 
659  h_resolutionElectronEta_ = ibooker.book1D("resolutionElectronEta",
660  "electron #eta resolution (EB); L1 EGamma #eta - GSF Electron #eta; events", 120, -0.3, 0.3);
661 
662  // electron turn-ons
664  std::vector<float> electronBins(electronEfficiencyBins_.begin(), electronEfficiencyBins_.end());
665  int nBins = electronBins.size() - 1;
666  float* electronBinArray = &(electronBins[0]);
667 
669  std::string str_threshold = std::to_string(int(threshold));
671  "efficiencyElectronET_EB_threshold_" + str_threshold + "_Num",
672  "electron efficiency (EB) (numerator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
674  "efficiencyElectronET_EE_threshold_" + str_threshold + "_Num",
675  "electron efficiency (EE) (numerator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
677  "efficiencyElectronET_EB_EE_threshold_" + str_threshold + "_Num",
678  "electron efficiency (EB+EE) (numerator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
680  "efficiencyElectronPhi_vs_Eta_threshold_" + str_threshold + "_Num",
681  "electron efficiency (numerator); GSF Electron #eta; GSF Electron #phi",
682  50, -2.5, 2.5, 32, -3.2, 3.2);
683 
685  "efficiencyElectronET_EB_threshold_" + str_threshold + "_Den",
686  "electron efficiency (EB) (denominator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
688  "efficiencyElectronET_EE_threshold_" + str_threshold + "_Den",
689  "electron efficiency (EE) (denominator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
691  "efficiencyElectronET_EB_EE_threshold_" + str_threshold + "_Den",
692  "electron efficiency (EB+EE) (denominator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
694  "efficiencyElectronPhi_vs_Eta_threshold_" + str_threshold + "_Den",
695  "electron efficiency (denominator); GSF Electron #eta; GSF Electron #phi",
696  50, -2.5, 2.5, 32, -3.2, 3.2);
697  }
698 
700  std::string str_threshold = std::to_string(int(threshold));
702  "efficiencyElectronEta_threshold_" + str_threshold + "_Num",
703  "electron efficiency (numerator); GSF Electron #eta; events", 50, -2.5, 2.5);
705  "efficiencyElectronPhi_threshold_" + str_threshold + "_Num",
706  "electron efficiency (numerator); GSF Electron #phi; events", 32, -3.2, 3.2);
708  "efficiencyElectronNVertex_threshold_" + str_threshold + "_Num",
709  "electron efficiency (numerator); Nvtx; events", 30, 0, 60);
710 
712  "efficiencyElectronEta_threshold_" + str_threshold + "_Den",
713  "electron efficiency (denominator); GSF Electron #eta; events", 50, -2.5, 2.5);
715  "efficiencyElectronPhi_threshold_" + str_threshold + "_Den",
716  "electron efficiency (denominator); GSF Electron #phi; events", 32, -3.2, 3.2);
718  "efficiencyElectronNVertex_threshold_" + str_threshold + "_Den",
719  "electron efficiency (denominator); Nvtx; events", 30, 0, 60);
720  }
721 
722 
723  ibooker.cd();
724 }
725 
727 {
728  ibooker.cd();
729  ibooker.setCurrentFolder(histFolder_);
730 
731  dqmoffline::l1t::HistDefinition templateETvsET = histDefinitions_[PlotConfig::ETvsET];
732  h_L1EGammaETvsPhotonET_EB_ = ibooker.book2D("L1EGammaETvsPhotonET_EB",
733  "L1 EGamma E_{T} vs Photon E_{T} (EB); Photon E_{T} (GeV); L1 EGamma E_{T} (GeV)",
734  templateETvsET.nbinsX, &templateETvsET.binsX[0], templateETvsET.nbinsY, &templateETvsET.binsY[0]);
735  h_L1EGammaETvsPhotonET_EE_ = ibooker.book2D("L1EGammaETvsPhotonET_EE",
736  "L1 EGamma E_{T} vs Photon E_{T} (EE); Photon E_{T} (GeV); L1 EGamma E_{T} (GeV)",
737  templateETvsET.nbinsX, &templateETvsET.binsX[0], templateETvsET.nbinsY, &templateETvsET.binsY[0]);
738  h_L1EGammaETvsPhotonET_EB_EE_ = ibooker.book2D("L1EGammaETvsPhotonET_EB_EE",
739  "L1 EGamma E_{T} vs Photon E_{T} (EB+EE); Photon E_{T} (GeV); L1 EGamma E_{T} (GeV)",
740  templateETvsET.nbinsX, &templateETvsET.binsX[0], templateETvsET.nbinsY, &templateETvsET.binsY[0]);
741 
742  dqmoffline::l1t::HistDefinition templatePHIvsPHI = histDefinitions_[PlotConfig::PHIvsPHI];
743  h_L1EGammaPhivsPhotonPhi_EB_ = ibooker.book2D("L1EGammaPhivsPhotonPhi_EB",
744  "#phi_{photon}^{L1} vs #phi_{photon}^{offline} (EB); #phi_{photon}^{offline}; #phi_{photon}^{L1}",
745  templatePHIvsPHI.nbinsX, templatePHIvsPHI.xmin, templatePHIvsPHI.xmax,
746  templatePHIvsPHI.nbinsY, templatePHIvsPHI.ymin, templatePHIvsPHI.ymax);
747  h_L1EGammaPhivsPhotonPhi_EE_ = ibooker.book2D("L1EGammaPhivsPhotonPhi_EE",
748  "#phi_{photon}^{L1} vs #phi_{photon}^{offline} (EE); #phi_{photon}^{offline}; #phi_{photon}^{L1}",
749  templatePHIvsPHI.nbinsX, templatePHIvsPHI.xmin, templatePHIvsPHI.xmax,
750  templatePHIvsPHI.nbinsY, templatePHIvsPHI.ymin, templatePHIvsPHI.ymax);
751  h_L1EGammaPhivsPhotonPhi_EB_EE_ = ibooker.book2D("L1EGammaPhivsPhotonPhi_EB_EE",
752  "#phi_{photon}^{L1} vs #phi_{photon}^{offline} (EB+EE); #phi_{photon}^{offline}; #phi_{photon}^{L1}",
753  templatePHIvsPHI.nbinsX, templatePHIvsPHI.xmin, templatePHIvsPHI.xmax,
754  templatePHIvsPHI.nbinsY, templatePHIvsPHI.ymin, templatePHIvsPHI.ymax);
755 
756  h_L1EGammaEtavsPhotonEta_ = ibooker.book2D("L1EGammaEtavsPhotonEta",
757  "L1 EGamma #eta vs Photon #eta; Photon #eta; L1 EGamma #eta", 100, -3, 3, 100, -3, 3);
758 
759  // photon resolutions
760  h_resolutionPhotonET_EB_ = ibooker.book1D("resolutionPhotonET_EB",
761  "photon ET resolution (EB); (L1 EGamma E_{T} - Photon E_{T})/ Photon E_{T}; events", 50, -1, 1.5);
762  h_resolutionPhotonET_EE_ = ibooker.book1D("resolutionPhotonET_EE",
763  "photon ET resolution (EE); (L1 EGamma E_{T} - Photon E_{T})/ Photon E_{T}; events", 50, -1, 1.5);
764  h_resolutionPhotonET_EB_EE_ = ibooker.book1D("resolutionPhotonET_EB_EE",
765  "photon ET resolution (EB+EE); (L1 EGamma E_{T} - Photon E_{T})/ Photon E_{T}; events", 50, -1, 1.5);
766 
767  h_resolutionPhotonPhi_EB_ = ibooker.book1D("resolutionPhotonPhi_EB",
768  "#phi_{photon} resolution (EB); #phi_{photon}^{L1} - #phi_{photon}^{offline}; events",
769  120, -0.3, 0.3);
770  h_resolutionPhotonPhi_EE_ = ibooker.book1D("resolutionPhotonPhi_EE",
771  "photon #phi resolution (EE); #phi_{photon}^{L1} - #phi_{photon}^{offline}; events",
772  120, -0.3, 0.3);
773  h_resolutionPhotonPhi_EB_EE_ = ibooker.book1D("resolutionPhotonPhi_EB_EE",
774  "photon #phi resolution (EB+EE); #phi_{photon}^{L1} - #phi_{photon}^{offline}; events",
775  120, -0.3, 0.3);
776 
777  h_resolutionPhotonEta_ = ibooker.book1D("resolutionPhotonEta",
778  "photon #eta resolution (EB); L1 EGamma #eta - Photon #eta; events", 120, -0.3, 0.3);
779 
780  // photon turn-ons
782  std::vector<float> photonBins(photonEfficiencyBins_.begin(), photonEfficiencyBins_.end());
783  int nBins = photonBins.size() - 1;
784  float* photonBinArray = &(photonBins[0]);
785 
787  std::string str_threshold = std::to_string(int(threshold));
789  "efficiencyPhotonET_EB_threshold_" + str_threshold + "_Num",
790  "photon efficiency (EB) (numerator); Photon E_{T} (GeV); events", nBins, photonBinArray);
792  "efficiencyPhotonET_EE_threshold_" + str_threshold + "_Num",
793  "photon efficiency (EE) (numerator); Photon E_{T} (GeV); events", nBins, photonBinArray);
795  "efficiencyPhotonET_EB_EE_threshold_" + str_threshold + "_Num",
796  "photon efficiency (EB+EE) (numerator); Photon E_{T} (GeV); events", nBins, photonBinArray);
797 
799  "efficiencyPhotonET_EB_threshold_" + str_threshold + "_Den",
800  "photon efficiency (EB) (denominator); Photon E_{T} (GeV); events", nBins, photonBinArray);
802  "efficiencyPhotonET_EE_threshold_" + str_threshold + "_Den",
803  "photon efficiency (EE) (denominator); Photon E_{T} (GeV); events", nBins, photonBinArray);
805  "efficiencyPhotonET_EB_EE_threshold_" + str_threshold + "_Den",
806  "photon efficiency (EB+EE) (denominator); Photon E_{T} (GeV); events", nBins, photonBinArray);
807  }
808 
809  ibooker.cd();
810 }
811 
814 }
815 
817  std::vector<MonitorElement *> monElementstoNormalize = {
825  };
826 
827  for (auto mon : monElementstoNormalize) {
828  if (mon != nullptr) {
829  auto h = mon->getTH2F();
830  if (h != nullptr) {
831  h->Scale(1, "width");
832  }
833  }
834  }
835 }
836 
837 //define this as a plug-in
#define LogDebug(id)
std::vector< float > binsX
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
BXVector< EGamma > EGammaBxCollection
Definition: EGamma.h:11
const_iterator end(int bx) const
void bookElectronHistos(DQMStore::IBooker &)
std::map< double, MonitorElement * > h_efficiencyElectronNVertex_pass_
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
void fillPhotons(edm::Event const &e, const unsigned int nVertex)
std::vector< double > electronEfficiencyBins_
MonitorElement * h_resolutionElectronPhi_EB_EE_
MonitorElement * h_L1EGammaPhivsElectronPhi_EE_
edm::EDGetTokenT< reco::GsfElectronCollection > theGsfElectronCollection_
MonitorElement * h_tagAndProbeMass_
Definition: Photon.py:1
double eta() const final
momentum pseudorapidity
trigger::TriggerObjectCollection getMatchedTriggerObjects(double eta, double phi, double maxDeltaR, const trigger::TriggerObjectCollection triggerObjects)
Definition: L1TCommon.cc:121
std::map< double, MonitorElement * > h_efficiencyPhotonET_EE_total_
MonitorElement * h_L1EGammaETvsElectronET_EB_EE_
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
float eSuperClusterOverP() const
Definition: GsfElectron.h:249
std::map< double, MonitorElement * > h_efficiencyPhotonET_EB_pass_
MonitorElement * h_L1EGammaPhivsPhotonPhi_EB_
double maxDeltaRForL1Matching_
bool passesMediumEleId(reco::GsfElectron const &electron) const
MonitorElement * h_L1EGammaETvsPhotonET_EB_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< std::vector< reco::Photon > > thePhotonCollection_
std::map< double, MonitorElement * > h_efficiencyElectronET_EB_EE_pass_
ParameterSet const & getParameterSet(ParameterSetID const &id)
std::string histFolder_
const std::vector< std::string > & triggerNames() const
names of trigger paths
MonitorElement * h_L1EGammaETvsPhotonET_EE_
void fillElectrons(edm::Event const &e, const unsigned int nVertex)
std::map< double, MonitorElement * > h_efficiencyElectronPhi_pass_
std::map< double, MonitorElement * > h_efficiencyPhotonET_EB_EE_total_
trigger::TriggerObjectCollection getTriggerObjects(const std::vector< edm::InputTag > &hltFilters, const trigger::TriggerEvent &triggerEvent)
Definition: L1TCommon.cc:80
MonitorElement * h_resolutionPhotonET_EE_
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
MonitorElement * h_resolutionElectronET_EB_
std::map< double, MonitorElement * > h_efficiencyElectronET_EB_total_
dqmoffline::l1t::HistDefinitions histDefinitions_
delete x;
Definition: CaloConfig.h:22
bool passesLooseEleId(reco::GsfElectron const &electron) const
void bookPhotonHistos(DQMStore::IBooker &)
~L1TEGammaOffline() override
std::map< double, MonitorElement * > h_efficiencyElectronPhi_vs_Eta_total_
L1TEGammaOffline(const edm::ParameterSet &ps)
MonitorElement * h_L1EGammaETvsElectronET_EB_
std::map< double, MonitorElement * > h_efficiencyElectronPhi_vs_Eta_pass_
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
MonitorElement * h_L1EGammaPhivsElectronPhi_EB_EE_
std::map< double, MonitorElement * > h_efficiencyPhotonET_EB_EE_pass_
bool isEE() const
Definition: GsfElectron.h:357
bool isEB() const
Definition: GsfElectron.h:356
std::vector< unsigned int > getTriggerIndices(const std::vector< std::string > &requestedTriggers, const std::vector< std::string > &triggersInEvent)
Definition: L1TCommon.cc:11
MonitorElement * h_resolutionElectronET_EE_
edm::EDGetTokenT< trigger::TriggerEvent > triggerInputTag_
void normalise2DHistogramsToBinArea()
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:253
void endJob() override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
double maxDeltaRForHLTMatching_
float hadronicOverEm() const
Definition: GsfElectron.h:495
std::vector< double > electronEfficiencyThresholds_
MonitorElement * h_L1EGammaPhivsPhotonPhi_EB_EE_
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
double et() const final
transverse energy
std::map< double, MonitorElement * > h_efficiencyElectronEta_pass_
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:256
std::map< double, MonitorElement * > h_efficiencyElectronNVertex_total_
MonitorElement * h_L1EGammaEtavsElectronEta_
std::string triggerProcess_
std::vector< edm::InputTag > getHLTFilters(const std::vector< unsigned int > &triggers, const HLTConfigProvider &hltConfig, const std::string triggerProcess)
Definition: L1TCommon.cc:106
MonitorElement * h_resolutionPhotonET_EB_
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
edm::EDGetTokenT< l1t::EGammaBxCollection > stage2CaloLayer2EGammaToken_
MonitorElement * h_resolutionElectronEta_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void endRun(edm::Run const &run, edm::EventSetup const &eSetup) override
reco::GsfElectron tagElectron_
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
bool isValid() const
Definition: HandleBase.h:74
MonitorElement * h_resolutionPhotonEta_
float scSigmaIEtaIEta() const
Definition: GsfElectron.h:491
MonitorElement * h_L1EGammaPhivsPhotonPhi_EE_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsInputTag_
static const std::map< std::string, unsigned int > PlotConfigNames
std::map< double, MonitorElement * > h_efficiencyElectronET_EE_total_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
HLTConfigProvider hltConfig_
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
HistDefinitions readHistDefinitions(const edm::ParameterSet &ps, const std::map< std::string, unsigned int > &mapping)
bool findTagAndProbePair(edm::Handle< reco::GsfElectronCollection > const &electrons)
std::map< double, MonitorElement * > h_efficiencyPhotonET_EB_total_
std::string efficiencyFolder_
std::map< double, MonitorElement * > h_efficiencyElectronET_EE_pass_
std::vector< double > deepInspectionElectronThresholds_
std::vector< float > binsY
reco::GsfElectron probeElectron_
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
bool matchesAnHLTObject(double eta, double phi) const
MonitorElement * h_resolutionPhotonPhi_EB_EE_
std::vector< bool > getTriggerResults(const std::vector< unsigned int > &triggers, const edm::TriggerResults &triggerResults)
Definition: L1TCommon.cc:35
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
void fill2DWithinLimits(MonitorElement *mon, double valueX, double valueY, double weight=1.)
std::map< double, MonitorElement * > h_efficiencyElectronPhi_total_
MonitorElement * h_resolutionElectronET_EB_EE_
float ecalEnergy() const
Definition: GsfElectron.h:860
std::map< double, MonitorElement * > h_efficiencyElectronEta_total_
std::map< double, MonitorElement * > h_efficiencyElectronET_EB_EE_total_
std::vector< std::string > triggerNames_
MonitorElement * h_resolutionElectronPhi_EB_
edm::TriggerResults triggerResults_
MonitorElement * h_nVertex_
void fillWithinLimits(MonitorElement *mon, double value, double weight=1.)
MonitorElement * h_resolutionPhotonPhi_EB_
fixed size matrix
std::vector< double > photonEfficiencyBins_
HLT enums.
MonitorElement * h_L1EGammaETvsPhotonET_EB_EE_
MonitorElement * h_L1EGammaETvsElectronET_EE_
MonitorElement * h_resolutionElectronPhi_EE_
MonitorElement * h_L1EGammaEtavsPhotonEta_
MonitorElement * h_resolutionPhotonPhi_EE_
edm::EDGetTokenT< reco::VertexCollection > thePVCollection_
std::vector< unsigned int > triggerIndices_
std::vector< double > photonEfficiencyThresholds_
std::map< double, MonitorElement * > h_efficiencyElectronET_EB_pass_
const_iterator begin(int bx) const
MonitorElement * h_L1EGammaPhivsElectronPhi_EB_
double phi() const final
momentum azimuthal angle
std::map< double, MonitorElement * > h_efficiencyPhotonET_EE_pass_
MonitorElement * h_resolutionPhotonET_EB_EE_
double recoToL1TThresholdFactor_
trigger::TriggerEvent triggerEvent_
std::vector< unsigned int > getFiredTriggerIndices(const std::vector< unsigned int > &triggers, const std::vector< bool > &triggerResults)
Definition: L1TCommon.cc:57
Definition: Run.h:45
bool passesAnyTriggerFromList(const std::vector< unsigned int > &triggers, const edm::TriggerResults &triggerResults)
Definition: L1TCommon.cc:69