From 2b89a411b409eb159917377abd69c9ae719784cc Mon Sep 17 00:00:00 2001 From: Juan Miguel Carceller <22276694+jmcarcell@users.noreply.github.com> Date: Mon, 11 Nov 2024 22:05:14 +0100 Subject: [PATCH] Fix service retrieval after deprecations in Gaudi v39r1 (#124) * 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 --- .../src/components/CorrectECalBarrelSliWinCluster.cpp | 3 ++- RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.h | 2 +- RecCalorimeter/src/components/CreateCaloClusters.cpp | 3 ++- RecCalorimeter/src/components/CreateCaloClusters.h | 2 +- RecCalorimeter/src/components/MassInv.cpp | 3 ++- RecCalorimeter/src/components/MassInv.h | 2 +- RecCalorimeter/src/components/NoiseCaloCellsFlatTool.cpp | 3 ++- RecCalorimeter/src/components/NoiseCaloCellsFlatTool.h | 2 +- RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.cpp | 3 ++- RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.h | 2 +- .../src/components/NoiseCaloCellsVsThetaFromFileTool.cpp | 3 ++- .../src/components/NoiseCaloCellsVsThetaFromFileTool.h | 2 +- 12 files changed, 18 insertions(+), 12 deletions(-) diff --git a/RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.cpp b/RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.cpp index 20b5b7e4..d5e784d0 100644 --- a/RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.cpp +++ b/RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.cpp @@ -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; } diff --git a/RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.h b/RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.h index 21b4f275..53921b81 100644 --- a/RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.h +++ b/RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.h @@ -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 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 diff --git a/RecCalorimeter/src/components/CreateCaloClusters.cpp b/RecCalorimeter/src/components/CreateCaloClusters.cpp index df715288..2ad87a2e 100644 --- a/RecCalorimeter/src/components/CreateCaloClusters.cpp +++ b/RecCalorimeter/src/components/CreateCaloClusters.cpp @@ -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; } diff --git a/RecCalorimeter/src/components/CreateCaloClusters.h b/RecCalorimeter/src/components/CreateCaloClusters.h index 2b5b6c8f..70b53804 100644 --- a/RecCalorimeter/src/components/CreateCaloClusters.h +++ b/RecCalorimeter/src/components/CreateCaloClusters.h @@ -59,7 +59,7 @@ class CreateCaloClusters : public Gaudi::Algorithm { private: /// Pointer to the interface of histogram service - ITHistSvc* m_histSvc{nullptr}; + SmartIF m_histSvc; /// Pointer to the geometry service SmartIF m_geoSvc; diff --git a/RecCalorimeter/src/components/MassInv.cpp b/RecCalorimeter/src/components/MassInv.cpp index 1e761f60..4b9a45f2 100644 --- a/RecCalorimeter/src/components/MassInv.cpp +++ b/RecCalorimeter/src/components/MassInv.cpp @@ -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; } diff --git a/RecCalorimeter/src/components/MassInv.h b/RecCalorimeter/src/components/MassInv.h index 8c9830ed..32b07488 100644 --- a/RecCalorimeter/src/components/MassInv.h +++ b/RecCalorimeter/src/components/MassInv.h @@ -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 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 diff --git a/RecCalorimeter/src/components/NoiseCaloCellsFlatTool.cpp b/RecCalorimeter/src/components/NoiseCaloCellsFlatTool.cpp index 9803bea5..c9604b21 100644 --- a/RecCalorimeter/src/components/NoiseCaloCellsFlatTool.cpp +++ b/RecCalorimeter/src/components/NoiseCaloCellsFlatTool.cpp @@ -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; } diff --git a/RecCalorimeter/src/components/NoiseCaloCellsFlatTool.h b/RecCalorimeter/src/components/NoiseCaloCellsFlatTool.h index ab149de0..3db823af 100644 --- a/RecCalorimeter/src/components/NoiseCaloCellsFlatTool.h +++ b/RecCalorimeter/src/components/NoiseCaloCellsFlatTool.h @@ -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 m_randSvc; /// Gaussian random number generator used for smearing with a constant resolution (m_sigma) Rndm::Numbers m_gauss; }; diff --git a/RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.cpp b/RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.cpp index e086f877..517a5890 100644 --- a/RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.cpp +++ b/RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.cpp @@ -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; } diff --git a/RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.h b/RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.h index 23796416..8d830f95 100644 --- a/RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.h +++ b/RecCalorimeter/src/components/NoiseCaloCellsFromFileTool.h @@ -90,7 +90,7 @@ class NoiseCaloCellsFromFileTool : public AlgTool, virtual public INoiseCaloCell std::vector m_histoElecNoiseRMS; /// Random Number Service - IRndmGenSvc* m_randSvc; + SmartIF m_randSvc; /// Gaussian random number generator used for the generation of random noise hits Rndm::Numbers m_gauss; diff --git a/RecFCCeeCalorimeter/src/components/NoiseCaloCellsVsThetaFromFileTool.cpp b/RecFCCeeCalorimeter/src/components/NoiseCaloCellsVsThetaFromFileTool.cpp index edb058db..b09191a8 100644 --- a/RecFCCeeCalorimeter/src/components/NoiseCaloCellsVsThetaFromFileTool.cpp +++ b/RecFCCeeCalorimeter/src/components/NoiseCaloCellsVsThetaFromFileTool.cpp @@ -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; } diff --git a/RecFCCeeCalorimeter/src/components/NoiseCaloCellsVsThetaFromFileTool.h b/RecFCCeeCalorimeter/src/components/NoiseCaloCellsVsThetaFromFileTool.h index efbd99b5..8dec5baf 100644 --- a/RecFCCeeCalorimeter/src/components/NoiseCaloCellsVsThetaFromFileTool.h +++ b/RecFCCeeCalorimeter/src/components/NoiseCaloCellsVsThetaFromFileTool.h @@ -112,7 +112,7 @@ class NoiseCaloCellsVsThetaFromFileTool : public AlgTool, virtual public INoiseC std::vector m_histoElecNoiseOffset; /// Random Number Service - IRndmGenSvc* m_randSvc; + SmartIF m_randSvc; /// Gaussian random number generator used for the generation of random noise hits Rndm::Numbers m_gauss;