FairShip welcomes any and all contributions — whether you are fixing a typo, adding a detector module, or refactoring a legacy algorithm. Pull requests are the preferred mechanism because they let the team review, discuss, and iterate before merging, but if you need help navigating Git you are always welcome to reach out directly. The single most important habit to build is writing small, self-contained commits: each commit should introduce one logical change that can be read, understood, and reverted independently. This discipline keeps review tractable for a volunteer collaboration spread across many institutes.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.
Branch Overview
FairShip maintains several long-lived branches with distinct purposes:master
Main development branch. All Python code must be Python 3. This is where new features and fixes targeting the current SHiP detector design land. Requires aliBuild default
release.charmdet
Branch for the charm cross-section measurement. Kept as a reference for potential future studies.
SHiP-2018
Frozen branch for the CDS, kept for backward compatibility. Python 2 only. Requires aliBuild default
fairship-2018. Do not open new feature PRs against this branch.muflux
Branch for the muon flux analysis. Python 2 only. Requires aliBuild default
fairship-2018.Contribution Workflow
Read the SHiP Git Tutorial
Even if you are an experienced Git user, read the SHiP Git Tutorial first. It explains the collaboration’s conventions for forks, branches, commit messages, and pull request etiquette.
Fork and clone
Fork the repository on GitHub, then clone your fork locally:Because FairShip uses git-lfs for large binary files (field maps, etc.), initialise LFS if you have not done so before:
Create a feature branch
Branch off
master (or the appropriate long-lived branch) with a descriptive name:Install pre-commit hooks
Pre-commit hooks enforce style and catch common mistakes automatically on every The hooks run clang-format, ruff, cpplint, codespell, REUSE validation, and more. See the Pre-commit Hooks section below for the full list.
git commit. Install them once after cloning:Write small, reviewable commits
Commit one logical change at a time. A good commit message has a short imperative subject line and, where helpful, a body explaining why the change is made:
Run static analysis before pushing
Use the pixi tasks to catch C++ and Python issues before CI sees them:
Code Style
C++ Guidelines
C++ Guidelines
FairShip targets modern, readable C++ and enforces style automatically through three tools, all of which run as pre-commit hooks and in CI.clang-format reformats code to the Google C++ style. The configuration lives in You can apply it manually:cpplint checks for Google C++ style guide violations. FairShip customises a subset of rules in clang-tidy performs deeper static analysis. Run it via pixi, passing files through the The full set of C++ conventions — including naming, header organisation, and ROOT/FairRoot idioms — is documented in the C++ guidelines wiki page.
.clang-format at the repository root:CPPLINT.cfg — whitespace, legal headers, several readability and runtime checks, and auto-generated dictionary files are excluded:CPP_FILES environment variable:Python Guidelines
Python Guidelines
All Python code in FairShip targets Python 3.12. Two tools enforce style and correctness.ruff is the linter and formatter, configured in The enabled rule sets cover bugbear (pyrefly is the type checker, also configured in The full Python style and documentation conventions are covered in the Python guidelines wiki page.
pyproject.toml:B), comprehensions (C4), pycodestyle errors and warnings (E, W), pyflakes (F), import sorting (I), Ruff-specific rules (RUF), simplification (SIM), and pyupgrade modernisation (UP). A number of rules are intentionally disabled for physics code (Greek Unicode, %-formatting, manual loop counters, etc.) — see pyproject.toml for the full ignore list.Run ruff directly:pyproject.toml. It targets Python 3.12 and searches python/ and stubs/ for type information:Pre-commit Hooks
FairShip uses pre-commit to enforce style and correctness automatically. After runningpre-commit install, each git commit runs the following hooks:
| Hook | Purpose |
|---|---|
trailing-whitespace | Removes trailing whitespace (excluding .dat files) |
end-of-file-fixer | Ensures files end with a newline |
check-yaml, check-toml | Validates YAML and TOML syntax |
check-added-large-files | Warns when large files are committed without LFS |
check-ast | Validates Python AST |
check-merge-conflict | Detects unresolved merge conflict markers |
check-vcs-permalinks | Ensures VCS links point to specific commits, not mutable refs |
check-executables-have-shebangs | Ensures executable files have shebang lines |
mixed-line-ending | Normalises line endings |
ruff-check + ruff-format | Python linting and formatting |
clang-format | C++ formatting (excludes LinkDef.h) |
cpplint | C++ style checking (excludes LinkDef.h) |
codespell | Spell-checking across all text files |
pyupgrade | Upgrades Python syntax to 3.12+ idioms |
mypy | Type-checking for a curated set of Python modules |
validate-cff | Validates the CITATION.cff file |
reuse | Checks REUSE licensing compliance |
gersemi | Formats CMake files |
yamlfmt | Formats YAML files |
Versioning and Changelog
FairShip uses Calendar Versioning inyear.month format, with the option of a patch component (year.month.patch) for hotfixes. The CHANGELOG.md at the repository root records all notable changes following the Keep a Changelog format.
When contributing a user-visible change, add an entry to the ## Unreleased section of CHANGELOG.md under the appropriate heading (Added, Changed, Fixed, or Removed).
License and REUSE Compliance
FairShip is distributed under LGPL-3.0-or-later. Copyright is held by CERN for the benefit of the SHiP Collaboration. Some components carry different licences — check individual file headers and theLICENSES/ directory.
The project follows the REUSE specification, which means every source file must carry an SPDX licence expression and copyright notice (either inline or via a corresponding .license sidecar file). The reuse pre-commit hook enforces this. If you add new files, include the appropriate header: