FairShip
Loading...
Searching...
No Matches
makeCascadePythia8 Namespace Reference

Classes

class  NucleusModel
class  SignalConfig
class  PythiaFactory
class  SignalEvents
class  InclusiveSignalEvents

Functions

 nucleus_model (version)
 read_pythia8_settings (path)
 kforced_charm (beam_id, nucleon_id, p)
 signal_kfactor (kfactors, beam_id, nucleon_id, p)
 mass (pdg_id)
 ecm (beam_id, nucleon_id, p)
 n_coll_avg (a, sigma_hn, model)
 nuclear_collision (coll_pythia, decayer, model, beam_id, px, py, pz, z, a, p_min)
 cm_beam_settings (beam_id, nucleon_id, p)
 next_event (pythia)
 parse_args ()
 main ()

Variables

list CASCADE_IDS = [2212, 211, 2112, 321, 130, 310]
list TARGET_NUCLEONS = [2212, 2112]
dict PROTON_FRACTION = {"W": 0.40, "Mo": 0.43}
dict TARGET_NUCLEUS = {"W": (74, 184), "Mo": (42, 98)}
list NCOLL_A = [1, 2, 4, 9, 12, 14, 16, 27, 40, 56, 63, 84, 107, 129, 197, 208]
dict NUCLEUS_MODELS
dict SIGNAL
str FTFT_FILE = "$FAIRSHIP/gconfig/FTFT.cmnd"
list KFORCED_CHARM_P = [34.0, 40.0, 47.0, 60.0, 100.0, 160.0, 250.0, 400.0]
dict KFORCED_CHARM
float SIGNAL_BIN_RATIO = 1.1
 PDG = ROOT.TDatabasePDG.Instance()
 PYTHIA_DATA = pythia8.Pythia("", False)
int MAX_INCLUSIVE_TRIES = 100_000_000

Detailed Description

Pythia8 version of makeCascade.py: generate ccbar or bbbar in the hadronic cascade of the target.

Same algorithm and output ntuple as makeCascade.py, so the output can be used as input file of
run_fixedTarget.py. Every particle on the cascade stack produces a signal event with probability
chi/chi_max, chi = K * sigma(signal) / sigma(total), and a minimum-bias event whose hadrons above
threshold are added to the stack. Pythia8 changes the beam energy event by event only for soft QCD,
so signal events are generated in batches in 10% momentum bins, in the centre-of-mass frame, and
boosted to the lab along the projectile.

Unlike makeCascade.py, elastic scattering does not increase the cascade depth, so depth 1 (the
normalisation of run_fixedTarget.py) covers the beam proton up to its first inelastic interaction.

With --cascade-model nucleus (default), every interaction of a cascade hadron is a hadron-nucleus
collision built from hadron-nucleon subcollisions as in Pythia's PythiaCascade: a geometric number
of subcollisions with the average of PythiaCascade for the target nucleus, the later ones by the
leading hadron of the previous one. The heavy-flavour probability is then per hadron-nucleus
collision, A sigma(signal) / sigma(hA), consistent with the normalisation of run_fixedTarget.py,
which is per proton-nucleus interaction. --cascade-model nucleon follows makeCascade.py, with
single collisions on free nucleons, which counts the subcollisions inside a nucleus twice.

With --charm-production inclusive, charm signal events are inclusive inelastic events (SoftQCD:inelastic)
generated at the exact momentum and direction of the projectile and kept if they contain charm, instead
of forced HardQCD:hardccbar events. The FTFT tune describes charm production data with inclusive events;
forced production has somewhat different x_F and pT^2 distributions. The normalisation (chi) is the same.

Function Documentation

◆ cm_beam_settings()

makeCascadePythia8.cm_beam_settings ( beam_id,
nucleon_id,
p )

Definition at line 303 of file makeCascadePythia8.py.

303def cm_beam_settings(beam_id, nucleon_id, p):
304 return [
305 f"Beams:idA = {beam_id}",
306 f"Beams:idB = {nucleon_id}",
307 # centre-of-mass frame: events generated at the nearest grid momentum are boosted with the
308 # momentum and direction of the actual projectile
309 "Beams:frameType = 1",
310 f"Beams:eCM = {ecm(beam_id, nucleon_id, p)}",
311 ]
312
313

◆ ecm()

makeCascadePythia8.ecm ( beam_id,
nucleon_id,
p )
Centre-of-mass energy of beam_id with momentum p on nucleon_id at rest.

Definition at line 203 of file makeCascadePythia8.py.

203def ecm(beam_id, nucleon_id, p):
204 """Centre-of-mass energy of beam_id with momentum p on nucleon_id at rest."""
205 m_beam, m_target = mass(beam_id), mass(nucleon_id)
206 return math.sqrt(m_beam**2 + m_target**2 + 2.0 * m_target * math.sqrt(p**2 + m_beam**2))
207
208

