3 from __future__
import print_function
4 from __future__
import absolute_import
8 from .
import dataLoader
22 entries =
list(
filter(filter_keyfunc, data.entries))
25 if any(e.params.etaMin < 0.
for e
in entries):
26 eta_test_points = data.eta_test_points
28 eta_test_points = data.abseta_test_points
30 for eta
in eta_test_points:
31 for pt
in data.pt_test_points:
32 ens_pt_eta = [e
for e
in entries
if e.params.etaMin < eta < e.params.etaMax
and 33 e.params.ptMin < pt < e.params.ptMax]
35 for discr
in data.discr_test_points:
36 ens_pt_eta_discr = [e
for e
in ens_pt_eta
if e.params.discrMin < discr < e.params.discrMax]
37 yield eta, pt, discr, ens_pt_eta_discr
39 yield eta, pt,
None, ens_pt_eta
44 for item
in [data.meas_type] +
list(data.syss):
47 "Item is not lowercase: %s" % item
52 self.assertIn(2, data.ops,
"OP_TIGHT is missing")
56 self.assertIn(1, data.ops,
"OP_MEDIUM is missing")
60 self.assertIn(0, data.ops,
"OP_LOOSE is missing")
64 self.assertIn(0, data.flavs,
"FLAV_B is missing")
68 self.assertIn(1, data.flavs,
"FLAV_C is missing")
72 self.assertIn(2, data.flavs,
"FLAV_UDSG is missing")
76 self.assertIn(
"central", data.syss,
77 "'central' sys. uncert. is missing")
81 self.assertIn(
"up", data.syss,
"'up' sys. uncert. is missing")
85 self.assertIn(
"down", data.syss,
"'down' sys. uncert. is missing")
89 for syst
in data.syss:
93 syst.startswith(
"up")
or syst.startswith(
"down"),
94 "sys. uncert name must start with 'up' or 'down' : %s" 100 for syst
in data.syss:
102 other = syst.replace(
"up",
"down")
103 self.assertIn(other, data.syss,
104 "'%s' sys. uncert. is missing" % other)
106 other = syst.replace(
"down",
"up")
107 self.assertIn(other, data.syss,
108 "'%s' sys. uncert. is missing" % other)
112 res =
list(itertools.chain.from_iterable(
114 for flav
in data.flavs
117 self.assertFalse(
bool(res),
"\n"+
"\n".
join(res))
120 region =
"op=%d, flav=%d" % (op, flav)
122 print(
"Checking sys side correctness for", region)
127 e.params.operatingPoint == op
and 128 e.params.jetFlavor == flav,
135 if not hasattr(e,
'tf1_func'):
136 e.tf1_func = ROOT.TF1(
"", e.formula)
138 sys_dict =
dict((e.params.sysType, e)
for e
in entries)
139 assert len(sys_dict) == len(entries)
140 sys_cent = sys_dict.pop(
'central',
None)
141 x = discr
if op == 3
else pt
142 for syst, e
in six.iteritems(sys_dict):
143 sys_val = e.tf1_func.Eval(x)
144 cent_val = sys_cent.tf1_func.Eval(x)
145 if syst.startswith(
'up')
and not sys_val > cent_val:
147 (
"Up variation '%s' not larger than 'central': %s " 148 "eta=%f, pt=%f " % (syst, region, eta, pt))
149 + ((
", discr=%f" % discr)
if discr
else "")
151 elif syst.startswith(
'down')
and not sys_val < cent_val:
153 (
"Down variation '%s' not smaller than 'central': %s " 154 "eta=%f, pt=%f " % (syst, region, eta, pt))
155 + ((
", discr=%f" % discr)
if discr
else "")
160 for a, b
in data.etas:
161 self.assertLess(a, b)
162 self.assertGreater(a, data.ETA_MIN - 1e-7)
163 self.assertLess(b, data.ETA_MAX + 1e-7)
166 for a, b
in data.pts:
167 self.assertLess(a, b)
168 self.assertGreater(a, data.PT_MIN - 1e-7)
169 self.assertLess(b, data.PT_MAX + 1e-7)
172 for a, b
in data.discrs:
173 self.assertLess(a, b)
174 self.assertGreater(a, data.DISCR_MIN - 1e-7)
175 self.assertLess(b, data.DISCR_MAX + 1e-7)
178 res =
list(itertools.chain.from_iterable(
180 for flav
in data.flavs
181 for syst
in data.syss
184 self.assertFalse(
bool(res),
"\n"+
"\n".
join(res))
187 region =
"op=%d, %s, flav=%d" % (op, syst, flav)
189 print(
"Checking coverage for", region)
195 e.params.operatingPoint == op
and 196 e.params.sysType == syst
and 197 e.params.jetFlavor == flav,
203 (
"Region not covered: %s eta=%f, pt=%f " 205 + ((
", discr=%f" % discr)
if discr
else "")
209 (
"Region covered %d times: %s eta=%f, pt=%f" 210 % (size, region, eta, pt))
211 + ((
", discr=%f" % discr)
if discr
else "")
216 def run_check(filename, op=True, sys=True, flavor=True):
227 op=
True, sys=
True, flavor=
True):
228 global data, check_op, check_sys, check_flavor
229 check_op, check_sys, check_flavor = op, sys, flavor
232 for dat
in data_loaders:
235 print(
'# Checking csv data for type / op / flavour:', \
236 data.meas_type, data.op, data.flav)
240 testsuite = unittest.TestLoader().loadTestsFromTestCase(
241 BtagCalibConsistencyChecker)
242 res = unittest.TextTestRunner().
run(testsuite)
243 all_res.append(
not bool(res.failures))
247 if __name__ ==
'__main__':
248 if len(sys.argv) < 2:
249 print(
'Need csv data file as first argument.')
251 print(
' --light (do not check op, sys, flav)')
252 print(
' --separate-by-op')
253 print(
' --separate-by-flav')
254 print(
' --separate-all (both of the above)')
258 ck_op = ck_sy = ck_fl =
not '--light' in sys.argv
260 dataLoader.separate_by_op =
'--separate-by-op' in sys.argv
261 dataLoader.separate_by_flav =
'--separate-by-flav' in sys.argv
263 if '--separate-all' in sys.argv:
264 dataLoader.separate_by_op = dataLoader.separate_by_flav =
True 266 if dataLoader.separate_by_op:
268 if dataLoader.separate_by_flav:
272 if not all(
run_check(sys.argv[1], ck_op, ck_sy, ck_fl)):
def test_systematics_doublesidedness(self)
def test_systematics_values_vs_centrals(self)
def run_check(filename, op=True, sys=True, flavor=True)
def _check_coverage(self, op, syst, flav)
bool any(const std::vector< T > &v, const T &what)
S & print(S &os, JobReport::InputFile const &f)
def test_discr_ranges(self)
def run_check_csv(csv_data, op=True, sys=True, flavor=True)
def _eta_pt_discr_entries_generator(filter_keyfunc, op)
def get_data_csv(csv_data)
def run_check_data(data_loaders, op=True, sys=True, flavor=True)
def test_flavs_udsg(self)
def test_eta_ranges(self)
def test_systematics_central(self)
static std::string join(char **cmd)
def test_systematics_down(self)
def test_systematics_up(self)
def _check_sys_side(self, op, flav)
def test_ops_medium(self)
def test_systematics_name(self)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run