From 703406b058b607c7bda7cd46102957671d07966f Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Mon, 9 Dec 2024 10:19:57 +0100 Subject: [PATCH 1/8] Multiple minor fixes: - Don't use the deprecated service retrieval - Add override when possible and use the default destructors instead of implementing them --- .../k4MarlinWrapper/converters/EDM4hep2Lcio.h | 13 ++++--------- .../k4MarlinWrapper/converters/Lcio2EDM4hep.h | 2 +- k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp | 2 -- k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp | 6 +----- k4MarlinWrapper/src/components/LcioEventAlgo.cpp | 8 ++++---- .../src/components/MarlinProcessorWrapper.cpp | 8 ++++---- 6 files changed, 14 insertions(+), 25 deletions(-) diff --git a/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h b/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h index e36cc9d6..a116b279 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h +++ b/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h @@ -19,20 +19,15 @@ #ifndef K4MARLINWRAPPER_EDM4HEP2LCIO_H #define K4MARLINWRAPPER_EDM4HEP2LCIO_H -// k4MarlinWrapper #include "k4MarlinWrapper/converters/IEDMConverter.h" -// FWCore #include -//k4EDM4hep2LcioConv #include "k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h" -// GAUDI #include #include -// std #include #include #include @@ -58,11 +53,11 @@ struct CollectionPairMappings; class EDM4hep2LcioTool : public AlgTool, virtual public IEDMConverter { public: EDM4hep2LcioTool(const std::string& type, const std::string& name, const IInterface* parent); - virtual ~EDM4hep2LcioTool(); - virtual StatusCode initialize(); - virtual StatusCode finalize(); + ~EDM4hep2LcioTool() override = default; + StatusCode initialize() override; + StatusCode finalize() override; - StatusCode convertCollections(lcio::LCEventImpl* lcio_event); + StatusCode convertCollections(lcio::LCEventImpl* lcio_event) override; private: Gaudi::Property> m_collNames{this, "collNameMapping", {}}; diff --git a/k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h b/k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h index fdc7f17d..b4e2f8d4 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h +++ b/k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h @@ -46,7 +46,7 @@ namespace EVENT { class Lcio2EDM4hepTool : public AlgTool, virtual public IEDMConverter { public: Lcio2EDM4hepTool(const std::string& type, const std::string& name, const IInterface* parent); - virtual ~Lcio2EDM4hepTool(); + ~Lcio2EDM4hepTool() override = default; StatusCode initialize() final; StatusCode finalize() final; diff --git a/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp b/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp index 793ecb64..1cf7dc01 100644 --- a/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp +++ b/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp @@ -53,8 +53,6 @@ EDM4hep2LcioTool::EDM4hep2LcioTool(const std::string& type, const std::string& n declareInterface(this); } -EDM4hep2LcioTool::~EDM4hep2LcioTool() { ; } - StatusCode EDM4hep2LcioTool::initialize() { StatusCode sc = m_eventDataSvc.retrieve(); m_podioDataSvc = dynamic_cast(m_eventDataSvc.get()); diff --git a/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp b/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp index 3224394a..f851d362 100644 --- a/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp +++ b/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp @@ -40,12 +40,8 @@ using namespace k4MarlinWrapper; Lcio2EDM4hepTool::Lcio2EDM4hepTool(const std::string& type, const std::string& name, const IInterface* parent) : AlgTool(type, name, parent), m_eds("EventDataSvc", "Lcio2EDM4hepTool") { declareInterface(this); - - StatusCode sc = m_eds.retrieve(); } -Lcio2EDM4hepTool::~Lcio2EDM4hepTool() { ; } - StatusCode Lcio2EDM4hepTool::initialize() { m_podioDataSvc = dynamic_cast(m_eds.get()); if (nullptr == m_podioDataSvc) @@ -198,7 +194,7 @@ StatusCode Lcio2EDM4hepTool::convertCollections(lcio::LCEventImpl* the_event) { error() << "Could not convert collection " << lcioName << " (type: " << lcio_coll_type_str << ")" << endmsg; } } - } catch (const lcio::DataNotAvailableException& ex) { + } catch (const lcio::DataNotAvailableException&) { warning() << "LCIO Collection " << lcioName << " not found in the event, skipping conversion to EDM4hep" << endmsg; continue; diff --git a/k4MarlinWrapper/src/components/LcioEventAlgo.cpp b/k4MarlinWrapper/src/components/LcioEventAlgo.cpp index 476b3627..ae7e04ed 100644 --- a/k4MarlinWrapper/src/components/LcioEventAlgo.cpp +++ b/k4MarlinWrapper/src/components/LcioEventAlgo.cpp @@ -52,10 +52,10 @@ StatusCode LcioEvent::execute(const EventContext&) const { return scStatus; } - IEventProcessor* evt = nullptr; - if (service("ApplicationMgr", evt, true).isSuccess()) { - evt->stopRun().ignore(); - evt->release(); + auto svc = service("ApplicationMgr"); + if (svc) { + svc->stopRun().ignore(); + svc->release(); } else { abort(); } diff --git a/k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp b/k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp index 329ade25..93a4b9df 100644 --- a/k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp +++ b/k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp @@ -297,10 +297,10 @@ StatusCode MarlinProcessorWrapper::execute(const EventContext&) const { error() << e.what() << endmsg; // Send stop to EventProcessor - IEventProcessor* evt = nullptr; - if (service("ApplicationMgr", evt, true).isSuccess()) { - evt->stopRun().ignore(); - evt->release(); + auto svc = service("ApplicationMgr"); + if (svc) { + svc->stopRun().ignore(); + svc->release(); } else { abort(); } From c5cfaeffebabc17cf60509f5c075ff0600cd7d6f Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Mon, 9 Dec 2024 10:58:37 +0100 Subject: [PATCH 2/8] Revert removing an extra line, add an error message --- k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp b/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp index f851d362..0654e4d1 100644 --- a/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp +++ b/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp @@ -40,6 +40,11 @@ using namespace k4MarlinWrapper; Lcio2EDM4hepTool::Lcio2EDM4hepTool(const std::string& type, const std::string& name, const IInterface* parent) : AlgTool(type, name, parent), m_eds("EventDataSvc", "Lcio2EDM4hepTool") { declareInterface(this); + + StatusCode sc = m_eds.retrieve(); + if (sc.isFailure()) { + error() << "Could not retrieve EventDataSvc" << endmsg; + } } StatusCode Lcio2EDM4hepTool::initialize() { From 809f99dc5e3496a449239f7a7f94fe66a97f6e5e Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Mon, 9 Dec 2024 11:10:17 +0100 Subject: [PATCH 3/8] Use ! instead of not --- k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp b/k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp index 93a4b9df..61050882 100644 --- a/k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp +++ b/k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp @@ -131,12 +131,12 @@ std::shared_ptr MarlinProcessorWrapper::parseParameter StatusCode MarlinProcessorWrapper::instantiateProcessor(std::shared_ptr& parameters, Gaudi::Property& processorTypeStr) { auto processorType = marlin::ProcessorMgr::instance()->getProcessor(processorTypeStr); - if (not processorType) { + if (!processorType) { error() << " Failed to instantiate " << name() << " because processor type could not be determined" << endmsg; return StatusCode::FAILURE; } m_processor = processorType->newProcessor(); - if (not m_processor) { + if (!m_processor) { error() << " Failed to instantiate " << name() << endmsg; return StatusCode::FAILURE; } @@ -215,7 +215,7 @@ StatusCode MarlinProcessorWrapper::execute(const EventContext&) const { StatusCode scStatus = eventSvc()->retrieveObject("/Event/LCEventStatus", pStatus); if (scStatus.isSuccess()) { bool hasLCEvent = static_cast(pStatus)->hasLCEvent; - if (not hasLCEvent) { + if (!hasLCEvent) { warning() << "LCIO Event reading returned nullptr, so MarlinProcessorWrapper won't execute" << endmsg; return StatusCode::SUCCESS; } From 2f960385f9228a989b2bdde018d849174523428c Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Mon, 9 Dec 2024 11:30:51 +0100 Subject: [PATCH 4/8] Don't compare to nullptr --- k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp | 4 ++-- k4MarlinWrapper/src/components/LcioEventAlgo.cpp | 2 +- k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp b/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp index 0654e4d1..078d6479 100644 --- a/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp +++ b/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp @@ -49,7 +49,7 @@ Lcio2EDM4hepTool::Lcio2EDM4hepTool(const std::string& type, const std::string& n StatusCode Lcio2EDM4hepTool::initialize() { m_podioDataSvc = dynamic_cast(m_eds.get()); - if (nullptr == m_podioDataSvc) + if (!m_podioDataSvc) return StatusCode::FAILURE; return AlgTool::initialize(); @@ -74,7 +74,7 @@ bool Lcio2EDM4hepTool::collectionExist(const std::string& collection_name) { void Lcio2EDM4hepTool::registerCollection( std::tuple> namedColl, EVENT::LCCollection* lcioColl) { auto& [name, e4hColl] = namedColl; - if (e4hColl == nullptr) { + if (!e4hColl) { error() << "Could not convert collection " << name << endmsg; return; } diff --git a/k4MarlinWrapper/src/components/LcioEventAlgo.cpp b/k4MarlinWrapper/src/components/LcioEventAlgo.cpp index ae7e04ed..6f04d3b3 100644 --- a/k4MarlinWrapper/src/components/LcioEventAlgo.cpp +++ b/k4MarlinWrapper/src/components/LcioEventAlgo.cpp @@ -41,7 +41,7 @@ StatusCode LcioEvent::initialize() { StatusCode LcioEvent::execute(const EventContext&) const { auto theEvent = m_reader->readNextEvent(EVENT::LCIO::UPDATE); - if (theEvent == nullptr) { + if (!theEvent) { // Store flag to indicate there was NOT a LCEvent auto pStatus = std::make_unique(false); const StatusCode scStatus = eventSvc()->registerObject("/Event/LCEventStatus", pStatus.release()); diff --git a/k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp b/k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp index 61050882..4d896de6 100644 --- a/k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp +++ b/k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp @@ -81,7 +81,7 @@ StatusCode MarlinProcessorWrapper::loadProcessorLibraries() const { // Load all libraries from the marlin_dll info() << "looking for marlindll" << endmsg; const char* const marlin_dll = getenv("MARLIN_DLL"); - if (marlin_dll == nullptr) { + if (!marlin_dll) { warning() << "MARLIN_DLL not set, not loading any processors " << endmsg; } else { info() << "Found marlin_dll " << marlin_dll << endmsg; From 81c9fdc52489a046f3c26f53588c5697aa50f142 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Mon, 9 Dec 2024 21:17:08 +0100 Subject: [PATCH 5/8] Set the environment for all the tests at once --- test/CMakeLists.txt | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 37061743..42578912 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -98,28 +98,15 @@ add_test( event_header_conversion bash -c "k4run ${CMAKE_CURRENT_SOURCE_DIR}/gau ExternalData_Add_Target(marlinwrapper_tests) -set_tests_properties ( - simple_processors - simple_processors2 - clicRec - converter_constants - all_events_bounds - over_total_events - same_num_io - clicRec_lcio_mt - clicRec_edm4hep_input - clic_geo_test - global_converter_maps - event_header_conversion - link_conversion_edm4hep_to_lcio +get_property(test_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS) +set_tests_properties(${test_names} PROPERTIES ENVIRONMENT +"TEST_DIR=${CMAKE_CURRENT_SOURCE_DIR};LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib64:$ENV{LD_LIBRARY_PATH};PYTHONPATH=${CMAKE_INSTALL_PREFIX}/python:$ENV{PYTHONPATH};EXAMPLE_DIR=${PROJECT_SOURCE_DIR}/k4MarlinWrapper/examples;MARLIN_DLL=$ENV{MARLIN_DLL}:${CMAKE_CURRENT_BINARY_DIR}/libMarlinTestProcessors.so" +) + +set_tests_properties( + clicRec clicRec_lcio_mt clicRec_edm4hep_input PROPERTIES - ENVIRONMENT "TEST_DIR=${CMAKE_CURRENT_SOURCE_DIR};LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib64:$ENV{LD_LIBRARY_PATH};PYTHONPATH=${CMAKE_INSTALL_PREFIX}/python:$ENV{PYTHONPATH};EXAMPLE_DIR=${PROJECT_SOURCE_DIR}/k4MarlinWrapper/examples;MARLIN_DLL=$ENV{MARLIN_DLL}:${CMAKE_CURRENT_BINARY_DIR}/libMarlinTestProcessors.so" - ) - - set_tests_properties( - clicRec clicRec_lcio_mt clicRec_edm4hep_input - PROPERTIES - DEPENDS CLICPerformance_setup - ) + DEPENDS CLICPerformance_setup +) From be38a79f94014dce8d5441dbcea46b1932292746 Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Tue, 10 Dec 2024 08:48:10 +0100 Subject: [PATCH 6/8] Remove the remaining default destructors and fix includes --- .../k4MarlinWrapper/LCEventWrapper.h | 2 -- .../k4MarlinWrapper/LcioEventAlgo.h | 14 ++++++-------- .../k4MarlinWrapper/LcioEventOutput.h | 18 ++++++++++-------- .../k4MarlinWrapper/MarlinProcessorWrapper.h | 13 +++---------- .../TrackingCellIDEncodingSvc.h | 5 +---- .../k4MarlinWrapper/converters/EDM4hep2Lcio.h | 5 ++--- .../src/components/EDM4hep2Lcio.cpp | 1 + .../src/components/LcioEventAlgo.cpp | 14 ++++++++++++-- .../src/components/LcioEventOutput.cpp | 6 ++++++ .../src/components/MarlinProcessorWrapper.cpp | 4 ++++ .../components/TrackingCellIDEncodingSvc.cpp | 6 +++--- test/CMakeLists.txt | 2 +- 12 files changed, 49 insertions(+), 41 deletions(-) diff --git a/k4MarlinWrapper/k4MarlinWrapper/LCEventWrapper.h b/k4MarlinWrapper/k4MarlinWrapper/LCEventWrapper.h index 8df4b61c..aa04b7c7 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/LCEventWrapper.h +++ b/k4MarlinWrapper/k4MarlinWrapper/LCEventWrapper.h @@ -30,8 +30,6 @@ class LCEventWrapper : public DataObject { public: LCEventWrapper(std::unique_ptr&& theEvent) : m_event(std::move(theEvent)) {} - ~LCEventWrapper() = default; - EVENT::LCEvent* getEvent() const { return m_event.get(); } private: diff --git a/k4MarlinWrapper/k4MarlinWrapper/LcioEventAlgo.h b/k4MarlinWrapper/k4MarlinWrapper/LcioEventAlgo.h index 20aaad46..7b589613 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/LcioEventAlgo.h +++ b/k4MarlinWrapper/k4MarlinWrapper/LcioEventAlgo.h @@ -26,19 +26,17 @@ */ #include -#include +#include -#include -#include - -#include "k4MarlinWrapper/LCEventWrapper.h" +namespace MT { + class LCReader; +} class LcioEvent : public Gaudi::Algorithm { public: explicit LcioEvent(const std::string& name, ISvcLocator* pSL); - virtual ~LcioEvent() = default; - virtual StatusCode initialize() override final; - virtual StatusCode execute(const EventContext&) const override; + StatusCode initialize() override final; + StatusCode execute(const EventContext&) const override; private: Gaudi::Property> m_fileNames{this, "Files", {}}; diff --git a/k4MarlinWrapper/k4MarlinWrapper/LcioEventOutput.h b/k4MarlinWrapper/k4MarlinWrapper/LcioEventOutput.h index 4a2cb65c..92d42cf1 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/LcioEventOutput.h +++ b/k4MarlinWrapper/k4MarlinWrapper/LcioEventOutput.h @@ -24,25 +24,27 @@ // LCEventOutput: Write out LCIO events using MT writer from LCIO //////////////////////////////////////////// -#include - #include +#include #include #include #include -#include #include -#include "k4MarlinWrapper/LCEventWrapper.h" +#include +#include + +namespace MT { + class LCWriter; +} class LcioEventOutput : public Gaudi::Algorithm { public: explicit LcioEventOutput(const std::string& name, ISvcLocator* pSL); - virtual ~LcioEventOutput() = default; - virtual StatusCode initialize() override final; - virtual StatusCode execute(const EventContext&) const final; - virtual StatusCode finalize() override final; + StatusCode initialize() override final; + StatusCode execute(const EventContext&) const final; + StatusCode finalize() override final; private: MT::LCWriter* m_writer = nullptr; diff --git a/k4MarlinWrapper/k4MarlinWrapper/MarlinProcessorWrapper.h b/k4MarlinWrapper/k4MarlinWrapper/MarlinProcessorWrapper.h index 4a4d344a..9e0ba1b5 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/MarlinProcessorWrapper.h +++ b/k4MarlinWrapper/k4MarlinWrapper/MarlinProcessorWrapper.h @@ -19,22 +19,18 @@ #ifndef K4MARLINWRAPPER_MARLINPROCESSORWRAPPER_H #define K4MARLINWRAPPER_MARLINPROCESSORWRAPPER_H -// std #include #include -// Gaudi #include #include #include #include #include -// LCIO #include #include -// Marlin #include #include #include @@ -42,10 +38,8 @@ #include #include -// ROOT #include -// k4MarlinWrapper #include "k4MarlinWrapper/converters/IEDMConverter.h" namespace marlin { @@ -56,10 +50,9 @@ namespace marlin { class MarlinProcessorWrapper : public Gaudi::Algorithm { public: explicit MarlinProcessorWrapper(const std::string& name, ISvcLocator* pSL); - virtual ~MarlinProcessorWrapper() = default; - virtual StatusCode execute(const EventContext&) const override final; - virtual StatusCode finalize() override final; - virtual StatusCode initialize() override final; + StatusCode execute(const EventContext&) const override final; + StatusCode finalize() override final; + StatusCode initialize() override final; private: std::string m_verbosity = "ERROR"; diff --git a/k4MarlinWrapper/k4MarlinWrapper/TrackingCellIDEncodingSvc.h b/k4MarlinWrapper/k4MarlinWrapper/TrackingCellIDEncodingSvc.h index 8eacb3b5..c5b3727d 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/TrackingCellIDEncodingSvc.h +++ b/k4MarlinWrapper/k4MarlinWrapper/TrackingCellIDEncodingSvc.h @@ -19,11 +19,9 @@ #ifndef CELLIDSVC_H #define CELLIDSVC_H +#include #include -//LCIO Includes -#include - #include class IGeoSvc; @@ -32,7 +30,6 @@ class TrackingCellIDEncodingSvc : public extends { public: TrackingCellIDEncodingSvc(const std::string& name, ISvcLocator* svc); - ~TrackingCellIDEncodingSvc(); StatusCode initialize() final; StatusCode finalize() final; diff --git a/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h b/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h index a116b279..9e4f5293 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h +++ b/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h @@ -21,8 +21,6 @@ #include "k4MarlinWrapper/converters/IEDMConverter.h" -#include - #include "k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h" #include @@ -32,6 +30,8 @@ #include #include +class PodioDataSvc; + template using ObjMapT = k4EDM4hep2LcioConv::VecMapT; using TrackMap = ObjMapT; @@ -53,7 +53,6 @@ struct CollectionPairMappings; class EDM4hep2LcioTool : public AlgTool, virtual public IEDMConverter { public: EDM4hep2LcioTool(const std::string& type, const std::string& name, const IInterface* parent); - ~EDM4hep2LcioTool() override = default; StatusCode initialize() override; StatusCode finalize() override; diff --git a/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp b/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp index 1cf7dc01..2f9eb39c 100644 --- a/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp +++ b/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp @@ -23,6 +23,7 @@ #include "k4FWCore/DataHandle.h" #include "k4FWCore/MetaDataHandle.h" +#include "k4FWCore/PodioDataSvc.h" #include "GaudiKernel/AnyDataWrapper.h" diff --git a/k4MarlinWrapper/src/components/LcioEventAlgo.cpp b/k4MarlinWrapper/src/components/LcioEventAlgo.cpp index 6f04d3b3..5394effa 100644 --- a/k4MarlinWrapper/src/components/LcioEventAlgo.cpp +++ b/k4MarlinWrapper/src/components/LcioEventAlgo.cpp @@ -17,9 +17,19 @@ * limitations under the License. */ -#include "k4MarlinWrapper/LcioEventAlgo.h" +#include + #include "k4MarlinWrapper/LCEventWrapper.h" -#include "k4MarlinWrapper/util/k4MarlinWrapperUtil.h" +#include "k4MarlinWrapper/LcioEventAlgo.h" + +#include "marlin/Global.h" +#include "marlin/StringParameters.h" + +#include +#include + +#include +#include DECLARE_COMPONENT(LcioEvent) diff --git a/k4MarlinWrapper/src/components/LcioEventOutput.cpp b/k4MarlinWrapper/src/components/LcioEventOutput.cpp index 74b0593e..6e69711a 100644 --- a/k4MarlinWrapper/src/components/LcioEventOutput.cpp +++ b/k4MarlinWrapper/src/components/LcioEventOutput.cpp @@ -17,8 +17,14 @@ * limitations under the License. */ +#include + +#include "k4MarlinWrapper/LCEventWrapper.h" #include "k4MarlinWrapper/LcioEventOutput.h" +#include +#include + DECLARE_COMPONENT(LcioEventOutput) LcioEventOutput::LcioEventOutput(const std::string& name, ISvcLocator* pSL) : Gaudi::Algorithm(name, pSL) {} diff --git a/k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp b/k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp index 4d896de6..c596b822 100644 --- a/k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp +++ b/k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp @@ -22,6 +22,10 @@ #include "k4MarlinWrapper/LCEventWrapper.h" #include "k4MarlinWrapper/util/k4MarlinWrapperUtil.h" +#include +#include +#include + DECLARE_COMPONENT(MarlinProcessorWrapper) MarlinProcessorWrapper::MarlinProcessorWrapper(const std::string& name, ISvcLocator* pSL) diff --git a/k4MarlinWrapper/src/components/TrackingCellIDEncodingSvc.cpp b/k4MarlinWrapper/src/components/TrackingCellIDEncodingSvc.cpp index 45e1b549..83d8e7ed 100644 --- a/k4MarlinWrapper/src/components/TrackingCellIDEncodingSvc.cpp +++ b/k4MarlinWrapper/src/components/TrackingCellIDEncodingSvc.cpp @@ -16,9 +16,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + +#include + #include "k4MarlinWrapper/TrackingCellIDEncodingSvc.h" -// k4fwcore #include #include @@ -28,8 +30,6 @@ DECLARE_COMPONENT(TrackingCellIDEncodingSvc); TrackingCellIDEncodingSvc::TrackingCellIDEncodingSvc(const std::string& name, ISvcLocator* svc) : base_class(name, svc) {} -TrackingCellIDEncodingSvc::~TrackingCellIDEncodingSvc() {} - StatusCode TrackingCellIDEncodingSvc::initialize() { try { info() << "Looking for GeoSvc with the name" << m_geoSvcName.value() << endmsg; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 42578912..723187ee 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -99,7 +99,7 @@ add_test( event_header_conversion bash -c "k4run ${CMAKE_CURRENT_SOURCE_DIR}/gau ExternalData_Add_Target(marlinwrapper_tests) get_property(test_names DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY TESTS) -set_tests_properties(${test_names} PROPERTIES ENVIRONMENT +set_tests_properties(${test_names} PROPERTIES ENVIRONMENT "TEST_DIR=${CMAKE_CURRENT_SOURCE_DIR};LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:${CMAKE_INSTALL_PREFIX}/lib64:$ENV{LD_LIBRARY_PATH};PYTHONPATH=${CMAKE_INSTALL_PREFIX}/python:$ENV{PYTHONPATH};EXAMPLE_DIR=${PROJECT_SOURCE_DIR}/k4MarlinWrapper/examples;MARLIN_DLL=$ENV{MARLIN_DLL}:${CMAKE_CURRENT_BINARY_DIR}/libMarlinTestProcessors.so" ) From 8c1ae10509a565dd61f82a2daa353395244e485e Mon Sep 17 00:00:00 2001 From: jmcarcell Date: Tue, 10 Dec 2024 10:38:28 +0100 Subject: [PATCH 7/8] Remove another default destructor and do some clean up in Lcio2EDM4hep --- k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h | 8 ++------ k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp | 1 + 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h b/k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h index b4e2f8d4..ffe44232 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h +++ b/k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h @@ -19,14 +19,9 @@ #ifndef K4MARLINWRAPPER_LCIO2EDM4HEP_H #define K4MARLINWRAPPER_LCIO2EDM4HEP_H -// GAUDI #include #include -// k4FWCore -#include - -// Converter Interface #include "k4MarlinWrapper/converters/IEDMConverter.h" #include @@ -43,10 +38,11 @@ namespace EVENT { class LCCollection; } +class PodioDataSvc; + class Lcio2EDM4hepTool : public AlgTool, virtual public IEDMConverter { public: Lcio2EDM4hepTool(const std::string& type, const std::string& name, const IInterface* parent); - ~Lcio2EDM4hepTool() override = default; StatusCode initialize() final; StatusCode finalize() final; diff --git a/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp b/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp index 078d6479..c843c4a5 100644 --- a/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp +++ b/k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp @@ -28,6 +28,7 @@ #include #include +#include #include "GaudiKernel/AnyDataWrapper.h" From 243a0417f5f09f856032a0d4b203d666b8b94a7b Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Tue, 10 Dec 2024 16:38:21 +0100 Subject: [PATCH 8/8] Use final consistently throughout all classes --- k4MarlinWrapper/k4MarlinWrapper/LcioEventAlgo.h | 6 +++--- k4MarlinWrapper/k4MarlinWrapper/LcioEventOutput.h | 4 ++-- k4MarlinWrapper/k4MarlinWrapper/MarlinProcessorWrapper.h | 8 ++++---- k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h | 6 +++--- k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h | 2 +- test/src/MarlinMCRecoLinkChecker.cc | 4 ++-- test/src/PseudoRecoAlgorithm.cc | 2 +- test/src/TrivialMCRecoLinker.cc | 2 +- test/src/TrivialMCTruthLinkerProcessor.h | 4 ++-- 9 files changed, 19 insertions(+), 19 deletions(-) diff --git a/k4MarlinWrapper/k4MarlinWrapper/LcioEventAlgo.h b/k4MarlinWrapper/k4MarlinWrapper/LcioEventAlgo.h index 7b589613..7ed13f75 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/LcioEventAlgo.h +++ b/k4MarlinWrapper/k4MarlinWrapper/LcioEventAlgo.h @@ -35,13 +35,13 @@ namespace MT { class LcioEvent : public Gaudi::Algorithm { public: explicit LcioEvent(const std::string& name, ISvcLocator* pSL); - StatusCode initialize() override final; - StatusCode execute(const EventContext&) const override; + StatusCode initialize() final; + StatusCode execute(const EventContext&) const final; private: Gaudi::Property> m_fileNames{this, "Files", {}}; MT::LCReader* m_reader = nullptr; - bool isReEntrant() const override { return false; } + bool isReEntrant() const final { return false; } }; #endif diff --git a/k4MarlinWrapper/k4MarlinWrapper/LcioEventOutput.h b/k4MarlinWrapper/k4MarlinWrapper/LcioEventOutput.h index 92d42cf1..be47f951 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/LcioEventOutput.h +++ b/k4MarlinWrapper/k4MarlinWrapper/LcioEventOutput.h @@ -42,9 +42,9 @@ namespace MT { class LcioEventOutput : public Gaudi::Algorithm { public: explicit LcioEventOutput(const std::string& name, ISvcLocator* pSL); - StatusCode initialize() override final; + StatusCode initialize() final; StatusCode execute(const EventContext&) const final; - StatusCode finalize() override final; + StatusCode finalize() final; private: MT::LCWriter* m_writer = nullptr; diff --git a/k4MarlinWrapper/k4MarlinWrapper/MarlinProcessorWrapper.h b/k4MarlinWrapper/k4MarlinWrapper/MarlinProcessorWrapper.h index 9e0ba1b5..a3f8e555 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/MarlinProcessorWrapper.h +++ b/k4MarlinWrapper/k4MarlinWrapper/MarlinProcessorWrapper.h @@ -50,9 +50,9 @@ namespace marlin { class MarlinProcessorWrapper : public Gaudi::Algorithm { public: explicit MarlinProcessorWrapper(const std::string& name, ISvcLocator* pSL); - StatusCode execute(const EventContext&) const override final; - StatusCode finalize() override final; - StatusCode initialize() override final; + StatusCode execute(const EventContext&) const final; + StatusCode finalize() final; + StatusCode initialize() final; private: std::string m_verbosity = "ERROR"; @@ -78,7 +78,7 @@ class MarlinProcessorWrapper : public Gaudi::Algorithm { static std::stack& ProcessorStack(); - bool isReEntrant() const override { return false; } + bool isReEntrant() const final { return false; } }; std::stack& MarlinProcessorWrapper::ProcessorStack() { diff --git a/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h b/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h index 9e4f5293..4d281004 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h +++ b/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h @@ -53,10 +53,10 @@ struct CollectionPairMappings; class EDM4hep2LcioTool : public AlgTool, virtual public IEDMConverter { public: EDM4hep2LcioTool(const std::string& type, const std::string& name, const IInterface* parent); - StatusCode initialize() override; - StatusCode finalize() override; + StatusCode initialize() final; + StatusCode finalize() final; - StatusCode convertCollections(lcio::LCEventImpl* lcio_event) override; + StatusCode convertCollections(lcio::LCEventImpl* lcio_event) final; private: Gaudi::Property> m_collNames{this, "collNameMapping", {}}; diff --git a/k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h b/k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h index ffe44232..a72a11f3 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h +++ b/k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h @@ -52,7 +52,7 @@ class Lcio2EDM4hepTool : public AlgTool, virtual public IEDMConverter { // - Convert associated collections from LCRelation for existing EDM4hep relations // - Converted collections are put into TES // ********************************** - StatusCode convertCollections(lcio::LCEventImpl* lcio_event) override; + StatusCode convertCollections(lcio::LCEventImpl* lcio_event) final; private: Gaudi::Property> m_collNames{this, "collNameMapping", {}}; diff --git a/test/src/MarlinMCRecoLinkChecker.cc b/test/src/MarlinMCRecoLinkChecker.cc index 1c82b20f..2664a398 100644 --- a/test/src/MarlinMCRecoLinkChecker.cc +++ b/test/src/MarlinMCRecoLinkChecker.cc @@ -31,9 +31,9 @@ class MarlinMCRecoLinkChecker : public marlin::Processor { public: MarlinMCRecoLinkChecker(); - marlin::Processor* newProcessor() override { return new MarlinMCRecoLinkChecker; } + marlin::Processor* newProcessor() final { return new MarlinMCRecoLinkChecker; } - void processEvent(LCEvent* evt) override; + void processEvent(LCEvent* evt) final; private: std::string m_mcCollName{}; diff --git a/test/src/PseudoRecoAlgorithm.cc b/test/src/PseudoRecoAlgorithm.cc index d6a5a909..ab1521c6 100644 --- a/test/src/PseudoRecoAlgorithm.cc +++ b/test/src/PseudoRecoAlgorithm.cc @@ -30,7 +30,7 @@ struct PseudoRecoAlgorithm final : Transformer(name, svcLoc, {KeyValues("InputMCs", {"MCParticles"})}, {KeyValues("OutputRecos", {"PseudoRecoParticles"})}) {} - edm4hep::ReconstructedParticleCollection operator()(const edm4hep::MCParticleCollection& input) const override { + edm4hep::ReconstructedParticleCollection operator()(const edm4hep::MCParticleCollection& input) const final { auto coll_out = edm4hep::ReconstructedParticleCollection(); for (const auto& particle : input) { auto new_particle = coll_out.create(); diff --git a/test/src/TrivialMCRecoLinker.cc b/test/src/TrivialMCRecoLinker.cc index 2ff5e738..4f73d9b8 100644 --- a/test/src/TrivialMCRecoLinker.cc +++ b/test/src/TrivialMCRecoLinker.cc @@ -36,7 +36,7 @@ struct TrivialMCRecoLinker final edm4hep::RecoMCParticleLinkCollection operator()( const edm4hep::MCParticleCollection& mcParticles, - const edm4hep::ReconstructedParticleCollection& recoParticles) const override { + const edm4hep::ReconstructedParticleCollection& recoParticles) const final { auto links = edm4hep::RecoMCParticleLinkCollection{}; for (size_t i = 0; i < mcParticles.size(); ++i) { diff --git a/test/src/TrivialMCTruthLinkerProcessor.h b/test/src/TrivialMCTruthLinkerProcessor.h index a7517b9d..3be82775 100644 --- a/test/src/TrivialMCTruthLinkerProcessor.h +++ b/test/src/TrivialMCTruthLinkerProcessor.h @@ -24,12 +24,12 @@ class TrivialMCTruthLinkerProcessor : public marlin::Processor { public: TrivialMCTruthLinkerProcessor(); - marlin::Processor* newProcessor() override { return new TrivialMCTruthLinkerProcessor; } + marlin::Processor* newProcessor() final { return new TrivialMCTruthLinkerProcessor; } /** process the event - In this case simply link MCparticle[i] with * ReconstructedParticle[i] */ - void processEvent(LCEvent* evt) override; + void processEvent(LCEvent* evt) final; private: std::string m_mcCollName{};