◆ kforced_charm()

makeCascadePythia8.kforced_charm ( beam_id,
nucleon_id,
p )
Forced-production charm K-factor for beam_id on target nucleon nucleon_id at momentum p.

Definition at line 165 of file makeCascadePythia8.py.

165def kforced_charm(beam_id, nucleon_id, p):
166 """Forced-production charm K-factor for beam_id on target nucleon nucleon_id at momentum p."""
167 abs_id = abs(beam_id)
168 if abs_id in (2212, 2112):
169 # n on p behaves as p on n, and n on n as p on p
170 key = (2212, nucleon_id) if abs_id == 2212 else (2212, 2112 if nucleon_id == 2212 else 2212)
171 kfactors = KFORCED_CHARM[key]
172 elif abs_id == 211:
173 # pi+ n behaves as pi- p, and pi- n as pi+ p
174 sign = 1 if beam_id > 0 else -1
175 key = (sign * 211 if nucleon_id == 2212 else -sign * 211, 2212)
176 kfactors = KFORCED_CHARM[key]
177 else:
178 kfactors = [0.5 * (a + b) for a, b in zip(KFORCED_CHARM[211, 2212], KFORCED_CHARM[-211, 2212])]
179 return float(np.interp(math.log(p), np.log(KFORCED_CHARM_P), kfactors))
180
181

◆ main()

makeCascadePythia8.main ( )

Definition at line 505 of file makeCascadePythia8.py.

