FairShip builds the full SHiP detector geometry at the start of every simulation run. The geometry is constructed in Python viaDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ShipSoft/FairShip/llms.txt
Use this file to discover all available pages before exploring further.
python/geometry_config.py, instantiated as ROOT detector modules in python/shipDet_conf.py, and then exported to a geo_{tag}.root file that every downstream step — reconstruction, analysis, alignment — reads back. Understanding how the geometry is configured and stored is essential for making consistent changes across the simulation chain.
The ShipGeo configuration object
All geometric parameters — target position, muon shield dimensions, decay volume boundaries, spectrometer field maps — are collected in a single Config object (an attribute-accessible Python dictionary defined in python/ShipGeoConfig.py). This object is created by geometry_config.create_config() at the start of run_simScript.py:
geo_{tag}.root under the key ShipGeo by python/saveBasicParameters.py.
Output geometry files
Every simulation run produces two geometry-related files:| File | Key(s) | Contents |
|---|---|---|
geo_{tag}.root | FAIRGeom | Full TGeoManager — all volumes, materials, and field regions as ROOT TGeo objects |
geo_{tag}.root | ShipGeo | Serialised Config object (JSON) — all numeric parameters used to build the geometry |
params_{tag}.root | (FairRoot parameters) | FairRoot runtime-database entries; required by ShipReco.py |
Loading geometry in analysis
To access either the TGeo navigation tree or the parameter config in an analysis script:load_from_root_file accepts either a ROOT.TFile object or a string path, and transparently handles both the current JSON format and older pickled-object files.
Muon shield database
The muon shield geometry is defined by parametric magnet dimensions stored in theshield_db dictionary in python/geometry_config.py. Each entry describes the six magnet sections of the active muon shield:
--shieldName in run_simScript.py. Currently TRY_2025 is the only supported entry.
The muon shield total length is computed automatically from the
params array: sum(gap + 2 × half_length) for each magnet section. Adding a new shield design requires adding an entry to shield_db and extending the choices list in the argument parser.Passive detector volumes
The followingFairModule subclasses form the passive structural skeleton of the SHiP detector. They are registered with FairRunSim in python/shipDet_conf.py:
ShipCave
The experimental cavern. Positioned at the start of the muon shield. Geometry loaded from
geometry/caveWithAir.geo. Sets the overall world volume for Geant4.ShipMuonShield
The active muon shield. Receives
shield_params from shield_db[shieldName]. The SetSNDSpace method carves a hole in the shield for the SND detector.ShipTargetStation
The fixed target. Layer positions and materials read from
geometry/target_config.yaml. Supports sliced tungsten targets and helium gaps between slices.ShipMagnet
The spectrometer magnet(s). Multiple magnet instances can be placed at different z positions depending on the geometry design (
magnetDesign parameter).shipDet_conf.configure().
YAML-based subsystem configuration
Several subsystems are configured through YAML files in thegeometry/ directory, which are resolved at runtime via the $FAIRSHIP environment variable:
| File | Subsystem |
|---|---|
geometry/target_config.yaml | Fixed target slices, materials, gaps |
geometry/veto_config_helium.yaml | Decay vessel geometry for helium fill |
geometry/veto_config_vacuums.yaml | Decay vessel geometry for vacuum fill |
geometry/strawtubes_config.yaml | Straw tube tracker station parameters |
geometry/MTC_config.yaml | SND design 2 — Muon Tracker Chamber |
geometry/SiliconTarget_config.yaml | SND design 2 — Silicon Target |
geometry/snd_config_old.yaml | SND design 1 — legacy emulsion target |
geometry/media.geo | Material definitions for all volumes |
--vacuums / --helium flag:
Key geometry parameters
- Target options
- Straw tube options
- Decay volume
The The total target length and individual slice boundaries are computed by
targetOpt comment in geometry_config.py documents the target geometry modes. In practice the target is now driven entirely by target_config.yaml, which specifies Nplates, plate thicknesses (L), inter-plate gaps (G), and materials (M) as lists:create_config() and stored in ship_geo.target.slices_length, ship_geo.target.slices_gap, and ship_geo.target.slices_material.Environment variables
FAIRSHIP
Repository root directory. Used throughout FairShip to resolve paths to YAML configs, input files, and field maps (e.g.
$FAIRSHIP/geometry/target_config.yaml). Set automatically by activate.sh in a pixi environment.GEOMPATH
Geometry data directory for additional geometry assets. Some legacy code paths use this variable to locate field map and media files outside the main repository.
Geometry inspection tools
Print volume hierarchy
--level 1 shows only top-level modules; higher values expand into sub-volumes.Check for overlaps
Enable overlap check during simulation
--check-overlaps flag calls TGeoManager.CheckOverlaps(0.1) (0.1 mm tolerance) after the run, then performs a finer per-node check at 0.1 μm. Using --dry-run exits after geometry initialisation so no events need to be generated.Geant4 physics and navigation configuration
The Geant4 VMC is configured ingconfig/g4Config.C. Key choices:
geomRoot option means the TGeo geometry defined in Python is used directly for navigation — there is no separate Geant4-native geometry construction. Magnetic fields are set via VMC with the /mcDet/setIsLocalMagField true directive; the spectrometer field map is registered through python/geomGeant4.py’s addVMCFields() function.