CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SingleTopTChannelLeptonDQM_miniAOD.cc
Go to the documentation of this file.
10 #include <iostream>
15 using namespace std;
16 namespace SingleTopTChannelLepton_miniAOD {
17 
18 // maximal number of leading jets
19 // to be used for top mass estimate
20 static const unsigned int MAXJETS = 4;
21 // nominal mass of the W boson to
22 // be used for the top mass estimate
23 static const double WMASS = 80.4;
24 
25 MonitorEnsemble::MonitorEnsemble(const char* label,
26  const edm::ParameterSet& cfg,
27  const edm::VParameterSet& vcfg,
29  : label_(label),
30  pvSelect_(nullptr),
31  jetIDSelect_(nullptr),
32  includeBTag_(false),
33  lowerEdge_(-1.),
34  upperEdge_(-1.),
35  logged_(0) {
36  // sources have to be given; this PSet is not optional
37  edm::ParameterSet sources = cfg.getParameter<edm::ParameterSet>("sources");
38  muons_ = iC.consumes<edm::View<pat::Muon>>(
39  sources.getParameter<edm::InputTag>("muons"));
40  elecs_gsf_ = iC.consumes<edm::View<pat::Electron>>(
41  sources.getParameter<edm::InputTag>("elecs_gsf"));
42 
43  jets_ = iC.consumes<edm::View<pat::Jet>>(
44  sources.getParameter<edm::InputTag>("jets"));
45  for (edm::InputTag const& tag :
46  sources.getParameter<std::vector<edm::InputTag>>("mets"))
47  mets_.push_back(iC.consumes<edm::View<pat::MET>>(tag));
48  pvs_ = iC.consumes<edm::View<reco::Vertex>>(
49  sources.getParameter<edm::InputTag>("pvs"));
50  // electronExtras are optional; they may be omitted or
51  // empty
52  if (cfg.existsAs<edm::ParameterSet>("elecExtras")) {
53  edm::ParameterSet elecExtras =
54  cfg.getParameter<edm::ParameterSet>("elecExtras");
55  // select is optional; in case it's not found no
56  // selection will be applied
57  if (elecExtras.existsAs<std::string>("select")) {
58  elecSelect_ = vcfg[1].getParameter<std::string>("select");
59  }
60  // isolation is optional; in case it's not found no
61  // isolation will be applied
62  if (elecExtras.existsAs<std::string>("isolation")) {
63  elecIso_ = elecExtras.getParameter<std::string>("isolation");
64  }
65 
66 
67  // electronId is optional; in case it's not found the
68  // InputTag will remain empty
69  if (elecExtras.existsAs<edm::ParameterSet>("electronId")) {
70  edm::ParameterSet elecId =
71  elecExtras.getParameter<edm::ParameterSet>("electronId");
72  electronId_ = iC.consumes<edm::ValueMap<float>>(
73  elecId.getParameter<edm::InputTag>("src"));
74  eidCutValue_ = elecId.getParameter<double>("cutValue");
75  }
76  }
77  // pvExtras are opetional; they may be omitted or empty
78  if (cfg.existsAs<edm::ParameterSet>("pvExtras")) {
79  edm::ParameterSet pvExtras =
80  cfg.getParameter<edm::ParameterSet>("pvExtras");
81  // select is optional; in case it's not found no
82  // selection will be applied
83  if (pvExtras.existsAs<std::string>("select")) {
85  pvExtras.getParameter<std::string>("select")));
86  }
87  }
88  // muonExtras are optional; they may be omitted or empty
89  if (cfg.existsAs<edm::ParameterSet>(
90  "muonExtras")) {
91  edm::ParameterSet muonExtras =
92  cfg.getParameter<edm::ParameterSet>("muonExtras");
93 
94  // select is optional; in case it's not found no
95  // selection will be applied
96  if (muonExtras.existsAs<std::string>("select")) {
97  muonSelect_ = vcfg[1].getParameter<std::string>("select");
98  }
99  // isolation is optional; in case it's not found no
100  // isolation will be applied
101  if (muonExtras.existsAs<std::string>("isolation")) {
102  muonIso_ = muonExtras.getParameter<std::string>("isolation");
103  }
104  }
105 
106 
107  // jetExtras are optional; they may be omitted or
108  // empty
109  if (cfg.existsAs<edm::ParameterSet>("jetExtras")) {
110  edm::ParameterSet jetExtras =
111  cfg.getParameter<edm::ParameterSet>("jetExtras");
112  // jetCorrector is optional; in case it's not found
113  // the InputTag will remain empty
114  if (jetExtras.existsAs<std::string>("jetCorrector")) {
115  jetCorrector_ = jetExtras.getParameter<std::string>("jetCorrector");
116  }
117  // read jetID information if it exists
118  if (jetExtras.existsAs<edm::ParameterSet>("jetID")) {
119  edm::ParameterSet jetID =
120  jetExtras.getParameter<edm::ParameterSet>("jetID");
121  jetIDLabel_ = iC.consumes<reco::JetIDValueMap>(
122  jetID.getParameter<edm::InputTag>("label"));
124  jetID.getParameter<std::string>("select")));
125  }
126  // select is optional; in case it's not found no
127  // selection will be applied (only implemented for
128  // CaloJets at the moment)
129  if (jetExtras.existsAs<std::string>("select")) {
130 
131  jetSelect_ = jetExtras.getParameter<std::string>("select");
132  jetSelect_ = vcfg[2].getParameter<std::string>("select");
133  }
134 
135  }
136 
137  // triggerExtras are optional; they may be omitted or empty
138  if (cfg.existsAs<edm::ParameterSet>("triggerExtras")) {
139  edm::ParameterSet triggerExtras =
140  cfg.getParameter<edm::ParameterSet>("triggerExtras");
141  triggerTable_ = iC.consumes<edm::TriggerResults>(
142  triggerExtras.getParameter<edm::InputTag>("src"));
143  triggerPaths_ =
144  triggerExtras.getParameter<std::vector<std::string>>("paths");
145  }
146 
147  // massExtras is optional; in case it's not found no mass
148  // window cuts are applied for the same flavor monitor
149  // histograms
150  if (cfg.existsAs<edm::ParameterSet>("massExtras")) {
151  edm::ParameterSet massExtras =
152  cfg.getParameter<edm::ParameterSet>("massExtras");
153  lowerEdge_ = massExtras.getParameter<double>("lowerEdge");
154  upperEdge_ = massExtras.getParameter<double>("upperEdge");
155  }
156 
157  // setup the verbosity level for booking histograms;
158  // per default the verbosity level will be set to
159  // STANDARD. This will also be the chosen level in
160  // the case when the monitoring PSet is not found
162  if (cfg.existsAs<edm::ParameterSet>("monitoring")) {
163  edm::ParameterSet monitoring =
164  cfg.getParameter<edm::ParameterSet>("monitoring");
165  if (monitoring.getParameter<std::string>("verbosity") == "DEBUG")
166  verbosity_ = DEBUG;
167  if (monitoring.getParameter<std::string>("verbosity") == "VERBOSE")
169  if (monitoring.getParameter<std::string>("verbosity") == "STANDARD")
171  }
172  // and don't forget to do the histogram booking
173  directory_ = cfg.getParameter<std::string>("directory");
174 
175 
178 
181 
182 }
183 
185  // set up the current directory path
186  std::string current(directory_);
187  current += label_;
188  ibooker.setCurrentFolder(current);
189 
190  // determine number of bins for trigger monitoring
191  unsigned int nPaths = triggerPaths_.size();
192 
193  // --- [STANDARD] --- //
194  // number of selected primary vertices
195  hists_["pvMult_"] = ibooker.book1D("PvMult", "N_{pvs}", 100, 0., 100.);
196  // pt of the leading muon
197  hists_["muonPt_"] = ibooker.book1D("MuonPt", "pt(#mu)", 50, 0., 250.);
198  // muon multiplicity before std isolation
199  hists_["muonMult_"] = ibooker.book1D("MuonMult", "N_{20}(#mu)", 10, 0., 10.);
200  // muon multiplicity after std isolation
201  hists_["muonMultIso_"] = ibooker.book1D("MuonMultIso", "N_{Iso}(#mu)", 10, 0., 10.);
202  // pt of the leading electron
203  hists_["elecPt_"] = ibooker.book1D("ElecPt", "pt(e)", 50, 0., 250.);
204  // electron multiplicity before std isolation
205  hists_["elecMult_"] = ibooker.book1D("ElecMult", "N_{30}(e)", 10, 0., 10.);
206  // electron multiplicity after std isolation
207  hists_["elecMultIso_"] = ibooker.book1D("ElecMultIso", "N_{Iso}(e)", 10, 0., 10.);
208  // multiplicity of jets with pt>20 (corrected to L2+L3)
209  hists_["jetMult_"] = ibooker.book1D("JetMult", "N_{30}(jet)", 10, 0., 10.);
210  // trigger efficiency estimates for single lepton triggers
211  hists_["triggerEff_"] = ibooker.book1D("TriggerEff",
212  "Eff(trigger)", nPaths, 0., nPaths);
213  // monitored trigger occupancy for single lepton triggers
214  hists_["triggerMon_"] = ibooker.book1D("TriggerMon",
215  "Mon(trigger)", nPaths, 0., nPaths);
216 
217  hists_["slimmedMETs_"] = ibooker.book1D("slimmedMETs", "MET_{slimmed}", 50, 0., 200.);
218 
219  // MET (calo)
220  hists_["slimmedMETsNoHF_"] = ibooker.book1D("slimmedMETsNoHF", "MET_{slimmedNoHF}", 50, 0., 200.);
221  // MET (pflow)
222  hists_["slimmedMETsPuppi_"] = ibooker.book1D("slimmedMETsPuppi", "MET_{slimmedPuppi}", 50, 0., 200.);
223  // W mass estimate
224  hists_["massW_"] = ibooker.book1D("MassW", "M(W)", 60, 0., 300.);
225  // Top mass estimate
226  hists_["massTop_"] = ibooker.book1D("MassTop", "M(Top)", 50, 0., 500.);
227  // W mass transverse estimate mu
228  hists_["MTWm_"] = ibooker.book1D("MTWm", "M_{T}^{W}(#mu)", 60, 0., 300.);
229  // Top mass transverse estimate mu
230  hists_["mMTT_"] = ibooker.book1D("mMTT", "M_{T}^{t}(#mu)", 50, 0., 500.);
231 
232  // W mass transverse estimate e
233  hists_["MTWe_"] = ibooker.book1D("MTWe", "M_{T}^{W}(e)", 60, 0., 300.);
234  // Top mass transverse estimate e
235  hists_["eMTT_"] = ibooker.book1D("eMTT", "M_{T}^{t}(e)", 50, 0., 500.);
236 
237  // set bin labels for trigger monitoring
239 
240  if (verbosity_ == STANDARD) return;
241 
242  // --- [VERBOSE] --- //
243 
244  // eta of the leading muon
245  hists_["muonEta_"] = ibooker.book1D("MuonEta", "#eta(#mu)", 30, -3., 3.);
246  // std isolation variable of the leading muon
247  hists_["muonPFRelIso_"] = ibooker.book1D("MuonPFRelIso",
248  "PFIso_{Rel}(#mu)", 50, 0., 1.);
249  hists_["muonRelIso_"] = ibooker.book1D("MuonRelIso", "Iso_{Rel}(#mu)", 50, 0., 1.);
250 
251  // eta of the leading electron
252  hists_["elecEta_"] = ibooker.book1D("ElecEta", "#eta(e)", 30, -3., 3.);
253  // std isolation variable of the leading electron
254  hists_["elecRelIso_"] = ibooker.book1D("ElecRelIso", "Iso_{Rel}(e)", 50, 0., 1.);
255  hists_["elecPFRelIso_"] = ibooker.book1D("ElecPFRelIso",
256  "PFIso_{Rel}(e)", 50, 0., 1.);
257 
258  // multiplicity of btagged jets (for track counting high efficiency) with
259  // pt(L2L3)>30
260  hists_["jetMultBEff_"] = ibooker.book1D("JetMultBEff",
261  "N_{30}(b/eff)", 10, 0., 10.);
262  // btag discriminator for track counting high efficiency for jets with
263  // pt(L2L3)>30
264  hists_["jetBDiscEff_"] = ibooker.book1D("JetBDiscEff",
265  "Disc_{b/eff}(jet)", 100, 0., 10.);
266 
267  // eta of the 1. leading jet
268  hists_["jet1Eta_"] = ibooker.book1D("Jet1Eta", "#eta (jet1)", 50, -5., 5.);
269  // eta of the 2. leading jet
270  hists_["jet2Eta_"] = ibooker.book1D("Jet2Eta", "#eta (jet2)", 50, -5., 5.);
271 
272  // pt of the 1. leading jet (corrected to L2+L3)
273  hists_["jet1Pt_"] = ibooker.book1D("Jet1Pt", "pt_{L2L3}(jet1)", 60, 0., 300.);
274  // pt of the 2. leading jet (corrected to L2+L3)
275  hists_["jet2Pt_"] = ibooker.book1D("Jet2Pt", "pt_{L2L3}(jet2)", 60, 0., 300.);
276 
277  // eta and pt of the b-tagged jet (filled only when nJets==2)
278  hists_["TaggedJetEta_"] = ibooker.book1D("TaggedJetEta",
279  "#eta (Tagged jet)", 50, -5., 5.);
280  hists_["TaggedJetPt_"] = ibooker.book1D("TaggedJetPt",
281  "pt_{L2L3}(Tagged jet)", 60, 0., 300.);
282 
283  // eta and pt of the jet not passing b-tag (filled only when nJets==2)
284  hists_["UnTaggedJetEta_"] = ibooker.book1D("UnTaggedJetEta",
285  "#eta (UnTagged jet)", 50, -5., 5.);
286  hists_["UnTaggedJetPt_"] = ibooker.book1D("UnTaggedJetPt",
287  "pt_{L2L3}(UnTagged jet)", 60, 0., 300.);
288 
289  // eta and pt of the most forward jet in the event with nJets==2
290  hists_["FwdJetEta_"] = ibooker.book1D("FwdJetEta", "#eta (Fwd jet)", 50, -5., 5.);
291  hists_["FwdJetPt_"] = ibooker.book1D("FwdJetPt",
292  "pt_{L2L3}(Fwd jet)", 60, 0., 300.);
293 
294  // 2D histogram (pt,eta) of the b-tagged jet (filled only when nJets==2)
295  hists_["TaggedJetPtEta_"] = ibooker.book2D("TaggedJetPt_Eta",
296  "(pt vs #eta)_{L2L3}(Tagged jet)", 60, 0., 300., 50, -5., 5.);
297 
298  // 2D histogram (pt,eta) of the not-b tagged jet (filled only when nJets==2)
299  hists_["UnTaggedJetPtEta_"] = ibooker.book2D("UnTaggedJetPt_Eta",
300  "(pt vs #eta)_{L2L3}(UnTagged jet)", 60, 0., 300., 50, -5., 5.);
301 
302 
303 
304  // dz for muons (to suppress cosmis)
305  hists_["muonDelZ_"] = ibooker.book1D("MuonDelZ", "d_{z}(#mu)", 50, -25., 25.);
306  // dxy for muons (to suppress cosmics)
307  hists_["muonDelXY_"] = ibooker.book2D("MuonDelXY",
308  "d_{xy}(#mu)", 50, -0.1, 0.1, 50, -0.1, 0.1);
309 
310  // set axes titles for dxy for muons
311  hists_["muonDelXY_"]->setAxisTitle("x [cm]", 1);
312  hists_["muonDelXY_"]->setAxisTitle("y [cm]", 2);
313 
314  if (verbosity_ == VERBOSE) return;
315 
316  // --- [DEBUG] --- //
317 
318  // relative muon isolation from charged hadrons for the leading muon
319  hists_["muonChHadIso_"] = ibooker.book1D("MuonChHadIso",
320  "Iso_{ChHad}(#mu)", 100, 0., 1.);
321  // relative muon isolation from neutral hadrons for the leading muon
322  hists_["muonNeuHadIso_"] = ibooker.book1D("MuonNeuHadIso",
323  "Iso_{NeuHad}(#mu)", 100, 0., 1.);
324  // relative muon isolation from photons for the leading muon
325  hists_["muonPhIso_"] = ibooker.book1D("MuonPhIso", "Iso_{Ph}(#mu)", 100, 0., 1.);
326 
327  // relative electron isolation from charged hadrons for the leading electron
328  hists_["elecChHadIso_"] = ibooker.book1D("ElecChHadIso",
329  "Iso_{ChHad}(e)", 100, 0., 1.);
330  // relative electron isolation from neutral hadrons for the leading electron
331  hists_["elecNeuHadIso_"] = ibooker.book1D("ElecNeuHadIso",
332  "Iso_{NeuHad}(e)", 100, 0., 1.);
333  // relative electron isolation from photons for the leading electron
334  hists_["elecPhIso_"] = ibooker.book1D("ElecPhIso", "Iso_{Ph}(e)", 100, 0., 1.);
335 
336  // multiplicity of btagged jets (for track counting high purity) with
337  // pt(L2L3)>30
338  hists_["jetMultBPur_"] = ibooker.book1D("JetMultBPur",
339  "N_{30}(b/pur)", 10, 0., 10.);
340  // btag discriminator for track counting high purity
341  hists_["jetBDiscPur_"] = ibooker.book1D("JetBDiscPur",
342  "Disc_{b/pur}(Jet)", 200, -10., 10.);
343  // btag discriminator for track counting high purity for 1. leading jet
344  hists_["jet1BDiscPur_"] = ibooker.book1D("Jet1BDiscPur",
345  "Disc_{b/pur}(Jet1)", 200, -10., 10.);
346  // btag discriminator for track counting high purity for 2. leading jet
347  hists_["jet2BDiscPur_"] = ibooker.book1D("Jet2BDiscPur",
348  "Disc_{b/pur}(Jet2)", 200, -10., 10.);
349 
350  // multiplicity of btagged jets (for simple secondary vertex) with pt(L2L3)>30
351  hists_["jetMultBVtx_"] = ibooker.book1D("JetMultBVtx",
352  "N_{30}(b/vtx)", 10, 0., 10.);
353  // btag discriminator for simple secondary vertex
354  hists_["jetBDiscVtx_"] = ibooker.book1D("JetBDiscVtx",
355  "Disc_{b/vtx}(Jet)", 35, -1., 6.);
356 
357  // multiplicity of btagged jets (for combined secondary vertex) with
358  // pt(L2L3)>30
359  hists_["jetMultBCombVtx_"] = ibooker.book1D("JetMultBCombVtx",
360  "N_{30}(b/CSV)", 10, 0., 10.);
361  // btag discriminator for combined secondary vertex
362  hists_["jetBDiscCombVtx_"] = ibooker.book1D("JetBDiscCombVtx",
363  "Disc_{b/CSV}(Jet)", 60, -1., 2.);
364  // btag discriminator for combined secondary vertex for 1. leading jet
365  hists_["jet1BDiscCombVtx_"] = ibooker.book1D("Jet1BDiscCombVtx",
366  "Disc_{b/CSV}(Jet1)", 60, -1., 2.);
367  // btag discriminator for combined secondary vertex for 2. leading jet
368  hists_["jet2BDiscCombVtx_"] = ibooker.book1D("Jet2BDiscCombVtx",
369  "Disc_{b/CSV}(Jet2)", 60, -1., 2.);
370 
371  // pt of the 1. leading jet (uncorrected)
372  hists_["jet1PtRaw_"] = ibooker.book1D("Jet1PtRaw", "pt_{Raw}(jet1)", 60, 0., 300.);
373  // pt of the 2. leading jet (uncorrected)
374  hists_["jet2PtRaw_"] = ibooker.book1D("Jet2PtRaw", "pt_{Raw}(jet2)", 60, 0., 300.);
375 
376  // selected events
377  hists_["eventLogger_"] = ibooker.book2D("EventLogger",
378  "Logged Events", 9, 0., 9., 10, 0., 10.);
379 
380  // set axes titles for selected events
381  hists_["eventLogger_"]->getTH1()->SetOption("TEXT");
382  hists_["eventLogger_"]->setBinLabel(1, "Run", 1);
383  hists_["eventLogger_"]->setBinLabel(2, "Block", 1);
384  hists_["eventLogger_"]->setBinLabel(3, "Event", 1);
385  hists_["eventLogger_"]->setBinLabel(4, "pt_{L2L3}(jet1)", 1);
386  hists_["eventLogger_"]->setBinLabel(5, "pt_{L2L3}(jet2)", 1);
387  hists_["eventLogger_"]->setBinLabel(6, "pt_{L2L3}(jet3)", 1);
388  hists_["eventLogger_"]->setBinLabel(7, "pt_{L2L3}(jet4)", 1);
389  hists_["eventLogger_"]->setBinLabel(8, "M_{W}", 1);
390  hists_["eventLogger_"]->setBinLabel(9, "M_{Top}", 1);
391  hists_["eventLogger_"]->setAxisTitle("logged evts", 2);
392  return;
393 }
394 
396  const edm::EventSetup& setup) {
397  // fetch trigger event if configured such
400  if (!event.getByToken(triggerTable_, triggerTable)) return;
401  }
402  /*
403  ------------------------------------------------------------
404 
405  Primary Vertex Monitoring
406 
407  ------------------------------------------------------------
408  */
409 
410  // fill monitoring plots for primary vertices
412  if (!event.getByToken(pvs_, pvs)) return;
413  unsigned int pvMult = 0;
414  for (edm::View<reco::Vertex>::const_iterator pv = pvs->begin();
415  pv != pvs->end(); ++pv) {
416  if (!pvSelect_ || (*pvSelect_)(*pv)) pvMult++;
417  }
418  fill("pvMult_", pvMult);
419 
420  /*
421  ------------------------------------------------------------
422 
423  Electron Monitoring
424 
425  ------------------------------------------------------------
426  */
427 
428  // fill monitoring plots for electrons
430 
431 
432 
433 
434 
435 
436  if (!event.getByToken(elecs_gsf_, elecs_gsf)) return;
437 
438  // loop electron collection
439  unsigned int eMult = 0, eMultIso = 0;
440  std::vector<const pat::Electron*> isoElecs;
442 
443  unsigned int idx_gsf = 0;
444  for ( edm::View<pat::Electron>::const_iterator elec = elecs_gsf->begin(); elec != elecs_gsf->end(); ++elec) {
445 
446  if (true){
447  if ((*elecSelect)(*elec)) {
448  double isolationRel =
449  (elec->dr03TkSumPt() + elec->dr03EcalRecHitSumEt() +
450  elec->dr03HcalTowerSumEt()) /
451  elec->pt();
452 
453  double isolationChHad =
454  elec->pt() /
455  (elec->pt() + elec->pfIsolationVariables().sumChargedHadronPt);
456  double isolationNeuHad =
457  elec->pt() /
458  (elec->pt() + elec->pfIsolationVariables().sumNeutralHadronEt);
459  double isolationPhoton =
460  elec->pt() /
461  (elec->pt() + elec->pfIsolationVariables().sumPhotonEt);
462  double el_ChHadIso = elec->pfIsolationVariables().sumChargedHadronPt;
463  double el_NeHadIso = elec->pfIsolationVariables().sumNeutralHadronEt;
464  double el_PhIso = elec->pfIsolationVariables().sumPhotonEt;
465  double PFisolationRel =
466  (el_ChHadIso +
467  max(0., el_NeHadIso + el_PhIso -
468  0.5 * elec->pfIsolationVariables().sumPUPt)) /
469  elec->pt();
470 
471  if (eMult == 0) {
472  fill("elecPt_", elec->pt());
473  fill("elecEta_", elec->eta());
474  fill("elecRelIso_", isolationRel);
475  fill("elecPFRelIso_", PFisolationRel);
476  fill("elecChHadIso_", isolationChHad);
477  fill("elecNeuHadIso_", isolationNeuHad);
478  fill("elecPhIso_", isolationPhoton);
479  }
480 
481  ++eMult;
482  if ((*elecIso)(*elec)) {
483  if (eMultIso == 0) e = *elec;
484  isoElecs.push_back(&(*elec));
485  ++eMultIso;
486  }
487  }
488  }
489  idx_gsf++;
490  }
491 
492  fill("elecMult_", eMult);
493  fill("elecMultIso_", eMultIso);
494 
495  /*
496  ------------------------------------------------------------
497 
498  Muon Monitoring
499 
500  ------------------------------------------------------------
501  */
502 
503  // fill monitoring plots for muons
504  unsigned int mMult = 0, mMultIso = 0;
505 
507 
508  pat::Muon mu;
509 
510  if (!event.getByToken(muons_, muons)) return;
511  for (edm::View<pat::Muon>::const_iterator muon = muons->begin(); muon != muons->end();
512  ++muon) {
513 
514  // restrict to globalMuons
515  if (muon->isGlobalMuon()) {
516  fill("muonDelZ_", muon->globalTrack()->vz());
517  fill("muonDelXY_", muon->globalTrack()->vx(), muon->globalTrack()->vy());
518 
519  // apply selection
520  if ((*muonSelect)(*muon)) {
521 
522  double isolationRel =
523  (muon->isolationR03().sumPt + muon->isolationR03().emEt +
524  muon->isolationR03().hadEt) /
525  muon->pt();
526  double isolationChHad =
527  muon->pt() /
528  (muon->pt() + muon->pfIsolationR04().sumChargedHadronPt);
529  double isolationNeuHad =
530  muon->pt() /
531  (muon->pt() + muon->pfIsolationR04().sumNeutralHadronEt);
532  double isolationPhoton =
533  muon->pt() / (muon->pt() + muon->pfIsolationR04().sumPhotonEt);
534  double PFisolationRel = (muon->pfIsolationR04().sumChargedHadronPt +
535  muon->pfIsolationR04().sumNeutralHadronEt +
536  muon->pfIsolationR04().sumPhotonEt) /
537  muon->pt();
538 
539  if (mMult == 0) {
540  // restrict to leading muon
541  fill("muonPt_", muon->pt());
542  fill("muonEta_", muon->eta());
543  fill("muonRelIso_", isolationRel);
544  fill("muonChHadIso_", isolationChHad);
545  fill("muonNeuHadIso_", isolationNeuHad);
546  fill("muonPhIso_", isolationPhoton);
547  fill("muonPFRelIso_", PFisolationRel);
548  }
549  ++mMult;
550 
551  if ((*muonIso)(*muon)) {
552  if (mMultIso == 0) mu = *muon;
553  ++mMultIso;
554  }
555  }
556  }
557  }
558  fill("muonMult_", mMult);
559  fill("muonMultIso_", mMultIso);
560 
561  /*
562  ------------------------------------------------------------
563 
564  Jet Monitoring
565 
566  ------------------------------------------------------------
567  */
568 
569  // loop jet collection
570  std::vector<pat::Jet> correctedJets;
571  unsigned int mult = 0, multBEff = 0, multBPur = 0, multNoBPur = 0,
572  multBVtx = 0, multBCombVtx = 0;
573 
575  if (!event.getByToken(jets_, jets)) return;
576 
577  vector<double> bJetDiscVal;
578  vector<double> NobJetDiscVal;
579  pat::Jet TaggedJetCand;
580  pat::Jet UnTaggedJetCand;
581  pat::Jet FwdJetCand;
582  for (edm::View<pat::Jet>::const_iterator jet = jets->begin();
583  jet != jets->end(); ++jet) {
584 
585  pat::Jet sel = *jet;
586 
587  if ( jetSelectJet==0)
589 
590  if (!((*jetSelectJet)(sel))) continue;
591 
592  // prepare jet to fill monitor histograms
593  pat::Jet monitorJet = *jet;
594  correctedJets.push_back(monitorJet);
595 
596  ++mult; // determine jet multiplicity
597 
598 
599  fill("jetBDiscEff_", monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags")); //hard coded discriminator and value right now.
600  if (monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags") > 0.89) ++multBEff;
601 
602 
603 
604  if (monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags") > 0.89) {
605  if (multBPur == 0) {
606  TaggedJetCand = monitorJet;
607  bJetDiscVal.push_back(monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags"));
608 
609  } else if (multBPur == 1) {
610  bJetDiscVal.push_back(monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags"));
611  if (bJetDiscVal[1] > bJetDiscVal[0]) TaggedJetCand = monitorJet;
612  }
613  ++multBPur;
614  } else {
615  if (multNoBPur == 0) {
616  UnTaggedJetCand = monitorJet;
617  NobJetDiscVal.push_back(monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags"));
618 
619  } else if (multNoBPur == 1) {
620  NobJetDiscVal.push_back(monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags"));
621  if (NobJetDiscVal[1] < NobJetDiscVal[0]) UnTaggedJetCand = monitorJet;
622  }
623 
624  ++multNoBPur;
625  }
626 
627 
628  if (monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags") > 0.89) ++multBEff;
629  if (mult == 1) {
630  fill("jet1BDiscPur_", monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags"));
631  } else if (mult == 2) {
632  fill("jet2BDiscPur_", monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags"));
633  }
634 
635  fill("jetBDiscPur_", monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags"));
636 
637 
638  // fill pt (raw or L2L3) for the leading jets
639  if (mult == 1) {
640  fill("jet1Pt_", monitorJet.pt());
641  fill("jet1Eta_", monitorJet.eta());
642  fill("jet1PtRaw_", jet->pt());
643  FwdJetCand = monitorJet;
644  }
645 
646  if (mult == 2) {
647  fill("jet2Pt_", monitorJet.pt());
648  fill("jet2Eta_", monitorJet.eta());
649  fill("jet2PtRaw_", jet->pt());
650 
651  if (abs(monitorJet.eta()) > abs(FwdJetCand.eta())) {
652  FwdJetCand = monitorJet;
653  }
654 
655  fill("FwdJetPt_", FwdJetCand.pt());
656  fill("FwdJetEta_", FwdJetCand.eta());
657  }
658  }
659 
660  if (multNoBPur == 1 && multBPur == 1) {
661 
662  fill("TaggedJetPtEta_", TaggedJetCand.pt(), TaggedJetCand.eta());
663  fill("UnTaggedJetPtEta_", UnTaggedJetCand.pt(), UnTaggedJetCand.eta());
664 
665  fill("TaggedJetPt_", TaggedJetCand.pt());
666  fill("TaggedJetEta_", TaggedJetCand.eta());
667  fill("UnTaggedJetPt_", UnTaggedJetCand.pt());
668  fill("UnTaggedJetEta_", UnTaggedJetCand.eta());
669  }
670 
671  fill("jetMult_", mult);
672  fill("jetMultBEff_", multBEff);
673  fill("jetMultBPur_", multBPur);
674  fill("jetMultBVtx_", multBVtx);
675  fill("jetMultBCombVtx_", multBCombVtx);
676 
677  /*
678  ------------------------------------------------------------
679 
680  MET Monitoring
681 
682  ------------------------------------------------------------
683  */
684 
685  // fill monitoring histograms for met
686  pat::MET mET;
687 
688  for (std::vector<edm::EDGetTokenT<edm::View<pat::MET>>>::const_iterator
689  met_ = mets_.begin();
690  met_ != mets_.end(); ++met_) {
692  if (!event.getByToken(*met_, met)) continue;
693  mET = *(met->begin());
694  if (met->begin() != met->end()) {
695  unsigned int idx = met_ - mets_.begin();
696  if (idx == 0) fill("slimmedMETs_", met->begin()->et());
697  if (idx == 1) fill("slimmedMETsNoHF_", met->begin()->et());
698  if (idx == 2) fill("slimmedMETsPuppi_", met->begin()->et());
699 
700  }
701  }
702 
703  /*
704  ------------------------------------------------------------
705 
706  Event Monitoring
707 
708  ------------------------------------------------------------
709  */
710 
711  // fill W boson and top mass estimates
712  Calculate_miniAOD eventKinematics(MAXJETS, WMASS);
713  double wMass = eventKinematics.massWBoson(correctedJets);
714  double topMass = eventKinematics.massTopQuark(correctedJets);
715  if (wMass >= 0 && topMass >= 0) {
716  fill("massW_", wMass);
717  fill("massTop_", topMass);
718  }
719  // fill plots for trigger monitoring
720  if ((lowerEdge_ == -1. && upperEdge_ == -1.) ||
721  (lowerEdge_ < wMass && wMass < upperEdge_)) {
723  fill(event, *triggerTable, "trigger", triggerPaths_);
724  if (logged_ <= hists_.find("eventLogger_")->second->getNbinsY()) {
725  // log runnumber, lumi block, event number & some
726  // more pysics infomation for interesting events
727  fill("eventLogger_", 0.5, logged_ + 0.5, event.eventAuxiliary().run());
728  fill("eventLogger_", 1.5, logged_ + 0.5,
729  event.eventAuxiliary().luminosityBlock());
730  fill("eventLogger_", 2.5, logged_ + 0.5, event.eventAuxiliary().event());
731  if (correctedJets.size() > 0)
732  fill("eventLogger_", 3.5, logged_ + 0.5, correctedJets[0].pt());
733  if (correctedJets.size() > 1)
734  fill("eventLogger_", 4.5, logged_ + 0.5, correctedJets[1].pt());
735  if (correctedJets.size() > 2)
736  fill("eventLogger_", 5.5, logged_ + 0.5, correctedJets[2].pt());
737  if (correctedJets.size() > 3)
738  fill("eventLogger_", 6.5, logged_ + 0.5, correctedJets[3].pt());
739  fill("eventLogger_", 7.5, logged_ + 0.5, wMass);
740  fill("eventLogger_", 8.5, logged_ + 0.5, topMass);
741  ++logged_;
742  }
743  }
744  if (multBPur != 0 && mMultIso == 1) {
745 
746  double mtW = eventKinematics.tmassWBoson(&mu, mET, TaggedJetCand);
747  fill("MTWm_", mtW);
748  double MTT = eventKinematics.tmassTopQuark(&mu, mET, TaggedJetCand);
749  fill("mMTT_", MTT);
750  }
751 
752  if (multBPur != 0 && eMultIso == 1) {
753  double mtW = eventKinematics.tmassWBoson(&e, mET, TaggedJetCand);
754  fill("MTWe_", mtW);
755  double MTT = eventKinematics.tmassTopQuark(&e, mET, TaggedJetCand);
756  fill("eMTT_", MTT);
757  }
758 }
759 }
760 
762  const edm::ParameterSet& cfg)
763  : vertexSelect_(nullptr),
764  beamspot_(""),
765  beamspotSelect_(nullptr),
766  muonStep_(nullptr),
767  electronStep_(nullptr),
768  pvStep_(nullptr),
769  metStep_(nullptr) {
770  jetSteps_.clear();
771 
772 
773  // configure preselection
774  edm::ParameterSet presel =
775  cfg.getParameter<edm::ParameterSet>("preselection");
776  if (presel.existsAs<edm::ParameterSet>("trigger")) {
777  edm::ParameterSet trigger =
778  presel.getParameter<edm::ParameterSet>("trigger");
779  triggerTable__ = consumes<edm::TriggerResults>(
780  trigger.getParameter<edm::InputTag>("src"));
781  triggerPaths_ = trigger.getParameter<std::vector<std::string>>("select");
782  }
783  if (presel.existsAs<edm::ParameterSet>("vertex")) {
784  edm::ParameterSet vertex = presel.getParameter<edm::ParameterSet>("vertex");
785  vertex_ = vertex.getParameter<edm::InputTag>("src");
786  vertex__ =
787  consumes<reco::Vertex>(vertex.getParameter<edm::InputTag>("src"));
789  vertex.getParameter<std::string>("select")));
790  }
791  if (presel.existsAs<edm::ParameterSet>("beamspot")) {
793  presel.getParameter<edm::ParameterSet>("beamspot");
794  beamspot_ = beamspot.getParameter<edm::InputTag>("src");
795  beamspot__ =
796  consumes<reco::BeamSpot>(beamspot.getParameter<edm::InputTag>("src"));
798  beamspot.getParameter<std::string>("select")));
799  }
800  // conifgure the selection
801  std::vector<edm::ParameterSet> sel =
802  cfg.getParameter<std::vector<edm::ParameterSet>>("selection");
803 
804  for (unsigned int i = 0; i < sel.size(); ++i) {
805  selectionOrder_.push_back(sel.at(i).getParameter<std::string>("label"));
806  selection_[selectionStep(selectionOrder_.back())] = std::make_pair(
807  sel.at(i),
808  std::unique_ptr<SingleTopTChannelLepton_miniAOD::MonitorEnsemble>(
810  selectionStep(selectionOrder_.back()).c_str(),
811  cfg.getParameter<edm::ParameterSet>("setup"),
812  cfg.getParameter<std::vector<edm::ParameterSet>>("selection"),
813  consumesCollector())));
814  }
815  for (std::vector<std::string>::const_iterator selIt = selectionOrder_.begin();
816  selIt != selectionOrder_.end(); ++selIt) {
817  std::string key = selectionStep(*selIt), type = objectType(*selIt);
818  if (selection_.find(key) != selection_.end()) {
819  using std::unique_ptr;
820 
821  if (type == "muons") {
823  consumesCollector()));
824  }
825  if (type == "elecs") {
828  }
829 
830  if (type == "pvs") {
832  consumesCollector()));
833  }
834  if (type == "jets") {
835  jetSteps_.push_back(std::unique_ptr<SelectionStep<pat::Jet>>(
837  consumesCollector())));
838  }
839  if (type == "met") {
841  consumesCollector()));
842  }
843  }
844  }
845 }
847  edm::Run const &, edm::EventSetup const & ){
848 
849  for (auto selIt = selection_.begin(); selIt != selection_.end(); ++selIt) {
850  selIt->second.second->book(ibooker);
851  }
852 }
854  const edm::EventSetup& setup) {
857  if (!event.getByToken(triggerTable__, triggerTable)) return;
858  if (!accept(event, *triggerTable, triggerPaths_)) return;
859  }
860  if (!beamspot__.isUninitialized()) {
862  if (!event.getByToken(beamspot__, beamspot)) return;
863  if (!(*beamspotSelect_)(*beamspot)) return;
864  }
865 
866  if (!vertex__.isUninitialized()) {
868  if (!event.getByToken(vertex__, vertex)) return;
870  if (!(*vertexSelect_)(*pv)) return;
871  }
872 
873  // apply selection steps
874  unsigned int passed = 0;
875  unsigned int nJetSteps = -1;
876 
877  for (std::vector<std::string>::const_iterator selIt = selectionOrder_.begin();
878  selIt != selectionOrder_.end(); ++selIt) {
879  std::string key = selectionStep(*selIt), type = objectType(*selIt);
880  if (selection_.find(key) != selection_.end()) {
881  if (type == "empty") {
882  selection_[key].second->fill(event, setup);
883  }
884  if (type == "presel") {
885  selection_[key].second->fill(event, setup);
886  }
887  if (type == "elecs" && electronStep_ != 0) {
888  if (electronStep_->select(event)) {
889  ++passed;
890  selection_[key].second->fill(event, setup);
891  } else
892  break;
893  }
894  if (type == "muons" && muonStep_ != 0) {
895  if (muonStep_->select(event)) {
896  ++passed;
897  selection_[key].second->fill(event, setup);
898  } else
899  break;
900  }
901  if (type == "jets") {
902  nJetSteps++;
903  if (jetSteps_[nJetSteps]) {
904  if (jetSteps_[nJetSteps]->select(event, setup)) {
905  ++passed;
906  selection_[key].second->fill(event, setup);
907  } else
908  break;
909  }
910  }
911  if (type == "met" && metStep_ != 0) {
912  if (metStep_->select(event)) {
913  ++passed;
914  selection_[key].second->fill(event, setup);
915  } else
916  break;
917  }
918  }
919  }
920 }
type
Definition: HCALResponse.h:21
Analysis-level MET class.
Definition: MET.h:43
std::unique_ptr< SelectionStep< pat::Electron > > electronStep_
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::ValueMap< float > > electronId_
electronId label
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< edm::View< pat::Electron > > elecs_gsf_
tuple cfg
Definition: looper.py:293
edm::EDGetTokenT< edm::TriggerResults > triggerTable_
trigger table
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
double tmassWBoson(pat::Muon *lep, const pat::MET &met, const pat::Jet &b)
calculate W boson transverse mass estimate
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
std::unique_ptr< StringCutObjectSelector< reco::JetID > > jetIDSelect_
extra jetID selection on calo jets
void triggerBinLabels(std::string channel, const std::vector< std::string > labels)
set configurable labels for trigger monitoring histograms
RunNumber_t run() const
std::unique_ptr< StringCutObjectSelector< pat::Muon, true > > muonIso
double massWBoson(const std::vector< pat::Jet > &jets)
calculate W boson mass estimate
std::map< std::string, std::pair< edm::ParameterSet, std::unique_ptr< SingleTopTChannelLepton_miniAOD::MonitorEnsemble > > > selection_
float bDiscriminator(const std::string &theLabel) const
-— methods for accessing b-tagging info -—
#define nullptr
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:30
#define MAXJETS
Definition: myFastSimVal.cc:30
LuminosityBlockNumber_t luminosityBlock() const
edm::EDGetTokenT< edm::View< pat::Jet > > jets_
input sources for monitoring
std::unique_ptr< StringCutObjectSelector< pat::Electron, true > > elecSelect
void fill(const edm::Event &event, const edm::EventSetup &setup)
fill monitor histograms with electronId and jetCorrections
virtual void analyze(const edm::Event &event, const edm::EventSetup &setup) override
do this during the event loop
std::string selectionStep(const std::string &label)
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
vector< PseudoJet > jets
std::unique_ptr< SelectionStep< pat::MET > > metStep_
std::unique_ptr< StringCutObjectSelector< reco::Vertex > > pvSelect_
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
std::string objectType(const std::string &label)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::unique_ptr< SelectionStep< pat::Muon > > muonStep_
const int mu
Definition: Constants.h:22
std::string muonIso_
extra isolation criterion on muon
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
double massTopQuark(const std::vector< pat::Jet > &jets)
calculate t-quark mass estimate
string key
FastSim: produces sample of signal events, overlayed with premixed minbias events.
double tmassTopQuark(pat::Muon *lep, const pat::MET &met, const pat::Jet &b)
calculate top quark transverse mass estimate
std::vector< std::unique_ptr< SelectionStep< pat::Jet > > > jetSteps_
edm::EDGetTokenT< reco::JetIDValueMap > jetIDLabel_
jetID as an extra selection type
std::vector< std::string > triggerPaths_
trigger paths
EventAuxiliary const & eventAuxiliary() const
Definition: Event.h:78
std::unique_ptr< StringCutObjectSelector< pat::Muon, true > > muonSelect
void book(DQMStore::IBooker &ibooker)
book histograms in subdirectory directory
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
Analysis-level electron class.
Definition: Electron.h:52
Analysis-level calorimeter jet class.
Definition: Jet.h:78
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Templated helper class to allow a selection on a certain object collection.
tuple muons
Definition: patZpeak.py:38
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
std::unique_ptr< StringCutObjectSelector< pat::Jet > > jetSelectJet
std::unique_ptr< StringCutObjectSelector< reco::Vertex > > vertexSelect_
string cut selector
std::unique_ptr< StringCutObjectSelector< pat::Electron, true > > elecIso
std::unique_ptr< StringCutObjectSelector< reco::BeamSpot > > beamspotSelect_
string cut selector
bool isUninitialized() const
Definition: EDGetToken.h:73
virtual double eta() const final
momentum pseudorapidity
volatile std::atomic< bool > shutdown_flag false
std::vector< edm::EDGetTokenT< edm::View< pat::MET > > > mets_
considers a vector of METs
SingleTopTChannelLeptonDQM_miniAOD(const edm::ParameterSet &cfg)
default constructor
edm::EDGetTokenT< edm::TriggerResults > triggerTable__
trigger table
std::unique_ptr< SelectionStep< reco::Vertex > > pvStep_
Analysis-level muon class.
Definition: Muon.h:49
EventNumber_t event() const
std::string elecIso_
extra isolation criterion on electron
Definition: Run.h:42
virtual double pt() const final
transverse momentum