From 39bc15cf0e10027030c53b075747ec81c12ae055 Mon Sep 17 00:00:00 2001
From: John Chapman <jchapman@cern.ch>
Date: Fri, 26 Mar 2021 16:10:18 +0100
Subject: [PATCH] Configuring Pile-up Digitization to run in AthenaMT should
 cause the job to bail

Digitization configuration should throw a RuntimeError if a pile-up digitization
job is configured to be run with AthenaMT. This configuration is not currently
supported. See discussion in ATLASRECTS-6129.
---
 Simulation/Digitization/python/DigitizationSteering.py | 6 ++++++
 Simulation/Digitization/share/ConfigDigitization.py    | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/Simulation/Digitization/python/DigitizationSteering.py b/Simulation/Digitization/python/DigitizationSteering.py
index dcbea0c8af9..c64c604a1e1 100644
--- a/Simulation/Digitization/python/DigitizationSteering.py
+++ b/Simulation/Digitization/python/DigitizationSteering.py
@@ -22,10 +22,16 @@ from SCT_Digitization.SCT_DigitizationConfigNew import SCT_DigitizationCfg
 from TileSimAlgs.TileDigitizationConfig import TileDigitizationCfg, TileTriggerDigitizationCfg
 from TRT_Digitization.TRT_DigitizationConfigNew import TRT_DigitizationCfg
 
+from AthenaCommon.Logging import logging
+logDigiSteering = logging.getLogger('DigitizationSteering')
 
 def DigitizationMainServicesCfg(flags):
     """Configure main digitization services"""
     if flags.Digitization.PileUp:
+        if flags.Concurrency.NumThreads > 0:
+            logDigiSteering.error("DigitizationMainServicesCfg: Attempting to run pile-up digitization AthenaMT using %s threads!", str(flags.Concurrency.NumThreads))
+            logDigiSteering.error("DigitizationMainServicesCfg: Running pile-up digitization with AthenaMT is not supported. Please update your configuration. The job will fail now.")
+            raise RuntimeError("DigitizationSteering.DigitizationMainServicesCfg: Running pile-up digitization with AthenaMT is not supported. Please update your configuration.")
         from Digitization.PileUpConfigNew import PileUpEventLoopMgrCfg
         acc = MainServicesCfg(flags, LoopMgr="PileUpEventLoopMgr")
         acc.merge(PileUpEventLoopMgrCfg(flags))
diff --git a/Simulation/Digitization/share/ConfigDigitization.py b/Simulation/Digitization/share/ConfigDigitization.py
index 91e8abea8f1..6f62b7ccdf2 100755
--- a/Simulation/Digitization/share/ConfigDigitization.py
+++ b/Simulation/Digitization/share/ConfigDigitization.py
@@ -75,6 +75,11 @@ if DetFlags.pileup.any_on() or digitizationFlags.doXingByXingPileUp():
     # protection for SteppingCache usage - currently incompatible with PileUpTools
     if digitizationFlags.SignalPatternForSteppingCache.statusOn and digitizationFlags.doXingByXingPileUp():
         raise RuntimeError("SteppingCache is incompatible with PileUpTools. Please switch off either digitizationFlags.SignalPatternForSteppingCache or digitizationFlags.doXingByXingPileUp.")
+    from AthenaCommon.ConcurrencyFlags import jobproperties as jp
+    if jp.ConcurrencyFlags.NumThreads() > 0:
+        logConfigDigitization.error("Attempting to run pile-up digitization AthenaMT using %s threads!", str(jp.ConcurrencyFlags.NumThreads()))
+        logConfigDigitization.error("Running pile-up digitization with AthenaMT is not supported. Please update your configuration. The job will fail now.")
+        raise RuntimeError("Running pile-up digitization with AthenaMT is not supported. Please update your configuration.")
     include( "Digitization/ConfigPileUpEventLoopMgr.py" )
 if DetFlags.pileup.any_on():
     logConfigDigitization.info("PILEUP CONFIGURATION:")
-- 
GitLab