Skip to content

Commit

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

see https://gitlab.cern.ch/gaudi/Gaudi/-/merge_requests/1637

* Fix another instance of the deprecated retrieval

* Fix typo

* Create the RandomGenSvc if it doesn't exist

---------

Co-authored-by: jmcarcell <[email protected]>
  • Loading branch information
jmcarcell and jmcarcell authored Nov 11, 2024
1 parent 5646fd1 commit 2b89a41
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ StatusCode CorrectECalBarrelSliWinCluster::initialize() {
m_decoder.insert (std::make_pair(m_systemId[iSys], m_geoSvc->getDetector()->readout(m_readoutName[iSys]).idSpec().decoder()));
}
// Initialize random 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
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class CorrectECalBarrelSliWinCluster : public Gaudi::Algorithm {
/// Histogram of pileup noise added to energy of clusters
mutable TH1F* m_hPileupEnergy;
/// Random Number Service
IRndmGenSvc* m_randSvc;
SmartIF<IRndmGenSvc> m_randSvc;
/// Gaussian random number generator used for the generation of random noise hits
Rndm::Numbers m_gauss;
/// Name of the file with noise constants
Expand Down
3 changes: 2 additions & 1 deletion RecCalorimeter/src/components/CreateCaloClusters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ StatusCode CreateCaloClusters::initialize() {
}

// Histogram service
if (service("THistSvc", m_histSvc).isFailure()) {
m_histSvc = service("THistSvc", false);
if (!m_histSvc) {
error() << "Unable to locate Histogram Service" << endmsg;
return StatusCode::FAILURE;
}
Expand Down
2 changes: 1 addition & 1 deletion RecCalorimeter/src/components/CreateCaloClusters.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CreateCaloClusters : public Gaudi::Algorithm {

private:
/// Pointer to the interface of histogram service
ITHistSvc* m_histSvc{nullptr};
SmartIF<ITHistSvc> m_histSvc;
/// Pointer to the geometry service
SmartIF<IGeoSvc> m_geoSvc;

Expand Down
3 changes: 2 additions & 1 deletion RecCalorimeter/src/components/MassInv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ StatusCode MassInv::initialize() {
m_decoder.insert (std::make_pair(m_systemId[iSys], m_geoSvc->getDetector()->readout(m_readoutName[iSys]).idSpec().decoder()));
}
// Initialize random 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
2 changes: 1 addition & 1 deletion RecCalorimeter/src/components/MassInv.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class MassInv : public Gaudi::Algorithm {
/// Histogram of pileup noise added to energy of clusters
TH1F* m_hPileupEnergy;
/// Random Number Service
IRndmGenSvc* m_randSvc;
SmartIF<IRndmGenSvc> m_randSvc;
/// Gaussian random number generator used for the generation of random noise hits
Rndm::Numbers m_gauss;
/// Name of the file with noise constants
Expand Down
3 changes: 2 additions & 1 deletion RecCalorimeter/src/components/NoiseCaloCellsFlatTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ StatusCode NoiseCaloCellsFlatTool::initialize() {
}

// Initialize random service
if (service("RndmGenSvc", m_randSvc).isFailure()) {
m_randSvc = service("RndmGenSvc", true);
if (!m_randSvc) {
error() << "Couldn't get RndmGenSvc" << endmsg;
return StatusCode::FAILURE;
}
Expand Down
2 changes: 1 addition & 1 deletion RecCalorimeter/src/components/NoiseCaloCellsFlatTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class NoiseCaloCellsFlatTool : public AlgTool, virtual public INoiseCaloCellsToo
this, "filterNoiseThreshold", 3,
"remove cells with energy below offset + threshold * noise RMS"};
/// 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;
};
Expand Down
3 changes: 2 additions & 1 deletion RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ StatusCode NoiseCaloCellsFromFileTool::initialize() {
}

// Initialize random 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
2 changes: 1 addition & 1 deletion RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class NoiseCaloCellsFromFileTool : public AlgTool, virtual public INoiseCaloCell
std::vector<TH1F> m_histoElecNoiseRMS;

/// Random Number Service
IRndmGenSvc* m_randSvc;
SmartIF<IRndmGenSvc> m_randSvc;
/// Gaussian random number generator used for the generation of random noise hits
Rndm::Numbers m_gauss;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ StatusCode NoiseCaloCellsVsThetaFromFileTool::initialize() {
}

// Initialize random 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
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class NoiseCaloCellsVsThetaFromFileTool : public AlgTool, virtual public INoiseC
std::vector<TH1F> m_histoElecNoiseOffset;

/// Random Number Service
IRndmGenSvc* m_randSvc;
SmartIF<IRndmGenSvc> m_randSvc;
/// Gaussian random number generator used for the generation of random noise hits
Rndm::Numbers m_gauss;

Expand Down

0 comments on commit 2b89a41

Please sign in to comment.