From e584974849574f6f93c66a244dd2c35efe72ddc6 Mon Sep 17 00:00:00 2001
From: John Derek Chapman <chapman@hep.phy.cam.ac.uk>
Date: Tue, 14 Feb 2023 14:09:52 +0100
Subject: [PATCH] Improve ComponentAccumulator-based configuration of Forward
 Detector Simulation

The various Twiss flags should only be written to the /Simulation/Parameters metadata when Forward Detector simulation is enabled
---
 .../python/AllConfigFlags.py                  |  2 +-
 .../python/ForwardRegionPropertiesConfig.py   | 12 ++---
 .../python/ForwardTransportConfig.py          |  5 +-
 .../python/ForwardTransportSvcConfig.py       | 51 +++++++++++++++++++
 .../test/G4AtlasFieldServices_test.py         |  7 ++-
 .../test/G4AtlasToolsConfig_test.py           |  8 ++-
 .../G4AtlasTools/test/G4FieldConfig_test.py   |  9 ++--
 .../test/G4GeometryToolConfig_Simtest.py      |  9 +++-
 .../test/G4GeometryToolConfig_test.py         |  9 +++-
 .../test/G4PhysicsRegionConfig_test.py        |  9 +++-
 .../SimulationConfig/python/SimConfigFlags.py |  9 ++--
 .../python/SimulationMetadata.py              |  3 ++
 .../test/test_AtlasG4_AFPSimTest.sh           |  2 +-
 .../test/test_AtlasG4_ALFASimTest.sh          |  2 +-
 .../test/test_AtlasG4_ZDCSimTest.sh           |  2 +-
 Tools/WorkflowTestRunner/python/References.py |  8 +--
 16 files changed, 112 insertions(+), 35 deletions(-)
 create mode 100644 ForwardDetectors/ForwardTransportSvc/python/ForwardTransportSvcConfig.py

diff --git a/Control/AthenaConfiguration/python/AllConfigFlags.py b/Control/AthenaConfiguration/python/AllConfigFlags.py
index 4c68670c879..e747d993e78 100644
--- a/Control/AthenaConfiguration/python/AllConfigFlags.py
+++ b/Control/AthenaConfiguration/python/AllConfigFlags.py
@@ -135,7 +135,7 @@ def initConfigFlags():
     acf.addFlag('Beam.BunchSpacing', 25) # former global.BunchSpacing
     acf.addFlag('Beam.Type', lambda prevFlags : BeamType(GetFileMD(prevFlags.Input.Files).get('beam_type', 'collisions')), enum=BeamType)# former global.BeamType
     acf.addFlag("Beam.NumberOfCollisions", lambda prevFlags : 2. if prevFlags.Beam.Type is BeamType.Collisions else 0.) # former global.NumberOfCollisions
-    acf.addFlag('Beam.Energy', lambda prevFlags : GetFileMD(prevFlags.Input.Files).get('beam_energy',7*TeV)) # former global.BeamEnergy
+    acf.addFlag('Beam.Energy', lambda prevFlags : float(GetFileMD(prevFlags.Input.Files).get('beam_energy', 6.8*TeV))) # This is the energy of each individual beam in MeV # former global.BeamEnergy
     acf.addFlag('Beam.estimatedLuminosity', lambda prevFlags : ( 1E33*(prevFlags.Beam.NumberOfCollisions)/2.3 ) *\
         (25./prevFlags.Beam.BunchSpacing)) # former flobal.estimatedLuminosity
     acf.addFlag('Beam.BunchStructureSource', lambda prevFlags: BunchStructureSource.MC if prevFlags.Input.isMC else BunchStructureSource.TrigConf)
diff --git a/ForwardDetectors/ForwardSimulation/ForwardRegionProperties/python/ForwardRegionPropertiesConfig.py b/ForwardDetectors/ForwardSimulation/ForwardRegionProperties/python/ForwardRegionPropertiesConfig.py
index 340232f4243..b9b2a11d2a5 100644
--- a/ForwardDetectors/ForwardSimulation/ForwardRegionProperties/python/ForwardRegionPropertiesConfig.py
+++ b/ForwardDetectors/ForwardSimulation/ForwardRegionProperties/python/ForwardRegionPropertiesConfig.py
@@ -19,10 +19,10 @@ def resolveTwissBeamFilePath(twiss_beam):
 
 
 def buildTwissFilePath(flags, filename, twiss_path=None):
