@@ -257,6 +257,23 @@ void GDetectorConstruction::loadDigitizationPlugins() {
257257 // when the geometry is reloaded with the same SD names.
258258 digitization_routines_map->clear ();
259259
260+ // Resolve the variation each routine uses to load constants / translation tables.
261+ // By default a routine follows the variation of the gsystem it belongs to; the
262+ // digitization_variation option, when set, overrides that for every routine.
263+ const std::string digiVariationOverride = gopt->getScalarString (" digitization_variation" );
264+ const bool overrideVariation = (digiVariationOverride != UNINITIALIZEDSTRINGQUANTITY );
265+
266+ // Map each digitization (sensitive-detector) name to its system's variation.
267+ std::map<std::string, std::string> systemVariationFor;
268+ for (const auto & [systemName, gsystemPtr] : *gworld->getSystemsMap ()) {
269+ for (const auto & [volumeName, gvolumePtr] : gsystemPtr->getGVolumesMap ()) {
270+ const auto & digiName = gvolumePtr->getDigitization ();
271+ if (digiName != " " && digiName != UNINITIALIZEDSTRINGQUANTITY ) {
272+ systemVariationFor.emplace (digiName, gsystemPtr->getVariation ());
273+ }
274+ }
275+ }
276+
260277 const auto sdetectors = gworld->getSensitiveDetectorsList ();
261278
262279 for (auto &sdname: sdetectors) {
@@ -281,6 +298,15 @@ void GDetectorConstruction::loadDigitizationPlugins() {
281298 // Ensure each routine uses the correct logger and is configured for readout.
282299 digitization_routines_map->at (sdname)->set_loggers (gopt);
283300
301+ // Resolve and store the variation used when loading this routine's constants/TT:
302+ // the digitization_variation option when set, otherwise the routine's gsystem variation.
303+ std::string variation = " default" ;
304+ if (const auto it = systemVariationFor.find (sdname); it != systemVariationFor.end ()) {
305+ variation = it->second ;
306+ }
307+ if (overrideVariation) { variation = digiVariationOverride; }
308+ digitization_routines_map->at (sdname)->setDigitizationVariation (variation);
309+
284310 if (digitization_routines_map->at (sdname)->defineReadoutSpecs ()) {
285311 log->info (1 , " Digitization routine <" + sdname + " > has been successfully defined." );
286312 } else { log->error (ERR_DEFINESPECFAIL , " defineReadoutSpecs failure for <" + sdname + " >" ); }
0 commit comments