From 7f1dd936fc0442d1023bb63b0585ce2785170839 Mon Sep 17 00:00:00 2001 From: Juraj Smiesko <34742917+kjvbrt@users.noreply.github.com> Date: Tue, 24 Oct 2023 16:21:37 +0200 Subject: [PATCH] Use PublicToolHandleArray for save tools (#53) --- SimG4Components/src/SimG4Alg.cpp | 13 ++++++------- SimG4Components/src/SimG4Alg.h | 12 +++++------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/SimG4Components/src/SimG4Alg.cpp b/SimG4Components/src/SimG4Alg.cpp index 04641d4..52a2ba3 100644 --- a/SimG4Components/src/SimG4Alg.cpp +++ b/SimG4Components/src/SimG4Alg.cpp @@ -20,13 +20,12 @@ StatusCode SimG4Alg::initialize() { error() << "Unable to locate Geant Simulation Service" << endmsg; return StatusCode::FAILURE; } - for (auto& toolname : m_saveToolNames) { - m_saveTools.push_back(tool(toolname)); - // FIXME: check StatusCode once the m_saveTools is a ToolHandleArray - // if (!) { - // error() << "Unable to retrieve the output saving tool." << endmsg; - // return StatusCode::FAILURE; - // } + for (auto& saveTool : m_saveTools) { + if(!saveTool.retrieve()) { + error() << "Unable to retrieve the output saving tool " << saveTool + << endmsg; + return StatusCode::FAILURE; + } } if (!m_eventTool.retrieve()) { error() << "Unable to retrieve the G4Event provider " << m_eventTool << endmsg; diff --git a/SimG4Components/src/SimG4Alg.h b/SimG4Components/src/SimG4Alg.h index bb00f63..26d5266 100644 --- a/SimG4Components/src/SimG4Alg.h +++ b/SimG4Components/src/SimG4Alg.h @@ -53,12 +53,10 @@ class SimG4Alg : public GaudiAlgorithm { /// Pointer to the interface of Geant simulation service ServiceHandle m_geantSvc; /// Handle to the tools saving the output - /// to be replaced with the ToolHandleArray m_saveTools - std::vector m_saveTools; - /// Names for the saving tools - /// to be deleted once the ToolHandleArray m_saveTools is in place - Gaudi::Property> m_saveToolNames{this, "outputs", {}, "Names for the saving tools"}; - /// Handle for tool that creates the G4Event - ToolHandle m_eventTool{"SimG4PrimariesFromEdmTool", this}; + PublicToolHandleArray m_saveTools { + this, "outputs", {}}; + /// Handle for the tool that creates the G4Event + ToolHandle m_eventTool{ + "SimG4PrimariesFromEdmTool", this}; }; #endif /* SIMG4COMPONENTS_G4SIMALG_H */