Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# pixi run install-hooks # one-off: install the git hooks
# pixi run lint # run all hooks on all files
exclude: ^tests/fairship_tests/references/
repos:
# prek runs these as native Rust builtins (no environment, fully portable).
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [Using pixi](#using-pixi)
- [Run instructions](#run-instructions)
- [Docker instructions](#docker-instructions)
- [Testing](#testing)
- [Troubleshooting information](#troubleshooting-information)
- [Documentation](#documentation)
- [License](#license)
Expand Down Expand Up @@ -174,6 +175,20 @@ desirable.
```
The option `-e DISPLAY=unix$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix` forwards graphics from the docker to your local system (similar to `ssh -X`). The option `-v /local_workdir:/image_workdir` mounts `/local_workdir` on the local system as `/image_workdir` within docker.

## Testing

Build and run the complete CTest suite, including the C++ and terminal-output
regression tests, with:

```bash
pixi run test
```

Some regression tests download remote input data and therefore require network
access. See [`tests/README.md`](tests/README.md) for commands that select
individual tests or only the regression suite, and for instructions on adding
tests and regenerating reference output.

## Troubleshooting information

Please see the wiki for [FAQ](https://github.com/ShipSoft/FairShip/wiki/FAQ-and-common-issues#faq)s and [common issues](https://github.com/ShipSoft/FairShip/wiki/FAQ-and-common-issues#common-issues).
Expand Down
8 changes: 8 additions & 0 deletions gconfig/DecayConfigTEvtGen.C
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ void DecayConfig() {
// Create the custom EvtGen decayer
TEvtGenDecayer* decayer = new TEvtGenDecayer();

// run_simScript exports the resolved command-line seed before VMC loads this
// macro. Pass it explicitly so initialization cannot advance the ROOT RNG
// and silently change the EvtGen/Pythia8-decayer seed.
TString RandomSeed = gSystem->Getenv("FAIRSHIP_RANDOM_SEED");
if (!RandomSeed.IsNull()) {
decayer->SetSeed(static_cast<UInt_t>(RandomSeed.Atoll()));
}

// Configure EvtGen files using EVTGENDATA
TString DecayFile = TString(gSystem->Getenv("EVTGENDATA")) + "/DECAY.DEC";
TString ParticleFile = TString(gSystem->Getenv("EVTGENDATA")) + "/evt.pdl";
Expand Down
4 changes: 4 additions & 0 deletions macro/run_simScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ def _fraction_0_1(value: str) -> float:
if seed > 900000000:
seed = seed % 900000000
ROOT.gRandom.SetSeed(seed)
os.environ["FAIRSHIP_RANDOM_SEED"] = str(seed)
shipRoot_conf.configure(0) # load basic libraries, prepare atexit for python
if options.reproducible and options.debug == 0:
ROOT.gErrorIgnoreLevel = ROOT.kWarning
Expand Down Expand Up @@ -616,6 +617,7 @@ def _fraction_0_1(value: str) -> float:
sys.exit()
if HNL or options.RPVSUSY or options.DarkPhoton:
assert P8gen is not None # guaranteed by the three branches above
P8gen.SetSeed(seed)
P8gen.SetSmearBeam(options.SmearBeam * u.cm) # Gaussian beam smearing
P8gen.SetPaintRadius(options.PaintBeam * u.cm) # beam painting radius
P8gen.SetLmin(ship_geo.decayVolume.z0 - ship_geo.target.z0)
Expand All @@ -640,6 +642,7 @@ def _fraction_0_1(value: str) -> float:
) # Uniform distribution in x/y on the target (0.5 cm of margin at both sides)
primGen.SmearVertexXY(True)
P8gen = ROOT.Pythia8Generator()
P8gen.SetSeed(seed)
P8gen.UseExternalFile(inputFile, options.firstEvent)
# Use geometry constants instead of fragile TGeo navigation
P8gen.SetTargetCoordinates(ship_geo.target.z0, ship_geo.target.z0 + ship_geo.target.length)
Expand All @@ -651,6 +654,7 @@ def _fraction_0_1(value: str) -> float:
if options.fixedTarget:
HNL = False
P8gen = ROOT.FixedTargetGenerator()
P8gen.SetSeed(seed)
P8gen.SetZoffset(options.z_offset * u.mm)
# Use geometry constants instead of fragile TGeo navigation
P8gen.SetTargetCoordinates(ship_geo.target.z0, ship_geo.target.z0 + ship_geo.target.length)
Expand Down
98 changes: 6 additions & 92 deletions pixi.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ numpy = "*"
scipy = "*"
matplotlib = "*"
pandas = "*"
pytest = "*"
pytest-xdist = "*"
pyyaml = "*"
tabulate = "*"

Expand Down Expand Up @@ -71,7 +69,9 @@ configure = { cmd = """cmake -S . -B build -G Ninja \
"-DCMAKE_CXX_FLAGS=-isystem $CONDA_PREFIX/include/geant4vmc -isystem $CONDA_PREFIX/include/Geant4" """ }
build = { cmd = "cmake --build build -j$(nproc)", depends-on = ["configure"] }
install = { cmd = "cmake --install build", depends-on = ["build"] }
test = { cmd = "ctest --test-dir build --output-on-failure", depends-on = ["build"] }
test = { cmd = "ctest --test-dir build --output-on-failure -LE regression", depends-on = ["build"] }
test-fairship = { cmd = "ctest --test-dir build --output-on-failure --parallel 4 -L regression", depends-on = ["build"] }
regenerate-fairship-references = { cmd = "tests/fairship_tests/regenerate_references.sh", depends-on = ["build"] }

# --- CI sim-chain tasks ---
# Mirror the per-step commands in .github/workflows/build-run.yml so the
Expand Down
5 changes: 3 additions & 2 deletions shipgen/DPPythia8Generator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ void DPPythia8Generator::Print() { fPythia->settings.listAll(); };

// ----- Init ----------------------------------------------------------
Bool_t DPPythia8Generator::Init() {
if (fUseRandom1) fRandomEngine = std::make_shared<PyTr1Rng>();
if (fUseRandom3) fRandomEngine = std::make_shared<PyTr3Rng>();
const UInt_t seed = fSeed != 0 ? fSeed : gRandom->GetSeed();
if (fUseRandom1) fRandomEngine = std::make_shared<PyTr1Rng>(seed);
if (fUseRandom3) fRandomEngine = std::make_shared<PyTr3Rng>(seed);
fPythia->setRndmEnginePtr(fRandomEngine);
// fPythiaHadDecay->setRndmEnginePtr(fRandomEngine);
fn = 0;
Expand Down
2 changes: 2 additions & 0 deletions shipgen/DPPythia8Generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class DPPythia8Generator : public SHiP::Generator {
void SetMom(Double_t mom) { fMom = mom; };
Double_t GetMom() { return fMom; };
void SetId(Double_t id) { fId = id; };
void SetSeed(UInt_t seed) { fSeed = seed; };
void SetDPId(Int_t id) { fDP = id; };
Int_t GetDPId() { return fDP; };
void SetLmin(Double_t z) { fLmin = z; };
Expand Down Expand Up @@ -98,6 +99,7 @@ class DPPythia8Generator : public SHiP::Generator {
Int_t fId; // target type
Bool_t fUseRandom1{kFALSE}; // flag to use TRandom1
Bool_t fUseRandom3{kTRUE}; // flag to use TRandom3 (default)
UInt_t fSeed{0}; // explicit RNG seed; 0 uses gRandom's seed
Bool_t
fpbrem; // flag to do proton bremstrahlung production (default is false)
TH2F* fpbremPDF; // pointer to TH2 containing PDF(p,theta) to have a dark
Expand Down
6 changes: 4 additions & 2 deletions shipgen/FixedTargetGenerator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ Bool_t FixedTargetGenerator::Init() {
LOG(error) << "Option not known " << Option.Data() << ", abort";
return kFALSE;
}
if (fUseRandom1) fRandomEngine = std::make_shared<PyTr1Rng>();
if (fUseRandom3) fRandomEngine = std::make_shared<PyTr3Rng>();
const UInt_t seed =
fSeed != 0 ? static_cast<UInt_t>(fSeed) : gRandom->GetSeed();
if (fUseRandom1) fRandomEngine = std::make_shared<PyTr1Rng>(seed);
if (fUseRandom3) fRandomEngine = std::make_shared<PyTr3Rng>(seed);
std::vector<int> r = {221, 221, 223, 223, 113, 331, 333};
std::vector<int> c = {6, 7, 5, 7, 5, 6, 9}; // decay channel mumu mumuX

Expand Down
5 changes: 3 additions & 2 deletions shipgen/HNLPythia8Generator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ Bool_t HNLPythia8Generator::Init() {
if (debug) {
List(9900015);
}
if (fUseRandom1) fRandomEngine = std::make_shared<PyTr1Rng>();
if (fUseRandom3) fRandomEngine = std::make_shared<PyTr3Rng>();
const UInt_t seed = fSeed != 0 ? fSeed : gRandom->GetSeed();
if (fUseRandom1) fRandomEngine = std::make_shared<PyTr1Rng>(seed);
if (fUseRandom3) fRandomEngine = std::make_shared<PyTr3Rng>(seed);
fPythia->setRndmEnginePtr(fRandomEngine);
fn = 0;
if (fextFile) {
Expand Down
Loading
Loading