33 P8gen, mass, couplings, sfermionmass, benchmark, inclusive, deepCopy: bool =
False, debug: bool =
True
36 _exit_stack = contextlib.ExitStack()
38 pythia_log = _exit_stack.enter_context(open(
"pythia8_conf.txt",
"w"))
40 h = make_interpolators(os.path.expandvars(f
"$FAIRSHIP/shipgen/branchingratiosrpvsusybench{benchmark}.dat"))
45 ROOT.TDatabasePDG.Instance()
47 make_particles_stable(P8gen, above_lifetime=1)
52 if inclusive ==
"True":
57 P8gen.SetParameters(
"HardQCD::hardccbar = on")
59 rpvsusy_instance =
rpvsusy.RPVSUSY(mass, couplings, sfermionmass, benchmark, debug=
True)
60 ctau = rpvsusy_instance.computeNLifetime(system=
"FairShip") * u.c_light * u.cm
61 print(
"RPVSUSY ctau ", ctau)
62 P8gen.SetParameters(f
"9900015:new = N2 N2 2 0 0 {mass:.12} 0.0 0.0 0.0 {ctau / u.mm:.12} 0 1 0 1 0")
63 P8gen.SetParameters(
"9900015:isResonance = false")
64 P8gen.SetParameters(
"Next:numberCount = 0")
66 rpvsusy_instance.AddChannelsToPythia(P8gen)
69 P8gen.SetParameters(
"9900015:mayDecay = on")
70 P8gen.SetHNLId(9900015)
72 gamma = u.hbarc / float(ctau)
73 addHNLtoROOT(pid=9900015, m=mass, g=gamma)
75 charmhistograms = [
"d_mu",
"ds_mu"]
77 maxsumBR = getmaxsumbrrpvsusy(h, charmhistograms, mass, couplings)
78 exit_if_zero_br(maxsumBR, inclusive, mass, particle=
"RPV neutralino")
79 gettotalbrrpvsusy(h, charmhistograms, mass, couplings)
83 "431:new D_s+ D_s- 1 3 0 1.96849"
84 " 0.00000 0.00000 0.00000 1.49900e-01 0 1 0 1 0"
87 br_ds_mu = getbr_rpvsusy(h,
"ds_mu", mass, couplings[1])
89 P8gen.SetParameters(f
"431:addChannel 1 {br_ds_mu / maxsumBR:.12} 0 -13 9900015")
90 sumBR += float(br_ds_mu / maxsumBR)
91 if sumBR < 1.0
and sumBR > 0.0:
92 P8gen.SetParameters(f
"431:addChannel 1 {1.0 - sumBR:.12} 0 22 -11")
96 "411:new D+ D- 1 3 0 1.86962 0.00000 0.00000 0.00000 3.11800e-01 0 1 0 1 0"
99 br_d_mu = getbr_rpvsusy(h,
"d_mu", mass, couplings[1])
101 P8gen.SetParameters(f
"411:addChannel 1 {br_d_mu / maxsumBR:.12} 0 -13 9900015")
102 sumBR += float(br_d_mu / maxsumBR)
103 if sumBR < 1.0
and sumBR > 0.0:
104 P8gen.SetParameters(f
"411:addChannel 1 {1.0 - sumBR:.12} 0 22 -11")
109 P8gen.SetParameters(
"HardQCD::hardbbbar = on")
111 rpvsusy_instance =
rpvsusy.RPVSUSY(mass, couplings, sfermionmass, benchmark, debug=
True)
112 ctau = rpvsusy_instance.computeNLifetime(system=
"FairShip") * u.c_light * u.cm
113 P8gen.SetParameters(f
"9900015:new = N2 N2 2 0 0 {mass:.12} 0.0 0.0 0.0 {ctau / u.mm:.12} 0 1 0 1 0")
114 P8gen.SetParameters(
"9900015:isResonance = false")
116 rpvsusy_instance.AddChannelsToPythia(P8gen)
118 P8gen.SetParameters(
"9900015:mayDecay = on")
119 P8gen.SetHNLId(9900015)
121 gamma = u.hbarc / float(ctau)
122 addHNLtoROOT(pid=9900015, m=mass, g=gamma)
124 beautyhistograms = [
"b_mu",
"b_tau",
"b0_nu_mu",
"b0_nu_tau"]
125 maxsumBR = getmaxsumbrrpvsusy(h, beautyhistograms, mass, couplings)
126 exit_if_zero_br(maxsumBR, inclusive, mass, particle=
"RPV neutralino")
127 gettotalbrrpvsusy(h, beautyhistograms, mass, couplings)
131 "521:new B+ B- 1 3 0 5.27925"
132 " 0.00000 0.00000 0.00000 4.91100e-01 0 1 0 1 0"
135 br_b_tau = getbr_rpvsusy(h,
"b_tau", mass, couplings[1])
137 P8gen.SetParameters(f
"521:addChannel 1 {br_b_tau / maxsumBR:.12} 0 9900015 -15")
138 sumBR += float(br_b_tau / maxsumBR)
139 if sumBR < 1.0
and sumBR > 0.0:
140 P8gen.SetParameters(f
"521:addChannel 1 {1.0 - sumBR:.12} 0 22 22")
144 "511:new B0 Bbar0 1 0 0 5.27958"
145 " 0.00000 0.00000 0.00000 4.58700e-01 0 1 0 1 0"
148 br_b0_nu_tau = getbr_rpvsusy(h,
"b0_nu_tau", mass, couplings[1])
149 if br_b0_nu_tau > 0.0:
150 P8gen.SetParameters(f
"511:addChannel 1 {br_b0_nu_tau / maxsumBR:.12} 22 9900015 16")
151 sumBR += float(br_b0_nu_tau / maxsumBR)
152 if sumBR < 1.0
and sumBR > 0.0:
153 P8gen.SetParameters(f
"511:addChannel 1 {1.0 - sumBR:.12} 0 22 22")
161 P8gen, mass, production_couplings, decay_couplings, process_selection, deepCopy: bool =
False, debug: bool =
True
164 This function configures a HNLPythia8Generator instance for SHiP usage.
167 if process_selection
is True:
168 process_selection =
"inclusive"
171 _exit_stack = contextlib.ExitStack()
173 pythia_log = _exit_stack.enter_context(open(
"pythia8_conf.txt",
"w"))
176 fairship_root = os.environ[
"FAIRSHIP"]
177 histograms = make_interpolators(fairship_root +
"/shipgen/branchingratios.dat")
182 ROOT.TDatabasePDG.Instance()
183 P8gen.SetParameters(
"Next:numberCount = 0")
185 make_particles_stable(P8gen, above_lifetime=1)
190 datafile = fairship_root +
"/python/hnl_production.yaml"
191 with open(datafile)
as f:
192 data = yaml.load(f, Loader=yaml.FullLoader)
193 all_channels = data[
"channels"]
198 if process_selection ==
"inclusive":
204 if process_selection ==
"c":
205 selection = data[
"selections"][
"c"]
206 for cmd
in selection[
"parameters"]:
207 P8gen.SetParameters(cmd)
208 add_hnl(P8gen, mass, decay_couplings)
214 c_particles = selection[
"particles"]
216 add_particles(P8gen, c_particles + [tau_id], data)
222 c_channels = [ch
for ch
in all_channels
if ch[
"id"]
in c_particles]
223 tau_channels = [ch
for ch
in all_channels
if ch[
"id"] == tau_id]
234 primary_decays = [(ch[
"id"], [get_br(histograms, ch, mass, production_couplings)])
for ch
in c_channels]
237 (ds_id, [ds_tau_br, get_br(histograms, ch, mass, production_couplings)])
for ch
in tau_channels
239 all_decays = primary_decays + secondary_decays
242 max_total_br = compute_max_total_br(all_decays)
243 exit_if_zero_br(max_total_br, process_selection, mass)
244 print_scale_factor(1 / max_total_br)
247 for ch
in c_channels:
248 add_channel(P8gen, ch, histograms, mass, production_couplings, 1 / max_total_br)
254 total_tau_br = sum(branching_ratios[1]
for (_, branching_ratios)
in secondary_decays)
255 assert ds_tau_br * total_tau_br <= max_total_br + 1e-12
257 f
"431:addChannel 1 {ds_tau_br * total_tau_br / max_total_br:.12} 0 -15 16"
260 for ch
in tau_channels:
262 add_tau_channel(P8gen, ch, histograms, mass, production_couplings, 1 / (total_tau_br
or 1))
265 fill_missing_channels(P8gen, max_total_br, all_decays)
273 if process_selection
in [
"b",
"bc"]:
274 selection = data[
"selections"][process_selection]
275 for cmd
in selection[
"parameters"]:
276 P8gen.SetParameters(cmd)
277 add_hnl(P8gen, mass, decay_couplings)
280 particles = selection[
"particles"]
281 add_particles(P8gen, particles, data)
284 channels = [ch
for ch
in all_channels
if ch[
"id"]
in particles]
285 decays = [(ch[
"id"], [get_br(histograms, ch, mass, production_couplings)])
for ch
in channels]
288 max_total_br = compute_max_total_br(decays)
289 exit_if_zero_br(max_total_br, process_selection, mass)
290 print_scale_factor(1 / max_total_br)
294 add_channel(P8gen, ch, histograms, mass, production_couplings, 1 / max_total_br)
297 fill_missing_channels(P8gen, max_total_br, decays)
304def add_hnl(P8gen, mass, decay_couplings) -> None:
305 "Adds the HNL to Pythia and ROOT"
306 hnl_instance =
hnl.HNL(mass, decay_couplings, debug=
True)
307 ctau = hnl_instance.computeNLifetime(system=
"FairShip") * u.c_light * u.cm
308 print(f
"HNL ctau {ctau}")
309 P8gen.SetParameters(f
"9900015:new = N2 N2 2 0 0 {mass:.12} 0.0 0.0 0.0 {ctau / u.mm:.12} 0 1 0 1 0")
310 P8gen.SetParameters(
"9900015:isResonance = false")
313 P8gen, hnl_instance, conffile=os.path.expandvars(
"$FAIRSHIP/python/DecaySelection.conf"), verbose=
False
316 P8gen.SetParameters(
"9900015:mayDecay = on")
317 P8gen.SetHNLId(9900015)
319 gamma = u.hbarc / float(ctau)
320 addHNLtoROOT(pid=9900015, m=mass, g=gamma)