Skip to content

Commit

Permalink
Purge mentions of associations from variable names and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
tmadlener committed Sep 9, 2024
1 parent ce2e33f commit 9901515
Show file tree
Hide file tree
Showing 15 changed files with 161 additions and 167 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ auto* lcio_converted_sim_tracker_hit_ptr = convSimTrackerHits(
collection_pairs.simtrackerhits,
collection_pairs.mcparticles);

// Run function to fix missing associations between collections.
// Run function to fix missing links between collections.
// Some collections that need to be linked to other collections may be converted
// after these are linked. Running this function after all conversions guarantees correct links
// between collections.
Expand Down
2 changes: 1 addition & 1 deletion doc/LCIO2EDM4hep.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ handles all the type details and can obviously also be used directly.
available in EDM4hep. They use the `"FromType"` and `"ToType"` collection
parameters to get the necessary type information.

The AssociationCollections in EDM4hep are then created using `createAssociations`.
The LinkCollections in EDM4hep are then created using `createLinks`.

## Converting entire events
Converting an entire event can be done calling the `convertEvent`. This can also
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,18 +332,18 @@ template <typename ObjectMappingT, typename ObjectMappingU>
void resolveRelations(ObjectMappingT& updateMaps, const ObjectMappingU& lookupMaps);

/**
* Convert the passed associatoin collections to LCRelation collections
* Convert the passed link collections to LCRelation collections
*/
template <typename ObjectMappingT>
std::vector<std::tuple<std::string, std::unique_ptr<lcio::LCCollection>>> createLCRelationCollections(
const std::vector<std::tuple<std::string, const podio::CollectionBase*>>& associationCollections,
const ObjectMappingT& objectMaps);
std::vector<std::tuple<std::string, std::unique_ptr<lcio::LCCollection>>>
createLCRelationCollections(const std::vector<std::tuple<std::string, const podio::CollectionBase*>>& linkCollections,
const ObjectMappingT& objectMaps);

