Skip to content

Commit

Permalink
Fix the service retrieval after deprecations in Gaudi v39r1 (#74)
Browse files Browse the repository at this point in the history
* Fix the service retrieval after deprecations in Gaudi v39r1

* Make sure the service is retrieved

---------

Co-authored-by: jmcarcell <[email protected]>
  • Loading branch information
jmcarcell and jmcarcell authored Nov 4, 2024
1 parent 2e155ff commit b0b5f97
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 6 additions & 7 deletions SimG4Fast/src/components/SimG4ParticleSmearSimple.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#include "SimG4ParticleSmearSimple.h"

// Gaudi

#include "GaudiKernel/IRndmGenSvc.h"

// CLHEP
#include "CLHEP/Vector/ThreeVector.h"

Expand All @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions SimG4Fast/src/components/SimG4ParticleSmearSimple.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Gaudi
#include "GaudiKernel/AlgTool.h"
#include "GaudiKernel/RndmGenerators.h"
class IRndmGenSvc;
#include "GaudiKernel/IRndmGenSvc.h"

// FCCSW
#include "SimG4Interface/ISimG4ParticleSmearTool.h"
Expand Down Expand Up @@ -51,7 +51,7 @@ class SimG4ParticleSmearSimple : public AlgTool, virtual public ISimG4ParticleSm

private:
/// Random Number Service
IRndmGenSvc* m_randSvc;
SmartIF<IRndmGenSvc> 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)
Expand Down

0 comments on commit b0b5f97

Please sign in to comment.