CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
def test_discr_ranges
 
def test_eta_ranges
 
def test_flavs_b
 
def test_flavs_c
 
def test_flavs_udsg
 
def test_lowercase
 
def test_ops_loose
 
def test_ops_medium
 
def test_ops_tight
 
def test_pt_ranges
 
def test_systematics_central
 
def test_systematics_doublesidedness
 
def test_systematics_down
 
def test_systematics_name
 
def test_systematics_up
 
def test_systematics_values_vs_centrals
 

Private Member Functions

def _check_coverage
 
def _check_sys_side
 

Detailed Description

Definition at line 47 of file checkBTagCalibrationConsistency.py.

Member Function Documentation

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

Definition at line 191 of file checkBTagCalibrationConsistency.py.

References checkBTagCalibrationConsistency._eta_pt_discr_entries_generator().

Referenced by checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_coverage().

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

Definition at line 124 of file checkBTagCalibrationConsistency.py.

References checkBTagCalibrationConsistency._eta_pt_discr_entries_generator(), and python.multivaluedict.dict.

Referenced by checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_systematics_values_vs_centrals().

125  def _check_sys_side(self, op, flav):
126  region = "op=%d, flav=%d" % (op, flav)
127  if verbose:
128  print "Checking sys side correctness for", region
129 
130  res = []
131  for eta, pt, discr, entries in _eta_pt_discr_entries_generator(
132  lambda e:
133  e.params.operatingPoint == op and
134  e.params.jetFlavor == flav,
135  op
136  ):
137  if not entries:
138  continue
139 
140  for e in entries: # do a little monkey patching with tf1's
141  if not hasattr(e, 'tf1_func'):
142  e.tf1_func = ROOT.TF1("", e.formula)
143 
144  sys_dict = dict((e.params.sysType, e) for e in entries)
145  assert len(sys_dict) == len(entries)
146  sys_cent = sys_dict.pop('central', None)
147  x = discr if op == 3 else pt
148  for syst, e in sys_dict.iteritems():
149  sys_val = e.tf1_func.Eval(x)
150  cent_val = sys_cent.tf1_func.Eval(x)
151  if syst.startswith('up') and not sys_val > cent_val:
152  res.append(
153  ("Up variation '%s' not larger than 'central': %s "
154  "eta=%f, pt=%f " % (syst, region, eta, pt))
155  + ((", discr=%f" % discr) if discr else "")
156  )
157  elif syst.startswith('down') and not sys_val < cent_val:
158  res.append(
159  ("Down variation '%s' not smaller than 'central': %s "
160  "eta=%f, pt=%f " % (syst, region, eta, pt))
161  + ((", discr=%f" % discr) if discr else "")
162  )
163  return res
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_coverage (   self)

Definition at line 182 of file checkBTagCalibrationConsistency.py.

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

183  def test_coverage(self):
184  res = list(itertools.chain.from_iterable(
185  self._check_coverage(op, syst, flav)
186  for flav in data.flavs
187  for syst in data.syss
188  for op in data.ops
189  ))
190  self.assertFalse(bool(res), "\n"+"\n".join(res))
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 176 of file checkBTagCalibrationConsistency.py.

177  def test_discr_ranges(self):
178  for a, b in data.discrs:
179  self.assertLess(a, b)
180  self.assertGreater(a, data.DISCR_MIN - 1e-7)
181  self.assertLess(b, data.DISCR_MAX + 1e-7)
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_eta_ranges (   self)

Definition at line 164 of file checkBTagCalibrationConsistency.py.

165  def test_eta_ranges(self):
166  for a, b in data.etas:
167  self.assertLess(a, b)
168  self.assertGreater(a, data.ETA_MIN - 1e-7)
169  self.assertLess(b, data.ETA_MAX + 1e-7)
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_flavs_b (   self)

Definition at line 67 of file checkBTagCalibrationConsistency.py.

67 
68  def test_flavs_b(self):
69  if check_flavor:
70  self.assertIn(0, data.flavs, "FLAV_B is missing")
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_flavs_c (   self)

Definition at line 71 of file checkBTagCalibrationConsistency.py.

71 
72  def test_flavs_c(self):
73  if check_flavor:
74  self.assertIn(1, data.flavs, "FLAV_C is missing")
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_flavs_udsg (   self)

Definition at line 75 of file checkBTagCalibrationConsistency.py.

75 
76  def test_flavs_udsg(self):
77  if check_flavor:
78  self.assertIn(2, data.flavs, "FLAV_UDSG is missing")
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_lowercase (   self)

Definition at line 48 of file checkBTagCalibrationConsistency.py.

References list().

48 
49  def test_lowercase(self):
50  for item in [data.meas_type] + list(data.syss):
51  self.assertEqual(
52  item, item.lower(),
53  "Item is not lowercase: %s" % item
54  )
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 63 of file checkBTagCalibrationConsistency.py.

63 
64  def test_ops_loose(self):
65  if check_op:
66  self.assertIn(0, data.ops, "OP_LOOSE is missing")
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_ops_medium (   self)

Definition at line 59 of file checkBTagCalibrationConsistency.py.

59 
60  def test_ops_medium(self):
61  if check_op:
62  self.assertIn(1, data.ops, "OP_MEDIUM is missing")
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_ops_tight (   self)

Definition at line 55 of file checkBTagCalibrationConsistency.py.

55 
56  def test_ops_tight(self):
57  if check_op:
58  self.assertIn(2, data.ops, "OP_TIGHT is missing")
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_pt_ranges (   self)

Definition at line 170 of file checkBTagCalibrationConsistency.py.

171  def test_pt_ranges(self):
172  for a, b in data.pts:
173  self.assertLess(a, b)
174  self.assertGreater(a, data.PT_MIN - 1e-7)
175  self.assertLess(b, data.PT_MAX + 1e-7)
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_systematics_central (   self)

Definition at line 79 of file checkBTagCalibrationConsistency.py.

79 
80  def test_systematics_central(self):
81  if check_sys:
82  self.assertIn("central", data.syss,
83  "'central' sys. uncert. is missing")
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_systematics_doublesidedness (   self)

Definition at line 103 of file checkBTagCalibrationConsistency.py.

105  if check_sys:
106  for syst in data.syss:
107  if "up" in syst:
108  other = syst.replace("up", "down")
109  self.assertIn(other, data.syss,
110  "'%s' sys. uncert. is missing" % other)
111  elif "down" in syst:
112  other = syst.replace("down", "up")
113  self.assertIn(other, data.syss,
114  "'%s' sys. uncert. is missing" % other)
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_systematics_down (   self)

Definition at line 88 of file checkBTagCalibrationConsistency.py.

88 
89  def test_systematics_down(self):
90  if check_sys:
91  self.assertIn("down", data.syss, "'down' sys. uncert. is missing")
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_systematics_name (   self)

Definition at line 92 of file checkBTagCalibrationConsistency.py.

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

Definition at line 84 of file checkBTagCalibrationConsistency.py.

84 
85  def test_systematics_up(self):
86  if check_sys:
87  self.assertIn("up", data.syss, "'up' sys. uncert. is missing")
def checkBTagCalibrationConsistency.BtagCalibConsistencyChecker.test_systematics_values_vs_centrals (   self)

Definition at line 115 of file checkBTagCalibrationConsistency.py.

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

117  if check_sys:
118  res = list(itertools.chain.from_iterable(
119  self._check_sys_side(op, flav)
120  for flav in data.flavs
121  for op in data.ops
122  ))
123  self.assertFalse(bool(res), "\n"+"\n".join(res))
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