505def main():
506 args = parse_args()
507 signal = SIGNAL[args.heavy_quark]
508 p_threshold, signal_ids, signal_process = signal.p_threshold, signal.ids, signal.process
509 proton_fraction = PROTON_FRACTION[args.target_composition]
510 if args.pythia8_tune == "FTFT":
511 tune_settings, kfactors = read_pythia8_settings(FTFT_FILE), signal.kfactors
512 else:
513 tune_settings, kfactors = [], (1.0, 1.0)
514
515 random.seed(args.seed)
516 new_pythia = PythiaFactory(args.seed, tune_settings, [*CASCADE_IDS, *signal_ids])
517
518 # minimum-bias events with variable beam particle and energy, one instance per target nucleon
519 mbias_pythia = [
520 new_pythia(
521 ["SoftQCD:all = on", "Beams:frameType = 3", "Beams:allowVariableEnergy = on", "Beams:allowIDAswitch = on"]
522 + [f"Beams:idB = {nucleon_id}", f"Beams:pzA = {args.p_beam}", "Beams:pzB = 0."]
523 )
524 for nucleon_id in TARGET_NUCLEONS
525 ]
526
527 # chi = K * sigma(signal) / sigma(total) vs momentum for all beam and target particles.
528 # The grid is logarithmic and chi is interpolated in log(chi) vs log(p): chi varies by orders of
529 # magnitude over the range and most of that variation sits close to the threshold.
530 p_grid = np.geomspace(p_threshold, args.p_beam, args.n_momentum_points)
531 log_p_grid = np.log(p_grid)
532 log_chi, sigma = {}, {}
533 for pdg_id in CASCADE_IDS:
534 for beam_id in sorted({pdg_id, -pdg_id}):
535 if not PDG.GetParticle(beam_id):
536 continue
537 for i_nucleon, nucleon_id in enumerate(TARGET_NUCLEONS):
538 sigma[beam_id, i_nucleon] = []
539 for p in p_grid:
540 pythia = new_pythia(
541 [signal_process, "PartonLevel:all = off", "HadronLevel:all = off"]
542 + cm_beam_settings(beam_id, nucleon_id, p)
543 )
544 for _ in range(args.n_sigma_events):
545 next_event(pythia)
546 sigma[beam_id, i_nucleon].append(
547 signal_kfactor(kfactors, beam_id, nucleon_id, p) * pythia.infoPython().sigmaGen()
548 )
549 sigma_total = [
550 mbias_pythia[i_nucleon].getSigmaTotal(beam_id, nucleon_id, ecm(beam_id, nucleon_id, p))
551 for p in p_grid
552 ]
553 log_chi[beam_id, i_nucleon] = np.log([s / t for s, t in zip(sigma[beam_id, i_nucleon], sigma_total)])
554 print(
555 f"K*sigma and chi at {args.p_beam} GeV for {beam_id} on {nucleon_id}: "
556 f"{sigma[beam_id, i_nucleon][-1]:.3e} mb, {math.exp(log_chi[beam_id, i_nucleon][-1]):.3e}"
557 )
558 z_target, a_target = TARGET_NUCLEUS[args.target_composition]
559 version = round(mbias_pythia[0].settings.parm("Pythia:versionNumber"), 3) # codespell:ignore parm
560 model = nucleus_model(version)
561 coll_pythia, decayer = [], None
562 if args.cascade_model == "nucleus":
563 # subcollisions with hadron decays off, and the decays once a collision is complete
564 coll_pythia = [
565 new_pythia(
566 ["SoftQCD:all = on", "HadronLevel:Decay = off", "Beams:frameType = 3"]
567 + ["Beams:allowVariableEnergy = on", "Beams:allowIDAswitch = on", f"Beams:idB = {nucleon_id}"]
568 + [f"Beams:pzA = {args.p_beam}", "Beams:pzB = 0."]
569 )
570 for nucleon_id in TARGET_NUCLEONS
571 ]
572 decayer = new_pythia(["ProcessLevel:all = off"])
573 # heavy-flavour probability per hadron-nucleus collision: A sigma_QQ(hN) / sigma(hA), with
574 # sigma(hA) = A sigma_tot(hp) / <n_coll> as in PythiaCascade
575 for beam_id in {b for b, _ in log_chi}:
576 chi_nucleus = []
577 for i, p in enumerate(p_grid):
578 sigma_tot = mbias_pythia[0].getSigmaTotal(beam_id, 2212, ecm(beam_id, 2212, p))
579 sigma_n = proton_fraction * sigma[beam_id, 0][i] + (1.0 - proton_fraction) * sigma[beam_id, 1][i]
580 chi_nucleus.append(n_coll_avg(a_target, sigma_tot, model) * sigma_n / sigma_tot)
581 log_chi[beam_id, 0] = log_chi[beam_id, 1] = np.log(chi_nucleus)
582 chi_max = max(np.exp(c).max() for c in log_chi.values())
583 # cross section per nucleon of the target composition, at the beam energy, for the normalisation
584 sigma_QQ = proton_fraction * sigma[2212, 0][-1] + (1.0 - proton_fraction) * sigma[2212, 1][-1]
585 print(f"K*sigma per nucleon at {args.p_beam} GeV: {1e3 * sigma_QQ:.2f} ub")
586
587 signal_events = SignalEvents(new_pythia, signal_process, signal_ids, args.p_beam)
588 inclusive_events = (
589 InclusiveSignalEvents(new_pythia, signal_ids, args.heavy_quark, args.p_beam)
590 if args.charm_production == "inclusive" and args.heavy_quark == 4
591 else None
592 )
593
594 output_file = ROOT.TFile.Open(args.output, "RECREATE")
595 ntuple = ROOT.TNtuple(
596 "pythia6",
597 "pythia8 heavy flavour",
598 "id:px:py:pz:E:M:mid:mpx:mpy:mpz:mE:mM:k:a0:a1:a2:a3:a4:a5:a6:a7:a8:a9:a10:a11:a12:a13:a14:a15:\
599s0:s1:s2:s3:s4:s5:s6:s7:s8:s9:s10:s11:s12:s13:s14:s15:n_hadrons",
600 )
601 # number of signal particles per cascade depth, used by FixedTargetGenerator for the normalisation
602 depth_hist = ROOT.TH1F("2", "nr signal per cascade depth", 50, 0.5, 50.5)
603 # cross section per nucleon [mb] this file was generated with, read back by run_fixedTarget.py to
604 # scale chicc/chibb, so that the normalisation follows the beam energy, tune and target of the file
605 # hadd adds TParameters by default; keep the value of the first file when cascade files are merged
606 sigma_parameter = ROOT.TParameter("double")("sigma_QQ", sigma_QQ) # type: ignore[missing-attribute]
607 sigma_parameter.SetMergeMode("f")
608 sigma_parameter.Write()
609
610 t0 = time.time()
611 for i_pot in range(args.n_pot):
612 if i_pot % 1000 == 0:
613 print("Generate event ", i_pot)
614 # stack: PID, px, py, pz, cascade depth, ancestors, interaction processes
615 stack: list[tuple[int, float, float, float, int, list[int], list[int]]] = []
616 stack.append((2212, 0.0, 0.0, args.p_beam, 1, [2212] + 99 * [0], 100 * [0]))
617 while stack:
618 beam_id, px, py, pz, depth, ancestors, processes = stack.pop()
619 p = math.sqrt(px**2 + py**2 + pz**2)
620 i_nucleon = 0 if random.random() < proton_fraction else 1
621 nucleon_id = TARGET_NUCLEONS[i_nucleon]
622 if math.exp(np.interp(math.log(p), log_p_grid, log_chi[beam_id, i_nucleon])) / chi_max > random.random():
623 beam_mass = mass(beam_id)
624 beam = ROOT.TLorentzVector(px, py, pz, math.sqrt(p**2 + beam_mass**2))
625 if inclusive_events is not None:
626 code, hadrons = inclusive_events.next(beam_id, i_nucleon, px, py, pz)
627 else:
628 code, hadrons = signal_events.next(beam_id, nucleon_id, p)
629 boost = (beam + ROOT.TLorentzVector(0, 0, 0, mass(nucleon_id))).BoostVector() # type: ignore[missing-attribute]
630 n_processes = min(depth - 1, 15)
631 for hadron_id, *p4, hadron_mass in hadrons:
632 hadron = ROOT.TLorentzVector(*p4)
633 if inclusive_events is None: # forced events are generated in the CM frame
634 hadron.RotateUz(beam.Vect().Unit()) # type: ignore[missing-attribute]
635 hadron.Boost(boost) # type: ignore[missing-attribute]
636 row = [hadron_id, hadron.Px(), hadron.Py(), hadron.Pz(), hadron.E(), hadron_mass]
637 row += [beam_id, px, py, pz, beam.E(), beam_mass, depth]
638 row += ancestors[:16] + processes[:n_processes] + [code] + (15 - n_processes) * [0]
639 # all signal hadrons of the event, read back together by FixedTargetGenerator
640 row += [len(hadrons)]
641 ntuple.Fill(array("f", row))
642 depth_hist.Fill(depth)
643 if args.cascade_model == "nucleus":
644 # hadron-nucleus collision to add new cascade particles to the stack
645 code, _, final = nuclear_collision(
646 coll_pythia, decayer, model, beam_id, px, py, pz, z_target, a_target, p_threshold
647 )
648 if code == 102:
649 # only elastic subcollisions: the cascade generation is kept
650 leading = max(final, key=lambda f: f[4])
651 if leading[4] > p_threshold and len(stack) < 999:
652 stack.append((beam_id, *leading[1:4], depth, ancestors, processes))
653 continue
654 new_depth = min(depth + 1, 98)
655 if depth == 1: # first inelastic interaction process of the beam proton
656 processes = [code] + processes[1:]
657 for part_id, part_px, part_py, part_pz, part_p in final:
658 if abs(part_id) in CASCADE_IDS and part_p > p_threshold and len(stack) < 999:
659 new_ancestors = ancestors[: new_depth - 1] + [part_id] + ancestors[new_depth:]
660 new_processes = processes[: new_depth - 1] + [code] + processes[new_depth:]
661 stack.append((part_id, part_px, part_py, part_pz, new_depth, new_ancestors, new_processes))
662 continue
663 # minimum-bias event to add new cascade particles to the stack
664 i_nucleon = 0 if random.random() < proton_fraction else 1
665 pythia = mbias_pythia[i_nucleon]
666 pythia.setBeamIDs(beam_id, TARGET_NUCLEONS[i_nucleon])
667 pythia.setKinematics(px, py, pz, 0.0, 0.0, 0.0)
668 next_event(pythia)
669 code = pythia.infoPython().code()
670 if code == 102:
671 # Elastic scattering does not start a new cascade generation: the scattered hadron keeps
672 # its depth. Depth 1 is then everything the beam proton produces up to and including its
673 # first inelastic interaction, which is what chicc/chibb in run_fixedTarget.py normalise.
674 final = [pythia.event[i] for i in range(pythia.event.size()) if pythia.event[i].isFinal()]
675 leading = max(final, key=lambda part: part.pAbs())
676 if leading.pAbs() > p_threshold and len(stack) < 999:
677 stack.append((beam_id, leading.px(), leading.py(), leading.pz(), depth, ancestors, processes))
678 continue
679 new_depth = min(depth + 1, 98)
680 if depth == 1: # first inelastic interaction process of the beam proton
681 processes = [code] + processes[1:]
682 for i in range(pythia.event.size()):
683 part = pythia.event[i]
684 if part.idAbs() in CASCADE_IDS and part.isFinal() and part.pAbs() > p_threshold and len(stack) < 999:
685 new_ancestors = ancestors[: new_depth - 1] + [part.id()] + ancestors[new_depth:]
686 new_processes = processes[: new_depth - 1] + [code] + processes[new_depth:]
687 stack.append((part.id(), part.px(), part.py(), part.pz(), new_depth, new_ancestors, new_processes))
688
689 print(f"Generated {args.n_pot} p.o.t. in {time.time() - t0} s with {new_pythia.n_instances} Pythia8 instances")
690 if inclusive_events is not None:
691 print(f"{inclusive_events.n_tried} inclusive events generated for the charm signal")
692 output_file.Write()
693 output_file.Close()
694 print(f"Output file is {args.output}")
695
696

