CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TopSingleLeptonDQM.cc
Go to the documentation of this file.
7 #include <iostream>
11 
12 using namespace std;
13 namespace TopSingleLepton {
14 
15 // maximal number of leading jets
16 // to be used for top mass estimate
17 static const unsigned int MAXJETS = 4;
18 // nominal mass of the W boson to
19 // be used for the top mass estimate
20 static const double WMASS = 80.4;
21 
22 MonitorEnsemble::MonitorEnsemble(const char* label,
23  const edm::ParameterSet& cfg,
25  : label_(label),
26  elecIso_(nullptr),
27  elecSelect_(nullptr),
28  pvSelect_(nullptr),
29  muonIso_(nullptr),
30  muonSelect_(nullptr),
31  jetIDSelect_(nullptr),
32  includeBTag_(false),
33  lowerEdge_(-1.),
34  upperEdge_(-1.),
35  logged_(0) {
36 
37  // sources have to be given; this PSet is not optional
38  edm::ParameterSet sources = cfg.getParameter<edm::ParameterSet>("sources");
39  muons_ = iC.consumes<edm::View<reco::PFCandidate> >(
40  sources.getParameter<edm::InputTag>("muons"));
41  elecs_ = iC.consumes<edm::View<reco::PFCandidate> >(
42  sources.getParameter<edm::InputTag>("elecs"));
43  pvs_ = iC.consumes<edm::View<reco::Vertex> >(
44  sources.getParameter<edm::InputTag>("pvs"));
45  jets_ = iC.consumes<edm::View<reco::Jet> >(
46  sources.getParameter<edm::InputTag>("jets"));
47  for (edm::InputTag const& tag :
48  sources.getParameter<std::vector<edm::InputTag> >("mets"))
49  mets_.push_back(iC.consumes<edm::View<reco::MET> >(tag));
50  // electronExtras are optional; they may be omitted or
51  // empty
52  if (cfg.existsAs<edm::ParameterSet>("elecExtras")) {
53  // rho for PF isolation with EA corrections
54  // eventrhoToken_ =
55  // iC.consumes<double>(edm::InputTag("fixedGridRhoFastjetAll"));
56 
57  edm::ParameterSet elecExtras =
58  cfg.getParameter<edm::ParameterSet>("elecExtras");
59  // select is optional; in case it's not found no
60  // selection will be applied
61  if (elecExtras.existsAs<std::string>("select")) {
63  elecExtras.getParameter<std::string>("select")));
64  }
65  // isolation is optional; in case it's not found no
66  // isolation will be applied
67  if (elecExtras.existsAs<std::string>("isolation")) {
69  elecExtras.getParameter<std::string>("isolation")));
70  }
71  // electronId is optional; in case it's not found the
72  // InputTag will remain empty
73  if (elecExtras.existsAs<edm::ParameterSet>("electronId")) {
74  edm::ParameterSet elecId =
75  elecExtras.getParameter<edm::ParameterSet>("electronId");
76  electronId_ = iC.consumes<edm::ValueMap<float> >(
77  elecId.getParameter<edm::InputTag>("src"));
78  eidCutValue_ = elecId.getParameter<double>("cutValue");
79  }
80  }
81  // pvExtras are opetional; they may be omitted or empty
82  if (cfg.existsAs<edm::ParameterSet>("pvExtras")) {
83  edm::ParameterSet pvExtras =
84  cfg.getParameter<edm::ParameterSet>("pvExtras");
85  // select is optional; in case it's not found no
86  // selection will be applied
87  if (pvExtras.existsAs<std::string>("select")) {
89  pvExtras.getParameter<std::string>("select")));
90  }
91  }
92  // muonExtras are optional; they may be omitted or empty
93  if (cfg.existsAs<edm::ParameterSet>("muonExtras")) {
94  edm::ParameterSet muonExtras =
95  cfg.getParameter<edm::ParameterSet>("muonExtras");
96  // select is optional; in case it's not found no
97  // selection will be applied
98  if (muonExtras.existsAs<std::string>("select")) {
100  muonExtras.getParameter<std::string>("select")));
101  }
102  // isolation is optional; in case it's not found no
103  // isolation will be applied
104  if (muonExtras.existsAs<std::string>("isolation")) {
106  muonExtras.getParameter<std::string>("isolation")));
107  }
108  }
109 
110  // jetExtras are optional; they may be omitted or
111  // empty
112  if (cfg.existsAs<edm::ParameterSet>("jetExtras")) {
113  edm::ParameterSet jetExtras =
114  cfg.getParameter<edm::ParameterSet>("jetExtras");
115  // jetCorrector is optional; in case it's not found
116  // the InputTag will remain empty
117  if (jetExtras.existsAs<std::string>("jetCorrector")) {
118  jetCorrector_ = jetExtras.getParameter<std::string>("jetCorrector");
119  }
120  // read jetID information if it exists
121  if (jetExtras.existsAs<edm::ParameterSet>("jetID")) {
123  jetExtras.getParameter<edm::ParameterSet>("jetID");
124  jetIDLabel_ = iC.consumes<reco::JetIDValueMap>(
125  jetID.getParameter<edm::InputTag>("label"));
127  jetID.getParameter<std::string>("select")));
128  }
129  // select is optional; in case it's not found no
130  // selection will be applied (only implemented for
131  // CaloJets at the moment)
132  if (jetExtras.existsAs<std::string>("select")) {
133  jetSelect_ = jetExtras.getParameter<std::string>("select");
134  }
135  // jetBDiscriminators are optional; in case they are
136  // not found the InputTag will remain empty; they
137  // consist of pairs of edm::JetFlavorAssociation's &
138  // corresponding working points
139  includeBTag_ = jetExtras.existsAs<edm::ParameterSet>("jetBTaggers");
140  if (includeBTag_) {
141  edm::ParameterSet btagEff =
142  jetExtras.getParameter<edm::ParameterSet>("jetBTaggers")
143  .getParameter<edm::ParameterSet>("trackCountingEff");
144  btagEff_ = iC.consumes<reco::JetTagCollection>(
145  btagEff.getParameter<edm::InputTag>("label"));
146  btagEffWP_ = btagEff.getParameter<double>("workingPoint");
147  edm::ParameterSet btagPur =
148  jetExtras.getParameter<edm::ParameterSet>("jetBTaggers")
149  .getParameter<edm::ParameterSet>("trackCountingPur");
150  btagPur_ = iC.consumes<reco::JetTagCollection>(
151  btagPur.getParameter<edm::InputTag>("label"));
152  btagPurWP_ = btagPur.getParameter<double>("workingPoint");
153  edm::ParameterSet btagVtx =
154  jetExtras.getParameter<edm::ParameterSet>("jetBTaggers")
155  .getParameter<edm::ParameterSet>("secondaryVertex");
156  btagVtx_ = iC.consumes<reco::JetTagCollection>(
157  btagVtx.getParameter<edm::InputTag>("label"));
158  btagVtxWP_ = btagVtx.getParameter<double>("workingPoint");
159  edm::ParameterSet btagCSV =
160  jetExtras.getParameter<edm::ParameterSet>("jetBTaggers")
161  .getParameter<edm::ParameterSet>("cvsVertex");
162  btagCSV_ = iC.consumes<reco::JetTagCollection>(
163  btagCSV.getParameter<edm::InputTag>("label"));
164  btagCSVWP_ = btagCSV.getParameter<double>("workingPoint");
165  }
166  }
167 
168  // triggerExtras are optional; they may be omitted or empty
169  if (cfg.existsAs<edm::ParameterSet>("triggerExtras")) {
170  edm::ParameterSet triggerExtras =
171  cfg.getParameter<edm::ParameterSet>("triggerExtras");
172  triggerTable_ = iC.consumes<edm::TriggerResults>(
173  triggerExtras.getParameter<edm::InputTag>("src"));
174  triggerPaths_ =
175  triggerExtras.getParameter<std::vector<std::string> >("paths");
176  }
177 
178  // massExtras is optional; in case it's not found no mass
179  // window cuts are applied for the same flavor monitor
180  // histograms
181  if (cfg.existsAs<edm::ParameterSet>("massExtras")) {
182  edm::ParameterSet massExtras =
183  cfg.getParameter<edm::ParameterSet>("massExtras");
184  lowerEdge_ = massExtras.getParameter<double>("lowerEdge");
185  upperEdge_ = massExtras.getParameter<double>("upperEdge");
186  }
187 
188  // setup the verbosity level for booking histograms;
189  // per default the verbosity level will be set to
190  // STANDARD. This will also be the chosen level in
191  // the case when the monitoring PSet is not found
193  if (cfg.existsAs<edm::ParameterSet>("monitoring")) {
194  edm::ParameterSet monitoring =
195  cfg.getParameter<edm::ParameterSet>("monitoring");
196  if (monitoring.getParameter<std::string>("verbosity") == "DEBUG")
197  verbosity_ = DEBUG;
198  if (monitoring.getParameter<std::string>("verbosity") == "VERBOSE")
200  if (monitoring.getParameter<std::string>("verbosity") == "STANDARD")
202  }
203  // and don't forget to do the histogram booking
204  directory_ = cfg.getParameter<std::string>("directory");
205  // book(ibooker);
206 }
207 
209  // set up the current directory path
211  current += label_;
212  ibooker.setCurrentFolder(current);
213 
214  // determine number of bins for trigger monitoring
215  unsigned int nPaths = triggerPaths_.size();
216 
217  // --- [STANDARD] --- //
218  // Run Number
219  hists_["RunNumb_"] = ibooker.book1D("RunNumber", "Run Nr.", 1.e4, 1.5e5, 3.e5);
220  // instantaneous luminosity
221  hists_["InstLumi_"] = ibooker.book1D("InstLumi", "Inst. Lumi.", 100, 0., 1.e3);
222  // number of selected primary vertices
223  hists_["pvMult_"] = ibooker.book1D("PvMult", "N_{pvs}", 100, 0., 100.);
224  // pt of the leading muon
225  hists_["muonPt_"] = ibooker.book1D("MuonPt", "pt(#mu)", 50, 0., 250.);
226  // muon multiplicity before std isolation
227  hists_["muonMult_"] = ibooker.book1D("MuonMult", "N_{All}(#mu)", 10, 0., 10.);
228  // muon multiplicity after std isolation
229  hists_["muonMultIso_"] = ibooker.book1D("MuonMultIso",
230  "N_{Iso}(#mu)", 10, 0., 10.);
231  // pt of the leading electron
232  hists_["elecPt_"] = ibooker.book1D("ElecPt", "pt(e)", 50, 0., 250.);
233  // electron multiplicity before std isolation
234  hists_["elecMult_"] = ibooker.book1D("ElecMult", "N_{All}(e)", 10, 0., 10.);
235  // electron multiplicity after std isolation
236  hists_["elecMultIso_"] = ibooker.book1D("ElecMultIso", "N_{Iso}(e)", 10, 0., 10.);
237  // multiplicity of jets with pt>20 (corrected to L2+L3)
238  hists_["jetMult_"] = ibooker.book1D("JetMult", "N_{30}(jet)", 10, 0., 10.);
239  // trigger efficiency estimates for single lepton triggers
240  hists_["triggerEff_"] = ibooker.book1D("TriggerEff",
241  "Eff(trigger)", nPaths, 0., nPaths);
242  // monitored trigger occupancy for single lepton triggers
243  hists_["triggerMon_"] = ibooker.book1D("TriggerMon",
244  "Mon(trigger)", nPaths, 0., nPaths);
245  // MET (calo)
246  hists_["metCalo_"] = ibooker.book1D("METCalo", "MET_{Calo}", 50, 0., 200.);
247  // W mass estimate
248  hists_["massW_"] = ibooker.book1D("MassW", "M(W)", 60, 0., 300.);
249  // Top mass estimate
250  hists_["massTop_"] = ibooker.book1D("MassTop", "M(Top)", 50, 0., 500.);
251  // b-tagged Top mass
252  hists_["massBTop_"] = ibooker.book1D("MassBTop", "M(Top, 1 b-tag)", 50, 0., 500.);
253  // set bin labels for trigger monitoring
255 
256  if (verbosity_ == STANDARD) return;
257 
258  // --- [VERBOSE] --- //
259  // eta of the leading muon
260  hists_["muonEta_"] = ibooker.book1D("MuonEta", "#eta(#mu)", 30, -3., 3.);
261  // relative isolation of the candidate muon (depending on the decay channel)
262  hists_["muonRelIso_"] = ibooker.book1D(
263  "MuonRelIso", "Iso_{Rel}(#mu) (#Delta#beta Corrected)", 50, 0., 1.);
264  // eta of the leading electron
265  hists_["elecEta_"] = ibooker.book1D("ElecEta", "#eta(e)", 30, -3., 3.);
266  // std isolation variable of the leading electron
267  hists_["elecRelIso_"] = ibooker.book1D("ElecRelIso", "Iso_{Rel}(e)", 50, 0., 1.);
268  // multiplicity of btagged jets (for track counting high efficiency) with
269  // pt(L2L3)>30
270  hists_["jetMultBEff_"] = ibooker.book1D("JetMultBEff",
271  "N_{30}(TCHE)", 10, 0., 10.);
272  // btag discriminator for track counting high efficiency for jets with
273  // pt(L2L3)>30
274  hists_["jetBDiscEff_"] = ibooker.book1D("JetBDiscEff",
275  "Disc_{TCHE}(jet)", 100, 0., 10.);
276  // eta of the 1. leading jet (corrected to L2+L3)
277  hists_["jet1Eta_"] = ibooker.book1D("Jet1Eta", "#eta_{L2L3}(jet1)", 60, -3., 3.);
278  // pt of the 1. leading jet (corrected to L2+L3)
279  hists_["jet1Pt_"] = ibooker.book1D("Jet1Pt", "pt_{L2L3}(jet1)", 60, 0., 300.);
280  // eta of the 2. leading jet (corrected to L2+L3)
281  hists_["jet2Eta_"] = ibooker.book1D("Jet2Eta", "#eta_{L2L3}(jet2)", 60, -3., 3.);
282  // pt of the 2. leading jet (corrected to L2+L3)
283  hists_["jet2Pt_"] = ibooker.book1D("Jet2Pt", "pt_{L2L3}(jet2)", 60, 0., 300.);
284  // eta of the 3. leading jet (corrected to L2+L3)
285  hists_["jet3Eta_"] = ibooker.book1D("Jet3Eta", "#eta_{L2L3}(jet3)", 60, -3., 3.);
286  // pt of the 3. leading jet (corrected to L2+L3)
287  hists_["jet3Pt_"] = ibooker.book1D("Jet3Pt", "pt_{L2L3}(jet3)", 60, 0., 300.);
288  // eta of the 4. leading jet (corrected to L2+L3)
289  hists_["jet4Eta_"] = ibooker.book1D("Jet4Eta", "#eta_{L2L3}(jet4)", 60, -3., 3.);
290  // pt of the 4. leading jet (corrected to L2+L3)
291  hists_["jet4Pt_"] = ibooker.book1D("Jet4Pt", "pt_{L2L3}(jet4)", 60, 0., 300.);
292  // MET (tc)
293  hists_["metTC_"] = ibooker.book1D("METTC", "MET_{TC}", 50, 0., 200.);
294  // MET (pflow)
295  hists_["metPflow_"] = ibooker.book1D("METPflow", "MET_{Pflow}", 50, 0., 200.);
296  // dz for muons (to suppress cosmis)
297  hists_["muonDelZ_"] = ibooker.book1D("MuonDelZ", "d_{z}(#mu)", 50, -25., 25.);
298  // dxy for muons (to suppress cosmics)
299  hists_["muonDelXY_"] = ibooker.book2D("MuonDelXY",
300  "d_{xy}(#mu)", 50, -0.1, 0.1, 50, -0.1, 0.1);
301 
302  // set axes titles for dxy for muons
303  hists_["muonDelXY_"]->setAxisTitle("x [cm]", 1);
304  hists_["muonDelXY_"]->setAxisTitle("y [cm]", 2);
305 
306  if (verbosity_ == VERBOSE) return;
307 
308  // --- [DEBUG] --- //
309  // charged hadron isolation component of the candidate muon (depending on the
310  // decay channel)
311  hists_["muonChHadIso_"] = ibooker.book1D("MuonChHadIsoComp",
312  "ChHad_{IsoComponent}(#mu)", 50, 0., 5.);
313  // neutral hadron isolation component of the candidate muon (depending on the
314  // decay channel)
315  hists_["muonNeHadIso_"] = ibooker.book1D("MuonNeHadIsoComp",
316  "NeHad_{IsoComponent}(#mu)", 50, 0., 5.);
317  // photon isolation component of the candidate muon (depending on the decay
318  // channel)
319  hists_["muonPhIso_"] = ibooker.book1D("MuonPhIsoComp",
320  "Photon_{IsoComponent}(#mu)", 50, 0., 5.);
321  // charged hadron isolation component of the candidate electron (depending on
322  // the decay channel)
323  hists_["elecChHadIso_"] = ibooker.book1D("ElectronChHadIsoComp",
324  "ChHad_{IsoComponent}(e)", 50, 0., 5.);
325  // neutral hadron isolation component of the candidate electron (depending on
326  // the decay channel)
327  hists_["elecNeHadIso_"] = ibooker.book1D("ElectronNeHadIsoComp",
328  "NeHad_{IsoComponent}(e)", 50, 0., 5.);
329  // photon isolation component of the candidate electron (depending on the
330  // decay channel)
331  hists_["elecPhIso_"] = ibooker.book1D("ElectronPhIsoComp",
332  "Photon_{IsoComponent}(e)", 50, 0., 5.);
333  // multiplicity of btagged jets (for track counting high purity) with
334  // pt(L2L3)>30
335  hists_["jetMultBPur_"] = ibooker.book1D("JetMultBPur",
336  "N_{30}(TCHP)", 10, 0., 10.);
337  // btag discriminator for track counting high purity
338  hists_["jetBDiscPur_"] = ibooker.book1D("JetBDiscPur",
339  "Disc_{TCHP}(Jet)", 100, 0., 10.);
340  // multiplicity of btagged jets (for simple secondary vertex) with pt(L2L3)>30
341  hists_["jetMultBVtx_"] = ibooker.book1D("JetMultBVtx",
342  "N_{30}(SSVHE)", 10, 0., 10.);
343  // btag discriminator for simple secondary vertex
344  hists_["jetBDiscVtx_"] = ibooker.book1D("JetBDiscVtx",
345  "Disc_{SSVHE}(Jet)", 35, -1., 6.);
346  // multiplicity for combined secondary vertex
347  hists_["jetMultCSVtx_"] = ibooker.book1D("JetMultCSV", "N_{30}(CSV)", 10, 0., 10.);
348  // btag discriminator for combined secondary vertex
349  hists_["jetBCVtx_"] = ibooker.book1D("JetDiscCSV",
350  "Disc_{CSV}(JET)", 100, -1., 2.);
351  // pt of the 1. leading jet (uncorrected)
352  hists_["jet1PtRaw_"] = ibooker.book1D("Jet1PtRaw", "pt_{Raw}(jet1)", 60, 0., 300.);
353  // pt of the 2. leading jet (uncorrected)
354  hists_["jet2PtRaw_"] = ibooker.book1D("Jet2PtRaw", "pt_{Raw}(jet2)", 60, 0., 300.);
355  // pt of the 3. leading jet (uncorrected)
356  hists_["jet3PtRaw_"] = ibooker.book1D("Jet3PtRaw", "pt_{Raw}(jet3)", 60, 0., 300.);
357  // pt of the 4. leading jet (uncorrected)
358  hists_["jet4PtRaw_"] = ibooker.book1D("Jet4PtRaw", "pt_{Raw}(jet4)", 60, 0., 300.);
359  // selected events
360  hists_["eventLogger_"] = ibooker.book2D("EventLogger",
361  "Logged Events", 9, 0., 9., 10, 0., 10.);
362 
363  // set axes titles for selected events
364  hists_["eventLogger_"]->getTH1()->SetOption("TEXT");
365  hists_["eventLogger_"]->setBinLabel(1, "Run", 1);
366  hists_["eventLogger_"]->setBinLabel(2, "Block", 1);
367  hists_["eventLogger_"]->setBinLabel(3, "Event", 1);
368  hists_["eventLogger_"]->setBinLabel(4, "pt_{L2L3}(jet1)", 1);
369  hists_["eventLogger_"]->setBinLabel(5, "pt_{L2L3}(jet2)", 1);
370  hists_["eventLogger_"]->setBinLabel(6, "pt_{L2L3}(jet3)", 1);
371  hists_["eventLogger_"]->setBinLabel(7, "pt_{L2L3}(jet4)", 1);
372  hists_["eventLogger_"]->setBinLabel(8, "M_{W}", 1);
373  hists_["eventLogger_"]->setBinLabel(9, "M_{Top}", 1);
374  hists_["eventLogger_"]->setAxisTitle("logged evts", 2);
375  return;
376 }
377 
379  const edm::EventSetup& setup) {
380  // fetch trigger event if configured such
382 
384  if (!event.getByToken(triggerTable_, triggerTable)) return;
385  }
386 
387  /*
388  ------------------------------------------------------------
389 
390  Primary Vertex Monitoring
391 
392  ------------------------------------------------------------
393  */
394  // fill monitoring plots for primary verices
396  if (!event.getByToken(pvs_, pvs)) return;
397  unsigned int pvMult = 0;
398  for (edm::View<reco::Vertex>::const_iterator pv = pvs->begin();
399  pv != pvs->end(); ++pv) {
400  if (!pvSelect_ || (*pvSelect_)(*pv)) pvMult++;
401  }
402  fill("pvMult_", pvMult);
403 
404  /*
405  ------------------------------------------------------------
406 
407  Run and Inst. Luminosity information (Inst. Lumi. filled now with a dummy
408  value=5.0)
409 
410  ------------------------------------------------------------
411  */
412  if (!event.eventAuxiliary().run()) return;
413  fill("RunNumb_", event.eventAuxiliary().run());
414 
415  double dummy = 5.;
416  fill("InstLumi_", dummy);
417 
418  /*
419  ------------------------------------------------------------
420 
421  Electron Monitoring
422 
423  ------------------------------------------------------------
424  */
425 
426  // fill monitoring plots for electrons
428  if (!event.getByToken(elecs_, elecs)) return;
429 
430  // check availability of electron id
432  if (!electronId_.isUninitialized()) {
433  if (!event.getByToken(electronId_, electronId)) return;
434  }
435 
436  // loop electron collection
437  unsigned int eMult = 0, eMultIso = 0;
438  std::vector<const reco::PFCandidate*> isoElecs;
439  for (edm::View<reco::PFCandidate>::const_iterator elec = elecs->begin();
440  elec != elecs->end(); ++elec) {
441  if (elec->gsfElectronRef().isNull()) {
442  continue;
443  }
444  reco::GsfElectronRef gsf_el = elec->gsfElectronRef();
445  // restrict to electrons with good electronId
446  if (electronId_.isUninitialized() ? true : ((double)(*electronId)[gsf_el] >=
447  eidCutValue_)) {
448  if (!elecSelect_ || (*elecSelect_)(*elec)) {
449 
450  double el_ChHadIso = gsf_el->pfIsolationVariables().sumChargedHadronPt;
451  double el_NeHadIso = gsf_el->pfIsolationVariables().sumNeutralHadronEt;
452  double el_PhIso = gsf_el->pfIsolationVariables().sumPhotonEt;
453  double el_pfRelIso =
454  (el_ChHadIso +
455  max(0., el_NeHadIso + el_PhIso -
456  0.5 * gsf_el->pfIsolationVariables().sumPUPt)) /
457  gsf_el->pt();
458  if (eMult == 0) {
459  // restrict to the leading electron
460  fill("elecPt_", elec->pt());
461  fill("elecEta_", elec->eta());
462  fill("elecRelIso_", el_pfRelIso);
463  fill("elecChHadIso_", el_ChHadIso);
464  fill("elecNeHadIso_", el_NeHadIso);
465  fill("elecPhIso_", el_PhIso);
466  }
467  // in addition to the multiplicity counter buffer the iso
468  // electron candidates for later overlap check with jets
469  ++eMult;
470  if (!elecIso_ || (*elecIso_)(*elec)) {
471  isoElecs.push_back(&(*elec));
472  ++eMultIso;
473  }
474  }
475  }
476  }
477  fill("elecMult_", eMult);
478  fill("elecMultIso_", eMultIso);
479 
480  /*
481  ------------------------------------------------------------
482 
483  Muon Monitoring
484 
485  ------------------------------------------------------------
486  */
487 
488  // fill monitoring plots for muons
489  unsigned int mMult = 0, mMultIso = 0;
490 
493 
494  if (!event.getByToken(muons_, muons)) return;
495 
496  for (edm::View<reco::PFCandidate>::const_iterator muonit = muons->begin();
497  muonit != muons->end(); ++muonit) {
498 
499  if (muonit->muonRef().isNull()) continue;
500  reco::MuonRef muon = muonit->muonRef();
501 
502  // restrict to globalMuons
503  if (muon->isGlobalMuon()) {
504  fill("muonDelZ_", muon->innerTrack()->vz()); // CB using inner track!
505  fill("muonDelXY_", muon->innerTrack()->vx(), muon->innerTrack()->vy());
506 
507  // apply preselection
508  if (!muonSelect_ || (*muonSelect_)(*muonit)) {
509 
510  double chHadPt = muon->pfIsolationR04().sumChargedHadronPt;
511  double neHadEt = muon->pfIsolationR04().sumNeutralHadronEt;
512  double phoEt = muon->pfIsolationR04().sumPhotonEt;
513 
514  double pfRelIso =
515  (chHadPt +
516  max(0., neHadEt + phoEt - 0.5 * muon->pfIsolationR04().sumPUPt)) /
517  muon->pt(); // CB dBeta corrected iso!
518 
519  if (mMult == 0) {
520  // restrict to leading muon
521  fill("muonPt_", muon->pt());
522  fill("muonEta_", muon->eta());
523 
524  fill("muonRelIso_", pfRelIso);
525 
526  fill("muonChHadIso_", chHadPt);
527  fill("muonNeHadIso_", neHadEt);
528  fill("muonPhIso_", phoEt);
529  }
530  ++mMult;
531  if (!muonIso_ || (*muonIso_)(*muonit)) ++mMultIso;
532  }
533  }
534  }
535  fill("muonMult_", mMult);
536  fill("muonMultIso_", mMultIso);
537 
538  /*
539  ------------------------------------------------------------
540 
541  Jet Monitoring
542 
543  ------------------------------------------------------------
544  */
545 
546  // check availability of the btaggers
547  edm::Handle<reco::JetTagCollection> btagEff, btagPur, btagVtx, btagCSV;
548  if (includeBTag_) {
549  if (!event.getByToken(btagEff_, btagEff)) return;
550  if (!event.getByToken(btagPur_, btagPur)) return;
551  if (!event.getByToken(btagVtx_, btagVtx)) return;
552  if (!event.getByToken(btagCSV_, btagCSV)) return;
553  }
554  // load jet corrector if configured such
555  const JetCorrector* corrector = 0;
556  if (!jetCorrector_.empty()) {
557  // check whether a jet correcto is in the event setup or not
559  JetCorrectionsRecord>())) {
560  corrector = JetCorrector::getJetCorrector(jetCorrector_, setup);
561  } else {
562  edm::LogVerbatim("TopSingleLeptonDQM")
563  << "\n"
564  << "-----------------------------------------------------------------"
565  "-------------------- \n"
566  << " No JetCorrectionsRecord available from EventSetup: "
567  " \n"
568  << " - Jets will not be corrected. "
569  " \n"
570  << " - If you want to change this add the following lines to your "
571  "cfg file: \n"
572  << " "
573  " \n"
574  << " ## load jet corrections "
575  " \n"
576  << " "
577  "process.load(\"JetMETCorrections.Configuration."
578  "JetCorrectionServicesAllAlgos_cff\") \n"
579  << " process.prefer(\"ak5CaloL2L3\") "
580  " \n"
581  << " "
582  " \n"
583  << "-----------------------------------------------------------------"
584  "-------------------- \n";
585  }
586  }
587 
588  // loop jet collection
589  std::vector<reco::Jet> correctedJets;
590  std::vector<double> JetTagValues;
591  unsigned int mult = 0, multBEff = 0, multBPur = 0, multBVtx = 0, multCSV = 0;
592 
594  if (!event.getByToken(jets_, jets)) {
595  return;
596  }
597 
599  if (jetIDSelect_) {
600  if (!event.getByToken(jetIDLabel_, jetID)) return;
601  }
602 
603  for (edm::View<reco::Jet>::const_iterator jet = jets->begin();
604  jet != jets->end(); ++jet) {
605  // check jetID for calo jets
606  unsigned int idx = jet - jets->begin();
607  if (jetIDSelect_ &&
608  dynamic_cast<const reco::CaloJet*>(jets->refAt(idx).get())) {
609  if (!(*jetIDSelect_)((*jetID)[jets->refAt(idx)])) continue;
610  }
611  // chekc additional jet selection for calo, pf and bare reco jets
612  if (dynamic_cast<const reco::CaloJet*>(&*jet)) {
613  reco::CaloJet sel = dynamic_cast<const reco::CaloJet&>(*jet);
614  sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
616  if (!jetSelect(sel)) {
617  continue;
618  }
619  } else if (dynamic_cast<const reco::PFJet*>(&*jet)) {
620  reco::PFJet sel = dynamic_cast<const reco::PFJet&>(*jet);
621  sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
623  if (!jetSelect(sel)) continue;
624  } else {
625  reco::Jet sel = *jet;
626  sel.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
628  if (!jetSelect(sel)) continue;
629  }
630 
631  // prepare jet to fill monitor histograms
632  reco::Jet monitorJet = *jet;
633  monitorJet.scaleEnergy(corrector ? corrector->correction(*jet) : 1.);
634  correctedJets.push_back(monitorJet);
635  ++mult; // determine jet multiplicity
636  if (includeBTag_) {
637  // fill b-discriminators
638  edm::RefToBase<reco::Jet> jetRef = jets->refAt(idx);
639  fill("jetBDiscEff_", (*btagEff)[jetRef]);
640  if ((*btagEff)[jetRef] > btagEffWP_) ++multBEff;
641  fill("jetBDiscPur_", (*btagPur)[jetRef]);
642  if ((*btagPur)[jetRef] > btagPurWP_) ++multBPur;
643  fill("jetBDiscVtx_", (*btagVtx)[jetRef]);
644  if ((*btagVtx)[jetRef] > btagVtxWP_) ++multBVtx;
645  fill("jetBCVtx_", (*btagCSV)[jetRef]);
646  if ((*btagCSV)[jetRef] > btagCSVWP_) ++multCSV;
647 
648  // Fill a vector with Jet b-tag WP for later M3+1tag calculation: CSV
649  // tagger
650  JetTagValues.push_back((*btagCSV)[jetRef]);
651  }
652  // fill pt (raw or L2L3) for the leading four jets
653  if (idx == 0) {
654  fill("jet1Pt_", monitorJet.pt());
655  fill("jet1PtRaw_", jet->pt());
656  fill("jet1Eta_", monitorJet.eta());
657  };
658  if (idx == 1) {
659  fill("jet2Pt_", monitorJet.pt());
660  fill("jet2PtRaw_", jet->pt());
661  fill("jet2Eta_", monitorJet.eta());
662  }
663  if (idx == 2) {
664  fill("jet3Pt_", monitorJet.pt());
665  fill("jet3PtRaw_", jet->pt());
666  fill("jet3Eta_", monitorJet.eta());
667  }
668  if (idx == 3) {
669  fill("jet4Pt_", monitorJet.pt());
670  fill("jet4PtRaw_", jet->pt());
671  fill("jet4Eta_", monitorJet.eta());
672  }
673  }
674  fill("jetMult_", mult);
675  fill("jetMultBEff_", multBEff);
676  fill("jetMultBPur_", multBPur);
677  fill("jetMultBVtx_", multBVtx);
678  fill("jetMultCSVtx_", multCSV);
679 
680  /*
681  ------------------------------------------------------------
682 
683  MET Monitoring
684 
685  ------------------------------------------------------------
686  */
687 
688  // fill monitoring histograms for met
689  for (std::vector<edm::EDGetTokenT<edm::View<reco::MET> > >::const_iterator
690  met_ = mets_.begin();
691  met_ != mets_.end(); ++met_) {
693  if (!event.getByToken(*met_, met)) continue;
694  if (met->begin() != met->end()) {
695  unsigned int idx = met_ - mets_.begin();
696  if (idx == 0) fill("metCalo_", met->begin()->et());
697  if (idx == 1) fill("metTC_", met->begin()->et());
698  if (idx == 2) fill("metPflow_", met->begin()->et());
699  }
700  }
701 
702  /*
703  ------------------------------------------------------------
704 
705  Event Monitoring
706 
707  ------------------------------------------------------------
708  */
709 
710  // fill W boson and top mass estimates
711 
712  Calculate 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 
720  // Fill M3 with Btag (CSV Tight) requirement
721 
722  if (!includeBTag_) return;
723  if (correctedJets.size() != JetTagValues.size()) return;
724  double btopMass =
725  eventKinematics.massBTopQuark(correctedJets, JetTagValues, btagCSVWP_);
726  if (btopMass >= 0) fill("massBTop_", btopMass);
727 
728  // fill plots for trigger monitoring
729  if ((lowerEdge_ == -1. && upperEdge_ == -1.) ||
730  (lowerEdge_ < wMass && wMass < upperEdge_)) {
732  fill(event, *triggerTable, "trigger", triggerPaths_);
733  if (logged_ <= hists_.find("eventLogger_")->second->getNbinsY()) {
734  // log runnumber, lumi block, event number & some
735  // more pysics infomation for interesting events
736  fill("eventLogger_", 0.5, logged_ + 0.5, event.eventAuxiliary().run());
737  fill("eventLogger_", 1.5, logged_ + 0.5,
738  event.eventAuxiliary().luminosityBlock());
739  fill("eventLogger_", 2.5, logged_ + 0.5, event.eventAuxiliary().event());
740  if (correctedJets.size() > 0)
741  fill("eventLogger_", 3.5, logged_ + 0.5, correctedJets[0].pt());
742  if (correctedJets.size() > 1)
743  fill("eventLogger_", 4.5, logged_ + 0.5, correctedJets[1].pt());
744  if (correctedJets.size() > 2)
745  fill("eventLogger_", 5.5, logged_ + 0.5, correctedJets[2].pt());
746  if (correctedJets.size() > 3)
747  fill("eventLogger_", 6.5, logged_ + 0.5, correctedJets[3].pt());
748  fill("eventLogger_", 7.5, logged_ + 0.5, wMass);
749  fill("eventLogger_", 8.5, logged_ + 0.5, topMass);
750  ++logged_;
751  }
752  }
753 }
754 }
755 
757  : vertexSelect_(nullptr),
758  beamspot_(""),
759  beamspotSelect_(nullptr),
760  MuonStep(nullptr),
761  ElectronStep(nullptr),
762  PvStep(nullptr),
763  METStep(nullptr) {
764  JetSteps.clear();
765  CaloJetSteps.clear();
766  PFJetSteps.clear();
767  // configure preselection
768  edm::ParameterSet presel =
769  cfg.getParameter<edm::ParameterSet>("preselection");
770  if (presel.existsAs<edm::ParameterSet>("trigger")) {
771  edm::ParameterSet trigger =
772  presel.getParameter<edm::ParameterSet>("trigger");
773  triggerTable__ = consumes<edm::TriggerResults>(
774  trigger.getParameter<edm::InputTag>("src"));
775  triggerPaths_ = trigger.getParameter<std::vector<std::string> >("select");
776  }
777  if (presel.existsAs<edm::ParameterSet>("beamspot")) {
778  edm::ParameterSet beamspot =
779  presel.getParameter<edm::ParameterSet>("beamspot");
780  beamspot_ = beamspot.getParameter<edm::InputTag>("src");
781  beamspot__ =
782  consumes<reco::BeamSpot>(beamspot.getParameter<edm::InputTag>("src"));
784  beamspot.getParameter<std::string>("select")));
785  }
786 
787  // conifgure the selection
788  sel_ = cfg.getParameter<std::vector<edm::ParameterSet> >("selection");
789  setup_ = cfg.getParameter<edm::ParameterSet>("setup");
790  for (unsigned int i = 0; i < sel_.size(); ++i) {
791  selectionOrder_.push_back(sel_.at(i).getParameter<std::string>("label"));
792  selection_[selectionStep(selectionOrder_.back())] = std::make_pair(
793  sel_.at(i),
794  std::unique_ptr<TopSingleLepton::MonitorEnsemble>(
796  selectionStep(selectionOrder_.back()).c_str(),
798  }
799  for (std::vector<std::string>::const_iterator selIt = selectionOrder_.begin();
800  selIt != selectionOrder_.end(); ++selIt) {
801  std::string key = selectionStep(*selIt), type = objectType(*selIt);
802  if (selection_.find(key) != selection_.end()) {
803  if (type == "muons") {
805  consumesCollector()));
806  }
807  if (type == "elecs") {
810  }
811  if (type == "pvs") {
813  consumesCollector()));
814  }
815  if (type == "jets") {
816  JetSteps.push_back(std::unique_ptr<SelectionStep<reco::Jet>>(
818  }
819  if (type == "jets/pf") {
820  PFJetSteps.push_back(std::unique_ptr<SelectionStep<reco::PFJet>>(
822  }
823  if (type == "jets/calo") {
824  CaloJetSteps.push_back(std::unique_ptr<SelectionStep<reco::CaloJet>>(
826  }
827  if (type == "met") {
829  consumesCollector()));
830  }
831  }
832  }
833 }
835  edm::Run const &, edm::EventSetup const & ){
836 
837  for (auto selIt = selection_.begin(); selIt != selection_.end(); ++selIt) {
838  selIt->second.second->book(ibooker);
839  }
840 }
842  const edm::EventSetup& setup) {
843 
846  if (!event.getByToken(triggerTable__, triggerTable)) return;
847  if (!accept(event, *triggerTable, triggerPaths_)) return;
848  }
849  if (!beamspot__.isUninitialized()) {
851  if (!event.getByToken(beamspot__, beamspot)) return;
852  if (!(*beamspotSelect_)(*beamspot)) return;
853  }
854  // cout<<" apply selection steps"<<endl;
855  unsigned int passed = 0;
856  unsigned int nJetSteps = -1;
857  unsigned int nPFJetSteps = -1;
858  unsigned int nCaloJetSteps = -1;
859  for (std::vector<std::string>::const_iterator selIt = selectionOrder_.begin();
860  selIt != selectionOrder_.end(); ++selIt) {
861  std::string key = selectionStep(*selIt), type = objectType(*selIt);
862  if (selection_.find(key) != selection_.end()) {
863  if (type == "empty") {
864  selection_[key].second->fill(event, setup);
865  }
866  if (type == "muons" && MuonStep != 0) {
867  if (MuonStep->select(event)) {
868  ++passed;
869  // cout<<"selected event! "<<selection_[key].second<<endl;
870  selection_[key].second->fill(event, setup);
871  } else
872  break;
873  }
874  // cout<<" apply selection steps 2"<<endl;
875  if (type == "elecs" && ElectronStep != 0) {
876  // cout<<"In electrons ..."<<endl;
877  if (ElectronStep->select(event, "electron")) {
878  ++passed;
879  selection_[key].second->fill(event, setup);
880  } else
881  break;
882  }
883  // cout<<" apply selection steps 3"<<endl;
884  if (type == "pvs" && PvStep != 0) {
885  if (PvStep->selectVertex(event)) {
886  ++passed;
887  selection_[key].second->fill(event, setup);
888  } else
889  break;
890  }
891  // cout<<" apply selection steps 4"<<endl;
892  if (type == "jets") {
893  nJetSteps++;
894  if (JetSteps[nJetSteps] != NULL) {
895  if (JetSteps[nJetSteps]->select(event, setup)) {
896  ++passed;
897  selection_[key].second->fill(event, setup);
898  } else
899  break;
900  }
901  }
902  if (type == "jets/pf") {
903  nPFJetSteps++;
904  if (PFJetSteps[nPFJetSteps] != NULL) {
905  if (PFJetSteps[nPFJetSteps]->select(event, setup)) {
906  ++passed;
907  selection_[key].second->fill(event, setup);
908  } else
909  break;
910  }
911  }
912  if (type == "jets/calo") {
913  nCaloJetSteps++;
914  if (CaloJetSteps[nCaloJetSteps] != NULL) {
915  if (CaloJetSteps[nCaloJetSteps]->select(event, setup)) {
916  ++passed;
917  selection_[key].second->fill(event, setup);
918  } else
919  break;
920  }
921  }
922  if (type == "met" && METStep != 0) {
923  if (METStep->select(event)) {
924  ++passed;
925  selection_[key].second->fill(event, setup);
926  } else
927  break;
928  }
929  }
930  }
931 }
932 
933 // Local Variables:
934 // show-trailing-whitespace: t
935 // truncate-lines: t
936 // End:
std::map< std::string, MonitorElement * > hists_
histogram container
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
int logged_
number of logged interesting events
edm::EDGetTokenT< reco::JetIDValueMap > jetIDLabel_
jetID as an extra selection type
int i
Definition: DBlmapReader.cc:9
double btagEffWP_
btag working points
edm::EDGetTokenT< edm::View< reco::PFCandidate > > muons_
tuple cfg
Definition: looper.py:237
double massBTopQuark(const std::vector< reco::Jet > &jets, std::vector< double > VbtagWP, double btagWP_)
calculate b-tagged t-quark mass estimate
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:184
Jets made from CaloTowers.
Definition: CaloJet.h:29
std::unique_ptr< SelectionStep< reco::PFCandidate > > ElectronStep
virtual void scaleEnergy(double fScale)
scale energy of the jet
virtual float pt() const
transverse momentum
std::unique_ptr< StringCutObjectSelector< reco::BeamSpot > > beamspotSelect_
string cut selector
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
std::vector< std::string > triggerPaths_
virtual double correction(const LorentzVector &fJet) const =0
get correction using Jet information only
Base class for all types of Jets.
Definition: Jet.h:20
edm::EDGetTokenT< edm::TriggerResults > triggerTable_
trigger table
std::unique_ptr< StringCutObjectSelector< reco::JetID > > jetIDSelect_
extra jetID selection on calo jets
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate > > muonSelect_
extra selection on muons
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate > > elecSelect_
extra selection on electrons
double massTopQuark(const std::vector< reco::Jet > &jets)
calculate t-quark mass estimate
RunNumber_t run() const
TopSingleLeptonDQM(const edm::ParameterSet &cfg)
default constructor
#define NULL
Definition: scimark2.h:8
edm::EDGetTokenT< reco::BeamSpot > beamspot__
std::map< std::string, std::pair< edm::ParameterSet, std::unique_ptr< TopSingleLepton::MonitorEnsemble > > > selection_
edm::EDGetTokenT< reco::JetTagCollection > btagCSV_
#define nullptr
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:25
Jets made from PFObjects.
Definition: PFJet.h:21
std::vector< std::string > triggerPaths_
trigger paths
double massWBoson(const std::vector< reco::Jet > &jets)
calculate W boson mass estimate
std::vector< std::string > selectionOrder_
std::vector< edm::EDGetTokenT< edm::View< reco::MET > > > mets_
considers a vector of METs
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate > > elecIso_
extra isolation criterion on electron
#define MAXJETS
Definition: myFastSimVal.cc:30
std::string selectionStep(const std::string &label)
edm::EDGetTokenT< edm::View< reco::Jet > > jets_
input sources for monitoring
LuminosityBlockNumber_t luminosityBlock() const
const eventsetup::EventSetupRecord * find(const eventsetup::EventSetupRecordKey &) const
Definition: EventSetup.cc:90
Level verbosity_
verbosity level for booking
static const double WMASS
double lowerEdge_
mass window upper and lower edge
std::vector< std::unique_ptr< SelectionStep< reco::Jet > > > JetSteps
Helper class for the calculation of a top and a W boson mass estime.
Definition: TopDQMHelpers.h:68
tuple corrector
Definition: mvaPFMET_cff.py:50
virtual float eta() const
momentum pseudorapidity
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
edm::InputTag beamspot_
beamspot
vector< PseudoJet > jets
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
edm::EDGetTokenT< edm::View< reco::Vertex > > pvs_
edm::EDGetTokenT< edm::View< reco::PFCandidate > > elecs_
void book(DQMStore::IBooker &ibooker)
book histograms in subdirectory directory
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
bool first
Definition: L1TdeRCT.cc:75
edm::EDGetTokenT< edm::TriggerResults > triggerTable__
trigger table
std::unique_ptr< SelectionStep< reco::PFCandidate > > MuonStep
EventAuxiliary const & eventAuxiliary() const
Definition: Event.h:69
std::unique_ptr< SelectionStep< reco::MET > > METStep
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
std::string label_
instance label
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
edm::EDGetTokenT< reco::JetTagCollection > btagVtx_
static const JetCorrector * getJetCorrector(const std::string &fName, const edm::EventSetup &fSetup)
retrieve corrector from the event setup. troughs exception if something is missing ...
Definition: JetCorrector.cc:50
Templated helper class to allow a selection on a certain object collection.
std::string objectType(const std::string &label)
std::unique_ptr< StringCutObjectSelector< reco::Vertex > > pvSelect_
list key
Definition: combine.py:13
tuple muons
Definition: patZpeak.py:38
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
void fill(const edm::Event &event, const edm::EventSetup &setup)
fill monitor histograms with electronId and jetCorrections
static EventSetupRecordKey makeKey()
std::vector< edm::ParameterSet > sel_
bool isUninitialized() const
Definition: EDGetToken.h:71
edm::ParameterSet setup_
edm::EDGetTokenT< reco::JetTagCollection > btagEff_
btag discriminator labels
void triggerBinLabels(std::string channel, const std::vector< std::string > labels)
set configurable labels for trigger monitoring histograms
volatile std::atomic< bool > shutdown_flag false
std::string jetCorrector_
jetCorrector
static const unsigned int MAXJETS
std::vector< std::unique_ptr< SelectionStep< reco::PFJet > > > PFJetSteps
edm::EDGetTokenT< edm::ValueMap< float > > electronId_
electronId label
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
EventNumber_t event() const
virtual void analyze(const edm::Event &event, const edm::EventSetup &setup)
do this during the event loop
std::unique_ptr< SelectionStep< reco::Vertex > > PvStep
edm::EDGetTokenT< reco::JetTagCollection > btagPur_
Definition: Run.h:41
std::vector< std::unique_ptr< SelectionStep< reco::CaloJet > > > CaloJetSteps
std::unique_ptr< StringCutObjectSelector< reco::PFCandidate > > muonIso_
extra isolation criterion on muon