Skip to content

Commit

Permalink
Switch LCIO to EDM4hep conversion to use k4EDM4hep2LcioConv functiona…
Browse files Browse the repository at this point in the history
…lity (#114)

* Implement conversion on top of k4EDM4hep2LcioConv

* Remove no longer necessary k4LCIOReader

* Add error outputs to track comparison

* Make sure to convert TrackerHits in tests

* Update the expected anajob outputs
  • Loading branch information
tmadlener authored Jul 19, 2023
1 parent edac52f commit 8e432f4
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 206 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ find_package(Marlin REQUIRED)
find_package(EDM4HEP REQUIRED)
find_package(k4FWCore REQUIRED)
find_package(k4EDM4hep2LcioConv REQUIRED)
find_package(k4LCIOReader REQUIRED)

include(CTest)

Expand Down
2 changes: 1 addition & 1 deletion k4MarlinWrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ gaudi_add_module(Lcio2EDM4hep
Gaudi::GaudiAlgLib
EDM4HEP::edm4hep
k4FWCore::k4FWCore
k4LCIOReader::k4LCIOReader
k4EDM4hep2LcioConv::k4EDM4hep2LcioConv
)

target_include_directories(Lcio2EDM4hep PUBLIC
Expand Down
54 changes: 41 additions & 13 deletions k4MarlinWrapper/k4MarlinWrapper/converters/Lcio2EDM4hep.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef K4MARLINWRAPPER_K4LCIOREADERWRAPPER_H
#define K4MARLINWRAPPER_K4LCIOREADERWRAPPER_H
#ifndef K4MARLINWRAPPER_LCIO2EDM4HEP_H
#define K4MARLINWRAPPER_LCIO2EDM4HEP_H

// GAUDI
#include <GaudiAlg/GaudiTool.h>
Expand All @@ -8,15 +8,25 @@
#include <k4FWCore/DataHandle.h>
#include <k4FWCore/PodioLegacyDataSvc.h>

// k4LCIOReader
#include <k4LCIOReader/k4LCIOConverter.h>
#include <k4LCIOReader/k4LCIOReader.h>

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

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

namespace podio {
class CollectionBase;
}

namespace LCIO2EDM4hepConv {
struct LcioEdmTypeMapping;
}

namespace EVENT {
class LCCollection;
}

class Lcio2EDM4hepTool : public GaudiTool, virtual public IEDMConverter {
public:
Expand All @@ -25,23 +35,41 @@ class Lcio2EDM4hepTool : public GaudiTool, virtual public IEDMConverter {
virtual StatusCode initialize();
virtual StatusCode finalize();

StatusCode convertCollections(lcio::LCEventImpl* lcio_event);
// **********************************
// - Convert all collections indicated in Tool parameters
// - Some collections implicitly convert associated collections
// - Convert associated collections from LCRelation for existing EDM4hep relations
// - Converted collections are put into TES
// **********************************
StatusCode convertCollections(lcio::LCEventImpl* lcio_event) override;

private:
Gaudi::Property<std::map<std::string, std::string>> m_collNames{this, "collNameMapping", {}};
Gaudi::Property<bool> m_convertAll{this, "convertAll", true};

std::map<std::string, DataObjectHandleBase*> m_dataHandlesMap;

ServiceHandle<IDataProviderSvc> m_eds;
PodioLegacyDataSvc* m_podioDataSvc;

// **********************************
// Check if a collection was already registered to skip it
// **********************************
bool collectionExist(const std::string& collection_name);

template <typename T>
void convertRegister(const std::string& edm_name, const std::string& lcio_name,
std::unique_ptr<k4LCIOConverter>& lcio_conver, const lcio::LCCollection* const lcio_coll,
const bool cnv_metadata = false);
/**
* Register a collection into the TES. If the lcioColl is not a nullptr also
* convert the metadata from the input lcio collection.
*/
void registerCollection(std::tuple<const std::string&, std::unique_ptr<podio::CollectionBase>> namedColl,
EVENT::LCCollection* lcioColl = nullptr);

/**
* Register a collection into the TES. If the lcioColl is not a nullptr also
* convert the metadata from the input lcio collection.
*/
void registerCollection(const std::string& name, std::unique_ptr<podio::CollectionBase>&& coll,
EVENT::LCCollection* lcioColl = nullptr) {
registerCollection(std::make_tuple(name, std::move(coll)), lcioColl);
}
};

#endif
Loading

0 comments on commit 8e432f4

Please sign in to comment.