13 from basf2
import create_path
27 """Test case for charged standard particle lists"""
31 Check that the list name we expect is the one that was
32 actually added to the ParticleLoader
34 for param
in particleloader.available_params():
35 if param.name ==
'decayStrings':
36 name = param.values[0].split(
':')[1]
39 "Name: \"%s\" added by function %s, expecting \"%s\""
40 % (name, functionname, target))
43 """check that a given listtype function works"""
45 testpath = create_path()
46 f(listtype, path=testpath)
48 len(testpath.modules()), 1
if listtype ==
'all' else 3,
49 "List %s doesn't work with function %s" % (listtype, f.__name__))
50 self.assertTrue(any(module.type() ==
"ParticleLoader" for module
in testpath.modules()))
54 loader = testpath.modules()[0]
58 """check that a function works (i.e. adds a particle loader)"""
60 testpath = create_path()
63 len(testpath.modules()), 3,
64 "Function %s doesn't work" % f.__name__)
65 self.assertTrue(any(module.type() ==
"ParticleLoader" for module
in testpath.modules()))
66 loader = testpath.modules()[0]
70 """check that a given listtype function doesn't do anything"""
72 testpath = create_path()
73 f(listtype, path=testpath)
75 len(testpath.modules()), 0,
76 "List %s works with function %s" % (listtype, f.__name__))
77 self.assertFalse(any(module.type() ==
"ParticleLoader" for module
in testpath.modules()))
80 """check that the builder functions fail with a nonexisting list"""
84 """check that the builder functions all work with the all list"""
88 """check that the builder functions all work with the good list"""
94 """check that the builder functions all work with the higheff list"""
98 """check that the builder functions all work with the loose list"""
102 """check that the builder functions all work with the percentile eff lists"""
103 for function
in _base_functions:
105 for ename
in stdCharged._effnames:
115 "Function: \"%s\" has no valid list based on efficiency percentile."
116 % (function.__name__))
119 """check that the builder functions work with the mostLikely lists"""
121 testpath = create_path()
124 len(testpath.modules()), 3 * nLists,
125 "There should be %i fillParticleList calls" % nLists)
126 self.assertTrue(any(module.type() ==
"ParticleLoader" for module
in testpath.modules()))
127 for module
in testpath.modules():
128 self.
_check_list_name_check_list_name(
'mostlikely',
'stdMostLikely', module)
131 if __name__ ==
'__main__':
def _check_listtype_does_not_exist(self, listtype, functions=_base_functions)
def test_nonesense_list(self)
def _check_function_call(self, functions=_base_functions, expectedlist=stdCharged._defaultlist)
def test_mostLikely_lists(self)
def test_percentile_eff(self)
def _check_list_name(self, target, functionname, particleloader)
def _check_listtype_exists(self, listtype, functions=_base_functions)
def stdMostLikely(pidPriors=None, suffix='', custom_cuts='', path=None)
def _stdChargedEffCuts(particletype, listtype)