19 entries =
filter(filter_keyfunc, data.entries)
22 if any(e.params.etaMin < 0.
for e
in entries):
23 eta_test_points = data.eta_test_points
25 eta_test_points = data.abseta_test_points
27 for eta
in eta_test_points:
28 for pt
in data.pt_test_points:
31 e.params.etaMin < eta < e.params.etaMax
and
32 e.params.ptMin < pt < e.params.ptMax,
36 for discr
in data.discr_test_points:
39 e.params.discrMin < discr < e.params.discrMax,
42 yield eta, pt, discr, ens_pt_eta_discr
44 yield eta, pt,
None, ens_pt_eta
49 for item
in [data.meas_type] +
list(data.syss):
52 "Item is not lowercase: %s" % item
57 self.assertIn(2, data.ops,
"OP_TIGHT is missing")
61 self.assertIn(1, data.ops,
"OP_MEDIUM is missing")
65 self.assertIn(0, data.ops,
"OP_LOOSE is missing")
69 self.assertIn(0, data.flavs,
"FLAV_B is missing")
73 self.assertIn(1, data.flavs,
"FLAV_C is missing")
77 self.assertIn(2, data.flavs,
"FLAV_UDSG is missing")
81 self.assertIn(
"central", data.syss,
82 "'central' sys. uncert. is missing")
86 self.assertIn(
"up", data.syss,
"'up' sys. uncert. is missing")
90 self.assertIn(
"down", data.syss,
"'down' sys. uncert. is missing")
94 for syst
in data.syss:
98 syst.startswith(
"up")
or syst.startswith(
"down"),
99 "sys. uncert name must start with 'up' or 'down' : %s"
105 for syst
in data.syss:
107 other = syst.replace(
"up",
"down")
108 self.assertIn(other, data.syss,
109 "'%s' sys. uncert. is missing" % other)
111 other = syst.replace(
"down",
"up")
112 self.assertIn(other, data.syss,
113 "'%s' sys. uncert. is missing" % other)
117 res =
list(itertools.chain.from_iterable(
119 for flav
in data.flavs
122 self.assertFalse(bool(res),
"\n"+
"\n".
join(res))
125 region =
"op=%d, flav=%d" % (op, flav)
127 print "Checking sys side correctness for", region
132 e.params.operatingPoint == op
and
133 e.params.jetFlavor == flav,
140 if not hasattr(e,
'tf1_func'):
141 e.tf1_func = ROOT.TF1(
"", e.formula)
143 sys_dict =
dict((e.params.sysType, e)
for e
in entries)
144 assert len(sys_dict) == len(entries)
145 sys_cent = sys_dict.pop(
'central',
None)
146 x = discr
if op == 3
else pt
147 for syst, e
in sys_dict.iteritems():
148 sys_val = e.tf1_func.Eval(x)
149 cent_val = sys_cent.tf1_func.Eval(x)
150 if syst.startswith(
'up')
and not sys_val > cent_val:
152 (
"Up variation '%s' not larger than 'central': %s "
153 "eta=%f, pt=%f " % (syst, region, eta, pt))
154 + ((
", discr=%f" % discr)
if discr
else "")
156 elif syst.startswith(
'down')
and not sys_val < cent_val:
158 (
"Down variation '%s' not smaller than 'central': %s "
159 "eta=%f, pt=%f " % (syst, region, eta, pt))
160 + ((
", discr=%f" % discr)
if discr
else "")
165 for a, b
in data.etas:
166 self.assertLess(a, b)
167 self.assertGreater(a, data.ETA_MIN - 1e-7)
168 self.assertLess(b, data.ETA_MAX + 1e-7)
171 for a, b
in data.pts:
172 self.assertLess(a, b)
173 self.assertGreater(a, data.PT_MIN - 1e-7)
174 self.assertLess(b, data.PT_MAX + 1e-7)
177 for a, b
in data.discrs:
178 self.assertLess(a, b)
179 self.assertGreater(a, data.DISCR_MIN - 1e-7)
180 self.assertLess(b, data.DISCR_MAX + 1e-7)
183 res =
list(itertools.chain.from_iterable(
185 for flav
in data.flavs
186 for syst
in data.syss
189 self.assertFalse(bool(res),
"\n"+
"\n".
join(res))
192 region =
"op=%d, %s, flav=%d" % (op, syst, flav)
194 print "Checking coverage for", region
200 e.params.operatingPoint == op
and
201 e.params.sysType == syst
and
202 e.params.jetFlavor == flav,
208 (
"Region not covered: %s eta=%f, pt=%f "
210 + ((
", discr=%f" % discr)
if discr
else "")
214 (
"Region covered %d times: %s eta=%f, pt=%f"
215 % (size, region, eta, pt))
216 + ((
", discr=%f" % discr)
if discr
else "")
221 def run_check(filename, op=True, sys=True, flavor=True):
232 op=
True, sys=
True, flavor=
True):
233 global data, check_op, check_sys, check_flavor
234 check_op, check_sys, check_flavor = op, sys, flavor
237 for dat
in data_loaders:
240 print '# Checking csv data for type / op / flavour:', \
241 data.meas_type, data.op, data.flav
245 testsuite = unittest.TestLoader().loadTestsFromTestCase(
246 BtagCalibConsistencyChecker)
247 res = unittest.TextTestRunner().
run(testsuite)
248 all_res.append(
not bool(res.failures))
252 if __name__ ==
'__main__':
253 if len(sys.argv) < 2:
254 print 'Need csv data file as first argument.'
256 print ' --light (do not check op, sys, flav)'
257 print ' --separate-by-op'
258 print ' --separate-by-flav'
259 print ' --separate-all (both of the above)'
263 ck_op = ck_sy = ck_fl =
not '--light' in sys.argv
265 dataLoader.separate_by_op =
'--separate-by-op' in sys.argv
266 dataLoader.separate_by_flav =
'--separate-by-flav' in sys.argv
268 if '--separate-all' in sys.argv:
269 dataLoader.separate_by_op = dataLoader.separate_by_flav =
True
271 if dataLoader.separate_by_op:
273 if dataLoader.separate_by_flav:
277 if not all(
run_check(sys.argv[1], ck_op, ck_sy, ck_fl)):
bool any(const std::vector< T > &v, const T &what)
def test_systematics_doublesidedness
def test_systematics_name
def test_systematics_central
def _eta_pt_discr_entries_generator
def test_systematics_values_vs_centrals
def test_systematics_down
static std::string join(char **cmd)
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