8import proton_bremsstrahlung
12from method_logger
import MethodLogger
22def addDPtoROOT(pid=9900015, m=0.2, g=4.866182e-04):
23 pdg = ROOT.TDatabasePDG.Instance()
24 pdg.AddParticle(
"A",
"DarkPhoton", m,
False, g, 0.0,
"A", pid)
28 FairShip = os.environ[
"FAIRSHIP"]
29 with open(FairShip +
"/shipgen/branchingratios.dat")
as ascii:
30 content = ascii.readlines()
33 while n < len(content):
36 keys = line.split(
"|")
38 limits = content[n].split(
",")
43 hname, keys[2] +
";" + keys[3] +
";" + keys[4], int(limits[0]), float(limits[1]), float(limits[2])
46 keys = line.split(
",")
47 h[hname].SetBinContent(int(keys[0]), float(keys[1]))
55 if motherMode ==
"pi0" and pi0mass - mass >= 0.0000001:
58 P8gen.SetParameters(
"111:oneChannel = 1 1 0 22 9900015")
60 elif motherMode ==
"eta" and etamass - mass >= 0.000001:
64 P8gen.SetParameters(
"221:oneChannel = 1 1 0 22 9900015")
66 elif motherMode ==
"omega" and omegamass - mass >= 0.00001:
70 P8gen.SetParameters(
"223:oneChannel = 1 1 0 111 9900015")
72 elif motherMode ==
"eta1" and eta1mass - mass >= 0.00001:
75 P8gen.SetParameters(
"331:oneChannel = 1 1 0 22 9900015")
80 elif motherMode ==
"eta11" and eta1mass - mass >= 0.00001:
83 P8gen.SetParameters(
"331:oneChannel = 1 1 0 113 9900015")
94def configure(P8gen, mass, epsilon, inclusive, motherMode, deepCopy=False, debug=True):
96 _exit_stack = contextlib.ExitStack()
98 pythia_log = _exit_stack.enter_context(
open(
"pythia8_conf.txt",
"w"))
104 ROOT.TDatabasePDG.Instance()
105 if inclusive ==
"meson":
107 p8 = P8gen.getPythiaInstance()
110 n = p8.particleData.nextId(n)
111 p = p8.particleData.particleDataEntryPtr(n)
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()))
118 P8gen.SetParameters(
"SoftQCD:nonDiffractive = on")
120 elif inclusive ==
"qcd":
122 P8gen.SetMinDPMass(0.7)
124 if mass < P8gen.MinDPMass():
125 print(
"WARNING! Mass is too small, minimum is set to %3.3f GeV." % P8gen.MinDPMass())
129 p8 = P8gen.getPythiaInstance()
132 n = p8.particleData.nextId(n)
133 p = p8.particleData.particleDataEntryPtr(n)
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()))
140 P8gen.SetParameters(
"HiddenValley:ffbar2Zv = on")
141 P8gen.SetParameters(
"HiddenValley:Ngauge = 1")
143 elif inclusive ==
"pbrem":
144 P8gen.SetParameters(
"ProcessLevel:all = off")
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)
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}")
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}")
176 P8gen.SetParameters(f
"{dpid}:onMode = off")
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"
187 P8gen.SetParameters(
"Next:numberCount = 0")
194 conffile=os.path.expandvars(
"$FAIRSHIP/python/darkphotonDecaySelection.conf"),
198 P8gen.SetParameters(f
"{P8gen.GetDPId()}:mayDecay = on")
201 gamma = u.hbarc / float(ctau)
202 print(
"gamma=%e" % gamma)
203 addDPtoROOT(pid=P8gen.GetDPId(), m=mass, g=gamma)
205 if inclusive ==
"meson":
208 print(
"selected mum is : %d" % selectedMum)
209 if selectedMum == -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 configure(P8gen, mass, epsilon, inclusive, motherMode, deepCopy=False, debug=True)
def manipulatePhysics(motherMode, mass, P8gen)
def addDarkPhotondecayChannels(P8gen, mDP, DP, conffile=os.path.expandvars("$FAIRSHIP/python/darkphotonDecaySelection.conf"), verbose=True)
int open(const char *, int)
Opens a file descriptor.