Skip to content

Commit

Permalink
Unified converter maps (#147)
Browse files Browse the repository at this point in the history
* Make object map names consistent in both directions

* Add a global map to keep state across several conversions

* Use TES to move global map between tools instead of singleton

* Pass the global maps to subset and association coll conversions

* Add isolated test case for the global converter maps

* Add brief description of new test case
  • Loading branch information
tmadlener authored Oct 5, 2023
1 parent 71369c8 commit d29e309
Show file tree
Hide file tree
Showing 15 changed files with 807 additions and 98 deletions.
3 changes: 3 additions & 0 deletions k4MarlinWrapper/examples/clicRec_e4h_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,9 @@
"BuildUpVertices_V0": "BuildUpVertices_V0",
"BuildUpVertices": "BuildUpVertices",
"PrimaryVertices": "PrimaryVertices",
"BuildUpVertices_RP": "BuildUpVertices_RP",
"BuildUpVertices_V0_RP": "BuildUpVertices_V0_RP",
"PrimaryVertices_RP": "PrimaryVertices_RP",
}
VertexFinderLCIOConv.OutputLevel = DEBUG
# Add it to VertexFinder Algorithm
Expand Down
79 changes: 38 additions & 41 deletions k4MarlinWrapper/k4MarlinWrapper/converters/EDM4hep2Lcio.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,24 @@
// std
#include <map>
#include <string>
#include <tuple>
#include <vector>

#ifdef EDM4HEP2LCIOCONV_NAMESPACE
using EDM4hep2LCIOConv::CollectionsPairVectors;
using EDM4hep2LCIOConv::vec_pair;
#endif
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::TrackerHit>;
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>;

struct CollectionPairMappings;

