From f09a8adaa9e378d47953fd8cf984c23d336933f6 Mon Sep 17 00:00:00 2001 From: Markus Frank <Markus.Frank@cern.ch> Date: Wed, 31 May 2023 11:24:47 +0200 Subject: [PATCH] Fix example args --- examples/ClientTests/CMakeLists.txt | 2 +- examples/ClientTests/scripts/Assemblies.py | 3 ++- examples/ClientTests/scripts/LheD_tracker.py | 3 ++- examples/ClientTests/scripts/MiniTel.py | 6 +++--- examples/ClientTests/scripts/MiniTel_hepmc.py | 3 ++- examples/ClientTests/scripts/NestedDetectors.py | 3 ++- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/ClientTests/CMakeLists.txt b/examples/ClientTests/CMakeLists.txt index c35a127d9..fceccea3c 100644 --- a/examples/ClientTests/CMakeLists.txt +++ b/examples/ClientTests/CMakeLists.txt @@ -492,7 +492,7 @@ if (DD4HEP_USE_GEANT4) foreach(script Assemblies LheD_tracker MiniTel MiniTel_hepmc NestedDetectors ) dd4hep_add_test_reg( ClientTests_sim_${script} COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_ClientTests.sh" - EXEC_ARGS ${Python_EXECUTABLE} ${ClientTestsEx_INSTALL}/scripts/${script}.py batch + EXEC_ARGS ${Python_EXECUTABLE} ${ClientTestsEx_INSTALL}/scripts/${script}.py -batch REGEX_PASS NONE REGEX_FAIL "Exception;EXCEPTION;ERROR;Error" ) endforeach(script) diff --git a/examples/ClientTests/scripts/Assemblies.py b/examples/ClientTests/scripts/Assemblies.py index 2db0af1dc..ab6dac5ab 100644 --- a/examples/ClientTests/scripts/Assemblies.py +++ b/examples/ClientTests/scripts/Assemblies.py @@ -25,6 +25,7 @@ from g4units import GeV, mm, cm def run(): + args = DDG4.CommandLine() kernel = DDG4.Kernel() install_dir = os.environ['DD4hepExamplesINSTALL'] kernel.loadGeometry(str("file:" + install_dir + "/examples/ClientTests/compact/Assemblies.xml")) @@ -33,7 +34,7 @@ def run(): geant4.printDetectors() # Configure UI geant4.setupCshUI() - if len(sys.argv) >= 2 and sys.argv[1] == "batch": + if args.batch: kernel.UI = '' # Configure field diff --git a/examples/ClientTests/scripts/LheD_tracker.py b/examples/ClientTests/scripts/LheD_tracker.py index 814aa86fc..512025c67 100644 --- a/examples/ClientTests/scripts/LheD_tracker.py +++ b/examples/ClientTests/scripts/LheD_tracker.py @@ -35,6 +35,7 @@ logger = logging.getLogger(__name__) def run(): + args = DDG4.CommandLine() kernel = DDG4.Kernel() description = kernel.detectorDescription() @@ -49,7 +50,7 @@ def run(): geant4.setupCshUI() # geant4.setupCshUI('csh',True,True) # geant4.setupCshUI('csh',True,True,'vis.mac') - if len(sys.argv) >= 2 and sys.argv[1] == "batch": + if args.batch: kernel.UI = '' # Configure field diff --git a/examples/ClientTests/scripts/MiniTel.py b/examples/ClientTests/scripts/MiniTel.py index 899591761..853e341d4 100644 --- a/examples/ClientTests/scripts/MiniTel.py +++ b/examples/ClientTests/scripts/MiniTel.py @@ -35,14 +35,14 @@ def run(): cmds.append('/ddg4/UI/terminate') m.kernel.UI = '' + # Configure G4 geometry setup + seq, act = m.geant4.addDetectorConstruction("Geant4DetectorGeometryConstruction/ConstructGeo") if args.debug: - # Configure G4 geometry setup - seq, act = m.geant4.addDetectorConstruction("Geant4DetectorGeometryConstruction/ConstructGeo") act.DebugVolumes = True act.DebugRegions = True act.DebugLimits = True - seq, act = m.geant4.addDetectorConstruction("Geant4DetectorSensitivesConstruction/ConstructSD") + seq, act = m.geant4.addDetectorConstruction("Geant4DetectorSensitivesConstruction/ConstructSD") m.ui.Commands = cmds m.configure() m.defineOutput() diff --git a/examples/ClientTests/scripts/MiniTel_hepmc.py b/examples/ClientTests/scripts/MiniTel_hepmc.py index 26787af63..ed08f3331 100644 --- a/examples/ClientTests/scripts/MiniTel_hepmc.py +++ b/examples/ClientTests/scripts/MiniTel_hepmc.py @@ -26,8 +26,9 @@ import DDG4 def run(): from MiniTelSetup import Setup + args = DDG4.CommandLine() m = Setup() - if len(sys.argv) >= 2 and sys.argv[1] == "batch": + if args.batch: DDG4.setPrintLevel(DDG4.OutputLevel.WARNING) m.kernel.UI = '' m.configure() diff --git a/examples/ClientTests/scripts/NestedDetectors.py b/examples/ClientTests/scripts/NestedDetectors.py index c77bb540a..f5f2f099f 100644 --- a/examples/ClientTests/scripts/NestedDetectors.py +++ b/examples/ClientTests/scripts/NestedDetectors.py @@ -28,6 +28,7 @@ from g4units import GeV, MeV def run(): + args = DDG4.CommandLine() kernel = DDG4.Kernel() install_dir = os.environ['DD4hepExamplesINSTALL'] kernel.setOutputLevel(str('Geant4Converter'), Output.DEBUG) @@ -37,7 +38,7 @@ def run(): geant4 = DDG4.Geant4(kernel) geant4.printDetectors() geant4.setupCshUI() - if len(sys.argv) >= 2 and sys.argv[1] == "batch": + if args.batch: kernel.UI = '' # Configure field -- GitLab