DESY Hbb Analysis Framework
Jet.cc
Go to the documentation of this file.
1 // system include files
2 //
3 // user include files
4 #include "FWCore/Framework/interface/Event.h"
5 //
6 #include "FWCore/ParameterSet/interface/ParameterSet.h"
7 
9 
10 #include "TRandom3.h"
11 //
12 // class declaration
13 //
14 
15 using namespace analysis;
16 using namespace analysis::tools;
17 
18 //
19 // constructors and destructor
20 //
22 {
23  extendedFlavour_ = "?";
24  btagAlgo_ = "";
25  fsr_ = nullptr;
26  muon_ = nullptr;
27  uncorrJetp4_ = p4_;
28  genjet_ = nullptr;
29  jermatch_ = false;
30 
31 }
32 Jet::Jet(const float & pt, const float & eta, const float & phi, const float & e) : Candidate(pt,eta,phi,e,0.)
33 {
34  extendedFlavour_ = "?";
35  btagAlgo_ = "";
36  fsr_ = nullptr;
37  muon_ = nullptr;
38  uncorrJetp4_ = p4_;
39  genjet_ = nullptr;
40  jermatch_ = false;
41 
42 
43 }
44 
46 {
47  // do anything here that needs to be done at desctruction time
48  // (e.g. close files, deallocate resources etc.)
49 }
50 
51 //
52 // member functions
53 //
54 // Gets
55 bool Jet::isPuppi() const { return isPuppi_; }
56 //float Jet::btag() const { return btags_.at(btagAlgo_); }
57 float Jet::btag(const std::string & algo) const { return btags_.at(algo); }
58 int Jet::flavour() const { return flavour_.at("Hadron"); }
59 int Jet::flavour(const std::string & definition) const { return flavour_.at(definition); }
60 bool Jet::idLoose() const { return idloose_; }
61 bool Jet::idTight() const { return idtight_; }
62 float Jet::jecUncert() const { return jecUnc_; }
63 std::vector<int> Jet::flavours() const { return flavours_; }
64 std::vector< std::shared_ptr<GenParticle> >\
65  Jet::partons() const { return partons_; }
66 std::string Jet::extendedFlavour() const { return extendedFlavour_; }
67 // float Jet::jerPtResolution() const { return jerptres_;}
68 // float Jet::jerSF() const { return jersf_; }
69 // float Jet::jerSFdown() const { return jersfdown_; }
70 // float Jet::jerSFup() const { return jersfup_; }
72 float Jet::jerSF() const { return jerSF(jerinfo_.scalefactor); }
73 float Jet::jerSFdown() const { return jerSFdown(jerinfo_.scalefactor); }
74 float Jet::jerSFup() const { return jerSFup(jerinfo_.scalefactor); }
75 //
76 float Jet::jerPtResolution(const JetResolution & jer) const
77 {
78  JetParameters pars = {{JME::Binning::JetPt, this->pt()}, {JME::Binning::JetEta, this->eta()}, {JME::Binning::Rho, this->rho()}};
79  float res = jer.getResolution(pars);
80  return res;
81 }
82 float Jet::jerSF(const JetResolutionScaleFactor & jersf) const
83 {
84  JetParameters pars = {{JME::Binning::JetPt, this->pt()},{JME::Binning::JetEta, this->eta()}};
85  float sf = jersf.getScaleFactor(pars);
86  return sf;
87 }
88 float Jet::jerSFdown(const JetResolutionScaleFactor & jersf) const
89 {
90  JetParameters pars = {{JME::Binning::JetPt, this->pt()},{JME::Binning::JetEta, this->eta()}};
91  float sf = jersf.getScaleFactor(pars,Variation::DOWN);
92  return sf;
93 }
94 float Jet::jerSFup(const JetResolutionScaleFactor & jersf) const
95 {
96  JetParameters pars = {{JME::Binning::JetPt, this->pt()},{JME::Binning::JetEta, this->eta()}};
97  float sf = jersf.getScaleFactor(pars,Variation::UP);
98  return sf;
99 }
100 
101 bool Jet::jerMatch(const std::string & collection)
102 {
103  float res = this->jerPtResolution();
104  jermatch_ = this->matched("GenJets"); // delta_R matching
105  jermatch_ = jermatch_ && (fabs(this->pt()-this->matched("GenJets")->pt()) < 3.*res*this->pt()); // delta pT
106 
107  return jermatch_;
108 
109 }
110 
111 bool Jet::jerMatch(const float & drmin)
112 {
113  float res = this->jerPtResolution();
114 
115  std::shared_ptr<GenJet> cand = nullptr;
116  std::shared_ptr<GenJet> nearcand = nullptr;
117  genjet_ = nullptr;
118  float minDeltaR = 100.;
119  for ( size_t i = 0; i < genjets_.size() ; ++i )
120  {
121  cand = genjets_.at(i);
122  if(this->deltaR(*cand) < minDeltaR)
123  {
124  minDeltaR = this->deltaR(*cand);
125  nearcand = cand;
126  }
127  }
128  if(minDeltaR < drmin) jermatch_ = true;
129  else return false;
130 
131  jermatch_ = jermatch_ && (fabs(this->pt()-nearcand->pt()) < 3.*res*this->pt()); // delta pT
132 
133  if (jermatch_) genjet_= nearcand;
134 
135  return jermatch_;
136 
137 }
138 
139 
140 bool Jet::jerMatch() const
141 {
142  return jermatch_;
143 }
145 {
146  float c = 1.;
147  float cup = 1.;
148  float cdown = 1.;
149 
150  float sf = this->jerSF();
151  float sfup = this->jerSFup();
152  float sfdown = this->jerSFdown();
153 
154  if ( jermatch_ )
155  {
156 // c += (sf-1)*((this->pt() - genjet_->pt())/this->pt());
157 // cup += (sfup-1)*((this->pt() - genjet_->pt())/this->pt());
158 // cdown += (sfdown-1)*((this->pt() - genjet_->pt())/this->pt());
159  // to avoid problems with regression corrections, use "uncorrected"
160  c += (sf-1)*((this->pt() - genjet_->pt())/uncorrJetp4_.Pt());
161  cup += (sfup-1)*((this->pt() - genjet_->pt())/uncorrJetp4_.Pt());
162  cdown += (sfdown-1)*((this->pt() - genjet_->pt())/uncorrJetp4_.Pt());
163  }
164  else
165  {
166  TRandom3 r(0);
167  float n = r.Gaus(0.,this->jerPtResolution());
168  c += n*sqrt(std::max(sf*sf-1.,0.));
169  cup += n*sqrt(std::max(sfup*sfup-1.,0.));
170  cdown += n*sqrt(std::max(sfdown*sfdown-1.,0.));
171  }
172 
173  jercorr_.nominal = c;
174  jercorr_.up = cup;
175  jercorr_.down = cdown;
176 
177 }
178 
179 float Jet::jerCorrection(const std::string & var, const float & nsig ) const
180 {
181  float corr = jercorr_.nominal;
182  std::string v = var;
183  std::transform(v.begin(), v.end(), v.begin(), ::tolower);
184  if ( v == "up" )
185  {
186  corr = jercorr_.nominal + (fabs(jercorr_.nominal-jercorr_.up)*nsig);
187 // corr = jercorr_.up;
188  }
189  if ( v == "down" )
190  {
191  corr = jercorr_.nominal - (fabs(jercorr_.nominal-jercorr_.down)*nsig);
192 // corr = jercorr_.down;
193  }
194 
195  return corr;
196 
197 }
198 
199 void Jet::jerInfo(const JetResolutionInfo & jerinfo, const std::string & collection)
200 {
201  jerinfo_ = jerinfo;
202  jerMatch("GenJets");
203  jerCorrections();
204 }
205 
206 void Jet::jerInfo(const JetResolutionInfo & jerinfo, const float & drmin)
207 {
208  jerinfo_ = jerinfo;
209  jerMatch(drmin);
210  jerCorrections();
211 }
212 
213 void Jet::applyJER(const JetResolutionInfo & jerinfo, const float & drmin)
214 {
215  this -> jerInfo(jerinfo,drmin);
216  p4_ = p4_ *this->jerCorrection();
217 }
218 
219 
220 
221 //
222 float Jet::neutralHadronFraction() const { return nHadFrac_; }
223 float Jet::neutralEmFraction() const { return nEmFrac_; }
224 float Jet::neutralMultiplicity() const { return nMult_; }
225 float Jet::chargedHadronFraction() const { return cHadFrac_; }
226 float Jet::chargedEmFraction() const { return cEmFrac_; }
227 float Jet::chargedMultiplicity() const { return cMult_; }
228 float Jet::muonFraction() const { return muFrac_; }
229 float Jet::constituents() const { return nConst_; }
230 
231 float Jet::qgLikelihood() const { return qgLikelihood_; }
233 int Jet::pileupJetIdFullId() const { return puJetIdFullId_; }
234 
235 float Jet::bRegCorr() const { return bRegCorr_; }
236 float Jet::bRegRes() const { return bRegRes_; }
237 
239 {
240  float pt = p4_.Pt()*this->bRegCorr();
241  float eta = p4_.Eta();
242  float phi = p4_.Phi();
243  float e = p4_.E()*this->bRegCorr();
244  p4_.SetPtEtaPhiE(pt,eta,phi,e);
245 }
246 
247 
248 
249 
250 double Jet::rho() const { return rho_; }
251 
252 
253 bool Jet::id(const std::string & wp) const
254 {
255  bool id = false;
256  if ( wp == "none" ) id = true;
257  if ( wp == "tight" ) id = idtight_;
258  if ( wp == "loose" ) id = idloose_;
259 
260  return id;
261 }
262 
263 
264 std::shared_ptr<GenJet> Jet::generatedJet() const { return genjet_; }
265 
266 // GenJet * Jet::generatedJet(const std::vector<GenJet*> & genjets, const float & deltaR)
267 // {
268 // GenJet * cand = nullptr;
269 // GenJet * nearcand = nullptr;
270 // genjet_ = nullptr;
271 // float minDeltaR = 100.;
272 // for ( size_t j = 0; j < genjets.size() ; ++j )
273 // {
274 // cand = genjets.at(j);
275 // if(this->deltaR(*cand) < minDeltaR)
276 // {
277 // minDeltaR = this->deltaR(*cand);
278 // nearcand = cand;
279 // }
280 // }
281 // if(minDeltaR < deltaR)
282 // {
283 // genjet_ = nearcand;
284 // }
285 //
286 // return genjet_;
287 // }
288 
289 double Jet::btagSFsys(std::shared_ptr<BTagCalibrationReader> reader, const std::string & systype, const std::string & flavalgo) const
290 {
291  double sf = 1;
292 
293  if ( reader == nullptr ) return sf;
294 
295 // if ( this->flavour(flavalgo) == 5 ) sf = reader->eval_auto_bounds(systype, BTagEntry::FLAV_B, fabs(this->eta()), this->pt() );
296 // if ( this->flavour(flavalgo) == 4 ) sf = reader->eval_auto_bounds(systype, BTagEntry::FLAV_C, fabs(this->eta()), this->pt() );
297 // if ( this->flavour(flavalgo) == 0 ) sf = reader->eval_auto_bounds(systype, BTagEntry::FLAV_UDSG, fabs(this->eta()), this->pt() );
298 
299 // to avoid problems with other corrections
300  if ( this->flavour(flavalgo) == 5 ) sf = reader->eval_auto_bounds(systype, BTagEntry::FLAV_B, fabs(uncorrJetp4_.Eta()), uncorrJetp4_.Pt() );
301  if ( this->flavour(flavalgo) == 4 ) sf = reader->eval_auto_bounds(systype, BTagEntry::FLAV_C, fabs(uncorrJetp4_.Eta()), uncorrJetp4_.Pt() );
302  if ( this->flavour(flavalgo) == 0 ) sf = reader->eval_auto_bounds(systype, BTagEntry::FLAV_UDSG, fabs(uncorrJetp4_.Eta()), uncorrJetp4_.Pt() );
303 
304  return sf;
305 }
306 
307 double Jet::btagSF(std::shared_ptr<BTagCalibrationReader> reader, const std::string & flavalgo) const
308 {
309  return this -> btagSFsys(reader,"central",flavalgo);
310 }
311 double Jet::btagSFup(std::shared_ptr<BTagCalibrationReader> reader, const float & nsig, const std::string & flavalgo) const
312 {
313  double sf = this -> btagSFsys(reader,"central",flavalgo);
314  double sfup = this -> btagSFsys(reader,"up",flavalgo);
315  double sig1 = fabs(sfup - sf);
316  sfup = sf+(nsig*sig1);
317 
318  return sfup;
319 }
320 double Jet::btagSFdown(std::shared_ptr<BTagCalibrationReader> reader, const float & nsig, const std::string & flavalgo) const
321 {
322  double sf = this -> btagSFsys(reader,"central",flavalgo);
323  double sfdown = this -> btagSFsys(reader,"down",flavalgo);
324  double sig1 = fabs(sfdown - sf);
325  sfdown = sf-(nsig*sig1);
326 
327  return sfdown;
328 }
329 
330 
331 bool Jet::pileupJetIdFullId(const std::string & wp) const
332 {
333  std::string wplow = wp;
334  std::transform(wplow.begin(), wplow.end(), wplow.begin(), ::tolower);
335  if ( puJetIdFullId_ < 0 )
336  {
337  std::cout << "analysis:tools::Jet *W* Pileup Jet ID FullId is negative; the collection may not have this information." << std::endl;
338  std::cout << " All jets are accepted." << std::endl;
339  return true;
340  }
341  if ( wplow == "none" ) return true;
342  if ( wplow == "loose" && (puJetIdFullId_ & (1 << 2)) ) return true;
343  if ( wplow == "medium" && (puJetIdFullId_ & (1 << 1)) ) return true;
344  if ( wplow == "tight" && (puJetIdFullId_ & (1 << 0)) ) return true;
345  return false;
346 }
347 
348 
349 
350 // Sets
351 void Jet::isPuppi (const bool & ispuppi) { isPuppi_ = ispuppi; }
352 void Jet::btag (const float & btag) { btag_ = btag; }
353 void Jet::btag (const std::string & algo, const float & btag) { btags_[algo] = btag; }
354 void Jet::flavour (const int & flav) { flavour_["Hadron"] = flav; }
355 void Jet::flavour (const std::string & definition, const int & flav) { flavour_[definition] = flav; }
356 void Jet::idLoose (const bool & loos) { idloose_ = loos; }
357 void Jet::idTight (const bool & tigh) { idtight_ = tigh; }
358 void Jet::jecUncert(const float & ju) { jecUnc_ = ju; }
359 void Jet::addParton(const std::shared_ptr<GenParticle> & parton) { partons_.push_back(parton);
360  flavours_.push_back(parton->pdgId()); }
361 void Jet::btagAlgo (const std::string & algo ) { btagAlgo_ = algo; }
362 
363 void Jet::jerPtResolution(const float & res) { jerptres_ = res; }
364 void Jet::jerSF(const float & sf) { jersf_ = sf; }
365 void Jet::jerSFdown(const float & sfd) { jersfdown_ = sfd; }
366 void Jet::jerSFup(const float & sfu) { jersfup_ = sfu; }
367 
368 void Jet::qgLikelihood(const float & discr) { qgLikelihood_ = discr; }
369 void Jet::pileupJetIdFullDiscriminant(const float & discr) { puJetIdFullDisc_ = discr; }
370 void Jet::pileupJetIdFullId(const int & id) { puJetIdFullId_ = id; }
371 
372 void Jet::bRegCorr(const float & bRegCorr) { bRegCorr_ = bRegCorr; }
373 void Jet::bRegRes(const float & bRegRes) { bRegRes_ = bRegRes; }
374 
375 void Jet::rho(const double & rho) { rho_ = rho; }
376 
377 void Jet::generatedJet(std::shared_ptr<GenJet> genjet) { genjet_ = genjet; }
378 
379 
380 int Jet::removeParton(const int & i)
381 {
382  if ( partons_.size() == 1 )
383  {
384  partons_.clear();
385  flavours_.clear();
386  }
387  else
388  {
389  partons_.erase(partons_.begin()+i);
390  flavours_.erase(flavours_.begin()+i);
391  }
392 
393  // re-do the extendedFlavour
394  int flavour = abs(this->flavour());
395  int flavCounter = 0;
396 
397  for ( auto & flav : flavours_ )
398  if ( abs(flav) == flavour ) ++flavCounter;
399 
400 // if (( flavour == 4 || flavour == 5 ) && flavCounter == 0 )
401 // {
402 // std::cout << "ERROR!!! Jet::removeParton => Original flavour has changed!? " << flavour << "->" << extendedFlavour_ << std::endl;
403 // return -1;
404 // }
405 
406  if ( flavour == 4 && flavCounter > 1 ) extendedFlavour_ == "cc";
407  if ( flavour == 5 && flavCounter > 1 ) extendedFlavour_ == "bb";
408 
409  return 0;
410 
411 }
412 
413 // ------------ methods -----------
414 void Jet::addFSR(Jet* j)
415 {
416  if ( j == nullptr ) return;
417  if ( fsr_ != nullptr )
418  {
419  std::cout << "FSR jet will not be added because FSR already exists" << std::endl;
420  return;
421  }
422  fsr_ = j;
423  p4_ = p4_ + fsr_->p4();
424 }
425 
427 {
428  p4_ = uncorrJetp4_;
429  fsr_ = nullptr;
430 }
431 
433 {
434  return fsr_;
435 }
436 
437 void Jet::addMuon(const std::shared_ptr<Muon> m)
438 {
439  if ( m == nullptr ) return;
440  if ( muon_ != nullptr )
441  {
442  std::cout << "A muon is already associated to this jet" << std::endl;
443  return;
444  }
445  muon_ = m;
446 }
447 
448 void Jet::addMuon(std::vector< std::shared_ptr<Muon> > muons, const float & dr)
449 {
450  if ( muons.size() == 0 ) return;
451 
452  for ( auto m : muons )
453  {
454  if ( this->deltaR((*m)) < dr )
455  {
456  addMuon(m);
457  return;
458  }
459  }
460 }
461 
463 {
464  muon_ = nullptr;
465 }
466 
467 std::shared_ptr<Muon> Jet::muon() const
468 {
469  return muon_;
470 }
471 
472 void Jet::genJets(const std::vector< std::shared_ptr<GenJet> > & genjets)
473 {
474  genjets_ = genjets;
475 }
476 
477 void Jet::associatePartons(const std::vector< std::shared_ptr<GenParticle> > & particles, const float & dRmax, const float & ptMin, const bool & pythia8 )
478 {
479  int flavour = abs(this->flavour());
480  extendedFlavour_ = "udsg";
481  if ( flavour == 5 ) extendedFlavour_ = "b";
482  if ( flavour == 4 ) extendedFlavour_ = "c";
483 
484  int flavCounter = 0;
485  for ( auto & particle : particles )
486  {
487  int pdg = particle->pdgId();
488  int status = particle->status();
489  float pt = particle->pt();
490  if ( pt < ptMin ) continue;
491  if ( pythia8 )
492  {
493  if ( status != 71 && status != 72 ) continue;
494  }
495  else
496  {
497  if ( status != 3 ) continue;
498  }
499  if ( abs(pdg) > 5 && pdg != 21 ) continue;
500  if ( this->p4().DeltaR(particle->p4()) > dRmax ) continue;
501 
502  addParton (particle);
503 
504  if ( abs(pdg) == flavour ) ++flavCounter;
505 
506  }
507 
508  // Need to check for ambiguities!!!
509 
510  // extendedFlavour re-definition
511  if ( flavour == 4 && flavCounter > 1 ) extendedFlavour_ = "cc";
512  if ( flavour == 5 && flavCounter > 1 ) extendedFlavour_ = "bb";
513 
514 }
515 
516 
517 
518 void Jet::id (const float & nHadFrac,
519  const float & nEmFrac ,
520  const float & nMult ,
521  const float & cHadFrac,
522  const float & cEmFrac ,
523  const float & cMult ,
524  const float & muFrac ,
525  const float & puppi )
526 {
527  this -> isPuppi(puppi>0);
528 
529  float nM;
530  float cM;
531  float numConst;
532  if ( isPuppi_ )
533  {
534  nM = nMult;
535  cM = cMult;
536  numConst = nM + cM;
537  }
538  else
539  {
540  nM = round(nMult);
541  cM = round(cMult);
542  numConst = round(nM + cM);
543  }
544  nHadFrac_ = nHadFrac;
545  nEmFrac_ = nEmFrac;
546  nMult_ = nM;
547  cHadFrac_ = cHadFrac;
548  cEmFrac_ = cEmFrac;
549  cMult_ = cM;
550  muFrac_ = muFrac;
551  nConst_ = numConst;
552 
553  // Jet ID 2017 - only for AK4CHS (slimmedJets)
554  // https://twiki.cern.ch/twiki/bin/view/CMS/JetID13TeVRun2017?rev=6
555  if ( fabs(p4_.Eta()) <= 2.7 )
556  {
557  idloose_ = false;
558  idtight_ = ((nHadFrac<0.90 && nEmFrac<0.90 && numConst>1) && ((abs(p4_.Eta())<=2.4 && cHadFrac>0 && cM>0 ) || fabs(p4_.Eta())>2.4) && fabs(p4_.Eta())<=2.7);
559  }
560  else if ( fabs(p4_.Eta()) > 2.7 && fabs(p4_.Eta()) <= 3. )
561  {
562  idloose_ = false;
563  if ( isPuppi_ )
564  {
565  idtight_ = (nHadFrac<0.99);
566  }
567  else
568  {
569  idtight_ = (nEmFrac>0.02 && nEmFrac<0.99 && nM>2);
570  }
571  }
572  else
573  {
574  idloose_ = false;
575  if ( isPuppi_ )
576  {
577  idtight_ = (nHadFrac>0.02 && nEmFrac<0.90 && nM>10);
578  }
579  else
580  {
581  idtight_ = (nHadFrac>0.02 && nEmFrac<0.90 && nM>10);
582  }
583 
584  }
585 
586 
587 // // Jet ID 2016
588 // // https://twiki.cern.ch/twiki/bin/view/CMS/JetID?rev=95#Recommendations_for_13_TeV_data
589 // if ( fabs(p4_.Eta()) <= 2.7 )
590 // {
591 // idloose_ = ((nHadFrac<0.99 && nEmFrac<0.99 && numConst>1) && ((abs(p4_.Eta())<=2.4 && cHadFrac>0 && cM>0 && cEmFrac<0.99) || fabs(p4_.Eta())>2.4) && fabs(p4_.Eta())<=2.7);
592 // idtight_ = ((nHadFrac<0.90 && nEmFrac<0.90 && numConst>1) && ((abs(p4_.Eta())<=2.4 && cHadFrac>0 && cM>0 && cEmFrac<0.99) || fabs(p4_.Eta())>2.4) && fabs(p4_.Eta())<=2.7);
593 // }
594 // else if ( fabs(p4_.Eta()) > 2.7 && fabs(p4_.Eta()) <= 3. )
595 // {
596 // idloose_ = (nEmFrac<0.90 && nM>2);
597 // idtight_ = (nEmFrac<0.90 && nM>2);
598 // }
599 // else
600 // {
601 // idloose_ = (nEmFrac<0.90 && nM>10);
602 // idtight_ = (nEmFrac<0.90 && nM>10);
603 // }
604 
605 // if ( tag_ == "JetIdOld" )
606 // {
607 // if ( fabs(p4_.Eta()) <= 3.0 )
608 // {
609 // idloose_ = ((nHadFrac<0.99 && nEmFrac<0.99 && numConst>1) && ((abs(p4_.Eta())<=2.4 && cHadFrac>0 && cM>0 && cEmFrac<0.99) || fabs(p4_.Eta())>2.4) && fabs(p4_.Eta())<=3.0);
610 // idtight_ = ((nHadFrac<0.90 && nEmFrac<0.90 && numConst>1) && ((abs(p4_.Eta())<=2.4 && cHadFrac>0 && cM>0 && cEmFrac<0.99) || fabs(p4_.Eta())>2.4) && fabs(p4_.Eta())<=3.0);
611 // }
612 // else
613 // {
614 // idloose_ = (nEmFrac<0.90 && nM>10);
615 // idtight_ = (nEmFrac<0.90 && nM>10);
616 // }
617 // }
618 
619 }
float bRegCorr() const
b-jet regression
Definition: Jet.cc:235
TLorentzVector p4() const
returns the 4-momentum (TLorentzVector)
Definition: Candidate.cc:143
std::map< std::string, float > btags_
btag value for each algo
Definition: Jet.h:269
JERCorrections jercorr_
JER correction factor.
Definition: Jet.h:297
float eta() const
returns the pseudorapidity
Definition: Candidate.cc:134
float nEmFrac_
Definition: Jet.h:303
void genJets(const std::vector< std::shared_ptr< GenJet > > &)
gen jets
Definition: Jet.cc:472
void applyJER(const JetResolutionInfo &, const float &drmin=0.2)
Definition: Jet.cc:213
float jerSF() const
returns jet energy resolution SF
Definition: Jet.cc:72
bool id(const std::string &wp="tight") const
returns if jet has a given working point
Definition: Jet.cc:253
float btag_
btag value
Definition: Jet.h:267
double btagSFdown(std::shared_ptr< BTagCalibrationReader > reader, const float &nsig=1, const std::string &flavalgo="Hadron") const
Definition: Jet.cc:320
void addFSR(Jet *)
add a final state radiation jet, will modify the 4-momentum
Definition: Jet.cc:414
void btagAlgo(const std::string &)
sets the default btag algo
Definition: Jet.cc:361
def status(submission_dir, failed_only=False)
Definition: naf_submit.py:362
std::vector< int > flavours() const
returns the vector containing flavours inside the jet
Definition: Jet.cc:63
float bRegRes_
Definition: Jet.h:318
float m() const
returns the mass
Definition: Candidate.cc:137
float e() const
returns the energy
Definition: Candidate.cc:136
std::map< std::string, int > flavour_
map of flavour to a given definition
Definition: Jet.h:273
int pileupJetIdFullId() const
Definition: Jet.cc:233
void jerCorrections()
Definition: Jet.cc:144
bool isPuppi() const
returns if jet is Puppi
Definition: Jet.cc:55
bool idTight() const
returns if jet has id tight working point
Definition: Jet.cc:61
std::shared_ptr< GenJet > generatedJet() const
Pointer to GenJet.
Definition: Jet.cc:264
std::string extendedFlavour() const
returns the extended flavour definition
Definition: Jet.cc:66
float jerPtResolution() const
returns jet pt resolution
Definition: Jet.cc:71
bool idLoose() const
returns if jet has id loose working point
Definition: Jet.cc:60
float puJetIdFullDisc_
pileup jet id
Definition: Jet.h:313
std::vector< int > flavours_
flavours inside the jet
Definition: Jet.h:275
TLorentzVector uncorrJetp4_
4-momentum before FSR correction
Definition: Jet.h:326
float jerCorrection(const std::string &var="nominal", const float &nsig=1) const
Definition: Jet.cc:179
float bRegRes() const
Definition: Jet.cc:236
Jet()
default constructor
Definition: Jet.cc:21
float bRegCorr_
b-jet regression
Definition: Jet.h:317
float phi() const
returns the azimuthal angle
Definition: Candidate.cc:135
std::shared_ptr< Muon > muon() const
pointer to the muon
Definition: Jet.cc:467
float jersfdown_
jet energy resolution SF Down variation
Definition: Jet.h:291
float getResolution(const JetParameters &parameters) const
std::string extendedFlavour_
extended flavour identification for merged jets
Definition: Jet.h:277
float chargedHadronFraction() const
Definition: Jet.cc:225
int flavour() const
returns the flavour with the Hadron definition (=0 for data)
Definition: Jet.cc:58
std::string btagAlgo_
default btag algo
Definition: Jet.h:271
const Candidate * matched(const std::string &name)
returns the pointer to the matched candidate object
Definition: Candidate.cc:147
float neutralHadronFraction() const
Definition: Jet.cc:222
bool jermatch_
JER matching.
Definition: Jet.h:295
double rho_
Fixedgridrho (for JER)
Definition: Jet.h:321
float chargedEmFraction() const
Definition: Jet.cc:226
float neutralMultiplicity() const
Definition: Jet.cc:224
float getScaleFactor(const JetParameters &parameters, Variation variation=Variation::NOMINAL, std::string uncertaintySource="") const
std::shared_ptr< GenJet > genjet_
generated jet
Definition: Jet.h:329
bool idloose_
jet id loose working point
Definition: Jet.h:281
float pt() const
returns the transverse momentum
Definition: Candidate.cc:133
double btagSF(std::shared_ptr< BTagCalibrationReader > reader, const std::string &flavalgo="Hadron") const
btag SF
Definition: Jet.cc:307
void rmMuon()
remove muon association to the jet
Definition: Jet.cc:462
void rmFSR()
remove the final state radiation jet, will change back the original 4-momentum
Definition: Jet.cc:426
TLorentzVector p4_
the 4-momentum
Definition: Candidate.h:114
void jerInfo(const JetResolutionInfo &, const std::string &)
Definition: Jet.cc:199
std::vector< std::shared_ptr< GenJet > > genjets_
collection of GenJets
Definition: Jet.h:332
float muonFraction() const
Definition: Jet.cc:228
float jecUncert() const
returns the jet energy correction uncertainty
Definition: Jet.cc:62
float jerptres_
jet energy resolution
Definition: Jet.h:293
JetResolutionInfo jerinfo_
JER info.
Definition: Jet.h:299
std::vector< std::shared_ptr< GenParticle > > partons_
vector of pointers to Genparticles from merged jets
Definition: Jet.h:279
float nHadFrac_
jet id
Definition: Jet.h:302
float deltaR(const Candidate &) const
returns the deltaR between this and another candidate
Definition: Candidate.cc:140
void associatePartons(const std::vector< std::shared_ptr< GenParticle > > &, const float &dRmax=0.5, const float &ptMin=1., const bool &pythi8=true)
associate partons to the jet
Definition: Jet.cc:477
float jersfup_
jet energy resolution SF Up variation
Definition: Jet.h:289
~Jet()
destructor
Definition: Jet.cc:45
Jet * fsr_
final state radiation
Definition: Jet.h:324
float jersf_
jet energy resolution SF
Definition: Jet.h:287
int removeParton(const int &)
remove parton from jet parton list
Definition: Jet.cc:380
float cEmFrac_
Definition: Jet.h:306
float neutralEmFraction() const
Definition: Jet.cc:223
bool jerMatch() const
Definition: Jet.cc:140
float jerSFdown() const
returns jet energy resolution SF Down variation
Definition: Jet.cc:73
double rho() const
Rho.
Definition: Jet.cc:250
double btagSFsys(std::shared_ptr< BTagCalibrationReader > reader, const std::string &systype="central", const std::string &flavalgo="Hadron") const
Definition: Jet.cc:289
float btag(const std::string &) const
returns the btag value of btag_csvivf
Definition: Jet.cc:57
float jecUnc_
jet energy correction uncertainty
Definition: Jet.h:285
JME::JetResolutionScaleFactor scalefactor
float cHadFrac_
Definition: Jet.h:305
Jet * fsrJet()
pointer to the FSR jet
Definition: Jet.cc:432
bool idtight_
jet id tight working point
Definition: Jet.h:283
float chargedMultiplicity() const
Definition: Jet.cc:227
double btagSFup(std::shared_ptr< BTagCalibrationReader > reader, const float &nsig=1, const std::string &flavalgo="Hadron") const
Definition: Jet.cc:311
float qgLikelihood() const
quark-gluon separation
Definition: Jet.cc:231
float constituents() const
Definition: Jet.cc:229
std::shared_ptr< Muon > muon_
muon in jet
Definition: Jet.h:336
int puJetIdFullId_
Definition: Jet.h:314
float pileupJetIdFullDiscriminant() const
pile up jet id
Definition: Jet.cc:232
void addParton(const std::shared_ptr< GenParticle > &)
add parton that gave rise to jet
Definition: Jet.cc:359
void addMuon(std::shared_ptr< Muon >)
associate a muon to the jet
Definition: Jet.cc:437
void applyBjetRegression()
Definition: Jet.cc:238
float jerSFup() const
returns jet energy resolution SF Up variation
Definition: Jet.cc:74
float qgLikelihood_
quark-gluon separation
Definition: Jet.h:311