12from basf2
import create_path
13from stdHyperons
import stdXi, stdXi0, stdOmega, goodXi, goodXi0, goodOmega
14from b2bii
import setB2BII, unsetB2BII
18 """Test case for standard hyperon lists"""
21 """Remove all spaces within a string"""
22 return "".join(s.split(
' '))
29 Check the given particle lists are created.
30 The std_function ONLY takes one path argument.
32 testpath = create_path()
33 std_function(path=testpath)
36 for module
in testpath.modules():
37 for param
in module.available_params():
38 if module.type() ==
'ParticleLoader' and param.name ==
'decayStringsWithCuts':
39 listname = param.values[0][0].split(
'->')[0]
40 elif module.type() ==
'ParticleListManipulator' and param.name ==
'outputListName':
41 listname = str(param.values).split(
' -> ')[0]
42 elif module.type() ==
'ParticleCombiner' and param.name ==
'decayString':
43 listname = param.values.split(
' -> ')[0]
47 if listname
not in built_lists:
48 built_lists.append(listname)
49 expected_lists = [self.
remove_spaces(listname)
for listname
in expected_lists]
51 for expected
in expected_lists:
52 if expected
not in built_lists:
58 for fitter
in [
'KFit',
'TreeFit']:
59 self.assertTrue(self.
_check_list(
lambda path: stdXi(fitter=fitter, path=path), expected_lists=[
'Xi-:std']))
66 expected_lists=[
'Xi-:good']))
73 expected_lists=[
'Xi- : std']))
76 """Check stdXi for B2BII settings"""
78 for fitter
in [
'KFit',
'TreeFit']:
79 self.assertTrue(self.
_check_list(
lambda path: stdXi(fitter=fitter, path=path), expected_lists=[
'Xi-:std']))
84 for gamma_efficiency
in [
'eff20',
'eff30',
'eff40',
'eff50',
'eff60']:
88 gammatype=gamma_efficiency,
90 expected_lists=[
'Xi0:std']))
93 """Check stdXi0 for B2BII settings"""
95 for gamma_efficiency
in [
'eff20',
'eff30',
'eff40',
'eff50',
'eff60']:
99 gammatype=gamma_efficiency,
101 expected_lists=[
'Xi0:std']))
106 for fitter
in [
'KFit',
'TreeFit']:
109 lambda path: stdOmega(
112 expected_lists=[
'Omega-:std']))
115 """Check stdOmega for B2BII settings"""
117 for fitter
in [
'KFit',
'TreeFit']:
120 lambda path: stdOmega(
123 expected_lists=[
'Omega-:std']))
127 """Check goodXi lists: veryloose, loose, tight"""
128 for xitype
in [
'veryloose',
'loose',
'tight']:
129 def create_list(path):
131 self.assertTrue(self.
_check_list(create_list, expected_lists=[
'Xi-:std', f
'Xi-:{xitype}']))
133 self.assertFalse(self.
_check_list(create_list, expected_lists=[f
'Xi:{xitype}']))
136 """Check goodXi lists: veryloose, loose, tight. Test behavior if std list was already added before."""
137 for xitype
in [
'veryloose',
'loose',
'tight']:
138 def create_list(path):
141 self.assertTrue(self.
_check_list(create_list, expected_lists=[
'Xi-:std', f
'Xi-:{xitype}']))
143 self.assertFalse(self.
_check_list(create_list, expected_lists=[f
'Xi:{xitype}']))
146 """Check goodXi0 lists: veryloose, loose, tight"""
147 for xitype
in [
'veryloose',
'loose',
'tight']:
148 def create_list(path):
149 goodXi0(xitype, path)
150 self.assertTrue(self.
_check_list(create_list, expected_lists=[
'Xi0:std', f
'Xi0:{xitype}']),
151 f
"xitype = {xitype}")
152 self.assertFalse(self.
_check_list(create_list, expected_lists=[f
'Xi:{xitype}']))
155 """Check goodXi0 lists: veryloose, loose, tight. Test behavior if std list was already added before."""
156 for xitype
in [
'veryloose',
'loose',
'tight']:
157 def create_list(path):
159 goodXi0(xitype, path)
160 self.assertTrue(self.
_check_list(create_list, expected_lists=[
'Xi0:std', f
'Xi0:{xitype}']),
161 f
"xitype = {xitype}")
162 self.assertFalse(self.
_check_list(create_list, expected_lists=[f
'Xi:{xitype}']))
165 """Check goodOmega lists: veryloose, loose, tight"""
166 for omegatype
in [
'veryloose',
'loose',
'tight']:
167 def create_list(path):
168 goodOmega(omegatype, path)
169 self.assertTrue(self.
_check_list(create_list, expected_lists=[
'Omega-:std', f
'Omega-:{omegatype}']))
170 self.assertFalse(self.
_check_list(create_list, expected_lists=[f
'Omega:{omegatype}']))
173 """Check goodOmega lists: veryloose, loose, tight. Test behavior if std list was already added before."""
174 for omegatype
in [
'veryloose',
'loose',
'tight']:
175 def create_list(path):
177 goodOmega(omegatype, path)
178 self.assertTrue(self.
_check_list(create_list, expected_lists=[
'Omega-:std', f
'Omega-:{omegatype}']))
179 self.assertFalse(self.
_check_list(create_list, expected_lists=[f
'Omega:{omegatype}']))
182if __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)