◆ mass()

makeCascadePythia8.mass ( pdg_id)

Definition at line 197 of file makeCascadePythia8.py.

197def mass(pdg_id):
198 if not PYTHIA_DATA.particleData.isParticle(pdg_id):
199 raise ValueError(f"Unknown particle: {pdg_id}")
200 return PYTHIA_DATA.particleData.m0(pdg_id)
201
202

◆ n_coll_avg()

makeCascadePythia8.n_coll_avg ( a,
sigma_hn,
model )
Average number of subcollisions in a hadron-nucleus collision (PythiaCascade::nCollAvg).

Definition at line 209 of file makeCascadePythia8.py.

209def n_coll_avg(a, sigma_hn, model):
210 """Average number of subcollisions in a hadron-nucleus collision (PythiaCascade::nCollAvg)."""
211
212 def n_more(i):
213 low = model.slope_lo[i] * sigma_hn
214 high = model.offset[i] + model.slope[i] * sigma_hn
215 if model.sigma_border is None:
216 return min(low, high)
217 return low if sigma_hn < model.sigma_border else high
218
219 for i, a_tab in enumerate(NCOLL_A):
220 if a == a_tab:
221 return 1.0 + n_more(i)
222 if a < a_tab:
223 w = (a_tab - a) / (a_tab - NCOLL_A[i - 1])
224 return (
225 1.0 + w * (a / NCOLL_A[i - 1]) ** (2 / 3) * n_more(i - 1) + (1 - w) * (a / a_tab) ** (2 / 3) * n_more(i)
226 )
227 raise ValueError(f"nucleus A = {a} outside 1-208")
228
229

