12from basf2
import create_path
26 """Test case for charged standard particle lists"""
30 Check that the list name we expect is the one that was
31 actually added to the ParticleLoader
33 for param
in particleloader.available_params():
34 if param.name ==
'decayStrings':
35 name = param.values[0].split(
':')[1]
38 "Name: \"%s\" added by function %s, expecting \"%s\""
39 % (name, functionname, target))
42 """check that a given listtype function works"""
44 testpath = create_path()
45 f(listtype, path=testpath)
47 len(testpath.modules()), 1
if listtype ==
'all' else 3,
48 f
"List {listtype} doesn't work with function {f.__name__}")
49 self.assertTrue(any(module.type() ==
"ParticleLoader" for module
in testpath.modules()))
53 loader = testpath.modules()[0]
57 """check that a function works (i.e. adds a particle loader)"""
59 testpath = create_path()
62 len(testpath.modules()), 3,
63 f
"Function {f.__name__} doesn't work")
64 self.assertTrue(any(module.type() ==
"ParticleLoader" for module
in testpath.modules()))
65 loader = testpath.modules()[0]
69 """check that a given listtype function doesn't do anything"""
71 testpath = create_path()
72 f(listtype, path=testpath)
74 len(testpath.modules()), 0,
75 f
"List {listtype} works with function {f.__name__}")
76 self.assertFalse(any(module.type() ==
"ParticleLoader" for module
in testpath.modules()))
79 """check that the builder functions fail with a nonexisting list"""
83 """check that the builder functions all work with the all list"""
87 """check that the builder functions all work with the good list"""
93 """check that the builder functions all work with the higheff list"""
97 """check that the builder functions all work with the loose list"""
101 """check that the builder functions all work with the percentile eff lists"""
102 for function
in _base_functions:
104 for ename
in stdCharged._effnames:
114 "Function: \"%s\" has no valid list based on efficiency percentile."
115 % (function.__name__))
118 """check that the builder functions work with the mostLikely lists"""
120 testpath = create_path()
123 len(testpath.modules()), 3 * nLists,
124 f
"There should be {int(nLists)} fillParticleList calls")
125 self.assertTrue(any(module.type() ==
"ParticleLoader" for module
in testpath.modules()))
126 for module
in testpath.modules():
130if __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 _stdChargedEffCuts(particletype, listtype)
def stdMostLikely(pidPriors=None, suffix='', custom_cuts='', path=None, writeOut=True)