CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions
checkBTagCalibrationConsistency.BtagCalibConsistencyChecker Class Reference
Inheritance diagram for checkBTagCalibrationConsistency.BtagCalibConsistencyChecker:

Public Member Functions

def test_coverage (self)
 
def test_discr_ranges (self)
 
def test_eta_ranges (self)
 
def test_flavs_b (self)
 
def test_flavs_c (self)
 
def test_flavs_udsg (self)
 
def test_lowercase (self)
 
def test_ops_loose (self)
 
def test_ops_medium (self)
 
def test_ops_tight (self)
 
def test_pt_ranges (self)
 
def test_systematics_central (self)
 
def test_systematics_doublesidedness (self)
 
def test_systematics_down (self)
 
def test_systematics_name (self)
 
def test_systematics_up (self)
 
def test_systematics_values_vs_centrals (self)
 

Private Member Functions

def _check_coverage (self, op, syst, flav)
 
def _check_sys_side (self, op, flav)
 

Detailed Description

Definition at line 42 of file checkBTagCalibrationConsistency.py.

Member Function Documentation

def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker._check_coverage (   self,
  op,
  syst,
  flav 
)
private

Definition at line 186 of file checkBTagCalibrationConsistency.py.

References checkBTagCalibrationConsistency._eta_pt_discr_entries_generator(), and edm.print().

Referenced by checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_coverage().

186  def _check_coverage(self, op, syst, flav):
187  region = "op=%d, %s, flav=%d" % (op, syst, flav)
188  if verbose:
189  print("Checking coverage for", region)
190 
191  # walk over all testpoints
192  res = []
193  for eta, pt, discr, entries in _eta_pt_discr_entries_generator(
194  lambda e:
195  e.params.operatingPoint == op and
196  e.params.sysType == syst and
197  e.params.jetFlavor == flav,
198  op
199  ):
200  size = len(entries)
201  if size == 0:
202  res.append(
203  ("Region not covered: %s eta=%f, pt=%f "
204  % (region, eta, pt))
205  + ((", discr=%f" % discr) if discr else "")
206  )
207  elif size > 1:
208  res.append(
209  ("Region covered %d times: %s eta=%f, pt=%f"
210  % (size, region, eta, pt))
211  + ((", discr=%f" % discr) if discr else "")
212  )
213  return res
214 
215 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def _eta_pt_discr_entries_generator(filter_keyfunc, op)
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker._check_sys_side (   self,
  op,
  flav 
)
private

Definition at line 119 of file checkBTagCalibrationConsistency.py.

References checkBTagCalibrationConsistency._eta_pt_discr_entries_generator(), cmsPerfStripChart.dict, and edm.print().

Referenced by checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_systematics_values_vs_centrals().

119  def _check_sys_side(self, op, flav):
120  region = "op=%d, flav=%d" % (op, flav)
121  if verbose:
122  print("Checking sys side correctness for", region)
123 
124  res = []
125  for eta, pt, discr, entries in _eta_pt_discr_entries_generator(
126  lambda e:
127  e.params.operatingPoint == op and
128  e.params.jetFlavor == flav,
129  op
130  ):
131  if not entries:
132  continue
133 
134  for e in entries: # do a little monkey patching with tf1's
135  if not hasattr(e, 'tf1_func'):
136  e.tf1_func = ROOT.TF1("", e.formula)
137 
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:
146  res.append(
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 "")
150  )
151  elif syst.startswith('down') and not sys_val < cent_val:
152  res.append(
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 "")
156  )
157  return res
158 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def _eta_pt_discr_entries_generator(filter_keyfunc, op)
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_coverage (   self)

Definition at line 177 of file checkBTagCalibrationConsistency.py.

References checkBTagCalibrationConsistency.BtagCalibConsistencyChecker._check_coverage(), electrons_cff.bool, join(), and list().

177  def test_coverage(self):
178  res = list(itertools.chain.from_iterable(
179  self._check_coverage(op, syst, flav)
180  for flav in data.flavs
181  for syst in data.syss
182  for op in data.ops
183  ))
184  self.assertFalse(bool(res), "\n"+"\n".join(res))
185 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
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
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_discr_ranges (   self)

Definition at line 171 of file checkBTagCalibrationConsistency.py.