◆ next_event()

makeCascadePythia8.next_event ( pythia)
Generate the next event, giving up after 100 failed attempts.

Definition at line 338 of file makeCascadePythia8.py.

338def next_event(pythia):
339 """Generate the next event, giving up after 100 failed attempts."""
340 for _ in range(100):
341 if pythia.next():
342 return
343 raise RuntimeError(
344 f"Pythia8 failed to generate an event for beams {pythia.infoPython().idA()} on {pythia.infoPython().idB()}"
345 )
346
347

◆ nuclear_collision()

makeCascadePythia8.nuclear_collision ( coll_pythia,
decayer,
model,
beam_id,
px,
py,
pz,
z,
a,
p_min )
Hadron-nucleus collision as a sequence of hadron-nucleon subcollisions, as in PythiaCascade::nextColl.

coll_pythia are minimum-bias instances on proton and neutron with hadron decays off, so that a leading
resonance collides again itself; the decays are done by decayer once the collision is complete.

Returns the process code of the first non-elastic subcollision (102 if all were elastic), the
number of subcollisions, and the final particles (id, px, py, pz, p) of all subcollisions, without
the hadrons that collided again.
Subcollisions stop once the leading hadron is below p_min, which no longer adds particles above it.

Definition at line 230 of file makeCascadePythia8.py.

