Skip to content

Commit d95be4d

Browse files
committed
o2-sim: Possibility to switch between TGeo and Geant4 navigation
1 parent 41d9be4 commit d95be4d

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

Common/SimConfig/include/SimConfig/G4Params.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,22 @@ enum class EG4Physics {
3333
kUSER = 8 /* allows to give own string combination */
3434
};
3535

36+
// enumerating possible geometry navigation modes
37+
// (understanding that geometry description is always done with TGeo)
38+
enum class EG4Nav {
39+
kTGeo = 0, /* navigate with TGeo */
40+
kG4 = 1 /* navigate with G4 native geometry */
41+
};
42+
3643
// parameters to influence the G4 engine
3744
struct G4Params : public o2::conf::ConfigurableParamHelper<G4Params> {
3845
EG4Physics physicsmode = EG4Physics::kFTFP_BERT_EMV_optical; // default physics mode with which to configure G4
3946

4047
std::string configMacroFile = ""; // a user provided g4Config.in file (otherwise standard one fill be taken)
4148
std::string userPhysicsList = ""; // possibility to directly give physics list as string
4249

50+
EG4Nav navmode = EG4Nav::kTGeo; // geometry navigation mode (default TGeo)
51+
4352
std::string const& getPhysicsConfigString() const;
4453

4554
O2ParamDef(G4Params, "G4");

Common/SimConfig/src/SimConfigLinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::conf::DigiParams> + ;
3030

3131
#pragma link C++ enum o2::conf::EG4Physics;
32+
#pragma link C++ enum o2::conf::EG4Nav;
3233
#pragma link C++ enum o2::conf::SimFieldMode;
3334
#pragma link C++ struct o2::conf::G4Params + ;
3435
#pragma link C++ class o2::conf::ConfigurableParamHelper < o2::conf::G4Params> + ;

Detectors/gconfig/g4Config.C

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,16 @@ void Config()
100100
auto& g4Params = ::o2::conf::G4Params::Instance();
101101
auto& physicsSetup = g4Params.getPhysicsConfigString();
102102
std::cout << "PhysicsSetup wanted " << physicsSetup << "\n";
103-
auto runConfiguration = new TG4RunConfiguration("geomRoot", physicsSetup, "stepLimiter+specialCuts",
103+
std::string geomNavStr;
104+
if (g4Params.navmode == o2::conf::EG4Nav::kTGeo) {
105+
geomNavStr = "geomRoot";
106+
} else if (g4Params.navmode == o2::conf::EG4Nav::kG4) {
107+
geomNavStr = "geomVMC+RootToGeant4";
108+
} else {
109+
LOG(fatal) << "Unsupported geometry navigation mode";
110+
}
111+
112+
auto runConfiguration = new TG4RunConfiguration(geomNavStr, physicsSetup, "stepLimiter+specialCuts",
104113
specialStacking, mtMode);
105114
/// avoid the use of G4BACKTRACE (it seems to inferfere with process logic in o2-sim)
106115
setenv("G4BACKTRACE", "none", 1);

Steer/src/O2MCApplication.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <TGeoTessellated.h>
4343
#include <DetectorsBase/O2Tessellated.h>
4444
#include <unordered_set>
45+
#include "SimConfig/G4Params.h"
4546

4647
namespace o2
4748
{
@@ -223,6 +224,11 @@ bool O2MCApplicationBase::MisalignGeometry()
223224

224225
void O2MCApplicationBase::fixTGeoRuntimeShapes()
225226
{
227+
auto& g4Params = o2::conf::G4Params::Instance();
228+
if (g4Params.navmode != o2::conf::EG4Nav::kTGeo) {
229+
return;
230+
}
231+
226232
// Replace TGeo shapes by other ones for performance or other reasons.
227233
// Should only affect runtime of simulation.
228234

0 commit comments

Comments
 (0)