-    twiss_energy = '%1.1fTeV'%(float(flags.Beam.Energy)*0.000001) # flags.Sim.TwissEnergy possibly obsolete?
+    twiss_energy = '%1.1fTeV'%(float(flags.Sim.TwissEnergy)*0.000001) # flags.Sim.TwissEnergy possibly obsolete?
     twiss_beta = '%07.2fm'%(0.001*flags.Sim.TwissFileBeta) # assumes flags.Sim.TwissFileBeta is in mm
     if not (flags.Sim.TwissFileNomReal and flags.Sim.TwissFileVersion):
-        print ("ForwardRegionPropertiesCfg: ERROR Need to either provide file names or set file name and file version flags.")
+        print (f"ForwardRegionPropertiesCfg: ERROR Need to either provide file names or set file name (currently {filename}) and file version flags (currently flags.Sim.TwissFileNomReal = {flags.Sim.TwissFileNomReal} and flags.Sim.TwissFileVersion = {flags.Sim.TwissFileVersion}.")
         raise Exception('Not enough information to locate Twiss files. Need to either provide file names or set file name and file version flags.')
     twiss_nomreal = flags.Sim.TwissFileNomReal
     twiss_version = flags.Sim.TwissFileVersion
@@ -33,7 +33,7 @@ def buildTwissFilePath(flags, filename, twiss_path=None):
         print("buildTwissFilePath: WARNING TwissFilePATH environment variable is empty.")
     twiss_beam = os.path.join(twiss_path, twiss_energy, twiss_beta, twiss_nomreal, twiss_version, filename)
     if not os.access(twiss_beam,os.R_OK):
-        raise Exception('Failed to find %s at %s'%(filename, twiss_beam))
+        raise Exception(f'Failed to find {filename} at {twiss_beam}')
     return twiss_beam
 
 
@@ -52,14 +52,14 @@ def ForwardRegionPropertiesCfg(flags, name="ForwardRegionProperties", **kwargs):
         twiss_beam1 = buildTwissFilePath(flags, 'beam1.tfs')
         twiss_beam2 = buildTwissFilePath(flags, 'beam2.tfs')
         import re,math
-        twiss_energy = '%1.1fTeV'%(float(flags.Beam.Energy)*0.000001) # flags.Sim.TwissEnergy possibly obsolete?
+        twiss_energy = '%1.1fTeV'%(float(flags.Sim.TwissEnergy)*0.000001)
         twiss_momentum =  math.sqrt(float(re.findall("\\d+.\\d+", twiss_energy)[0])**2 - (0.938e-3)**2)*1e3
     else:
         # Have to sort out twiss momentum based on file name
         tmp = twiss_beam1.split('TeV')[0]
         tmp_spot = len(tmp)
-        if flags.Beam.Energy:
-            twiss_energy = '%1.1fTeV'%(float(flags.Beam.Energy)*0.000001)
+        if flags.Sim.TwissEnergy:
+            twiss_energy = '%1.1fTeV'%(float(flags.Sim.TwissEnergy)*0.000001)
         else:
             while True:
                 try:
diff --git a/ForwardDetectors/ForwardTransport/python/ForwardTransportConfig.py b/ForwardDetectors/ForwardTransport/python/ForwardTransportConfig.py
index 686c2ad4789..0061b726a26 100644
--- a/ForwardDetectors/ForwardTransport/python/ForwardTransportConfig.py
+++ b/ForwardDetectors/ForwardTransport/python/ForwardTransportConfig.py
@@ -5,7 +5,10 @@ from AthenaConfiguration.ComponentFactory import CompFactory
 
 def ForwardTransportModelCfg(flags, name="ForwardTransportModel", **kwargs):
     result = ComponentAccumulator()
-    kwargs.setdefault("ForwardTransportSvcName", "ForwardTransportSvc")
+    from ForwardTransportSvc.ForwardTransportSvcConfig import ForwardTransportSvcCfg
+    serviceName ="ForwardTransportSvc"
+    result.merge(ForwardTransportSvcCfg(flags, serviceName, **kwargs))
+    kwargs.setdefault("ForwardTransportSvcName", serviceName) #Not a ServiceHandle
     kwargs.setdefault("RegionNames" , ["FWDBeamLine"] )
     result.setPrivateTools(CompFactory.ForwardTransportModelTool(name, **kwargs))
     return result