230def nuclear_collision(coll_pythia, decayer, model, beam_id, px, py, pz, z, a, p_min):
231 """Hadron-nucleus collision as a sequence of hadron-nucleon subcollisions, as in PythiaCascade::nextColl.
232
233 coll_pythia are minimum-bias instances on proton and neutron with hadron decays off, so that a leading
234 resonance collides again itself; the decays are done by decayer once the collision is complete.
235
236 Returns the process code of the first non-elastic subcollision (102 if all were elastic), the
237 number of subcollisions, and the final particles (id, px, py, pz, p) of all subcollisions, without
238 the hadrons that collided again.
239 Subcollisions stop once the leading hadron is below p_min, which no longer adds particles above it.
240 """
241 p = math.sqrt(px**2 + py**2 + pz**2)
242 sigma_hn = coll_pythia[0].getSigmaTotal(beam_id, 2212, ecm(beam_id, 2212, p))
243 prob_more = 1.0 - 1.0 / n_coll_avg(a, sigma_hn, model)
244 direction = (px / p, py / p, pz / p)
245 n_p, n_n = z, a - z
246 final, latest = [], []
247 projectile = (beam_id, px, py, pz)
248 first_code, n_coll = 102, 0
249 for i_coll in range(1, a + 1):
250 proc_type = 0
251 if i_coll > 1:
252 if random.random() > prob_more:
253 break
254 hadrons = [f for f in latest if f[5]]
255 if not hadrons:
256 break
257 lead = max(hadrons, key=lambda f: f[1] * direction[0] + f[2] * direction[1] + f[3] * direction[2])
258 if lead[4] < p_min:
259 break
260 final.remove(lead)
261 projectile = lead[:4]
262 if ecm(lead[0], 2212, lead[4]) > model.sd_min_ecm:
263 proc_type = 4 if random.random() < model.prob_sd else model.other_process
264 on_proton = random.random() < n_p / (n_p + n_n)
265 if on_proton:
266 n_p -= 1
267 else:
268 n_n -= 1
269 pythia = coll_pythia[0 if on_proton else 1]
270 pythia.setBeamIDs(projectile[0], TARGET_NUCLEONS[0 if on_proton else 1])
271 pythia.setKinematics(*projectile[1:], 0.0, 0.0, 0.0)
272 for _ in range(100):
273 if pythia.next(proc_type) if proc_type else pythia.next():
274 break
275 else:
276 raise RuntimeError(f"Pythia8 failed to generate a subcollision for {projectile[0]}")
277 if first_code == 102:
278 first_code = pythia.infoPython().code()
279 n_coll += 1
280 event = pythia.event
281 latest = [
282 (event[i].id(), event[i].px(), event[i].py(), event[i].pz(), event[i].pAbs(), event[i].isHadron())
283 + (event[i].e(), event[i].m())
284 for i in range(event.size())
285 if event[i].isFinal()
286 ]
287 final += latest
288 # decays of the final particles, the cascade species staying stable
289 decayer.event.reset()
290 for part_id, part_px, part_py, part_pz, _, _, part_e, part_m in final:
291 decayer.event.append(part_id, 1, 0, 0, part_px, part_py, part_pz, part_e, part_m)
292 if not decayer.moreDecays():
293 raise RuntimeError("Pythia8 failed to decay the final particles of a hadron-nucleus collision")
294 event = decayer.event
295 final = [
296 (event[i].id(), event[i].px(), event[i].py(), event[i].pz(), event[i].pAbs())
297 for i in range(event.size())
298 if event[i].isFinal()
299 ]
300 return first_code, n_coll, final
301
302
constexpr Double_t m

◆ nucleus_model()

makeCascadePythia8.nucleus_model ( version)
PythiaCascade model of the installed Pythia version.

Definition at line 99 of file makeCascadePythia8.py.

99def nucleus_model(version):
100 """PythiaCascade model of the installed Pythia version."""
101 return NUCLEUS_MODELS[8.317 if version >= 8.317 else 8.312]
102
103

◆ parse_args()

makeCascadePythia8.parse_args ( )

Definition at line 430 of file makeCascadePythia8.py.

430def parse_args():
431 ap = argparse.ArgumentParser(description="Run SHiP makeCascade with Pythia8: generate ccbar or bbbar")
432 ap.add_argument(
433 "-s",
434 "--seed",
435 type=int,
436 default=int(time.time() * 100000000 % 900000000),
437 help="Random number seed, integer. If not given, current time will be used",
438 )
439 ap.add_argument(
440 "-t",
441 "--Fntuple",
442 dest="output",
443 default="",
444 help="Name of ntuple output file, default: Cascade{nevgen/1000}k-pythia8-{pythia8_tune}-MSEL{mselcb}-ntuple.root",
445 )
446 ap.add_argument(
447 "-n", "--nevgen", dest="n_pot", type=int, default=100000, help="Number of events to produce, default 100000"
448 )
449 ap.add_argument(
450 "-E", "--pbeamh", dest="p_beam", type=float, default=400.0, help="Energy of beam in GeV, default 400 GeV"
451 )
452 ap.add_argument(
453 "-m",
454 "--mselcb",
455 dest="heavy_quark",
456 type=int,
457 default=4,
458 help="4 (5): charm (beauty) production, default charm",
459 choices=[4, 5],
460 )
461 ap.add_argument(
462 "--target-composition",
463 default="W",
464 help="Target composition (to determine the ratio of protons in the material). Default is Tungsten (W). Only other choice is Molybdenum (Mo)",
465 choices=["W", "Mo"],
466 )
467 ap.add_argument(
468 "--pythia8-tune",
469 default="default",
470 choices=["default", "FTFT"],
471 help="Pythia8 tune: default (Monash 2013) or FTFT (arXiv:2608.29076, with its K-factors)",
472 )
473 ap.add_argument(
474 "--cascade-model",
475 default="nucleus",
476 choices=["nucleus", "nucleon"],
477 help="Hadron-nucleus collisions (default) or single hadron-nucleon collisions as in makeCascade.py",
478 )
479 ap.add_argument(
480 "--charm-production",
481 default="forced",
482 choices=["forced", "inclusive"],
483 help="Charm signal events from forced (HardQCD:hardccbar) or inclusive (SoftQCD:inelastic) production; "
484 "inclusive is only for charm (-m 4), beauty is always forced",
485 )
486 ap.add_argument(
487 "--nev", dest="n_sigma_events", type=int, default=2000, help="Events per momentum point for sig/sigtot"
488 )
489 ap.add_argument(
490 "--nrpoints",
491 dest="n_momentum_points",
492 type=int,
493 default=40,
494 help="Number of momentum points taken to calculate sig/sigtot",
495 )
496 args = ap.parse_args()
497 p_threshold = SIGNAL[args.heavy_quark].p_threshold
498 if args.n_pot < 1 or args.n_sigma_events < 1 or args.n_momentum_points < 2 or args.p_beam <= p_threshold:
499 ap.error(f"need --nevgen >= 1, --nev >= 1, --nrpoints >= 2 and a beam energy above {p_threshold} GeV")
500 if args.output == "":
501 args.output = f"Cascade{int(args.n_pot / 1000)}k-pythia8-{args.pythia8_tune}-MSEL{args.heavy_quark}-ntuple.root"
502 return args
503
504

