CMS 3D CMS Logo

B2GDQM.cc
Go to the documentation of this file.
2 
3 #include <memory>
4 
5 // DQM
8 
9 // Framework
18 
19 // Candidate handling
26 
27 // Vertex utilities
30 
31 // Other
35 
36 // Math
44 
45 // vertexing
46 
47 // Transient tracks
55 
56 // JetCorrection
58 
59 // Substructure
62 
63 // ROOT
64 #include "TLorentzVector.h"
65 
66 // STDLIB
67 #include <iostream>
68 #include <iomanip>
69 #include <cstdio>
70 #include <string>
71 #include <sstream>
72 #include <cmath>
73 
74 using namespace edm;
75 using namespace std;
76 using namespace reco;
77 using namespace trigger;
78 
79 //
80 // -- Constructor
81 //
83 
84  edm::LogInfo("B2GDQM") << " Starting B2GDQM "
85  << "\n";
86 
87  typedef std::vector<edm::InputTag> vtag;
88 
89  // Get parameters from configuration file
90  // Trigger
91  theTriggerResultsCollection =
92  ps.getParameter<InputTag>("triggerResultsCollection");
93  triggerToken_ = consumes<edm::TriggerResults>(theTriggerResultsCollection);
94 
95  // Jets
96  jetLabels_ = ps.getParameter<std::vector<edm::InputTag> >("jetLabels");
97  for (std::vector<edm::InputTag>::const_iterator
98  jetlabel = jetLabels_.begin(),
99  jetlabelEnd = jetLabels_.end();
100  jetlabel != jetlabelEnd; ++jetlabel) {
101  jetTokens_.push_back(consumes<edm::View<reco::Jet> >(*jetlabel));
102  }
103  cmsTagLabel_ = ps.getParameter<edm::InputTag>("cmsTagLabel");
104  cmsTagToken_ = consumes<edm::View<reco::BasicJet> >(cmsTagLabel_);
105 
106  muonToken_ = consumes<edm::View<reco::Muon> >(
107  ps.getParameter<edm::InputTag>("muonSrc"));
108  electronToken_ = consumes<edm::View<reco::GsfElectron> >(
109  ps.getParameter<edm::InputTag>("electronSrc"));
110 
111  jetPtMins_ = ps.getParameter<std::vector<double> >("jetPtMins");
112  allHadPtCut_ = ps.getParameter<double>("allHadPtCut");
113  allHadRapidityCut_ = ps.getParameter<double>("allHadRapidityCut");
114  allHadDeltaPhiCut_ = ps.getParameter<double>("allHadDeltaPhiCut");
115 
116  semiMu_HadJetPtCut_ = ps.getParameter<double>("semiMu_HadJetPtCut");
117  semiMu_LepJetPtCut_ = ps.getParameter<double>("semiMu_LepJetPtCut");
118  semiMu_dphiHadCut_ = ps.getParameter<double>("semiMu_dphiHadCut");
119  semiMu_dRMin_ = ps.getParameter<double>("semiMu_dRMin");
120  semiMu_ptRel_ = ps.getParameter<double>("semiMu_ptRel");
121  muonSelect_ = std::make_shared<StringCutObjectSelector<reco::Muon> >(
122 
123  ps.getParameter<std::string>("muonSelect"));
124 
125  semiE_HadJetPtCut_ = ps.getParameter<double>("semiE_HadJetPtCut");
126  semiE_LepJetPtCut_ = ps.getParameter<double>("semiE_LepJetPtCut");
127  semiE_dphiHadCut_ = ps.getParameter<double>("semiE_dphiHadCut");
128  semiE_dRMin_ = ps.getParameter<double>("semiE_dRMin");
129  semiE_ptRel_ = ps.getParameter<double>("semiE_ptRel");
130  elecSelect_ = std::make_shared<StringCutObjectSelector<reco::GsfElectron> >(
131 
132  ps.getParameter<std::string>("elecSelect"));
133 
134  PFJetCorService_ = ps.getParameter<std::string>("PFJetCorService");
135 
136  // MET
137  PFMETLabel_ = ps.getParameter<InputTag>("pfMETCollection");
138  PFMETToken_ = consumes<std::vector<reco::PFMET> >(PFMETLabel_);
139 }
140 
141 //
142 // -- Destructor
143 //
145  edm::LogInfo("B2GDQM") << " Deleting B2GDQM "
146  << "\n";
147 }
148 
149 //
150 // -- Book histograms
151 //
153  edm::EventSetup const&) {
154 
155  bei.setCurrentFolder("Physics/B2G");
156 
157  //--- Jets
158 
159  for (unsigned int icoll = 0; icoll < jetLabels_.size(); ++icoll) {
160  std::stringstream ss;
161  ss << "Physics/B2G/" << jetLabels_[icoll].label();
162  bei.setCurrentFolder(ss.str());
163  pfJet_pt.push_back(
164  bei.book1D("pfJet_pt", "Pt of PFJet (GeV)", 50, 0.0, 1000));
165  pfJet_y.push_back(
166  bei.book1D("pfJet_y", "Rapidity of PFJet", 60, -6.0, 6.0));
167  pfJet_phi.push_back(bei.book1D("pfJet_phi", "#phi of PFJet (radians)", 60,
168  -3.14159, 3.14159));
169  pfJet_m.push_back(
170  bei.book1D("pfJet_m", "Mass of PFJet (GeV)", 50, 0.0, 500));
171  pfJet_chef.push_back(
172  bei.book1D("pfJet_pfchef", "PFJetID CHEF", 50, 0.0, 1.0));
173  pfJet_nhef.push_back(
174  bei.book1D("pfJet_pfnhef", "PFJetID NHEF", 50, 0.0, 1.0));
175  pfJet_cemf.push_back(
176  bei.book1D("pfJet_pfcemf", "PFJetID CEMF", 50, 0.0, 1.0));
177  pfJet_nemf.push_back(
178  bei.book1D("pfJet_pfnemf", "PFJetID NEMF", 50, 0.0, 1.0));
179 
180  boostedJet_subjetPt.push_back(
181  bei.book1D("boostedJet_subjetPt", "Pt of subjets (GeV)", 50, 0.0, 500));
182  boostedJet_subjetY.push_back(
183  bei.book1D("boostedJet_subjetY", "Rapidity of subjets", 60, -6.0, 6.0));
184  boostedJet_subjetPhi.push_back(bei.book1D("boostedJet_subjetPhi",
185  "#phi of subjets (radians)", 60,
186  -3.14159, 3.14159));
187  boostedJet_subjetM.push_back(bei.book1D(
188  "boostedJet_subjetM", "Mass of subjets (GeV)", 50, 0.0, 250.));
189  boostedJet_subjetN.push_back(
190  bei.book1D("boostedJet_subjetN", "Number of subjets", 10, 0, 10));
191  boostedJet_massDrop.push_back(bei.book1D(
192  "boostedJet_massDrop", "Mass drop for W-like jets", 50, 0.0, 1.0));
193  boostedJet_minMass.push_back(
194  bei.book1D("boostedJet_minMass",
195  "Minimum Mass Pairing for top-like jets", 50, 0.0, 250.0));
196  }
197 
198  bei.setCurrentFolder("Physics/B2G/MET");
199  pfMet_pt = bei.book1D("pfMet_pt", "Pf Missing p_{T}; GeV", 50, 0.0, 500);
200  pfMet_phi = bei.book1D("pfMet_phi", "Pf Missing p_{T} #phi;#phi (radians)",
201  35, -3.5, 3.5);
202 
203  //--- Mu+Jets
204  bei.setCurrentFolder("Physics/B2G/SemiMu");
205  semiMu_muPt = bei.book1D(
206  "semiMu_muPt", "Pt of Muon in #mu+Jets Channel (GeV)", 50, 0.0, 1000);
207  semiMu_muEta = bei.book1D("semiMu_muEta", "#eta of Muon in #mu+Jets Channel",
208  60, -6.0, 6.0);
209  semiMu_muPhi =
210  bei.book1D("semiMu_muPhi", "#phi of Muon in #mu+Jets Channel (radians)",
211  60, -3.14159, 3.14159);
212  semiMu_muDRMin =
213  bei.book1D("semiMu_muDRMin",
214  "#Delta R(E,nearest jet) in #mu+Jets Channel", 50, 0, 10.0);
215  semiMu_muPtRel = bei.book1D("semiMu_muPtRel",
216  "p_{T}^{REL} in #mu+Jets Channel", 60, 0, 300.);
217  semiMu_hadJetDR =
218  bei.book1D("semiMu_hadJetDR", "#Delta R(E,had jet) in #mu+Jets Channel",
219  50, 0, 10.0);
220  semiMu_hadJetPt = bei.book1D(
221  "semiMu_hadJetPt", "Pt of Leading Hadronic Jet in #mu+Jets Channel (GeV)",
222  50, 0.0, 1000);
223  semiMu_hadJetY = bei.book1D(
224  "semiMu_hadJetY", "Rapidity of Leading Hadronic Jet in #mu+Jets Channel",
225  60, -6.0, 6.0);
226  semiMu_hadJetPhi =
227  bei.book1D("semiMu_hadJetPhi",
228  "#phi of Leading Hadronic Jet in #mu+Jets Channel (radians)",
229  60, -3.14159, 3.14159);
230  semiMu_hadJetMass = bei.book1D(
231  "semiMu_hadJetMass",
232  "Mass of Leading Hadronic Jet in #mu+Jets Channel (GeV)", 50, 0.0, 500);
233  semiMu_hadJetMinMass = bei.book1D(
234  "semiMu_hadJetminMass",
235  "Minimum Mass Pairing for Leading Hadronic Jet in #mu+Jets Channel (GeV)",
236  50, 0.0, 250.0);
237  semiMu_mttbar = bei.book1D(
238  "semiMu_mttbar", "Mass of #mu+Jets ttbar Candidate", 100, 0., 5000.);
239 
240  //--- E+Jets
241  bei.setCurrentFolder("Physics/B2G/SemiE");
242  semiE_ePt = bei.book1D("semiE_ePt", "Pt of Electron in e+Jets Channel (GeV)",
243  50, 0.0, 1000);
244  semiE_eEta = bei.book1D("semiE_eEta", "#eta of Electron in e+Jets Channel",
245  60, -6.0, 6.0);
246  semiE_ePhi =
247  bei.book1D("semiE_ePhi", "#phi of Electron in e+Jets Channel (radians)",
248  60, -3.14159, 3.14159);
249  semiE_eDRMin = bei.book1D(
250  "semiE_eDRMin", "#Delta R(E,nearest jet) in e+Jets Channel", 50, 0, 10.0);
251  semiE_ePtRel =
252  bei.book1D("semiE_ePtRel", "p_{T}^{REL} in e+Jets Channel", 60, 0, 300.);
253  semiE_hadJetDR = bei.book1D(
254  "semiE_hadJetDR", "#Delta R(E,had jet) in e+Jets Channel", 50, 0, 10.0);
255  semiE_hadJetPt = bei.book1D(
256  "semiE_hadJetPt", "Pt of Leading Hadronic Jet in e+Jets Channel (GeV)",
257  50, 0.0, 1000);
258  semiE_hadJetY = bei.book1D(
259  "semiE_hadJetY", "Rapidity of Leading Hadronic Jet in e+Jets Channel", 60,
260  -6.0, 6.0);
261  semiE_hadJetPhi =
262  bei.book1D("semiE_hadJetPhi",
263  "#phi of Leading Hadronic Jet in e+Jets Channel (radians)", 60,
264  -3.14159, 3.14159);
265  semiE_hadJetMass = bei.book1D(
266  "semiE_hadJetMass",
267  "Mass of Leading Hadronic Jet in e+Jets Channel (GeV)", 50, 0.0, 500);
268  semiE_hadJetMinMass = bei.book1D(
269  "semiE_hadJetminMass",
270  "Minimum Mass Pairing for Leading Hadronic Jet in e+Jets Channel (GeV)",
271  50, 0.0, 250.0);
272  semiE_mttbar = bei.book1D("semiE_mttbar", "Mass of e+Jets ttbar Candidate",
273  100, 0., 5000.);
274 
275  //--- All-hadronic
276  bei.setCurrentFolder("Physics/B2G/AllHad");
277  allHad_pt0 = bei.book1D(
278  "allHad_pt0", "Pt of Leading All-Hadronic PFJet (GeV)", 50, 0.0, 1000);
279  allHad_y0 = bei.book1D("allHad_y0", "Rapidity of Leading All-Hadronic PFJet",
280  60, -6.0, 6.0);
281  allHad_phi0 =
282  bei.book1D("allHad_phi0", "#phi of Leading All-Hadronic PFJet (radians)",
283  60, -3.14159, 3.14159);
284  allHad_mass0 = bei.book1D(
285  "allHad_mass0", "Mass of Leading All-Hadronic PFJet (GeV)", 50, 0.0, 500);
286  allHad_minMass0 =
287  bei.book1D("allHad_minMass0",
288  "Minimum Mass Pairing for Leading All-Hadronic PFJet (GeV)",
289  50, 0.0, 250.0);
290  allHad_pt1 = bei.book1D(
291  "allHad_pt1", "Pt of Subleading All-Hadronic PFJet (GeV)", 50, 0.0, 1000);
292  allHad_y1 = bei.book1D(
293  "allHad_y1", "Rapidity of Subleading All-Hadronic PFJet", 60, -6.0, 6.0);
294  allHad_phi1 = bei.book1D("allHad_phi1",
295  "#phi of Subleading All-Hadronic PFJet (radians)",
296  60, -3.14159, 3.14159);
297  allHad_mass1 =
298  bei.book1D("allHad_mass1", "Mass of Subleading All-Hadronic PFJet (GeV)",
299  50, 0.0, 500);
300  allHad_minMass1 =
301  bei.book1D("allHad_minMass1",
302  "Minimum Mass Pairing for Subleading All-Hadronic PFJet (GeV)",
303  50, 0.0, 250.0);
304  allHad_mttbar = bei.book1D(
305  "allHad_mttbar", "Mass of All-Hadronic ttbar Candidate", 100, 0., 5000.);
306 }
307 
308 //
309 // -- Analyze
310 //
311 void B2GDQM::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
312 
313  analyzeJets(iEvent, iSetup);
314  analyzeSemiMu(iEvent, iSetup);
315  analyzeSemiE(iEvent, iSetup);
316  analyzeAllHad(iEvent, iSetup);
317 }
318 
319 void B2GDQM::analyzeJets(const Event& iEvent, const edm::EventSetup& iSetup) {
320 
321  // Loop over the different types of jets,
322  // Loop over the jets in that collection,
323  // fill PF jet information as well as substructure
324  // information for boosted jets.
325  // Utilizes the CMS top-tagging algorithm and the "mass drop" W-tagger.
326  for (unsigned int icoll = 0; icoll < jetLabels_.size(); ++icoll) {
327 
328  edm::Handle<edm::View<reco::Jet> > pfJetCollection;
329  bool ValidPFJets = iEvent.getByToken(jetTokens_[icoll], pfJetCollection);
330  if (!ValidPFJets) continue;
331  edm::View<reco::Jet> const& pfjets = *pfJetCollection;
332 
333  // Jet Correction
334  int countJet = 0;
335  // const JetCorrector* pfcorrector =
336  // JetCorrector::getJetCorrector(PFJetCorService_,iSetup);
337 
339  jetEnd = pfjets.end();
340  jet != jetEnd; ++jet) {
341  if (jet->pt() < jetPtMins_[icoll]) continue;
342  pfJet_pt[icoll]->Fill(jet->pt());
343  pfJet_y[icoll]->Fill(jet->rapidity());
344  pfJet_phi[icoll]->Fill(jet->phi());
345  pfJet_m[icoll]->Fill(jet->mass());
346 
347  // Dynamic cast the base class (reco::Jet) to the derived class (PFJet)
348  // to access the PFJet information
349  reco::PFJet const* pfjet = dynamic_cast<reco::PFJet const*>(&*jet);
350 
351  if (pfjet != nullptr) {
352  pfJet_chef[icoll]->Fill(pfjet->chargedHadronEnergyFraction());
353  pfJet_nhef[icoll]->Fill(pfjet->neutralHadronEnergyFraction());
354  pfJet_cemf[icoll]->Fill(pfjet->chargedEmEnergyFraction());
355  pfJet_nemf[icoll]->Fill(pfjet->neutralEmEnergyFraction());
356  }
357 
358  // Dynamic cast the base class (reco::Jet) to the derived class (BasicJet)
359  // to access the substructure information
360  reco::BasicJet const* basicjet =
361  dynamic_cast<reco::BasicJet const*>(&*jet);
362 
363  if (basicjet != nullptr) {
364  boostedJet_subjetN[icoll]->Fill(jet->numberOfDaughters());
365 
366  for (unsigned int ida = 0; ida < jet->numberOfDaughters(); ++ida) {
367  reco::Candidate const* subjet = jet->daughter(ida);
368  boostedJet_subjetPt[icoll]->Fill(subjet->pt());
369  boostedJet_subjetY[icoll]->Fill(subjet->rapidity());
370  boostedJet_subjetPhi[icoll]->Fill(subjet->phi());
371  boostedJet_subjetM[icoll]->Fill(subjet->mass());
372  }
373  // Check the various tagging algorithms
374 
375  // For top-tagging, check the minimum mass pairing
376  if (jetLabels_[icoll].label() == "cmsTopTagPFJetsCHS") {
377  CATopJetHelper helper(173., 80.4);
378  reco::CATopJetProperties properties = helper(*basicjet);
379  if (jet->numberOfDaughters() > 2) {
380  boostedJet_minMass[icoll]->Fill(properties.minMass);
381  } else {
382  boostedJet_minMass[icoll]->Fill(-1.0);
383  }
384 
385  // For W-tagging, check the mass drop
386  } else if ((jetLabels_[icoll].label() == "ak8PFJetsCHSPruned")||(jetLabels_[icoll].label() == "ak8PFJetsCHSSoftdrop")) {
387  if (jet->numberOfDaughters() > 1) {
388  reco::Candidate const* da0 = jet->daughter(0);
389  reco::Candidate const* da1 = jet->daughter(1);
390  if (da0->mass() > da1->mass()) {
391  boostedJet_massDrop[icoll]->Fill(da0->mass() / jet->mass());
392  } else {
393  boostedJet_massDrop[icoll]->Fill(da1->mass() / jet->mass());
394  }
395  } else {
396  boostedJet_massDrop[icoll]->Fill(-1.0);
397  }
398 
399  } // end if collection is AK8 PFJets CHS Pruned
400 
401  } // end if basic jet != 0
402  countJet++;
403  }
404  }
405 
406  // PFMETs
407  edm::Handle<std::vector<reco::PFMET> > pfMETCollection;
408  bool ValidPFMET = iEvent.getByToken(PFMETToken_, pfMETCollection);
409  if (!ValidPFMET) return;
410 
411  pfMet_pt->Fill((*pfMETCollection)[0].pt());
412  pfMet_phi->Fill((*pfMETCollection)[0].phi());
413 }
414 
415 void B2GDQM::analyzeAllHad(const Event& iEvent, const edm::EventSetup& iSetup) {
416 
418  bool validJets = iEvent.getByToken(cmsTagToken_, jetCollection);
419  if (!validJets) return;
420 
421  // Require two back-to-back jets at high pt with |delta y| < 1.0
422  if (jetCollection->size() < 2) return;
423  edm::Ptr<reco::BasicJet> jet0 = jetCollection->ptrAt(0);
424  edm::Ptr<reco::BasicJet> jet1 = jetCollection->ptrAt(1);
425  if (jet0.isAvailable() == false || jet1.isAvailable() == false) return;
426  if (jet0->pt() < allHadPtCut_ || jet1->pt() < allHadPtCut_) return;
427  if (std::abs(jet0->rapidity() - jet1->rapidity()) > allHadRapidityCut_)
428  return;
429  if (std::abs(reco::deltaPhi(jet0->phi(), jet1->phi())) < M_PI * 0.5) return;
430 
431  CATopJetHelper helper(173., 80.4);
432 
433  allHad_pt0->Fill(jet0->pt());
434  allHad_y0->Fill(jet0->rapidity());
435  allHad_phi0->Fill(jet0->phi());
436  allHad_mass0->Fill(jet0->mass());
437  reco::CATopJetProperties properties0 = helper(*jet0);
438  if (jet0->numberOfDaughters() > 2) {
439  allHad_minMass0->Fill(properties0.minMass);
440  } else {
441  allHad_minMass0->Fill(-1.0);
442  }
443 
444  allHad_pt1->Fill(jet1->pt());
445  allHad_y1->Fill(jet1->rapidity());
446  allHad_phi1->Fill(jet1->phi());
447  allHad_mass1->Fill(jet1->mass());
448  reco::CATopJetProperties properties1 = helper(*jet1);
449  if (jet1->numberOfDaughters() > 2) {
450  allHad_minMass1->Fill(properties1.minMass);
451  } else {
452  allHad_minMass1->Fill(-1.0);
453  }
454 
455  auto p4cand = (jet0->p4() + jet1->p4());
456  allHad_mttbar->Fill(p4cand.mass());
457 }
458 
459 void B2GDQM::analyzeSemiMu(const Event& iEvent, const edm::EventSetup& iSetup) {
460 
462  bool validMuons = iEvent.getByToken(muonToken_, muonCollection);
463 
464  if (!validMuons) return;
465  if (muonCollection->empty()) return;
466  reco::Muon const& muon = muonCollection->at(0);
467  if (!(*muonSelect_)(muon)) return;
468 
470  bool validJets = iEvent.getByToken(cmsTagToken_, jetCollection);
471  if (!validJets) return;
472  if (jetCollection->size() < 2) return;
473 
474  double pt0 = -1.0;
475  double dRMin = 999.0;
476  edm::Ptr<reco::BasicJet> hadJet; // highest pt jet with dphi(lep,jet) > pi/2
477  edm::Ptr<reco::BasicJet> lepJet; // closest jet to lepton with pt > ptMin
478 
479  for (auto ijet = jetCollection->begin(), ijetBegin = ijet,
480  ijetEnd = jetCollection->end();
481  ijet != ijetEnd; ++ijet) {
482  // Hadronic jets
483  if (std::abs(reco::deltaPhi(muon, *ijet)) > M_PI * 0.5) {
484  if (ijet->pt() > pt0 && ijet->p() > semiMu_HadJetPtCut_) {
485  hadJet = jetCollection->ptrAt(ijet - ijetBegin);
486  pt0 = hadJet->pt();
487  }
488  }
489  // Leptonic jets
490  else if (ijet->pt() > semiMu_LepJetPtCut_) {
491  auto idRMin = reco::deltaR(muon, *ijet);
492  if (idRMin < dRMin) {
493  lepJet = jetCollection->ptrAt(ijet - ijetBegin);
494  dRMin = idRMin;
495  }
496  }
497  }
498  if (hadJet.isAvailable() == false || lepJet.isAvailable() == false) return;
499 
500  auto lepJetP4 = lepJet->p4();
501  const auto& muonP4 = muon.p4();
502 
503  double tot = lepJetP4.mag2();
504  double ss = muonP4.Dot(lepJet->p4());
505  double per = muonP4.mag2();
506  if (tot > 0.0) per -= ss * ss / tot;
507  if (per < 0) per = 0;
508  double ptRel = per;
509  bool pass2D = dRMin > semiMu_dRMin_ || ptRel > semiMu_ptRel_;
510 
511  if (!pass2D) return;
512 
513  CATopJetHelper helper(173., 80.4);
514 
515  semiMu_muPt->Fill(muon.pt());
516  semiMu_muEta->Fill(muon.eta());
517  semiMu_muPhi->Fill(muon.phi());
518  semiMu_muDRMin->Fill(dRMin);
519  semiMu_muPtRel->Fill(ptRel);
520 
521  semiMu_hadJetDR->Fill(reco::deltaR(muon, *hadJet));
522  semiMu_mttbar->Fill(0.0);
523 
524  semiMu_hadJetPt->Fill(hadJet->pt());
525  semiMu_hadJetY->Fill(hadJet->rapidity());
526  semiMu_hadJetPhi->Fill(hadJet->phi());
527  semiMu_hadJetMass->Fill(hadJet->mass());
528  reco::CATopJetProperties properties0 = helper(*hadJet);
529  if (hadJet->numberOfDaughters() > 2) {
530  semiMu_hadJetMinMass->Fill(properties0.minMass);
531  } else {
532  semiMu_hadJetMinMass->Fill(-1.0);
533  }
534 }
535 
536 void B2GDQM::analyzeSemiE(const Event& iEvent, const edm::EventSetup& iSetup) {
537 
539  bool validElectrons = iEvent.getByToken(electronToken_, electronCollection);
540 
541  if (!validElectrons) return;
542  if (electronCollection->empty()) return;
543  reco::GsfElectron const& electron = electronCollection->at(0);
544  if (!(*elecSelect_)(electron)) return;
545 
547  bool validJets = iEvent.getByToken(cmsTagToken_, jetCollection);
548  if (!validJets) return;
549  if (jetCollection->size() < 2) return;
550 
551  double pt0 = -1.0;
552  double dRMin = 999.0;
553  edm::Ptr<reco::BasicJet> hadJet; // highest pt jet with dphi(lep,jet) > pi/2
554  edm::Ptr<reco::BasicJet> lepJet; // closest jet to lepton with pt > ptMin
555 
556  for (auto ijet = jetCollection->begin(), ijetBegin = ijet,
557  ijetEnd = jetCollection->end();
558  ijet != ijetEnd; ++ijet) {
559  // Hadronic jets
560  if (std::abs(reco::deltaPhi(electron, *ijet)) > M_PI * 0.5) {
561  if (ijet->pt() > pt0 && ijet->p() > semiE_HadJetPtCut_) {
562  hadJet = jetCollection->ptrAt(ijet - ijetBegin);
563  pt0 = hadJet->pt();
564  }
565  }
566  // Leptonic jets
567  else if (ijet->pt() > semiE_LepJetPtCut_) {
568  auto idRMin = reco::deltaR(electron, *ijet);
569  if (idRMin < dRMin) {
570  lepJet = jetCollection->ptrAt(ijet - ijetBegin);
571  dRMin = idRMin;
572  }
573  }
574  }
575  if (hadJet.isAvailable() == false || lepJet.isAvailable() == false) return;
576 
577  auto lepJetP4 = lepJet->p4();
578  const auto& electronP4 = electron.p4();
579 
580  double tot = lepJetP4.mag2();
581  double ss = electronP4.Dot(lepJet->p4());
582  double per = electronP4.mag2();
583  if (tot > 0.0) per -= ss * ss / tot;
584  if (per < 0) per = 0;
585  double ptRel = per;
586  bool pass2D = dRMin > semiE_dRMin_ || ptRel > semiE_ptRel_;
587 
588  if (!pass2D) return;
589 
590  CATopJetHelper helper(173., 80.4);
591 
592  semiE_ePt->Fill(electron.pt());
593  semiE_eEta->Fill(electron.eta());
594  semiE_ePhi->Fill(electron.phi());
595  semiE_eDRMin->Fill(dRMin);
596  semiE_ePtRel->Fill(ptRel);
597 
598  semiE_hadJetDR->Fill(reco::deltaR(electron, *hadJet));
599  semiE_mttbar->Fill(0.0);
600 
601  semiE_hadJetPt->Fill(hadJet->pt());
602  semiE_hadJetY->Fill(hadJet->rapidity());
603  semiE_hadJetPhi->Fill(hadJet->phi());
604  semiE_hadJetMass->Fill(hadJet->mass());
605  reco::CATopJetProperties properties0 = helper(*hadJet);
606  if (hadJet->numberOfDaughters() > 2) {
607  semiE_hadJetMinMass->Fill(properties0.minMass);
608  } else {
609  semiE_hadJetMinMass->Fill(-1.0);
610  }
611 }
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
T getParameter(std::string const &) const
double eta() const final
momentum pseudorapidity
Definition: helper.py:1
virtual void analyzeSemiMu(edm::Event const &e, edm::EventSetup const &eSetup)
Definition: B2GDQM.cc:459
~B2GDQM() override
Definition: B2GDQM.cc:144
virtual void analyzeAllHad(edm::Event const &e, edm::EventSetup const &eSetup)
Definition: B2GDQM.cc:415
const LorentzVector & p4(P4Kind kind) const
Definition: GsfElectron.cc:225
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
float chargedHadronEnergyFraction() const
chargedHadronEnergyFraction
Definition: PFJet.h:100
double rapidity() const final
rapidity
bool isAvailable() const
Definition: Ptr.h:258
double pt() const final
transverse momentum
void bookHistograms(DQMStore::IBooker &bei, edm::Run const &, edm::EventSetup const &) override
Definition: B2GDQM.cc:152
Jets made from CaloTowers.
Definition: BasicJet.h:20
Jets made from PFObjects.
Definition: PFJet.h:21
size_t numberOfDaughters() const override
number of daughters
float neutralEmEnergyFraction() const
neutralEmEnergyFraction
Definition: PFJet.h:152
int iEvent
Definition: GenABIO.cc:230
const_iterator begin() const
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float neutralHadronEnergyFraction() const
neutralHadronEnergyFraction
Definition: PFJet.h:104
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
virtual void analyzeSemiE(edm::Event const &e, edm::EventSetup const &eSetup)
Definition: B2GDQM.cc:536
#define M_PI
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
float chargedEmEnergyFraction() const
chargedEmEnergyFraction
Definition: PFJet.h:144
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
virtual double pt() const =0
transverse momentum
B2GDQM(const edm::ParameterSet &ps)
Definition: B2GDQM.cc:82
virtual double mass() const =0
mass
void analyze(edm::Event const &e, edm::EventSetup const &eSetup) override
Definition: B2GDQM.cc:311
virtual void analyzeJets(edm::Event const &e, edm::EventSetup const &eSetup)
Definition: B2GDQM.cc:319
virtual double rapidity() const =0
rapidity
fixed size matrix
HLT enums.
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
const_iterator end() const
double phi() const final
momentum azimuthal angle
virtual double phi() const =0
momentum azimuthal angle
Definition: Run.h:44
double mass() const final
mass
int icoll
Definition: AMPTWrapper.h:136