FairShip
Loading...
Searching...
No Matches
test_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
4import pytest
5from heavyFlavourScaling import (
6 CHIBB_REF,
7 CHICC_REF,
8 SIGMA_BB_REF,
9 SIGMA_CC_REF,
10 check_input_flavour,
11 check_run_type_override,
12 derive_cross_sections,
13 file_is_beauty,
14)
15
16
18 cs = derive_cross_sections("Mo")
19 assert cs.A == 98.0
20 assert cs.scale == pytest.approx(1.0)
21 assert cs.chicc == pytest.approx(CHICC_REF)
22 assert cs.chibb == pytest.approx(CHIBB_REF)
23
24
26 cs = derive_cross_sections("W")
27 assert cs.A == 184.0
28 assert cs.scale == pytest.approx((184.0 / 98.0) ** 0.29)
29 assert cs.chicc == pytest.approx(CHICC_REF * cs.scale)
30 assert cs.chibb == pytest.approx(CHIBB_REF * cs.scale)
31
32
34 cs = derive_cross_sections(A=181.0)
35 assert cs.A == 181.0
36 assert cs.scale == pytest.approx((181.0 / 98.0) ** 0.29)
37 assert cs.chicc == pytest.approx(CHICC_REF * cs.scale)
38 assert cs.chibb == pytest.approx(CHIBB_REF * cs.scale)
39
40
42 """Passing both is deliberate: an explicit A wins over the "W" preset."""
43 cs = derive_cross_sections("W", A=98.0)
44 assert cs.A == 98.0
45 assert cs.scale == pytest.approx(1.0)
46
47
49 cs = derive_cross_sections(A=98.0, chicc=5e-3, chibb=2e-7)
50 assert cs.chicc == 5e-3
51 assert cs.chibb == 2e-7
52
53
55 with pytest.raises(ValueError):
56 derive_cross_sections()
57
58
60 with pytest.raises(ValueError):
61 derive_cross_sections(A=0)
62 with pytest.raises(ValueError):
63 derive_cross_sections(A=-1.0)
64
65
67 # charm run with chicc, beauty run with chibb, and no override at all.
68 check_run_type_override(is_beauty=False, chicc=1e-3, chibb=None)
69 check_run_type_override(is_beauty=True, chicc=None, chibb=1e-7)
70 check_run_type_override(is_beauty=False, chicc=None, chibb=None)
71
72
74 with pytest.raises(ValueError, match="beauty run"):
75 check_run_type_override(is_beauty=True, chicc=1e-3, chibb=None)
76 with pytest.raises(ValueError, match="charm run"):
77 check_run_type_override(is_beauty=False, chicc=None, chibb=1e-7)
78
79
81 with pytest.raises(ValueError, match="only one"):
82 check_run_type_override(is_beauty=False, chicc=1e-3, chibb=1e-7)
83
84
86 cs = derive_cross_sections("Mo", sigma_QQ=2 * SIGMA_CC_REF)
87 assert cs.chicc == pytest.approx(2 * CHICC_REF)
88 assert cs.chibb == pytest.approx(CHIBB_REF)
89
90
92 cs = derive_cross_sections("Mo", sigma_QQ=2 * SIGMA_BB_REF, is_beauty=True)
93 assert cs.chibb == pytest.approx(2 * CHIBB_REF)
94 assert cs.chicc == pytest.approx(CHICC_REF)
95
96
98 assert derive_cross_sections("W", sigma_QQ=SIGMA_CC_REF).chicc == pytest.approx(derive_cross_sections("W").chicc)
99
100
102 assert derive_cross_sections("Mo", chicc=1e-3, sigma_QQ=2 * SIGMA_CC_REF).chicc == pytest.approx(1e-3)
103
104
106 with pytest.raises(ValueError, match="sigma_QQ"):
107 derive_cross_sections("W", sigma_QQ=0.0)
108
109
111 assert file_is_beauty(5.28) # B0
112 assert not file_is_beauty(1.865) # D0
113
114
116 check_input_flavour(False, file_is_beauty(1.865))
117 check_input_flavour(True, file_is_beauty(5.28))
118
119
121 with pytest.raises(ValueError, match="--charm was requested, but the cascade input file holds beauty"):
122 check_input_flavour(False, file_is_beauty(5.28))
123
124
126 with pytest.raises(ValueError, match="--beauty was requested, but the cascade input file holds charm"):
127 check_input_flavour(True, file_is_beauty(1.865))