◆ read_pythia8_settings()

makeCascadePythia8.read_pythia8_settings ( path)
Settings of a Pythia8 command file, in order, without comments and blank lines.

Definition at line 137 of file makeCascadePythia8.py.

137def read_pythia8_settings(path):
138 """Settings of a Pythia8 command file, in order, without comments and blank lines."""
139 with open(os.path.expandvars(path)) as f:
140 return [line.split("!", 1)[0].strip() for line in f if line.split("!", 1)[0].strip()]
141
142
143# Forced-production charm K-factors equivalent to the FTFT inclusive normalisation (K = 2.48 for
144# nucleon and 2.02 for meson beams), K_incl * sigma_incl / sigma_forced, from Pythia 8.312 runs with
145# the FTFT tune. The ratio of inclusive to forced charm grows towards threshold, so the K-factor
146# depends on the beam momentum (GeV); values are interpolated in log(p) and kept flat outside the grid.
147# Measured for p p, p n, pi+ p and pi- p from 34 GeV, the charm threshold of the cascade, to 400 GeV
148# (statistical precision 1-2% above 60 GeV, 2-5% below); other beams use isospin
149# (n p = p n, n n = p p, pi+ n = pi- p, pi- n = pi+ p), antinucleons the nucleon and kaons the mean
150# pion values.

◆ signal_kfactor()

makeCascadePythia8.signal_kfactor ( kfactors,
beam_id,
nucleon_id,
p )
K-factor applied to the forced signal cross section of beam_id on nucleon_id at momentum p.

kfactors: (nucleon beams, meson beams), or None for the momentum-dependent charm K-factors.

Definition at line 182 of file makeCascadePythia8.py.

182def signal_kfactor(kfactors, beam_id, nucleon_id, p):
183 """K-factor applied to the forced signal cross section of beam_id on nucleon_id at momentum p.
184
185 kfactors: (nucleon beams, meson beams), or None for the momentum-dependent charm K-factors.
186 """
187 if kfactors is None:
188 return kforced_charm(beam_id, nucleon_id, p)
189 return kfactors[0] if abs(beam_id) in (2212, 2112) else kfactors[1]
190
191
192# Pythia8 instance for particle data: unlike TDatabasePDG it knows the resonances that can lead a
193# subcollision with decays off, such as psi(3770)

Variable Documentation

◆ CASCADE_IDS

list makeCascadePythia8.CASCADE_IDS = [2212, 211, 2112, 321, 130, 310]

Definition at line 43 of file makeCascadePythia8.py.

◆ FTFT_FILE

str makeCascadePythia8.FTFT_FILE = "$FAIRSHIP/gconfig/FTFT.cmnd"

Definition at line 134 of file makeCascadePythia8.py.

◆ KFORCED_CHARM

dict makeCascadePythia8.KFORCED_CHARM
Initial value:
1= {
2 (2212, 2212): [35.52, 25.24, 17.48, 13.99, 10.06, 9.11, 8.10, 7.30],
3 (2212, 2112): [38.08, 24.22, 18.93, 13.90, 10.56, 8.94, 8.25, 7.06],
4 (211, 2212): [12.93, 10.76, 9.92, 8.30, 6.49, 5.87, 5.33, 5.16],
5 (-211, 2212): [10.89, 9.22, 7.66, 7.03, 5.79, 5.30, 5.12, 5.12],
6}

Definition at line 152 of file makeCascadePythia8.py.

◆ KFORCED_CHARM_P

list makeCascadePythia8.KFORCED_CHARM_P = [34.0, 40.0, 47.0, 60.0, 100.0, 160.0, 250.0, 400.0]

Definition at line 151 of file makeCascadePythia8.py.

◆ MAX_INCLUSIVE_TRIES

int makeCascadePythia8.MAX_INCLUSIVE_TRIES = 100_000_000

