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