33def load(conffile=os.path.expandvars(
"$FAIRSHIP/python/DecaySelection.conf"), verbose=
True):
34 with open(conffile)
as f:
35 reader = csv.reader(f, delimiter=
":")
40 if str(row[0]).strip().startswith(
"#"):
42 channel = str(row[0]).strip()
43 flag = str(row[-1]).partition(
"#")[0].strip()
44 configuredDecays[channel] = flag
46 print(
"Activated decay channels (plus charge conjugates): ")
47 for channel
in configuredDecays:
48 if configuredDecays[channel] ==
"yes":
50 return configuredDecays
53def addHNLdecayChannels(P8Gen, hnl, conffile=os.path.expandvars(
"$FAIRSHIP/python/DecaySelection.conf"), verbose=
True):
55 Configures the HNL decay table in Pythia8
57 - P8Gen: an instance of ROOT.HNLPythia8Generator()
58 - hnl: an instance of hnl.HNL()
59 - conffile: a file listing the channels one wishes to activate
62 allowed = hnl.allowedChannels()
64 wanted =
load(conffile=conffile, verbose=verbose)
68 raise ValueError(f
"addHNLdecayChannels: channel not configured: {dec}")
69 if allowed[dec] ==
"yes" and wanted[dec] ==
"yes":
70 particles = list(dec.replace(
"->",
" ").split())
71 children = particles[1:]
72 childrenCodes = [
PDGcode(p)
for p
in children]
73 BR = hnl.findBranchingRatio(dec)
76 codes =
" ".join([str(code)
for code
in childrenCodes])
77 P8Gen.SetParameters(f
"9900015:addChannel = 1 {BR:.12} 0 {codes}")
79 codes =
" ".join([(str(-1 * code)
if is_known_particle(-code)
else str(code))
for code
in childrenCodes])
80 P8Gen.SetParameters(f
"9900015:addChannel = 1 {BR:.12} 0 {codes}")
85 P8gen, mDP, DP, conffile=os.path.expandvars(
"$FAIRSHIP/python/darkphotonDecaySelection.conf"), verbose=
True
88 Configures the DP decay table in Pythia8
91 - P8gen: an instance of ROOT.HNLPythia8Generator()
92 - conffile: a file listing the channels one wishes to activate
94 isResonant = P8gen.GetDPId() == 4900023
96 allowed = DP.allowedChannels()
98 wanted =
load(conffile=conffile, verbose=verbose)
101 print(
"channel allowed:", dec)
102 if dec
not in wanted:
103 raise ValueError(f
"addDarkPhotondecayChannels: channel not configured (add it to the conf file): {dec}")
104 print(
"channel wanted:", dec)
106 if allowed[dec] ==
"yes" and wanted[dec] ==
"yes":
107 BR = DP.findBranchingRatio(dec)
114 print(
"debug readdecay table hadrons BR ", BR)
116 dpid = P8gen.GetDPId()
118 P8gen.SetParameters(f
"{dpid}:addChannel = 1 {0.167 * BR:.12} {meMode} 1 -1")
119 P8gen.SetParameters(f
"{dpid}:addChannel = 1 {0.666 * BR:.12} {meMode} 2 -2")
120 P8gen.SetParameters(f
"{dpid}:addChannel = 1 {0.167 * BR:.12} {meMode} 3 -3")
122 P8gen.SetParameters(f
"{dpid}:addChannel = 1 {0.1 * BR:.12} {meMode} 1 -1")
123 P8gen.SetParameters(f
"{dpid}:addChannel = 1 {0.4 * BR:.12} {meMode} 2 -2")
124 P8gen.SetParameters(f
"{dpid}:addChannel = 1 {0.1 * BR:.12} {meMode} 3 -3")
125 P8gen.SetParameters(f
"{dpid}:addChannel = 1 {0.4 * BR:.12} {meMode} 4 -4")
127 particles = list(dec.replace(
"->",
" ").split())
128 children = particles[1:]
129 childrenCodes = [
PDGcode(p)
for p
in children]
130 codes =
" ".join(str(code)
for code
in childrenCodes)
131 P8gen.SetParameters(f
"{P8gen.GetDPId()}:addChannel = 1 {BR:.12} {meMode} {codes}")
132 print(
"debug readdecay table ", particles, children, BR)