CMS 3D CMS Logo

SingleTopTChannelLeptonDQM_miniAOD.cc
Go to the documentation of this file.
7 #include <iostream>
11 
16 
18 
19 using namespace std;
21 
22 // maximal number of leading jets
23 // to be used for top mass estimate
24 static const unsigned int MAXJETS = 4;
25 // nominal mass of the W boson to
26 // be used for the top mass estimate
27 static const double WMASS = 80.4;
28 
29 MonitorEnsemble::MonitorEnsemble(const char* label,
30  const edm::ParameterSet& cfg,
32  : label_(label),
33  elecIso_(nullptr),
34  elecSelect_(nullptr),
35  pvSelect_(nullptr),
36  muonIso_(nullptr),
37  muonSelect_(nullptr),
38  jetIDSelect_(nullptr),
39  jetSelect(nullptr),
40  includeBTag_(false),
41  lowerEdge_(-1.),
42  upperEdge_(-1.),
43  logged_(0) {
44 
45  // sources have to be given; this PSet is not optional
46  edm::ParameterSet sources = cfg.getParameter<edm::ParameterSet>("sources");
47  // muons_ = iC.consumes<edm::View<reco::PFCandidate> >(
48  // sources.getParameter<edm::InputTag>("muons"));
49 
50 
51  muons_ = iC.consumes<edm::View<pat::Muon> >(
52  sources.getParameter<edm::InputTag>("muons"));
53 
54 
55  elecs_ = iC.consumes<edm::View<pat::Electron> >(
56  sources.getParameter<edm::InputTag>("elecs"));
57  pvs_ = iC.consumes<edm::View<reco::Vertex> >(
58  sources.getParameter<edm::InputTag>("pvs"));
59  jets_ = iC.consumes<edm::View<pat::Jet> >(
60  sources.getParameter<edm::InputTag>("jets"));
61  for (edm::InputTag const& tag :
62  sources.getParameter<std::vector<edm::InputTag> >("mets"))
63  mets_.push_back(iC.consumes<edm::View<pat::MET> >(tag));
64  // electronExtras are optional; they may be omitted or
65  // empty
66  if (cfg.existsAs<edm::ParameterSet>("elecExtras")) {
67 
68 
69  edm::ParameterSet elecExtras =
70  cfg.getParameter<edm::ParameterSet>("elecExtras");
71  // select is optional; in case it's not found no
72  // selection will be applied
73  if (elecExtras.existsAs<std::string>("select")) {
75  elecExtras.getParameter<std::string>("select")));
76  }
77  // isolation is optional; in case it's not found no
78  // isolation will be applied
79  if (elecExtras.existsAs<std::string>("isolation")) {
81  elecExtras.getParameter<std::string>("isolation")));
82  }
83 
84  if (elecExtras.existsAs<std::string>("rho")) {
85  rhoTag = elecExtras.getParameter<edm::InputTag>("rho");
86  }
87  // electronId is optional; in case it's not found the
88  // InputTag will remain empty
89  if (elecExtras.existsAs<edm::ParameterSet>("electronId")) {
90  edm::ParameterSet elecId =
91  elecExtras.getParameter<edm::ParameterSet>("electronId");
92  electronId_ = iC.consumes<edm::ValueMap<float> >(
93  elecId.getParameter<edm::InputTag>("src"));
94  eidCutValue_ = elecId.getParameter<double>("cutValue");
95  }
96  }
97  // pvExtras are opetional; they may be omitted or empty
98  if (cfg.existsAs<edm::ParameterSet>("pvExtras")) {
99  edm::ParameterSet pvExtras =
100  cfg.getParameter<edm::ParameterSet>("pvExtras");
101  // select is optional; in case it's not found no
102  // selection will be applied
103  if (pvExtras.existsAs<std::string>("select")) {
105  pvExtras.getParameter<std::string>("select")));
106  }
107  }
108  // muonExtras are optional; they may be omitted or empty
109  if (cfg.existsAs<edm::ParameterSet>("muonExtras")) {
110  edm::ParameterSet muonExtras =
111  cfg.getParameter<edm::ParameterSet>("muonExtras");
112  // select is optional; in case it's not found no
113  // selection will be applied
114  if (muonExtras.existsAs<std::string>("select")) {
116  muonExtras.getParameter<std::string>("select")));
117  }
118  // isolation is optional; in case it's not found no
119  // isolation will be applied
120  if (muonExtras.existsAs<std::string>("isolation")) {
122  muonExtras.getParameter<std::string>("isolation")));
123  }
124  }
125 
126  // jetExtras are optional; they may be omitted or
127  // empty
128  if (cfg.existsAs<edm::ParameterSet>("jetExtras")) {
129  edm::ParameterSet jetExtras =
130  cfg.getParameter<edm::ParameterSet>("jetExtras");
131  // jetCorrector is optional; in case it's not found
132  // the InputTag will remain empty
133  if (jetExtras.existsAs<std::string>("jetCorrector")) {
134  jetCorrector_ = jetExtras.getParameter<std::string>("jetCorrector");
135  }
136  // read jetID information if it exists
137  if (jetExtras.existsAs<edm::ParameterSet>("jetID")) {
138  edm::ParameterSet jetID =
139  jetExtras.getParameter<edm::ParameterSet>("jetID");
140  jetIDLabel_ = iC.consumes<reco::JetIDValueMap>(
141  jetID.getParameter<edm::InputTag>("label"));
143  jetID.getParameter<std::string>("select")));
144  }
145  // select is optional; in case it's not found no
146  // selection will be applied (only implemented for
147  // CaloJets at the moment)
148  if (jetExtras.existsAs<std::string>("select")) {
149  jetSelect_ = jetExtras.getParameter<std::string>("select");
151  }
152  }
153 
154  // triggerExtras are optional; they may be omitted or empty
155  if (cfg.existsAs<edm::ParameterSet>("triggerExtras")) {
156  edm::ParameterSet triggerExtras =
157  cfg.getParameter<edm::ParameterSet>("triggerExtras");
158  triggerTable_ = iC.consumes<edm::TriggerResults>(
159  triggerExtras.getParameter<edm::InputTag>("src"));
160  triggerPaths_ =
161  triggerExtras.getParameter<std::vector<std::string> >("paths");
162  }
163 
164  // massExtras is optional; in case it's not found no mass
165  // window cuts are applied for the same flavor monitor
166  // histograms
167  if (cfg.existsAs<edm::ParameterSet>("massExtras")) {
168  edm::ParameterSet massExtras =
169  cfg.getParameter<edm::ParameterSet>("massExtras");
170  lowerEdge_ = massExtras.getParameter<double>("lowerEdge");
171  upperEdge_ = massExtras.getParameter<double>("upperEdge");
172  }
173 
174  // setup the verbosity level for booking histograms;
175  // per default the verbosity level will be set to
176  // STANDARD. This will also be the chosen level in
177  // the case when the monitoring PSet is not found
179  if (cfg.existsAs<edm::ParameterSet>("monitoring")) {
181  cfg.getParameter<edm::ParameterSet>("monitoring");
182  if (monitoring.getParameter<std::string>("verbosity") == "DEBUG")
183  verbosity_ = DEBUG;
184  if (monitoring.getParameter<std::string>("verbosity") == "VERBOSE")
185  verbosity_ = VERBOSE;
186  if (monitoring.getParameter<std::string>("verbosity") == "STANDARD")
187  verbosity_ = STANDARD;
188  }
189  // and don't forget to do the histogram booking
190  directory_ = cfg.getParameter<std::string>("directory");
191  // book(ibooker);
192 }
193 
195  // set up the current directory path
196  std::string current(directory_);
197  current += label_;
198  ibooker.setCurrentFolder(current);
199 
200  // determine number of bins for trigger monitoring
201  //unsigned int nPaths = triggerPaths_.size();
202 
203  // --- [STANDARD] --- //
204  // Run Number
205  //hists_["RunNumb_"] = ibooker.book1D("RunNumber", "Run Nr.", 1.e4, 1.5e5, 3.e5);
206  // instantaneous luminosity
207  //hists_["InstLumi_"] = ibooker.book1D("InstLumi", "Inst. Lumi.", 100, 0., 1.e3);
208  // number of selected primary vertices
209  hists_["pvMult_"] = ibooker.book1D("PvMult", "N_{good pvs}", 50, 0., 50.);
210  // pt of the leading muon
211  hists_["muonPt_"] = ibooker.book1D("MuonPt", "pt(#mu TightId, TightIso)", 40, 0., 200.);
212  // muon multiplicity before std isolation
213  hists_["muonMult_"] = ibooker.book1D("MuonMult", "N_{loose}(#mu)", 10, 0., 10.);
214  // muon multiplicity after std isolation
215  //hists_["muonMultIso_"] = ibooker.book1D("MuonMultIso",
216  // "N_{TightIso}(#mu)", 10, 0., 10.);
217 
218  hists_["muonMultTight_"] = ibooker.book1D("MuonMultTight",
219  "N_{TightIso,TightId}(#mu)", 10, 0., 10.);
220 
221  // pt of the leading electron
222  hists_["elecPt_"] = ibooker.book1D("ElecPt", "pt(e TightId, TightIso)", 40, 0., 200.);
223  // electron multiplicity before std isolation
224  //hists_["elecMult_"] = ibooker.book1D("ElecMult", "N_{looseId}(e)", 10, 0., 10.);
225  // electron multiplicity after std isolation
226  //hists_["elecMultIso_"] = ibooker.book1D("ElecMultIso", "N_{Iso}(e)", 10, 0., 10.);
227  // multiplicity of jets with pt>20 (corrected to L2+L3)
228  hists_["jetMult_"] = ibooker.book1D("JetMult", "N_{30}(jet)", 10, 0., 10.);
229  hists_["jetLooseMult_"] = ibooker.book1D("JetLooseMult", "N_{30,loose}(jet)", 10, 0., 10.);
230 
231  // trigger efficiency estimates for single lepton triggers
232  //hists_["triggerEff_"] = ibooker.book1D("TriggerEff",
233  // "Eff(trigger)", nPaths, 0., nPaths);
234  // monitored trigger occupancy for single lepton triggers
235  //hists_["triggerMon_"] = ibooker.book1D("TriggerMon",
236  // "Mon(trigger)", nPaths, 0., nPaths);
237  // MET (calo)
238  hists_["slimmedMETs_"] = ibooker.book1D("slimmedMETs", "MET_{slimmed}", 40, 0., 200.);
239  // W mass estimate
240  hists_["massW_"] = ibooker.book1D("MassW", "M(W)", 60, 0., 300.);
241  // Top mass estimate
242  hists_["massTop_"] = ibooker.book1D("MassTop", "M(Top)", 50, 0., 500.);
243  // b-tagged Top mass
244  //hists_["massBTop_"] = ibooker.book1D("MassBTop", "M(Top, 1 b-tag)", 50, 0., 500.);
245 
246  // W mass transverse estimate mu
247  hists_["MTWm_"] = ibooker.book1D("MTWm", "M_{T}^{W}(#mu)", 60, 0., 300.);
248  // Top mass transverse estimate mu
249  hists_["mMTT_"] = ibooker.book1D("mMTT", "M_{T}^{t}(#mu)", 50, 0., 500.);
250 
251  // W mass transverse estimate e
252  hists_["MTWe_"] = ibooker.book1D("MTWe", "M_{T}^{W}(e)", 60, 0., 300.);
253  // Top mass transverse estimate e
254  hists_["eMTT_"] = ibooker.book1D("eMTT", "M_{T}^{t}(e)", 50, 0., 500.);
255 
256 
257 
258  // set bin labels for trigger monitoring
260 
261  if (verbosity_ == STANDARD) return;
262 
263  // --- [VERBOSE] --- //
264  // eta of the leading muon
265  hists_["muonEta_"] = ibooker.book1D("MuonEta", "#eta(#mu TightId,TightIso)", 30, -3., 3.);
266  // relative isolation of the candidate muon (depending on the decay channel)
267  hists_["muonPhi_"] = ibooker.book1D("MuonPhi", "#phi(#mu TightId,TightIso)", 40, -4., 4.);
268  hists_["muonRelIso_"] = ibooker.book1D(
269  "MuonRelIso", "Iso_{Rel}(#mu TightId) (#Delta#beta Corrected)", 50, 0., 1.);
270 
271  // eta of the leading electron
272  hists_["elecEta_"] = ibooker.book1D("ElecEta", "#eta(e TightId, TightIso)", 30, -3., 3.);
273  hists_["elecPhi_"] = ibooker.book1D("ElecPhi", "#phi(e TightId, TightIso)", 40, -4., 4.);
274  // std isolation variable of the leading electron
275  hists_["elecRelIso_"] = ibooker.book1D("ElecRelIso", "Iso_{Rel}(e TightId)", 50, 0., 1.);
276 
277  hists_["elecMultTight_"] = ibooker.book1D("ElecMultTight",
278  "N_{TightIso,TightId}(e)", 10, 0., 10.);
279 
280 
281  // multiplicity of btagged jets (for track counting high efficiency) with
282  // pt(L2L3)>30
283  //hists_["jetMultBEff_"] = ibooker.book1D("JetMultBEff",
284  // "N_{30}(TCHE)", 10, 0., 10.);
285  // btag discriminator for track counting high efficiency for jets with
286  // pt(L2L3)>30
287  //hists_["jetBDiscEff_"] = ibooker.book1D("JetBDiscEff",
288  // "Disc_{TCHE}(jet)", 100, 0., 10.);
289  // eta of the 1. leading jet (corrected to L2+L3)
290  hists_["jet1Eta_"] = ibooker.book1D("Jet1Eta", "#eta_{30,loose}(jet1)", 60, -3., 3.);
291  // pt of the 1. leading jet (corrected to L2+L3)
292  hists_["jet1Pt_"] = ibooker.book1D("Jet1Pt", "pt_{30,loose}(jet1)", 60, 0., 300.);
293  // eta of the 2. leading jet (corrected to L2+L3)
294  hists_["jet2Eta_"] = ibooker.book1D("Jet2Eta", "#eta_{30,loose}(jet2)", 60, -3., 3.);
295  // pt of the 2. leading jet (corrected to L2+L3)
296  hists_["jet2Pt_"] = ibooker.book1D("Jet2Pt", "pt_{30,loose}(jet2)", 60, 0., 300.);
297  // eta of the 3. leading jet (corrected to L2+L3)
298  //hists_["jet3Eta_"] = ibooker.book1D("Jet3Eta", "#eta_{30,loose}(jet3)", 60, -3., 3.);
299  // pt of the 3. leading jet (corrected to L2+L3)
300  //hists_["jet3Pt_"] = ibooker.book1D("Jet3Pt", "pt_{30,loose}(jet3)", 60, 0., 300.);
301  // eta of the 4. leading jet (corrected to L2+L3)
302  //hists_["jet4Eta_"] = ibooker.book1D("Jet4Eta", "#eta_{30,loose}(jet4)", 60, -3., 3.);
303  // pt of the 4. leading jet (corrected to L2+L3)
304  //hists_["jet4Pt_"] = ibooker.book1D("Jet4Pt", "pt_{30,loose}(jet4)", 60, 0., 300.);
305  // MET (tc)
306  hists_["slimmedMETsNoHF_"] = ibooker.book1D("slimmedMETsNoHF", "MET_{slimmedNoHF}", 40, 0., 200.);
307  // MET (pflow)
308  hists_["slimmedMETsPuppi_"] = ibooker.book1D("slimmedMETsPuppi", "MET_{slimmedPuppi}", 40, 0., 200.);
309  // dz for muons (to suppress cosmis)
310  hists_["muonDelZ_"] = ibooker.book1D("MuonDelZ", "d_{z}(#mu)", 50, -25., 25.);
311  // dxy for muons (to suppress cosmics)
312  hists_["muonDelXY_"] = ibooker.book2D("MuonDelXY",
313  "d_{xy}(#mu)", 50, -0.1, 0.1, 50, -0.1, 0.1);
314 
315  // set axes titles for dxy for muons
316  hists_["muonDelXY_"]->setAxisTitle("x [cm]", 1);
317  hists_["muonDelXY_"]->setAxisTitle("y [cm]", 2);
318 
319  if (verbosity_ == VERBOSE) return;
320 
321  // --- [DEBUG] --- //
322  // charged hadron isolation component of the candidate muon (depending on the
323  // decay channel)
324  hists_["muonChHadIso_"] = ibooker.book1D("MuonChHadIsoComp",
325  "ChHad_{IsoComponent}(#mu TightId)", 50, 0., 5.);
326  // neutral hadron isolation component of the candidate muon (depending on the
327  // decay channel)
328  hists_["muonNeHadIso_"] = ibooker.book1D("MuonNeHadIsoComp",
329  "NeHad_{IsoComponent}(#mu TightId)", 50, 0., 5.);
330  // photon isolation component of the candidate muon (depending on the decay
331  // channel)
332  hists_["muonPhIso_"] = ibooker.book1D("MuonPhIsoComp",
333  "Photon_{IsoComponent}(#mu TightId)", 50, 0., 5.);
334  // charged hadron isolation component of the candidate electron (depending on
335  // the decay channel)
336  hists_["elecChHadIso_"] = ibooker.book1D("ElectronChHadIsoComp",
337  "ChHad_{IsoComponent}(e TightId)", 50, 0., 5.);
338  // neutral hadron isolation component of the candidate electron (depending on
339  // the decay channel)
340  hists_["elecNeHadIso_"] = ibooker.book1D("ElectronNeHadIsoComp",
341  "NeHad_{IsoComponent}(e TightId)", 50, 0., 5.);
342  // photon isolation component of the candidate electron (depending on the
343  // decay channel)
344  hists_["elecPhIso_"] = ibooker.book1D("ElectronPhIsoComp",
345  "Photon_{IsoComponent}(e TightId)", 50, 0., 5.);
346  // multiplicity of btagged jets (for track counting high purity) with
347  // pt(L2L3)>30
348  //hists_["jetMultBPur_"] = ibooker.book1D("JetMultBPur",
349  // "N_{30}(TCHP)", 10, 0., 10.);
350  // btag discriminator for track counting high purity
351  //hists_["jetBDiscPur_"] = ibooker.book1D("JetBDiscPur",
352  // "Disc_{TCHP}(Jet)", 100, 0., 10.);
353  // multiplicity of btagged jets (for simple secondary vertex) with pt(L2L3)>30
354  //hists_["jetMultBVtx_"] = ibooker.book1D("JetMultBVtx",
355  // "N_{30}(SSVHE)", 10, 0., 10.);
356  // btag discriminator for simple secondary vertex
357  //hists_["jetBDiscVtx_"] = ibooker.book1D("JetBDiscVtx",
358  // "Disc_{SSVHE}(Jet)", 35, -1., 6.);
359  // multiplicity for combined secondary vertex
360  hists_["jetMultBCSVM_"] = ibooker.book1D("JetMultBCSVM", "N_{30}(CSVM)", 10, 0., 10.);
361  // btag discriminator for combined secondary vertex
362  hists_["jetBCSV_"] = ibooker.book1D("JetDiscCSV","BJet Disc_{CSV}(JET)", 100, -1., 2.);
363  // pt of the 1. leading jet (uncorrected)
364  //hists_["jet1PtRaw_"] = ibooker.book1D("Jet1PtRaw", "pt_{Raw}(jet1)", 60, 0., 300.);
365  // pt of the 2. leading jet (uncorrected)
366  //hists_["jet2PtRaw_"] = ibooker.book1D("Jet2PtRaw", "pt_{Raw}(jet2)", 60, 0., 300.);
367  // pt of the 3. leading jet (uncorrected)
368  //hists_["jet3PtRaw_"] = ibooker.book1D("Jet3PtRaw", "pt_{Raw}(jet3)", 60, 0., 300.);
369  // pt of the 4. leading jet (uncorrected)
370  //hists_["jet4PtRaw_"] = ibooker.book1D("Jet4PtRaw", "pt_{Raw}(jet4)", 60, 0., 300.);
371  // selected events
372  hists_["eventLogger_"] = ibooker.book2D("EventLogger",
373  "Logged Events", 9, 0., 9., 10, 0., 10.);
374 
375  // set axes titles for selected events
376  hists_["eventLogger_"]->getTH1()->SetOption("TEXT");
377  hists_["eventLogger_"]->setBinLabel(1, "Run", 1);
378  hists_["eventLogger_"]->setBinLabel(2, "Block", 1);
379  hists_["eventLogger_"]->setBinLabel(3, "Event", 1);
380  hists_["eventLogger_"]->setBinLabel(4, "pt_{L2L3}(jet1)", 1);
381  hists_["eventLogger_"]->setBinLabel(5, "pt_{L2L3}(jet2)", 1);
382  hists_["eventLogger_"]->setBinLabel(6, "pt_{L2L3}(jet3)", 1);
383  hists_["eventLogger_"]->setBinLabel(7, "pt_{L2L3}(jet4)", 1);
384  hists_["eventLogger_"]->setBinLabel(8, "M_{W}", 1);
385  hists_["eventLogger_"]->setBinLabel(9, "M_{Top}", 1);
386  hists_["eventLogger_"]->setAxisTitle("logged evts", 2);
387  return;
388 }
389 
391  const edm::EventSetup& setup) {
392  // fetch trigger event if configured such
394 
396  if (!event.getByToken(triggerTable_, triggerTable)) return;
397  }
398 
399  /*
400  ------------------------------------------------------------
401 
402  Primary Vertex Monitoring
403 
404  ------------------------------------------------------------
405  */
406  // fill monitoring plots for primary verices
408  if (!event.getByToken(pvs_, pvs)) return;
409  const reco::Vertex& pver= pvs->front();
410 
411  unsigned int pvMult = 0;
412  if(pvs.isValid()){
413  for (edm::View<reco::Vertex>::const_iterator pv = pvs->begin();
414  pv != pvs->end(); ++pv) {
415 
416  bool isGood = ( !(pv->isFake()) &&
417  (pv->ndof() > 4.0) &&
418  (abs(pv->z()) < 24.0) &&
419  (abs(pv->position().Rho()) < 2.0)
420  );
421  if( !isGood ) continue;
422  pvMult++;
423  }
424  //std::cout<<" npv "<<testn<<endl;
425  }
426 
427  fill("pvMult_", pvMult);
428 
429  /*
430  ------------------------------------------------------------
431 
432  Run and Inst. Luminosity information (Inst. Lumi. filled now with a dummy
433  value=5.0)
434 
435  ------------------------------------------------------------
436  */
437 
438  //if (!event.eventAuxiliary().run()) return;
439 
440  //fill("RunNumb_", event.eventAuxiliary().run());
441 
442  //double dummy = 5.;
443  //fill("InstLumi_", dummy);
444 
445  /*
446  ------------------------------------------------------------
447 
448  Electron Monitoring
449 
450  ------------------------------------------------------------
451  */
452 
453  // fill monitoring plots for electrons
455  if (!event.getByToken(elecs_, elecs)) return;
456 
457  edm::Handle< double > _rhoHandle;
458  event.getByLabel(rhoTag,_rhoHandle);
459  //if (!event.getByToken(elecs_, elecs)) return;
460 
461 
462  // check availability of electron id
464  if (!electronId_.isUninitialized()) {
465  if (!event.getByToken(electronId_, electronId)) return;
466  }
467 
468  // loop electron collection
469  unsigned int eMultIso = 0, eMult = 0;
470  std::vector<const pat::Electron*> isoElecs;
471 
473 
474  for (edm::View<pat::Electron>::const_iterator elec = elecs->begin();
475  elec != elecs->end(); ++elec) {
476 
477  if(true){//loose id
478  if (!elecSelect_ || (*elecSelect_)(*elec)) {
479 
480  double el_ChHadIso = elec->pfIsolationVariables().sumChargedHadronPt;
481  double el_NeHadIso = elec->pfIsolationVariables().sumNeutralHadronEt;
482  double el_PhIso = elec->pfIsolationVariables().sumPhotonEt;
483 
484  double rho = _rhoHandle.isValid() ? (float)(*_rhoHandle) : 0;
485  double absEta = abs(elec->superCluster()->eta());
486  double eA = 0;
487  if (absEta < 1.000) eA = 0.1703;
488  else if (absEta < 1.479) eA = 0.1715;
489  else if (absEta < 2.000) eA = 0.1213;
490  else if (absEta < 2.200) eA = 0.1230;
491  else if (absEta < 2.300) eA = 0.1635;
492  else if (absEta < 2.400) eA = 0.1937;
493  else if (absEta < 5.000) eA = 0.2393;
494 
495 
496  double el_pfRelIso = (el_ChHadIso + max(0., el_NeHadIso + el_PhIso - rho * eA)) /elec->pt();
497 
498  ++eMult;
499 
500  if(eMult==1){
501  fill("elecRelIso_", el_pfRelIso);
502  fill("elecChHadIso_", el_ChHadIso);
503  fill("elecNeHadIso_", el_NeHadIso);
504  fill("elecPhIso_", el_PhIso);
505  }
506  //loose Iso
507  //if(!((el_pfRelIso<0.0994 && absEta<1.479)||(el_pfRelIso<0.107 && absEta>1.479)))continue;
508 
509  //tight Iso
510  if(!((el_pfRelIso<0.0588 && absEta<1.479)||(el_pfRelIso<0.0571 && absEta>1.479)))continue;
511  ++eMultIso;
512 
513 
514  if (eMultIso == 1) {
515  // restrict to the leading electron
516  e = *elec;
517 
518  fill("elecPt_", elec->pt());
519  fill("elecEta_", elec->eta());
520  fill("elecPhi_", elec->phi());
521  }
522  }
523  }
524  }
525  //fill("elecMult_", eMult);
526  fill("elecMultTight_", eMultIso);
527 
528 
529 
530 
531 
532  /*
533  ------------------------------------------------------------
534 
535  Muon Monitoring
536 
537  ------------------------------------------------------------
538  */
539 
540  // fill monitoring plots for muons
541  unsigned int mMult = 0, mTight=0;
542 
544 
545  pat::Muon mu;
546 
548 
549  if (!event.getByToken(muons_, muons)) return;
550 
551  for (edm::View<pat::Muon>::const_iterator muon = muons->begin();
552  muon != muons->end(); ++muon) {
553 
554 
555  // restrict to globalMuons
556  if (muon->isGlobalMuon()) {
557  fill("muonDelZ_", muon->innerTrack()->vz()); // CB using inner track!
558  fill("muonDelXY_", muon->innerTrack()->vx(), muon->innerTrack()->vy());
559 
560 
561 
562  // apply preselection loose muon
563  if (!muonSelect_ || (*muonSelect_)(*muon)) {
564 
565  //loose muon count
566  ++mMult;
567 
568  double chHadPt = muon->pfIsolationR04().sumChargedHadronPt;
569  double neHadEt = muon->pfIsolationR04().sumNeutralHadronEt;
570  double phoEt = muon->pfIsolationR04().sumPhotonEt;
571 
572  double pfRelIso = (chHadPt + max(0., neHadEt + phoEt - 0.5 * muon->pfIsolationR04().sumPUPt)) / muon->pt(); // CB dBeta corrected iso!
573 
574  if(!(muon->isGlobalMuon() && muon->isPFMuon() && muon->globalTrack()->normalizedChi2() < 10. && muon->globalTrack()->hitPattern().numberOfValidMuonHits() > 0 && muon->numberOfMatchedStations() > 1 && fabs(muon->muonBestTrack()->dxy(pver.position())) < 0.2 && fabs(muon->muonBestTrack()->dz(pver.position())) < 0.5 && muon->innerTrack()->hitPattern().numberOfValidPixelHits() > 0 && muon->innerTrack()->hitPattern().trackerLayersWithMeasurement() > 5 ) )continue;
575 
576  if (mMult == 1) {
577  // restrict to leading muon
578  fill("muonRelIso_", pfRelIso);
579  fill("muonChHadIso_", chHadPt);
580  fill("muonNeHadIso_", neHadEt);
581  fill("muonPhIso_", phoEt);
582  fill("muonRelIso_",pfRelIso);
583 
584  }
585 
586  if(!(pfRelIso<0.15))continue;
587 
588  ++mTight;
589 
590 
591  //tight id
592  if (mTight == 1) {
593  // restrict to leading muon
594  mu = *muon;
595  fill("muonPt_", muon->pt());
596  fill("muonEta_", muon->eta());
597  fill("muonPhi_", muon->phi());
598 
599  }
600  }
601  }
602  }
603  fill("muonMult_", mMult); //loose
604  fill("muonMultTight_", mTight); //tight id & iso
605 
606  /*
607  ------------------------------------------------------------
608 
609  Jet Monitoring
610 
611  ------------------------------------------------------------
612  */
613 
614 
615 
616  // loop jet collection
617  std::vector<pat::Jet> correctedJets;
618  std::vector<double> JetTagValues;
619  pat::Jet TaggedJetCand;
620  vector<double> bJetDiscVal;
621 
622  unsigned int mult = 0, loosemult=0, multBCSVM = 0;
623 
625  if (!event.getByToken(jets_, jets)) {
626  return;
627  }
628 
629  for (edm::View<pat::Jet>::const_iterator jet = jets->begin();
630  jet != jets->end(); ++jet) {
631  // check jetID for calo jets
632  //unsigned int idx = jet - jets->begin();
633 
634  pat::Jet sel = *jet;
635 
636  if ( jetSelect==nullptr)
638 
639  if(!(*jetSelect)(sel))continue;
640 // if (!jetSelect(sel)) continue;
641 
642  // prepare jet to fill monitor histograms
643  pat::Jet monitorJet = *jet;
644 
645 
646  ++mult;
647 
648  if(monitorJet.chargedHadronEnergyFraction()>0 && monitorJet.chargedMultiplicity()>0 && monitorJet.chargedEmEnergyFraction()<0.99 && monitorJet.neutralHadronEnergyFraction()<0.99 && monitorJet.neutralEmEnergyFraction()<0.99 && (monitorJet.chargedMultiplicity()+monitorJet.neutralMultiplicity())>1 ){
649 
650  correctedJets.push_back(monitorJet);
651  ++loosemult; // determine jet multiplicity
652 
653  fill("jetBCSV_", monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags")); //hard coded discriminator and value right now.
654  if (monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags") > 0.89){
655 
656  if (multBCSVM == 0){
657  TaggedJetCand = monitorJet;
658  bJetDiscVal.push_back(monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags"));
659  }else if(multBCSVM == 1){
660  bJetDiscVal.push_back(monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags"));
661  if (bJetDiscVal[1] > bJetDiscVal[0]) TaggedJetCand = monitorJet;
662  }
663 
664  ++multBCSVM;
665  }
666 
667 
668 
669  // Fill a vector with Jet b-tag WP for later M3+1tag calculation: CSV
670  // tagger
671  JetTagValues.push_back(monitorJet.bDiscriminator("pfCombinedInclusiveSecondaryVertexV2BJetTags"));
672  // }
673  // fill pt (raw or L2L3) for the leading four jets
674  if (loosemult == 1) {
675  //cout<<" jet id= "<<monitorJet.chargedHadronEnergyFraction()<<endl;
676 
677  fill("jet1Pt_", monitorJet.pt());
678  //fill("jet1PtRaw_", jet->pt());
679  fill("jet1Eta_", monitorJet.eta());
680  };
681  if (loosemult == 2) {
682  fill("jet2Pt_", monitorJet.pt());
683  //fill("jet2PtRaw_", jet->pt());
684  fill("jet2Eta_", monitorJet.eta());
685  }
686 
687  }
688  }
689  fill("jetMult_", mult);
690  fill("jetLooseMult_", loosemult);
691  fill("jetMultBCSVM_", multBCSVM);
692 
693  /*
694  ------------------------------------------------------------
695 
696  MET Monitoring
697 
698  ------------------------------------------------------------
699  */
700 
701  // fill monitoring histograms for met
702 
703  pat::MET mET;
704 
705  for (std::vector<edm::EDGetTokenT<edm::View<pat::MET> > >::const_iterator
706  met_ = mets_.begin();
707  met_ != mets_.end(); ++met_) {
709  if (!event.getByToken(*met_, met)) continue;
710  if (met->begin() != met->end()) {
711  unsigned int idx = met_ - mets_.begin();
712  if (idx == 0) fill("slimmedMETs_", met->begin()->et());
713  if (idx == 1) fill("slimmedMETsNoHF_", met->begin()->et());
714  if (idx == 2) fill("slimmedMETsPuppi_", met->begin()->et());
715  }
716  }
717 
718  /*
719  ------------------------------------------------------------
720 
721  Event Monitoring
722 
723  ------------------------------------------------------------
724  */
725 
726  // fill W boson and top mass estimates
727 
728  Calculate_miniAOD eventKinematics(MAXJETS, WMASS);
729  double wMass = eventKinematics.massWBoson(correctedJets);
730  double topMass = eventKinematics.massTopQuark(correctedJets);
731  if (wMass >= 0 && topMass >= 0) {
732  fill("massW_", wMass);
733  fill("massTop_", topMass);
734  }
735 
736  // Fill M3 with Btag (CSV Tight) requirement
737 
738  // if (!includeBTag_) return;
739  //if (correctedJets.size() != JetTagValues.size()) return;
740  //double btopMass =
741  // eventKinematics.massBTopQuark(correctedJets, JetTagValues, 0.89); //hard coded CSVv2 value
742 
743  //if (btopMass >= 0) fill("massBTop_", btopMass);
744 
745  // fill plots for trigger monitoring
746  if ((lowerEdge_ == -1. && upperEdge_ == -1.) ||
747  (lowerEdge_ < wMass && wMass < upperEdge_)) {
749  fill(event, *triggerTable, "trigger", triggerPaths_);
750  if (logged_ <= hists_.find("eventLogger_")->second->getNbinsY()) {
751  // log runnumber, lumi block, event number & some
752  // more pysics infomation for interesting events
753  fill("eventLogger_", 0.5, logged_ + 0.5, event.eventAuxiliary().run());
754  fill("eventLogger_", 1.5, logged_ + 0.5,event.eventAuxiliary().luminosityBlock());
755  fill("eventLogger_", 2.5, logged_ + 0.5, event.eventAuxiliary().event());
756  if (correctedJets.size() > 0)
757  fill("eventLogger_", 3.5, logged_ + 0.5, correctedJets[0].pt());
758  if (correctedJets.size() > 1)
759  fill("eventLogger_", 4.5, logged_ + 0.5, correctedJets[1].pt());
760  if (correctedJets.size() > 2)
761  fill("eventLogger_", 5.5, logged_ + 0.5, correctedJets[2].pt());
762  if (correctedJets.size() > 3)
763  fill("eventLogger_", 6.5, logged_ + 0.5, correctedJets[3].pt());
764 
765  fill("eventLogger_", 7.5, logged_ + 0.5, wMass);
766  fill("eventLogger_", 8.5, logged_ + 0.5, topMass);
767  ++logged_;
768  }
769  }
770 
771  if (multBCSVM != 0 && mTight == 1) {
772 
773  double mtW = eventKinematics.tmassWBoson(&mu, mET, TaggedJetCand);
774  fill("MTWm_", mtW);
775  double MTT = eventKinematics.tmassTopQuark(&mu, mET, TaggedJetCand);
776  fill("mMTT_", MTT);
777  }
778 
779  if (multBCSVM != 0 && eMultIso == 1) {
780  double mtW = eventKinematics.tmassWBoson(&e, mET, TaggedJetCand);
781  fill("MTWe_", mtW);
782  double MTT = eventKinematics.tmassTopQuark(&e, mET, TaggedJetCand);
783  fill("eMTT_", MTT);
784  }
785 
786 
787 
788 
789 }
790 }
791 
793  : vertexSelect_(nullptr),
794  beamspot_(""),
795  beamspotSelect_(nullptr),
796  MuonStep(nullptr),
797  ElectronStep(nullptr),
798  PvStep(nullptr),
799  METStep(nullptr) {
800  JetSteps.clear();
801 
802  // configure preselection
803  edm::ParameterSet presel =
804  cfg.getParameter<edm::ParameterSet>("preselection");
805  if (presel.existsAs<edm::ParameterSet>("trigger")) {
807  presel.getParameter<edm::ParameterSet>("trigger");
808  triggerTable__ = consumes<edm::TriggerResults>(
809  trigger.getParameter<edm::InputTag>("src"));
810  triggerPaths_ = trigger.getParameter<std::vector<std::string> >("select");
811  }
812  if (presel.existsAs<edm::ParameterSet>("beamspot")) {
814  presel.getParameter<edm::ParameterSet>("beamspot");
815  beamspot_ = beamspot.getParameter<edm::InputTag>("src");
816  beamspot__ =
817  consumes<reco::BeamSpot>(beamspot.getParameter<edm::InputTag>("src"));
819  beamspot.getParameter<std::string>("select")));
820  }
821 
822  // conifgure the selection
823  sel_ = cfg.getParameter<std::vector<edm::ParameterSet> >("selection");
824  setup_ = cfg.getParameter<edm::ParameterSet>("setup");
825  for (unsigned int i = 0; i < sel_.size(); ++i) {
826  selectionOrder_.push_back(sel_.at(i).getParameter<std::string>("label"));
827  selection_[selectionStep(selectionOrder_.back())] = std::make_pair(
828  sel_.at(i),
829  std::unique_ptr<SingleTopTChannelLepton_miniAOD::MonitorEnsemble>(
831  selectionStep(selectionOrder_.back()).c_str(),
833  }
834  for (std::vector<std::string>::const_iterator selIt = selectionOrder_.begin();
835  selIt != selectionOrder_.end(); ++selIt) {
836  std::string key = selectionStep(*selIt), type = objectType(*selIt);
837  if (selection_.find(key) != selection_.end()) {
838  if (type == "muons") {
840  consumesCollector()));
841  }
842  if (type == "elecs") {
845  }
846  if (type == "pvs") {
848  consumesCollector()));
849  }
850  if (type == "jets") {
851  JetSteps.push_back(std::unique_ptr<SelectionStep<pat::Jet>>(
853  }
854 
855  if (type == "met") {
857  consumesCollector()));
858  }
859  }
860  }
861 }
863  edm::Run const &, edm::EventSetup const & ){
864 
865  for (auto selIt = selection_.begin(); selIt != selection_.end(); ++selIt) {
866  selIt->second.second->book(ibooker);
867  }
868 }
870  const edm::EventSetup& setup) {
871 
874  if (!event.getByToken(triggerTable__, triggerTable)) return;
875  if (!accept(event, *triggerTable, triggerPaths_)) return;
876  }
877  if (!beamspot__.isUninitialized()) {
879  if (!event.getByToken(beamspot__, beamspot)) return;
880  if (!(*beamspotSelect_)(*beamspot)) return;
881  }
882 
883  unsigned int passed = 0;
884  unsigned int nJetSteps = -1;
885 
886  for (std::vector<std::string>::const_iterator selIt = selectionOrder_.begin();
887  selIt != selectionOrder_.end(); ++selIt) {
888  std::string key = selectionStep(*selIt), type = objectType(*selIt);
889  if (selection_.find(key) != selection_.end()) {
890  if (type == "empty") {
891  selection_[key].second->fill(event, setup);
892  }
893  if (type == "muons" && MuonStep != nullptr) {
894  if (MuonStep->select(event)) {
895  ++passed;
896 
897  selection_[key].second->fill(event, setup);
898  } else
899  break;
900  }
901 
902  if (type == "elecs" && ElectronStep != nullptr) {
903 
904  if (ElectronStep->select(event)) {
905  ++passed;
906  selection_[key].second->fill(event, setup);
907  } else
908  break;
909  }
910 
911  if (type == "pvs" && PvStep != nullptr) {
912  if (PvStep->selectVertex(event)) {
913  ++passed;
914  selection_[key].second->fill(event, setup);
915  } else
916  break;
917  }
918 
919  if (type == "jets") {
920  nJetSteps++;
921  if (JetSteps[nJetSteps] != NULL) {
922  if (JetSteps[nJetSteps]->select(event, setup)) {
923  ++passed;
924  selection_[key].second->fill(event, setup);
925  } else
926  break;
927  }
928  }
929 
930  if (type == "met" && METStep != nullptr) {
931  if (METStep->select(event)) {
932  ++passed;
933  selection_[key].second->fill(event, setup);
934  } else
935  break;
936  }
937  }
938  }
939 }
940 
941 // Local Variables:
942 // show-trailing-whitespace: t
943 // truncate-lines: t
944 // End:
type
Definition: HCALResponse.h:21
Analysis-level MET class.
Definition: MET.h:43
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::ValueMap< float > > electronId_
electronId label
std::unique_ptr< SelectionStep< reco::Vertex > > PvStep
float neutralHadronEnergyFraction() const
neutralHadronEnergyFraction (relative to uncorrected jet energy)
Definition: Jet.h:374
EventAuxiliary const & eventAuxiliary() const override
Definition: Event.h:92
std::map< std::string, MonitorElement * > hists_
histogram container
edm::EDGetTokenT< edm::TriggerResults > triggerTable_
trigger table
double eta() const final
momentum pseudorapidity
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
std::vector< std::unique_ptr< SelectionStep< pat::Jet > > > JetSteps
float chargedHadronEnergyFraction() const
chargedHadronEnergyFraction (relative to uncorrected jet energy)
Definition: Jet.h:372
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
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
edm::EDGetTokenT< edm::View< pat::Electron > > elecs_
float chargedEmEnergyFraction() const
chargedEmEnergyFraction (relative to uncorrected jet energy)
Definition: Jet.h:376
RunNumber_t run() const
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
double pt() const final
transverse momentum
#define NULL
Definition: scimark2.h:8
int neutralMultiplicity() const
neutralMultiplicity
Definition: Jet.h:422
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::unique_ptr< StringCutObjectSelector< pat::Electron > > elecIso_
extra isolation criterion on electron
const Point & position() const
position
Definition: Vertex.h:109
std::unique_ptr< StringCutObjectSelector< pat::Muon > > muonIso_
extra isolation criterion on muon
LuminosityBlockNumber_t luminosityBlock() const
edm::EDGetTokenT< edm::View< pat::Jet > > jets_
input sources for monitoring
std::map< std::string, std::pair< edm::ParameterSet, std::unique_ptr< SingleTopTChannelLepton_miniAOD::MonitorEnsemble > > > selection_
std::unique_ptr< SelectionStep< pat::Muon > > MuonStep
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< StringCutObjectSelector< reco::Vertex > > pvSelect_
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
def pv(vc)
Definition: MetAnalyzer.py:6
std::string objectType(const std::string &label)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const int mu
Definition: Constants.h:22
bool isValid() const
Definition: HandleBase.h:74
std::unique_ptr< StringCutObjectSelector< pat::Electron > > elecSelect_
extra selection on electrons
edm::EDGetTokenT< reco::JetIDValueMap > jetIDLabel_
jetID as an extra selection type
std::vector< std::string > triggerPaths_
trigger paths
void book(DQMStore::IBooker &ibooker)
book histograms in subdirectory directory
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:136
met
===> hadronic RAZOR
Analysis-level electron class.
Definition: Electron.h:52
Analysis-level calorimeter jet class.
Definition: Jet.h:80
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Templated helper class to allow a selection on a certain object collection.
std::unique_ptr< SelectionStep< pat::MET > > METStep
std::unique_ptr< StringCutObjectSelector< pat::Jet > > jetSelect
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
std::unique_ptr< StringCutObjectSelector< reco::BeamSpot > > beamspotSelect_
string cut selector
std::unique_ptr< StringCutObjectSelector< pat::Muon > > muonSelect_
extra selection on muons
bool isUninitialized() const
Definition: EDGetToken.h:73
float neutralEmEnergyFraction() const
neutralEmEnergyFraction (relative to uncorrected jet energy)
Definition: Jet.h:378
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
Analysis-level muon class.
Definition: Muon.h:50
int chargedMultiplicity() const
chargedMultiplicity
Definition: Jet.h:684
EventNumber_t event() const
Definition: event.py:1
Definition: Run.h:43
std::unique_ptr< SelectionStep< pat::Electron > > ElectronStep