From 6256ddc73cda2643c8817717366ab1235e5c9b7c Mon Sep 17 00:00:00 2001 From: Markus Frank <Markus.Frank@cern.ch> Date: Mon, 29 Apr 2019 11:27:21 +0200 Subject: [PATCH] Add properties to Geant4GDMLWriteAction to steer writing of regions, cuts and sensitive detectors. See github issue https://github.com/AIDASoft/DD4hep/issues/507 --- DDG4/src/Geant4UIManager.cpp | 8 +++++++- examples/CLICSiD/CMakeLists.txt | 12 ++++++------ examples/CLICSiD/scripts/CLIC_G4Gun.py | 5 +++++ 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/DDG4/src/Geant4UIManager.cpp b/DDG4/src/Geant4UIManager.cpp index 37ebc5df8..3d6757a4d 100644 --- a/DDG4/src/Geant4UIManager.cpp +++ b/DDG4/src/Geant4UIManager.cpp @@ -152,8 +152,14 @@ void Geant4UIManager::start() { context()->kernel().runManager().BeamOn(numEvent); } catch (DD4hep_End_Of_File& e) { printout(INFO,"Geant4UIManager","++ End of file reached, ending run..."); - context()->kernel().runManager().RunTermination(); } + // Execute the chained command statements + for(const auto& c : m_postRunCommands) { + printout(INFO,"Geant4UIManager","++ Executing Command statement:%s",c.c_str()); + mgr->ApplyCommand(c.c_str()); + executed_statements = true; + } + context()->kernel().runManager().RunTermination(); } /// Stop and release resources diff --git a/examples/CLICSiD/CMakeLists.txt b/examples/CLICSiD/CMakeLists.txt index 9967ff104..cc2f74aeb 100644 --- a/examples/CLICSiD/CMakeLists.txt +++ b/examples/CLICSiD/CMakeLists.txt @@ -119,12 +119,12 @@ if (DD4HEP_USE_GEANT4) endforeach(script) # # Write GDML from Geant4 using UI - #dd4hep_add_test_reg( CLICSiD_DDG4_GDML_LONGTEST - # COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" - # EXEC_ARGS python ${CLICSiDEx_INSTALL}/scripts/CLIC_GDML.py - # REQUIRES DDG4 Geant4 - # REGEX_PASS "G4GDML. Writing 'CLICSiD.gdml' done !" - # REGEX_FAIL "Exception;EXCEPTION;ERROR" ) + dd4hep_add_test_reg( CLICSiD_DDG4_GDML_LONGTEST + COMMAND "${CMAKE_INSTALL_PREFIX}/bin/run_test_CLICSiD.sh" + EXEC_ARGS python ${CLICSiDEx_INSTALL}/scripts/CLIC_GDML.py + REQUIRES DDG4 Geant4 + REGEX_PASS "G4GDML. Writing 'CLICSiD.gdml' done !" + REGEX_FAIL "Exception;EXCEPTION;ERROR" ) # # Material scan dd4hep_add_test_reg( CLICSiD_DDG4_g4material_scan_LONGTEST diff --git a/examples/CLICSiD/scripts/CLIC_G4Gun.py b/examples/CLICSiD/scripts/CLIC_G4Gun.py index 6964c4174..a860c8a4a 100644 --- a/examples/CLICSiD/scripts/CLIC_G4Gun.py +++ b/examples/CLICSiD/scripts/CLIC_G4Gun.py @@ -51,6 +51,11 @@ def run(): user.enableUI() part.adopt(user) # + # Setup the GDML writer action + writer = DDG4.Action(kernel,'Geant4GDMLWriteAction/Writer') + writer.enableUI() + kernel.registerGlobalAction(writer) + sid.setupDetectors() sid.setupPhysics('QGSP_BERT') sid.test_config() -- GitLab