CMS 3D CMS Logo

SUSY_HLT_SingleLepton.cc
Go to the documentation of this file.
2 
3 #include <algorithm>
4 #include <limits>
5 
9 
11 
13 
15 
19 
20 namespace {
21  bool Contains(const std::string &text, const std::string &pattern) { return text.find(pattern) != std::string::npos; }
22 
23  void SetBinLabels(MonitorElement *const me) {
24  if (!me)
25  return;
26  me->setBinLabel(1, "No CSV Reqs.");
27  me->setBinLabel(2, "N_{CSVL} >= 1");
28  me->setBinLabel(3, "N_{CSVL} >= 2");
29  me->setBinLabel(4, "N_{CSVL} >= 3");
30  me->setBinLabel(5, "N_{CSVL} >= 4");
31  me->setBinLabel(6, "N_{CSVM} >= 1");
32  me->setBinLabel(7, "N_{CSVM} >= 2");
33  me->setBinLabel(8, "N_{CSVM} >= 3");
34  me->setBinLabel(9, "N_{CSVM} >= 4");
35  me->setBinLabel(10, "N_{CSVT} >= 1");
36  me->setBinLabel(11, "N_{CSVT} >= 2");
37  me->setBinLabel(12, "N_{CSVT} >= 3");
38  me->setBinLabel(13, "N_{CSVT} >= 4");
39  }
40 
41  bool IsGood(const reco::GsfElectron &el,
42  const reco::Vertex::Point &pv_position,
43  const reco::BeamSpot::Point &bs_position,
45  const float dEtaIn = el.deltaEtaSuperClusterTrackAtVtx();
46  const float dPhiIn = el.deltaPhiSuperClusterTrackAtVtx();
47  const float sigmaietaieta = el.full5x5_sigmaIetaIeta();
48  const float hOverE = el.hcalOverEcal();
49  float d0 = 0.0, dz = 0.0;
50  try {
51  d0 = -(el.gsfTrack()->dxy(pv_position));
52  dz = el.gsfTrack()->dz(pv_position);
53  } catch (...) {
54  edm::LogError("SUSY_HLT_SingleLepton") << "Could not read electron.gsfTrack().\n";
55  return false;
56  }
57  float ooemoop = 1e30;
58  if (el.ecalEnergy() > 0.0 && std::isfinite(el.ecalEnergy())) {
59  ooemoop = fabs(1.0 / el.ecalEnergy() - el.eSuperClusterOverP() / el.ecalEnergy());
60  }
61  const auto &iso = el.pfIsolationVariables();
62  const float absiso =
63  iso.sumChargedHadronPt + std::max(0.0, iso.sumNeutralHadronEt + iso.sumPhotonEt - 0.5 * iso.sumPUPt);
64  const float relisowithdb = absiso / el.pt();
65 
66  bool pass_conversion = false;
67  if (convs.isValid()) {
68  try {
69  pass_conversion = !ConversionTools::hasMatchedConversion(el, *convs, bs_position);
70  } catch (...) {
71  edm::LogError("SUSY_HLT_SingleLepton") << "Electron conversion matching failed.\n";
72  return false;
73  }
74  }
75 
76  float etasc = 0.0;
77  try {
78  etasc = el.superCluster()->eta();
79  } catch (...) {
80  edm::LogError("SUSY_HLT_SingleLepton") << "Could not read electron.superCluster().\n";
81  return false;
82  }
83  if (fabs(etasc) > 2.5) {
84  return false;
85  } else if (fabs(etasc) > 1.479) {
86  if (fabs(dEtaIn) > 0.0106)
87  return false;
88  if (fabs(dPhiIn) > 0.0359)
89  return false;
90  if (sigmaietaieta > 0.0305)
91  return false;
92  if (hOverE > 0.0835)
93  return false;
94  if (fabs(d0) > 0.0163)
95  return false;
96  if (fabs(dz) > 0.5999)
97  return false;
98  if (fabs(ooemoop) > 0.1126)
99  return false;
100  if (relisowithdb > 0.2075)
101  return false;
102  if (!pass_conversion)
103  return false;
104  } else {
105  if (fabs(dEtaIn) > 0.0091)
106  return false;
107  if (fabs(dPhiIn) > 0.031)
108  return false;
109  if (sigmaietaieta > 0.0106)
110  return false;
111  if (hOverE > 0.0532)
112  return false;
113  if (fabs(d0) > 0.0126)
114  return false;
115  if (fabs(dz) > 0.0116)
116  return false;
117  if (fabs(ooemoop) > 0.0609)
118  return false;
119  if (relisowithdb > 0.1649)
120  return false;
121  if (!pass_conversion)
122  return false;
123  }
124  return true;
125  }
126 
127  bool IsGood(const reco::Muon &mu, const reco::Vertex::Point &pv_position) {
128  if (!mu.isGlobalMuon())
129  return false;
130  if (!mu.isPFMuon())
131  return false;
132  try {
133  if (mu.globalTrack()->normalizedChi2() >= 10.)
134  return false;
135  if (mu.globalTrack()->hitPattern().numberOfValidMuonHits() <= 0)
136  return false;
137  } catch (...) {
138  edm::LogWarning("SUSY_HLT_SingleLepton") << "Could not read muon.globalTrack().\n";
139  return false;
140  }
141  if (mu.numberOfMatchedStations() <= 1)
142  return false;
143  try {
144  if (fabs(mu.muonBestTrack()->dxy(pv_position)) >= 0.2)
145  return false;
146  if (fabs(mu.muonBestTrack()->dz(pv_position)) >= 0.5)
147  return false;
148  } catch (...) {
149  edm::LogWarning("SUSY_HLT_SingleLepton") << "Could not read muon.muonBestTrack().\n";
150  return false;
151  }
152  try {
153  if (mu.innerTrack()->hitPattern().numberOfValidPixelHits() <= 0)
154  return false;
155  if (mu.innerTrack()->hitPattern().trackerLayersWithMeasurement() <= 5)
156  return false;
157  } catch (...) {
158  edm::LogWarning("SUSY_HLT_SingleLepton") << "Could not read muon.innerTrack().\n";
159  return false;
160  }
161  return true;
162  }
163 } // namespace
164 
166  : theElectronTag_(ps.getParameter<edm::InputTag>("electronCollection")),
167  theElectronCollection_(consumes<reco::GsfElectronCollection>(theElectronTag_)),
168  theMuonTag_(ps.getParameter<edm::InputTag>("muonCollection")),
169  theMuonCollection_(consumes<reco::MuonCollection>(theMuonTag_)),
170  thePfMETTag_(ps.getParameter<edm::InputTag>("pfMetCollection")),
171  thePfMETCollection_(consumes<reco::PFMETCollection>(thePfMETTag_)),
172  thePfJetTag_(ps.getParameter<edm::InputTag>("pfJetCollection")),
173  thePfJetCollection_(consumes<reco::PFJetCollection>(thePfJetTag_)),
174  theJetTagTag_(ps.getParameter<edm::InputTag>("jetTagCollection")),
175  theJetTagCollection_(consumes<reco::JetTagCollection>(theJetTagTag_)),
176 
177  theVertexCollectionTag_(ps.getParameter<edm::InputTag>("vertexCollection")),
178  theVertexCollection_(consumes<reco::VertexCollection>(theVertexCollectionTag_)),
179  theConversionCollectionTag_(ps.getParameter<edm::InputTag>("conversionCollection")),
180  theConversionCollection_(consumes<reco::ConversionCollection>(theConversionCollectionTag_)),
181  theBeamSpotTag_(ps.getParameter<edm::InputTag>("beamSpot")),
182  theBeamSpot_(consumes<reco::BeamSpot>(theBeamSpotTag_)),
183 
184  theLeptonFilterTag_(ps.getParameter<edm::InputTag>("leptonFilter")),
185  theHLTHTTag_(ps.getParameter<edm::InputTag>("hltHt")),
186  theHLTHT_(consumes<reco::METCollection>(theHLTHTTag_)),
187  theHLTMETTag_(ps.getParameter<edm::InputTag>("hltMet")),
188  theHLTMET_(consumes<reco::METCollection>(theHLTMETTag_)),
189  theHLTJetCollectionTag_(ps.getParameter<edm::InputTag>("hltJets")),
190  theHLTJetCollection_(consumes<reco::CaloJetCollection>(theHLTJetCollectionTag_)),
191  theHLTJetTagCollectionTag_(ps.getParameter<edm::InputTag>("hltJetTags")),
192  theHLTJetTagCollection_(consumes<reco::JetTagCollection>(theHLTJetTagCollectionTag_)),
193 
194  theTriggerResultsTag_(ps.getParameter<edm::InputTag>("triggerResults")),
195  theTriggerResults_(consumes<edm::TriggerResults>(theTriggerResultsTag_)),
196  theTrigSummaryTag_(ps.getParameter<edm::InputTag>("trigSummary")),
197  theTrigSummary_(consumes<trigger::TriggerEvent>(theTrigSummaryTag_)),
198 
199  fHltConfig_(),
200 
201  HLTProcess_(ps.getParameter<std::string>("hltProcess")),
202 
203  triggerPath_(ps.getParameter<std::string>("triggerPath")),
204  triggerPathAuxiliary_(ps.getParameter<std::string>("triggerPathAuxiliary")),
205  triggerPathLeptonAuxiliary_(ps.getParameter<std::string>("triggerPathLeptonAuxiliary")),
206 
207  csvlCut_(ps.getUntrackedParameter<double>("csvlCut")),
208  csvmCut_(ps.getUntrackedParameter<double>("csvmCut")),
209  csvtCut_(ps.getUntrackedParameter<double>("csvtCut")),
210 
211  jetPtCut_(ps.getUntrackedParameter<double>("jetPtCut")),
212  jetEtaCut_(ps.getUntrackedParameter<double>("jetEtaCut")),
213  metCut_(ps.getUntrackedParameter<double>("metCut")),
214  htCut_(ps.getUntrackedParameter<double>("htCut")),
215 
216  lep_pt_threshold_(ps.getUntrackedParameter<double>("leptonPtThreshold")),
217  ht_threshold_(ps.getUntrackedParameter<double>("htThreshold")),
218  met_threshold_(ps.getUntrackedParameter<double>("metThreshold")),
219  csv_threshold_(ps.getUntrackedParameter<double>("csvThreshold")),
220 
221  h_triggerLepPt_(nullptr),
222  h_triggerLepEta_(nullptr),
223  h_triggerLepPhi_(nullptr),
224  h_HT_(nullptr),
225  h_MET_(nullptr),
226  h_maxCSV_(nullptr),
227  h_leptonTurnOn_num_(nullptr),
228  h_leptonTurnOn_den_(nullptr),
229  h_pfHTTurnOn_num_(nullptr),
230  h_pfHTTurnOn_den_(nullptr),
231  h_pfMetTurnOn_num_(nullptr),
232  h_pfMetTurnOn_den_(nullptr),
233  h_CSVTurnOn_num_(nullptr),
234  h_CSVTurnOn_den_(nullptr),
235  h_btagTurnOn_num_(nullptr),
236  h_btagTurnOn_den_(nullptr) {
237  edm::LogInfo("SUSY_HLT_SingleLepton") << "Constructor SUSY_HLT_SingleLepton::SUSY_HLT_SingleLepton\n";
238 }
239 
241  edm::LogInfo("SUSY_HLT_SingleLepton") << "Destructor SUSY_HLT_SingleLepton::~SUSY_HLT_SingleLepton\n";
242 }
243 
245  bool changed;
246 
247  if (!fHltConfig_.init(run, e, HLTProcess_, changed)) {
248  edm::LogError("SUSY_HLT_SingleLepton") << "Initialization of HLTConfigProvider failed!!\n";
249  return;
250  }
251 
252  bool pathFound = false;
253  for (const auto &trig_name : fHltConfig_.triggerNames()) {
254  if (Contains(trig_name, triggerPath_))
255  pathFound = true;
256  }
257 
258  if (!pathFound) {
259  LogDebug("SUSY_HLT_SingleLepton") << "Path not found: " << triggerPath_ << '\n';
260  return;
261  }
262 
263  edm::LogInfo("SUSY_HLT_SingleLepton") << "SUSY_HLT_SingleLepton::beginRun\n";
264 }
265 
267  edm::LogInfo("SUSY_HLT_SingleLepton") << "SUSY_HLT_SingleLepton::bookHistograms\n";
268  // book at beginRun
269  ibooker.cd();
270  ibooker.setCurrentFolder("HLT/SUSYBSM/" + triggerPath_);
271 
272  bool is_mu = false;
273  bool is_ele = false;
274  if (theElectronTag_.label().empty() && !theMuonTag_.label().empty()) {
275  is_mu = true;
276  } else if (!theElectronTag_.label().empty() && theMuonTag_.label().empty()) {
277  is_ele = true;
278  }
279  std::string lepton = "lepton", Lepton = "Lepton";
280  if (is_mu && !is_ele) {
281  lepton = "muon";
282  Lepton = "Muon";
283  } else if (is_ele && !is_mu) {
284  lepton = "electron";
285  Lepton = "Electron";
286  }
287 
288  // online quantities
289  h_triggerLepPt_ = ibooker.book1D("triggerLepPt", (";" + Lepton + " p_{T} [GeV];").c_str(), 20, 0.0, 500.0);
290  h_triggerLepEta_ = ibooker.book1D("triggerLepEta", (";" + Lepton + " #eta;").c_str(), 20, -3.0, 3.0);
291  h_triggerLepPhi_ = ibooker.book1D("triggerLepPhi", (";" + Lepton + " #phi;").c_str(), 20, -3.5, 3.5);
292 
293  if (!theHLTHTTag_.label().empty()) {
294  h_HT_ = ibooker.book1D("HT", ";HLT HT [GeV];", 40, 0.0, 1000.0);
295  }
296 
297  if (!theHLTMETTag_.label().empty()) {
298  h_MET_ = ibooker.book1D("MET", ";HLT MET [GeV];", 40, 0.0, 1000.0);
299  }
300 
301  if (!theHLTJetCollectionTag_.label().empty() && !theHLTJetTagCollectionTag_.label().empty()) {
302  h_maxCSV_ = ibooker.book1D("maxCSV", ";Max HLT CSV;", 20, 0.0, 1.0);
303  }
304 
305  // num and den hists to be divided in harvesting step to make turn on curves
307  ibooker.book1D("leptonTurnOn_num", ("Numerator;Offline " + lepton + " p_{T} [GeV];").c_str(), 30, 0.0, 150);
309  ibooker.book1D("leptonTurnOn_den", ("Denominator;Offline " + lepton + " p_{T} [GeV];").c_str(), 30, 0.0, 150.0);
310  h_pfHTTurnOn_num_ = ibooker.book1D("pfHTTurnOn_num", "Numerator;Offline H_{T} [GeV];", 30, 0.0, 1500.0);
311  h_pfHTTurnOn_den_ = ibooker.book1D("pfHTTurnOn_den", "Denominator;Offline H_{T} [GeV];", 30, 0.0, 1500.0);
312 
313  if (!theHLTMETTag_.label().empty()) {
314  h_pfMetTurnOn_num_ = ibooker.book1D("pfMetTurnOn_num", "Numerator;Offline MET [GeV];", 20, 0.0, 500.0);
315  h_pfMetTurnOn_den_ = ibooker.book1D("pfMetTurnOn_den", "Denominator;Offline MET [GeV];", 20, 0.0, 500.0);
316  }
317 
318  if (!theHLTJetCollectionTag_.label().empty() && !theHLTJetTagCollectionTag_.label().empty()) {
319  h_CSVTurnOn_num_ = ibooker.book1D("CSVTurnOn_num", "Numerator;Offline Max CSV Discriminant;", 20, 0.0, 1.0);
320  h_CSVTurnOn_den_ = ibooker.book1D("CSVTurnOn_den", "Denominator;Offline Max CSV Discriminant;", 20, 0.0, 1.0);
321 
322  h_btagTurnOn_num_ = ibooker.book1D("btagTurnOn_num", "Numerator;Offline CSV Requirement;", 13, -0.5, 12.5);
323  h_btagTurnOn_den_ = ibooker.book1D("btagTurnOn_den", "Denominator;Offline CSV Requirements;", 13, -0.5, 12.5);
324 
325  SetBinLabels(h_btagTurnOn_num_);
326  SetBinLabels(h_btagTurnOn_den_);
327  }
328  ibooker.cd();
329 }
330 
332  edm::LogInfo("SUSY_HLT_SingleLepton") << "SUSY_HLT_SingleLepton::analyze\n";
333 
334  // HLT HT
336  if (!theHLTHTTag_.label().empty()) {
337  e.getByToken(theHLTHT_, HLTHT);
338  if (!HLTHT.isValid()) {
339  edm::LogInfo("SUSY_HLT_SingleLepton") << "Invalid METCollection: " << theHLTHTTag_.label() << '\n';
340  }
341  }
342 
343  // HLT MET
345  if (!theHLTMETTag_.label().empty()) {
346  e.getByToken(theHLTMET_, HLTMET);
347  if (!HLTMET.isValid()) {
348  edm::LogInfo("SUSY_HLT_SingleLepton") << "Invalid METCollection: " << theHLTMETTag_.label() << '\n';
349  }
350  }
351 
352  // HLT Jets
353  edm::Handle<reco::CaloJetCollection> HLTJetCollection;
354  if (!theHLTJetCollectionTag_.label().empty()) {
355  e.getByToken(theHLTJetCollection_, HLTJetCollection);
356  if (!HLTJetCollection.isValid()) {
357  edm::LogInfo("SUSY_HLT_SingleLepton") << "Invalid CaloJetCollection: " << theHLTJetCollectionTag_.label() << '\n';
358  }
359  }
360 
361  // HLT Jet Tags
362  edm::Handle<reco::JetTagCollection> HLTJetTagCollection;
363  if (!theHLTJetTagCollectionTag_.label().empty()) {
364  e.getByToken(theHLTJetTagCollection_, HLTJetTagCollection);
365  if (!HLTJetTagCollection.isValid()) {
366  edm::LogInfo("SUSY_HLT_SingleLepton")
367  << "Invalid JetTagCollection: " << theHLTJetTagCollectionTag_.label() << '\n';
368  }
369  }
370 
371  // Vertex
373  if (!theVertexCollectionTag_.label().empty()) {
374  e.getByToken(theVertexCollection_, VertexCollection);
375  if (!VertexCollection.isValid()) {
376  edm::LogWarning("SUSY_HLT_SingleLepton")
377  << "Invalid VertexCollection: " << theVertexCollectionTag_.label() << '\n';
378  }
379  }
380 
381  // Conversions
383  if (!theConversionCollectionTag_.label().empty()) {
384  e.getByToken(theConversionCollection_, ConversionCollection);
385  if (!ConversionCollection.isValid()) {
386  edm::LogWarning("SUSY_HLT_SingleLepton")
387  << "Invalid ConversionCollection: " << theConversionCollectionTag_.label() << '\n';
388  }
389  }
390 
391  // Beam Spot
393  if (!theBeamSpotTag_.label().empty()) {
394  e.getByToken(theBeamSpot_, BeamSpot);
395  if (!BeamSpot.isValid()) {
396  edm::LogWarning("SUSY_HLT_SingleLepton") << "Invalid BeamSpot: " << theBeamSpotTag_.label() << '\n';
397  }
398  }
399 
400  // MET
401  edm::Handle<reco::PFMETCollection> pfMETCollection;
402  if (!thePfMETTag_.label().empty()) {
403  e.getByToken(thePfMETCollection_, pfMETCollection);
404  if (!pfMETCollection.isValid()) {
405  edm::LogWarning("SUSY_HLT_SingleLepton") << "Invalid PFMETCollection: " << thePfMETTag_.label() << '\n';
406  }
407  }
408 
409  // Jets
410  edm::Handle<reco::PFJetCollection> pfJetCollection;
411  if (!thePfJetTag_.label().empty()) {
412  e.getByToken(thePfJetCollection_, pfJetCollection);
413  if (!pfJetCollection.isValid()) {
414  edm::LogWarning("SUSY_HLT_SingleLepton") << "Invalid PFJetCollection: " << thePfJetTag_.label() << '\n';
415  }
416  }
417 
418  // b-tags
419  edm::Handle<reco::JetTagCollection> jetTagCollection;
420  if (!theJetTagTag_.label().empty()) {
421  e.getByToken(theJetTagCollection_, jetTagCollection);
422  if (!jetTagCollection.isValid()) {
423  edm::LogWarning("SUSY_HLT_SingleLepton") << "Invalid JetTagCollection: " << theJetTagTag_.label() << '\n';
424  }
425  }
426 
427  // Electron
429  if (!theElectronTag_.label().empty()) {
430  e.getByToken(theElectronCollection_, ElectronCollection);
431  if (!ElectronCollection.isValid()) {
432  edm::LogWarning("SUSY_HLT_SingleLepton") << "Invalid GsfElectronCollection: " << theElectronTag_.label() << '\n';
433  }
434  }
435 
436  // Muon
438  if (!theMuonTag_.label().empty()) {
439  e.getByToken(theMuonCollection_, MuonCollection);
440  if (!MuonCollection.isValid()) {
441  edm::LogWarning("SUSY_HLT_SingleLepton") << "Invalid MuonCollection: " << theMuonTag_.label() << '\n';
442  }
443  }
444 
445  // Trigger
447  if (!theTriggerResultsTag_.label().empty()) {
448  e.getByToken(theTriggerResults_, hltresults);
449  if (!hltresults.isValid()) {
450  edm::LogWarning("SUSY_HLT_SingleLepton") << "Invalid TriggerResults: " << theTriggerResultsTag_.label() << '\n';
451  }
452  }
453  edm::Handle<trigger::TriggerEvent> triggerSummary;
454  if (!theTrigSummaryTag_.label().empty()) {
455  e.getByToken(theTrigSummary_, triggerSummary);
456  if (!triggerSummary.isValid()) {
457  edm::LogWarning("SUSY_HLT_SingleLepton") << "Invalid TriggerEvent: " << theTrigSummaryTag_.label() << '\n';
458  }
459  }
460 
461  // Get online leptons
462  std::vector<float> ptLepton, etaLepton, phiLepton;
463  if (triggerSummary.isValid()) {
464  // Leptons
465  size_t filterIndex = triggerSummary->filterIndex(theLeptonFilterTag_);
467  if (!(filterIndex >= triggerSummary->sizeFilters())) {
468  size_t ilep = 0, num_keys = triggerSummary->filterKeys(filterIndex).size();
469  ptLepton.resize(num_keys);
470  etaLepton.resize(num_keys);
471  phiLepton.resize(num_keys);
472  for (const auto &key : triggerSummary->filterKeys(filterIndex)) {
473  const trigger::TriggerObject &foundObject = triggerObjects[key];
474 
475  if (h_triggerLepPt_)
476  h_triggerLepPt_->Fill(foundObject.pt());
477  if (h_triggerLepEta_)
478  h_triggerLepEta_->Fill(foundObject.eta());
479  if (h_triggerLepPhi_)
480  h_triggerLepPhi_->Fill(foundObject.phi());
481 
482  ptLepton.at(ilep) = foundObject.pt();
483  etaLepton.at(ilep) = foundObject.eta();
484  phiLepton.at(ilep) = foundObject.phi();
485  ++ilep;
486  }
487  }
488  }
489 
490  // Get online ht and met
491  const float hlt_ht = ((HLTHT.isValid() && !HLTHT->empty()) ? HLTHT->front().sumEt() : -1.0);
492  if (h_HT_)
493  h_HT_->Fill(hlt_ht);
494  const float hlt_met = ((HLTMET.isValid() && !HLTMET->empty()) ? HLTMET->front().pt() : -1.0);
495  if (h_MET_)
496  h_MET_->Fill(hlt_met);
497 
498  // Get online csv and fill plot
499  float hlt_csv = -1.0;
500  if (HLTJetCollection.isValid() && HLTJetTagCollection.isValid()) {
501  for (const auto &jet : *HLTJetTagCollection) {
502  if (jet.second > hlt_csv)
503  hlt_csv = jet.second;
504  }
505  }
506  if (h_maxCSV_)
507  h_maxCSV_->Fill(hlt_csv);
508 
509  // Test whether main and auxilliary triggers fired
510  bool hasFired = false;
511  bool hasFiredAuxiliary = false;
512  bool hasFiredLeptonAuxiliary = false;
513  if (hltresults.isValid()) {
514  const edm::TriggerNames &trigNames = e.triggerNames(*hltresults);
515  for (unsigned int hltIndex = 0; hltIndex < trigNames.size(); ++hltIndex) {
516  if (hltresults->wasrun(hltIndex) && hltresults->accept(hltIndex)) {
517  const std::string &name = trigNames.triggerName(hltIndex);
518  if (Contains(name, triggerPath_))
519  hasFired = true;
520  if (Contains(name, triggerPathAuxiliary_))
521  hasFiredAuxiliary = true;
522  if (Contains(name, triggerPathLeptonAuxiliary_))
523  hasFiredLeptonAuxiliary = true;
524  }
525  }
526  }
527 
528  // Get offline HT
529  double pfHT = -1.0;
530  if (pfJetCollection.isValid()) {
531  pfHT = 0.0;
532  for (const auto &pfjet : *pfJetCollection) {
533  if (pfjet.pt() < jetPtCut_)
534  continue;
535  if (fabs(pfjet.eta()) > jetEtaCut_)
536  continue;
537  pfHT += pfjet.pt();
538  }
539  }
540 
541  // Get offline MET
542  double pfMET = -1.0;
543  if (pfMETCollection.isValid() && !pfMETCollection->empty()) {
544  pfMET = pfMETCollection->front().et();
545  }
546 
547  // Get offline b-tagging info
548  float maxCSV = -1.0;
549  unsigned num_csvl = 0;
550  unsigned num_csvm = 0;
551  unsigned num_csvt = 0;
552  if (jetTagCollection.isValid()) {
553  for (const auto &jet : *jetTagCollection) {
554  const float CSV = jet.second;
555  if (jet.first->pt() > jetPtCut_) {
556  if (CSV > maxCSV) {
557  maxCSV = CSV;
558  }
559  if (CSV > csvlCut_) {
560  ++num_csvl;
561  if (CSV > csvmCut_) {
562  ++num_csvm;
563  if (CSV > csvtCut_) {
564  ++num_csvt;
565  }
566  }
567  }
568  }
569  }
570  }
571  if (h_maxCSV_)
572  h_maxCSV_->Fill(maxCSV);
573 
574  // Fill lepton pt efficiency plot
575  double lep_max_pt = -1.0;
576  if (VertexCollection.isValid() && !VertexCollection->empty()) { // for quality checks
577  // Try to find a reco electron
578  if (ElectronCollection.isValid() && ConversionCollection.isValid() && BeamSpot.isValid()) {
579  for (const auto &electron : *ElectronCollection) {
580  if (IsGood(electron, VertexCollection->front().position(), BeamSpot->position(), ConversionCollection)) {
581  if (electron.pt() > lep_max_pt)
582  lep_max_pt = electron.pt();
583  }
584  }
585  }
586 
587  // Try to find a reco muon
588  if (MuonCollection.isValid()) {
589  for (const auto &muon : *MuonCollection) {
590  if (IsGood(muon, VertexCollection->front().position())) {
591  if (muon.pt() > lep_max_pt) {
592  lep_max_pt = muon.pt();
593  }
594  }
595  }
596  }
597  }
598 
599  const bool lep_plateau = lep_max_pt > lep_pt_threshold_ || lep_pt_threshold_ < 0.0;
600  const bool ht_plateau = pfHT > ht_threshold_ || ht_threshold_ < 0.0;
601  const bool met_plateau = pfMET > met_threshold_ || met_threshold_ < 0.0;
602  const bool csv_plateau = maxCSV > csv_threshold_ || csv_threshold_ < 0.0;
603 
604  // Fill lepton turn-on histograms
605  if (hasFiredLeptonAuxiliary || triggerPathLeptonAuxiliary_.empty() || !e.isRealData()) {
606  // Fill histograms using highest pt reco lepton
607  if (ht_plateau && met_plateau && csv_plateau && (pfMET > metCut_ || metCut_ < 0.0) &&
608  (pfHT > htCut_ || htCut_ < 0.0)) {
610  h_leptonTurnOn_den_->Fill(lep_max_pt);
611  if (h_leptonTurnOn_num_ && hasFired)
612  h_leptonTurnOn_num_->Fill(lep_max_pt);
613  }
614  }
615 
616  // Fill remaining turn-on histograms
617  if (hasFiredAuxiliary || triggerPathAuxiliary_.empty() || !e.isRealData()) {
618  // Fill HT efficiency plot
619  if (lep_plateau && met_plateau && csv_plateau) {
620  if (h_pfHTTurnOn_den_)
621  h_pfHTTurnOn_den_->Fill(pfHT);
622  if (h_pfHTTurnOn_num_ && hasFired)
623  h_pfHTTurnOn_num_->Fill(pfHT);
624  }
625 
626  // Fill MET efficiency plot
627  if (lep_plateau && ht_plateau && csv_plateau) {
628  if (h_pfMetTurnOn_den_)
629  h_pfMetTurnOn_den_->Fill(pfMET);
630  if (h_pfMetTurnOn_num_ && hasFired)
631  h_pfMetTurnOn_num_->Fill(pfMET);
632  }
633 
634  // Fill CSV efficiency plot
635  if (lep_plateau && ht_plateau && met_plateau) {
636  if (h_CSVTurnOn_den_)
637  h_CSVTurnOn_den_->Fill(maxCSV);
638  if (h_CSVTurnOn_num_ && hasFired)
639  h_CSVTurnOn_num_->Fill(maxCSV);
640 
641  if (h_btagTurnOn_den_) {
642  switch (num_csvl) {
643  default:
645  case 3:
647  case 2:
649  case 1:
651  case 0:
653  }
654  switch (num_csvm) {
655  default:
657  case 3:
659  case 2:
661  case 1:
663  case 0:
664  break; // Don't double count in the no tag bin
665  }
666  switch (num_csvt) {
667  default:
668  h_btagTurnOn_den_->Fill(12);
669  case 3:
670  h_btagTurnOn_den_->Fill(11);
671  case 2:
672  h_btagTurnOn_den_->Fill(10);
673  case 1:
675  case 0:
676  break; // Don't double count in the no tag bin
677  }
678  }
679  if (h_btagTurnOn_num_ && hasFired) {
680  switch (num_csvl) {
681  default:
683  case 3:
685  case 2:
687  case 1:
689  case 0:
691  }
692  switch (num_csvm) {
693  default:
695  case 3:
697  case 2:
699  case 1:
701  case 0:
702  break; // Don't double count in the no tag bin
703  }
704  switch (num_csvt) {
705  default:
706  h_btagTurnOn_num_->Fill(12);
707  case 3:
708  h_btagTurnOn_num_->Fill(11);
709  case 2:
710  h_btagTurnOn_num_->Fill(10);
711  case 1:
713  case 0:
714  break; // Don't double count in the no tag bin
715  }
716  }
717  }
718  }
719 }
720 
722  edm::LogInfo("SUSY_HLT_SingleLepton") << "SUSY_HLT_SingleLepton::endRun\n";
723 }
724 
725 // define this as a plug-in
#define LogDebug(id)
const PflowIsolationVariables & pfIsolationVariables() const
Definition: GsfElectron.h:687
GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Definition: GsfElectron.h:186
bool wasrun() const
Was at least one path run?
edm::EDGetTokenT< edm::TriggerResults > theTriggerResults_
edm::InputTag theConversionCollectionTag_
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:135
float eSuperClusterOverP() const
Definition: GsfElectron.h:249
void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &, const edm::EventSetup &) override
virtual TrackRef innerTrack() const
Definition: Muon.h:48
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
float phi() const
Definition: TriggerObject.h:58
edm::EDGetTokenT< reco::MuonCollection > theMuonCollection_
edm::EDGetTokenT< reco::METCollection > theHLTMET_
edm::InputTag theTriggerResultsTag_
bool accept() const
Has at least one path accepted the event?
void dqmBeginRun(const edm::Run &run, const edm::EventSetup &e) override
const std::vector< std::string > & triggerNames() const
names of trigger paths
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
#define nullptr
void endRun(const edm::Run &run, const edm::EventSetup &eSetup) override
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:123
HLTConfigProvider fHltConfig_
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)
MonitorElement * h_triggerLepPt_
double pt() const final
transverse momentum
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
MonitorElement * h_pfMetTurnOn_den_
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:29
void analyze(const edm::Event &e, const edm::EventSetup &eSetup) override
MonitorElement * h_leptonTurnOn_num_
MonitorElement * h_CSVTurnOn_num_
Strings::size_type size() const
Definition: TriggerNames.cc:31
MonitorElement * h_pfHTTurnOn_num_
float eta() const
Definition: TriggerObject.h:57
JetFloatAssociation::Container JetTagCollection
Definition: JetTag.h:18
edm::EDGetTokenT< reco::JetTagCollection > theJetTagCollection_
MonitorElement * h_CSVTurnOn_den_
bool isRealData() const
Definition: EventBase.h:62
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
edm::EDGetTokenT< reco::CaloJetCollection > theHLTJetCollection_
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
Definition: ConversionFwd.h:9
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
void Fill(long long x)
float full5x5_sigmaIetaIeta() const
Definition: GsfElectron.h:462
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:22
edm::EDGetTokenT< reco::GsfElectronCollection > theElectronCollection_
float deltaEtaSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:253
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
virtual TrackRef muonBestTrack() const
Definition: Muon.h:63
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
bool isGlobalMuon() const override
Definition: Muon.h:291
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
edm::EDGetTokenT< reco::ConversionCollection > theConversionCollection_
MonitorElement * h_btagTurnOn_den_
static bool hasMatchedConversion(const reco::GsfElectron &ele, const reco::ConversionCollection &convCol, const math::XYZPoint &beamspot, bool allowCkfMatch=true, float lxyMin=2.0, float probMin=1e-6, unsigned int nHitsBeforeVtxMax=0)
float deltaPhiSuperClusterTrackAtVtx() const
Definition: GsfElectron.h:256
float hcalOverEcal() const
Definition: GsfElectron.h:448
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
const int mu
Definition: Constants.h:22
MonitorElement * h_triggerLepPhi_
Collection of MET.
bool isValid() const
Definition: HandleBase.h:74
std::vector< Electron > ElectronCollection
collectin of Electron objects
Definition: ElectronFwd.h:9
edm::EDGetTokenT< reco::JetTagCollection > theHLTJetTagCollection_
edm::InputTag theHLTJetCollectionTag_
edm::EDGetTokenT< reco::BeamSpot > theBeamSpot_
int numberOfMatchedStations(ArbitrationType type=SegmentAndTrackArbitration) const
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
edm::EDGetTokenT< reco::PFJetCollection > thePfJetCollection_
static const char *const trigNames[]
Definition: EcalDumpRaw.cc:74
MonitorElement * h_pfHTTurnOn_den_
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:22
MonitorElement * h_triggerLepEta_
bool init(const edm::Run &iRun, const edm::EventSetup &iSetup, const std::string &processName, bool &changed)
d&#39;tor
MonitorElement * h_pfMetTurnOn_num_
edm::EDGetTokenT< reco::PFMETCollection > thePfMETCollection_
edm::EDGetTokenT< reco::VertexCollection > theVertexCollection_
float ecalEnergy() const
Definition: GsfElectron.h:859
std::string const & label() const
Definition: InputTag.h:36
std::vector< PFJet > PFJetCollection
collection of PFJet objects
fixed size matrix
HLT enums.
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:185
bool isPFMuon() const
Definition: Muon.h:295
MonitorElement * h_btagTurnOn_num_
const Point & position() const
position
Definition: BeamSpot.h:62
Definition: Lepton.py:1
float sumChargedHadronPt
sum-pt of charged Hadron // old float chargedHadronIso ;
Definition: GsfElectron.h:639
SUSY_HLT_SingleLepton(const edm::ParameterSet &ps)
MonitorElement * h_leptonTurnOn_den_
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:256
edm::EDGetTokenT< reco::METCollection > theHLTHT_
edm::InputTag theVertexCollectionTag_
Definition: Run.h:45
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects
edm::EDGetTokenT< trigger::TriggerEvent > theTrigSummary_
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:54
edm::InputTag theHLTJetTagCollectionTag_
Collection of PF MET.