Skip to content

Commit

Permalink
Remove the ParticleID relation from the Clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Feb 8, 2024
1 parent 07c8f18 commit 3b9d4e5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -449,23 +449,6 @@ namespace EDM4hep2LCIOConv {
subdetEnergies.push_back(edmEnergy);
}

// Convert ParticleIDs associated to the recoparticle
for (const auto& edm_pid : edm_cluster.getParticleIDs()) {
if (edm_pid.isAvailable()) {
auto* lcio_pid = new lcio::ParticleIDImpl;

lcio_pid->setType(edm_pid.getType());
lcio_pid->setPDG(edm_pid.getPDG());
lcio_pid->setLikelihood(edm_pid.getLikelihood());
lcio_pid->setAlgorithmType(edm_pid.getAlgorithmType());
for (const auto& param : edm_pid.getParameters()) {
lcio_pid->addParameter(param);
}

lcio_cluster->addParticleID(lcio_pid);
}
}

// Add LCIO and EDM4hep pair collections to vec
k4EDM4hep2LcioConv::detail::mapInsert(lcio_cluster, edm_cluster, cluster_vec);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,9 @@ namespace LCIO2EDM4hepConv {
* part of the Cluster collection in LCIO. The name of this collection is
* <name>_particleIDs
*/
template<typename ClusterMapT, typename PIDMapT>
std::vector<CollNamePair> convertClusters(
const std::string& name,
EVENT::LCCollection* LCCollection,
ClusterMapT& clusterMap,
PIDMapT& particleIDMap);
template<typename ClusterMapT>
std::unique_ptr<edm4hep::ClusterCollection>
convertClusters(const std::string& name, EVENT::LCCollection* LCCollection, ClusterMapT& clusterMap);

/**
* Create an EventHeaderCollection and fills it with the Metadata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,12 +472,9 @@ namespace LCIO2EDM4hepConv {
return dest;
}

template<typename ClusterMapT, typename PIDMapT>
std::vector<CollNamePair> convertClusters(
const std::string& name,
EVENT::LCCollection* LCCollection,
ClusterMapT& clusterMap,
PIDMapT& particleIDMap)
template<typename ClusterMapT>
std::unique_ptr<edm4hep::ClusterCollection>
convertClusters(const std::string& name, EVENT::LCCollection* LCCollection, ClusterMapT& clusterMap)
{
auto particleIDs = std::make_unique<edm4hep::ParticleIDCollection>();
auto dest = std::make_unique<edm4hep::ClusterCollection>();
Expand All @@ -503,26 +500,8 @@ namespace LCIO2EDM4hepConv {
std::cerr << "EDM4hep element " << existingId << " did not get inserted. It belongs to the " << name
<< " collection" << std::endl;
}

// Need to convert the particle IDs here, since they are part of the cluster
// collection in LCIO
for (const auto lcioPid : rval->getParticleIDs()) {
auto pid = convertParticleID(lcioPid);
const auto [pidIt, pidInserted] = k4EDM4hep2LcioConv::detail::mapInsert(lcioPid, pid, particleIDMap);
if (pidInserted) {
lval.addToParticleIDs(pid);
particleIDs->push_back(pid);
}
else {
lval.addToParticleIDs(k4EDM4hep2LcioConv::detail::getMapped(pidIt));
}
}
}
std::vector<CollNamePair> results;
results.reserve(2);
results.emplace_back(name, std::move(dest));
results.emplace_back(name + "_particleIDs", std::move(particleIDs));
return results;
return dest;
}

template<typename ObjectMappingT>
Expand All @@ -544,7 +523,7 @@ namespace LCIO2EDM4hepConv {
retColls.emplace_back(name, convertTracks(name, LCCollection, typeMapping.tracks));
}
else if (type == "Cluster") {
return convertClusters(name, LCCollection, typeMapping.clusters, typeMapping.particleIDs);
retColls.emplace_back(name, convertClusters(name, LCCollection, typeMapping.clusters));
}
else if (type == "SimCalorimeterHit") {
retColls.emplace_back(name, convertSimCalorimeterHits(name, LCCollection, typeMapping.simCaloHits));
Expand Down

0 comments on commit 3b9d4e5

Please sign in to comment.