Skip to content

Commit

Permalink
Make sure that TrackerHitPlanes get converted to LCIO
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Jun 7, 2024
1 parent c2fd175 commit a9872c8
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 25 deletions.
29 changes: 16 additions & 13 deletions k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@
// std
#include <map>
#include <string>
#include <tuple>
#include <vector>

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

using TrackMap = ObjMapT<lcio::TrackImpl*, edm4hep::Track>;
using ClusterMap = ObjMapT<lcio::ClusterImpl*, edm4hep::Cluster>;
using VertexMap = ObjMapT<lcio::VertexImpl*, edm4hep::Vertex>;
using TrackerHitMap = ObjMapT<lcio::TrackerHitImpl*, edm4hep::TrackerHit3D>;
using SimTrackerHitMap = ObjMapT<lcio::SimTrackerHitImpl*, edm4hep::SimTrackerHit>;
using CaloHitMap = ObjMapT<lcio::CalorimeterHitImpl*, edm4hep::CalorimeterHit>;
using SimCaloHitMap = ObjMapT<lcio::SimCalorimeterHitImpl*, edm4hep::SimCalorimeterHit>;
using RawCaloHitMap = ObjMapT<lcio::RawCalorimeterHitImpl*, edm4hep::RawCalorimeterHit>;
using TPCHitMap = ObjMapT<lcio::TPCHitImpl*, edm4hep::RawTimeSeries>;
using RecoParticleMap = ObjMapT<lcio::ReconstructedParticleImpl*, edm4hep::ReconstructedParticle>;
using MCParticleMap = ObjMapT<lcio::MCParticleImpl*, edm4hep::MCParticle>;
using ParticleIDMap = ObjMapT<lcio::ParticleIDImpl*, edm4hep::ParticleID>;
using TrackMap = ObjMapT<lcio::TrackImpl*, edm4hep::Track>;
using ClusterMap = ObjMapT<lcio::ClusterImpl*, edm4hep::Cluster>;
using VertexMap = ObjMapT<lcio::VertexImpl*, edm4hep::Vertex>;
using TrackerHitMap = ObjMapT<lcio::TrackerHitImpl*, edm4hep::TrackerHit3D>;
using TrackerHitPlaneMap = ObjMapT<lcio::TrackerHitPlaneImpl*, edm4hep::TrackerHitPlane>;
using SimTrackerHitMap = ObjMapT<lcio::SimTrackerHitImpl*, edm4hep::SimTrackerHit>;
using CaloHitMap = ObjMapT<lcio::CalorimeterHitImpl*, edm4hep::CalorimeterHit>;
using SimCaloHitMap = ObjMapT<lcio::SimCalorimeterHitImpl*, edm4hep::SimCalorimeterHit>;
using RawCaloHitMap = ObjMapT<lcio::RawCalorimeterHitImpl*, edm4hep::RawCalorimeterHit>;
using TPCHitMap = ObjMapT<lcio::TPCHitImpl*, edm4hep::RawTimeSeries>;
using RecoParticleMap = ObjMapT<lcio::ReconstructedParticleImpl*, edm4hep::ReconstructedParticle>;
using MCParticleMap = ObjMapT<lcio::MCParticleImpl*, edm4hep::MCParticle>;
using ParticleIDMap = ObjMapT<lcio::ParticleIDImpl*, edm4hep::ParticleID>;

struct CollectionPairMappings;