Definition at line 384 of file makeCascadePythia8.py.

◆ NCOLL_A

list makeCascadePythia8.NCOLL_A = [1, 2, 4, 9, 12, 14, 16, 27, 40, 56, 63, 84, 107, 129, 197, 208]

Definition at line 67 of file makeCascadePythia8.py.

◆ NUCLEUS_MODELS

dict makeCascadePythia8.NUCLEUS_MODELS
Initial value:
1= {
2 # Pythia 8.312 to 8.316
3 8.312: NucleusModel(
4 offset=[0.0, 0.03, 0.08, 0.15, 0.20, 0.20, 0.20, 0.26, 0.30, 0.34, 0.40, 0.40, 0.40, 0.50, 0.50, 0.60],
5 slope=[0.0, 0.0016, 0.0033, 0.0075, 0.0092, 0.0105, 0.012, 0.017, 0.022, 0.027, 0.028, 0.034, 0.040]
6 + [0.044, 0.055, 0.055],
7 slope_lo=[0.0, 0.0031, 0.0073, 0.015, 0.0192, 0.0205, 0.022, 0.03, 0.037, 0.044, 0.048, 0.054, 0.06]
8 + [0.069, 0.08, 0.085],
9 sigma_border=20.0,
10 prob_sd=0.3,
11 sd_min_ecm=10.0,
12 other_process=1,
13 ),
14 # Pythia 8.317 and later. Their nCollAvg interpolates between the tabulated nuclei with an integer
15 # division (A / tabA), which drops most of the interpolation for nuclei such as W and Mo; the intended
16 # interpolation is used here.
17 8.317: NucleusModel(
18 offset=[0.0, 0.0510, 0.1164, 0.2036, 0.2328, 0.2520, 0.2624, 0.3190]
19 + [0.3562, 0.3898, 0.3900, 0.3446, 0.3496, 0.3504, 0.3484, 0.3415],
20 slope=[0.0, 0.00187, 0.00496, 0.0107, 0.0136, 0.0152, 0.0169, 0.0243]
21 + [0.0314, 0.0385, 0.0415, 0.0506, 0.0581, 0.0644, 0.0806, 0.0830],
22 slope_lo=[0.0, 0.00361, 0.00884, 0.0174, 0.0210, 0.0233, 0.0252, 0.0340]
23 + [0.0418, 0.0496, 0.0524, 0.0600, 0.0668, 0.0727, 0.0873, 0.0893],
24 sigma_border=None,
25 prob_sd=0.5,
26 sd_min_ecm=0.0,
27 other_process=0,
28 ),
29}

Definition at line 68 of file makeCascadePythia8.py.

◆ PDG

makeCascadePythia8.PDG = ROOT.TDatabasePDG.Instance()

Definition at line 162 of file makeCascadePythia8.py.

◆ PROTON_FRACTION

dict makeCascadePythia8.PROTON_FRACTION = {"W": 0.40, "Mo": 0.43}

Definition at line 46 of file makeCascadePythia8.py.

◆ PYTHIA_DATA

makeCascadePythia8.PYTHIA_DATA = pythia8.Pythia("", False)

Definition at line 194 of file makeCascadePythia8.py.

◆ SIGNAL

dict makeCascadePythia8.SIGNAL
Initial value:
1= {
2 4: SignalConfig(
3 p_threshold=34.0,
4 ids={411, 421, 431, 4122, 4132, 4232, 4332, 4412, 4414, 4422, 4424, 4432, 4434, 4444},
5 process="HardQCD:hardccbar = on",
6 kfactors=None,
7 ),
8 5: SignalConfig(
9 p_threshold=130.0,
10 ids={511, 521, 531, 541, 5122, 5132, 5142, 5232, 5242, 5332, 5342, 5412, 5414, 5422, 5424, 5432, 5434}
11 | {5442, 5444, 5512, 5514, 5522, 5524, 5532, 5534, 5542, 5544, 5554},
12 process="HardQCD:hardbbbar = on",
13 kfactors=(1.04, 1.19),
14 ),
15}

Definition at line 117 of file makeCascadePythia8.py.

◆ SIGNAL_BIN_RATIO

float makeCascadePythia8.SIGNAL_BIN_RATIO = 1.1

Definition at line 160 of file makeCascadePythia8.py.

◆ TARGET_NUCLEONS

list makeCascadePythia8.TARGET_NUCLEONS = [2212, 2112]

Definition at line 44 of file makeCascadePythia8.py.

◆ TARGET_NUCLEUS

dict makeCascadePythia8.TARGET_NUCLEUS = {"W": (74, 184), "Mo": (42, 98)}

Definition at line 48 of file makeCascadePythia8.py.