30def load(conffile = os.path.expandvars(
'$FAIRSHIP/python/DecaySelection.conf'), verbose=
True):
31 f = open(conffile,
'r')
32 reader = csv.reader(f, delimiter=
':')
36 if str(row[0]).strip().startswith(
'#'):
38 channel = str(row[0]).strip()
39 flag = str(row[-1]).partition(
'#')[0].strip()
40 configuredDecays[channel] = flag
42 print(
'Activated decay channels (plus charge conjugates): ')
43 for channel
in configuredDecays.keys():
44 if configuredDecays[channel] ==
'yes':
46 return configuredDecays
48def addHNLdecayChannels(P8Gen, hnl, conffile=os.path.expandvars(
'$FAIRSHIP/python/DecaySelection.conf'), verbose=
True):
50 Configures the HNL decay table in Pythia8
52 - P8Gen: an instance of ROOT.HNLPythia8Generator()
53 - hnl: an instance of hnl.HNL()
54 - conffile: a file listing the channels one wishes to activate
57 allowed = hnl.allowedChannels()
59 wanted =
load(conffile=conffile, verbose=verbose)
63 print(
'addHNLdecayChannels ERROR: channel not configured!\t', dec)
65 if allowed[dec] ==
'yes' and wanted[dec] ==
'yes':
66 particles = [p
for p
in dec.replace(
'->',
' ').split()]
67 children = particles[1:]
68 childrenCodes = [
PDGcode(p)
for p
in children]
69 BR = hnl.findBranchingRatio(dec)
72 codes =
' '.join([str(code)
for code
in childrenCodes])
73 P8Gen.SetParameters(
'9900015:addChannel = 1 {:.12} 0 {}'.format(BR, codes))
75 codes =
' '.join([(str(-1*code)
if pdg.GetParticle(-code)!=
None else str(code))
for code
in childrenCodes])
76 P8Gen.SetParameters(
'9900015:addChannel = 1 {:.12} 0 {}'.format(BR, codes))
79def addDarkPhotondecayChannels(P8gen, mDP, DP,conffile=os.path.expandvars(
'$FAIRSHIP/python/darkphotonDecaySelection.conf'), verbose=
True):
81 Configures the DP decay table in Pythia8
84 - P8gen: an instance of ROOT.HNLPythia8Generator()
85 - conffile: a file listing the channels one wishes to activate
87 isResonant = (P8gen.GetDPId()==4900023)
89 allowed = DP.allowedChannels()
91 wanted =
load(conffile=conffile, verbose=verbose)
94 print(
'channel allowed:',dec)
96 print(
'addDarkPhotondecayChannels WARNING: channel not configured! Please add also in conf file.\t', dec)
98 print(
'channel wanted:',dec)
100 if allowed[dec] ==
'yes' and wanted[dec] ==
'yes':
102 BR = DP.findBranchingRatio(dec)
105 if isResonant: meMode = 103
108 print(
"debug readdecay table hadrons BR ",BR)
110 dpid = P8gen.GetDPId()
112 P8gen.SetParameters(
"{}:addChannel = 1 {:.12} {} 1 -1"\
113 .format(dpid, 0.167*BR, meMode))
114 P8gen.SetParameters(
"{}:addChannel = 1 {:.12} {} 2 -2"\
115 .format(dpid, 0.666*BR, meMode))
116 P8gen.SetParameters(
"{}:addChannel = 1 {:.12} {} 3 -3"\
117 .format(dpid, 0.167*BR, meMode))
119 P8gen.SetParameters(
"{}:addChannel = 1 {:.12} {} 1 -1"\
120 .format(dpid, 0.1*BR, meMode))
121 P8gen.SetParameters(
"{}:addChannel = 1 {:.12} {} 2 -2"\
122 .format(dpid, 0.4*BR, meMode))
123 P8gen.SetParameters(
"{}:addChannel = 1 {:.12} {} 3 -3"\
124 .format(dpid, 0.1*BR, meMode))
125 P8gen.SetParameters(
"{}:addChannel = 1 {:.12} {} 4 -4"\
126 .format(dpid, 0.4*BR, meMode))
128 particles = [p
for p
in dec.replace(
'->',
' ').split()]
129 children = particles[1:]
130 childrenCodes = [
PDGcode(p)
for p
in children]
131 codes =
' '.join(str(code)
for code
in childrenCodes)
132 P8gen.SetParameters(
"{}:addChannel = 1 {:.12} {} {}"\
133 .format(P8gen.GetDPId(), BR, meMode, codes))
134 print(
"debug readdecay table ",particles,children,BR)