94def configure(P8gen, mass, epsilon, inclusive, motherMode, deepCopy=False, debug=True):
95
96 _exit_stack = contextlib.ExitStack()
97 if debug:
98 pythia_log = _exit_stack.enter_context(
open(
"pythia8_conf.txt",
"w"))
99 P8gen = MethodLogger(P8gen, sink=pythia_log)
100 P8gen.UseRandom3()
101 P8gen.SetMom(400)
102 if deepCopy:
103 P8gen.UseDeepCopy()
104 ROOT.TDatabasePDG.Instance()
105 if inclusive == "meson":
106
107 p8 = P8gen.getPythiaInstance()
108 n = 1
109 while n != 0:
110 n = p8.particleData.nextId(n)
111 p = p8.particleData.particleDataEntryPtr(n)
112 if p.tau0() > 1:
113 command = str(n) + ":mayDecay = false"
114 p8.readString(command)
115 print("Pythia8 configuration: Made %s stable for Pythia, should decay in Geant4" % (p.name()))
116
117
118 P8gen.SetParameters("SoftQCD:nonDiffractive = on")
119
120 elif inclusive == "qcd":
121 P8gen.SetDY()
122 P8gen.SetMinDPMass(0.7)
123
124 if mass < P8gen.MinDPMass():
125 print("WARNING! Mass is too small, minimum is set to %3.3f GeV." % P8gen.MinDPMass())
126 return 0
127
128
129 p8 = P8gen.getPythiaInstance()
130 n = 1
131 while n != 0:
132 n = p8.particleData.nextId(n)
133 p = p8.particleData.particleDataEntryPtr(n)
134 if p.tau0() > 1:
135 command = str(n) + ":mayDecay = false"
136 p8.readString(command)
137 print("Pythia8 configuration: Made %s stable for Pythia, should decay in Geant4" % (p.name()))
138
139
140 P8gen.SetParameters("HiddenValley:ffbar2Zv = on")
141 P8gen.SetParameters("HiddenValley:Ngauge = 1")
142
143 elif inclusive == "pbrem":
144 P8gen.SetParameters("ProcessLevel:all = off")
145
146
147
148
149
150
151
152 P8gen.SetParameters("Next:numberShowInfo = 0")
153 P8gen.SetParameters("Next:numberShowProcess = 0")
154 P8gen.SetParameters("Next:numberShowEvent = 0")
155 proton_bremsstrahlung.protonEnergy = P8gen.GetMom()
157 print("A' production rate per p.o.t: \t %.8g" % norm)
159
160
162 ctau = DP_instance.cTau()
163 print("ctau p8dpconf file =%3.6f cm" % ctau)
164 print("Initial particle parameters for PDGID %d :" % P8gen.GetDPId())
165 P8gen.List(P8gen.GetDPId())
166 if inclusive == "qcd":
167 dpid = P8gen.GetDPId()
168 P8gen.SetParameters(f"{dpid}:m0 = {mass:.12}")
169
170 P8gen.SetParameters(f"{dpid}:mWidth = {u.hbarc / ctau:.12}")
171 P8gen.SetParameters(f"{dpid}:mMin = 0.001")
172 P8gen.SetParameters(f"{dpid}:tau0 = {ctau / u.mm:.12}")
173
174
175
176 P8gen.SetParameters(f"{dpid}:onMode = off")
177 else:
178 P8gen.SetParameters(
179 f"{P8gen.GetDPId()}:new = A A 3 0 0 {mass:.12} 0.0 0.0 0.0 {ctau / u.mm:.12} 0 1 0 1 0"
180 )
181
182
186
187 P8gen.SetParameters("Next:numberCount = 0")
188
189
191 P8gen,
192 mass,
193 DP_instance,
194 conffile=os.path.expandvars("$FAIRSHIP/python/darkphotonDecaySelection.conf"),
195 verbose=True,
196 )
197
198 P8gen.SetParameters(f"{P8gen.GetDPId()}:mayDecay = on")
199
200
201 gamma = u.hbarc / float(ctau)
202 print("gamma=%e" % gamma)
203 addDPtoROOT(pid=P8gen.GetDPId(), m=mass, g=gamma)
204
205 if inclusive == "meson":
206
207 selectedMum = manipulatePhysics(motherMode, mass, P8gen)
208 print("selected mum is : %d" % selectedMum)
209 if selectedMum == -1:
210 return 0
211
212
213
214 _exit_stack.close()
215
216 return 1
def prodRate(mDarkPhoton, epsilon, tmin=-0.5 *math.pi, tmax=0.5 *math.pi)
def hProdPDF(mDarkPhoton, epsilon, norm, binsp, binstheta, tmin=-0.5 *math.pi, tmax=0.5 *math.pi, suffix="")
def addDarkPhotondecayChannels(P8gen, mDP, DP, conffile=os.path.expandvars("$FAIRSHIP/python/darkphotonDecaySelection.conf"), verbose=True)
int open(const char *, int)
Opens a file descriptor.