diff --git a/ForwardDetectors/ForwardTransportSvc/python/ForwardTransportSvcConfig.py b/ForwardDetectors/ForwardTransportSvc/python/ForwardTransportSvcConfig.py
new file mode 100644
index 00000000000..326772d0854
--- /dev/null
+++ b/ForwardDetectors/ForwardTransportSvc/python/ForwardTransportSvcConfig.py
@@ -0,0 +1,51 @@
+# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
+
+from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
+from AthenaConfiguration.ComponentFactory import CompFactory
+from ForwardRegionProperties.ForwardRegionPropertiesConfig import resolveTwissBeamFilePath, buildTwissFilePath
+
+def ForwardTransportSvcCfg(flags, name="ForwardTransportSvc", **kwargs):
+   # Settings of optics to be used
+    twiss_beam1 = resolveTwissBeamFilePath(flags.Sim.TwissFileBeam1)
+    twiss_beam2 = resolveTwissBeamFilePath(flags.Sim.TwissFileBeam2)
+    if twiss_beam1 is None or twiss_beam2 is None:
+        print("ForwardTransportSvcCfg: Attempting to build TwissFileBeam paths manually")
+        # Getting paths to the twiss files, momentum calculation; you can switch to local files
+        twiss_beam1 = buildTwissFilePath(flags, 'beam1.tfs')
+        twiss_beam2 = buildTwissFilePath(flags, 'beam2.tfs')
+
+    # properties of the field set according to the optics settings above
+    kwargs.setdefault("TwissFile1", twiss_beam1)
+    kwargs.setdefault("TwissFile2", twiss_beam2)
+    kwargs.setdefault("PositionC1", 149)
+    kwargs.setdefault("PositionC2", 184)
+    kwargs.setdefault("ApertureC1", 999)
+    kwargs.setdefault("ApertureC2", 999)
+    if flags.Detector.GeometryALFA:
+        return ALFAForwardTransportSvcCfg(name, **kwargs)
+    if flags.Detector.GeometryZDC:
+        return ZDCForwardTransportSvcCfg (name, **kwargs)
+    print ("ForwardTransportSvcCfg: WARNING ALFA and ZDC are deactivated.")
+    return ComponentAccumulator()
+
+
+def ALFAForwardTransportSvcCfg(name="ForwardTransportSvc", **kwargs):
+    print ("ALFAForwardTransportSvc")
+    result = ComponentAccumulator()
+    kwargs.setdefault("EndMarker",     236.888)
+    kwargs.setdefault("TransportFlag", 1)
+    kwargs.setdefault("EtaCut",        7.5)
+    kwargs.setdefault("XiCut",         0.8)
+    result.addService(CompFactory.ForwardTransportSvc(name,**kwargs), create=True, primary=True)
+    return result
+
+
+def ZDCForwardTransportSvcCfg(name="ForwardTransportSvc", **kwargs):
+    print ("ZDCForwardTransportSvc")
+    result = ComponentAccumulator()
+    kwargs.setdefault("EndMarker",     141.580)
+    kwargs.setdefault("TransportFlag", 0)
+    kwargs.setdefault("EtaCut",        7.5)
+    kwargs.setdefault("XiCut",         0)
+    result.addService(CompFactory.ForwardTransportSvc(name,**kwargs), create=True, primary=True)
+    return result
diff --git a/Simulation/G4Atlas/G4AtlasServices/test/G4AtlasFieldServices_test.py b/Simulation/G4Atlas/G4AtlasServices/test/G4AtlasFieldServices_test.py
index 6cce8b8ed0f..018f8a5ce81 100755
--- a/Simulation/G4Atlas/G4AtlasServices/test/G4AtlasFieldServices_test.py
+++ b/Simulation/G4Atlas/G4AtlasServices/test/G4AtlasFieldServices_test.py
@@ -20,12 +20,11 @@ if __name__ == '__main__':
   flags = initConfigFlags()
   flags.Input.Files = defaultTestFiles.EVNT
   # Arbitrary configuration for Twiss Files
-  flags.Sim.TwissFileBeam1 = '3.5TeV/0090.00m/nominal/v02/beam1.tfs'
-  flags.Sim.TwissFileBeam2 = '3.5TeV/0090.00m/nominal/v02/beam2.tfs'
+  flags.Sim.TwissFileBeam1 = '4.0TeV/0090.00m/nominal/v01/beam1.tfs'
+  flags.Sim.TwissFileBeam2 = '4.0TeV/0090.00m/nominal/v01/beam2.tfs'
   flags.Sim.TwissFileBeta = 90000 # in mm
   flags.Sim.TwissFileNomReal = 'nominal'
