DAS  3.0
Das Analysis System
BTagEntry

Description

BTagEntry

Represents one pt- or discriminator-dependent calibration function.

measurement_type: e.g. comb, ttbar, di-mu, boosted, ... sys_type: e.g. central, plus, minus, plus_JEC, plus_JER, ...

Everything is converted into a function, as it is easiest to store it in a txt or json file.

#include <BTagCalibration.h>

+ Collaboration diagram for BTagEntry:

Classes

struct  Parameters
 

Public Types

enum  OperatingPoint { OP_LOOSE =0, OP_MEDIUM =1, OP_TIGHT =2, OP_RESHAPING =3 }
 
enum  JetFlavor { FLAV_B =5, FLAV_C =4, FLAV_UDSG =0 }
 

Public Member Functions

 BTagEntry ()
 
 BTagEntry (const std::string &csvLine)
 
 BTagEntry (const std::string &func, Parameters p)
 
 BTagEntry (const TF1 *func, Parameters p)
 
 BTagEntry (const TH1 *histo, Parameters p)
 
 ~BTagEntry ()
 
std::string makeCSVLine () const
 

Static Public Member Functions

static std::string makeCSVHeader ()
 
static std::string trimStr (std::string str)
 

Public Attributes

std::string formula
 
Parameters params
 

Member Enumeration Documentation

◆ JetFlavor

enum JetFlavor
Enumerator
FLAV_B 
FLAV_C 
FLAV_UDSG 
32  { // modified from original code to match UL convention
33  FLAV_B=5, // previously 0
34  FLAV_C=4, // previsouly 1
35  FLAV_UDSG=0, // previsouly 2
36  };

◆ OperatingPoint

Enumerator
OP_LOOSE 
OP_MEDIUM 
OP_TIGHT 
OP_RESHAPING 
26  {
27  OP_LOOSE=0,
28  OP_MEDIUM=1,
29  OP_TIGHT=2,
30  OP_RESHAPING=3,
31  };

Constructor & Destructor Documentation

◆ BTagEntry() [1/5]

BTagEntry ( )
inline
65 {}

◆ BTagEntry() [2/5]

BTagEntry ( const std::string &  csvLine)
40 {
41  // make tokens
42  std::stringstream buff(csvLine);
43  std::vector<std::string> vec;
44  std::string token;
45  while (std::getline(buff, token, ","[0])) {
47  if (token.empty()) {
48  continue;
49  }
50  vec.push_back(token);
51  }
52  if (vec.size() != 11) {
53 std::cerr << "ERROR in BTagCalibration: "
54  << "Invalid csv line; num tokens != 11: "
55  << csvLine;
56 throw std::exception();
57  }
58 
59  // clean string values
60  char chars[] = " \"\n";
61  for (unsigned int i = 0; i < strlen(chars); ++i) {
62  vec[1].erase(remove(vec[1].begin(),vec[1].end(),chars[i]),vec[1].end());
63  vec[2].erase(remove(vec[2].begin(),vec[2].end(),chars[i]),vec[2].end());
64  vec[10].erase(remove(vec[10].begin(),vec[10].end(),chars[i]),vec[10].end());
65  }
66 
67  // make formula
68  formula = vec[10];
69  TF1 f1("", formula.c_str()); // compile formula to check validity
70  if (f1.IsZombie()) {
71 std::cerr << "ERROR in BTagCalibration: "
72  << "Invalid csv line; formula does not compile: "
73  << csvLine;
74 throw std::exception();
75  }
76 
77  // make parameters
78  unsigned op = stoi(vec[0]);
79  if (op > 3) {
80 std::cerr << "ERROR in BTagCalibration: "
81  << "Invalid csv line; OperatingPoint > 3: "
82  << csvLine;
83 throw std::exception();
84  }
85  unsigned jf = stoi(vec[3]);
86  if (jf != FLAV_B && jf != FLAV_C && jf != FLAV_UDSG) { // modified from original code to match UL convention
87 std::cerr << "ERROR in BTagCalibration: "
88  << "Invalid csv line; JetFlavor has none of the known values: "
89  << csvLine;
90 throw std::exception();
91  }
94  vec[1],
95  vec[2],
97  stof(vec[4]),
98  stof(vec[5]),
99  stof(vec[6]),
100  stof(vec[7]),
101  stof(vec[8]),
102  stof(vec[9])
103  );
104 }

◆ BTagEntry() [3/5]

BTagEntry ( const std::string &  func,
BTagEntry::Parameters  p 
)
106  :
107  formula(func),
108  params(p)
109 {
110  TF1 f1("", formula.c_str()); // compile formula to check validity
111  if (f1.IsZombie()) {
112 std::cerr << "ERROR in BTagCalibration: "
113  << "Invalid func string; formula does not compile: "
114  << func;
115 throw std::exception();
116  }
117 }

◆ BTagEntry() [4/5]

BTagEntry ( const TF1 *  func,
BTagEntry::Parameters  p 
)
119  :
120  formula(std::string(func->GetExpFormula("p").Data())),
121  params(p)
122 {
123  if (func->IsZombie()) {
124 std::cerr << "ERROR in BTagCalibration: "
125  << "Invalid TF1 function; function is zombie: "
126  << func->GetName();
127 throw std::exception();
128  }
129 }

◆ BTagEntry() [5/5]

