FairShip
Loading...
Searching...
No Matches
heavyFlavourScaling.py
Go to the documentation of this file.
1# SPDX-License-Identifier: LGPL-3.0-or-later
2# SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP Collaboration
3
4"""Target-composition scaling of charm/beauty over min-bias cross-section ratios.
5
6Shared by ``macro/makeDecay.py`` and ``macro/run_fixedTarget.py`` so the physics
7constants and the ``chicc``/``chibb`` derivation live in a single place.
8"""
9
10from collections import namedtuple
11
12# Reference values for Molybdenum (historical defaults). Cross-section ratios
13# scale heavy-flavour ~ A and mbias ~ A^(0.71).
14heavyflavour_Ascale = 1
15mbias_Ascale = 0.71
16
17A_REF = 98.0
18CHICC_REF = 1.7e-3 # prob to produce primary ccbar pair/pot on Mo
19CHIBB_REF = 1.6e-7 # prob to produce primary bbbar pair/pot on Mo
20# cross sections per nucleon [mb] the reference probabilities above were derived with, so that a
21# cascade file generated with a different one (energy, tune, target) can rescale them
22SIGMA_CC_REF = 18.1e-3
23SIGMA_BB_REF = SIGMA_CC_REF * CHIBB_REF / CHICC_REF
24TARGET_A = {"W": 184.0, "Mo": 98.0}
25
26CrossSections = namedtuple("CrossSections", ["chicc", "chibb", "A", "scale"])
27# FixedTargetGenerator::InitForCharmOrBeauty treats an input file as beauty if its first hadron is heavier
28BEAUTY_MASS_MIN = 5.0 # GeV
29
30
31def file_is_beauty(first_hadron_mass):
32 """Flavour of a cascade input file as FixedTargetGenerator sees it, from the mass [GeV] of its first hadron."""
33 return first_hadron_mass > BEAUTY_MASS_MIN
34
35
36def check_input_flavour(is_beauty, file_beauty):
37 """Reject a run type (``--charm``/``--beauty``) that disagrees with the flavour of the cascade input file.
38
39 The generator takes the flavour from the file, so a mismatch would scale the wrong cross section.
40 """
41 if is_beauty != file_beauty:
42 requested = "beauty" if is_beauty else "charm"
43 found = "beauty" if file_beauty else "charm"
44 raise ValueError(f"--{requested} was requested, but the cascade input file holds {found}")
45
46
47def derive_cross_sections(target_composition=None, A=None, chicc=None, chibb=None, sigma_QQ=None, is_beauty=False):
48 """Return default-scaled chicc/chibb, honouring explicit overrides.
49
50 ``A`` overrides the ``target_composition`` preset; ``chicc``/``chibb``
51 override the target-derived value when not ``None``. Supply either
52 ``target_composition`` (a known preset) or an explicit ``A``.
53 ``sigma_QQ`` is the cross section per nucleon [mb] of the cascade input
54 file, and rescales the reference probability of the flavour that file
55 holds: beauty for ``is_beauty``, charm otherwise.
56 """
57 if A is None:
58 if target_composition is None:
59 raise ValueError(f"Provide either target_composition (one of {sorted(TARGET_A)}) or an explicit A.")
60 A = TARGET_A[target_composition]
61 if A <= 0:
62 raise ValueError(f"Invalid target mass number A={A}. Must be > 0.")
63 if sigma_QQ is not None and sigma_QQ <= 0:
64 raise ValueError(f"Invalid cross section sigma_QQ={sigma_QQ}. Must be > 0.")
65 scale = (A / A_REF) ** (heavyflavour_Ascale - mbias_Ascale)
66 cc_ref = CHICC_REF if sigma_QQ is None or is_beauty else CHICC_REF * sigma_QQ / SIGMA_CC_REF
67 bb_ref = CHIBB_REF * sigma_QQ / SIGMA_BB_REF if sigma_QQ is not None and is_beauty else CHIBB_REF
68 chicc = chicc if chicc is not None else cc_ref * scale
69 chibb = chibb if chibb is not None else bb_ref * scale
70 return CrossSections(chicc, chibb, A, scale)
71
72
73def check_run_type_override(is_beauty, chicc, chibb):
74 """Reject a cross-section override that does not match the run type.
75
76 A run is either charm or beauty, so at most one of ``chicc``/``chibb`` is
77 meaningful. Passing the wrong one (or both) is a mistake and raises
78 ``ValueError`` with a clear message rather than being silently ignored.
79 """
80 if chicc is not None and chibb is not None:
81 raise ValueError("Set only one of --chicc / --chibb; a run is either charm or beauty.")
82 if is_beauty and chicc is not None:
83 raise ValueError("This is a beauty run: pass --chibb, not --chicc.")
84 if not is_beauty and chibb is not None:
85 raise ValueError("This is a charm run: pass --chicc, not --chibb.")
86
87
88def format_summary(cs, target_composition=None):
89 """One human-readable summary of the derived cross-section ratios."""
90 label = target_composition or "custom (A given)"
91 return (
92 f"Target composition: {label}, A={cs.A}, "
93 f"scale=(A/{A_REF})^({heavyflavour_Ascale}-{mbias_Ascale})={cs.scale:.4f}\n"
94 f"Derived cross-section ratios: chicc={cs.chicc:.3e}, chibb={cs.chibb:.3e}"
95 )
derive_cross_sections(target_composition=None, A=None, chicc=None, chibb=None, sigma_QQ=None, is_beauty=False)
check_input_flavour(is_beauty, file_beauty)
format_summary(cs, target_composition=None)
check_run_type_override(is_beauty, chicc, chibb)
file_is_beauty(first_hadron_mass)