-  flags.Sim.TwissFileVersion = 'v02'
-  flags.Beam.Energy = '3500000'
+  flags.Sim.TwissFileVersion = 'v01'
   # Finalize
   flags.lock()
 
diff --git a/Simulation/G4Atlas/G4AtlasTools/test/G4AtlasToolsConfig_test.py b/Simulation/G4Atlas/G4AtlasTools/test/G4AtlasToolsConfig_test.py
index 51f3b71f874..d58d70d2161 100755
--- a/Simulation/G4Atlas/G4AtlasTools/test/G4AtlasToolsConfig_test.py
+++ b/Simulation/G4Atlas/G4AtlasTools/test/G4AtlasToolsConfig_test.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 """Run tests on G4AtlasToolsConfig
 
-Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
+Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
 """
 
 if __name__ == '__main__':
@@ -31,6 +31,12 @@ if __name__ == '__main__':
   # Setup detector flags
   from AthenaConfiguration.DetectorConfigFlags import setupDetectorFlags
   setupDetectorFlags(flags, ['BCM', 'Pixel', 'SCT', 'TRT', 'LAr', 'MBTS'], toggle_geometry=True)
+  # Arbitrary configuration for Twiss Files
+  flags.Sim.TwissFileBeam1 = '4.0TeV/0090.00m/nominal/v01/beam1.tfs'
+  flags.Sim.TwissFileBeam2 = '4.0TeV/0090.00m/nominal/v01/beam2.tfs'
+  flags.Sim.TwissFileBeta = 90000 # in mm
+  flags.Sim.TwissFileNomReal = 'nominal'
+  flags.Sim.TwissFileVersion = 'v01'
 
   # Finalize
   flags.lock()
diff --git a/Simulation/G4Atlas/G4AtlasTools/test/G4FieldConfig_test.py b/Simulation/G4Atlas/G4AtlasTools/test/G4FieldConfig_test.py
index 05e5d572130..6a642f8a34f 100755
--- a/Simulation/G4Atlas/G4AtlasTools/test/G4FieldConfig_test.py
+++ b/Simulation/G4Atlas/G4AtlasTools/test/G4FieldConfig_test.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 """Run tests on G4AtlasFieldConfig
 
-Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
+Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
 """
 
 if __name__ == '__main__':
@@ -20,12 +20,11 @@ if __name__ == '__main__':
   flags = initConfigFlags()
   flags.Input.Files = defaultTestFiles.EVNT
   # Arbitrary configuration for Twiss Files
-  flags.Sim.TwissFileBeam1 = '3.5TeV/0090.00m/nominal/v02/beam1.tfs'
-  flags.Sim.TwissFileBeam2 = '3.5TeV/0090.00m/nominal/v02/beam2.tfs'
+  flags.Sim.TwissFileBeam1 = '4.0TeV/0090.00m/nominal/v01/beam1.tfs'
+  flags.Sim.TwissFileBeam2 = '4.0TeV/0090.00m/nominal/v01/beam2.tfs'
   flags.Sim.TwissFileBeta = 90000 # in mm
   flags.Sim.TwissFileNomReal = 'nominal'
-  flags.Sim.TwissFileVersion = 'v02'
-  flags.Beam.Energy = '3500000'
+  flags.Sim.TwissFileVersion = 'v01'
   # Finalize
   flags.lock()
 
diff --git a/Simulation/G4Atlas/G4AtlasTools/test/G4GeometryToolConfig_Simtest.py b/Simulation/G4Atlas/G4AtlasTools/test/G4GeometryToolConfig_Simtest.py
index 120978ad252..f98ba217d10 100755
--- a/Simulation/G4Atlas/G4AtlasTools/test/G4GeometryToolConfig_Simtest.py
+++ b/Simulation/G4Atlas/G4AtlasTools/test/G4GeometryToolConfig_Simtest.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 """Run tests on G4Geometry Tool configuration
 
-Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
+Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
 """
 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
 
@@ -35,7 +35,12 @@ if __name__ == '__main__':
   flags.Sim.WorldRRange = 15000
   flags.Sim.WorldZRange = 27000
 
-  flags.Sim.TwissFileNomReal = "nominal" #so it doesn't crash
+  # Arbitrary configuration for Twiss Files
+  flags.Sim.TwissFileBeam1 = '4.0TeV/0090.00m/nominal/v01/beam1.tfs'
+  flags.Sim.TwissFileBeam2 = '4.0TeV/0090.00m/nominal/v01/beam2.tfs'
+  flags.Sim.TwissFileBeta = 90000 # in mm
+  flags.Sim.TwissFileNomReal = 'nominal'
+  flags.Sim.TwissFileVersion = 'v01'
 
   # Finalize
   flags.lock()
