From b0b5f978dd20d17327eba9fc3a495a55bcf4ea1d Mon Sep 17 00:00:00 2001 From: Juan Miguel Carceller <22276694+jmcarcell@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:01:04 +0100 Subject: [PATCH] Fix the service retrieval after deprecations in Gaudi v39r1 (#74) * Fix the service retrieval after deprecations in Gaudi v39r1 * Make sure the service is retrieved --------- Co-authored-by: jmcarcell --- .../src/components/SimG4ParticleSmearSimple.cpp | 13 ++++++------- SimG4Fast/src/components/SimG4ParticleSmearSimple.h | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/SimG4Fast/src/components/SimG4ParticleSmearSimple.cpp b/SimG4Fast/src/components/SimG4ParticleSmearSimple.cpp index 1a5a616..b824a68 100644 --- a/SimG4Fast/src/components/SimG4ParticleSmearSimple.cpp +++ b/SimG4Fast/src/components/SimG4ParticleSmearSimple.cpp @@ -1,9 +1,5 @@ #include "SimG4ParticleSmearSimple.h" -// Gaudi - -#include "GaudiKernel/IRndmGenSvc.h" - // CLHEP #include "CLHEP/Vector/ThreeVector.h" @@ -18,11 +14,14 @@ SimG4ParticleSmearSimple::SimG4ParticleSmearSimple(const std::string& type, cons SimG4ParticleSmearSimple::~SimG4ParticleSmearSimple() {} StatusCode SimG4ParticleSmearSimple::initialize() { - if (AlgTool::initialize().isFailure()) { + + m_randSvc = service("RndmGenSvc", false); + if (!m_randSvc) { + error() << "Couldn't get RndmGenSvc" << endmsg; return StatusCode::FAILURE; } - if (service("RndmGenSvc", m_randSvc).isFailure()) { - error() << "Couldn't get RndmGenSvc" << endmsg; + + if (AlgTool::initialize().isFailure()) { return StatusCode::FAILURE; } m_gauss.initialize(m_randSvc, Rndm::Gauss(1, m_sigma)).ignore(); diff --git a/SimG4Fast/src/components/SimG4ParticleSmearSimple.h b/SimG4Fast/src/components/SimG4ParticleSmearSimple.h index 5b2850e..beba9b2 100644 --- a/SimG4Fast/src/components/SimG4ParticleSmearSimple.h +++ b/SimG4Fast/src/components/SimG4ParticleSmearSimple.h @@ -4,7 +4,7 @@ // Gaudi #include "GaudiKernel/AlgTool.h" #include "GaudiKernel/RndmGenerators.h" -class IRndmGenSvc; +#include "GaudiKernel/IRndmGenSvc.h" // FCCSW #include "SimG4Interface/ISimG4ParticleSmearTool.h" @@ -51,7 +51,7 @@ class SimG4ParticleSmearSimple : public AlgTool, virtual public ISimG4ParticleSm private: /// Random Number Service - IRndmGenSvc* m_randSvc; + SmartIF m_randSvc; /// Gaussian random number generator used for smearing with a constant resolution (m_sigma) Rndm::Numbers m_gauss; /// Constant resolution for the smearing (set by job options)