From befeb60711046ad94a9d8987ed99da9accf8b75b Mon Sep 17 00:00:00 2001 From: Juan Miguel Carceller <22276694+jmcarcell@users.noreply.github.com> Date: Fri, 1 Nov 2024 14:46:15 +0100 Subject: [PATCH] Update service retrieval after deprecations in Gaudi v39.1 (#256) --- k4FWCore/src/PodioDataSvc.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/k4FWCore/src/PodioDataSvc.cpp b/k4FWCore/src/PodioDataSvc.cpp index d0372d3a..dd26f960 100644 --- a/k4FWCore/src/PodioDataSvc.cpp +++ b/k4FWCore/src/PodioDataSvc.cpp @@ -59,13 +59,12 @@ StatusCode PodioDataSvc::initialize() { m_metadataframe = podio::Frame(); } - IProperty* property; - auto sc = service("ApplicationMgr", property); - if (sc == StatusCode::FAILURE) { - error() << "Could not get ApplicationMgr properties" << std::endl; + auto appMgr = service("ApplicationMgr", false); + if (!appMgr) { + throw std::runtime_error("Could not get ApplicationMgr"); } Gaudi::Property evtMax; - evtMax.assign(property->getProperty("EvtMax")); + evtMax.assign(appMgr->getProperty("EvtMax")); m_requestedEventMax = evtMax; m_requestedEventMax -= m_1stEvtEntry; @@ -133,11 +132,15 @@ void PodioDataSvc::endOfRead() { if (m_eventNum >= m_numAvailableEvents) { info() << "Reached end of file with event " << m_eventNum << " (" << m_requestedEventMax << " events requested)" << endmsg; - IEventProcessor* eventProcessor; - sc = service("ApplicationMgr", eventProcessor); + auto eventProcessor = service("ApplicationMgr", false); + if (!eventProcessor) { + throw std::runtime_error("Could not retrieve ApplicationMgr to schedule a stop"); + } sc = eventProcessor->stopRun(); + if (sc.isFailure()) { + throw std::runtime_error("Failed to stop the run"); + } } - // todo: figure out sthg to do with sc (added to silence -Wunused-result) } /// Standard Constructor