From 13c60f0a1f05e9c0435d8146683004f71ca80f18 Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Tue, 24 Nov 2026 22:14:05 +0100 Subject: [PATCH 1/2] Simulation: define 6Li and 7Li for Geant4 Geant4 VMC looks a primary up in Geant4's particle table, which holds d, t, 3He and alpha from the start but a heavier ion only once it is created. A generated 6Li or 7Li was skipped as unknown, and the stack then stopped the worker ("Inconsistency in primary particles"). FairMCApplication::AddIons does not define an ion that TDatabasePDG already knows, and O2's ion table has both. O2MCApplicationBase now defines them through DefineIon (Geant4 only: Geant3's DefineIon would give them new isomer codes). Co-Authored-By: Claude Opus 5.5 --- Steer/include/Steer/O2MCApplicationBase.h | 1 + Steer/src/O2MCApplication.cxx | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Steer/include/Steer/O2MCApplicationBase.h b/Steer/include/Steer/O2MCApplicationBase.h index 42c39c1275777..6a07292be51f8 100644 --- a/Steer/include/Steer/O2MCApplicationBase.h +++ b/Steer/include/Steer/O2MCApplicationBase.h @@ -67,6 +67,7 @@ class O2MCApplicationBase : public FairMCApplication void InitGeometry() override; bool MisalignGeometry() override; void AddParticles() override; + void AddIons() override; // specific implementation of our hard geometry limits double TrackingRmax() const override { return mCutParams.maxRTracking; } diff --git a/Steer/src/O2MCApplication.cxx b/Steer/src/O2MCApplication.cxx index 8db7dd3c54b12..f9227ed960746 100644 --- a/Steer/src/O2MCApplication.cxx +++ b/Steer/src/O2MCApplication.cxx @@ -1814,6 +1814,29 @@ void addSpecialParticles() TVirtualMC::GetMC()->DefineParticle(-4120000, "AntiMonopole_asymm", kPTUndefined, monopoleMass, 0.0, 1e10, "BSM", 0.0, 0, 0, 0, 0, 0, 0, 0, 0, kTRUE); } +void O2MCApplicationBase::AddIons() +{ + // dispatch first to function in FairRoot + FairMCApplication::AddIons(); + + // Geant4 VMC looks a primary up in Geant4's particle table, which holds d, t, 3He and alpha from + // the start but a heavier ion only once it is created (by Z and A); an unknown primary is + // skipped. These are the stable ions beyond alpha that generators make (coalescence, + // injection). Only for Geant4: Geant3's DefineIon gives an ion already in TDatabasePDG a new + // isomer code. + if (std::strcmp(TVirtualMC::GetMC()->GetName(), "TGeant4") != 0) { + return; + } + struct Ion { + const char* name; // TDatabasePDG's: Geant4 VMC finds the ion's charge by the particle's name + int z; + int a; + }; + for (const auto& ion : {Ion{"Li6", 3, 6}, Ion{"Li7", 3, 7}}) { + TVirtualMC::GetMC()->DefineIon(ion.name, ion.z, ion.a, ion.z, 0., 0.); + } +} + void O2MCApplicationBase::AddParticles() { // dispatch first to function in FairRoot From b22cf41ce9a5df10b220d1f41069dad9f816356b Mon Sep 17 00:00:00 2001 From: Felix Schlepper Date: Tue, 24 Nov 2026 23:26:22 +0100 Subject: [PATCH 2/2] Simulation: Geant4 physics for the light hypernuclei; anti-hypernucleus charges Geant4 defines the light hypernuclei itself (hypertriton, hyperH4, hyperalpha, hyperHe5 and their antiparticles), so O2's DefineParticle for them is ignored, and it gives them only the decay unless G4HadronicParameters::SetEnableHyperNuclei is set: no ionisation, no multiple scattering, no hadronic interactions. Their TRK hits had zero energy loss and made no digits. g4Config.C now enables them before the physics is built. O2DatabasePDG gave the four anti-hypernuclei (3LH, 4LH, 4LHe, 5LHe) a positive charge; now negative. Co-Authored-By: Claude Opus 5.5 --- .../include/SimulationDataFormat/O2DatabasePDG.h | 8 ++++---- Detectors/gconfig/g4Config.C | 6 ++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/DataFormats/simulation/include/SimulationDataFormat/O2DatabasePDG.h b/DataFormats/simulation/include/SimulationDataFormat/O2DatabasePDG.h index e369142c3cad4..68d03aa3e260e 100644 --- a/DataFormats/simulation/include/SimulationDataFormat/O2DatabasePDG.h +++ b/DataFormats/simulation/include/SimulationDataFormat/O2DatabasePDG.h @@ -344,7 +344,7 @@ inline void O2DatabasePDG::addALICEParticles(TDatabasePDG* db, double monopoleMa ionCode = -1010010030; if (!db->GetParticle(ionCode)) { db->AddParticle("AntiHyperTriton", "AntiHyperTriton", 2.991134, kFALSE, - 2.5e-15, 3, "Ion", ionCode); + 2.5e-15, -3, "Ion", ionCode); } //hyper hydrogen 4 ground state @@ -357,7 +357,7 @@ inline void O2DatabasePDG::addALICEParticles(TDatabasePDG* db, double monopoleMa ionCode = -1010010040; if (!db->GetParticle(ionCode)) { db->AddParticle("AntiHyperhydrog4", "AntiHyperhydrog4", 3.922434, kFALSE, - 2.5e-15, 3, "Ion", ionCode); + 2.5e-15, -3, "Ion", ionCode); } //hyper helium 4 ground state ionCode = 1010020040; @@ -369,7 +369,7 @@ inline void O2DatabasePDG::addALICEParticles(TDatabasePDG* db, double monopoleMa ionCode = -1010020040; if (!db->GetParticle(ionCode)) { db->AddParticle("AntiHyperhelium4", "AntiHyperhelium4", 3.921728, kFALSE, - 2.5e-15, 6, "Ion", ionCode); + 2.5e-15, -6, "Ion", ionCode); } // Lithium 4 ground state @@ -394,7 +394,7 @@ inline void O2DatabasePDG::addALICEParticles(TDatabasePDG* db, double monopoleMa ionCode = -1010020050; if (!db->GetParticle(ionCode)) { db->AddParticle("AntiHyperhelium5", "AntiHyperhelium5", 4.839961, kFALSE, - 2.5e-15, 6, "Ion", ionCode); + 2.5e-15, -6, "Ion", ionCode); } ionCode = 1020010040; diff --git a/Detectors/gconfig/g4Config.C b/Detectors/gconfig/g4Config.C index 2dc6af4947c13..0b5b0cd110d2b 100644 --- a/Detectors/gconfig/g4Config.C +++ b/Detectors/gconfig/g4Config.C @@ -80,6 +80,7 @@ R__LOAD_LIBRARY(libgeant4vmc) #include "G4UImanager.hh" #include "G4RegionStore.hh" #include "G4ProductionCuts.hh" +#include "G4HadronicParameters.hh" #endif #include "commonConfig.C" @@ -184,6 +185,11 @@ void Config() const char* nthreads = getenv("ALICE_NSIMWORKERS"); setenv("G4FORCENUMBEROFTHREADS", nthreads ? nthreads : "1", 1); } + // Geant4 gives its light hypernuclei and their antiparticles (3LH, 4LH, 4LHe, 5LHe, ...) + // ionisation, multiple scattering and hadronic interactions only when enabled; otherwise they + // cross the detectors without depositing energy. It must be set before the physics is built. + G4HadronicParameters::Instance()->SetEnableHyperNuclei(true); + /// Create the G4 VMC TGeant4* geant4 = new TGeant4("TGeant4", "The Geant4 Monte Carlo", runConfiguration); std::cout << "Geant4 has been created." << std::endl;