diff --git a/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h b/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h index d6f5302a..3b515451 100644 --- a/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h +++ b/k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h @@ -34,23 +34,23 @@ // std #include #include -#include #include template using ObjMapT = k4EDM4hep2LcioConv::VecMapT; -using TrackMap = ObjMapT; -using ClusterMap = ObjMapT; -using VertexMap = ObjMapT; -using TrackerHitMap = ObjMapT; -using SimTrackerHitMap = ObjMapT; -using CaloHitMap = ObjMapT; -using SimCaloHitMap = ObjMapT; -using RawCaloHitMap = ObjMapT; -using TPCHitMap = ObjMapT; -using RecoParticleMap = ObjMapT; -using MCParticleMap = ObjMapT; -using ParticleIDMap = ObjMapT; +using TrackMap = ObjMapT; +using ClusterMap = ObjMapT; +using VertexMap = ObjMapT; +using TrackerHitMap = ObjMapT; +using TrackerHitPlaneMap = ObjMapT; +using SimTrackerHitMap = ObjMapT; +using CaloHitMap = ObjMapT; +using SimCaloHitMap = ObjMapT; +using RawCaloHitMap = ObjMapT; +using TPCHitMap = ObjMapT; +using RecoParticleMap = ObjMapT; +using MCParticleMap = ObjMapT; +using ParticleIDMap = ObjMapT; struct CollectionPairMappings; @@ -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); diff --git a/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp b/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp index bb3e5c2e..d56dd2a2 100644 --- a/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp +++ b/k4MarlinWrapper/src/components/EDM4hep2Lcio.cpp @@ -35,18 +35,19 @@ using namespace k4MarlinWrapper; using GlobalMapWrapper = AnyDataWrapper; 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) @@ -95,7 +96,7 @@ void EDM4hep2LcioTool::convertTrackerHits(TrackerHitMap& trackerhits_vec, const MetaDataHandle cellIDStrHandle{trackerhits_handle, edm4hep::CellIDEncoding, Gaudi::DataHandle::Reader}; auto conv_trackerhits = - EDM4hep2LCIOConv::convertTrackerHits(trackerhits_coll, cellIDStrHandle.get(), trackerhits_vec); + EDM4hep2LCIOConv::convertTrackerHits(trackerhits_coll, cellIDStrHandle.get(""), trackerhits_vec); // Add all trackerhits to event lcio_event->addCollection(conv_trackerhits.release(), lcio_coll_name); @@ -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 trackerhits_handle{e4h_coll_name, Gaudi::DataHandle::Reader, this}; + const auto trackerhits_coll = trackerhits_handle.get(); + + MetaDataHandle 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 @@ -275,8 +290,10 @@ void EDM4hep2LcioTool::convertAdd(const std::string& e4h_coll_name, const std::s if (fulltype == "edm4hep::Track") { convertTracks(collection_pairs.tracks, e4h_coll_name, lcio_coll_name, lcio_event); - } else if (fulltype == "edm4hep::TrackerHit") { + } else if (fulltype == "edm4hep::TrackerHit" || fulltype == "edm4hep::TrackerHit3D") { 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") { @@ -308,7 +325,7 @@ void EDM4hep2LcioTool::convertAdd(const std::string& e4h_coll_name, const std::s } else { warning() << "Error trying to convert requested " << fulltype << " with name " << e4h_coll_name << endmsg; warning() << "List of supported types: " - << "Track, TrackerHit, SimTrackerHit, " + << "Track, TrackerHit3D, TrackerHitPlane, SimTrackerHit, " << "Cluster, CalorimeterHit, RawCalorimeterHit, " << "SimCalorimeterHit, Vertex, ReconstructedParticle, " << "MCParticle." << endmsg;