Skip to content

Commit f31d614

Browse files
sawenzelclaude
andcommitted
Add a G4 parameter to transport e-, e+ and gamma with G4HepEm
This adds the switch G4.useG4HepEm, off by default. - It appends _HEP to the hadronic physics list, eg. FTFP_BERT_EMV_HEP+optical, which selects G4HepEm in geant4_vmc. - It needs a geant4_vmc built with G4HepEm. https://its.cern.ch/jira/browse/O2-5901 https://its.cern.ch/jira/browse/O2-7316 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent cc26941 commit f31d614

5 files changed

Lines changed: 12 additions & 8 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct G4Params : public o2::conf::ConfigurableParamHelper<G4Params> {
5454

5555
std::string configMacroFile = ""; // a user provided g4Config.in file (otherwise standard one fill be taken)
5656
std::string userPhysicsList = ""; // possibility to directly give physics list as string
57+
bool useG4HepEm = false; // transport e-, e+ and gamma with G4HepEm (needs geant4_vmc built with G4HepEm)
5758

5859
EG4Nav navmode = EG4Nav::kTGeo; // geometry navigation mode (default TGeo)
5960

@@ -76,7 +77,7 @@ struct G4Params : public o2::conf::ConfigurableParamHelper<G4Params> {
7677
// their placements
7778

7879
std::string fluenceWeightFile = ""; // file containing the scoring weights (pdg, ekin, weight)
79-
std::string const& getPhysicsConfigString() const;
80+
std::string getPhysicsConfigString() const;
8081

8182
bool g4scoring = false;
8283
bool g4fluenceweight = false;

‎Common/SimConfig/src/G4Params.cxx‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ static const std::string confstrings[8] = {"FTFP_BERT+optical",
2929
"FTFP_BERT_HP_EMV+optical"};
3030
}
3131

32-
std::string const& G4Params::getPhysicsConfigString() const
32+
std::string G4Params::getPhysicsConfigString() const
3333
{
34-
if (physicsmode == o2::conf::EG4Physics::kUSER) {
35-
return userPhysicsList;
34+
std::string conf = physicsmode == o2::conf::EG4Physics::kUSER ? userPhysicsList : confstrings[(int)physicsmode];
35+
if (useG4HepEm && conf.find("_HEP") == std::string::npos) {
36+
// geant4_vmc selects G4HepEm with the suffix _HEP on the hadronic list, eg. FTFP_BERT_EMV_HEP+optical
37+
const auto pos = conf.find('+');
38+
conf.insert(pos == std::string::npos ? conf.size() : pos, "_HEP");
3639
}
37-
return confstrings[(int)physicsmode];
40+
return conf;
3841
}
3942

4043
} // namespace conf

‎Detectors/gconfig/g4Config.C‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void Config()
140140
// any other choice is dangerously inconsistent with the FinishPrimary() interface of VMCApp
141141

142142
auto& g4Params = ::o2::conf::G4Params::Instance();
143-
auto& physicsSetup = g4Params.getPhysicsConfigString();
143+
auto physicsSetup = g4Params.getPhysicsConfigString();
144144
std::cout << "PhysicsSetup wanted " << physicsSetup << "\n";
145145
std::string geomNavStr;
146146
if (g4Params.navmode == o2::conf::EG4Nav::kTGeo) {

‎run/g4DetermineUnknownPdgProperties.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ int main(int argc, char** argv)
5050
// need a dummy VMC App
5151
new o2::mc::O2TrivialMCApplication();
5252
// setup G4 as we usually do
53-
auto& physicsSetup = ::o2::conf::G4Params::Instance().getPhysicsConfigString();
53+
auto physicsSetup = ::o2::conf::G4Params::Instance().getPhysicsConfigString();
5454
auto runConfiguration = new TG4RunConfiguration("geomRoot", physicsSetup);
5555
auto vmc = new TGeant4("TGeant4", "The Geant4 Monte Carlo", runConfiguration);
5656
// needs to be initialised to have particle and ion tables / physics entirely ready

‎run/o2sim_g4_particle_table.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ int main(int argc, char** argv)
4242

4343
// We use our O2 VMC setup to make sure we are in line with our physics definition.
4444
new o2::mc::O2TrivialMCApplication();
45-
auto& physicsSetup = ::o2::conf::G4Params::Instance().getPhysicsConfigString();
45+
auto physicsSetup = ::o2::conf::G4Params::Instance().getPhysicsConfigString();
4646
auto runConfiguration = new TG4RunConfiguration("geomRoot", physicsSetup);
4747
auto vmc = new TGeant4("TGeant4", "The Geant4 Monte Carlo", runConfiguration);
4848
// needs to be initialised to have the particle table / physics entirely ready

0 commit comments

Comments
 (0)