Expand All @@ -76,6 +76,9 @@ class EDM4hep2LcioTool : public GaudiTool, virtual public IEDMConverter {
void convertTrackerHits(TrackerHitMap& trackerhits_vec, const std::string& e4h_coll_name,
const std::string& lcio_coll_name, lcio::LCEventImpl* lcio_event);

void convertTrackerHitPlanes(TrackerHitPlaneMap& trackerhits_vec, const std::string& e4h_coll_name,
const std::string& lcio_coll_name, lcio::LCEventImpl* lcio_event);

void convertSimTrackerHits(SimTrackerHitMap& simtrackerhits_vec, const std::string& e4h_coll_name,
const std::string& lcio_coll_name, lcio::LCEventImpl* lcio_event);

Expand Down
41 changes: 29 additions & 12 deletions k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,19 @@ using namespace k4MarlinWrapper;
using GlobalMapWrapper = AnyDataWrapper<GlobalConvertedObjectsMap>;

struct CollectionPairMappings {
TrackMap tracks{};
TrackerHitMap trackerHits{};
SimTrackerHitMap simTrackerHits{};
CaloHitMap caloHits{};
RawCaloHitMap rawCaloHits{};
SimCaloHitMap simCaloHits{};
TPCHitMap tpcHits{};
ClusterMap clusters{};
VertexMap vertices{};
RecoParticleMap recoParticles{};
MCParticleMap mcParticles{};
ParticleIDMap particleIDs{};
TrackMap tracks{};
TrackerHitMap trackerHits{};
TrackerHitPlaneMap trackerHitsPlane{};
SimTrackerHitMap simTrackerHits{};
CaloHitMap caloHits{};
RawCaloHitMap rawCaloHits{};
SimCaloHitMap simCaloHits{};
TPCHitMap tpcHits{};
ClusterMap clusters{};
VertexMap vertices{};
RecoParticleMap recoParticles{};
MCParticleMap mcParticles{};
ParticleIDMap particleIDs{};
};

EDM4hep2LcioTool::EDM4hep2LcioTool(const std::string& type, const std::string& name, const IInterface* parent)
Expand Down Expand Up @@ -107,6 +108,20 @@ void EDM4hep2LcioTool::convertParticleIDs(ParticleIDMap& pidMap, const std::stri
EDM4hep2LCIOConv::convertParticleIDs(pidHandle.get(), pidMap, algoId);
}

void EDM4hep2LcioTool::convertTrackerHitPlanes(TrackerHitPlaneMap& trackerhits_vec, const std::string& e4h_coll_name,
const std::string& lcio_coll_name, lcio::LCEventImpl* lcio_event) {
DataHandle<edm4hep::TrackerHitPlaneCollection> trackerhits_handle{e4h_coll_name, Gaudi::DataHandle::Reader, this};
const auto trackerhits_coll = trackerhits_handle.get();

MetaDataHandle<std::string> cellIDStrHandle{trackerhits_handle, edm4hep::CellIDEncoding, Gaudi::DataHandle::Reader};

auto conv_trackerhits =
EDM4hep2LCIOConv::convertTrackerHitPlanes(trackerhits_coll, cellIDStrHandle.get(), trackerhits_vec);

// Add all trackerhits to event
lcio_event->addCollection(conv_trackerhits.release(), lcio_coll_name);
}

// Convert EDM4hep SimTrackerHits to LCIO
// Add converted LCIO ptr and original EDM4hep collection to vector of pairs
// Add LCIO Collection Vector to LCIO event
Expand Down Expand Up @@ -277,6 +292,8 @@ void EDM4hep2LcioTool::convertAdd(const std::string& e4h_coll_name, const std::s
convertTracks(collection_pairs.tracks, e4h_coll_name, lcio_coll_name, lcio_event);
} else if (fulltype == "edm4hep::TrackerHit") {
convertTrackerHits(collection_pairs.trackerHits, e4h_coll_name, lcio_coll_name, lcio_event);
} else if (fulltype == "edm4hep::TrackerHitPlane") {
convertTrackerHitPlanes(collection_pairs.trackerHitsPlane, e4h_coll_name, lcio_coll_name, lcio_event);
} else if (fulltype == "edm4hep::SimTrackerHit") {
convertSimTrackerHits(collection_pairs.simTrackerHits, e4h_coll_name, lcio_coll_name, lcio_event);
} else if (fulltype == "edm4hep::CalorimeterHit") {
Expand Down

0 comments on commit a9872c8

Please sign in to comment.