Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple minor fixes #207

Merged
merged 8 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions k4MarlinWrapper/k4MarlinWrapper/LCEventWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class LCEventWrapper : public DataObject {
public:
LCEventWrapper(std::unique_ptr<EVENT::LCEvent>&& theEvent) : m_event(std::move(theEvent)) {}

~LCEventWrapper() = default;

EVENT::LCEvent* getEvent() const { return m_event.get(); }

private:
Expand Down
14 changes: 6 additions & 8 deletions k4MarlinWrapper/k4MarlinWrapper/LcioEventAlgo.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,17 @@
*/

#include <Gaudi/Algorithm.h>
#include <GaudiKernel/IEventProcessor.h>
#include <Gaudi/Property.h>

#include <EVENT/LCIO.h>
#include <MT/LCReader.h>

#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;
tmadlener marked this conversation as resolved.
Show resolved Hide resolved

private:
Gaudi::Property<std::vector<std::string>> m_fileNames{this, "Files", {}};
Expand Down
18 changes: 10 additions & 8 deletions k4MarlinWrapper/k4MarlinWrapper/LcioEventOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,27 @@
// LCEventOutput: Write out LCIO events using MT writer from LCIO
////////////////////////////////////////////

#include <iostream>

#include <Gaudi/Algorithm.h>
#include <Gaudi/Property.h>

#include <EVENT/LCIO.h>
#include <IMPL/LCCollectionVec.h>
#include <IMPL/LCEventImpl.h>
#include <MT/LCWriter.h>
#include <lcio.h>

#include "k4MarlinWrapper/LCEventWrapper.h"
#include <string>
#include <vector>

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;
Expand Down
13 changes: 3 additions & 10 deletions k4MarlinWrapper/k4MarlinWrapper/MarlinProcessorWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,27 @@
#ifndef K4MARLINWRAPPER_MARLINPROCESSORWRAPPER_H
#define K4MARLINWRAPPER_MARLINPROCESSORWRAPPER_H

// std
#include <stack>
#include <string>

// Gaudi
#include <Gaudi/Algorithm.h>
#include <GaudiKernel/IEventProcessor.h>
#include <GaudiKernel/IRndmEngine.h>
#include <GaudiKernel/MsgStream.h>
#include <GaudiKernel/ToolHandle.h>

// LCIO
#include <EVENT/LCEvent.h>
#include <EVENT/LCRunHeader.h>

// Marlin
#include <marlin/EventModifier.h>
#include <marlin/Exceptions.h>
#include <marlin/Global.h>
#include <marlin/ProcessorEventSeeder.h>
#include <marlin/ProcessorMgr.h>
#include <marlin/StringParameters.h>

// ROOT
#include <TSystem.h>

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

namespace marlin {
Expand All @@ -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";
Expand Down
5 changes: 1 addition & 4 deletions k4MarlinWrapper/k4MarlinWrapper/TrackingCellIDEncodingSvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,9 @@
#ifndef CELLIDSVC_H
#define CELLIDSVC_H

#include <Gaudi/Property.h>
#include <GaudiKernel/Service.h>

//LCIO Includes
#include <UTIL/LCTrackerConf.h>

#include <string>

class IGeoSvc;
Expand All @@ -32,7 +30,6 @@ class TrackingCellIDEncodingSvc : public extends<Service, IService> {
public:
TrackingCellIDEncodingSvc(const std::string& name, ISvcLocator* svc);

~TrackingCellIDEncodingSvc();
StatusCode initialize() final;
StatusCode finalize() final;

Expand Down
16 changes: 5 additions & 11 deletions k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,19 @@
#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>

class PodioDataSvc;

template <typename K, typename V> using ObjMapT = k4EDM4hep2LcioConv::VecMapT<K, V>;

using TrackMap = ObjMapT<lcio::TrackImpl*, edm4hep::Track>;
Expand All @@ -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() override;
StatusCode finalize() override;
tmadlener marked this conversation as resolved.
Show resolved Hide resolved

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
8 changes: 2 additions & 6 deletions k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,9 @@
#ifndef K4MARLINWRAPPER_LCIO2EDM4HEP_H
#define K4MARLINWRAPPER_LCIO2EDM4HEP_H

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

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

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

#include <lcio.h>
Expand All @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "k4FWCore/DataHandle.h"
#include "k4FWCore/MetaDataHandle.h"
#include "k4FWCore/PodioDataSvc.h"

#include "GaudiKernel/AnyDataWrapper.h"

Expand Down Expand Up @@ -53,8 +54,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
12 changes: 7 additions & 5 deletions k4MarlinWrapper/src/components/Lcio2EDM4hep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <k4FWCore/DataHandle.h>
#include <k4FWCore/MetaDataHandle.h>
#include <k4FWCore/PodioDataSvc.h>

#include "GaudiKernel/AnyDataWrapper.h"

Expand All @@ -42,13 +43,14 @@ Lcio2EDM4hepTool::Lcio2EDM4hepTool(const std::string& type, const std::string& n
declareInterface<IEDMConverter>(this);

StatusCode sc = m_eds.retrieve();
if (sc.isFailure()) {
error() << "Could not retrieve EventDataSvc" << endmsg;
}
}

Lcio2EDM4hepTool::~Lcio2EDM4hepTool() { ; }

StatusCode Lcio2EDM4hepTool::initialize() {
m_podioDataSvc = dynamic_cast<PodioDataSvc*>(m_eds.get());
if (nullptr == m_podioDataSvc)
if (!m_podioDataSvc)
return StatusCode::FAILURE;

return AlgTool::initialize();
Expand All @@ -73,7 +75,7 @@ bool Lcio2EDM4hepTool::collectionExist(const std::string& collection_name) {
void Lcio2EDM4hepTool::registerCollection(
std::tuple<const std::string&, std::unique_ptr<podio::CollectionBase>> namedColl, EVENT::LCCollection* lcioColl) {
auto& [name, e4hColl] = namedColl;
if (e4hColl == nullptr) {
if (!e4hColl) {
error() << "Could not convert collection " << name << endmsg;
return;
}
Expand Down Expand Up @@ -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;
Expand Down
24 changes: 17 additions & 7 deletions k4MarlinWrapper/src/components/LcioEventAlgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,19 @@
* limitations under the License.
*/

#include "k4MarlinWrapper/LcioEventAlgo.h"
#include <GaudiKernel/IEventProcessor.h>

#include "k4MarlinWrapper/LCEventWrapper.h"
#include "k4MarlinWrapper/util/k4MarlinWrapperUtil.h"
#include "k4MarlinWrapper/LcioEventAlgo.h"

#include "marlin/Global.h"
#include "marlin/StringParameters.h"

#include <EVENT/LCIO.h>
#include <MT/LCReader.h>

#include <memory>
#include <string>

DECLARE_COMPONENT(LcioEvent)

Expand All @@ -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<LCEventWrapperStatus>(false);
const StatusCode scStatus = eventSvc()->registerObject("/Event/LCEventStatus", pStatus.release());
Expand All @@ -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<IEventProcessor>("ApplicationMgr");
if (svc) {
svc->stopRun().ignore();
svc->release();
} else {
abort();
}
Expand Down
6 changes: 6 additions & 0 deletions k4MarlinWrapper/src/components/LcioEventOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@
* limitations under the License.
*/

#include <MT/LCWriter.h>

#include "k4MarlinWrapper/LCEventWrapper.h"
#include "k4MarlinWrapper/LcioEventOutput.h"

#include <string>
#include <vector>

DECLARE_COMPONENT(LcioEventOutput)

LcioEventOutput::LcioEventOutput(const std::string& name, ISvcLocator* pSL) : Gaudi::Algorithm(name, pSL) {}
Expand Down
20 changes: 12 additions & 8 deletions k4MarlinWrapper/src/components/MarlinProcessorWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#include "k4MarlinWrapper/LCEventWrapper.h"
#include "k4MarlinWrapper/util/k4MarlinWrapperUtil.h"

#include <map>
#include <string>
#include <vector>

DECLARE_COMPONENT(MarlinProcessorWrapper)

MarlinProcessorWrapper::MarlinProcessorWrapper(const std::string& name, ISvcLocator* pSL)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -131,12 +135,12 @@ std::shared_ptr<marlin::StringParameters> MarlinProcessorWrapper::parseParameter
StatusCode MarlinProcessorWrapper::instantiateProcessor(std::shared_ptr<marlin::StringParameters>& parameters,
Gaudi::Property<std::string>& 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;
}
Expand Down Expand Up @@ -215,7 +219,7 @@ StatusCode MarlinProcessorWrapper::execute(const EventContext&) const {
StatusCode scStatus = eventSvc()->retrieveObject("/Event/LCEventStatus", pStatus);
if (scStatus.isSuccess()) {
bool hasLCEvent = static_cast<LCEventWrapperStatus*>(pStatus)->hasLCEvent;
if (not hasLCEvent) {
if (!hasLCEvent) {
warning() << "LCIO Event reading returned nullptr, so MarlinProcessorWrapper won't execute" << endmsg;
return StatusCode::SUCCESS;
}
Expand Down Expand Up @@ -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<IEventProcessor>("ApplicationMgr");
if (svc) {
svc->stopRun().ignore();
svc->release();
} else {
abort();
}
Expand Down
Loading
Loading