CMS 3D CMS Logo

TopSingleLeptonDQM_miniAOD.cc
Go to the documentation of this file.
7 #include <iostream>
11 
16 using namespace std;
18 
19 // maximal number of leading jets
20 // to be used for top mass estimate
21 static const unsigned int MAXJETS = 4;
22 // nominal mass of the W boson to
23 // be used for the top mass estimate
24 static const double WMASS = 80.4;
25 
26 MonitorEnsemble::MonitorEnsemble(const char* label,
27  const edm::ParameterSet& cfg,
29  : label_(label),
30  elecIso_(nullptr),
31  elecSelect_(nullptr),
32  pvSelect_(nullptr),
33  muonIso_(nullptr),
34  muonSelect_(nullptr),
35  jetIDSelect_(nullptr),
36  jetSelect(nullptr),
37  includeBTag_(false),
38  lowerEdge_(-1.),
39  upperEdge_(-1.),
40  logged_(0) {
41 
42  // sources have to be given; this PSet is not optional
43  edm::ParameterSet sources = cfg.getParameter<edm::ParameterSet>("sources");
44  // muons_ = iC.consumes<edm::View<reco::PFCandidate> >(
45  // sources.getParameter<edm::InputTag>("muons"));
46 
47 
48  muons_ = iC.consumes<edm::View<pat::Muon> >(
49  sources.getParameter<edm::InputTag>("muons"));
50 
51 
52  elecs_ = iC.consumes<edm::View<pat::Electron> >(
53  sources.getParameter<edm::InputTag>("elecs"));
54  pvs_ = iC.consumes<edm::View<reco::Vertex> >(
55  sources.getParameter<edm::InputTag>("pvs"));
56  jets_ = iC.consumes<edm::View<pat::Jet> >(
57  sources.getParameter<edm::InputTag>("jets"));
58  for (edm::InputTag const& tag :
59  sources.getParameter<std::vector<edm::InputTag> >("mets"))
60  mets_.push_back(iC.consumes<edm::View<pat::MET> >(tag));
61  // electronExtras are optional; they may be omitted or
62  // empty
63  if (cfg.existsAs<edm::ParameterSet>("elecExtras")) {
64 
65 
66  edm::ParameterSet elecExtras =
67  cfg.getParameter<edm::ParameterSet>("elecExtras");
68  // select is optional; in case it's not found no
69  // selection will be applied
70  if (elecExtras.existsAs<std::string>("select")) {
72  elecExtras.getParameter<std::string>("select")));
73  }
74  // isolation is optional; in case it's not found no
75  // isolation will be applied
76  if (elecExtras.existsAs<std::string>("isolation")) {
78  elecExtras.getParameter<std::string>("isolation")));
79  }
80  // electronId is optional; in case it's not found the
81  // InputTag will remain empty
82  if (elecExtras.existsAs<edm::ParameterSet>("electronId")) {
83  edm::ParameterSet elecId =
84  elecExtras.getParameter<edm::ParameterSet>("electronId");
85  electronId_ = iC.consumes<edm::ValueMap<float> >(
86  elecId.getParameter<edm::InputTag>("src"));
87  eidCutValue_ = elecId.getParameter<double>("cutValue");
88  }
89  }
90  // pvExtras are opetional; they may be omitted or empty
91  if (cfg.existsAs<edm::ParameterSet>("pvExtras")) {
92  edm::ParameterSet pvExtras =
93  cfg.getParameter<edm::ParameterSet>("pvExtras");
94  // select is optional; in case it's not found no
95  // selection will be applied
96  if (pvExtras.existsAs<std::string>("select")) {
98  pvExtras.getParameter<std::string>("select")));
99  }
100  }
101  // muonExtras are optional; they may be omitted or empty
102  if (cfg.existsAs<edm::ParameterSet>("muonExtras")) {
103  edm::ParameterSet muonExtras =
104  cfg.getParameter<edm::ParameterSet>("muonExtras");
105  // select is optional; in case it's not found no
106  // selection will be applied
107  if (muonExtras.existsAs<std::string>("select")) {
109  muonExtras.getParameter<std::string>("select")));
110  }
111  // isolation is optional; in case it's not found no
112  // isolation will be applied
113  if (muonExtras.existsAs<std::string>("isolation")) {
115  muonExtras.getParameter<std::string>("isolation")));
116  }
117  }
118 
119  // jetExtras are optional; they may be omitted or
120  // empty
121  if (cfg.existsAs<edm::ParameterSet>("jetExtras")) {
122  edm::ParameterSet jetExtras =
123  cfg.getParameter<edm::ParameterSet>("jetExtras");
124  // jetCorrector is optional; in case it's not found
125  // the InputTag will remain empty
126  if (jetExtras.existsAs<std::string>("jetCorrector")) {
127  jetCorrector_ = jetExtras.getParameter<std::string>("jetCorrector");
128  }
129  // read jetID information if it exists
130  if (jetExtras.existsAs<edm::ParameterSet>("jetID")) {
131  edm::ParameterSet jetID =
132  jetExtras.getParameter<edm::ParameterSet>("jetID");
133  jetIDLabel_ = iC.consumes<reco::JetIDValueMap>(
134  jetID.getParameter<edm::InputTag>("label"));
136  jetID.getParameter<std::string>("select")));
137  }
138  // select is optional; in case it's not found no
139  // selection will be applied (only implemented for
140  // CaloJets at the moment)
141  if (jetExtras.existsAs<std::string>("select")) {
142  jetSelect_ = jetExtras.getParameter<std::string>("select");
144  }
145  }
146 
147  // triggerExtras are optional; they may be omitted or empty
148  if (cfg.existsAs<edm::ParameterSet>("triggerExtras")) {
149  edm::ParameterSet triggerExtras =
150  cfg.getParameter<edm::ParameterSet>("triggerExtras");
151  triggerTable_ = iC.consumes<edm::TriggerResults>(
152  triggerExtras.getParameter<edm::InputTag>("src"));
153  triggerPaths_ =
154  triggerExtras.getParameter<std::vector<std::string> >("paths");
155  }
156 
157  // massExtras is optional; in case it's not found no mass
158  // window cuts are applied for the same flavor monitor
159  // histograms
160  if (cfg.existsAs<edm::ParameterSet>("massExtras")) {
161  edm::ParameterSet massExtras =
162  cfg.getParameter<edm::ParameterSet>("massExtras");
163  lowerEdge_ = massExtras.getParameter<double>("lowerEdge");
164  upperEdge_ = massExtras.getParameter<double>("upperEdge");
165  }
166 
167  // setup the verbosity level for booking histograms;
168  // per default the verbosity level will be set to
169  // STANDARD. This will also be the chosen level in
170  // the case when the monitoring PSet is not found
172  if (cfg.existsAs<edm::ParameterSet>("monitoring")) {
174  cfg.getParameter<edm::ParameterSet>("monitoring");
175  if (monitoring.getParameter<std::string>("verbosity") == "DEBUG")
176  verbosity_ = DEBUG;
177  if (monitoring.getParameter<std::string>("verbosity") == "VERBOSE")
178  verbosity_ = VERBOSE;
179  if (monitoring.getParameter<std::string>("verbosity") == "STANDARD")
180  verbosity_ = STANDARD;
181  }
182  // and don't forget to do the histogram booking
183  directory_ = cfg.getParameter<std::string>("directory");
184  // book(ibooker);
185 }
186 
188  // set up the current directory path
189  std::string current(directory_);
190  current += label_;
191  ibooker.setCurrentFolder(current);
192 
193  // determine number of bins for trigger monitoring
194  unsigned int nPaths = triggerPaths_.size();
195 
196  // --- [STANDARD] --- //
197  // Run Number
198  hists_["RunNumb_"] = ibooker.book1D("RunNumber", "Run Nr.", 1.e4, 1.5e5, 3.e5);
199  // instantaneous luminosity
200  hists_["InstLumi_"] = ibooker.book1D("InstLumi", "Inst. Lumi.", 100, 0., 1.e3);
201  // number of selected primary vertices
202  hists_["pvMult_"] = ibooker.book1D("PvMult", "N_{pvs}", 100, 0., 100.);
203  // pt of the leading muon
204  hists_["muonPt_"] = ibooker.book1D("MuonPt", "pt(#mu)", 50, 0., 250.);
205  // muon multiplicity before std isolation
206  hists_["muonMult_"] = ibooker.book1D("MuonMult", "N_{All}(#mu)", 10, 0., 10.);
207  // muon multiplicity after std isolation
208  hists_["muonMultIso_"] = ibooker.book1D("MuonMultIso",
209  "N_{Iso}(#mu)", 10, 0., 10.);
210  // pt of the leading electron
211  hists_["elecPt_"] = ibooker.book1D("ElecPt", "pt(e)", 50, 0., 250.);
212  // electron multiplicity before std isolation
213  hists_["elecMult_"] = ibooker.book1D("ElecMult", "N_{All}(e)", 10, 0., 10.);
214  // electron multiplicity after std isolation
215  hists_["elecMultIso_"] = ibooker.book1D("ElecMultIso", "N_{Iso}(e)", 10, 0., 10.);
216  // multiplicity of jets with pt>20 (corrected to L2+L3)
217  hists_["jetMult_"] = ibooker.book1D("JetMult", "N_{30}(jet)", 10, 0., 10.);
218  // trigger efficiency estimates for single lepton triggers
219  hists_["triggerEff_"] = ibooker.book1D("TriggerEff",
220  "Eff(trigger)", nPaths, 0., nPaths);
221  // monitored trigger occupancy for single lepton triggers
222  hists_["triggerMon_"] = ibooker.book1D("TriggerMon",
223  "Mon(trigger)", nPaths, 0., nPaths);
224  // MET (calo)
225  hists_["slimmedMETs_"] = ibooker.book1D("slimmedMETs", "MET_{slimmed}", 50, 0., 200.);
226  // W mass estimate
227  hists_["massW_"] = ibooker.book1D("MassW", "M(W)", 60, 0., 300.);
228  // Top mass estimate
229  hists_["massTop_"] = ibooker.book1D("MassTop", "M(Top)", 50, 0., 500.);
230  // b-tagged Top mass
231  hists_["massBTop_"] = ibooker.book1D("MassBTop", "M(Top, 1 b-tag)", 50, 0., 500.);
232  // set bin labels for trigger monitoring
234 
235  if (verbosity_ == STANDARD) return;
236 
237  // --- [VERBOSE] --- //
238  // eta of the leading muon
239  hists_["muonEta_"] = ibooker.book1D("MuonEta", "#eta(#mu)", 30, -3., 3.);
240  // relative isolation of the candidate muon (depending on the decay channel)
241  hists_["muonRelIso_"] = ibooker.book1D(
242  "MuonRelIso", "Iso_{Rel}(#mu) (#Delta#beta Corrected)", 50, 0., 1.);
243  // eta of the leading electron
244  hists_["elecEta_"] = ibooker.book1D("ElecEta", "#eta(e)", 30, -3., 3.);
245  // std isolation variable of the leading electron
246  hists_["elecRelIso_"] = ibooker.book1D("ElecRelIso", "Iso_{Rel}(e)", 50, 0., 1.);
247  // multiplicity of btagged jets (for track counting high efficiency) with
248  // pt(L2L3)>30
249  hists_["jetMultBEff_"] = ibooker.book1D("JetMultBEff",
250  "N_{30}(TCHE)", 10, 0., 10.);
251  // btag discriminator for track counting high efficiency for jets with
252  // pt(L2L3)>30
253  hists_["jetBDiscEff_"] = ibooker.book1D("JetBDiscEff",
254  "Disc_{TCHE}(jet)", 100, 0., 10.);
255  // eta of the 1. leading jet (corrected to L2+L3)
256  hists_["jet1Eta_"] = ibooker.book1D("Jet1Eta", "#eta_{L2L3}(jet1)", 60, -3., 3.);
257  // pt of the 1. leading jet (corrected to L2+L3)
258  hists_["jet1Pt_"] = ibooker.book1D("Jet1Pt", "pt_{L2L3}(jet1)", 60, 0., 300.);
259  // eta of the 2. leading jet (corrected to L2+L3)
260  hists_["jet2Eta_"] = ibooker.book1D("Jet2Eta", "#eta_{L2L3}(jet2)", 60, -3., 3.);
261  // pt of the 2. leading jet (corrected to L2+L3)
262  hists_["jet2Pt_"] = ibooker.book1D("Jet2Pt", "pt_{L2L3}(jet2)", 60, 0., 300.);
263  // eta of the 3. leading jet (corrected to L2+L3)
264  hists_["jet3Eta_"] = ibooker.book1D("Jet3Eta", "#eta_{L2L3}(jet3)", 60, -3., 3.);
265  // pt of the 3. leading jet (corrected to L2+L3)
266  hists_["jet3Pt_"] = ibooker.book1D("Jet3Pt", "pt_{L2L3}(jet3)", 60, 0., 300.);
267  // eta of the 4. leading jet (corrected to L2+L3)
268  hists_["jet4Eta_"] = ibooker.book1D("Jet4Eta", "#eta_{L2L3}(jet4)", 60, -3., 3.);
269  // pt of the 4. leading jet (corrected to L2+L3)
270  hists_["jet4Pt_"] = ibooker.book1D("Jet4Pt", "pt_{L2L3}(jet4)", 60, 0., 300.);
271  // MET (tc)
272  hists_["slimmedMETsNoHF_"] = ibooker.book1D("slimmedMETsNoHF", "MET_{slimmedNoHF}", 50, 0., 200.);
273  // MET (pflow)
274  hists_["slimmedMETsPuppi_"] = ibooker.book1D("slimmedMETsPuppi", "MET_{slimmedPuppi}", 50, 0., 200.);
275  // dz for muons (to suppress cosmis)
276  hists_["muonDelZ_"] = ibooker.book1D("MuonDelZ", "d_{z}(#mu)", 50, -25., 25.);
277  // dxy for muons (to suppress cosmics)
278  hists_["muonDelXY_"] = ibooker.book2D("MuonDelXY",
279  "d_{xy}(#mu)", 50, -0.1, 0.1, 50, -0.1, 0.1);
280 
281  // set axes titles for dxy for muons
282  hists_["muonDelXY_"]->setAxisTitle("x [cm]", 1);
283  hists_["muonDelXY_"]->setAxisTitle("y [cm]", 2);
284 
285  if (verbosity_ == VERBOSE) return;
286 
287  // --- [DEBUG] --- //
288  // charged hadron isolation component of the candidate muon (depending on the
289  // decay channel)
290  hists_["muonChHadIso_"] = ibooker.book1D("MuonChHadIsoComp",
291  "ChHad_{IsoComponent}(#mu)", 50, 0., 5.);
292  // neutral hadron isolation component of the candidate muon (depending on the
293  // decay channel)
294  hists_["muonNeHadIso_"] = ibooker.book1D("MuonNeHadIsoComp",
295  "NeHad_{IsoComponent}(#mu)", 50, 0., 5.);
296  // photon isolation component of the candidate muon (depending on the decay
297  // channel)
298  hists_["muonPhIso_"] = ibooker.book1D("MuonPhIsoComp",
299  "Photon_{IsoComponent}(#mu)", 50, 0., 5.);
300  // charged hadron isolation component of the candidate electron (depending on
301  // the decay channel)
302  hists_["elecChHadIso_"] = ibooker.book1D("ElectronChHadIsoComp",
303  "ChHad_{IsoComponent}(e)", 50, 0., 5.);
304  // neutral hadron isolation component of the candidate electron (depending on
305  // the decay channel)
306  hists_["elecNeHadIso_"] = ibooker.book1D("ElectronNeHadIsoComp",
307  "NeHad_{IsoComponent}(e)", 50, 0., 5.);
308  // photon isolation component of the candidate electron (depending on the
309  // decay channel)
310  hists_["elecPhIso_"] = ibooker.book1D("ElectronPhIsoComp",
311  "Photon_{IsoComponent}(e)", 50, 0., 5.);
312  // multiplicity of btagged jets (for track counting high purity) with
313  // pt(L2L3)>30
314  hists_["jetMultBPur_"] = ibooker.book1D("JetMultBPur",
315  "N_{30}(TCHP)", 10, 0., 10.);
316  // btag discriminator for track counting high purity
317  hists_["jetBDiscPur_"] = ibooker.book1D("JetBDiscPur",
318  "Disc_{TCHP}(Jet)", 100, 0., 10.);
319  // multiplicity of btagged jets (for simple secondary vertex) with pt(L2L3)>30
320  hists_["jetMultBVtx_"] = ibooker.book1D("JetMultBVtx",
321  "N_{30}(SSVHE)", 10, 0., 10.);
322  // btag discriminator for simple secondary vertex
323  hists_["jetBDiscVtx_"] = ibooker.book1D("JetBDiscVtx",
324  "Disc_{SSVHE}(Jet)", 35, -1., 6.);
325  // multiplicity for combined secondary vertex
326  hists_["jetMultCSVtx_"] = ibooker.book1D("JetMultCSV", "N_{30}(CSV)", 10, 0., 10.);
327  // btag discriminator for combined secondary vertex
328  hists_["jetBCVtx_"] = ibooker.book1D("JetDiscCSV",
329  "Disc_{CSV}(JET)", 100, -1., 2.);
330  // pt of the 1. leading jet (uncorrected)
331  hists_["jet1PtRaw_"] = ibooker.book1D("Jet1PtRaw", "pt_{Raw}(jet1)", 60, 0., 300.);
332  // pt of the 2. leading jet (uncorrected)
333  hists_["jet2PtRaw_"] = ibooker.book1D("Jet2PtRaw", "pt_{Raw}(jet2)", 60, 0., 300.);
334  // pt of the 3. leading jet (uncorrected)
335  hists_["jet3PtRaw_"] = ibooker.book1D("Jet3PtRaw", "pt_{Raw}(jet3)", 60, 0., 300.);
336  // pt of the 4. leading jet (uncorrected)
337  hists_["jet4PtRaw_"] = ibooker.book1D("Jet4PtRaw", "pt_{Raw}(jet4)", 60, 0., 300.);
338  // selected events
339  hists_["eventLogger_"] = ibooker.book2D("EventLogger",
340  "Logged Events", 9, 0., 9., 10, 0., 10.);
341 
342  // set axes titles for selected events
343  hists_["eventLogger_"]->getTH1()->SetOption("TEXT");
344  hists_["eventLogger_"]->setBinLabel(1, "Run", 1);
345  hists_["eventLogger_"]->setBinLabel(2, "Block", 1);
346  hists_["eventLogger_"]->setBinLabel(3, "Event", 1);
347  hists_["eventLogger_"]->setBinLabel(4, "pt_{L2L3}(jet1)", 1);
348  hists_["eventLogger_"]->setBinLabel(5, "pt_{L2L3}(jet2)", 1);
349  hists_["eventLogger_"]->setBinLabel(6, "pt_{L2L3}(jet3)", 1);
350  hists_["eventLogger_"]->setBinLabel(7, "pt_{L2L3}(jet4)", 1);
351  hists_["eventLogger_"]->setBinLabel(8, "M_{W}", 1);
352  hists_["eventLogger_"]->setBinLabel(9, "M_{Top}", 1);
353  hists_["eventLogger_"]->setAxisTitle("logged evts", 2);
354  return;
355 }
356 
358  const edm::EventSetup& setup) {
359  // fetch trigger event if configured such
361 
363  if (!event.getByToken(triggerTable_, triggerTable)) return;
364  }
365 
366  /*
367  ------------------------------------------------------------
368 
369  Primary Vertex Monitoring
370 
371  ------------------------------------------------------------
372  */
373  // fill monitoring plots for primary verices
375  if (!event.getByToken(pvs_, pvs)) return;
376  unsigned int pvMult = 0;
377  for (edm::View<reco::Vertex>::const_iterator pv = pvs->begin();
378  pv != pvs->end(); ++pv) {
379  if (!pvSelect_ || (*pvSelect_)(*pv)) pvMult++;
380  }
381  fill("pvMult_", pvMult);
382 
383  /*
384  ------------------------------------------------------------
385 
386  Run and Inst. Luminosity information (Inst. Lumi. filled now with a dummy
387  value=5.0)
388 
389  ------------------------------------------------------------
390  */
391  if (!event.eventAuxiliary().run()) return;
392  fill("RunNumb_", event.eventAuxiliary().run());
393 
394  double dummy = 5.;
395  fill("InstLumi_", dummy);
396 
397  /*
398  ------------------------------------------------------------
399 
400  Electron Monitoring
401 
402  ------------------------------------------------------------
403  */
404 
405  // fill monitoring plots for electrons
407  if (!event.getByToken(elecs_, elecs)) return;
408 
409  // check availability of electron id
411  if (!electronId_.isUninitialized()) {
412  if (!event.getByToken(electronId_, electronId)) return;
413  }
414 
415  // loop electron collection
416  unsigned int eMult = 0, eMultIso = 0;
417  std::vector<const pat::Electron*> isoElecs;
418 
419 
420  for (edm::View<pat::Electron>::const_iterator elec = elecs->begin();
421  elec != elecs->end(); ++elec) {
422 
423  if(true){//no electron id applied yet!
424  if (!elecSelect_ || (*elecSelect_)(*elec)) {
425 
426  double el_ChHadIso = elec->pfIsolationVariables().sumChargedHadronPt;
427  double el_NeHadIso = elec->pfIsolationVariables().sumNeutralHadronEt;
428  double el_PhIso = elec->pfIsolationVariables().sumPhotonEt;
429  double el_pfRelIso =
430  (el_ChHadIso +
431  max(0., el_NeHadIso + el_PhIso -
432  0.5 * elec->pfIsolationVariables().sumPUPt)) /
433  elec->pt();
434  if (eMult == 0) {
435  // restrict to the leading electron
436  fill("elecPt_", elec->pt());
437  fill("elecEta_", elec->eta());
438  fill("elecRelIso_", el_pfRelIso);
439  fill("elecChHadIso_", el_ChHadIso);
440  fill("elecNeHadIso_", el_NeHadIso);
441  fill("elecPhIso_", el_PhIso);
442  }
443 
444  ++eMult;
445  if (!elecIso_ || (*elecIso_)(*elec)) {
446  isoElecs.push_back(&(*elec));
447  ++eMultIso;
448  }
449  }
450  }
451  }
452  fill("elecMult_", eMult);
453  fill("elecMultIso_", eMultIso);
454 
455  /*
456  ------------------------------------------------------------
457 
458  Muon Monitoring
459 
460  ------------------------------------------------------------
461  */
462 
463  // fill monitoring plots for muons
464  unsigned int mMult = 0, mMultIso = 0;
465 
468 
469  if (!event.getByToken(muons_, muons)) return;
470 
471 
472 
473  for (edm::View<pat::Muon>::const_iterator muon = muons->begin();
474  muon != muons->end(); ++muon) {
475 
476 
477  // restrict to globalMuons
478  if (muon->isGlobalMuon()) {
479  fill("muonDelZ_", muon->innerTrack()->vz()); // CB using inner track!
480  fill("muonDelXY_", muon->innerTrack()->vx(), muon->innerTrack()->vy());
481 
482 
483 
484  // apply preselection
485  if (!muonSelect_ || (*muonSelect_)(*muon)) {
486 
487 
488  double chHadPt = muon->pfIsolationR04().sumChargedHadronPt;
489  double neHadEt = muon->pfIsolationR04().sumNeutralHadronEt;
490  double phoEt = muon->pfIsolationR04().sumPhotonEt;
491 
492  double pfRelIso =
493  (chHadPt +
494  max(0., neHadEt + phoEt - 0.5 * muon->pfIsolationR04().sumPUPt)) /
495  muon->pt(); // CB dBeta corrected iso!
496 
497  if (mMult == 0) {
498  // restrict to leading muon
499  fill("muonPt_", muon->pt());
500  fill("muonEta_", muon->eta());
501 
502  fill("muonRelIso_", pfRelIso);
503 
504  fill("muonChHadIso_", chHadPt);
505  fill("muonNeHadIso_", neHadEt);
506  fill("muonPhIso_", phoEt);
507  }
508  ++mMult;
509  if (!muonIso_ || (*muonIso_)(*muon)) ++mMultIso;
510  }
511  }
512  }
513  fill("muonMult_", mMult);
514  fill("muonMultIso_", mMultIso);
515 
516  /*
517  ------------------------------------------------------------
518 
519  Jet Monitoring
520 
521  ------------------------------------------------------------
522  */
523 
524 
525  // loop jet collection
526  std::vector<pat::Jet> correctedJets;
527  std::vector<double> JetTagValues;
528  unsigned int mult = 0, multBEff = 0, multBPur = 0, multBVtx = 0, multCSV = 0;
529 
531  if (!event.getByToken(jets_, jets)) {
532  return;
533  }
534 
535  for (edm::View<pat::Jet>::const_iterator jet = jets->begin();
536  jet != jets->end(); ++jet) {
537  // check jetID for calo jets
538  unsigned int idx = jet - jets->begin();
539 
540  pat::Jet sel = *jet;
541 
542  if(!(*jetSelect)(sel))continue;
543 // if (!jetSelect(sel)) continue;
544 
545  // prepare jet to fill monitor histograms
546  pat::Jet monitorJet = *jet;
547 
548  correctedJets.push_back(monitorJet);
549  ++mult; // determine jet multiplicity
550 
551  fill("jetBDiscEff_", monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags")); //hard coded discriminator and value right now.
552  if (monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags") > 0.89) ++multBEff;
553 
554 
555  // Fill a vector with Jet b-tag WP for later M3+1tag calculation: CSV
556  // tagger
557  JetTagValues.push_back(monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags"));
558 // }
559  // fill pt (raw or L2L3) for the leading four jets
560  if (idx == 0) {
561  fill("jet1Pt_", monitorJet.pt());
562  fill("jet1PtRaw_", jet->pt());
563  fill("jet1Eta_", monitorJet.eta());
564  };
565  if (idx == 1) {
566  fill("jet2Pt_", monitorJet.pt());
567  fill("jet2PtRaw_", jet->pt());
568  fill("jet2Eta_", monitorJet.eta());
569  }
570  if (idx == 2) {
571  fill("jet3Pt_", monitorJet.pt());
572  fill("jet3PtRaw_", jet->pt());
573  fill("jet3Eta_", monitorJet.eta());
574  }
575  if (idx == 3) {
576  fill("jet4Pt_", monitorJet.pt());
577  fill("jet4PtRaw_", jet->pt());
578  fill("jet4Eta_", monitorJet.eta());
579  }
580  }
581  fill("jetMult_", mult);
582  fill("jetMultBEff_", multBEff);
583  fill("jetMultBPur_", multBPur);
584  fill("jetMultBVtx_", multBVtx);
585  fill("jetMultCSVtx_", multCSV);
586 
587  /*
588  ------------------------------------------------------------
589 
590  MET Monitoring
591 
592  ------------------------------------------------------------
593  */
594 
595  // fill monitoring histograms for met
596  for (std::vector<edm::EDGetTokenT<edm::View<pat::MET> > >::const_iterator
597  met_ = mets_.begin();
598  met_ != mets_.end(); ++met_) {
600  if (!event.getByToken(*met_, met)) continue;
601  if (met->begin() != met->end()) {
602  unsigned int idx = met_ - mets_.begin();
603  if (idx == 0) fill("slimmedMETs_", met->begin()->et());
604  if (idx == 1) fill("slimmedMETsNoHF_", met->begin()->et());
605  if (idx == 2) fill("slimmedMETsPuppi_", met->begin()->et());
606  }
607  }
608 
609  /*
610  ------------------------------------------------------------
611 
612  Event Monitoring
613 
614  ------------------------------------------------------------
615  */
616 
617  // fill W boson and top mass estimates
618 
619  Calculate_miniAOD eventKinematics(MAXJETS, WMASS);
620  double wMass = eventKinematics.massWBoson(correctedJets);
621  double topMass = eventKinematics.massTopQuark(correctedJets);
622  if (wMass >= 0 && topMass >= 0) {
623  fill("massW_", wMass);
624  fill("massTop_", topMass);
625  }
626 
627  // Fill M3 with Btag (CSV Tight) requirement
628 
629  // if (!includeBTag_) return;
630  if (correctedJets.size() != JetTagValues.size()) return;
631  double btopMass =
632  eventKinematics.massBTopQuark(correctedJets, JetTagValues, 0.89); //hard coded CSVv2 value
633 
634  if (btopMass >= 0) fill("massBTop_", btopMass);
635 
636 }
637 }
638 
640  : vertexSelect_(nullptr),
641  beamspot_(""),
642  beamspotSelect_(nullptr),
643  MuonStep(nullptr),
644  ElectronStep(nullptr),
645  PvStep(nullptr),
646  METStep(nullptr) {
647  JetSteps.clear();
648 
649  // configure preselection
650  edm::ParameterSet presel =
651  cfg.getParameter<edm::ParameterSet>("preselection");
652  if (presel.existsAs<edm::ParameterSet>("trigger")) {
654  presel.getParameter<edm::ParameterSet>("trigger");
655  triggerTable__ = consumes<edm::TriggerResults>(
656  trigger.getParameter<edm::InputTag>("src"));
657  triggerPaths_ = trigger.getParameter<std::vector<std::string> >("select");
658  }
659  if (presel.existsAs<edm::ParameterSet>("beamspot")) {
661  presel.getParameter<edm::ParameterSet>("beamspot");
662  beamspot_ = beamspot.getParameter<edm::InputTag>("src");
663  beamspot__ =
664  consumes<reco::BeamSpot>(beamspot.getParameter<edm::InputTag>("src"));
666  beamspot.getParameter<std::string>("select")));
667  }
668 
669  // conifgure the selection
670  sel_ = cfg.getParameter<std::vector<edm::ParameterSet> >("selection");
671  setup_ = cfg.getParameter<edm::ParameterSet>("setup");
672  for (unsigned int i = 0; i < sel_.size(); ++i) {
673  selectionOrder_.push_back(sel_.at(i).getParameter<std::string>("label"));
674  selection_[selectionStep(selectionOrder_.back())] = std::make_pair(
675  sel_.at(i),
676  std::unique_ptr<TopSingleLepton_miniAOD::MonitorEnsemble>(
678  selectionStep(selectionOrder_.back()).c_str(),
680  }
681  for (std::vector<std::string>::const_iterator selIt = selectionOrder_.begin();
682  selIt != selectionOrder_.end(); ++selIt) {
683  std::string key = selectionStep(*selIt), type = objectType(*selIt);
684  if (selection_.find(key) != selection_.end()) {
685  if (type == "muons") {
687  consumesCollector()));
688  }
689  if (type == "elecs") {
692  }
693  if (type == "pvs") {
695  consumesCollector()));
696  }
697  if (type == "jets") {
698  JetSteps.push_back(std::unique_ptr<SelectionStep<pat::Jet>>(
700  }
701 
702  if (type == "met") {
704  consumesCollector()));
705  }
706  }
707  }
708 }
710  edm::Run const &, edm::EventSetup const & ){
711 
712  for (auto selIt = selection_.begin(); selIt != selection_.end(); ++selIt) {
713  selIt->second.second->book(ibooker);
714  }
715 }
717  const edm::EventSetup& setup) {
718 
721  if (!event.getByToken(triggerTable__, triggerTable)) return;
722  if (!accept(event, *triggerTable, triggerPaths_)) return;
723  }
724  if (!beamspot__.isUninitialized()) {
726  if (!event.getByToken(beamspot__, beamspot)) return;
727  if (!(*beamspotSelect_)(*beamspot)) return;
728  }
729 
730  unsigned int passed = 0;
731  unsigned int nJetSteps = -1;
732 
733  for (std::vector<std::string>::const_iterator selIt = selectionOrder_.begin();
734  selIt != selectionOrder_.end(); ++selIt) {
735  std::string key = selectionStep(*selIt), type = objectType(*selIt);
736  if (selection_.find(key) != selection_.end()) {
737  if (type == "empty") {
738  selection_[key].second->fill(event, setup);
739  }
740  if (type == "muons" && MuonStep != 0) {
741  if (MuonStep->select(event)) {
742  ++passed;
743 
744  selection_[key].second->fill(event, setup);
745  } else
746  break;
747  }
748 
749  if (type == "elecs" && ElectronStep != 0) {
750 
751  if (ElectronStep->select(event)) {
752  ++passed;
753  selection_[key].second->fill(event, setup);
754  } else
755  break;
756  }
757 
758  if (type == "pvs" && PvStep != 0) {
759  if (PvStep->selectVertex(event)) {
760  ++passed;
761  selection_[key].second->fill(event, setup);
762  } else
763  break;
764  }
765 
766  if (type == "jets") {
767  nJetSteps++;
768  if (JetSteps[nJetSteps] != NULL) {
769  if (JetSteps[nJetSteps]->select(event, setup)) {
770  ++passed;
771  selection_[key].second->fill(event, setup);
772  } else
773  break;
774  }
775  }
776 
777  if (type == "met" && METStep != 0) {
778  if (METStep->select(event)) {
779  ++passed;
780  selection_[key].second->fill(event, setup);
781  } else
782  break;
783  }
784  }
785  }
786 }
787 
788 // Local Variables:
789 // show-trailing-whitespace: t
790 // truncate-lines: t
791 // End:
type
Definition: HCALResponse.h:21
std::unique_ptr< StringCutObjectSelector< pat::Muon > > muonIso_
extra isolation criterion on muon
T getParameter(std::string const &) const
virtual double pt() const final
transverse momentum
std::unique_ptr< StringCutObjectSelector< reco::JetID > > jetIDSelect_
extra jetID selection on calo jets
std::vector< edm::EDGetTokenT< edm::View< pat::MET > > > mets_
considers a vector of METs
std::unique_ptr< StringCutObjectSelector< pat::Muon > > muonSelect_
extra selection on muons
EventAuxiliary const & eventAuxiliary() const override
Definition: Event.h:78
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
std::unique_ptr< SelectionStep< reco::Vertex > > PvStep
std::string objectType(const std::string &label)
std::unique_ptr< StringCutObjectSelector< pat::Electron > > elecIso_
extra isolation criterion on electron
edm::EDGetTokenT< edm::View< pat::Jet > > jets_
input sources for monitoring
virtual double eta() const final
momentum pseudorapidity
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:460
edm::EDGetTokenT< edm::ValueMap< float > > electronId_
electronId label
void triggerBinLabels(std::string channel, const std::vector< std::string > labels)
set configurable labels for trigger monitoring histograms
edm::EDGetTokenT< edm::View< pat::Electron > > elecs_
static const unsigned int MAXJETS
RunNumber_t run() const
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
#define NULL
Definition: scimark2.h:8
std::unique_ptr< StringCutObjectSelector< reco::BeamSpot > > beamspotSelect_
string cut selector
std::map< std::string, std::pair< edm::ParameterSet, std::unique_ptr< TopSingleLepton_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
std::vector< edm::ParameterSet > sel_
std::vector< std::string > selectionOrder_
TopSingleLeptonDQM_miniAOD(const edm::ParameterSet &cfg)
default constructor
edm::EDGetTokenT< reco::BeamSpot > beamspot__
std::string selectionStep(const std::string &label)
std::unique_ptr< StringCutObjectSelector< pat::Jet > > jetSelect
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
std::unique_ptr< StringCutObjectSelector< reco::Vertex > > pvSelect_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
vector< PseudoJet > jets
edm::EDGetTokenT< edm::TriggerResults > triggerTable_
trigger table
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
def pv(vc)
Definition: MetAnalyzer.py:6
std::map< std::string, MonitorElement * > hists_
histogram container
std::vector< std::string > triggerPaths_
trigger paths
std::unique_ptr< SelectionStep< pat::MET > > METStep
std::vector< std::unique_ptr< SelectionStep< pat::Jet > > > JetSteps
virtual void analyze(const edm::Event &event, const edm::EventSetup &setup) override
do this during the event loop
std::unique_ptr< SelectionStep< pat::Muon > > MuonStep
edm::EDGetTokenT< edm::View< pat::Muon > > muons_
void fill(const edm::Event &event, const edm::EventSetup &setup)
fill monitor histograms with electronId and jetCorrections
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
edm::EDGetTokenT< edm::View< reco::Vertex > > pvs_
met
===> hadronic RAZOR
double lowerEdge_
mass window upper and lower edge
void book(DQMStore::IBooker &ibooker)
book histograms in subdirectory directory
Analysis-level calorimeter jet class.
Definition: Jet.h:78
Templated helper class to allow a selection on a certain object collection.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
bool isUninitialized() const
Definition: EDGetToken.h:73
std::unique_ptr< StringCutObjectSelector< pat::Electron > > elecSelect_
extra selection on electrons
Level verbosity_
verbosity level for booking
std::unique_ptr< SelectionStep< pat::Electron > > ElectronStep
edm::EDGetTokenT< edm::TriggerResults > triggerTable__
trigger table
Definition: event.py:1
Definition: Run.h:42
edm::EDGetTokenT< reco::JetIDValueMap > jetIDLabel_
jetID as an extra selection type