171  def test_discr_ranges(self):
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)
176 
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_eta_ranges (   self)

Definition at line 159 of file checkBTagCalibrationConsistency.py.

159  def test_eta_ranges(self):
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)
164 
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_flavs_b (   self)

Definition at line 62 of file checkBTagCalibrationConsistency.py.

62  def test_flavs_b(self):
63  if check_flavor:
64  self.assertIn(0, data.flavs, "FLAV_B is missing")
65 
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_flavs_c (   self)

Definition at line 66 of file checkBTagCalibrationConsistency.py.

66  def test_flavs_c(self):
67  if check_flavor:
68  self.assertIn(1, data.flavs, "FLAV_C is missing")
69 
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_flavs_udsg (   self)

Definition at line 70 of file checkBTagCalibrationConsistency.py.

70  def test_flavs_udsg(self):
71  if check_flavor:
72  self.assertIn(2, data.flavs, "FLAV_UDSG is missing")
73 
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_lowercase (   self)

Definition at line 43 of file checkBTagCalibrationConsistency.py.

References list().

43  def test_lowercase(self):
44  for item in [data.meas_type] + list(data.syss):
45  self.assertEqual(
46  item, item.lower(),
47  "Item is not lowercase: %s" % item
48  )
49 
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
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_ops_loose (   self)

Definition at line 58 of file checkBTagCalibrationConsistency.py.

58  def test_ops_loose(self):
59  if check_op:
60  self.assertIn(0, data.ops, "OP_LOOSE is missing")
61 
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_ops_medium (   self)

Definition at line 54 of file checkBTagCalibrationConsistency.py.

54  def test_ops_medium(self):
55  if check_op:
56  self.assertIn(1, data.ops, "OP_MEDIUM is missing")
57 
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_ops_tight (   self)

Definition at line 50 of file checkBTagCalibrationConsistency.py.

50  def test_ops_tight(self):
51  if check_op:
52  self.assertIn(2, data.ops, "OP_TIGHT is missing")
53 
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_pt_ranges (   self)

Definition at line 165 of file checkBTagCalibrationConsistency.py.

165  def test_pt_ranges(self):
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)
170 
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_systematics_central (   self)

Definition at line 74 of file checkBTagCalibrationConsistency.py.

75  if check_sys:
76  self.assertIn("central", data.syss,
77  "'central' sys. uncert. is missing")
78 
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_systematics_doublesidedness (   self)

Definition at line 98 of file checkBTagCalibrationConsistency.py.

99  if check_sys:
100  for syst in data.syss:
101  if "up" in syst:
102  other = syst.replace("up", "down")
103  self.assertIn(other, data.syss,
104  "'%s' sys. uncert. is missing" % other)
105  elif "down" in syst:
106  other = syst.replace("down", "up")
107  self.assertIn(other, data.syss,
108  "'%s' sys. uncert. is missing" % other)
109 
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_systematics_down (   self)

Definition at line 83 of file checkBTagCalibrationConsistency.py.

84  if check_sys:
85  self.assertIn("down", data.syss, "'down' sys. uncert. is missing")
86 
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_systematics_name (   self)

Definition at line 87 of file checkBTagCalibrationConsistency.py.

88  if check_sys:
89  for syst in data.syss:
90  if syst == 'central':
91  continue
92  self.assertTrue(
93  syst.startswith("up") or syst.startswith("down"),
94  "sys. uncert name must start with 'up' or 'down' : %s"
95  % syst
96  )
97 
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_systematics_up (   self)

Definition at line 79 of file checkBTagCalibrationConsistency.py.

80  if check_sys:
81  self.assertIn("up", data.syss, "'up' sys. uncert. is missing")
82 
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_systematics_values_vs_centrals (   self)

Definition at line 110 of file checkBTagCalibrationConsistency.py.

References checkBTagCalibrationConsistency.BtagCalibConsistencyChecker._check_sys_side(), electrons_cff.bool, join(), and list().

111  if check_sys:
112  res = list(itertools.chain.from_iterable(
113  self._check_sys_side(op, flav)
114  for flav in data.flavs
115  for op in data.ops
116  ))
117  self.assertFalse(bool(res), "\n"+"\n".join(res))
118 
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
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