DAS  3.0
Das Analysis System
JetWeight

Description

Calculate the jet weight from the b-tagging calibration following the BTV recommendations.

+ Collaboration diagram for JetWeight:

Public Member Functions

 JetWeight (const fs::path &SFtables, const fs::path &fDisc)
 
double operator() (const RecJet &jet)
 

Public Attributes

BTagCalibrationReader loose
 
BTagCalibrationReader medium
 
BTagCalibrationReader tight
 
unique_ptr< TH3 > discriminant
 

Constructor & Destructor Documentation

◆ JetWeight()

JetWeight ( const fs::path &  SFtables,
const fs::path &  fDisc 
)
inline

Prepares the objects to retrieve the SFs from the SF tables and the binned discriminant.

Parameters
SFtablespath to the CSV file (provided by BTV)
fDiscpath to the ROOT file (calculated with DAS)
47  :
48  loose (BTagEntry::OP_LOOSE , "central", {"up", "down"}),
49  medium(BTagEntry::OP_MEDIUM, "central", {"up", "down"}),
50  tight (BTagEntry::OP_TIGHT , "central", {"up", "down"})
51  {
52  cout << "Extracting binned discriminant from " << fDisc << endl;
53  discriminant = DT::GetHist<TH3>({fDisc}, "discriminant");
54  if (discriminant->GetNbinsZ() != 4) {
55  const char * what = Form("Found %d working points (expecting 4)",
56  discriminant->GetNbinsZ());
57  BOOST_THROW_EXCEPTION( DE::BadInput(what, discriminant) );
58  }
59 
60  cout << "Extracting scale factors from " << SFtables << endl;
61  BTagCalibration calib("DeepJet", SFtables.c_str());
62  for (BTagCalibrationReader * reader: {&loose, &medium, &tight}) {
63  reader->load(calib, BTagEntry::FLAV_B , "comb");
64  reader->load(calib, BTagEntry::FLAV_C , "comb");
65  reader->load(calib, BTagEntry::FLAV_UDSG, "incl");
66  }
67  }

Member Function Documentation

◆ operator()()

double operator() ( const RecJet jet)
inline

Takes the discriminat values, true flavour, and kinematics of a jet to calculate the jet weight.

Todo:
variation
Todo:
standardise flavour indices...
Todo:
variations
73  {
74  int ifl;
76  if (jet.nBHadrons > 0) { ifl = 5; fl = BTagEntry::FLAV_B; }
77  else if (jet.nCHadrons > 0) { ifl = 4; fl = BTagEntry::FLAV_C; }
78  else { ifl = 0; fl = BTagEntry::FLAV_UDSG; }
79 
80  const char * variation = "central";
81 
82  float pt = jet.CorrPt(),
83  eta = abs(jet.p4.Eta());
84 
85  float disc = jet.DeepJet.B();
86  int idisc = discriminant->GetZaxis()->FindBin(disc);
87 
88  if (idisc == 4) // above the tight WP
89  return tight.eval_auto_bounds(variation, fl, eta, pt);
90 
91  int ipt = discriminant->GetXaxis()->FindBin(pt);
92  double Nt = discriminant->GetBinContent(ipt, ifl, 4),
93  Nm = discriminant->GetBinContent(ipt, ifl, 3);
94  if (idisc == 3) { // above the medium WP
95  double SFt = tight .eval_auto_bounds(variation, fl, eta, pt),
96  SFm = medium.eval_auto_bounds(variation, fl, eta, pt);
97  return SFm + (Nt/Nm)*(SFm-SFt);
98  }
99 
100  double Nl = discriminant->GetBinContent(ipt, ifl, 2);
101  if (idisc == 2) { // above the loose WP
102  double SFm = medium.eval_auto_bounds(variation, fl, eta, pt),
103  SFl = loose .eval_auto_bounds(variation, fl, eta, pt);
104  return SFl + ((Nm+Nt)/Nl)*(SFl-SFm);
105  }
106 
107  double Nn = discriminant->GetBinContent(ipt, ifl, 1),
108  SFl = loose.eval_auto_bounds(variation, fl, eta, pt);
109  return 1 + ((Nl+Nm+Nt)/Nn)*(1-SFl);
110  }

Member Data Documentation

◆ discriminant

unique_ptr<TH3> discriminant

in the same convention as in getBTagBinnedDiscriminant

◆ loose

◆ medium

◆ tight

object to call to get SFs


The documentation for this struct was generated from the following file:
jmarExample.pt
pt
Definition: jmarExample.py:19
DAS::BTagging::JetWeight::medium
BTagCalibrationReader medium
Definition: applyBTagSF.cc:38
DAS::BTagging::JetWeight::tight
BTagCalibrationReader tight
object to call to get SFs
Definition: applyBTagSF.cc:38
BTagCalibration
Definition: BTagCalibration.h:109
BTagEntry::FLAV_C
@ FLAV_C
Definition: BTagCalibration.h:34
BTagEntry::OP_LOOSE
@ OP_LOOSE
Definition: BTagCalibration.h:27
DAS::BTagging::JetWeight::discriminant
unique_ptr< TH3 > discriminant
in the same convention as in getBTagBinnedDiscriminant
Definition: applyBTagSF.cc:40
BTagEntry::OP_MEDIUM
@ OP_MEDIUM
Definition: BTagCalibration.h:28
BTagCalibrationReader
Definition: BTagCalibration.h:154
BTagCalibrationReader::eval_auto_bounds
double eval_auto_bounds(const std::string &sys, BTagEntry::JetFlavor jf, float eta, float pt, float discr=0.) const
Definition: BTagCalibration.cc:649
BTagEntry::JetFlavor
JetFlavor
Definition: BTagCalibration.h:32
BTagEntry::OP_TIGHT
@ OP_TIGHT
Definition: BTagCalibration.h:29
DAS::BTagging::JetWeight::loose
BTagCalibrationReader loose
Definition: applyBTagSF.cc:38
BTagEntry::FLAV_B
@ FLAV_B
Definition: BTagCalibration.h:33
BTagEntry::FLAV_UDSG
@ FLAV_UDSG
Definition: BTagCalibration.h:35
Darwin::Exceptions::BadInput
Generic exception for ill-defined input (before the event loop).
Definition: exceptions.h:83
jmarExample.eta
eta
DeepAK8/ParticleNet tagging.
Definition: jmarExample.py:19