CMS 3D CMS Logo

WMuNuValidator.cc
Go to the documentation of this file.
1 // //
3 // WMuNuValidator //
4 // //
6 // //
7 // Basic plots before & after cuts (without Candidate formalism) //
8 // Intended for a prompt validation of samples. //
9 // //
10 // Use in combination with WMuNuValidatorMacro (in bin/WMuNuValidatorMacro.cpp) //
11 // //
13 
14 
23 #include "TH1D.h"
24 #include <map>
25 
26 class WMuNuValidator : public edm::EDFilter {
27 public:
29  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
30  virtual void beginJob() override;
31  virtual void endJob() override;
32  void init_histograms();
33  void fill_histogram(const char*, const double&);
34 private:
45  double ptCut_;
46  double etaCut_;
49  double isoCut03_;
50  double mtMin_;
51  double mtMax_;
52  double metMin_;
53  double metMax_;
54  double acopCut_;
55 
56  double dxyCut_;
60 
61  double ptThrForZ1_;
62  double ptThrForZ2_;
63 
64  double eJetMin_;
65  int nJetMax_;
66 
67  unsigned int nall;
68  unsigned int nrec;
69  unsigned int niso;
70  unsigned int nhlt;
71  unsigned int nmet;
72  unsigned int nsel;
73 
74  std::map<std::string,TH1D*> h1_;
75 };
76 
80 
83 
86 
88 
90 
92 
93 using namespace edm;
94 using namespace std;
95 using namespace reco;
96 
98  // Fast selection (no histograms or book-keeping)
99  fastOption_(cfg.getUntrackedParameter<bool> ("FastOption", false)),
100 
101  // Input collections
102  trigToken_(consumes<TriggerResults>(cfg.getUntrackedParameter<edm::InputTag> ("TrigTag", edm::InputTag("TriggerResults::HLT")))),
103  muonToken_(consumes<View<Muon> >(cfg.getUntrackedParameter<edm::InputTag> ("MuonTag", edm::InputTag("muons")))),
104  metTag_(cfg.getUntrackedParameter<edm::InputTag> ("METTag", edm::InputTag("met"))),
106  metIncludesMuons_(cfg.getUntrackedParameter<bool> ("METIncludesMuons", false)),
107  jetTag_(cfg.getUntrackedParameter<edm::InputTag> ("JetTag", edm::InputTag("sisCone5CaloJets"))),
109  beamSpotToken_(consumes<reco::BeamSpot>(edm::InputTag("offlineBeamSpot"))),
110 
111  // Main cuts
112  muonTrig_(cfg.getUntrackedParameter<std::string> ("MuonTrig", "HLT_Mu9")),
113  ptCut_(cfg.getUntrackedParameter<double>("PtCut", 25.)),
114  etaCut_(cfg.getUntrackedParameter<double>("EtaCut", 2.1)),
115  isRelativeIso_(cfg.getUntrackedParameter<bool>("IsRelativeIso", true)),
116  isCombinedIso_(cfg.getUntrackedParameter<bool>("IsCombinedIso", false)),
117  isoCut03_(cfg.getUntrackedParameter<double>("IsoCut03", 0.1)),
118  mtMin_(cfg.getUntrackedParameter<double>("MtMin", 50.)),
119  mtMax_(cfg.getUntrackedParameter<double>("MtMax", 200.)),
120  metMin_(cfg.getUntrackedParameter<double>("MetMin", -999999.)),
121  metMax_(cfg.getUntrackedParameter<double>("MetMax", 999999.)),
122  acopCut_(cfg.getUntrackedParameter<double>("AcopCut", 2.)),
123 
124  // Muon quality cuts
125  dxyCut_(cfg.getUntrackedParameter<double>("DxyCut", 0.2)),
126  normalizedChi2Cut_(cfg.getUntrackedParameter<double>("NormalizedChi2Cut", 10.)),
127  trackerHitsCut_(cfg.getUntrackedParameter<int>("TrackerHitsCut", 11)),
128  isAlsoTrackerMuon_(cfg.getUntrackedParameter<bool>("IsAlsoTrackerMuon", true)),
129 
130  // Z rejection
131  ptThrForZ1_(cfg.getUntrackedParameter<double>("PtThrForZ1", 20.)),
132  ptThrForZ2_(cfg.getUntrackedParameter<double>("PtThrForZ2", 10.)),
133 
134  // Top rejection
135  eJetMin_(cfg.getUntrackedParameter<double>("EJetMin", 999999.)),
136  nJetMax_(cfg.getUntrackedParameter<int>("NJetMax", 999999))
137 {
138 }
139 
141  nall = 0;
142  nsel = 0;
143 
144  if (!fastOption_) {
145  nrec = 0;
146  niso = 0;
147  nhlt = 0;
148  nmet = 0;
149  init_histograms();
150  }
151 }
152 
155  TFileDirectory subDir0 = fs->mkdir("BeforeCuts");
156  TFileDirectory subDir1 = fs->mkdir("LastCut");
157  TFileDirectory* subDir[2]; subDir[0] = &subDir0; subDir[1] = &subDir1;
158 
159  char chname[256] = "";
160  char chtitle[256] = "";
161  std::string chsuffix[2] = { "_BEFORECUTS", "_LASTCUT" };
162 
163  for (int i=0; i<2; ++i) {
164  snprintf(chname, 255, "PT%s", chsuffix[i].data());
165  snprintf(chtitle, 255, "Muon transverse momentum [GeV]");
166  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle,100,0.,100.);
167 
168  snprintf(chname, 255, "ETA%s", chsuffix[i].data());
169  snprintf(chtitle, 255, "Muon pseudo-rapidity");
170  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle,50,-2.5,2.5);
171 
172  snprintf(chname, 255, "DXY%s", chsuffix[i].data());
173  snprintf(chtitle, 255, "Muon transverse distance to beam spot [cm]");
174  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle,100,-0.5,0.5);
175 
176  snprintf(chname, 255, "CHI2%s", chsuffix[i].data());
177  snprintf(chtitle, 255, "Normalized Chi2, inner track fit");
178  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle,100,0.,100.);
179 
180  snprintf(chname, 255, "NHITS%s", chsuffix[i].data());
181  snprintf(chtitle, 255, "Number of hits, inner track");
182  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle,40,-0.5,39.5);
183 
184  snprintf(chname, 255, "ValidMuonHits%s", chsuffix[i].data());
185  snprintf(chtitle, 255, "number Of Valid Muon Hits");
186  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle,40,-0.5,39.5);
187 
188  snprintf(chname, 255, "TKMU%s", chsuffix[i].data());
189  snprintf(chtitle, 255, "Tracker-muon flag (for global muons)");
190  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle,2,-0.5,1.5);
191 
192  snprintf(chname, 255, "ISO%s", chsuffix[i].data());
193  if (isRelativeIso_) {
194  if (isCombinedIso_) {
195  snprintf(chtitle, 255, "Relative (combined) isolation variable");
196  } else {
197  snprintf(chtitle, 255, "Relative (tracker) isolation variable");
198  }
199  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle, 100, 0., 1.);
200  } else {
201  if (isCombinedIso_) {
202  snprintf(chtitle, 255, "Absolute (combined) isolation variable [GeV]");
203  } else {
204  snprintf(chtitle, 255, "Absolute (tracker) isolation variable [GeV]");
205  }
206  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle, 100, 0., 20.);
207  }
208 
209  snprintf(chname, 255, "TRIG%s", chsuffix[i].data());
210  snprintf(chtitle, 255, "Trigger response (bit %s)", muonTrig_.data());
211  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle,2,-0.5,1.5);
212 
213  snprintf(chname, 255, "MT%s", chsuffix[i].data());
214  snprintf(chtitle, 255, "Transverse mass (%s) [GeV]", metTag_.label().data());
215  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle,150,0.,300.);
216 
217  snprintf(chname, 255, "MET%s", chsuffix[i].data());
218  snprintf(chtitle, 255, "Missing transverse energy (%s) [GeV]", metTag_.label().data());
219  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle,100,0.,200.);
220 
221  snprintf(chname, 255, "ACOP%s", chsuffix[i].data());
222  snprintf(chtitle, 255, "MU-MET (%s) acoplanarity", metTag_.label().data());
223  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle,50,0.,M_PI);
224 
225  snprintf(chname, 255, "NZ1%s", chsuffix[i].data());
226  snprintf(chtitle, 255, "Z rejection: number of muons above %.2f GeV", ptThrForZ1_);
227  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle, 10, -0.5, 9.5);
228 
229  snprintf(chname, 255, "NZ2%s", chsuffix[i].data());
230  snprintf(chtitle, 255, "Z rejection: number of muons above %.2f GeV", ptThrForZ2_);
231  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle, 10, -0.5, 9.5);
232 
233  snprintf(chname, 255, "NJETS%s", chsuffix[i].data());
234  snprintf(chtitle, 255, "Number of jets (%s) above %.2f GeV", jetTag_.label().data(), eJetMin_);
235  h1_[chname] = subDir[i]->make<TH1D>(chname,chtitle,10,-0.5,9.5);
236 
237  }
238 }
239 
240 void WMuNuValidator::fill_histogram(const char* name, const double& var) {
241  if (fastOption_) return;
242  h1_[name]->Fill(var);
243 }
244 
246  double all = nall;
247  double esel = nsel/all;
248  LogVerbatim("") << "\n>>>>>> W SELECTION SUMMARY BEGIN >>>>>>>>>>>>>>>";
249  LogVerbatim("") << "Total numer of events analyzed: " << nall << " [events]";
250  LogVerbatim("") << "Total numer of events selected: " << nsel << " [events]";
251  LogVerbatim("") << "Overall efficiency: " << "(" << setprecision(4) << esel*100. <<" +/- "<< setprecision(2) << sqrt(esel*(1-esel)/all)*100. << ")%";
252 
253  if (!fastOption_) {
254  double erec = nrec/all;
255  double eiso = niso/all;
256  double ehlt = nhlt/all;
257  double emet = nmet/all;
258 
259  double num = nrec;
260  double eff = erec;
261  double err = sqrt(eff*(1-eff)/all);
262  LogVerbatim("") << "Passing Pt/Eta/Quality cuts: " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%";
263 
264  num = niso;
265  eff = eiso;
266  err = sqrt(eff*(1-eff)/all);
267  double effstep = 0.;
268  double errstep = 0.;
269  if (nrec>0) effstep = eiso/erec;
270  if (nrec>0) errstep = sqrt(effstep*(1-effstep)/nrec);
271  LogVerbatim("") << "Passing isolation cuts: " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" << setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
272 
273  num = nhlt;
274  eff = ehlt;
275  err = sqrt(eff*(1-eff)/all);
276  effstep = 0.;
277  errstep = 0.;
278  if (niso>0) effstep = ehlt/eiso;
279  if (niso>0) errstep = sqrt(effstep*(1-effstep)/niso);
280  LogVerbatim("") << "Passing HLT criteria: " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" << setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
281 
282  num = nmet;
283  eff = emet;
284  err = sqrt(eff*(1-eff)/all);
285  effstep = 0.;
286  errstep = 0.;
287  if (nhlt>0) effstep = emet/ehlt;
288  if (nhlt>0) errstep = sqrt(effstep*(1-effstep)/nhlt);
289  LogVerbatim("") << "Passing MET/acoplanarity cuts: " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" << setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
290 
291  num = nsel;
292  eff = esel;
293  err = sqrt(eff*(1-eff)/all);
294  effstep = 0.;
295  errstep = 0.;
296  if (nmet>0) effstep = esel/emet;
297  if (nmet>0) errstep = sqrt(effstep*(1-effstep)/nmet);
298  LogVerbatim("") << "Passing Z/top rejection cuts: " << num << " [events], (" << setprecision(4) << eff*100. <<" +/- "<< setprecision(2) << err*100. << ")%, to previous step: (" << setprecision(4) << effstep*100. << " +/- "<< setprecision(2) << errstep*100. <<")%";
299  }
300 
301  LogVerbatim("") << ">>>>>> W SELECTION SUMMARY END >>>>>>>>>>>>>>>\n";
302 }
303 
305 
306  // Reset global event selection flags
307  bool rec_sel = false;
308  bool iso_sel = false;
309  bool hlt_sel = false;
310  bool met_sel = false;
311  bool all_sel = false;
312 
313  // Muon collection
315  if (!ev.getByToken(muonToken_, muonCollection)) {
316  LogError("") << ">>> Muon collection does not exist !!!";
317  return 0;
318  }
319  unsigned int muonCollectionSize = muonCollection->size();
320 
321  // Beam spot
322  Handle<reco::BeamSpot> beamSpotHandle;
323  if (!ev.getByToken(beamSpotToken_, beamSpotHandle)) {
324  LogTrace("") << ">>> No beam spot found !!!";
325  return false;
326  }
327 
328  // MET
329  double met_px = 0.;
330  double met_py = 0.;
332  if (!ev.getByToken(metToken_, metCollection)) {
333  LogError("") << ">>> MET collection does not exist !!!";
334  return false;
335  }
336  const MET& met = metCollection->at(0);
337  met_px = met.px();
338  met_py = met.py();
339  if (!metIncludesMuons_) {
340  for (unsigned int i=0; i<muonCollectionSize; i++) {
341  const Muon& mu = muonCollection->at(i);
342  if (!mu.isGlobalMuon()) continue;
343  met_px -= mu.px();
344  met_py -= mu.py();
345  }
346  }
347  double met_et = sqrt(met_px*met_px+met_py*met_py);
348  LogTrace("") << ">>> MET, MET_px, MET_py: " << met_et << ", " << met_px << ", " << met_py << " [GeV]";
349  fill_histogram("MET_BEFORECUTS",met_et);
350 
351  // Trigger
353  if (!ev.getByToken(trigToken_, triggerResults)) {
354  LogError("") << ">>> TRIGGER collection does not exist !!!";
355  return 0;
356  }
357  const edm::TriggerNames & triggerNames = ev.triggerNames(*triggerResults);
358  /*
359  for (unsigned int i=0; i<triggerResults->size(); i++) {
360  if (triggerResults->accept(i)) {
361  LogTrace("") << "Accept by: " << i << ", Trigger: " << triggerNames.triggerName(i);
362  }
363  }
364  */
365  bool trigger_fired = false;
366  int itrig1 = triggerNames.triggerIndex(muonTrig_);
367  if (triggerResults->accept(itrig1)) trigger_fired = true;
368  LogTrace("") << ">>> Trigger bit: " << trigger_fired << " (" << muonTrig_ << ")";
369  fill_histogram("TRIG_BEFORECUTS",trigger_fired);
370 
371  // Loop to reject/control Z->mumu is done separately
372  unsigned int nmuonsForZ1 = 0;
373  unsigned int nmuonsForZ2 = 0;
374  for (unsigned int i=0; i<muonCollectionSize; i++) {
375  const Muon& mu = muonCollection->at(i);
376  if (!mu.isGlobalMuon()) continue;
377  double pt = mu.pt();
378  if (pt>ptThrForZ1_) nmuonsForZ1++;
379  if (pt>ptThrForZ2_) nmuonsForZ2++;
380  }
381  LogTrace("") << "> Z rejection: muons above " << ptThrForZ1_ << " [GeV]: " << nmuonsForZ1;
382  LogTrace("") << "> Z rejection: muons above " << ptThrForZ2_ << " [GeV]: " << nmuonsForZ2;
383  fill_histogram("NZ1_BEFORECUTS",nmuonsForZ1);
384  fill_histogram("NZ2_BEFORECUTS",nmuonsForZ2);
385 
386  // Jet collection
387  Handle<View<Jet> > jetCollection;
388  if (!ev.getByToken(jetToken_, jetCollection)) {
389  LogError("") << ">>> JET collection does not exist !!!";
390  return 0;
391  }
392  unsigned int jetCollectionSize = jetCollection->size();
393  int njets = 0;
394  for (unsigned int i=0; i<jetCollectionSize; i++) {
395  const Jet& jet = jetCollection->at(i);
396  if (jet.et()>eJetMin_) njets++;
397  }
398  LogTrace("") << ">>> Total number of jets: " << jetCollectionSize;
399  LogTrace("") << ">>> Number of jets above " << eJetMin_ << " [GeV]: " << njets;
400  fill_histogram("NJETS_BEFORECUTS",njets);
401 
402  // Start counting, reject already events if possible (under FastOption flag)
403  nall++;
404  if (fastOption_ && !trigger_fired) return false;
405  if (fastOption_ && nmuonsForZ1>=1 && nmuonsForZ2>=2) return false;
406  if (fastOption_ && njets>nJetMax_) return false;
407 
408  // Histograms per event shouldbe done only once, so keep track of them
409  bool hlt_hist_done = false;
410  bool met_hist_done = false;
411  bool nz1_hist_done = false;
412  bool nz2_hist_done = false;
413  bool njets_hist_done = false;
414 
415  // Central W->mu nu selection criteria
416  const int NFLAGS = 13;
417  bool muon_sel[NFLAGS];
418  for (unsigned int i=0; i<muonCollectionSize; i++) {
419  for (int j=0; j<NFLAGS; ++j) {
420  muon_sel[j] = false;
421  }
422 
423  const Muon& mu = muonCollection->at(i);
424  if (!mu.isGlobalMuon()) continue;
425  if (mu.globalTrack().isNull()) continue;
426  if (mu.innerTrack().isNull()) continue;
427 
428  LogTrace("") << "> Wsel: processing muon number " << i << "...";
429  reco::TrackRef gm = mu.globalTrack();
430  //reco::TrackRef tk = mu.innerTrack();
431 
432  // Pt,eta cuts
433  double pt = mu.pt();
434  double eta = mu.eta();
435  LogTrace("") << "\t... pt, eta: " << pt << " [GeV], " << eta;;
436  if (pt>ptCut_) muon_sel[0] = true;
437  else if (fastOption_) continue;
438  if (fabs(eta)<etaCut_) muon_sel[1] = true;
439  else if (fastOption_) continue;
440 
441  // d0, chi2, nhits quality cuts
442  double dxy = gm->dxy(beamSpotHandle->position());
443  double normalizedChi2 = gm->normalizedChi2();
444  double validmuonhits=gm->hitPattern().numberOfValidMuonHits();
445  //double standalonehits=mu.outerTrack()->numberOfValidHits();
446  double trackerHits = gm->hitPattern().numberOfValidTrackerHits();
447  LogTrace("") << "\t... dxy, normalizedChi2, trackerHits, isTrackerMuon?: " << dxy << " [cm], " << normalizedChi2 << ", " << trackerHits << ", " << mu.isTrackerMuon();
448  if (fabs(dxy)<dxyCut_) muon_sel[2] = true;
449  else if (fastOption_) continue;
450  if (muon::isGoodMuon(mu,muon::GlobalMuonPromptTight)) muon_sel[3] = true;
451  else if (fastOption_) continue;
452  if (trackerHits>=trackerHitsCut_) muon_sel[4] = true;
453  else if (fastOption_) continue;
454  if (mu.isTrackerMuon()) muon_sel[5] = true;
455  else if (fastOption_) continue;
456 
457  fill_histogram("PT_BEFORECUTS",pt);
458  fill_histogram("ETA_BEFORECUTS",eta);
459  fill_histogram("DXY_BEFORECUTS",dxy);
460  fill_histogram("CHI2_BEFORECUTS",normalizedChi2);
461  fill_histogram("NHITS_BEFORECUTS",trackerHits);
462  fill_histogram("ValidMuonHits_BEFORECUTS",validmuonhits);
463  fill_histogram("TKMU_BEFORECUTS",mu.isTrackerMuon());
464 
465  // Isolation cuts
466  double isovar = mu.isolationR03().sumPt;
467  if (isCombinedIso_) {
468  isovar += mu.isolationR03().emEt;
469  isovar += mu.isolationR03().hadEt;
470  }
471  if (isRelativeIso_) isovar /= pt;
472  if (isovar<isoCut03_) muon_sel[6] = true;
473  else if (fastOption_) continue;
474  LogTrace("") << "\t... isolation value" << isovar <<", isolated? " << muon_sel[6];
475  fill_histogram("ISO_BEFORECUTS",isovar);
476 
477  // HLT (not mtched to muon for the time being)
478  if (trigger_fired) muon_sel[7] = true;
479  else if (fastOption_) continue;
480 
481  // MET/MT cuts
482  double w_et = met_et+ mu.pt();
483  double w_px = met_px+ mu.px();
484  double w_py = met_py+mu.py();
485  double massT = w_et*w_et - w_px*w_px - w_py*w_py;
486  massT = (massT>0) ? sqrt(massT) : 0;
487 
488  LogTrace("") << "\t... W mass, W_et, W_px, W_py: " << massT << ", " << w_et << ", " << w_px << ", " << w_py << " [GeV]";
489  if (massT>mtMin_ && massT<mtMax_) muon_sel[8] = true;
490  else if (fastOption_) continue;
491  fill_histogram("MT_BEFORECUTS",massT);
492  if (met_et>metMin_ && met_et<metMax_) muon_sel[9] = true;
493  else if (fastOption_) continue;
494 
495  // Acoplanarity cuts
496  Geom::Phi<double> deltaphi(mu.phi()-atan2(met_py,met_px));
497  double acop = deltaphi.value();
498  if (acop<0) acop = - acop;
499  acop = M_PI - acop;
500  LogTrace("") << "\t... acoplanarity: " << acop;
501  if (acop<acopCut_) muon_sel[10] = true;
502  else if (fastOption_) continue;
503  fill_histogram("ACOP_BEFORECUTS",acop);
504 
505  // Remaining flags (from global event information)
506  if (nmuonsForZ1<1 || nmuonsForZ2<2) muon_sel[11] = true;
507  else if (fastOption_) continue;
508  if (njets<=nJetMax_) muon_sel[12] = true;
509  else if (fastOption_) continue;
510 
511  if (fastOption_) {
512  all_sel = true;
513  break;
514  } else {
515  // Collect necessary flags "per muon"
516  int flags_passed = 0;
517  bool rec_sel_this = true;
518  bool iso_sel_this = true;
519  bool hlt_sel_this = true;
520  bool met_sel_this = true;
521  bool all_sel_this = true;
522  for (int j=0; j<NFLAGS; ++j) {
523  if (muon_sel[j]) flags_passed += 1;
524  if (j<6 && !muon_sel[j]) rec_sel_this = false;
525  if (j<7 && !muon_sel[j]) iso_sel_this = false;
526  if (j<8 && !muon_sel[j]) hlt_sel_this = false;
527  if (j<11 && !muon_sel[j]) met_sel_this = false;
528  if (!muon_sel[j]) all_sel_this = false;
529  }
530 
531  // "rec" => pt,eta and quality cuts are satisfied
532  if (rec_sel_this) rec_sel = true;
533  // "iso" => "rec" AND "muon is isolated"
534  if (iso_sel_this) iso_sel = true;
535  // "hlt" => "iso" AND "event is triggered"
536  if (hlt_sel_this) hlt_sel = true;
537  // "met" => "hlt" AND "MET/MT and acoplanarity cuts"
538  if (met_sel_this) met_sel = true;
539  // "all" => "met" AND "Z/top rejection cuts"
540  if (all_sel_this) all_sel = true;
541 
542  // Do N-1 histograms now (and only once for global event quantities)
543  if (flags_passed >= (NFLAGS-1)) {
544  if (!muon_sel[0] || flags_passed==NFLAGS)
545  fill_histogram("PT_LASTCUT",pt);
546  if (!muon_sel[1] || flags_passed==NFLAGS)
547  fill_histogram("ETA_LASTCUT",eta);
548  if (!muon_sel[2] || flags_passed==NFLAGS)
549  fill_histogram("DXY_LASTCUT",dxy);
550  if (!muon_sel[3] || flags_passed==NFLAGS) {
551  fill_histogram("CHI2_LASTCUT",normalizedChi2);
552  fill_histogram("ValidMuonHits_LASTCUT",validmuonhits); }
553  if (!muon_sel[4] || flags_passed==NFLAGS)
554  fill_histogram("NHITS_LASTCUT",trackerHits);
555  if (!muon_sel[5] || flags_passed==NFLAGS)
556  fill_histogram("TKMU_LASTCUT",mu.isTrackerMuon());
557  if (!muon_sel[6] || flags_passed==NFLAGS)
558  fill_histogram("ISO_LASTCUT",isovar);
559  if (!muon_sel[7] || flags_passed==NFLAGS) {
560  if (!hlt_hist_done) { fill_histogram("TRIG_LASTCUT",trigger_fired);
561  hlt_hist_done = true;}
562  }
563  if (!muon_sel[8] || flags_passed==NFLAGS)
564  fill_histogram("MT_LASTCUT",massT);
565  if (!muon_sel[9] || flags_passed==NFLAGS) {
566  if (!met_hist_done) { fill_histogram("MET_LASTCUT",met_et);
567  met_hist_done = true;}
568  }
569  if (!muon_sel[10] || flags_passed==NFLAGS)
570  fill_histogram("ACOP_LASTCUT",acop);
571  if (!muon_sel[11] || flags_passed==NFLAGS) {
572  if (!nz1_hist_done) { fill_histogram("NZ1_LASTCUT",nmuonsForZ1);
573  nz1_hist_done = true;}
574  }
575  if (!muon_sel[11] || flags_passed==NFLAGS) {
576  if (!nz2_hist_done) { fill_histogram("NZ2_LASTCUT",nmuonsForZ2);
577  nz2_hist_done = true; }
578  }
579  if (!muon_sel[12] || flags_passed==NFLAGS) {
580  if (!njets_hist_done) { fill_histogram("NJETS_LASTCUT",njets);
581  njets_hist_done = true;}
582  }
583  }
584  }
585 
586  }
587 
588  // Collect final flags
589  if (!fastOption_) {
590  if (rec_sel) nrec++;
591  if (iso_sel) niso++;
592  if (hlt_sel) nhlt++;
593  if (met_sel) nmet++;
594  }
595 
596  if (all_sel) {
597  nsel++;
598  LogTrace("") << ">>>> Event ACCEPTED";
599  } else {
600  LogTrace("") << ">>>> Event REJECTED";
601  }
602 
603  return all_sel;
604 
605 }
606 
608 
unsigned int nsel
float hadEt
hcal sum-Et
Definition: MuonIsolation.h:9
virtual double pt() const final
transverse momentum
std::map< std::string, TH1D * > h1_
float sumPt
sum-pt of tracks
Definition: MuonIsolation.h:7
virtual double eta() const final
momentum pseudorapidity
virtual TrackRef innerTrack() const
Definition: Muon.h:48
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
bool isTrackerMuon() const
Definition: Muon.h:226
bool accept() const
Has at least one path accepted the event?
bool isGlobalMuon() const
Definition: Muon.h:225
bool ev
edm::EDGetTokenT< edm::View< reco::MET > > metToken_
unsigned int niso
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
virtual double phi() const final
momentum azimuthal angle
virtual double et() const final
transverse energy
unsigned int nrec
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
edm::EDGetTokenT< edm::View< reco::Jet > > jetToken_
Definition: Muon.py:1
Definition: Jet.py:1
Definition: MET.h:42
virtual double px() const final
x coordinate of momentum vector
T sqrt(T t)
Definition: SSEVec.h:18
float emEt
ecal sum-Et
Definition: MuonIsolation.h:8
edm::EDGetTokenT< edm::View< reco::Muon > > muonToken_
virtual void beginJob() override
edm::InputTag metTag_
WMuNuValidator(const edm::ParameterSet &)
double normalizedChi2Cut_
T * make(const Args &...args) const
make new ROOT object
const int mu
Definition: Constants.h:22
unsigned int nhlt
static std::string const triggerResults
Definition: EdmProvDump.cc:41
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken_
virtual bool filter(edm::Event &, const edm::EventSetup &) override
bool isNull() const
Checks for null.
Definition: Ref.h:250
#define LogTrace(id)
bool isGoodMuon(const reco::Muon &muon, SelectionType type, reco::Muon::ArbitrationType arbitrationType=reco::Muon::SegmentAndTrackArbitration)
main GoodMuon wrapper call
#define M_PI
T value() const
Explicit access to value in case implicit conversion not OK.
Definition: Phi.h:38
edm::EDGetTokenT< edm::TriggerResults > trigToken_
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
met
===> hadronic RAZOR
virtual void endJob() override
edm::InputTag jetTag_
unsigned int nmet
std::string const & label() const
Definition: InputTag.h:36
fixed size matrix
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
void fill_histogram(const char *, const double &)
const Point & position() const
position
Definition: BeamSpot.h:62
const std::string muonTrig_
virtual double py() const final
y coordinate of momentum vector
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:239
unsigned int nall
const MuonIsolation & isolationR03() const
Definition: Muon.h:162
virtual TrackRef globalTrack() const
reference to Track reconstructed in both tracked and muon detector
Definition: Muon.h:54