Skip to content

Commit 0534015

Browse files
committed
fix reload geometry argument
1 parent 8f22563 commit 0534015

6 files changed

Lines changed: 19 additions & 9 deletions

File tree

gdetector/examples/gdetector_example.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ int main(int argc, char* argv[]) {
150150
runManager->SetUserInitialization(physicsList);
151151

152152
auto gdetector = std::make_shared<GDetectorConstruction>(gopts);
153-
gdetector->reload_geometry();
153+
auto gsystems = gsystem::getSystems(gopts);
154+
gdetector->reload_geometry(gsystems);
154155

155156
auto runDat = run_simulation_in_threads(nevents, nthreads, gopts, log, gdetector);
156157

gdetector/gdetectorConstruction.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ G4ThreadLocal GMagneto* GDetectorConstruction::gmagneto = nullptr;
2222
GDetectorConstruction::GDetectorConstruction(std::shared_ptr<GOptions> gopts)
2323
: GBase(gopts, GDETECTOR_LOGGER),
2424
G4VUserDetectorConstruction(), // Geant4 base class.
25-
gopt(gopts) {
26-
digitization_routines_map = std::make_shared<gdynamicdigitization::dRoutinesMap>();
27-
}
25+
gopt(gopts) { digitization_routines_map = std::make_shared<gdynamicdigitization::dRoutinesMap>(); }
2826

2927
G4VPhysicalVolume* GDetectorConstruction::Construct() {
3028
log->debug(NORMAL, FUNCTION_NAME);
@@ -42,8 +40,14 @@ G4VPhysicalVolume* GDetectorConstruction::Construct() {
4240

4341
// - if no systems are provided, we just launched gemc: create from options
4442
// - otherwise, it's a geometry re-load. use existing systems.
45-
if (gsystems.empty()) { gworld = std::make_shared<GWorld>(gopt); }
46-
else { gworld = std::make_shared<GWorld>(gopt, gsystems); }
43+
if (gsystems.empty()) {
44+
log->debug(NORMAL, FUNCTION_NAME, "creating world from options");
45+
gworld = std::make_shared<GWorld>(gopt);
46+
}
47+
else {
48+
log->debug(NORMAL, FUNCTION_NAME, "creating world from a gsystem vector of size ", gsystems.size());
49+
gworld = std::make_shared<GWorld>(gopt, gsystems);
50+
}
4751

4852
// Build Geant4 world (solids, logical and physical volumes) based on the GEMC world.
4953
g4world = std::make_shared<G4World>(gworld.get(), gopt);
@@ -148,6 +152,7 @@ void GDetectorConstruction::loadDigitizationPlugins() {
148152

149153

150154
void GDetectorConstruction::reload_geometry(SystemList sl) {
155+
151156
// it could be empty for tests
152157
if (!sl.empty()) {
153158
// Use vector assignment to update the local systems.
@@ -163,6 +168,5 @@ void GDetectorConstruction::reload_geometry(SystemList sl) {
163168
rm->DefineWorldVolume(Construct());
164169
ConstructSDandField();
165170
}
166-
167171
else { log->error(1, "GDetectorConstruction::reload_geometry", "Geant4 Run manager not found."); }
168172
}

gdetector/gdetectorConstruction.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class GDetectorConstruction : public GBase<GDetectorConstruction>, public G4VUse
3737
* Reloads the geometry using a new vector of GSystem objects.
3838
* @param sl new vector of gsystem pointers.
3939
*/
40-
void reload_geometry(SystemList sl = {nullptr});
40+
void reload_geometry(SystemList sl);
4141

4242
std::shared_ptr<GDynamicDigitization> get_digitization_routines_for_sdname(const std::string &sd_name) const {
4343
return digitization_routines_map->at(sd_name);

gdetector/meson.build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ verbosities = ['-verbosity.plugins=2',
44
'-debug.plugins=true',
55
'-verbosity.gsystem=2',
66
'-debug.gsystem=true',
7+
'-verbosity.gworld=2',
8+
'-debug.gworld=true',
9+
'-verbosity.gvolume=2',
10+
'-debug.gvolume=true',
711
'-verbosity.g4system=2',
812
'-debug.g4system=true',
913
'-verbosity.g4system=2',

gsystem/gworld.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ GWorld::GWorld(const std::shared_ptr<GOptions>& g, SystemList gsystems)
3333
: GBase(g, GWORLD_LOGGER),
3434
gopts(g) {
3535
log->debug(NORMAL, SFUNCTION_NAME, "From SystemList");
36+
3637
// create the gsystem map
3738
create_gsystemsMap(gsystems);
3839

gsystem/gworld.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class GWorld : public GBase<GWorld> {
3434
* @param gopts Pointer to options.
3535
*/
3636
explicit GWorld(const std::shared_ptr<GOptions>& gopts);
37-
GWorld(const std::shared_ptr<GOptions>& gopts, SystemList systems);
37+
explicit GWorld(const std::shared_ptr<GOptions>& gopts, SystemList systems);
3838

3939
/// Returns the map of GSystem objects.
4040
[[nodiscard]] SystemMap* getSystemsMap() const { return gsystemsMap.get(); }

0 commit comments

Comments
 (0)