Skip to content

Commit 821da1c

Browse files
committed
reload run fixed for different variations with the caviat that optical properties must be carried across reload
1 parent c642d6f commit 821da1c

2 files changed

Lines changed: 16 additions & 14 deletions

File tree

examples/optical/cherenkov/cherenkov.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,18 @@
7070
for variation, material in variation_material.items():
7171
cfg.init_variation(variation)
7272

73-
mat = GMaterial(material_definitions[material]["name"])
74-
mat.description = material_definitions[material]["description"]
75-
mat.density = material_definitions[material]["density"]
76-
77-
for element, natoms in material_definitions[material]["atoms"]:
78-
mat.addNAtoms(element, natoms)
79-
80-
mat.photonEnergy = photon_energy
81-
mat.indexOfRefraction = rindex[material]
82-
mat.absorptionLength = absorption[material]
83-
mat.publish(cfg)
73+
for material_name, definition in material_definitions.items():
74+
mat = GMaterial(definition["name"])
75+
mat.description = definition["description"]
76+
mat.density = definition["density"]
77+
78+
for element, natoms in definition["atoms"]:
79+
mat.addNAtoms(element, natoms)
80+
81+
mat.photonEnergy = photon_energy
82+
mat.indexOfRefraction = rindex[material_name]
83+
mat.absorptionLength = absorption[material_name]
84+
mat.publish(cfg)
8485

8586
# World
8687
world = GVolume("root")

gdetector/gdetectorConstruction.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,13 @@ void GDetectorConstruction::prepare_geometry_for_run() {
336336
GVisManagerGuard::set(nullptr);
337337
// Geometry is being rebuilt: ensure loadDigitizationPlugins() runs inside Initialize().
338338
digiplugins_need_reload = true;
339+
rm->ReinitializeGeometry(true, true);
340+
rm->GeometryHasBeenModified();
339341
// Optical processes such as G4Cerenkov cache material-property tables by
340342
// material index. A setup-tab reload can introduce a different variation's
341-
// optical material, so force physics tables to rebuild with the new material set.
343+
// optical material, so force physics tables to rebuild after the new
344+
// geometry/material set has been installed.
342345
rm->PhysicsHasBeenModified();
343-
rm->ReinitializeGeometry(false, true);
344-
rm->GeometryHasBeenModified();
345346
rm->Initialize();
346347
GVisManagerGuard::set(visManager);
347348
} else { log->error(1, "GDetectorConstruction::prepare_geometry_for_run", "Geant4 Run manager not found."); }

0 commit comments

Comments
 (0)