From 7e85cc1d7fca6e7b0a9fda4e6ff35c34fc8cf114 Mon Sep 17 00:00:00 2001
From: Rupert Tombs <rt500@cam.ac.uk>
Date: Fri, 5 Jun 2020 13:48:59 +0100
Subject: [PATCH] Create sim comparison test for art. Link test and increase to
 4 events.

---
 Simulation/G4Atlas/G4AtlasAlg/CMakeLists.txt  |  8 +---
 .../test/G4AtlasAlgConfigNew_Test.py          |  2 +-
 .../SimCoreTests/test/test_Sim_Comparison.sh  | 43 +++++++++++++++++++
 3 files changed, 45 insertions(+), 8 deletions(-)
 create mode 100755 Simulation/Tests/SimCoreTests/test/test_Sim_Comparison.sh

diff --git a/Simulation/G4Atlas/G4AtlasAlg/CMakeLists.txt b/Simulation/G4Atlas/G4AtlasAlg/CMakeLists.txt
index c49cd430ed4..3a0b865f076 100644
--- a/Simulation/G4Atlas/G4AtlasAlg/CMakeLists.txt
+++ b/Simulation/G4Atlas/G4AtlasAlg/CMakeLists.txt
@@ -44,13 +44,7 @@ atlas_add_component( G4AtlasAlg
                      INCLUDE_DIRS ${GEANT4_INCLUDE_DIRS} ${EIGEN_INCLUDE_DIRS} ${XERCESC_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS} 
                      LINK_LIBRARIES ${GEANT4_LIBRARIES} ${EIGEN_LIBRARIES} ${XERCESC_LIBRARIES} ${CLHEP_LIBRARIES} AtlasHepMCLib AthenaBaseComps AthenaKernel GaudiKernel G4AtlasInterfaces G4AtlasAlgLib SGTools StoreGateLib SGtests EventInfo GeneratorObjects MCTruthBaseLib )
 
-#Test G4AtlasAlg
-#atlas_add_test( G4AtlasAlgConfigNew_Test
-#                SCRIPT test/G4AtlasAlgConfigNew_Test.py
-#                PROPERTIES TIMEOUT 300 )
-
-
 # Install files from the package:
 atlas_install_python_modules( python/*.py
                               POST_BUILD_CMD ${ATLAS_FLAKE8} )
-
+atlas_install_scripts( test/*.py )
diff --git a/Simulation/G4Atlas/G4AtlasAlg/test/G4AtlasAlgConfigNew_Test.py b/Simulation/G4Atlas/G4AtlasAlg/test/G4AtlasAlgConfigNew_Test.py
index f28fab90b4d..5fba79a6e60 100755
--- a/Simulation/G4Atlas/G4AtlasAlg/test/G4AtlasAlgConfigNew_Test.py
+++ b/Simulation/G4Atlas/G4AtlasAlg/test/G4AtlasAlgConfigNew_Test.py
@@ -139,7 +139,7 @@ if __name__ == '__main__':
     myRunNumber = 284500
     myFirstLB = 1
     myInitialTimeStamp = 1446539185
-    evtMax = 1
+    evtMax = 4
     from AthenaConfiguration.ComponentFactory import CompFactory
     evtIdModifierSvc = CompFactory.EvtIdModifierSvc(EvtStoreName="StoreGateSvc")
     iovDbMetaDataTool = CompFactory.IOVDbMetaDataTool()
diff --git a/Simulation/Tests/SimCoreTests/test/test_Sim_Comparison.sh b/Simulation/Tests/SimCoreTests/test/test_Sim_Comparison.sh
new file mode 100755
index 00000000000..69ddd827f5c
--- /dev/null
+++ b/Simulation/Tests/SimCoreTests/test/test_Sim_Comparison.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# art-description: Simulation example to test agreement between ConfGetter and ComponentAccumulator configurations.
+# art-include: master/Athena
+# art-type: grid
+# art-output: test.HITS.pool.root
+# art-output: myHITSnew.pool.root
+
+# ComponentAccumulator
+G4AtlasAlgConfigNew_Test.py
+rc=$?
+echo "art-result: $rc CAsim"
+
+# ConfGetter
+rc2=-9999
+if [ $rc -eq 0 ]
+then
+    AtlasG4_tf.py \
+    --conditionsTag 'default:OFLCOND-MC16-SDR-14' \
+    --physicsList 'FTFP_BERT_ATL' \
+    --truthStrategy 'MC15aPlus' \
+    --postInclude 'default:PyJobTransforms/UseFrontier.py' \
+    --preInclude 'AtlasG4Tf:SimulationJobOptions/preInclude.BeamPipeKill.py,SimulationJobOptions/preInclude.FrozenShowersFCalOnly.py' \
+    --preExec 'AtlasG4Tf:simFlags.TightMuonStepping=True' \
+    --DataRunNumber '284500' \
+    --geometryVersion 'default:ATLAS-R2-2016-01-00-01' \
+    --inputEVNTFile "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/SimCoreTests/valid1.410000.PowhegPythiaEvtGen_P2012_ttbar_hdamp172p5_nonallhad.evgen.EVNT.e4993.EVNT.08166201._000012.pool.root.1" \
+    --outputHITSFile "test.HITS.pool.root" \
+    --maxEvents 4 \
+    --imf False \
+    --postExec 'topSeq+=CfgMgr.JobOptsDumperAlg(FileName="G4AtlasTestConfigOld.txt")'
+    rc2=$?
+fi
+
+rc3=-9999
+echo "art-result: $rc simulation"
+if [ $rc2 -eq 0 ]
+then
+    acmd.py diff-root test.HITS.pool.root myHITSnew.pool.root --mode=semi-detailed --order-trees --ignore-leaves RecoTimingObj_p1_HITStoRDO_timings index_ref --error-mode resilient
+    rc3=$?
+fi
+
+echo "art-result: $rc2 regression"
-- 
GitLab