6 from variables
import variables
as vm
10 """Test case for the variables.utils functions"""
13 _list_of_variables = [
'M',
'p']
16 """Expand the list of expected aliases by appending _{name} for each variable in the _list_of_variables"""
26 """Make sure the aliases created for given decaystring are as expected
27 Also, pass any additional keyword arguments to the create_aliases_for_selected function
31 self.assertEqual(expected, actual, f
"decaystring: {decaystring}, arguments: {argk}")
38 """Make sure we get an error if the decaystring is not valid"""
39 with self.assertRaises(ValueError):
40 create_aliases_for_selected([
"p"],
"eeh <- ok")
43 """Make sure we get an error if o particle is selected"""
44 with self.assertRaises(ValueError):
45 create_aliases_for_selected([
"p"],
"B0 -> pi0")
48 """Make sure we get an error if the number of supplied prefixes doesn't
49 match the number of selected particles"""
50 with self.assertRaises(ValueError):
51 create_aliases_for_selected([
"p"],
"^B0 -> ^pi0", prefix=
"one")
52 with self.assertRaises(ValueError):
53 create_aliases_for_selected([
"p"],
"B0 -> ^pi0", prefix=[
"one",
"two"])
56 """Make sure we got an error if the supplied provided prefixes are not unique"""
57 with self.assertRaises(ValueError):
58 create_aliases_for_selected([
"p"],
"^B0 -> ^pi0", prefix=[
"mine",
"mine"])
61 """Check daughter can be selected for an specific named alias"""
62 self.
assertAliases(
'B0 -> [^D0 -> pi+ K-] pi0', [
'dzero'], prefix=
'dzero')
65 """Check mother and daughter can be selected for an specific named alias"""
66 self.
assertAliases(
'^B0 -> [^D0 -> pi+ ^K-] pi0', [
'MyB',
'MyD',
'MyK'], prefix=[
'MyB',
'MyD',
'MyK'])
69 """Check daughter can be selected w/o an specific named alias"""
70 self.
assertAliases(
'B0 -> [^D0 -> ^pi+ ^K-] pi0', [
'd0',
'd0_d0',
'd0_d1'], use_names=
False)
73 """Check daughter can be selected w/o an specific named alias"""
74 self.
assertAliases(
'^B0 -> pi0 ^pi0', [
'',
'd1'], use_names=
False)
76 self.
assertAliases(
'^B0 -> pi0 ^pi0', [
'',
'd1'], use_names=
False, use_relative_indices=
True)
79 """Check granddaughter can be selected for an automatic name alias"""
83 """Check multiple granddaughters can be selected for automatic name aliases"""
85 'B0 -> [D0 -> ^pi+ ^pi- ^pi0] ^pi0',
94 """ check decay-string-of-doom with automatic names """
96 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
111 """ check decay-string-of-doom with automatic names and relative indexing"""
113 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
125 ], use_relative_indices=
True)
128 """ check decay-string-of-doom with automatic names and forced indices"""
130 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
142 ], always_include_indices=
True)
145 """ check decay-string-of-doom with automatic names, relative indexing and forced indices"""
147 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
159 ], use_relative_indices=
True, always_include_indices=
True)
162 """ check decay-string-of-doom w/o automatic names """
164 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
179 """ check decay-string-of-doom w/o automatic names and make sure relative indexing is **not** honored"""
181 "^B0 -> [D0 -> ^pi+ ^pi-] [D+ -> ^pi+ pi0] [D0 -> ^pi+ ^pi-] [K- -> ^pi+ ^pi-] ^pi+ ^pi- pi0",
193 ], use_names=
False, use_relative_indices=
True)
196 """ check if the indexing works with more than two ... """
198 "B0 -> [D+ -> [K+ -> ^pi+]] [D+ -> [K+ -> ^pi+]] [D+ -> [K+ -> ^pi+]]",
206 """ check if the indexing works with more than two ... """
208 "B0 -> [D+ -> [K+ -> ^pi+]] [D+ -> [K+ -> ^pi+]] [D+ -> [K+ -> ^pi+]] [D+ -> [K+ -> ^pi+]]",
216 "B0 -> [D+ -> [K+ -> pi+]] [D+ -> [K+ -> ^pi+]] [D+ -> [^K+ -> pi+]] [D+ -> [K+ -> ^pi+]]",
223 "B0 -> [D+ -> [K+ -> pi+]] [D+ -> [K+ -> ^pi+]] [D+ -> [^K+ -> pi+]] [D+ -> [K+ -> ^pi+]]",
228 ], use_relative_indices=
True)
231 """Test many many children"""
233 "B0 -> e+:0 ^e+:1 ^e+:2 e+:3 ^e+:4 e+:5 ^e+:6 mu+:7 ^mu+:8 mu+:9 ^mu+:10 ^mu+:11 mu+:12",
245 """Test many many children with relative indices"""
247 "B0 -> e+:0 ^e+:1 ^e+:2 e+:3 ^e+:4 e+:5 ^e+:6 mu+:7 ^mu+:8 mu+:9 ^mu+:10 ^mu+:11 mu+:12",
256 ], use_relative_indices=
True)
259 """Test many many children without names"""
260 for use_relative_indices
in True,
False:
261 for always_include_indices
in True,
False:
263 "B0 -> e+:0 ^e+:1 ^e+:2 e+:3 ^e+:4 e+:5 ^e+:6 mu+:7 ^mu+:8 mu+:9 ^mu+:10 ^mu+:11 mu+:12",
273 use_relative_indices=use_relative_indices,
274 always_include_indices=always_include_indices,
278 """Select a decay with the inclusive particle marker"""
282 """Print all aliases as a final check"""
286 if __name__ ==
'__main__':