class EDM4hep2LcioTool : public GaudiTool, virtual public IEDMConverter {
public:
Expand All @@ -57,62 +69,47 @@ class EDM4hep2LcioTool : public GaudiTool, virtual public IEDMConverter {
PodioDataSvc* m_podioDataSvc;
ServiceHandle<IDataProviderSvc> m_eventDataSvc;

void convertTracks(vec_pair<lcio::TrackImpl*, edm4hep::Track>& tracks_vec,
vec_pair<lcio::TrackerHitImpl*, edm4hep::TrackerHit>& trackerhits_vec,
const std::string& e4h_coll_name, const std::string& lcio_coll_name,
lcio::LCEventImpl* lcio_event);
void convertTracks(TrackMap& tracks_vec, const TrackerHitMap& trackerhits_vec, const std::string& e4h_coll_name,
const std::string& lcio_coll_name, lcio::LCEventImpl* lcio_event);

void convertTrackerHits(vec_pair<lcio::TrackerHitImpl*, edm4hep::TrackerHit>& trackerhits_vec,
const std::string& e4h_coll_name, const std::string& lcio_coll_name,
lcio::LCEventImpl* lcio_event);
void convertTrackerHits(TrackerHitMap& trackerhits_vec, const std::string& e4h_coll_name,
const std::string& lcio_coll_name, lcio::LCEventImpl* lcio_event);

void convertSimTrackerHits(vec_pair<lcio::SimTrackerHitImpl*, edm4hep::SimTrackerHit>& simtrackerhits_vec,
const vec_pair<lcio::MCParticleImpl*, edm4hep::MCParticle>& mcparticles_vec,
void convertSimTrackerHits(SimTrackerHitMap& simtrackerhits_vec, const MCParticleMap& mcparticles_vec,
const std::string& e4h_coll_name, const std::string& lcio_coll_name,
lcio::LCEventImpl* lcio_event);

void convertCalorimeterHits(vec_pair<lcio::CalorimeterHitImpl*, edm4hep::CalorimeterHit>& calo_hits_vec,
const std::string& e4h_coll_name, const std::string& lcio_coll_name,
lcio::LCEventImpl* lcio_event);
void convertCalorimeterHits(CaloHitMap& calo_hits_vec, const std::string& e4h_coll_name,
const std::string& lcio_coll_name, lcio::LCEventImpl* lcio_event);

void convertRawCalorimeterHits(vec_pair<lcio::RawCalorimeterHitImpl*, edm4hep::RawCalorimeterHit>& raw_calo_hits_vec,
const std::string& e4h_coll_name, const std::string& lcio_coll_name,
lcio::LCEventImpl* lcio_event);
void convertRawCalorimeterHits(RawCaloHitMap& raw_calo_hits_vec, const std::string& e4h_coll_name,
const std::string& lcio_coll_name, lcio::LCEventImpl* lcio_event);

void convertSimCalorimeterHits(vec_pair<lcio::SimCalorimeterHitImpl*, edm4hep::SimCalorimeterHit>& sim_calo_hits_vec,
const vec_pair<lcio::MCParticleImpl*, edm4hep::MCParticle>& mcparticles,
void convertSimCalorimeterHits(SimCaloHitMap& sim_calo_hits_vec, const MCParticleMap& mcparticles,
const std::string& e4h_coll_name, const std::string& lcio_coll_name,
lcio::LCEventImpl* lcio_event);

void convertTPCHits(vec_pair<lcio::TPCHitImpl*, edm4hep::RawTimeSeries>& tpc_hits_vec,
const std::string& e4h_coll_name, const std::string& lcio_coll_name,
void convertTPCHits(TPCHitMap& tpc_hits_vec, const std::string& e4h_coll_name, const std::string& lcio_coll_name,
lcio::LCEventImpl* lcio_event);

void convertClusters(vec_pair<lcio::ClusterImpl*, edm4hep::Cluster>& cluster_vec,
const vec_pair<lcio::CalorimeterHitImpl*, edm4hep::CalorimeterHit>& calohits_vec,
const std::string& e4h_coll_name, const std::string& lcio_coll_name,
lcio::LCEventImpl* lcio_event);
void convertClusters(ClusterMap& cluster_vec, const CaloHitMap& calohits_vec, const std::string& e4h_coll_name,
const std::string& lcio_coll_name, lcio::LCEventImpl* lcio_event);

void convertVertices(
vec_pair<lcio::VertexImpl*, edm4hep::Vertex>& vertex_vec,
const vec_pair<lcio::ReconstructedParticleImpl*, edm4hep::ReconstructedParticle>& recoparticles_vec,
const std::string& e4h_name, const std::string& lcio_coll_name, lcio::LCEventImpl* lcio_event);
void convertVertices(VertexMap& vertex_vec, const RecoParticleMap& recoparticles_vec, const std::string& e4h_name,
const std::string& lcio_coll_name, lcio::LCEventImpl* lcio_event);

void convertReconstructedParticles(
vec_pair<lcio::ReconstructedParticleImpl*, edm4hep::ReconstructedParticle>& recoparticles_vec,
const vec_pair<lcio::TrackImpl*, edm4hep::Track>& tracks_vec,
const vec_pair<lcio::VertexImpl*, edm4hep::Vertex>& vertex_vec,
const vec_pair<lcio::ClusterImpl*, edm4hep::Cluster>& clusters_vec, const std::string& e4h_coll_name,
const std::string& lcio_coll_name, lcio::LCEventImpl* lcio_event);
void convertReconstructedParticles(RecoParticleMap& recoparticles_vec, const TrackMap& tracks_vec,
const VertexMap& vertex_vec, const ClusterMap& clusters_vec,
const std::string& e4h_coll_name, const std::string& lcio_coll_name,
lcio::LCEventImpl* lcio_event);

void convertMCParticles(vec_pair<lcio::MCParticleImpl*, edm4hep::MCParticle>& mc_particles_vec,
const std::string& e4h_coll_name, const std::string& lcio_coll_name,
lcio::LCEventImpl* lcio_event);
void convertMCParticles(MCParticleMap& mc_particles_vec, const std::string& e4h_coll_name,
const std::string& lcio_coll_name, lcio::LCEventImpl* lcio_event);

void convertEventHeader(const std::string& e4h_coll_name, lcio::LCEventImpl* lcio_event);

void convertAdd(const std::string& e4h_coll_name, const std::string& lcio_coll_name, lcio::LCEventImpl* lcio_event,
CollectionsPairVectors& collection_pairs);
CollectionPairMappings& collection_pairs);
};

#endif
Loading

0 comments on commit d29e309

Please sign in to comment.