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

Introduce a global object map that is shared by all converter instances #142

Merged
merged 14 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading