Skip to content

Commit

Permalink
Fix service retrieval after deprecations in Gaudi v39r1 (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcarcell authored Nov 8, 2024
1 parent 120ea0d commit 4dad0b5
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 10 deletions.
3 changes: 1 addition & 2 deletions ARCdigi/include/ARCdigitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

// EDM4HEP
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/TrackCollection.h"
#if __has_include("edm4hep/TrackerHit3DCollection.h")
#include "edm4hep/TrackerHit3DCollection.h"
#else
Expand Down Expand Up @@ -63,7 +62,7 @@ class ARCdigitizer : public Gaudi::Algorithm {
// Detector geometry
dd4hep::Detector* m_detector;
// Random Number Service
IRndmGenSvc* m_randSvc;
SmartIF<IRndmGenSvc> m_randSvc;
// Uniform random number generator used for the SiPM quantum efficiency
Rndm::Numbers m_uniform;
};
3 changes: 2 additions & 1 deletion ARCdigi/src/ARCdigitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ StatusCode ARCdigitizer::initialize() {
return StatusCode::FAILURE;
}
// Initialize random number service
if (service("RndmGenSvc", m_randSvc).isFailure()) {
m_randSvc = service("RndmGenSvc", false);
if (!m_randSvc) {
error() << "Couldn't get RndmGenSvc!" << endmsg;
return StatusCode::FAILURE;
}
Expand Down
3 changes: 1 addition & 2 deletions DCHdigi/include/DCHsimpleDigitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

// EDM4HEP
#include "edm4hep/SimTrackerHitCollection.h"
#include "edm4hep/TrackCollection.h"
#if __has_include("edm4hep/TrackerHit3DCollection.h")
#include "edm4hep/TrackerHit3DCollection.h"
#else
Expand Down Expand Up @@ -75,7 +74,7 @@ class DCHsimpleDigitizer : public Gaudi::Algorithm {
FloatProperty m_xy_resolution{this, "xyResolution", 0.1, "Spatial resolution in the xy direction [mm]"};

// Random Number Service
IRndmGenSvc* m_randSvc;
SmartIF<IRndmGenSvc> m_randSvc;
// Gaussian random number generator used for the smearing of the z position
Rndm::Numbers m_gauss_z;
// Gaussian random number generator used for the smearing of the xy position
Expand Down
2 changes: 1 addition & 1 deletion DCHdigi/include/DCHsimpleDigitizerExtendedEdm.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class DCHsimpleDigitizerExtendedEdm : public Gaudi::Algorithm {
mutable DataHandle<podio::UserDataCollection<double>> m_rightHitSimHitDeltaLocalZ{"rightHitSimHitDeltaLocalZ", Gaudi::DataHandle::Writer, this}; // mm

// Random Number Service
IRndmGenSvc* m_randSvc;
SmartIF<IRndmGenSvc> m_randSvc;
// Gaussian random number generator used for the smearing of the z position
Rndm::Numbers m_gauss_z;
// Gaussian random number generator used for the smearing of the xy position
Expand Down
3 changes: 2 additions & 1 deletion DCHdigi/src/DCHsimpleDigitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ DCHsimpleDigitizer::~DCHsimpleDigitizer() {}

StatusCode DCHsimpleDigitizer::initialize() {
// Initialize random services
if (service("RndmGenSvc", m_randSvc).isFailure()) {
m_randSvc = service("RndmGenSvc", false);
if (!m_randSvc) {
error() << "Couldn't get RndmGenSvc!" << endmsg;
return StatusCode::FAILURE;
}
Expand Down
3 changes: 2 additions & 1 deletion DCHdigi/src/DCHsimpleDigitizerExtendedEdm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ DCHsimpleDigitizerExtendedEdm::~DCHsimpleDigitizerExtendedEdm() {}

StatusCode DCHsimpleDigitizerExtendedEdm::initialize() {
// Initialize random services
if (service("RndmGenSvc", m_randSvc).isFailure()) {
m_randSvc = service("RndmGenSvc", false);
if (!m_randSvc) {
error() << "Couldn't get RndmGenSvc!" << endmsg;
return StatusCode::FAILURE;
}
Expand Down
2 changes: 1 addition & 1 deletion VTXdigi/include/VTXdigitizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class VTXdigitizer : public Gaudi::Algorithm {
BooleanProperty m_forceHitsOntoSurface{this, "forceHitsOntoSurface", false, "Project hits onto the surface in case they are not yet on the surface (default: false"};

// Random Number Service
IRndmGenSvc* m_randSvc;
SmartIF<IRndmGenSvc> m_randSvc;

// Gaussian random number generator used for smearing
std::vector<Rndm::Numbers> m_gauss_x_vec;
Expand Down
3 changes: 2 additions & 1 deletion VTXdigi/src/VTXdigitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ VTXdigitizer::~VTXdigitizer() {}

StatusCode VTXdigitizer::initialize() {
// Initialize random services
if (service("RndmGenSvc", m_randSvc).isFailure()) {
m_randSvc = service("RndmGenSvc", false);
if (!m_randSvc) {
error() << "Couldn't get RndmGenSvc!" << endmsg;
return StatusCode::FAILURE;
}
Expand Down

0 comments on commit 4dad0b5

Please sign in to comment.