CMS 3D CMS Logo

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