/**
* Create an LCRelation collection from the passed Association Collection
* Create an LCRelation collection from the passed Link Collection
*/
template <typename AssocCollT, typename FromMapT, typename ToMapT>
std::unique_ptr<lcio::LCCollection> createLCRelationCollection(const AssocCollT& associations, const FromMapT& fromMap,
template <typename LinkCollT, typename FromMapT, typename ToMapT>
std::unique_ptr<lcio::LCCollection> createLCRelationCollection(const LinkCollT& links, const FromMapT& fromMap,
const ToMapT& toMap);

bool collectionExist(const std::string& collection_name, const lcio::LCEventImpl* lcio_event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,33 +757,30 @@ void resolveRelations(ObjectMappingT& update_pairs, const ObjectMappingU& lookup
}

template <typename ObjectMappingT>
std::vector<std::tuple<std::string, std::unique_ptr<lcio::LCCollection>>> createLCRelationCollections(
const std::vector<std::tuple<std::string, const podio::CollectionBase*>>& associationCollections,
const ObjectMappingT& objectMaps) {
std::vector<std::tuple<std::string, std::unique_ptr<lcio::LCCollection>>>
createLCRelationCollections(const std::vector<std::tuple<std::string, const podio::CollectionBase*>>& linkCollections,
const ObjectMappingT& objectMaps) {
std::vector<std::tuple<std::string, std::unique_ptr<lcio::LCCollection>>> relationColls{};
relationColls.reserve(associationCollections.size());
relationColls.reserve(linkCollections.size());

for (const auto& [name, coll] : associationCollections) {
if (const auto assocs = dynamic_cast<const edm4hep::RecoMCParticleLinkCollection*>(coll)) {
for (const auto& [name, coll] : linkCollections) {
if (const auto links = dynamic_cast<const edm4hep::RecoMCParticleLinkCollection*>(coll)) {
relationColls.emplace_back(name,
createLCRelationCollection(*assocs, objectMaps.recoParticles, objectMaps.mcParticles));
} else if (const auto assocs = dynamic_cast<const edm4hep::CaloHitSimCaloHitLinkCollection*>(coll)) {
createLCRelationCollection(*links, objectMaps.recoParticles, objectMaps.mcParticles));
} else if (const auto links = dynamic_cast<const edm4hep::CaloHitSimCaloHitLinkCollection*>(coll)) {
relationColls.emplace_back(name, createLCRelationCollection(*links, objectMaps.caloHits, objectMaps.simCaloHits));
} else if (const auto links = dynamic_cast<const edm4hep::TrackerHitSimTrackerHitLinkCollection*>(coll)) {
relationColls.emplace_back(name,
createLCRelationCollection(*assocs, objectMaps.caloHits, objectMaps.simCaloHits));
} else if (const auto assocs = dynamic_cast<const edm4hep::TrackerHitSimTrackerHitLinkCollection*>(coll)) {
relationColls.emplace_back(
name, createLCRelationCollection(*assocs, objectMaps.trackerHits, objectMaps.simTrackerHits));
} else if (const auto assocs = dynamic_cast<const edm4hep::CaloHitMCParticleLinkCollection*>(coll)) {
createLCRelationCollection(*links, objectMaps.trackerHits, objectMaps.simTrackerHits));
} else if (const auto links = dynamic_cast<const edm4hep::CaloHitMCParticleLinkCollection*>(coll)) {
relationColls.emplace_back(name, createLCRelationCollection(*links, objectMaps.caloHits, objectMaps.mcParticles));
} else if (const auto links = dynamic_cast<const edm4hep::ClusterMCParticleLinkCollection*>(coll)) {
relationColls.emplace_back(name, createLCRelationCollection(*links, objectMaps.clusters, objectMaps.mcParticles));
} else if (const auto links = dynamic_cast<const edm4hep::TrackMCParticleLinkCollection*>(coll)) {
relationColls.emplace_back(name, createLCRelationCollection(*links, objectMaps.tracks, objectMaps.mcParticles));
} else if (const auto links = dynamic_cast<const edm4hep::VertexRecoParticleLinkCollection*>(coll)) {
relationColls.emplace_back(name,
createLCRelationCollection(*assocs, objectMaps.caloHits, objectMaps.mcParticles));
} else if (const auto assocs = dynamic_cast<const edm4hep::ClusterMCParticleLinkCollection*>(coll)) {
relationColls.emplace_back(name,
createLCRelationCollection(*assocs, objectMaps.clusters, objectMaps.mcParticles));
} else if (const auto assocs = dynamic_cast<const edm4hep::TrackMCParticleLinkCollection*>(coll)) {
relationColls.emplace_back(name, createLCRelationCollection(*assocs, objectMaps.tracks, objectMaps.mcParticles));
} else if (const auto assocs = dynamic_cast<const edm4hep::VertexRecoParticleLinkCollection*>(coll)) {
relationColls.emplace_back(name,
createLCRelationCollection(*assocs, objectMaps.vertices, objectMaps.recoParticles));
createLCRelationCollection(*links, objectMaps.vertices, objectMaps.recoParticles));
} else {
std::cerr << "Trying to create an LCRelation collection from a " << coll->getTypeName()
<< " which is not supported" << std::endl;
Expand Down Expand Up @@ -820,8 +817,8 @@ namespace detail {
#undef DEFINE_TYPE_NAME
} // namespace detail

template <typename AssocCollT, typename FromMapT, typename ToMapT>
std::unique_ptr<lcio::LCCollection> createLCRelationCollection(const AssocCollT& associations, const FromMapT& fromMap,
template <typename LinkCollT, typename FromMapT, typename ToMapT>
std::unique_ptr<lcio::LCCollection> createLCRelationCollection(const LinkCollT& links, const FromMapT& fromMap,
const ToMapT& toMap) {
using FromLCIOT = std::remove_pointer_t<k4EDM4hep2LcioConv::detail::key_t<FromMapT>>;
using ToLCIOT = std::remove_pointer_t<k4EDM4hep2LcioConv::detail::key_t<ToMapT>>;
Expand All @@ -830,11 +827,11 @@ std::unique_ptr<lcio::LCCollection> createLCRelationCollection(const AssocCollT&
lcioColl->parameters().setValue("FromType", detail::getTypeName<FromLCIOT>());
lcioColl->parameters().setValue("ToType", detail::getTypeName<ToLCIOT>());

for (const auto assoc : associations) {
for (const auto link : links) {
auto lcioRel = new lcio::LCRelationImpl{};
lcioRel->setWeight(assoc.getWeight());
lcioRel->setWeight(link.getWeight());

const auto edm4hepFrom = assoc.getFrom();
const auto edm4hepFrom = link.getFrom();
const auto lcioFrom = k4EDM4hep2LcioConv::detail::mapLookupFrom(edm4hepFrom, fromMap);
if (lcioFrom) {
lcioRel->setFrom(lcioFrom.value());
Expand All @@ -843,7 +840,7 @@ std::unique_ptr<lcio::LCCollection> createLCRelationCollection(const AssocCollT&
<< std::endl;
}

const auto edm4hepTo = assoc.getTo();
const auto edm4hepTo = link.getTo();
const auto lcioTo = k4EDM4hep2LcioConv::detail::mapLookupFrom(edm4hepTo, toMap);
if (lcioTo) {
lcioRel->setTo(lcioTo.value());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ void resolveRelationsVertices(VertexMapT& vertexMap, URecoParticleMapT& updateRP
const LURecoParticleMapT& lookupRPMap);

template <typename VertexMapT, typename RecoParticleMapT>
void finalizeVertexRecoParticleLinks(edm4hep::VertexRecoParticleLinkCollection& associations,
const VertexMapT& vertexMap, const RecoParticleMapT& recoParticleMap);
void finalizeVertexRecoParticleLinks(edm4hep::VertexRecoParticleLinkCollection& links, const VertexMapT& vertexMap,
const RecoParticleMapT& recoParticleMap);

/**
* Go from chi^2 and probability (1 - CDF(chi^2, ndf)) to ndf by a binary search
Expand Down
Loading

0 comments on commit 9901515

Please sign in to comment.