diff --git a/Simulation/G4Atlas/G4AtlasTools/test/G4GeometryToolConfig_test.py b/Simulation/G4Atlas/G4AtlasTools/test/G4GeometryToolConfig_test.py
index 52d114421c5..7e86b32b701 100755
--- a/Simulation/G4Atlas/G4AtlasTools/test/G4GeometryToolConfig_test.py
+++ b/Simulation/G4Atlas/G4AtlasTools/test/G4GeometryToolConfig_test.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 """Run tests on G4Geometry Tool configuration
 
-Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
+Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
 """
 
 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
@@ -34,7 +34,12 @@ if __name__ == '__main__':
   flags.Sim.WorldRRange = 15000
   flags.Sim.WorldZRange = 27000
 
-  flags.Sim.TwissFileNomReal = "nominal" #so it doesn't crash
+  # Arbitrary configuration for Twiss Files
+  flags.Sim.TwissFileBeam1 = '4.0TeV/0090.00m/nominal/v01/beam1.tfs'
+  flags.Sim.TwissFileBeam2 = '4.0TeV/0090.00m/nominal/v01/beam2.tfs'
+  flags.Sim.TwissFileBeta = 90000 # in mm
+  flags.Sim.TwissFileNomReal = 'nominal'
+  flags.Sim.TwissFileVersion = 'v01'
 
   # Finalize
   flags.lock()
diff --git a/Simulation/G4Atlas/G4AtlasTools/test/G4PhysicsRegionConfig_test.py b/Simulation/G4Atlas/G4AtlasTools/test/G4PhysicsRegionConfig_test.py
index ffba7313c0b..96777f6ee26 100755
--- a/Simulation/G4Atlas/G4AtlasTools/test/G4PhysicsRegionConfig_test.py
+++ b/Simulation/G4Atlas/G4AtlasTools/test/G4PhysicsRegionConfig_test.py
@@ -2,7 +2,7 @@
 
 """Run tests on G4PhysicsRegionConfig configuration
 
-Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
+Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
 from __future__ import print_function
 """
 
@@ -22,7 +22,12 @@ if __name__ == '__main__':
   inputDir = defaultTestFiles.d
   flags = initConfigFlags()
   flags.Input.Files = defaultTestFiles.EVNT
-
+  # Arbitrary configuration for Twiss Files
+  flags.Sim.TwissFileBeam1 = '4.0TeV/0090.00m/nominal/v01/beam1.tfs'
+  flags.Sim.TwissFileBeam2 = '4.0TeV/0090.00m/nominal/v01/beam2.tfs'
+  flags.Sim.TwissFileBeta = 90000 # in mm
+  flags.Sim.TwissFileNomReal = 'nominal'
+  flags.Sim.TwissFileVersion = 'v01'
   # Finalize
   flags.lock()
 
diff --git a/Simulation/SimulationConfig/python/SimConfigFlags.py b/Simulation/SimulationConfig/python/SimConfigFlags.py
index b634d965b86..f8baf8eddc2 100644
--- a/Simulation/SimulationConfig/python/SimConfigFlags.py
+++ b/Simulation/SimulationConfig/python/SimConfigFlags.py
@@ -4,6 +4,7 @@ from AthenaConfiguration.AthConfigFlags import AthConfigFlags, isGaudiEnv
 from AthenaConfiguration.AutoConfigFlags import GetFileMD
 from SimulationConfig.SimEnums import BeamPipeSimMode, CalibrationRun, CavernBackground, \
     LArParameterization, SimulationFlavour, TruthStrategy, VertexSource
+from AthenaCommon.SystemOfUnits import m
 
 #todo? add in the explanatory text from previous implementation
 
@@ -61,10 +62,10 @@ def createSimConfigFlags():
     # Forward region
     scf.addFlag("Sim.TwissFileBeam1", False)
     scf.addFlag("Sim.TwissFileBeam2", False)
-    scf.addFlag("Sim.TwissEnergy", 8000000.)
-    scf.addFlag("Sim.TwissFileBeta", 550.)
-    scf.addFlag("Sim.TwissFileNomReal", False)  # "nominal", "real" / default to one of these?!
-    scf.addFlag("Sim.TwissFileVersion", "v01")
+    scf.addFlag("Sim.TwissEnergy", lambda prevFlags : float(prevFlags.Beam.Energy)) # energy of each beam
+    scf.addFlag("Sim.TwissFileBeta", 90.*m)
+    scf.addFlag("Sim.TwissFileNomReal", 'nominal')  # "nominal", "real" / default to one of these?!
+    scf.addFlag("Sim.TwissFileVersion", "v02")
 
     # G4AtlasAlg
     scf.addFlag("Sim.ReleaseGeoModel", False)
