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..7ed13f75 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/LcioEventAlgo.h +++ b/k4MarlinWrapper/k4MarlinWrapper/LcioEventAlgo.h @@ -26,24 +26,22 @@ */ #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() 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 4a2cb65c..be47f951 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() final; + StatusCode execute(const EventContext&) const final; + StatusCode finalize() final; private: MT::LCWriter* m_writer = nullptr; diff --git a/k4MarlinWrapper/k4MarlinWrapper/MarlinProcessorWrapper.h b/k4MarlinWrapper/k4MarlinWrapper/MarlinProcessorWrapper.h index 4a4d344a..a3f8e555 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 final; + StatusCode finalize() final; + StatusCode initialize() final; private: std::string m_verbosity = "ERROR"; @@ -85,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/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 e36cc9d6..4d281004 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h +++ b/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h @@ -19,24 +19,19 @@ #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 +class PodioDataSvc; + template using ObjMapT = k4EDM4hep2LcioConv::VecMapT; using TrackMap = ObjMapT; @@ -58,11 +53,10 @@ 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(); + StatusCode initialize() final; + StatusCode finalize() final; - StatusCode convertCollections(lcio::LCEventImpl* lcio_event); + 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 fdc7f17d..a72a11f3 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); - virtual ~Lcio2EDM4hepTool(); StatusCode initialize() final; StatusCode finalize() final; @@ -56,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/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp b/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp index 793ecb64..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" @@ -53,8 +54,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..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" @@ -42,13 +43,14 @@ Lcio2EDM4hepTool::Lcio2EDM4hepTool(const std::string& type, const std::string& n declareInterface(this); StatusCode sc = m_eds.retrieve(); + if (sc.isFailure()) { + error() << "Could not retrieve EventDataSvc" << endmsg; + } } -Lcio2EDM4hepTool::~Lcio2EDM4hepTool() { ; } - StatusCode Lcio2EDM4hepTool::initialize() { m_podioDataSvc = dynamic_cast(m_eds.get()); - if (nullptr == m_podioDataSvc) + if (!m_podioDataSvc) return StatusCode::FAILURE; return AlgTool::initialize(); @@ -73,7 +75,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; } @@ -198,7 +200,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..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) @@ -41,7 +51,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()); @@ -52,10 +62,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/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 329ade25..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) @@ -81,7 +85,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; @@ -131,12 +135,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 +219,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; } @@ -297,10 +301,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(); } 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 37061743..723187ee 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 +) 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{};