From 1d4efab18abddc73abffc86cf23ccfd96498b51c Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Fri, 1 Nov 2024 17:39:00 +0100 Subject: [PATCH 1/4] Fix service retrieval after deprecations in Gaudi v39r1 see https://gitlab.cern.ch/gaudi/Gaudi/-/merge_requests/1637 --- .../src/components/CorrectECalBarrelSliWinCluster.cpp | 3 ++- RecCalorimeter/src/components/CorrectECalBarrelSliWinCluster.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 +- 10 files changed, 15 insertions(+), 10 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/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..1cc0b1e0 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", false); + 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; From 3fa9acdb64f0303d8329a3bf23f38d5605caa9ff Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Fri, 1 Nov 2024 18:03:57 +0100 Subject: [PATCH 2/4] Fix another instance of the deprecated retrieval --- RecCalorimeter/src/components/CreateCaloClusters.cpp | 3 ++- RecCalorimeter/src/components/CreateCaloClusters.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/RecCalorimeter/src/components/CreateCaloClusters.cpp b/RecCalorimeter/src/components/CreateCaloClusters.cpp index cab3f915..a939d1e1 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 8ecab012..d761796f 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; From 5ef0a847f05cd97ab26a766be1f73ebe0f1c3c07 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Fri, 1 Nov 2024 18:05:37 +0100 Subject: [PATCH 3/4] Fix typo --- RecCalorimeter/src/components/CreateCaloClusters.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecCalorimeter/src/components/CreateCaloClusters.cpp b/RecCalorimeter/src/components/CreateCaloClusters.cpp index a939d1e1..908ac746 100644 --- a/RecCalorimeter/src/components/CreateCaloClusters.cpp +++ b/RecCalorimeter/src/components/CreateCaloClusters.cpp @@ -50,7 +50,7 @@ StatusCode CreateCaloClusters::initialize() { } // Histogram service - m_histSvc = service("THistSvc", false): + m_histSvc = service("THistSvc", false); if (!m_histSvc) { error() << "Unable to locate Histogram Service" << endmsg; return StatusCode::FAILURE; From 2dfa0b9b1777aadd76994675517b8b1dd5739c7c Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Fri, 8 Nov 2024 18:00:49 +0100 Subject: [PATCH 4/4] Create the RandomGenSvc if it doesn't exist --- RecCalorimeter/src/components/NoiseCaloCellsFlatTool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RecCalorimeter/src/components/NoiseCaloCellsFlatTool.cpp b/RecCalorimeter/src/components/NoiseCaloCellsFlatTool.cpp index 1cc0b1e0..c9604b21 100644 --- a/RecCalorimeter/src/components/NoiseCaloCellsFlatTool.cpp +++ b/RecCalorimeter/src/components/NoiseCaloCellsFlatTool.cpp @@ -16,7 +16,7 @@ StatusCode NoiseCaloCellsFlatTool::initialize() { } // Initialize random service - m_randSvc = service("RndmGenSvc", false); + m_randSvc = service("RndmGenSvc", true); if (!m_randSvc) { error() << "Couldn't get RndmGenSvc" << endmsg; return StatusCode::FAILURE;