diff --git a/Simulation/G4Atlas/G4AtlasAlg/G4AtlasAlg/G4AtlasRunManager.h b/Simulation/G4Atlas/G4AtlasAlg/G4AtlasAlg/G4AtlasRunManager.h index b5a1ff6923913e26199b5ad95eec65d105e66a30..df7b8df2abcbd526dc61f980f658ef6abbfec25d 100644 --- a/Simulation/G4Atlas/G4AtlasAlg/G4AtlasAlg/G4AtlasRunManager.h +++ b/Simulation/G4Atlas/G4AtlasAlg/G4AtlasAlg/G4AtlasRunManager.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef G4ATLASALG_G4AtlasRunManager_h @@ -17,7 +17,6 @@ #include "G4AtlasInterfaces/ISensitiveDetectorMasterTool.h" #include "G4AtlasInterfaces/IFastSimulationMasterTool.h" #include "G4AtlasInterfaces/IPhysicsListSvc.h" -#include "G4AtlasInterfaces/IUserActionSvc.h" #include "G4AtlasInterfaces/IDetectorGeometrySvc.h" #include "G4AtlasInterfaces/IFluxRecorder.h" @@ -41,13 +40,6 @@ public: /// G4 function called at end of run void RunTermination() override final; - - /// @name Methods to pass configuration in from G4AtlasAlg - /// @{ - /// Configure the user action service handle - void SetUserActionSvc(const std::string& typeAndName) { - m_userActionSvc.setTypeAndName(typeAndName); - } /// Configure the detector geometry service handle void SetDetGeoSvc(const std::string& typeAndName) { @@ -103,12 +95,10 @@ private: ToolHandle<IFastSimulationMasterTool> m_fastSimTool; ServiceHandle<IPhysicsListSvc> m_physListSvc; - /// Handle to the user action service - ServiceHandle<G4UA::IUserActionSvc> m_userActionSvc; ServiceHandle<IDetectorGeometrySvc> m_detGeoSvc; - + /// Interface to flux recording - + std::unique_ptr<IFluxRecorder> m_fluxRecorder; }; diff --git a/Simulation/G4Atlas/G4AtlasAlg/G4AtlasAlg/G4AtlasUserWorkerThreadInitialization.h b/Simulation/G4Atlas/G4AtlasAlg/G4AtlasAlg/G4AtlasUserWorkerThreadInitialization.h index f8983ee6fd775515e9289b356eed5b45b6d0800c..107901ae2b85de797bbb1158fb7de7390afe3893 100644 --- a/Simulation/G4Atlas/G4AtlasAlg/G4AtlasAlg/G4AtlasUserWorkerThreadInitialization.h +++ b/Simulation/G4Atlas/G4AtlasAlg/G4AtlasAlg/G4AtlasUserWorkerThreadInitialization.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef G4ATLASALG_G4ATLASUSERWORKERTHREADINITIALIZATION_H @@ -32,11 +32,6 @@ public: /// @name Methods to pass configuration in from G4AtlasAlg /// @{ - /// Configure the user action service handle - void SetUserActionSvc(const std::string& typeAndName) { - m_userActionSvcName = typeAndName; - } - /// Configure the detector geometry service handle void SetDetGeoSvc(const std::string& typeAndName) { m_detGeoSvcName = typeAndName; @@ -56,7 +51,6 @@ private: std::string m_detGeoSvcName{"DetectorGeometrySvc"}; std::string m_senDetToolName{"SensitiveDetectorMasterTool"}; std::string m_fastSimToolName{"FastSimulationMasterTool"}; - std::string m_userActionSvcName{"G4UA::UserActionSvc"}; }; // class G4AtlasUserWorkerThreadInitialization diff --git a/Simulation/G4Atlas/G4AtlasAlg/G4AtlasAlg/G4AtlasWorkerRunManager.h b/Simulation/G4Atlas/G4AtlasAlg/G4AtlasAlg/G4AtlasWorkerRunManager.h index 93bc9c448a025658f63a513b88239b87a710e7cc..e9e93601809eb345f885c7297a8e7d3f361bb2f0 100644 --- a/Simulation/G4Atlas/G4AtlasAlg/G4AtlasAlg/G4AtlasWorkerRunManager.h +++ b/Simulation/G4Atlas/G4AtlasAlg/G4AtlasAlg/G4AtlasWorkerRunManager.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #ifndef G4ATLASALG_G4ATLASWORKERRUNMANAGER_H @@ -18,7 +18,6 @@ #include "G4AtlasInterfaces/IDetectorGeometrySvc.h" #include "G4AtlasInterfaces/ISensitiveDetectorMasterTool.h" #include "G4AtlasInterfaces/IFastSimulationMasterTool.h" -#include "G4AtlasInterfaces/IUserActionSvc.h" /// @brief ATLAS worker run manager for master-slave multi-threading model @@ -41,11 +40,6 @@ public: /// @name Methods to pass configuration in from G4AtlasUserWorkerThreadInitialization /// @{ - /// Configure the user action service handle - void SetUserActionSvc(const std::string& typeAndName) { - m_userActionSvc.setTypeAndName(typeAndName); - } - /// Configure the detector geometry service handle void SetDetGeoSvc(const std::string& typeAndName) { m_detGeoSvc.setTypeAndName(typeAndName); @@ -97,9 +91,6 @@ private: /// Handle to the FastSim tool ToolHandle<IFastSimulationMasterTool> m_fastSimTool; - /// Handle to the user action service - ServiceHandle<G4UA::IUserActionSvc> m_userActionSvc; - }; #endif // G4MULTITHREADED diff --git a/Simulation/G4Atlas/G4AtlasAlg/src/G4AtlasAlg.cxx b/Simulation/G4Atlas/G4AtlasAlg/src/G4AtlasAlg.cxx index 6cdac043e136aedb6cb75e03d352961f71ea7efe..1f5ee78cbff1246a026e9b5b7614744ddfa50d5d 100644 --- a/Simulation/G4Atlas/G4AtlasAlg/src/G4AtlasAlg.cxx +++ b/Simulation/G4Atlas/G4AtlasAlg/src/G4AtlasAlg.cxx @@ -1,10 +1,11 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // Local includes #include "G4AtlasAlg.h" #include "G4AtlasFluxRecorder.h" +#include "G4AtlasAlg/G4AtlasActionInitialization.h" #include "AthenaKernel/RNGWrapper.h" @@ -121,11 +122,13 @@ void G4AtlasAlg::initializeOnce() // Worker Thread initialization used to create worker run manager on demand. std::unique_ptr<G4AtlasUserWorkerThreadInitialization> workerInit = std::make_unique<G4AtlasUserWorkerThreadInitialization>(); - workerInit->SetUserActionSvc( m_userActionSvc.typeAndName() ); workerInit->SetDetGeoSvc( m_detGeoSvc.typeAndName() ); workerInit->SetSDMasterTool( m_senDetTool.typeAndName() ); workerInit->SetFastSimMasterTool( m_fastSimTool.typeAndName() ); runMgr->SetUserInitialization( workerInit.release() ); + std::unique_ptr<G4AtlasActionInitialization> actionInitialization = + std::make_unique<G4AtlasActionInitialization>(&*m_userActionSvc); + runMgr->SetUserInitialization(actionInitialization.release()); #else throw std::runtime_error("Trying to use multi-threading in non-MT build!"); #endif @@ -136,11 +139,13 @@ void G4AtlasAlg::initializeOnce() m_physListSvc->SetPhysicsList(); runMgr->SetRecordFlux( m_recordFlux, std::make_unique<G4AtlasFluxRecorder>() ); runMgr->SetLogLevel( int(msg().level()) ); // Synch log levels - runMgr->SetUserActionSvc( m_userActionSvc.typeAndName() ); runMgr->SetDetGeoSvc( m_detGeoSvc.typeAndName() ); runMgr->SetSDMasterTool(m_senDetTool.typeAndName() ); runMgr->SetFastSimMasterTool(m_fastSimTool.typeAndName() ); runMgr->SetPhysListSvc(m_physListSvc.typeAndName() ); + std::unique_ptr<G4AtlasActionInitialization> actionInitialization = + std::make_unique<G4AtlasActionInitialization>(&*m_userActionSvc); + runMgr->SetUserInitialization(actionInitialization.release()); } // G4 user interface commands diff --git a/Simulation/G4Atlas/G4AtlasAlg/src/G4AtlasRunManager.cxx b/Simulation/G4Atlas/G4AtlasAlg/src/G4AtlasRunManager.cxx index 399ce45aaf84e05a3353da8a68c38670e1f114c3..7a538629ad0c7d9680d226d2f74c3f7e9a753c95 100644 --- a/Simulation/G4Atlas/G4AtlasAlg/src/G4AtlasRunManager.cxx +++ b/Simulation/G4Atlas/G4AtlasAlg/src/G4AtlasRunManager.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ #include "G4AtlasAlg/G4AtlasRunManager.h" @@ -27,7 +27,6 @@ G4AtlasRunManager::G4AtlasRunManager() , m_senDetTool("SensitiveDetectorMasterTool") , m_fastSimTool("FastSimulationMasterTool") , m_physListSvc("PhysicsListSvc", "G4AtlasRunManager") - , m_userActionSvc("G4UA::UserActionSvc", "G4AtlasRunManager") , m_detGeoSvc("DetectorGeometrySvc", "G4AtlasRunManager") { } @@ -42,26 +41,10 @@ G4AtlasRunManager* G4AtlasRunManager::GetG4AtlasRunManager() void G4AtlasRunManager::Initialize() { - const std::string methodName = "G4AtlasRunManager::Initialize"; - // ADA 11/28.2018: switch initialization order to meet ISF requirements // Call the base class Initialize method. This will call // InitializeGeometry and InitializePhysics. G4RunManager::Initialize(); - - // Setup the user actions now. - if( !m_userActionSvc.name().empty() ) { - ATH_MSG_INFO("Creating user actions now"); - if(m_userActionSvc.retrieve().isFailure()) { - throw GaudiException("Could not retrieve UserActionSvc", - methodName, StatusCode::FAILURE); - } - if(m_userActionSvc->initializeActions().isFailure()) { - throw GaudiException("Failed to initialize actions", - methodName, StatusCode::FAILURE); - } - } - } diff --git a/Simulation/G4Atlas/G4AtlasAlg/src/G4AtlasUserWorkerThreadInitialization.cxx b/Simulation/G4Atlas/G4AtlasAlg/src/G4AtlasUserWorkerThreadInitialization.cxx index 4e52944fbd798a1d92048d513563f70b39f378d1..dd0ea43feb8532901bb0177226215e3e059cb302 100644 --- a/Simulation/G4Atlas/G4AtlasAlg/src/G4AtlasUserWorkerThreadInitialization.cxx +++ b/Simulation/G4Atlas/G4AtlasAlg/src/G4AtlasUserWorkerThreadInitialization.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // Hide multi-threading classes from builds without G4MT @@ -14,7 +14,6 @@ CreateWorkerRunManager() const { // TODO: maybe better to just use the pseudo-singleton mechanism auto* workerRunManager = G4AtlasWorkerRunManager::GetG4AtlasWorkerRunManager(); - workerRunManager->SetUserActionSvc(m_userActionSvcName); workerRunManager->SetDetGeoSvc(m_detGeoSvcName); workerRunManager->SetSDMasterTool(m_senDetToolName); workerRunManager->SetFastSimMasterTool(m_fastSimToolName); diff --git a/Simulation/G4Atlas/G4AtlasAlg/src/G4AtlasWorkerRunManager.cxx b/Simulation/G4Atlas/G4AtlasAlg/src/G4AtlasWorkerRunManager.cxx index a8df9171b80dd4b936ee355b60838319e81545b1..28c651b654f7596db107d63b4f771fe353cd6a8e 100644 --- a/Simulation/G4Atlas/G4AtlasAlg/src/G4AtlasWorkerRunManager.cxx +++ b/Simulation/G4Atlas/G4AtlasAlg/src/G4AtlasWorkerRunManager.cxx @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ // Hide multi-threading classes from builds without G4MT @@ -36,7 +36,6 @@ G4AtlasWorkerRunManager::G4AtlasWorkerRunManager() , m_detGeoSvc("DetectorGeometrySvc", "G4AtlasWorkerRunManager") , m_senDetTool("SensitiveDetectorMasterTool") , m_fastSimTool("FastSimulationMasterTool") - , m_userActionSvc("G4UA::UserActionSvc", "G4AtlasWorkerRunManager") {} @@ -54,18 +53,6 @@ void G4AtlasWorkerRunManager::Initialize() // Locking this initialization to protect currently thread-unsafe services std::lock_guard<std::mutex> lock(workerInitMutex); - const std::string methodName = "G4AtlasWorkerRunManager::Initialize"; - - // Setup the user actions for current worker thread. - if(m_userActionSvc.retrieve().isFailure()) { - throw GaudiException("Could not retrieve UserActionSvc for worker thread", - methodName, StatusCode::FAILURE); - } - if(m_userActionSvc->initializeActions().isFailure()) { - throw GaudiException("Failed to initialize actions for worker thread", - methodName, StatusCode::FAILURE); - } - // Setup geometry and physics via the base class G4RunManager::Initialize(); @@ -84,6 +71,7 @@ void G4AtlasWorkerRunManager::Initialize() ** will have to be thoroughly reviewed. */ ATH_MSG_DEBUG("G4 Command: Trying at the end of Initialize()"); + const std::string methodName = "G4AtlasWorkerRunManager::Initialize"; G4MTRunManager* masterRM = G4MTRunManager::GetMasterRunManager(); std::vector<G4String> cmds = masterRM->GetCommandStack(); G4UImanager* uimgr = G4UImanager::GetUIpointer(); diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/G4LegacyTransportTool.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/G4LegacyTransportTool.cxx index 8502dcaa70b2bd83340d3a424e0900a7f1a60359..4dbc60e91e746066bf3e4b691ed80e3b957d7378 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/G4LegacyTransportTool.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/G4LegacyTransportTool.cxx @@ -7,6 +7,7 @@ //package includes #include "G4AtlasAlg/G4AtlasRunManager.h" +#include "G4AtlasAlg/G4AtlasActionInitialization.h" #include "ISFFluxRecorder.h" #include "AthenaKernel/RNGWrapper.h" @@ -118,11 +119,13 @@ void iGeant4::G4LegacyTransportTool::initializeOnce() m_pRunMgr->SetRecordFlux( m_recordFlux, std::make_unique<ISFFluxRecorder>() ); m_pRunMgr->SetLogLevel( int(msg().level()) ); // Synch log levels - m_pRunMgr->SetUserActionSvc( m_userActionSvc.typeAndName() ); m_pRunMgr->SetDetGeoSvc( m_detGeoSvc.typeAndName() ); m_pRunMgr->SetSDMasterTool(m_senDetTool.typeAndName() ); m_pRunMgr->SetFastSimMasterTool(m_fastSimTool.typeAndName() ); m_pRunMgr->SetPhysListSvc(m_physListSvc.typeAndName() ); + std::unique_ptr<G4AtlasActionInitialization> actionInitialization = + std::make_unique<G4AtlasActionInitialization>(&*m_userActionSvc); + m_pRunMgr->SetUserInitialization(actionInitialization.release()); G4UImanager *ui = G4UImanager::GetUIpointer(); diff --git a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.cxx b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.cxx index 11d066c1a01218983704defdf97490b1424f3cda..1eeef3c0b97326a1ec29d412e2f54ebc014f87b6 100644 --- a/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.cxx +++ b/Simulation/ISF/ISF_Geant4/ISF_Geant4Tools/src/TransportTool.cxx @@ -10,6 +10,7 @@ #include "G4AtlasAlg/G4AtlasWorkerRunManager.h" #include "G4AtlasAlg/G4AtlasUserWorkerThreadInitialization.h" #include "G4AtlasAlg/G4AtlasRunManager.h" +#include "G4AtlasAlg/G4AtlasActionInitialization.h" #include "ISFFluxRecorder.h" #include "AthenaKernel/RNGWrapper.h" @@ -121,11 +122,13 @@ void iGeant4::G4TransportTool::initializeOnce() // Worker Thread initialization used to create worker run manager on demand. std::unique_ptr<G4AtlasUserWorkerThreadInitialization> workerInit = std::make_unique<G4AtlasUserWorkerThreadInitialization>(); - workerInit->SetUserActionSvc( m_userActionSvc.typeAndName() ); workerInit->SetDetGeoSvc( m_detGeoSvc.typeAndName() ); workerInit->SetSDMasterTool( m_senDetTool.typeAndName() ); workerInit->SetFastSimMasterTool( m_fastSimTool.typeAndName() ); runMgr->SetUserInitialization( workerInit.release() ); + std::unique_ptr<G4AtlasActionInitialization> actionInitialization = + std::make_unique<G4AtlasActionInitialization>(&*m_userActionSvc); + runMgr->SetUserInitialization(actionInitialization.release()); #else throw std::runtime_error("Trying to use multi-threading in non-MT build!"); #endif @@ -136,11 +139,13 @@ void iGeant4::G4TransportTool::initializeOnce() m_physListSvc->SetPhysicsList(); runMgr->SetRecordFlux( m_recordFlux, std::make_unique<ISFFluxRecorder>() ); runMgr->SetLogLevel( int(msg().level()) ); // Synch log levels - runMgr->SetUserActionSvc( m_userActionSvc.typeAndName() ); runMgr->SetDetGeoSvc( m_detGeoSvc.typeAndName() ); runMgr->SetSDMasterTool(m_senDetTool.typeAndName() ); runMgr->SetFastSimMasterTool(m_fastSimTool.typeAndName() ); runMgr->SetPhysListSvc(m_physListSvc.typeAndName() ); + std::unique_ptr<G4AtlasActionInitialization> actionInitialization = + std::make_unique<G4AtlasActionInitialization>(&*m_userActionSvc); + runMgr->SetUserInitialization(actionInitialization.release()); } G4UImanager *ui = G4UImanager::GetUIpointer();