CMS 3D CMS Logo

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