Skip to content

Commit e670fb4

Browse files
sawenzelclaude
andcommitted
Move the Geant4 run configuration from FastSim to gconfig
This moves the O2 Geant4 VMC run configuration out of FastSim, so that other features can extend it. - G4RunConfiguration is now o2::g4config::G4RunConfiguration in Detectors/gconfig, built into G4Setup. - FastSim provides the fast simulation and its regions through createFastSimulation() and createFastSimRegionConstruction(). - The behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 731e8d0 commit e670fb4

6 files changed

Lines changed: 74 additions & 19 deletions

File tree

‎Detectors/FastSim/include/FastSim/G4FastSimulation.h‎

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
/// `G4.fastSimRegions` overrides the walk with an explicit space-separated list
3030
/// of media, for when a model should see less than a whole subtree.
3131

32-
#include "TG4RunConfiguration.h"
3332
#include "TG4VUserFastSimulation.h"
3433
#include "TG4VUserPostDetConstruction.h"
3534

@@ -53,15 +52,11 @@ class G4FastSimulation : public TG4VUserFastSimulation
5352
double mMinEnergy = 1.;
5453
};
5554

56-
/// Supplies Geant4-VMC with the fast simulation models and their regions.
57-
/// Returns nullptr when no model is configured, so nothing is set up.
58-
class G4RunConfiguration : public TG4RunConfiguration
59-
{
60-
public:
61-
using TG4RunConfiguration::TG4RunConfiguration;
62-
TG4VUserFastSimulation* CreateUserFastSimulation() override;
63-
TG4VUserPostDetConstruction* CreateUserPostDetConstruction() override;
64-
};
55+
/// The fast simulation for Geant4-VMC, or nullptr when `G4.fastSimModels` is empty.
56+
TG4VUserFastSimulation* createFastSimulation();
57+
58+
/// The construction of the fast simulation regions, or nullptr when `G4.fastSimModels` is empty.
59+
TG4VUserPostDetConstruction* createFastSimRegionConstruction();
6560

6661
} // namespace o2::fastsim
6762

‎Detectors/FastSim/src/G4FastSimulation.cxx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void G4FastSimulation::Construct()
6767
}
6868

6969
//_____________________________________________________________________________
70-
TG4VUserFastSimulation* G4RunConfiguration::CreateUserFastSimulation()
70+
TG4VUserFastSimulation* createFastSimulation()
7171
{
7272
const auto& params = o2::conf::G4Params::Instance();
7373
auto models = split(params.fastSimModels, ',');
@@ -79,12 +79,12 @@ TG4VUserFastSimulation* G4RunConfiguration::CreateUserFastSimulation()
7979
}
8080

8181
//_____________________________________________________________________________
82-
TG4VUserPostDetConstruction* G4RunConfiguration::CreateUserPostDetConstruction()
82+
TG4VUserPostDetConstruction* createFastSimRegionConstruction()
8383
{
8484
const auto& params = o2::conf::G4Params::Instance();
8585
auto models = split(params.fastSimModels, ',');
8686
if (models.empty()) {
87-
return TG4RunConfiguration::CreateUserPostDetConstruction();
87+
return nullptr;
8888
}
8989
std::vector<FastSimRegionConstruction::ModelRegions> wanted;
9090
wanted.reserve(models.size());

‎Detectors/gconfig/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ o2_add_library(G3Setup
1515
)
1616

1717
o2_add_library(G4Setup
18-
SOURCES src/G4Config.cxx
18+
SOURCES src/G4Config.cxx src/G4RunConfiguration.cxx
1919
PUBLIC_LINK_LIBRARIES MC::Geant4VMC MC::Geant4 FairRoot::Base O2::SimulationDataFormat O2::Generators O2::SimSetup O2::FastSim
2020
)
2121

‎Detectors/gconfig/g4Config.C‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ R__LOAD_LIBRARY(libgeant4vmc)
6565
#include "G4ScoringManager.hh"
6666
#include "G4VScoringMesh.hh"
6767
#include <unistd.h>
68-
#include "FastSim/G4FastSimulation.h"
68+
#include "SimSetup/G4RunConfiguration.h"
6969
#endif
7070
#include "commonConfig.C"
7171

@@ -119,12 +119,12 @@ void Config()
119119
LOG(fatal) << "Unsupported geometry navigation mode";
120120
}
121121

122-
// o2::fastsim::G4RunConfiguration differs from TG4RunConfiguration only in
122+
// o2::g4config::G4RunConfiguration differs from TG4RunConfiguration only in
123123
// providing the fast-simulation hook; with G4.fastSimModels empty it behaves
124124
// identically.
125-
auto runConfiguration = new o2::fastsim::G4RunConfiguration(geomNavStr, physicsSetup,
126-
"stepLimiter+specialCuts",
127-
specialStacking, mtMode);
125+
auto runConfiguration = new o2::g4config::G4RunConfiguration(geomNavStr, physicsSetup,
126+
"stepLimiter+specialCuts",
127+
specialStacking, mtMode);
128128
if (g4Params.g4scoring) {
129129
runConfiguration->SetUseOfG4Scoring();
130130
if (g4Params.g4fluenceweight) {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#ifndef O2_SIMSETUP_G4RUNCONFIGURATION_H_
13+
#define O2_SIMSETUP_G4RUNCONFIGURATION_H_
14+
15+
#include "TG4RunConfiguration.h"
16+
17+
namespace o2::g4config
18+
{
19+
20+
/// The Geant4 VMC run configuration of O2: adds the fast simulation.
21+
class G4RunConfiguration : public TG4RunConfiguration
22+
{
23+
public:
24+
using TG4RunConfiguration::TG4RunConfiguration;
25+
TG4VUserFastSimulation* CreateUserFastSimulation() override;
26+
TG4VUserPostDetConstruction* CreateUserPostDetConstruction() override;
27+
};
28+
29+
} // namespace o2::g4config
30+
31+
#endif // O2_SIMSETUP_G4RUNCONFIGURATION_H_
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright 2019-2026 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
#include "SimSetup/G4RunConfiguration.h"
13+
#include "FastSim/G4FastSimulation.h"
14+
15+
namespace o2::g4config
16+
{
17+
18+
TG4VUserFastSimulation* G4RunConfiguration::CreateUserFastSimulation()
19+
{
20+
return o2::fastsim::createFastSimulation();
21+
}
22+
23+
TG4VUserPostDetConstruction* G4RunConfiguration::CreateUserPostDetConstruction()
24+
{
25+
auto fastSimRegions = o2::fastsim::createFastSimRegionConstruction();
26+
return fastSimRegions ? fastSimRegions : TG4RunConfiguration::CreateUserPostDetConstruction();
27+
}
28+
29+
} // namespace o2::g4config

0 commit comments

Comments
 (0)