-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathBTagCalibrationStandalone.h
189 lines (149 loc) · 4.29 KB
/
BTagCalibrationStandalone.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#ifndef BTagEntry_H
#define BTagEntry_H
/**
*
* 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 <string>
#include <TF1.h>
#include <TH1.h>
class BTagEntry
{
public:
enum OperatingPoint {
OP_LOOSE=0,
OP_MEDIUM=1,
OP_TIGHT=2,
OP_RESHAPING=3,
};
enum JetFlavor {
FLAV_B=0,
FLAV_C=1,
FLAV_UDSG=2,
};
struct Parameters {
OperatingPoint operatingPoint;
std::string measurementType;
std::string sysType;
JetFlavor jetFlavor;
float etaMin;
float etaMax;
float ptMin;
float ptMax;
float discrMin;
float discrMax;
// default constructor
Parameters(
OperatingPoint op=OP_TIGHT,
std::string measurement_type="comb",
std::string sys_type="central",
JetFlavor jf=FLAV_B,
float eta_min=-99999.,
float eta_max=99999.,
float pt_min=0.,
float pt_max=99999.,
float discr_min=0.,
float discr_max=99999.
);
};
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() {}
static std::string makeCSVHeader();
std::string makeCSVLine() const;
static std::string trimStr(std::string str);
// public, no getters needed
std::string formula;
Parameters params;
};
#endif // BTagEntry_H
#ifndef BTagCalibration_H
#define BTagCalibration_H
/**
* BTagCalibration
*
* The 'hierarchy' of stored information is this:
* - by tagger (BTagCalibration)
* - by operating point or reshape bin
* - by jet parton flavor
* - by type of measurement
* - by systematic
* - by eta bin
* - as 1D-function dependent of pt or discriminant
*
************************************************************/
#include <map>
#include <vector>
#include <string>
#include <istream>
#include <ostream>
class BTagCalibration
{
public:
BTagCalibration() {}
BTagCalibration(const std::string &tagger);
BTagCalibration(const std::string &tagger, const std::string &filename);
~BTagCalibration() {}
std::string tagger() const {return tagger_;}
void addEntry(const BTagEntry &entry);
const std::vector<BTagEntry>& getEntries(const BTagEntry::Parameters &par) const;
void readCSV(std::istream &s);
void readCSV(const std::string &s);
void makeCSV(std::ostream &s) const;
std::string makeCSV() const;
protected:
static std::string token(const BTagEntry::Parameters &par);
std::string tagger_;
std::map<std::string, std::vector<BTagEntry> > data_;
};
#endif // BTagCalibration_H
#ifndef BTagCalibrationReader_H
#define BTagCalibrationReader_H
/**
* BTagCalibrationReader
*
* Helper class to pull out a specific set of BTagEntry's out of a
* BTagCalibration. TF1 functions are set up at initialization time.
*
************************************************************/
#include <memory>
#include <string>
class BTagCalibrationReader
{
public:
class BTagCalibrationReaderImpl;
BTagCalibrationReader() {}
BTagCalibrationReader(BTagEntry::OperatingPoint op,
const std::string & sysType="central",
const std::vector<std::string> & otherSysTypes={});
void load(const BTagCalibration & c,
BTagEntry::JetFlavor jf,
const std::string & measurementType="comb");
double eval(BTagEntry::JetFlavor jf,
float eta,
float pt,
float discr=0.) const;
double eval_auto_bounds(const std::string & sys,
BTagEntry::JetFlavor jf,
float eta,
float pt,
float discr=0.) const;
std::pair<float, float> min_max_pt(BTagEntry::JetFlavor jf,
float eta,
float discr=0.) const;
protected:
std::shared_ptr<BTagCalibrationReaderImpl> pimpl;
};
#endif // BTagCalibrationReader_H