FairShip
Loading...
Searching...
No Matches
test_cavern_layout.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"""Check that the ECN3 cross-section of the geometry configuration is that of ShipCave.
5
6ShipCave builds the cavern from the constants in passive/ShipCavernLayout.h,
7while geometry_config places the UBT and its scoring planes from its own copy
8of the ECN3 floor and side walls. Nothing else ties the two together, so if one
9changed without the other, the UBT would stand off the floor or the scoring
10planes would cut into the walls without any error.
11"""
12
13from pathlib import Path
14
15import geometry_config
16import pytest
17import shipunit as u
18
19ROOT = pytest.importorskip("ROOT")
20
21SOURCE = Path(__file__).resolve().parent.parent
22
23# geometry_config name -> ShipCavernLayout constant
24QUANTITIES = {
25 "ECN3LeftX": "kECN3LeftX",
26 "ECN3RightX": "kECN3RightX",
27 "ECN3FloorY": "kECN3FloorY",
28}
29
30
31@pytest.fixture(scope="module")
32def layout():
33 """The ShipCavernLayout namespace, compiled by Cling from the header ShipCave uses."""
34 for directory in ("passive", "shipdata"):
35 ROOT.gInterpreter.AddIncludePath(str(SOURCE / directory))
36 assert ROOT.gInterpreter.Declare('#include "ShipCavernLayout.h"')
37 return ROOT.ShipCavernLayout
38
39
40@pytest.mark.parametrize("quantity", QUANTITIES)
42 # Both are in the FairShip length unit.
44 assert cave[quantity] == pytest.approx(getattr(layout, QUANTITIES[quantity]), abs=1.0e-6 * u.cm)
create_config(str DecayVolumeMedium="helium", float Yheight=6.0, int strawDesign=10, str shieldName="TRY_2026", int nuTargetPassive=1, bool SND=True, SND_design=None, TARGET_YAML=None)
test_ecn3_cross_section_matches_ship_cave(layout, quantity)