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  tagElectron_(),
56  probeElectron_(),
57  tagAndProbleInvariantMass_(-1.),
58  hltConfig_(),
59  triggerIndices_(),
60  triggerResults_(),
61  triggerEvent_(),
62  histDefinitions_(dqmoffline::l1t::readHistDefinitions(ps.getParameterSet("histDefinitions"), PlotConfigNames)),
63  h_nVertex_(),
64  h_tagAndProbeMass_(),
65  h_L1EGammaETvsElectronET_EB_(),
66  h_L1EGammaETvsElectronET_EE_(),
67  h_L1EGammaETvsElectronET_EB_EE_(),
68  h_L1EGammaPhivsElectronPhi_EB_(),
69  h_L1EGammaPhivsElectronPhi_EE_(),
70  h_L1EGammaPhivsElectronPhi_EB_EE_(),
71  h_L1EGammaEtavsElectronEta_(),
72  h_resolutionElectronET_EB_(),
73  h_resolutionElectronET_EE_(),
74  h_resolutionElectronET_EB_EE_(),
75  h_resolutionElectronPhi_EB_(),
76  h_resolutionElectronPhi_EE_(),
77  h_resolutionElectronPhi_EB_EE_(),
78  h_resolutionElectronEta_(),
79  h_efficiencyElectronET_EB_pass_(),
80  h_efficiencyElectronET_EE_pass_(),
81  h_efficiencyElectronET_EB_EE_pass_(),
82  h_efficiencyElectronPhi_vs_Eta_pass_(),
83  h_efficiencyElectronEta_pass_(),
84  h_efficiencyElectronPhi_pass_(),
85  h_efficiencyElectronNVertex_pass_(),
86  h_efficiencyElectronET_EB_total_(),
87  h_efficiencyElectronET_EE_total_(),
88  h_efficiencyElectronET_EB_EE_total_(),
89  h_efficiencyElectronPhi_vs_Eta_total_(),
90  h_efficiencyElectronEta_total_(),
91  h_efficiencyElectronPhi_total_(),
92  h_efficiencyElectronNVertex_total_(),
93  h_L1EGammaETvsPhotonET_EB_(),
94  h_L1EGammaETvsPhotonET_EE_(),
95  h_L1EGammaETvsPhotonET_EB_EE_(),
96  h_L1EGammaPhivsPhotonPhi_EB_(),
97  h_L1EGammaPhivsPhotonPhi_EE_(),
98  h_L1EGammaPhivsPhotonPhi_EB_EE_(),
99  h_L1EGammaEtavsPhotonEta_(),
100  h_resolutionPhotonEta_(),
101  h_efficiencyPhotonET_EB_pass_(),
102  h_efficiencyPhotonET_EE_pass_(),
103  h_efficiencyPhotonET_EB_EE_pass_(),
104  h_efficiencyPhotonET_EB_total_(),
105  h_efficiencyPhotonET_EE_total_(),
106  h_efficiencyPhotonET_EB_EE_total_()
107 {
108  edm::LogInfo("L1TEGammaOffline") << "Constructor " << "L1TEGammaOffline::L1TEGammaOffline " << std::endl;
109 }
110 
111 //
112 // -- Destructor
113 //
115 {
116  edm::LogInfo("L1TEGammaOffline") << "Destructor L1TEGammaOffline::~L1TEGammaOffline " << std::endl;
117 }
118 
119 //
120 // -------------------------------------- beginRun --------------------------------------------
121 //
122 void L1TEGammaOffline::dqmBeginRun(edm::Run const & iRun, edm::EventSetup const & iSetup)
123 {
124  edm::LogInfo("L1TEGammaOffline") << "L1TEGammaOffline::beginRun" << std::endl;
125  bool changed(true);
126  if (!hltConfig_.init(iRun, iSetup, triggerProcess_, changed)) {
127  edm::LogError("L1TEGammaOffline")
128  << " HLT config extraction failure with process name "
129  << triggerProcess_<< std::endl;
130  triggerNames_.clear();
131  } else {
133  }
134 }
135 
136 //
137 // -------------------------------------- bookHistos --------------------------------------------
138 //
140 {
141  edm::LogInfo("L1TEGammaOffline") << "L1TEGammaOffline::bookHistograms" << std::endl;
142 
143  //book at beginRun
144  bookElectronHistos(ibooker);
145  // bookPhotonHistos(ibooker);
146 }
147 
148 //
149 // -------------------------------------- Analyze --------------------------------------------
150 //
152 {
153  edm::LogInfo("L1TEGammaOffline") << "L1TEGammaOffline::analyze" << std::endl;
154 
155  edm::Handle<edm::TriggerResults> triggerResultHandle;
156  e.getByToken(triggerResultsInputTag_, triggerResultHandle);
157  if (!triggerResultHandle.isValid()) {
158  edm::LogWarning("L1TEGammaOffline") << "invalid edm::TriggerResults handle" << std::endl;
159  return;
160  }
161  triggerResults_ = *triggerResultHandle;
162 
163  edm::Handle<trigger::TriggerEvent> triggerEventHandle;
164  e.getByToken(triggerInputTag_, triggerEventHandle);
165  if (!triggerEventHandle.isValid()) {
166  edm::LogWarning("L1TEGammaOffline") << "invalid trigger::TriggerEvent handle" << std::endl;
167  return;
168  }
169  triggerEvent_ = *triggerEventHandle;
170 
172  e.getByToken(thePVCollection_, vertexHandle);
173  if (!vertexHandle.isValid()) {
174  edm::LogWarning("L1TEGammaOffline") << "invalid collection: vertex " << std::endl;
175  return;
176  }
177 
178  unsigned int nVertex = vertexHandle->size();
180 
182  return;
183  }
184  // L1T
185  fillElectrons(e, nVertex);
186  // fillPhotons(e, nVertex);
187 }
188 
189 void L1TEGammaOffline::fillElectrons(edm::Event const& e, const unsigned int nVertex)
190 {
193 
195  e.getByToken(theGsfElectronCollection_, gsfElectrons);
196 
197  if (!gsfElectrons.isValid()) {
198  edm::LogWarning("L1TEGammaOffline") << "invalid collection: GSF electrons " << std::endl;
199  return;
200  }
201  if (gsfElectrons->empty()) {
202  LogDebug("L1TEGammaOffline") << "empty collection: GSF electrons " << std::endl;
203  return;
204  }
205  if (!l1EGamma.isValid()) {
206  edm::LogWarning("L1TEGammaOffline") << "invalid collection: L1 EGamma " << std::endl;
207  return;
208  }
209  if (!findTagAndProbePair(gsfElectrons)) {
210  LogDebug("L1TEGammaOffline") << "Could not find a tag & probe pair" << std::endl;
211  return; //continue to next event
212  }
213 
214  auto probeElectron = probeElectron_;
215 
216  // find corresponding L1 EG
217  double minDeltaR = maxDeltaRForL1Matching_;
218  l1t::EGamma closestL1EGamma;
219  bool foundMatch = false;
220 
221  int bunchCrossing = 0;
222  for (auto egamma = l1EGamma->begin(bunchCrossing); egamma != l1EGamma->end(bunchCrossing); ++egamma) {
223  double currentDeltaR = deltaR(egamma->eta(), egamma->phi(), probeElectron.eta(), probeElectron.phi());
224  if (currentDeltaR > minDeltaR) {
225  continue;
226  } else {
227  minDeltaR = currentDeltaR;
228  closestL1EGamma = *egamma;
229  foundMatch = true;
230  break;
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
264  if(recoEt > threshold){
265  fillWithinLimits(h_efficiencyElectronEta_pass_[threshold], recoEta);
266  fillWithinLimits(h_efficiencyElectronPhi_pass_[threshold], recoPhi);
268  }
269  }
270 
273  recoEta, recoPhi);
274  if(l1Et > threshold + probeToL1Offset_){
276  recoEta, recoPhi);
277  }
278  }
279 
280  if (std::abs(recoEta) <= 1.479) { // barrel
281  // et
284  //resolution
287  // phi
290  // resolution
293 
294  // turn-ons
295  for (auto threshold : electronEfficiencyThresholds_) {
298  if (l1Et > threshold) {
301  }
302  }
303  } else { // end-cap
304  // et
307  //resolution
310  // phi
313  // resolution
316 
317  // turn-ons
318  for (auto threshold : electronEfficiencyThresholds_) {
321  if (l1Et > threshold) {
324  }
325  }
326  }
327 }
328 
348 {
349  bool foundBoth(false);
350  auto nElectrons = electrons->size();
351  if (nElectrons < 2)
352  return false;
353 
354  for (auto tagElectron : *electrons) {
355  for (auto probeElectron : *electrons) {
356  if (tagElectron.p4() == probeElectron.p4())
357  continue;
358 
359  auto combined(tagElectron.p4() + probeElectron.p4());
360  auto tagAbsEta = std::abs(tagElectron.eta());
361  auto probeAbsEta = std::abs(probeElectron.eta());
362 
363  // EB-EE transition region
364  bool isEBEEGap = tagElectron.isEBEEGap() || probeElectron.isEBEEGap();
365  bool passesEta = !isEBEEGap && tagAbsEta < 2.5 && probeAbsEta < 2.5;
366  bool passesCharge = tagElectron.charge() == -probeElectron.charge();
367 
368  // https://github.com/ikrav/cmssw/blob/egm_id_80X_v1/RecoEgamma/ElectronIdentification/plugins/cuts/GsfEleFull5x5SigmaIEtaIEtaCut.cc#L45
369  bool tagPassesMediumID = passesMediumEleId(tagElectron) && tagElectron.et() > 30.;
370  bool probePassesLooseID = passesLooseEleId(probeElectron);
371  bool passesInvariantMass = combined.M() > 60 && combined.M() < 120;
372  bool tagMatchesHLTObject = matchesAnHLTObject(tagElectron.eta(), tagElectron.phi());
373 
374  if (passesEta && passesInvariantMass && passesCharge && tagPassesMediumID &&
375  probePassesLooseID && tagMatchesHLTObject) {
376  foundBoth = true;
377  tagElectron_ = tagElectron;
378  probeElectron_ = probeElectron;
379  // plot tag & probe invariant mass
381  return foundBoth;
382  }
383  }
384 
385  }
386  return foundBoth;
387 }
388 
396 {
397  const float ecal_energy_inverse = 1.0 / electron.ecalEnergy();
398  const float eSCoverP = electron.eSuperClusterOverP();
399  const float eOverP = std::abs(1.0 - eSCoverP) * ecal_energy_inverse;
400 
401  if (electron.isEB() && eOverP > 0.241)
402  return false;
403  if (electron.isEE() && eOverP > 0.14)
404  return false;
405  if (electron.isEB() && std::abs(electron.deltaEtaSuperClusterTrackAtVtx()) > 0.00477)
406  return false;
407  if (electron.isEE() && std::abs(electron.deltaEtaSuperClusterTrackAtVtx()) > 0.00868)
408  return false;
409  if (electron.isEB() && std::abs(electron.deltaPhiSuperClusterTrackAtVtx()) > 0.222)
410  return false;
411  if (electron.isEE() && std::abs(electron.deltaPhiSuperClusterTrackAtVtx()) > 0.213)
412  return false;
413  if (electron.isEB() && electron.scSigmaIEtaIEta() > 0.011)
414  return false;
415  if (electron.isEE() && electron.scSigmaIEtaIEta() > 0.0314)
416  return false;
417  if (electron.isEB() && electron.hadronicOverEm() > 0.298)
418  return false;
419  if (electron.isEE() && electron.hadronicOverEm() > 0.101)
420  return false;
421  return true;
422 }
423 
424 /*
425  * Structure from
426  * https://github.com/cms-sw/cmssw/blob/CMSSW_9_0_X/DQMOffline/EGamma/plugins/ElectronAnalyzer.cc
427  * Values from
428  * https://twiki.cern.ch/twiki/bin/view/CMS/CutBasedElectronIdentificationRun2
429  */
431 {
432  const float ecal_energy_inverse = 1.0 / electron.ecalEnergy();
433  const float eSCoverP = electron.eSuperClusterOverP();
434  const float eOverP = std::abs(1.0 - eSCoverP) * ecal_energy_inverse;
435 
436  if (electron.isEB() && eOverP < 0.134)
437  return false;
438  if (electron.isEE() && eOverP > 0.13)
439  return false;
440  if (electron.isEB() && std::abs(electron.deltaEtaSuperClusterTrackAtVtx()) > 0.00311)
441  return false;
442  if (electron.isEE() && std::abs(electron.deltaEtaSuperClusterTrackAtVtx()) > 0.00609)
443  return false;
444  if (electron.isEB() && std::abs(electron.deltaPhiSuperClusterTrackAtVtx()) > 0.103)
445  return false;
446  if (electron.isEE() && std::abs(electron.deltaPhiSuperClusterTrackAtVtx()) > 0.045)
447  return false;
448  if (electron.isEB() && electron.scSigmaIEtaIEta() > 0.00998)
449  return false;
450  if (electron.isEE() && electron.scSigmaIEtaIEta() > 0.0298)
451  return false;
452  if (electron.isEB() && electron.hadronicOverEm() > 0.253)
453  return false;
454  if (electron.isEE() && electron.hadronicOverEm() > 0.0878)
455  return false;
456  return true;
457 }
458 
459 bool L1TEGammaOffline::matchesAnHLTObject(double eta, double phi) const{
460  // get HLT objects of fired triggers
461  using namespace dqmoffline::l1t;
463  std::vector<unsigned int> firedTriggers = getFiredTriggerIndices(triggerIndices_, results);
464  std::vector<edm::InputTag> hltFilters = getHLTFilters(firedTriggers, hltConfig_, triggerProcess_);
465  const trigger::TriggerObjectCollection hltObjects = getTriggerObjects(hltFilters, triggerEvent_);
466  const trigger::TriggerObjectCollection matchedObjects = getMatchedTriggerObjects(eta, phi, maxDeltaRForHLTMatching_, hltObjects);
467 
468  return !matchedObjects.empty();
469 }
470 
471 void L1TEGammaOffline::fillPhotons(edm::Event const& e, const unsigned int nVertex)
472 {
473  // TODO - just an example here
476 
478  e.getByToken(thePhotonCollection_, photons);
479 
480  if (!photons.isValid()) {
481  edm::LogWarning("L1TEGammaOffline") << "invalid collection: reco::Photons " << std::endl;
482  return;
483  }
484  if (!l1EGamma.isValid()) {
485  edm::LogWarning("L1TEGammaOffline") << "invalid collection: L1 EGamma " << std::endl;
486  return;
487  }
488 
489  if(photons->empty()){
490  LogDebug("L1TEGammaOffline") << "No photons found in event." << std::endl;
491  return;
492  }
493 
494  auto probePhoton = photons->at(0);
495 
496  double minDeltaR = 0.3;
497  l1t::EGamma closestL1EGamma;
498  bool foundMatch = false;
499 
500  int bunchCrossing = 0;
501  for (auto egamma = l1EGamma->begin(bunchCrossing); egamma != l1EGamma->end(bunchCrossing); ++egamma) {
502  double currentDeltaR = deltaR(egamma->eta(), egamma->phi(), probePhoton.eta(), probePhoton.phi());
503  if (currentDeltaR > minDeltaR) {
504  continue;
505  } else {
506  minDeltaR = currentDeltaR;
507  closestL1EGamma = *egamma;
508  foundMatch = true;
509  }
510 
511  }
512 
513  if (!foundMatch) {
514  LogDebug("L1TEGammaOffline") << "Could not find a matching L1 EGamma " << std::endl;
515  return;
516  }
517 
518  double recoEt = probePhoton.et();
519  double recoEta = probePhoton.eta();
520  double recoPhi = probePhoton.phi();
521 
522  double l1Et = closestL1EGamma.et();
523  double l1Eta = closestL1EGamma.eta();
524  double l1Phi = closestL1EGamma.phi();
525 
526  // if no reco value, relative resolution does not make sense -> sort to overflow
527  double outOfBounds = 9999;
528  double resolutionEt = recoEt > 0 ? (l1Et - recoEt) / recoEt : outOfBounds;
529  double resolutionEta = l1Eta - recoEta;
530  double resolutionPhi = reco::deltaPhi(l1Phi, recoPhi);
531 
532  using namespace dqmoffline::l1t;
533  // eta
536 
537  if (std::abs(recoEta) <= 1.479) { // barrel
538  // et
541  //resolution
544  // phi
547  // resolution
550 
551  // turn-ons
555  if (l1Et > threshold) {
558  }
559  }
560  } else { // end-cap
561  // et
564  //resolution
567  // phi
570  // resolution
573 
574  // turn-ons
578  if (l1Et > threshold) {
581  }
582  }
583  }
584 }
585 
586 //
587 // -------------------------------------- endRun --------------------------------------------
588 //
590 {
591  edm::LogInfo("L1TEGammaOffline") << "L1TEGammaOffline::endRun" << std::endl;
592 }
593 
594 //
595 // -------------------------------------- book histograms --------------------------------------------
596 //
598 {
599  ibooker.cd();
600  ibooker.setCurrentFolder(histFolder_);
601 
602  dqmoffline::l1t::HistDefinition nVertexDef = histDefinitions_[PlotConfig::nVertex];
603  h_nVertex_ = ibooker.book1D(
604  nVertexDef.name, nVertexDef.title, nVertexDef.nbinsX, nVertexDef.xmin, nVertexDef.xmax
605  );
606  h_tagAndProbeMass_ = ibooker.book1D("tagAndProbeMass", "Invariant mass of tag & probe pair", 100, 40, 140);
607  // electron reco vs L1
608  dqmoffline::l1t::HistDefinition templateETvsET = histDefinitions_[PlotConfig::ETvsET];
609  h_L1EGammaETvsElectronET_EB_ = ibooker.book2D("L1EGammaETvsElectronET_EB",
610  "L1 EGamma E_{T} vs GSF Electron E_{T} (EB); GSF Electron E_{T} (GeV); L1 EGamma E_{T} (GeV)",
611  templateETvsET.nbinsX, &templateETvsET.binsX[0], templateETvsET.nbinsY, &templateETvsET.binsY[0]);
612  h_L1EGammaETvsElectronET_EE_ = ibooker.book2D("L1EGammaETvsElectronET_EE",
613  "L1 EGamma E_{T} vs GSF Electron E_{T} (EE); GSF Electron E_{T} (GeV); L1 EGamma E_{T} (GeV)",
614  templateETvsET.nbinsX, &templateETvsET.binsX[0], templateETvsET.nbinsY, &templateETvsET.binsY[0]);
615  h_L1EGammaETvsElectronET_EB_EE_ = ibooker.book2D("L1EGammaETvsElectronET_EB_EE",
616  "L1 EGamma E_{T} vs GSF Electron E_{T} (EB+EE); GSF Electron E_{T} (GeV); L1 EGamma E_{T} (GeV)",
617  templateETvsET.nbinsX, &templateETvsET.binsX[0], templateETvsET.nbinsY, &templateETvsET.binsY[0]);
618 
619  dqmoffline::l1t::HistDefinition templatePHIvsPHI = histDefinitions_[PlotConfig::PHIvsPHI];
620  h_L1EGammaPhivsElectronPhi_EB_ = ibooker.book2D("L1EGammaPhivsElectronPhi_EB",
621  "#phi_{electron}^{L1} vs #phi_{electron}^{offline} (EB); #phi_{electron}^{offline}; #phi_{electron}^{L1}",
622  templatePHIvsPHI.nbinsX, templatePHIvsPHI.xmin, templatePHIvsPHI.xmax,
623  templatePHIvsPHI.nbinsY, templatePHIvsPHI.ymin, templatePHIvsPHI.ymax);
624  h_L1EGammaPhivsElectronPhi_EE_ = ibooker.book2D("L1EGammaPhivsElectronPhi_EE",
625  "#phi_{electron}^{L1} vs #phi_{electron}^{offline} (EE); #phi_{electron}^{offline}; #phi_{electron}^{L1}",
626  templatePHIvsPHI.nbinsX, templatePHIvsPHI.xmin, templatePHIvsPHI.xmax,
627  templatePHIvsPHI.nbinsY, templatePHIvsPHI.ymin, templatePHIvsPHI.ymax);
628  h_L1EGammaPhivsElectronPhi_EB_EE_ = ibooker.book2D("L1EGammaPhivsElectronPhi_EB_EE",
629  "#phi_{electron}^{L1} vs #phi_{electron}^{offline} (EB+EE); #phi_{electron}^{offline}; #phi_{electron}^{L1}",
630  templatePHIvsPHI.nbinsX, templatePHIvsPHI.xmin, templatePHIvsPHI.xmax,
631  templatePHIvsPHI.nbinsY, templatePHIvsPHI.ymin, templatePHIvsPHI.ymax);
632 
633  h_L1EGammaEtavsElectronEta_ = ibooker.book2D("L1EGammaEtavsElectronEta",
634  "L1 EGamma #eta vs GSF Electron #eta; GSF Electron #eta; L1 EGamma #eta", 100, -3, 3, 100, -3, 3);
635 
636  // electron resolutions
637  h_resolutionElectronET_EB_ = ibooker.book1D("resolutionElectronET_EB",
638  "electron ET resolution (EB); (L1 EGamma E_{T} - GSF Electron E_{T})/GSF Electron E_{T}; events", 50, -1, 1.5);
639  h_resolutionElectronET_EE_ = ibooker.book1D("resolutionElectronET_EE",
640  "electron ET resolution (EE); (L1 EGamma E_{T} - GSF Electron E_{T})/GSF Electron E_{T}; events", 50, -1, 1.5);
641  h_resolutionElectronET_EB_EE_ = ibooker.book1D("resolutionElectronET_EB_EE",
642  "electron ET resolution (EB+EE); (L1 EGamma E_{T} - GSF Electron E_{T})/GSF Electron E_{T}; events", 50, -1, 1.5);
643 
645  ibooker.book1D("resolutionElectronPhi_EB",
646  "#phi_{electron} resolution (EB); #phi_{electron}^{L1} - #phi_{electron}^{offline}; events",
647  120, -0.3, 0.3);
649  ibooker.book1D("resolutionElectronPhi_EE",
650  "electron #phi resolution (EE); #phi_{electron}^{L1} - #phi_{electron}^{offline}; events",
651  120, -0.3, 0.3);
653  ibooker.book1D("resolutionElectronPhi_EB_EE",
654  "electron #phi resolution (EB+EE); #phi_{electron}^{L1} - #phi_{electron}^{offline}; events",
655  120, -0.3, 0.3);
656 
657  h_resolutionElectronEta_ = ibooker.book1D("resolutionElectronEta",
658  "electron #eta resolution (EB); L1 EGamma #eta - GSF Electron #eta; events", 120, -0.3, 0.3);
659 
660  // electron turn-ons
662  std::vector<float> electronBins(electronEfficiencyBins_.begin(), electronEfficiencyBins_.end());
663  int nBins = electronBins.size() - 1;
664  float* electronBinArray = &(electronBins[0]);
665 
667  std::string str_threshold = std::to_string(int(threshold));
669  "efficiencyElectronET_EB_threshold_" + str_threshold + "_Num",
670  "electron efficiency (EB) (numerator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
672  "efficiencyElectronET_EE_threshold_" + str_threshold + "_Num",
673  "electron efficiency (EE) (numerator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
675  "efficiencyElectronET_EB_EE_threshold_" + str_threshold + "_Num",
676  "electron efficiency (EB+EE) (numerator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
678  "efficiencyElectronPhi_vs_Eta_threshold_" + str_threshold + "_Num",
679  "electron efficiency (numerator); GSF Electron #eta; GSF Electron #phi",
680  50, -2.5, 2.5, 32, -3.2, 3.2);
681 
683  "efficiencyElectronET_EB_threshold_" + str_threshold + "_Den",
684  "electron efficiency (EB) (denominator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
686  "efficiencyElectronET_EE_threshold_" + str_threshold + "_Den",
687  "electron efficiency (EE) (denominator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
689  "efficiencyElectronET_EB_EE_threshold_" + str_threshold + "_Den",
690  "electron efficiency (EB+EE) (denominator); GSF Electron E_{T} (GeV); events", nBins, electronBinArray);
692  "efficiencyElectronPhi_vs_Eta_threshold_" + str_threshold + "_Den",
693  "electron efficiency (denominator); GSF Electron #eta; GSF Electron #phi",
694  50, -2.5, 2.5, 32, -3.2, 3.2);
695  }
696 
698  std::string str_threshold = std::to_string(int(threshold));
700  "efficiencyElectronEta_threshold_" + str_threshold + "_Num",
701  "electron efficiency (numerator); GSF Electron #eta; events", 50, -2.5, 2.5);
703  "efficiencyElectronPhi_threshold_" + str_threshold + "_Num",
704  "electron efficiency (numerator); GSF Electron #phi; events", 32, -3.2, 3.2);
706  "efficiencyElectronNVertex_threshold_" + str_threshold + "_Num",
707  "electron efficiency (numerator); Nvtx; events", 30, 0, 60);
708 
710  "efficiencyElectronEta_threshold_" + str_threshold + "_Den",
711  "electron efficiency (denominator); GSF Electron #eta; events", 50, -2.5, 2.5);
713  "efficiencyElectronPhi_threshold_" + str_threshold + "_Den",
714  "electron efficiency (denominator); GSF Electron #phi; events", 32, -3.2, 3.2);
716  "efficiencyElectronNVertex_threshold_" + str_threshold + "_Den",
717  "electron efficiency (denominator); Nvtx; events", 30, 0, 60);
718  }
719 
720 
721  ibooker.cd();
722 }
723 
725 {
726  ibooker.cd();
727  ibooker.setCurrentFolder(histFolder_);
728 
729  dqmoffline::l1t::HistDefinition templateETvsET = histDefinitions_[PlotConfig::ETvsET];
730  h_L1EGammaETvsPhotonET_EB_ = ibooker.book2D("L1EGammaETvsPhotonET_EB",
731  "L1 EGamma E_{T} vs Photon E_{T} (EB); Photon E_{T} (GeV); L1 EGamma E_{T} (GeV)",
732  templateETvsET.nbinsX, &templateETvsET.binsX[0], templateETvsET.nbinsY, &templateETvsET.binsY[0]);
733  h_L1EGammaETvsPhotonET_EE_ = ibooker.book2D("L1EGammaETvsPhotonET_EE",
734  "L1 EGamma E_{T} vs Photon E_{T} (EE); Photon E_{T} (GeV); L1 EGamma E_{T} (GeV)",
735  templateETvsET.nbinsX, &templateETvsET.binsX[0], templateETvsET.nbinsY, &templateETvsET.binsY[0]);
736  h_L1EGammaETvsPhotonET_EB_EE_ = ibooker.book2D("L1EGammaETvsPhotonET_EB_EE",
737  "L1 EGamma E_{T} vs Photon E_{T} (EB+EE); Photon E_{T} (GeV); L1 EGamma E_{T} (GeV)",
738  templateETvsET.nbinsX, &templateETvsET.binsX[0], templateETvsET.nbinsY, &templateETvsET.binsY[0]);
739 
740  dqmoffline::l1t::HistDefinition templatePHIvsPHI = histDefinitions_[PlotConfig::PHIvsPHI];
741  h_L1EGammaPhivsPhotonPhi_EB_ = ibooker.book2D("L1EGammaPhivsPhotonPhi_EB",
742  "#phi_{photon}^{L1} vs #phi_{photon}^{offline} (EB); #phi_{photon}^{offline}; #phi_{photon}^{L1}",
743  templatePHIvsPHI.nbinsX, templatePHIvsPHI.xmin, templatePHIvsPHI.xmax,
744  templatePHIvsPHI.nbinsY, templatePHIvsPHI.ymin, templatePHIvsPHI.ymax);
745  h_L1EGammaPhivsPhotonPhi_EE_ = ibooker.book2D("L1EGammaPhivsPhotonPhi_EE",
746  "#phi_{photon}^{L1} vs #phi_{photon}^{offline} (EE); #phi_{photon}^{offline}; #phi_{photon}^{L1}",
747  templatePHIvsPHI.nbinsX, templatePHIvsPHI.xmin, templatePHIvsPHI.xmax,
748  templatePHIvsPHI.nbinsY, templatePHIvsPHI.ymin, templatePHIvsPHI.ymax);
749  h_L1EGammaPhivsPhotonPhi_EB_EE_ = ibooker.book2D("L1EGammaPhivsPhotonPhi_EB_EE",
750  "#phi_{photon}^{L1} vs #phi_{photon}^{offline} (EB+EE); #phi_{photon}^{offline}; #phi_{photon}^{L1}",
751  templatePHIvsPHI.nbinsX, templatePHIvsPHI.xmin, templatePHIvsPHI.xmax,
752  templatePHIvsPHI.nbinsY, templatePHIvsPHI.ymin, templatePHIvsPHI.ymax);
753 
754  h_L1EGammaEtavsPhotonEta_ = ibooker.book2D("L1EGammaEtavsPhotonEta",
755  "L1 EGamma #eta vs Photon #eta; Photon #eta; L1 EGamma #eta", 100, -3, 3, 100, -3, 3);
756 
757  // photon resolutions
758  h_resolutionPhotonET_EB_ = ibooker.book1D("resolutionPhotonET_EB",
759  "photon ET resolution (EB); (L1 EGamma E_{T} - Photon E_{T})/ Photon E_{T}; events", 50, -1, 1.5);
760  h_resolutionPhotonET_EE_ = ibooker.book1D("resolutionPhotonET_EE",
761  "photon ET resolution (EE); (L1 EGamma E_{T} - Photon E_{T})/ Photon E_{T}; events", 50, -1, 1.5);
762  h_resolutionPhotonET_EB_EE_ = ibooker.book1D("resolutionPhotonET_EB_EE",
763  "photon ET resolution (EB+EE); (L1 EGamma E_{T} - Photon E_{T})/ Photon E_{T}; events", 50, -1, 1.5);
764 
765  h_resolutionPhotonPhi_EB_ = ibooker.book1D("resolutionPhotonPhi_EB",
766  "#phi_{photon} resolution (EB); #phi_{photon}^{L1} - #phi_{photon}^{offline}; events",
767  120, -0.3, 0.3);
768  h_resolutionPhotonPhi_EE_ = ibooker.book1D("resolutionPhotonPhi_EE",
769  "photon #phi resolution (EE); #phi_{photon}^{L1} - #phi_{photon}^{offline}; events",
770  120, -0.3, 0.3);
771  h_resolutionPhotonPhi_EB_EE_ = ibooker.book1D("resolutionPhotonPhi_EB_EE",
772  "photon #phi resolution (EB+EE); #phi_{photon}^{L1} - #phi_{photon}^{offline}; events",
773  120, -0.3, 0.3);
774 
775  h_resolutionPhotonEta_ = ibooker.book1D("resolutionPhotonEta",
776  "photon #eta resolution (EB); L1 EGamma #eta - Photon #eta; events", 120, -0.3, 0.3);
777 
778  // photon turn-ons
780  std::vector<float> photonBins(photonEfficiencyBins_.begin(), photonEfficiencyBins_.end());
781  int nBins = photonBins.size() - 1;
782  float* photonBinArray = &(photonBins[0]);
783 
785  std::string str_threshold = std::to_string(int(threshold));
787  "efficiencyPhotonET_EB_threshold_" + str_threshold + "_Num",
788  "photon efficiency (EB) (numerator); Photon E_{T} (GeV); events", nBins, photonBinArray);
790  "efficiencyPhotonET_EE_threshold_" + str_threshold + "_Num",
791  "photon efficiency (EE) (numerator); Photon E_{T} (GeV); events", nBins, photonBinArray);
793  "efficiencyPhotonET_EB_EE_threshold_" + str_threshold + "_Num",
794  "photon efficiency (EB+EE) (numerator); Photon E_{T} (GeV); events", nBins, photonBinArray);
795 
797  "efficiencyPhotonET_EB_threshold_" + str_threshold + "_Den",
798  "photon efficiency (EB) (denominator); Photon E_{T} (GeV); events", nBins, photonBinArray);
800  "efficiencyPhotonET_EE_threshold_" + str_threshold + "_Den",
801  "photon efficiency (EE) (denominator); Photon E_{T} (GeV); events", nBins, photonBinArray);
803  "efficiencyPhotonET_EB_EE_threshold_" + str_threshold + "_Den",
804  "photon efficiency (EB+EE) (denominator); Photon E_{T} (GeV); events", nBins, photonBinArray);
805  }
806 
807  ibooker.cd();
808 }
809 
812 }
813 
815  std::vector<MonitorElement *> monElementstoNormalize = {
823  };
824 
825  for (auto mon : monElementstoNormalize) {
826  if (mon != nullptr) {
827  auto h = mon->getTH2F();
828  if (h != nullptr) {
829  h->Scale(1, "width");
830  }
831  }
832  }
833 }
834 
835 //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:245
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:579
edm::EDGetTokenT< std::vector< reco::Photon > > thePhotonCollection_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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:353
bool isEB() const
Definition: GsfElectron.h:352
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:249
void endJob() override
double maxDeltaRForHLTMatching_
float hadronicOverEm() const
Definition: GsfElectron.h:487
std::vector< double > electronEfficiencyThresholds_
MonitorElement * h_L1EGammaPhivsPhotonPhi_EB_EE_
double et() const final
transverse energy
std::map< double, MonitorElement * > h_efficiencyElectronEta_pass_
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:252
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:118
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:483
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
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
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)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
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:136
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:844
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_
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:44
bool passesAnyTriggerFromList(const std::vector< unsigned int > &triggers, const edm::TriggerResults &triggerResults)
Definition: L1TCommon.cc:69