1 from __future__
import print_function
7 ROOT.gROOT.ProcessLine(
'.L BTagCalibrationStandalone.cpp+')
11 except AttributeError:
12 print(
'ROOT.BTagEntry is needed! Please copy ' \
13 'BTagCalibrationStandalone.[h|cpp] to the working directory. Exit.')
16 separate_by_op =
False 17 separate_by_flav =
False 21 def __init__(self, csv_data, measurement_type, operating_point, flavour):
23 self.
op = operating_point
33 if (e.params.measurementType == measurement_type
34 and ((
not separate_by_op)
35 or e.params.operatingPoint == operating_point)
36 and ((
not separate_by_flav)
37 or e.params.jetFlavor == flavour)
41 raise RuntimeError(
"Error: can not interpret line: " + l)
48 self.
ops = set(e.params.operatingPoint
for e
in ens)
49 self.
flavs = set(e.params.jetFlavor
for e
in ens)
50 self.
syss = set(e.params.sysType
for e
in ens)
51 self.
etas = set((e.params.etaMin, e.params.etaMax)
for e
in ens)
52 self.
pts = set((e.params.ptMin, e.params.ptMax)
for e
in ens)
53 self.
discrs = set((e.params.discrMin, e.params.discrMax)
55 if e.params.operatingPoint == 3)
61 if any(e.params.operatingPoint == 3
for e
in ens):
65 if e.params.operatingPoint == 3
70 if e.params.operatingPoint == 3
78 eta_test_points = list(itertools.ifilter(
81 (a + eps
for a, _
in self.
etas),
82 (a - eps
for a, _
in self.
etas),
83 (b + eps
for _, b
in self.
etas),
84 (b - eps
for _, b
in self.
etas),
88 abseta_test_points = list(itertools.ifilter(
89 lambda x: 0. < x < self.
ETA_MAX,
91 (a + eps
for a, _
in self.
etas),
92 (a - eps
for a, _
in self.
etas),
93 (b + eps
for _, b
in self.
etas),
94 (b - eps
for _, b
in self.
etas),
98 pt_test_points = list(itertools.ifilter(
101 (a + eps
for a, _
in self.
pts),
102 (a - eps
for a, _
in self.
pts),
103 (b + eps
for _, b
in self.
pts),
104 (b - eps
for _, b
in self.
pts),
108 discr_test_points = list(itertools.ifilter(
111 (a + eps
for a, _
in self.
discrs),
112 (a - eps
for a, _
in self.
discrs),
113 (b + eps
for _, b
in self.
discrs),
114 (b - eps
for _, b
in self.
discrs),
125 print(
"\nFound operating points:")
128 print(
"\nFound jet flavors:")
131 print(
"\nFound sys types (need at least 'central', 'up', 'down'; " \
132 "also 'up_SYS'/'down_SYS' compatibility is checked):")
135 print(
"\nFound eta ranges: (need everything covered from %g or 0. " \
139 print(
"\nFound pt ranges: (need everything covered from %g " \
143 print(
"\nFound discr ranges: (only needed for operatingPoint==3, " \
147 print(
"\nTest points for eta (bounds +- epsilon):")
150 print(
"\nTest points for pt (bounds +- epsilon):")
153 print(
"\nTest points for discr (bounds +- epsilon):")
161 l.split(
',')[1].
strip()
163 if len(l.split()) == 11
170 if len(l.split()) == 11
171 )
if separate_by_op
else [
'all']
177 if len(l.split()) == 11
178 )
if separate_by_flav
else [
'all']
187 lds = [d
for d
in lds
if d.entries]
192 with open(filename)
as f:
193 csv_data = f.readlines()
194 if not (csv_data
and "OperatingPoint" in csv_data[0]):
195 print(
"Data file does not contain typical header: %s. Exit" % filename)
def __init__(self, csv_data, measurement_type, operating_point, flavour)
bool any(const std::vector< T > &v, const T &what)
def get_data_csv(csv_data)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)