Skip to content

Commit 8e99d05

Browse files
sawenzelclaude
andcommitted
Use the TRD collision model with G4HepEm by default
This makes the TRD ionisation model follow the G4HepEm physics. - The new default TRDSimParams.ionisationModel=-1 selects the collision tables (1) when G4HepEm transports e-, e+ and gamma, and the energy deposit with PAI (0) otherwise. - G4HepEm counts as active when the physics list in use has the suffix _HEP, so a list given by name behaves like G4.useG4HepEm=1. - An explicit 0 or 1 still wins; 0 together with G4HepEm gives a warning, since G4HepEm has no PAI model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 064b5d3 commit 8e99d05

5 files changed

Lines changed: 21 additions & 8 deletions

File tree

‎Common/SimConfig/include/SimConfig/G4Params.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ struct G4Params : public o2::conf::ConfigurableParamHelper<G4Params> {
7878

7979
std::string fluenceWeightFile = ""; // file containing the scoring weights (pdg, ekin, weight)
8080
std::string getPhysicsConfigString() const;
81+
/// whether the physics list in use transports e-, e+ and gamma with G4HepEm (suffix _HEP)
82+
bool isG4HepEmActive() const { return getPhysicsConfigString().find("_HEP") != std::string::npos; }
8183

8284
bool g4scoring = false;
8385
bool g4fluenceweight = false;

‎Detectors/TRD/simulation/README.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ o2-sim -m PIPE MAG TRD -n 1000 -g boxgen --configKeyValues 'BoxGun.pdg=211;BoxGu
2525
--configKeyValues 'TRDSimParams.doTR=false;TRDSimParams.maxMCStepSize=0.1'
2626
```
2727

28-
The charge of a hit in the gas comes from one of two models, selected with `TRDSimParams.ionisationModel`:
28+
The charge of a hit in the gas comes from one of two models, selected with `TRDSimParams.ionisationModel`. The
29+
default `-1` selects `1` when G4HepEm transports e-, e+ and gamma (`G4.useG4HepEm=1`) and `0` otherwise:
2930
- `0`: the Geant4 energy deposit in the gas divided by Wion. Geant4 then uses the PAI model in the TRD gas
3031
(`Detectors/gconfig/g4config_trd_pai.in`, applied by `g4Config.C`).
3132
- `1`: the TRD collision model (`src/IonisationModel.cxx`). Geant4 runs without PAI in the gas. The tables are made

‎Detectors/TRD/simulation/include/TRDSimulation/TRDSimParams.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@ struct TRDSimParams : public o2::conf::ConfigurableParamHelper<TRDSimParams> {
3838
bool doTR = true; ///< switch for transition radiation
3939
SimParam::GasMixture gas = SimParam::GasMixture::Xenon; ///< the gas mixture in the TRD
4040
// ionisation in the gas
41-
int ionisationModel = 0; ///< charge from 0: Geant4 energy deposit with PAI, 1: TRD collision tables, no PAI
41+
int ionisationModel = -1; ///< charge from 0: Geant4 energy deposit with PAI, 1: TRD collision tables, no PAI, -1: 1 with G4HepEm, else 0
4242
float ionisationMinBetaGamma = 0.04; ///< below this beta*gamma the charge comes from the energy deposit
4343
float ionisationMinEkin = 30e3; ///< (eV) below this kinetic energy the charge comes from the energy deposit
4444
// TRF parameters
4545
int trf = 1; // Sampled TRF function. 0: default TRF, 1: TRF described in TRF TDR, 2: No TRF, 3: Landau dist as TRF (parameters specified below)
4646
float trf_landau_mu = 0.; // Mu of the Landau distribution used to describe TRF
4747
float trf_landau_sigma = .03; // Sigma of the Landau distribution used to describe TRF
4848
float t0 = -0.170; // Time delay before start of amplification peak, in us
49+
/// the ionisation model in use, resolving -1 by whether G4HepEm transports e-, e+ and gamma
50+
int activeIonisationModel(bool useG4HepEm) const { return ionisationModel >= 0 ? ionisationModel : (useG4HepEm ? 1 : 0); }
4951
O2ParamDef(TRDSimParams, "TRDSimParams");
5052
};
5153

‎Detectors/TRD/simulation/src/Detector.cxx‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "CommonUtils/ShmAllocator.h"
2121
#include "DetectorsBase/MaterialManager.h"
22+
#include "SimConfig/G4Params.h"
2223
#include "DetectorsBase/Stack.h"
2324
#include "FairVolume.h"
2425
#include "FairRootManager.h"
@@ -124,15 +125,20 @@ void Detector::InitializeParams()
124125
mMaxMCStepDef = TRDSimParams::Instance().maxMCStepSize;
125126

126127
const auto& simParams = TRDSimParams::Instance();
127-
if (simParams.ionisationModel == 1) {
128+
const bool g4HepEm = o2::conf::G4Params::Instance().isG4HepEmActive();
129+
const int ionisationModel = simParams.activeIonisationModel(g4HepEm);
130+
if (g4HepEm && ionisationModel == 0) {
131+
LOG(warning) << "TRD: energy-deposit charge with G4HepEm, which has no PAI model for e-/e+ in the gas";
132+
}
133+
if (ionisationModel == 1) {
128134
mIonisation = std::make_unique<IonisationModel>(simParams.gas);
129135
// the tables start at minBetaGamma; below it the energy deposit is used
130136
mIonMinBetaGamma = std::max<double>(simParams.ionisationMinBetaGamma, IonisationModel::minBetaGamma());
131137
mIonMinEkin = simParams.ionisationMinEkin;
132138
LOG(info) << "TRD: ionisation from collision tables, energy deposit below beta*gamma " << mIonMinBetaGamma
133139
<< " or kinetic energy " << mIonMinEkin << " eV";
134-
} else if (simParams.ionisationModel != 0) {
135-
LOG(fatal) << "TRD: unknown ionisationModel " << simParams.ionisationModel;
140+
} else if (ionisationModel != 0) {
141+
LOG(fatal) << "TRD: unknown ionisationModel " << ionisationModel;
136142
}
137143
}
138144

‎Detectors/gconfig/g4Config.C‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ R__LOAD_LIBRARY(libgeant4vmc)
8787
constexpr const char* kSkipUnknownParticles = "/mcPrimaryGenerator/skipUnknownParticles true";
8888

8989
// whether the TRD charge comes from the Geant4 energy deposit (TRDSimParams.ionisationModel=0), true without TRD
90-
bool trdUsesEnergyDeposit()
90+
bool trdUsesEnergyDeposit(bool useG4HepEm)
9191
{
9292
try {
93-
return o2::conf::ConfigurableParam::getValueAs<int>("TRDSimParams.ionisationModel") == 0;
93+
const int model = o2::conf::ConfigurableParam::getValueAs<int>("TRDSimParams.ionisationModel");
94+
// -1 selects the collision tables (1) with G4HepEm and the energy deposit (0) otherwise
95+
return model == 0 || (model < 0 && !useG4HepEm);
9496
} catch (...) {
9597
return true;
9698
}
@@ -247,7 +249,7 @@ void Config()
247249
geant4->ProcessGeantMacro(configm1.Data());
248250

249251
// PAI in the TRD gas only when the TRD charge comes from the energy deposit
250-
if (trdUsesEnergyDeposit()) {
252+
if (trdUsesEnergyDeposit(g4Params.isG4HepEmActive())) {
251253
geant4->ProcessGeantMacro((configm + "/Detectors/gconfig/g4config_trd_pai.in").Data());
252254
}
253255
}

0 commit comments

Comments
 (0)