Skip to content

Commit

Permalink
Multiple minor fixes:
Browse files Browse the repository at this point in the history
- Don't use the deprecated service retrieval
- Add override when possible and use the default destructors instead of
  implementing them
  • Loading branch information
jmcarcell committed Dec 9, 2024
1 parent c1227e9 commit 2e2e897
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 25 deletions.
13 changes: 4 additions & 9 deletions k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,15 @@
#ifndef K4MARLINWRAPPER_EDM4HEP2LCIO_H
#define K4MARLINWRAPPER_EDM4HEP2LCIO_H

// k4MarlinWrapper
#include "k4MarlinWrapper/converters/IEDMConverter.h"

// FWCore
#include <k4FWCore/PodioDataSvc.h>

//k4EDM4hep2LcioConv
#include "k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h"

// GAUDI
#include <Gaudi/Property.h>
#include <GaudiKernel/AlgTool.h>

// std
#include <map>
#include <string>
#include <vector>
Expand All @@ -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<std::map<std::string, std::string>> m_collNames{this, "collNameMapping", {}};
Expand Down
2 changes: 1 addition & 1 deletion k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 0 additions & 2 deletions k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ EDM4hep2LcioTool::EDM4hep2LcioTool(const std::string& type, const std::string& n
declareInterface<IEDMConverter>(this);
}

EDM4hep2LcioTool::~EDM4hep2LcioTool() { ; }

StatusCode EDM4hep2LcioTool::initialize() {
StatusCode sc = m_eventDataSvc.retrieve();
m_podioDataSvc = dynamic_cast<PodioDataSvc*>(m_eventDataSvc.get());
Expand Down
6 changes: 1 addition & 5 deletions k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<IEDMConverter>(this);

StatusCode sc = m_eds.retrieve();
}

Lcio2EDM4hepTool::~Lcio2EDM4hepTool() { ; }

StatusCode Lcio2EDM4hepTool::initialize() {
m_podioDataSvc = dynamic_cast<PodioDataSvc*>(m_eds.get());
if (nullptr == m_podioDataSvc)
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions k4MarlinWrapper/src/components/LcioEventAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<IEventProcessor>("ApplicationMgr");
if (svc) {
svc->stopRun().ignore();
svc->release();
} else {
abort();
}
Expand Down
8 changes: 4 additions & 4 deletions k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<IEventProcessor>("ApplicationMgr");
if (svc) {
svc->stopRun().ignore();
svc->release();
} else {
abort();
}
Expand Down

0 comments on commit 2e2e897

Please sign in to comment.