diff --git a/Simulation/SimulationConfig/python/SimulationMetadata.py b/Simulation/SimulationConfig/python/SimulationMetadata.py
index e617335668f..83d50a215d7 100644
--- a/Simulation/SimulationConfig/python/SimulationMetadata.py
+++ b/Simulation/SimulationConfig/python/SimulationMetadata.py
@@ -17,6 +17,9 @@ def fillAtlasMetadata(flags, dbFiller):
             if "GenerationConfiguration" in flag:
                 # This flag is only temporarily defined in the SimConfigFlags module
                 continue
+            if "Twiss" in flag and not flags.Detector.GeometryForward:
+                # The various Twiss flags should only be written out when Forward Detector simulation is enabled
+                continue
             key = flag.split(".")[-1] #use final part of flag as the key
             value = flags._get(flag)
             if isinstance(value, FlagEnum):
diff --git a/Simulation/Tests/SimCoreTests/test/test_AtlasG4_AFPSimTest.sh b/Simulation/Tests/SimCoreTests/test/test_AtlasG4_AFPSimTest.sh
index a1557ce3a1b..be5237f7f69 100755
--- a/Simulation/Tests/SimCoreTests/test/test_AtlasG4_AFPSimTest.sh
+++ b/Simulation/Tests/SimCoreTests/test/test_AtlasG4_AFPSimTest.sh
@@ -61,7 +61,7 @@ AtlasG4_tf.py \
 
 rc2=$?
 mv log.AtlasG4Tf log.AtlasG4Tf_CG
-echo  "art-result: $rc simOLD"
+echo  "art-result: $rc2 simOLD"
 if [ $status -eq 0 ]
 then
     status=$rc2
diff --git a/Simulation/Tests/SimCoreTests/test/test_AtlasG4_ALFASimTest.sh b/Simulation/Tests/SimCoreTests/test/test_AtlasG4_ALFASimTest.sh
index e076bf1f0f4..c1c08c114db 100755
--- a/Simulation/Tests/SimCoreTests/test/test_AtlasG4_ALFASimTest.sh
+++ b/Simulation/Tests/SimCoreTests/test/test_AtlasG4_ALFASimTest.sh
@@ -60,7 +60,7 @@ AtlasG4_tf.py \
 
 rc2=$?
 mv log.AtlasG4Tf log.AtlasG4Tf_CG
-echo  "art-result: $rc simOLD"
+echo  "art-result: $rc2 simOLD"
 if [ $status -eq 0 ]
 then
     status=$rc2
diff --git a/Simulation/Tests/SimCoreTests/test/test_AtlasG4_ZDCSimTest.sh b/Simulation/Tests/SimCoreTests/test/test_AtlasG4_ZDCSimTest.sh
index 24975944e5b..f250b62f7a0 100755
--- a/Simulation/Tests/SimCoreTests/test/test_AtlasG4_ZDCSimTest.sh
+++ b/Simulation/Tests/SimCoreTests/test/test_AtlasG4_ZDCSimTest.sh
@@ -60,7 +60,7 @@ AtlasG4_tf.py \
 
 rc2=$?
 mv log.AtlasG4Tf log.AtlasG4Tf_CG
-echo  "art-result: $rc simOLD"
+echo  "art-result: $rc2 simOLD"
 if [ $status -eq 0 ]
 then
     status=$rc2
diff --git a/Tools/WorkflowTestRunner/python/References.py b/Tools/WorkflowTestRunner/python/References.py
index a52cb24f186..b038fa48da0 100644
--- a/Tools/WorkflowTestRunner/python/References.py
+++ b/Tools/WorkflowTestRunner/python/References.py
@@ -11,11 +11,11 @@
 # Format is "test" : "version"
 references_map = {
     # Simulation
-    "s3761": "v9",
+    "s3761": "v10",
     "s3779": "v7",
-    "s4005": "v6",
-    "s4006": "v10",
-    "s4007": "v10",
+    "s4005": "v7",
+    "s4006": "v11",
+    "s4007": "v11",
     "s4008": "v4",
     # Overlay
     "d1590": "v14",
-- 
GitLab