5 from basf2
import create_path
19 """Test case for charged standard particle lists"""
23 Check that the list name we expect is the one that was
24 actually added to the ParticleLoader
26 for param
in particleloader.available_params():
27 if param.name ==
'decayStringsWithCuts':
28 name = param.values[0][0].split(
':')[1]
31 "Name: \"%s\" added by function %s, expecting \"%s\""
32 % (name, functionname, target))
35 """check that a given listtype function works"""
37 testpath = create_path()
38 f(listtype, path=testpath)
40 len(testpath.modules()), 1,
41 "List %s doesn't work with function %s" % (listtype, f.__name__))
42 self.assertTrue(any(module.type() ==
"ParticleLoader" for module
in testpath.modules()))
46 loader = testpath.modules()[0]
50 """check that a function works (i.e. adds a particle loader)"""
52 testpath = create_path()
55 len(testpath.modules()), 1,
56 "Function %s doesn't work" % f.__name__)
57 self.assertTrue(any(module.type() ==
"ParticleLoader" for module
in testpath.modules()))
58 loader = testpath.modules()[0]
62 """check that a given listtype function doesn't do anything"""
64 testpath = create_path()
65 f(listtype, path=testpath)
67 len(testpath.modules()), 0,
68 "List %s works with function %s" % (listtype, f.__name__))
69 self.assertFalse(any(module.type() ==
"ParticleLoader" for module
in testpath.modules()))
72 """check that the builder functions fail with a nonexisting list"""
76 """check that the builder functions all work with the all list"""
80 """check that the builder functions all work with the good list"""
86 """check that the builder functions all work with the higheff list"""
90 """check that the builder functions all work with the loose list"""
94 """check that the builder functions all work with the percentile eff lists"""
95 for function
in _base_functions:
97 for ename
in stdCharged._effnames:
107 "Function: \"%s\" has no valid list based on efficiency percentile."
108 % (function.__name__))
111 """check that the builder functions work with the mostLikely lists"""
113 testpath = create_path()
116 len(testpath.modules()), nLists,
117 "There should be %i fillParticleList calls" % nLists)
118 self.assertTrue(any(module.type() ==
"ParticleLoader" for module
in testpath.modules()))
119 for module
in testpath.modules():
122 if __name__ ==
'__main__':