From 658ef0d0aa82347b6eee7fe62c1adb667424c55c Mon Sep 17 00:00:00 2001
From: Thomas Strebler <thomas.strebler@cern.ch>
Date: Mon, 11 Sep 2023 17:09:46 +0200
Subject: [PATCH] Enable vertex time smearing for Run4 simulation (fix
 ATLSWUPGR-215)

Enable vertex time smearing for Run4 simulation (fix ATLSWUPGR-215)
---
 Simulation/BeamEffects/python/BeamEffectsAlgConfig.py |  4 +++-
 Simulation/SimulationConfig/python/SimConfigFlags.py  |  3 +++
 Tools/PROCTools/data/q447_AOD_digest.ref              | 10 +++++-----
 Tools/WorkflowTestRunner/python/References.py         |  8 ++++----
 4 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/Simulation/BeamEffects/python/BeamEffectsAlgConfig.py b/Simulation/BeamEffects/python/BeamEffectsAlgConfig.py
index 7f666efb16f..27463fc266c 100755
--- a/Simulation/BeamEffects/python/BeamEffectsAlgConfig.py
+++ b/Simulation/BeamEffects/python/BeamEffectsAlgConfig.py
@@ -1,6 +1,6 @@
 #!/usr/bin/env python
 
-# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
 
 """Define methods to configure beam effects with the ComponentAccumulator"""
 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
@@ -63,6 +63,7 @@ def VertexBeamCondPositionerCfg(flags, name="VertexBeamCondPositioner", **kwargs
     acc = ComponentAccumulator()
 
     kwargs.setdefault("RandomSvc", acc.getPrimaryAndMerge(AthRNGSvcCfg(flags)).name)
+    kwargs.setdefault("SimpleTimeSmearing", flags.Sim.VertexTimeSmearing)
 
     from BeamSpotConditions.BeamSpotConditionsConfig import BeamSpotCondAlgCfg
     acc.merge(BeamSpotCondAlgCfg(flags))
@@ -91,6 +92,7 @@ def LongBeamspotVertexPositionerCfg(flags, name="LongBeamspotVertexPositioner",
     """Return a long beamspot vertex positioner tool"""
     # todo needs LParameter and RandomSvc
     acc = ComponentAccumulator()
+    kwargs.setdefault("SimpleTimeSmearing", flags.Sim.VertexTimeSmearing)
     acc.setPrivateTools(CompFactory.Simulation.LongBeamspotVertexPositioner(name, **kwargs))
     return acc
 
diff --git a/Simulation/SimulationConfig/python/SimConfigFlags.py b/Simulation/SimulationConfig/python/SimConfigFlags.py
index 0df1652cd39..704e269d754 100644
--- a/Simulation/SimulationConfig/python/SimConfigFlags.py
+++ b/Simulation/SimulationConfig/python/SimConfigFlags.py
@@ -2,6 +2,7 @@
 
 from AthenaConfiguration.AthConfigFlags import AthConfigFlags, isGaudiEnv
 from AthenaConfiguration.AutoConfigFlags import GetFileMD
+from AthenaConfiguration.Enums import LHCPeriod
 from SimulationConfig.SimEnums import BeamPipeSimMode, CalibrationRun, CavernBackground, \
     LArParameterization, SimulationFlavour, TruthStrategy, VertexSource
 from AthenaCommon.SystemOfUnits import m
@@ -128,6 +129,8 @@ def createSimConfigFlags():
 
     # BeameffectsAlg
     scf.addFlag("Sim.VertexSource", VertexSource.CondDB, enum=VertexSource)
+    scf.addFlag("Sim.VertexTimeSmearing", lambda prevFlags:
+                prevFlags.GeoModel.Run >= LHCPeriod.Run4)
 
     # G4UserActions
     scf.addFlag("Sim.NRRThreshold", False)
diff --git a/Tools/PROCTools/data/q447_AOD_digest.ref b/Tools/PROCTools/data/q447_AOD_digest.ref
index 9a2d739fb2f..faef3900923 100644
--- a/Tools/PROCTools/data/q447_AOD_digest.ref
+++ b/Tools/PROCTools/data/q447_AOD_digest.ref
@@ -1,6 +1,6 @@
          run       event       nTopo   nIdTracks  nTauTracks       nTaus      nMuons       nElec   nTrueElec   nFakeElec       nPhot   nTruePhot   nFakePhot
-      242000     3120001         199           6           2           1           1           0           0           0           0           0           0
-      242000     3120002         184           6           0           0           1           0           0           0           0           0           0
-      242000     3120003         380          35           3           1           2           0           0           0           0           0           0
-      242000     3120004         182          11           4           1           0           0           0           0           0           0           0
-      242000     3120005         394          36           7           2           2           1           0           1           3           2           1
+      242000     3120001         249           8           2           1           1           0           0           0           0           0           0
+      242000     3120002         153           6           0           0           1           0           0           0           0           0           0
+      242000     3120003         356          36           7           2           2           1           0           1           0           0           0
+      242000     3120004         170          10           5           1           0           0           0           0           0           0           0
+      242000     3120005         409          40           7           2           3           1           0           1           3           1           2
diff --git a/Tools/WorkflowTestRunner/python/References.py b/Tools/WorkflowTestRunner/python/References.py
index 8707266c365..1d7e0d850ac 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": "v3",
+    "s3761": "v4",
     "s3779": "v2",
-    "s4005": "v2",
-    "s4006": "v2",
-    "s4007": "v2",
+    "s4005": "v3",
+    "s4006": "v3",
+    "s4007": "v3",
     "s4008": "v1",
     # Overlay
     "d1590": "v1",
-- 
GitLab