diff --git a/Generators/TruthIO/TruthIO/HepMCReadFromFile.h b/Generators/TruthIO/TruthIO/HepMCReadFromFile.h index 02d74c51f0722766d5b366256d95c586f6362a01..6e17eab4641be1a19586ee2fb20aa08421065f8d 100644 --- a/Generators/TruthIO/TruthIO/HepMCReadFromFile.h +++ b/Generators/TruthIO/TruthIO/HepMCReadFromFile.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration */ #ifndef TRUTHIO_HEPMCREADFROMFILE_H @@ -15,9 +15,9 @@ class HepMCReadFromFile : public GenBase { public: HepMCReadFromFile(const std::string& name, ISvcLocator* pSvcLocator); - StatusCode initialize(); - StatusCode execute(); - StatusCode finalize(); + virtual StatusCode initialize() override; + virtual StatusCode execute() override; + virtual StatusCode finalize() override; private: @@ -25,8 +25,6 @@ private: int m_event_number; double m_sum_xs; - StoreGateSvc* m_sgSvc; - #ifdef HEPMC3 std::shared_ptr<HepMC3::Reader> m_hepmcio; #else diff --git a/Generators/TruthIO/src/HepMCReadFromFile.cxx b/Generators/TruthIO/src/HepMCReadFromFile.cxx index ac213e2fd3fd491eb519b941783d3725f8a597b1..b9a698e6d983a509c17d936b2988b3fbf41455c1 100644 --- a/Generators/TruthIO/src/HepMCReadFromFile.cxx +++ b/Generators/TruthIO/src/HepMCReadFromFile.cxx @@ -15,8 +15,7 @@ HepMCReadFromFile::HepMCReadFromFile(const std::string& name, ISvcLocator* pSvcLocator) : - GenBase(name, pSvcLocator), - m_sgSvc(0) + GenBase(name, pSvcLocator) { declareProperty("InputFile", m_input_file="events.hepmc"); m_event_number = 0; @@ -27,12 +26,6 @@ HepMCReadFromFile::HepMCReadFromFile(const std::string& name, ISvcLocator* pSvcL StatusCode HepMCReadFromFile::initialize() { CHECK(GenBase::initialize()); - StatusCode sc = service("StoreGateSvc", m_sgSvc); - if (sc.isFailure()) { - msg(MSG::ERROR) << "Could not find StoreGateSvc" << endmsg; - return sc; - } - // Initialize input file and event number #ifdef HEPMC3 m_hepmcio = HepMC3::deduce_reader(m_input_file); @@ -48,13 +41,13 @@ StatusCode HepMCReadFromFile::execute() { McEventCollection* mcEvtColl = nullptr; - if ( m_sgSvc->contains<McEventCollection>(m_mcEventKey) && m_sgSvc->retrieve(mcEvtColl, m_mcEventKey).isSuccess() ) { + if ( evtStore()->contains<McEventCollection>(m_mcEventKey) && evtStore()->retrieve(mcEvtColl, m_mcEventKey).isSuccess() ) { if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "found an McEventCollecion in store" << endmsg; } else { // McCollection doesn't exist. Create it (empty) if (msgLvl(MSG::VERBOSE)) msg(MSG::VERBOSE) << "create new McEventCollecion in store" << endmsg; mcEvtColl = new McEventCollection; - StatusCode status = m_sgSvc->record( mcEvtColl, m_mcEventKey ); + StatusCode status = evtStore()->record( mcEvtColl, m_mcEventKey ); if (status.isFailure()) { msg(MSG::ERROR) << "Could not record McEventCollection" << endmsg; return status; diff --git a/Generators/TruthIO/src/HepMcTupleWriterTool.cxx b/Generators/TruthIO/src/HepMcTupleWriterTool.cxx index 2e3cd4c697683e1df5da784f0227ea3872386f3c..23e888e63a1a058bfb227446dcaec391ebb1c021 100755 --- a/Generators/TruthIO/src/HepMcTupleWriterTool.cxx +++ b/Generators/TruthIO/src/HepMcTupleWriterTool.cxx @@ -152,9 +152,8 @@ StatusCode HepMcTupleWriterTool::write( const HepMC::GenEvent* evt ) void HepMcTupleWriterTool::setupBackend( Gaudi::Details::PropertyBase& /*m_outputFileName*/ ) { - const bool createIf = false; - IProperty * tSvc = nullptr; - if ( !service( m_tupleSvc.name(), tSvc, createIf ).isSuccess() ) { + SmartIF<IProperty> tSvc{m_tupleSvc.get()}; + if ( !tSvc ) { ATH_MSG_ERROR("Could not retrieve THistSvc handle !!"); throw GaudiException( "Could not retrieve THistSvc", name(), StatusCode::FAILURE ); }