Skip to content

Commit

Permalink
Pass separate lookup maps for resolving MC and reco particle
Browse files Browse the repository at this point in the history
Necessary to build hierarchies that might span several collections
  • Loading branch information
tmadlener committed Oct 5, 2023
1 parent 5836536 commit a9c3df7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ namespace LCIO2EDM4hepConv {
/**
* Resolve the relations for the MCParticles.
*/
template<typename MCParticleMapT>
void resolveRelationsMCParticles(MCParticleMapT& mcparticlesMap);
template<typename MCParticleMapT, typename MCParticleLookupMapT>
void resolveRelationsMCParticles(MCParticleMapT& mcparticlesMap, const MCParticleLookupMapT& lookupMap);

/**
* Resolve the relations for SimTrackerHits
Expand All @@ -358,9 +358,15 @@ namespace LCIO2EDM4hepConv {
/**
* Resolve the relations for ReconstructedParticles
*/
template<typename RecoParticleMapT, typename VertexMapT, typename ClusterMapT, typename TrackMapT>
template<
typename RecoParticleMapT,
typename RecoParticleLookupMapT,
typename VertexMapT,
typename ClusterMapT,
typename TrackMapT>
void resolveRelationsRecoParticles(
RecoParticleMapT& recoparticlesMap,
const RecoParticleLookupMapT& recoLookupMap,
const VertexMapT& vertexMap,
const ClusterMapT& clusterMap,
const TrackMapT& tracksMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,8 @@ namespace LCIO2EDM4hepConv {
return contrCollection;
}

template<typename MCParticleMapT>
void resolveRelationsMCParticles(MCParticleMapT& mcparticlesMap)
template<typename MCParticleMapT, typename MCParticleLookupMapT>
void resolveRelationsMCParticles(MCParticleMapT& mcparticlesMap, const MCParticleLookupMapT& lookupMap)
{
int edmnum = 1;
for (auto& [lcio, edm] : mcparticlesMap) {
Expand All @@ -623,7 +623,7 @@ namespace LCIO2EDM4hepConv {
if (d == nullptr) {
continue;
}
if (const auto edmD = k4EDM4hep2LcioConv::detail::mapLookupTo(d, mcparticlesMap)) {
if (const auto edmD = k4EDM4hep2LcioConv::detail::mapLookupTo(d, lookupMap)) {
edm.addToDaughters(edmD.value());
}
else {
Expand All @@ -636,7 +636,7 @@ namespace LCIO2EDM4hepConv {
if (p == nullptr) {
continue;
}
if (const auto edmP = k4EDM4hep2LcioConv::detail::mapLookupTo(p, mcparticlesMap)) {
if (const auto edmP = k4EDM4hep2LcioConv::detail::mapLookupTo(p, lookupMap)) {
edm.addToParents(edmP.value());
}
else {
Expand Down Expand Up @@ -667,9 +667,15 @@ namespace LCIO2EDM4hepConv {
}
}

template<typename RecoParticleMapT, typename VertexMapT, typename ClusterMapT, typename TrackMapT>
template<
typename RecoParticleMapT,
typename RecoParticleLookupMapT,
typename VertexMapT,
typename ClusterMapT,
typename TrackMapT>
void resolveRelationsRecoParticles(
RecoParticleMapT& recoparticlesMap,
const RecoParticleLookupMapT& recoLookupMap,
const VertexMapT& vertexMap,
const ClusterMapT& clusterMap,
const TrackMapT& tracksMap)
Expand Down Expand Up @@ -725,7 +731,7 @@ namespace LCIO2EDM4hepConv {
if (p == nullptr) {
continue;
}
if (const auto edmReco = k4EDM4hep2LcioConv::detail::mapLookupTo(p, recoparticlesMap)) {
if (const auto edmReco = k4EDM4hep2LcioConv::detail::mapLookupTo(p, recoLookupMap)) {
edm.addToParticles(edmReco.value());
}
else {
Expand Down Expand Up @@ -864,9 +870,9 @@ namespace LCIO2EDM4hepConv {
template<typename ObjectMappingT, typename ObjectMappingU>
void resolveRelations(ObjectMappingT& updateMaps, const ObjectMappingU& lookupMaps)
{
resolveRelationsMCParticles(updateMaps.mcParticles);
resolveRelationsMCParticles(updateMaps.mcParticles, lookupMaps.mcParticles);
resolveRelationsRecoParticles(
updateMaps.recoParticles, lookupMaps.vertices, lookupMaps.clusters, lookupMaps.tracks);
updateMaps.recoParticles, lookupMaps.recoParticles, lookupMaps.vertices, lookupMaps.clusters, lookupMaps.tracks);
resolveRelationsSimTrackerHits(updateMaps.simTrackerHits, lookupMaps.mcParticles);
resolveRelationsClusters(updateMaps.clusters, lookupMaps.caloHits);
resolveRelationsTracks(updateMaps.tracks, lookupMaps.trackerHits, lookupMaps.tpcHits, lookupMaps.trackerHitPlanes);
Expand Down

0 comments on commit a9c3df7

Please sign in to comment.