4"""Target-composition scaling of charm/beauty over min-bias cross-section ratios.
6Shared by ``macro/makeDecay.py`` and ``macro/run_fixedTarget.py`` so the physics
7constants and the ``chicc``/``chibb`` derivation live in a single place.
10from collections
import namedtuple
14heavyflavour_Ascale = 1
23SIGMA_BB_REF = SIGMA_CC_REF * CHIBB_REF / CHICC_REF
24TARGET_A = {
"W": 184.0,
"Mo": 98.0}
26CrossSections = namedtuple(
"CrossSections", [
"chicc",
"chibb",
"A",
"scale"])
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
37 """Reject a run type (``--charm``/``--beauty``) that disagrees with the flavour of the cascade input file.
39 The generator takes the flavour from the file, so a mismatch would scale the wrong cross section.
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}")
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.
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.
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]
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
74 """Reject a cross-section override that does not match the run type.
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.
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.")
89 """One human-readable summary of the derived cross-section ratios."""
90 label = target_composition
or "custom (A given)"
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}"
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)