5# ==================================================================
21from hnl import PDGname
23pdg = ROOT.TDatabasePDG.Instance()
28 Read particle ID from PDG database
30 particle = PDGname(particle)
31 tPart = pdg.GetParticle(particle)
32 return int(tPart.PdgCode())
35def load(conffile=os.path.expandvars(
"$FAIRSHIP/python/DecaySelection.conf"), verbose=
True):
36 with open(conffile)
as f:
37 reader = csv.reader(f, delimiter=
":")
42 if str(row[0]).strip().startswith(
"#"):
44 channel = str(row[0]).strip()
45 flag = str(row[-1]).partition(
"#")[0].strip()
46 configuredDecays[channel] = flag
48 print(
"Activated decay channels (plus charge conjugates): ")
49 for channel
in configuredDecays:
50 if configuredDecays[channel] ==
"yes":
52 return configuredDecays
55def addHNLdecayChannels(P8Gen, hnl, conffile=os.path.expandvars(
"$FAIRSHIP/python/DecaySelection.conf"), verbose=
True):
57 Configures the HNL decay table in Pythia8
59 - P8Gen: an instance of ROOT.HNLPythia8Generator()
61 - conffile: a file listing the channels one wishes to activate
64 allowed = hnl.allowedChannels()
66 wanted =
load(conffile=conffile, verbose=verbose)
70 print(
"addHNLdecayChannels ERROR: channel not configured!\t", dec)
72 if allowed[dec] ==
"yes" and wanted[dec] ==
"yes":
73 particles = list(dec.replace(
"->",
" ").split())
74 children = particles[1:]
75 childrenCodes = [
PDGcode(p)
for p
in children]
76 BR = hnl.findBranchingRatio(dec)
79 codes =
" ".join([str(code)
for code
in childrenCodes])
80 P8Gen.SetParameters(f
"9900015:addChannel = 1 {BR:.12} 0 {codes}")
83 [(str(-1 * code)
if pdg.GetParticle(-code)
is not None else str(code))
for code
in childrenCodes]
85 P8Gen.SetParameters(f
"9900015:addChannel = 1 {BR:.12} 0 {codes}")
90 P8gen, mDP, DP, conffile=os.path.expandvars(
"$FAIRSHIP/python/darkphotonDecaySelection.conf"), verbose=
True
93 Configures the DP decay table in Pythia8
96 - P8gen: an instance of ROOT.HNLPythia8Generator()
97 - conffile: a file listing the channels one wishes to activate
99 isResonant = P8gen.GetDPId() == 4900023
101 allowed = DP.allowedChannels()
103 wanted =
load(conffile=conffile, verbose=verbose)
106 print(
"channel allowed:", dec)
107 if dec
not in wanted:
108 print(
"addDarkPhotondecayChannels WARNING: channel not configured! Please add also in conf file.\t", dec)
110 print(
"channel wanted:", dec)
112 if allowed[dec] ==
"yes" and wanted[dec] ==
"yes":
113 BR = DP.findBranchingRatio(dec)
120 print(
"debug readdecay table hadrons BR ", BR)
122 dpid = P8gen.GetDPId()
124 P8gen.SetParameters(f
"{dpid}:addChannel = 1 {0.167 * BR:.12} {meMode} 1 -1")
125 P8gen.SetParameters(f
"{dpid}:addChannel = 1 {0.666 * BR:.12} {meMode} 2 -2")
126 P8gen.SetParameters(f
"{dpid}:addChannel = 1 {0.167 * BR:.12} {meMode} 3 -3")
128 P8gen.SetParameters(f
"{dpid}:addChannel = 1 {0.1 * BR:.12} {meMode} 1 -1")
129 P8gen.SetParameters(f
"{dpid}:addChannel = 1 {0.4 * BR:.12} {meMode} 2 -2")
130 P8gen.SetParameters(f
"{dpid}:addChannel = 1 {0.1 * BR:.12} {meMode} 3 -3")
131 P8gen.SetParameters(f
"{dpid}:addChannel = 1 {0.4 * BR:.12} {meMode} 4 -4")
133 particles = list(dec.replace(
"->",
" ").split())
134 children = particles[1:]
135 childrenCodes = [
PDGcode(p)
for p
in children]
136 codes =
" ".join(str(code)
for code
in childrenCodes)
137 P8gen.SetParameters(f
"{P8gen.GetDPId()}:addChannel = 1 {BR:.12} {meMode} {codes}")
138 print(
"debug readdecay table ", particles, children, BR)
141if __name__ ==
"__main__":
143 print(
"Activated decay channels: ")
144 for channel
in configuredDecays:
145 if configuredDecays[channel] ==
"yes":
def load(conffile=os.path.expandvars("$FAIRSHIP/python/DecaySelection.conf"), verbose=True)
def addDarkPhotondecayChannels(P8gen, mDP, DP, conffile=os.path.expandvars("$FAIRSHIP/python/darkphotonDecaySelection.conf"), verbose=True)
def addHNLdecayChannels(P8Gen, hnl, conffile=os.path.expandvars("$FAIRSHIP/python/DecaySelection.conf"), verbose=True)
int open(const char *, int)
Opens a file descriptor.