FairShip’s tracking system converts digitised straw tube hits into fully fitted tracks with momentum vectors and covariance matrices. The system is split into three loosely coupled stages: pattern recognition (grouping hits into track candidates), track fitting (estimating track parameters and uncertainties via a Kalman filter), and — optionally — an alternative ACTS-based pipeline. A dedicated benchmarking tool measures the performance of each component quantitatively. This page documents each stage in detail, explains the data flow between them, and shows how to run and interpret the benchmark.Documentation 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.
Pattern recognition
python/shipPatRec.py is the central dispatcher for all pattern recognition algorithms. Its public API is a single function:
Input format
smeared_hits is a Python list of dicts, one entry per digitised straw hit:
dist field holds the drift-distance measurement after applying the spatial resolution smearing controlled by --noStrawSmearing in ShipReco.py. The geometry constants used by all algorithms are set from two module-level globals:
Output format
execute() returns a dict of track candidates keyed by integer index:
Algorithm selection
Themethod argument routes to the appropriate algorithm:
- AR (Artificial Retina)
- FH (Fast Hough)
- TemplateMatching
The AR algorithm — activated by
--patRec AR in ShipReco.py — is the
production default. It uses a retina scoring function that accumulates votes for
(slope, intercept) bins from each hit pair. The bin with the highest accumulated
score seeds a track candidate; hits within a tolerance band around the seed
direction are then assigned to it. The process repeats after removing assigned hits
until no high-scoring bins remain.AR is robust in medium-multiplicity events (typical SHiP signal topologies) and
produces low ghost and clone rates.Track fitting
Track candidates from pattern recognition are fitted bypython/shipStrawTracking.py using the GenFit2 DAF (Deterministic Annealing Filter), a robust variant of the Kalman filter that down-weights outlier measurements iteratively.
GenFit2 setup
Before the event loop,ShipReco.py initialises three singleton objects that GenFit requires:
Measurement construction
For each straw hit in a candidate, the fitter constructs agenfit::WireMeasurement from the straw wire endpoints (top and bottom) and the drift distance. Wire measurements encode the left-right ambiguity inherent in drift chambers; DAF resolves this ambiguity by simultaneously fitting both hypotheses and weighting by consistency.
Output
Each fitted track is stored as agenfit::Track* in the FitTracks branch. The following accessors are most commonly used in analysis:
fitTrack2MC vector maps each fitted-track index to the MC particle index:
Vertex finding
python/shipVertex.Task is the vertex-finding module called from ShipDigiReco.reconstruct(). It loops over all pairs of tracks in goodTracks, extrapolates each track to an initial closest-approach estimate, then iterates until the vertex Z position converges to within 0.1 cm.
ShipParticle with its 4-momentum, production vertex, DOCA, and vertex covariance matrix. Vertex finding can be disabled entirely with --noVertexing in ShipReco.py.
ACTS integration (experimental)
python/ACTSReco.py provides an alternative tracking backend using the ACTS framework. It is invoked via the dedicated script macro/run_ACTSTracking.py — it is not a --patRec option in ShipReco.py. The ACTS script has its own argument set:
run_ACTSTracking.py:
| Argument | Default | Description |
|---|---|---|
-f / --inputFile | required | Input simulation ROOT file |
-g / --geoFile | required | Geometry ROOT file |
-n / --nEvents | 1 000 000 | Maximum events to process |
-o / --outputDir | CWD | Output directory |
--detector | SiliconTarget | Detector geometry: SiliconTarget, MTC, SND, StrawTracker |
--realPR | False | Enable pattern recognition |
--vertexing | False | Enable vertex fitting |
--DQM | False | Enable ACTS DQM histograms |
--minHits | 6 | Minimum hits to build a valid track |
--minPt | 0 | Minimum transverse momentum (GeV) |
--detector; three have builders implemented in ACTSReco.py:
--detector value | Builder class | Field |
|---|---|---|
StrawTracker | acts.examples.StrawtubeBuilder | Full FairShip field map |
MTC | acts.examples.MTCBuilder | Constant B = −1.2 T (y) |
SiliconTarget | acts.examples.SiTargetBuilder | Zero field |
SND | (not yet implemented in ACTSReco.py) | — |
ACTS support requires a FairShip build with ACTS enabled. Check that
import acts succeeds in your environment before using run_ACTSTracking.py.
The output file is named {inputfile_basename}_tracked.root and written to
the directory specified by --outputDir.Tracking benchmark
macro/run_tracking_benchmark.py orchestrates a complete performance measurement by running simulation, reconstruction, and metric computation as separate subprocesses (required because FairRoot singletons prevent multiple FairRunSim instances in one process).
Running the benchmark
Benchmark arguments
| Argument | Default | Description |
|---|---|---|
-n / --nEvents | 1000 | Number of simulated events |
--pID | 13 | PDG ID of gun particle (13 = µ⁻) |
--Estart | 1.0 GeV | Low end of energy range |
--Eend | 100.0 GeV | High end of energy range |
--Vz | 8300 cm | Gun z-position (~1 m upstream of T1) |
--Dx | 200 cm | Transverse spread in x |
--Dy | 300 cm | Transverse spread in y |
--nTracks | 1 | Tracks per event |
--tag | benchmark | Output file name prefix |
--output-json | {outputDir}/tracking_metrics.json | JSON metrics output path (defaults to outputDir if not set) |
--seed | 42 | Random seed |
-o / --outputDir | . | Directory for all output files |
--debug | 0 | FairLogger verbosity level: 0=info, 1=debug, 2=debug1, 3=debug2 |
Output files
| File | Contents |
|---|---|
sim_{tag}.root | Particle-gun simulation |
geo_{tag}.root | Geometry file |
sim_{tag}_rec.root | Reconstruction output |
tracking_benchmark_histos.root | Diagnostic histograms |
tracking_metrics.json | Numerical performance metrics |
Metrics computed by tracking_benchmark.py
python/tracking_benchmark.py defines TrackingBenchmark, which compares reconstructed tracks against MC truth using the following parameters:
Track finding efficiency
Fraction of reconstructible MC tracks for which at least one reco track satisfies
the purity cut. Reconstructibility requires ≥
min_hits straw hits and ≥
min_stations stations crossed. Uncertainty is computed via the Wilson score
interval (wilson_interval(k, n)) at 1σ.Clone rate
Fraction of reco tracks matched to an MC track that was already claimed by
another reco track with a higher purity score. A clone indicates that a single
real track was reconstructed twice.
Ghost rate
Fraction of reco tracks that do not satisfy the purity cut with any MC track.
Ghosts arise from combinatorial fake track candidates in the pattern recognition.
Momentum resolution
σ(Δp/p) from a Gaussian fit to the relative momentum residual distribution of
matched tracks. Stored in the JSON metrics file and as a histogram in
tracking_benchmark_histos.root.Wilson score interval
Thewilson_interval(k, n) function in tracking_benchmark.py computes the 68% (1σ) half-width of the Wilson score confidence interval for a binomial proportion: