13 from basf2
import create_path
14 from stdHyperons
import stdXi, stdXi0, stdOmega, goodXi, goodXi0, goodOmega
15 from b2bii
import setB2BII, unsetB2BII
19 """Test case for standard hyperon lists"""
22 """Remove all spaces within a string"""
23 return "".join(s.split(
' '))
30 Check the given particle lists are created.
31 The std_function ONLY takes one path argument.
33 testpath = create_path()
34 std_function(path=testpath)
37 for module
in testpath.modules():
38 for param
in module.available_params():
39 if module.type() ==
'ParticleLoader' and param.name ==
'decayStringsWithCuts':
40 listname = param.values[0][0].split(
'->')[0]
41 elif module.type() ==
'ParticleListManipulator' and param.name ==
'outputListName':
42 listname = str(param.values).split(
' -> ')[0]
43 elif module.type() ==
'ParticleCombiner' and param.name ==
'decayString':
44 listname = param.values.split(
' -> ')[0]
48 if listname
not in built_lists:
49 built_lists.append(listname)
50 expected_lists = [self.
remove_spacesremove_spaces(listname)
for listname
in expected_lists]
52 for expected
in expected_lists:
53 if expected
not in built_lists:
59 for fitter
in [
'KFit',
'TreeFit']:
60 self.assertTrue(self.
_check_list_check_list(
lambda path: stdXi(fitter=fitter, path=path), expected_lists=[
'Xi-:std']))
67 expected_lists=[
'Xi-:good']))
74 expected_lists=[
'Xi- : std']))
77 """Check stdXi for B2BII settings"""
79 for fitter
in [
'KFit',
'TreeFit']:
80 self.assertTrue(self.
_check_list_check_list(
lambda path: stdXi(fitter=fitter, path=path), expected_lists=[
'Xi-:std']))
85 for gamma_efficiency
in [
'eff20',
'eff30',
'eff40',
'eff50',
'eff60']:
89 gammatype=gamma_efficiency,
91 expected_lists=[
'Xi0:std']))
94 """Check stdXi0 for B2BII settings"""
96 for gamma_efficiency
in [
'eff20',
'eff30',
'eff40',
'eff50',
'eff60']:
100 gammatype=gamma_efficiency,
102 expected_lists=[
'Xi0:std']))
107 for fitter
in [
'KFit',
'TreeFit']:
110 lambda path: stdOmega(
113 expected_lists=[
'Omega-:std']))
116 """Check stdOmega for B2BII settings"""
118 for fitter
in [
'KFit',
'TreeFit']:
121 lambda path: stdOmega(
124 expected_lists=[
'Omega-:std']))
128 """Check goodXi lists: veryloose, loose, tight"""
129 for xitype
in [
'veryloose',
'loose',
'tight']:
130 def create_list(path):
132 self.assertTrue(self.
_check_list_check_list(create_list, expected_lists=[
'Xi-:std', f
'Xi-:{xitype}']))
134 self.assertFalse(self.
_check_list_check_list(create_list, expected_lists=[f
'Xi:{xitype}']))
137 """Check goodXi lists: veryloose, loose, tight. Test behavior if std list was already added before."""
138 for xitype
in [
'veryloose',
'loose',
'tight']:
139 def create_list(path):
142 self.assertTrue(self.
_check_list_check_list(create_list, expected_lists=[
'Xi-:std', f
'Xi-:{xitype}']))
144 self.assertFalse(self.
_check_list_check_list(create_list, expected_lists=[f
'Xi:{xitype}']))
147 """Check goodXi0 lists: veryloose, loose, tight"""
148 for xitype
in [
'veryloose',
'loose',
'tight']:
149 def create_list(path):
150 goodXi0(xitype, path)
151 self.assertTrue(self.
_check_list_check_list(create_list, expected_lists=[
'Xi0:std', f
'Xi0:{xitype}']),
152 f
"xitype = {xitype}")
153 self.assertFalse(self.
_check_list_check_list(create_list, expected_lists=[f
'Xi:{xitype}']))
156 """Check goodXi0 lists: veryloose, loose, tight. Test behavior if std list was already added before."""
157 for xitype
in [
'veryloose',
'loose',
'tight']:
158 def create_list(path):
160 goodXi0(xitype, path)
161 self.assertTrue(self.
_check_list_check_list(create_list, expected_lists=[
'Xi0:std', f
'Xi0:{xitype}']),
162 f
"xitype = {xitype}")
163 self.assertFalse(self.
_check_list_check_list(create_list, expected_lists=[f
'Xi:{xitype}']))
166 """Check goodOmega lists: veryloose, loose, tight"""
167 for omegatype
in [
'veryloose',
'loose',
'tight']:
168 def create_list(path):
169 goodOmega(omegatype, path)
170 self.assertTrue(self.
_check_list_check_list(create_list, expected_lists=[
'Omega-:std', f
'Omega-:{omegatype}']))
171 self.assertFalse(self.
_check_list_check_list(create_list, expected_lists=[f
'Omega:{omegatype}']))
174 """Check goodOmega lists: veryloose, loose, tight. Test behavior if std list was already added before."""
175 for omegatype
in [
'veryloose',
'loose',
'tight']:
176 def create_list(path):
178 goodOmega(omegatype, path)
179 self.assertTrue(self.
_check_list_check_list(create_list, expected_lists=[
'Omega-:std', f
'Omega-:{omegatype}']))
180 self.assertFalse(self.
_check_list_check_list(create_list, expected_lists=[f
'Omega:{omegatype}']))
183 if __name__ ==
'__main__':
def test_goodXi_with_std_added_before(self)
def test_goodXi0_with_std_added_before(self)
def test_stdXi0_b2bii(self)
def test_stdXi_b2bii(self)
def test_goodOmega_with_std_added_before(self)
def _check_list(self, std_function, expected_lists=[])
def test_stdOmega_b2bii(self)
def remove_spaces(self, s)