CMS 3D CMS Logo

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