diff --git a/DDDigi/src/DigiStoreDump.cpp b/DDDigi/src/DigiStoreDump.cpp index 84ab134c1e9ee0b8e604302295aeab20b0e2ddf8..d3144fae47889e4fe49274a8559f931a10455c7a 100644 --- a/DDDigi/src/DigiStoreDump.cpp +++ b/DDDigi/src/DigiStoreDump.cpp @@ -216,12 +216,12 @@ DigiStoreDump::dump_history(DigiContext& context, Key container_key, const T& co } std::vector<std::string> -DigiStoreDump::dump_deposit_history(DigiContext& context, Key container_key, const DepositMapping& container) const { - std::size_t count = 0; +DigiStoreDump::dump_deposit_history(DigiContext& /*context*/, Key container_key, const DepositMapping& container) const { std::vector<std::string> records; auto line = format("|---- %s", data_header(container_key, "deposits", container).c_str()); records.emplace_back(line); #ifdef DDDIGI_INPLACE_HISTORY + std::size_t count = 0; for( const auto& item : container ) { auto rec = dump_history(context, container_key, item, count++); records.insert(records.end(), rec.begin(), rec.end()); @@ -231,12 +231,12 @@ DigiStoreDump::dump_deposit_history(DigiContext& context, Key container_key, con } std::vector<std::string> -DigiStoreDump::dump_deposit_history(DigiContext& context, Key container_key, const DepositVector& container) const { - std::size_t count = 0; +DigiStoreDump::dump_deposit_history(DigiContext& /*context*/, Key container_key, const DepositVector& container) const { std::vector<std::string> records; auto line = format("|---- %s", data_header(container_key, "deposits", container).c_str()); records.emplace_back(line); #ifdef DDDIGI_INPLACE_HISTORY + std::size_t count = 0; for( const auto& item : container ) { auto rec = dump_history(context, container_key, item, count++); records.insert(records.end(), rec.begin(), rec.end()); diff --git a/DDG4/python/DDG4.py b/DDG4/python/DDG4.py index d396a1af58bbd7fd53d89428f6e0063bfebc1709..84a50de6265ff5cbbe957c8aa05c6628ac76091f 100644 --- a/DDG4/python/DDG4.py +++ b/DDG4/python/DDG4.py @@ -134,11 +134,14 @@ def _registerGlobalFilter(self, filter): def _evalProperty(data): """ Function necessary to extract real strings from the property value. - Strings may be emraced by quotes: '<value>' + Strings may be embraced by quotes: '<value>' """ try: if isinstance(data, str): - return eval(data) + import ast + return ast.literal_eval(data) + except ValueError: + pass except TypeError: pass finally: diff --git a/DDG4/src/Geant4Kernel.cpp b/DDG4/src/Geant4Kernel.cpp index bc42fb39fb4dca32ca0ff783022f038901963a61..64c1f2c2b55faa19a8d5bd53e379cc83b5cff9f5 100644 --- a/DDG4/src/Geant4Kernel.cpp +++ b/DDG4/src/Geant4Kernel.cpp @@ -12,22 +12,22 @@ //========================================================================== // Framework include files -#include "DD4hep/Detector.h" -#include "DD4hep/Memory.h" -#include "DD4hep/Plugins.h" -#include "DD4hep/Printout.h" -#include "DD4hep/Primitives.h" -#include "DD4hep/InstanceCount.h" +#include <DD4hep/Detector.h> +#include <DD4hep/Memory.h> +#include <DD4hep/Plugins.h> +#include <DD4hep/Printout.h> +#include <DD4hep/Primitives.h> +#include <DD4hep/InstanceCount.h> -#include "DDG4/Geant4Kernel.h" -#include "DDG4/Geant4Context.h" -#include "DDG4/Geant4ActionPhase.h" +#include <DDG4/Geant4Kernel.h> +#include <DDG4/Geant4Context.h> +#include <DDG4/Geant4ActionPhase.h> // Geant4 include files -#include "G4RunManager.hh" -#include "G4UIdirectory.hh" -#include "G4Threading.hh" -#include "G4AutoLock.hh" +#include <G4RunManager.hh> +#include <G4UIdirectory.hh> +#include <G4Threading.hh> +#include <G4AutoLock.hh> // C/C++ include files #include <stdexcept> diff --git a/DDG4/src/Geant4UIManager.cpp b/DDG4/src/Geant4UIManager.cpp index c02e8dd71afe9e2e9e8d227d602f5df03644dd3c..449da0cbdac146c6b20272e8014ed24a085b0ed5 100644 --- a/DDG4/src/Geant4UIManager.cpp +++ b/DDG4/src/Geant4UIManager.cpp @@ -76,8 +76,11 @@ void Geant4UIManager::configure() { } /// Execute the chained command statements for(const auto& c : m_configureCommands) { - info("++ Executing configure command:%s",c.c_str()); - mgr->ApplyCommand(c.c_str()); + info("++ Executing configure command: %s",c.c_str()); + G4int ret = mgr->ApplyCommand(c.c_str()); + if ( ret != 0 ) { + except("Failed to execute command: %s",c.c_str()); + } } } @@ -87,8 +90,11 @@ void Geant4UIManager::initialize() { G4UImanager* mgr = G4UImanager::GetUIpointer(); /// Execute the chained command statements for(const auto& c : m_initializeCommands) { - info("++ Executing initialization command:%s",c.c_str()); - mgr->ApplyCommand(c.c_str()); + info("++ Executing initialization command: %s",c.c_str()); + G4int ret = mgr->ApplyCommand(c.c_str()); + if ( ret != 0 ) { + except("Failed to execute command: %s",c.c_str()); + } } } @@ -98,8 +104,11 @@ void Geant4UIManager::terminate() { G4UImanager* mgr = G4UImanager::GetUIpointer(); /// Execute the chained command statements for(const auto& c : m_terminateCommands) { - info("++ Executing finalization command:%s",c.c_str()); - mgr->ApplyCommand(c.c_str()); + info("++ Executing finalization command: %s",c.c_str()); + G4int ret = mgr->ApplyCommand(c.c_str()); + if ( ret != 0 ) { + except("Failed to execute command: %s",c.c_str()); + } } } @@ -109,8 +118,11 @@ void Geant4UIManager::applyCommand(const string& command) { G4UImanager* mgr = G4UImanager::GetUIpointer(); if ( mgr ) { info("++ Executing G4 command: %s",command.c_str()); - mgr->ApplyCommand(command.c_str()); - return; + G4int ret = mgr->ApplyCommand(command.c_str()); + if ( ret == 0 ) { + return; + } + except("Failed to execute command: %s",command.c_str()); } except("No UI reference present. Too early to interact with Geant4!"); } @@ -180,24 +192,24 @@ void Geant4UIManager::start() { } /// Configure visualization instance if ( !m_visSetup.empty() ) { - info("++ Executing visualization setup:%s",m_visSetup.c_str()); + info("++ Executing visualization setup: %s",m_visSetup.c_str()); mgr->ApplyCommand(make_cmd(m_visSetup).c_str()); } /// Configure UI instance if ( !m_uiSetup.empty() ) { - info("++ Executing UI setup:%s",m_uiSetup.c_str()); + info("++ Executing UI setup: %s",m_uiSetup.c_str()); mgr->ApplyCommand(make_cmd(m_uiSetup).c_str()); executed_statements = true; } /// Execute the chained macro files for(const auto& m : m_macros) { - info("++ Executing Macro file:%s",m.c_str()); + info("++ Executing Macro file: %s",m.c_str()); mgr->ApplyCommand(make_cmd(m.c_str())); executed_statements = true; } /// Execute the chained pre-run command statements for(const auto& c : m_preRunCommands) { - info("++ Executing pre-run statement:%s",c.c_str()); + info("++ Executing pre-run statement: %s",c.c_str()); mgr->ApplyCommand(c.c_str()); executed_statements = true; } @@ -206,7 +218,7 @@ void Geant4UIManager::start() { m_ui->SessionStart(); /// Execute the chained post-run command statements for(const auto& c : m_postRunCommands) { - info("++ Executing post-run statement:%s",c.c_str()); + info("++ Executing post-run statement: %s",c.c_str()); mgr->ApplyCommand(c.c_str()); executed_statements = true; } @@ -219,7 +231,7 @@ void Geant4UIManager::start() { else if ( executed_statements ) { /// Execute the chained post-run command statements for(const auto& c : m_postRunCommands) { - info("++ Executing post-run statement:%s",c.c_str()); + info("++ Executing post-run statement: %s",c.c_str()); mgr->ApplyCommand(c.c_str()); } return;