BTagEntry ( const TH1 *  histo,
BTagEntry::Parameters  p 
)
195  :
196  params(p)
197 {
198  int nbins = hist->GetNbinsX();
199  TAxis const* axis = hist->GetXaxis();
200 
201  // overwrite bounds with histo values
203  params.discrMin = axis->GetBinLowEdge(1);
204  params.discrMax = axis->GetBinUpEdge(nbins);
205  } else {
206  params.ptMin = axis->GetBinLowEdge(1);
207  params.ptMax = axis->GetBinUpEdge(nbins);
208  }
209 
210  // balanced full binary tree height = ceil(log(2*n_leaves)/log(2))
211  // breakes even around 10, but lower values are more propable in pt-spectrum
212  if (nbins < 15) {
213  formula = th1ToFormulaLin(hist);
214  } else {
216  }
217 
218  // compile formula to check validity
219  TF1 f1("", formula.c_str());
220  if (f1.IsZombie()) {
221 std::cerr << "ERROR in BTagCalibration: "
222  << "Invalid histogram; formula does not compile (>150 bins?): "
223  << hist->GetName();
224 throw std::exception();
225  }
226 }

◆ ~BTagEntry()

~BTagEntry ( )
inline
70 {}

Member Function Documentation

◆ makeCSVHeader()

std::string makeCSVHeader ( )
static
229 {
230  return "OperatingPoint, "
231  "measurementType, "
232  "sysType, "
233  "jetFlavor, "
234  "etaMin, "
235  "etaMax, "
236  "ptMin, "
237  "ptMax, "
238  "discrMin, "
239  "discrMax, "
240  "formula \n";
241 }

◆ makeCSVLine()

std::string makeCSVLine ( ) const
244 {
245  std::stringstream buff;
246  buff << params.operatingPoint
247  << ", " << params.measurementType
248  << ", " << params.sysType
249  << ", " << params.jetFlavor
250  << ", " << params.etaMin
251  << ", " << params.etaMax
252  << ", " << params.ptMin
253  << ", " << params.ptMax
254  << ", " << params.discrMin
255  << ", " << params.discrMax
256  << ", \"" << formula
257  << "\" \n";
258  return buff.str();
259 }

◆ trimStr()

std::string trimStr ( std::string  str)
static
261  {
262  size_t s = str.find_first_not_of(" \n\r\t");
263  size_t e = str.find_last_not_of (" \n\r\t");
264 
265  if((std::string::npos == s) || (std::string::npos == e))
266  return "";
267  else
268  return str.substr(s, e-s+1);
269 }

Member Data Documentation

◆ formula

std::string formula

◆ params

Parameters params

The documentation for this class was generated from the following files:
BTagEntry::Parameters::measurementType
std::string measurementType
Definition: BTagCalibration.h:39
BTagEntry::Parameters::discrMin
float discrMin
Definition: BTagCalibration.h:46
Ntupliser_cfg.cerr
cerr
Definition: Ntupliser_cfg.py:93
BTagEntry::Parameters::jetFlavor
JetFlavor jetFlavor
Definition: BTagCalibration.h:41
th1ToFormulaBinTree
std::string th1ToFormulaBinTree(const TH1 *hist, int start=0, int end=-1)
Definition: BTagCalibration.cc:154
BTagEntry::FLAV_C
@ FLAV_C
Definition: BTagCalibration.h:34
BTagEntry::formula
std::string formula
Definition: BTagCalibration.h:76
Ntupliser_cfg.p
p
Definition: Ntupliser_cfg.py:358
BTagEntry::OP_LOOSE
@ OP_LOOSE
Definition: BTagCalibration.h:27
BTagEntry::Parameters::discrMax
float discrMax
Definition: BTagCalibration.h:47
BTagEntry::Parameters::operatingPoint
OperatingPoint operatingPoint
Definition: BTagCalibration.h:38
BTagEntry::OP_MEDIUM
@ OP_MEDIUM
Definition: BTagCalibration.h:28
BTagEntry::OperatingPoint
OperatingPoint
Definition: BTagCalibration.h:26
BTagEntry::Parameters::etaMin
float etaMin
Definition: BTagCalibration.h:42
BTagEntry::Parameters
Definition: BTagCalibration.h:37
gitlab_post_comment.token
token
Definition: gitlab_post_comment.py:10
BTagEntry::Parameters::sysType
std::string sysType
Definition: BTagCalibration.h:40
BTagEntry::OP_RESHAPING
@ OP_RESHAPING
Definition: BTagCalibration.h:30
BTagEntry::JetFlavor
JetFlavor
Definition: BTagCalibration.h:32
BTagEntry::Parameters::etaMax
float etaMax
Definition: BTagCalibration.h:43
BTagEntry::params
Parameters params
Definition: BTagCalibration.h:77
BTagEntry::OP_TIGHT
@ OP_TIGHT
Definition: BTagCalibration.h:29
BTagEntry::FLAV_B
@ FLAV_B
Definition: BTagCalibration.h:33
th1ToFormulaLin
std::string th1ToFormulaLin(const TH1 *hist)
Definition: BTagCalibration.cc:134
BTagEntry::trimStr
static std::string trimStr(std::string str)
Definition: BTagCalibration.cc:261
BTagEntry::Parameters::ptMax
float ptMax
Definition: BTagCalibration.h:45
BTagEntry::FLAV_UDSG
@ FLAV_UDSG
Definition: BTagCalibration.h:35
BTagEntry::Parameters::ptMin
float ptMin
Definition: BTagCalibration.h:44