diff --git a/README.md b/README.md index 54550df..0391284 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/doc/LCIO2EDM4hep.md b/doc/LCIO2EDM4hep.md index 5e09e9e..a4e954c 100644 --- a/doc/LCIO2EDM4hep.md +++ b/doc/LCIO2EDM4hep.md @@ -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 diff --git a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h index 1520435..d8c5a5f 100644 --- a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h +++ b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.h @@ -332,18 +332,18 @@ template void resolveRelations(ObjectMappingT& updateMaps, const ObjectMappingU& lookupMaps); /** - * Convert the passed associatoin collections to LCRelation collections + * Convert the passed link collections to LCRelation collections */ template -std::vector>> createLCRelationCollections( - const std::vector>& associationCollections, - const ObjectMappingT& objectMaps); +std::vector>> +createLCRelationCollections(const std::vector>& linkCollections, + const ObjectMappingT& objectMaps); /** - * Create an LCRelation collection from the passed Association Collection + * Create an LCRelation collection from the passed Link Collection */ -template -std::unique_ptr createLCRelationCollection(const AssocCollT& associations, const FromMapT& fromMap, +template +std::unique_ptr createLCRelationCollection(const LinkCollT& links, const FromMapT& fromMap, const ToMapT& toMap); bool collectionExist(const std::string& collection_name, const lcio::LCEventImpl* lcio_event); diff --git a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.ipp b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.ipp index e725f48..c5a7a1b 100644 --- a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.ipp +++ b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4EDM4hep2LcioConv.ipp @@ -757,33 +757,30 @@ void resolveRelations(ObjectMappingT& update_pairs, const ObjectMappingU& lookup } template -std::vector>> createLCRelationCollections( - const std::vector>& associationCollections, - const ObjectMappingT& objectMaps) { +std::vector>> +createLCRelationCollections(const std::vector>& linkCollections, + const ObjectMappingT& objectMaps) { std::vector>> relationColls{}; - relationColls.reserve(associationCollections.size()); + relationColls.reserve(linkCollections.size()); - for (const auto& [name, coll] : associationCollections) { - if (const auto assocs = dynamic_cast(coll)) { + for (const auto& [name, coll] : linkCollections) { + if (const auto links = dynamic_cast(coll)) { relationColls.emplace_back(name, - createLCRelationCollection(*assocs, objectMaps.recoParticles, objectMaps.mcParticles)); - } else if (const auto assocs = dynamic_cast(coll)) { + createLCRelationCollection(*links, objectMaps.recoParticles, objectMaps.mcParticles)); + } else if (const auto links = dynamic_cast(coll)) { + relationColls.emplace_back(name, createLCRelationCollection(*links, objectMaps.caloHits, objectMaps.simCaloHits)); + } else if (const auto links = dynamic_cast(coll)) { relationColls.emplace_back(name, - createLCRelationCollection(*assocs, objectMaps.caloHits, objectMaps.simCaloHits)); - } else if (const auto assocs = dynamic_cast(coll)) { - relationColls.emplace_back( - name, createLCRelationCollection(*assocs, objectMaps.trackerHits, objectMaps.simTrackerHits)); - } else if (const auto assocs = dynamic_cast(coll)) { + createLCRelationCollection(*links, objectMaps.trackerHits, objectMaps.simTrackerHits)); + } else if (const auto links = dynamic_cast(coll)) { + relationColls.emplace_back(name, createLCRelationCollection(*links, objectMaps.caloHits, objectMaps.mcParticles)); + } else if (const auto links = dynamic_cast(coll)) { + relationColls.emplace_back(name, createLCRelationCollection(*links, objectMaps.clusters, objectMaps.mcParticles)); + } else if (const auto links = dynamic_cast(coll)) { + relationColls.emplace_back(name, createLCRelationCollection(*links, objectMaps.tracks, objectMaps.mcParticles)); + } else if (const auto links = dynamic_cast(coll)) { relationColls.emplace_back(name, - createLCRelationCollection(*assocs, objectMaps.caloHits, objectMaps.mcParticles)); - } else if (const auto assocs = dynamic_cast(coll)) { - relationColls.emplace_back(name, - createLCRelationCollection(*assocs, objectMaps.clusters, objectMaps.mcParticles)); - } else if (const auto assocs = dynamic_cast(coll)) { - relationColls.emplace_back(name, createLCRelationCollection(*assocs, objectMaps.tracks, objectMaps.mcParticles)); - } else if (const auto assocs = dynamic_cast(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; @@ -820,8 +817,8 @@ namespace detail { #undef DEFINE_TYPE_NAME } // namespace detail -template -std::unique_ptr createLCRelationCollection(const AssocCollT& associations, const FromMapT& fromMap, +template +std::unique_ptr createLCRelationCollection(const LinkCollT& links, const FromMapT& fromMap, const ToMapT& toMap) { using FromLCIOT = std::remove_pointer_t>; using ToLCIOT = std::remove_pointer_t>; @@ -830,11 +827,11 @@ std::unique_ptr createLCRelationCollection(const AssocCollT& lcioColl->parameters().setValue("FromType", detail::getTypeName()); lcioColl->parameters().setValue("ToType", detail::getTypeName()); - 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()); @@ -843,7 +840,7 @@ std::unique_ptr 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()); diff --git a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.h b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.h index 9c1a33e..b911711 100644 --- a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.h +++ b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.h @@ -403,8 +403,8 @@ void resolveRelationsVertices(VertexMapT& vertexMap, URecoParticleMapT& updateRP const LURecoParticleMapT& lookupRPMap); template -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 diff --git a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.ipp b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.ipp index 289f7f7..b5b74c7 100644 --- a/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.ipp +++ b/k4EDM4hep2LcioConv/include/k4EDM4hep2LcioConv/k4Lcio2EDM4hepConv.ipp @@ -119,7 +119,7 @@ template std::vector convertReconstructedParticles(const std::string& name, EVENT::LCCollection* LCCollection, RecoMapT& recoparticlesMap) { auto dest = std::make_unique(); - auto startVertexAssocs = std::make_unique(); + auto startVertexLinks = std::make_unique(); // Set up a PIDHandler to split off the ParticlID objects stored in the // reconstructed particles into separate collections. Each algorithm id / @@ -167,10 +167,10 @@ std::vector convertReconstructedParticles(const std::string& name, } } - // Keep track of the startVertex associations + // Keep track of the startVertex links if (rval->getStartVertex() != nullptr) { - auto assoc = startVertexAssocs->create(); - assoc.setTo(lval); + auto link = startVertexLinks->create(); + link.setTo(lval); } } @@ -180,7 +180,7 @@ std::vector convertReconstructedParticles(const std::string& name, for (auto& [id, coll] : particleIDs) { results.emplace_back(getPIDCollName(name, pidHandler.getAlgorithmName(id)), std::move(coll)); } - results.emplace_back(name + "_startVertices", std::move(startVertexAssocs)); + results.emplace_back(name + "_startVertices", std::move(startVertexLinks)); return results; } @@ -790,39 +790,37 @@ void resolveRelationsVertices(VertexMapT& vertexMap, URecoParticleMapT& updateRP } template -void finalizeVertexRecoParticleLinks(edm4hep::VertexRecoParticleLinkCollection& associations, - const VertexMapT& vertexMap, const RecoParticleMapT& recoParticleMap) { - for (auto assoc : associations) { - auto assocRec = assoc.getTo(); - auto assocVtx = assoc.getFrom(); - - if (assocRec.isAvailable()) { - // This is the association that points from the particles to their start vertex - if (const auto lcioRec = k4EDM4hep2LcioConv::detail::mapLookupFrom(assocRec, recoParticleMap)) { +void finalizeVertexRecoParticleLinks(edm4hep::VertexRecoParticleLinkCollection& links, const VertexMapT& vertexMap, + const RecoParticleMapT& recoParticleMap) { + for (auto link : links) { + auto linkRec = link.getTo(); + auto linkVtx = link.getFrom(); + + if (linkRec.isAvailable()) { + // This is the link that points from the particles to their start vertex + if (const auto lcioRec = k4EDM4hep2LcioConv::detail::mapLookupFrom(linkRec, recoParticleMap)) { const auto lcioStartVtx = lcioRec.value()->getStartVertex(); if (const auto startVtx = k4EDM4hep2LcioConv::detail::mapLookupTo(lcioStartVtx, vertexMap)) { - assoc.setFrom(startVtx.value()); + link.setFrom(startVtx.value()); } else { - std::cerr << "Could not find start vertex while finalizing the RecoParticle - Vertex associations" - << std::endl; + std::cerr << "Could not find start vertex while finalizing the RecoParticle - Vertex links" << std::endl; } } else { - std::cerr - << "Could not find a corresponding LCIO reco particle for finalizing the RecoParticle - Vertex associations" - << std::endl; + std::cerr << "Could not find a corresponding LCIO reco particle for finalizing the RecoParticle - Vertex links" + << std::endl; } } else { - // This is the association that points from the vertex to the associated particle - if (const auto lcioVtx = k4EDM4hep2LcioConv::detail::mapLookupFrom(assocVtx, vertexMap)) { - const auto lcioAssocParticle = lcioVtx.value()->getAssociatedParticle(); - if (const auto assocParticle = k4EDM4hep2LcioConv::detail::mapLookupTo(lcioAssocParticle, recoParticleMap)) { - assoc.setTo(assocParticle.value()); + // This is the link that points from the vertex to the linkiated particle + if (const auto lcioVtx = k4EDM4hep2LcioConv::detail::mapLookupFrom(linkVtx, vertexMap)) { + const auto lcioLinkParticle = lcioVtx.value()->getAssociatedParticle(); + if (const auto linkParticle = k4EDM4hep2LcioConv::detail::mapLookupTo(lcioLinkParticle, recoParticleMap)) { + link.setTo(linkParticle.value()); } else { - std::cerr << "Could not find an associated particle while finalizing the RecoParticle - Vertex associations" + std::cerr << "Could not find an linkiated particle while finalizing the RecoParticle - Vertex links" << std::endl; } } else { - std::cerr << "Could not find a corresponding LCIO vertex for finalizing the RecoParticle - Vertex associations" + std::cerr << "Could not find a corresponding LCIO vertex for finalizing the RecoParticle - Vertex links" << std::endl; } } @@ -849,12 +847,12 @@ template std::unique_ptr createLinkCollection(EVENT::LCCollection* relations, const FromMapT& fromMap, const ToMapT& toMap) { - auto assocColl = std::make_unique(); + auto linkColl = std::make_unique(); auto relIter = UTIL::LCIterator(relations); while (const auto rel = relIter.next()) { - auto assoc = assocColl->create(); - assoc.setWeight(rel->getWeight()); + auto link = linkColl->create(); + link.setWeight(rel->getWeight()); const auto lcioTo = static_cast(rel->getTo()); const auto lcioFrom = static_cast(rel->getFrom()); const auto edm4hepTo = k4EDM4hep2LcioConv::detail::mapLookupTo(lcioTo, toMap); @@ -862,31 +860,31 @@ std::unique_ptr createLinkCollection(EVENT::LCCollection* relations, cons if (edm4hepTo.has_value() && edm4hepFrom.has_value()) { if constexpr (Reverse) { if constexpr (std::is_same_v, edm4hep::MutableVertex>) { - assoc.setFrom(*edm4hepTo); - assoc.setTo(*edm4hepFrom); + link.setFrom(*edm4hepTo); + link.setTo(*edm4hepFrom); } else { - assoc.setTo(*edm4hepTo); - assoc.setFrom(*edm4hepFrom); + link.setTo(*edm4hepTo); + link.setFrom(*edm4hepFrom); } } else { if constexpr (std::is_same_v, edm4hep::MutableVertex>) { - assoc.setFrom(*edm4hepFrom); - assoc.setTo(*edm4hepTo); + link.setFrom(*edm4hepFrom); + link.setTo(*edm4hepTo); } else { - assoc.setTo(*edm4hepFrom); - assoc.setFrom(*edm4hepTo); + link.setTo(*edm4hepFrom); + link.setFrom(*edm4hepTo); } } } } - return assocColl; + return linkColl; } template std::vector createLinks(const ObjectMappingT& typeMapping, const std::vector>& LCRelation) { - std::vector assoCollVec; + std::vector linksCollVec; for (const auto& [name, relations] : LCRelation) { const auto& params = relations->getParameters(); @@ -901,70 +899,70 @@ std::vector createLinks(const ObjectMappingT& typeMapping, if (fromType == "MCParticle" && toType == "ReconstructedParticle") { auto mc_a = createLinkCollection(relations, typeMapping.mcParticles, typeMapping.recoParticles); - assoCollVec.emplace_back(name, std::move(mc_a)); + linksCollVec.emplace_back(name, std::move(mc_a)); } else if (fromType == "ReconstructedParticle" && toType == "MCParticle") { auto mc_a = createLinkCollection( relations, typeMapping.recoParticles, typeMapping.mcParticles); - assoCollVec.emplace_back(name, std::move(mc_a)); + linksCollVec.emplace_back(name, std::move(mc_a)); } else if (fromType == "CalorimeterHit" && toType == "SimCalorimeterHit") { auto mc_a = createLinkCollection(relations, typeMapping.caloHits, typeMapping.simCaloHits); - assoCollVec.emplace_back(name, std::move(mc_a)); + linksCollVec.emplace_back(name, std::move(mc_a)); } else if (fromType == "SimCalorimeterHit" && toType == "CalorimeterHit") { auto mc_a = createLinkCollection( relations, typeMapping.simCaloHits, typeMapping.caloHits); - assoCollVec.emplace_back(name, std::move(mc_a)); + linksCollVec.emplace_back(name, std::move(mc_a)); } else if (fromType == "Cluster" && toType == "MCParticle") { auto mc_a = createLinkCollection(relations, typeMapping.clusters, typeMapping.mcParticles); - assoCollVec.emplace_back(name, std::move(mc_a)); + linksCollVec.emplace_back(name, std::move(mc_a)); } else if (fromType == "MCParticle" && toType == "Cluster") { auto mc_a = createLinkCollection( relations, typeMapping.mcParticles, typeMapping.clusters); - assoCollVec.emplace_back(name, std::move(mc_a)); + linksCollVec.emplace_back(name, std::move(mc_a)); } else if (fromType == "MCParticle" && toType == "Track") { auto mc_a = createLinkCollection( relations, typeMapping.mcParticles, typeMapping.tracks); - assoCollVec.emplace_back(name, std::move(mc_a)); + linksCollVec.emplace_back(name, std::move(mc_a)); } else if (fromType == "Track" && toType == "MCParticle") { auto mc_a = createLinkCollection(relations, typeMapping.tracks, typeMapping.mcParticles); - assoCollVec.emplace_back(name, std::move(mc_a)); + linksCollVec.emplace_back(name, std::move(mc_a)); } else if (fromType == "TrackerHit" && toType == "SimTrackerHit") { auto mc_a = createLinkCollection( relations, typeMapping.trackerHits, typeMapping.simTrackerHits); - assoCollVec.emplace_back(name, std::move(mc_a)); + linksCollVec.emplace_back(name, std::move(mc_a)); } else if (fromType == "TrackerHitPlane" && toType == "SimTrackerHit") { auto mc_a = createLinkCollection( relations, typeMapping.trackerHitPlanes, typeMapping.simTrackerHits); - assoCollVec.emplace_back(name, std::move(mc_a)); + linksCollVec.emplace_back(name, std::move(mc_a)); } else if (fromType == "SimTrackerHit" && (toType == "TrackerHit" || toType == "TrackerHitPlane")) { auto mc_a = createLinkCollection( relations, typeMapping.simTrackerHits, typeMapping.trackerHits); - assoCollVec.emplace_back(name, std::move(mc_a)); + linksCollVec.emplace_back(name, std::move(mc_a)); } else if (fromType == "ReconstructedParticle" && toType == "Vertex") { auto mc_a = createLinkCollection( relations, typeMapping.recoParticles, typeMapping.vertices); - assoCollVec.emplace_back(name, std::move(mc_a)); + linksCollVec.emplace_back(name, std::move(mc_a)); } else if (fromType == "Vertex" && toType == "ReconstructedParticle") { auto mc_a = createLinkCollection( relations, typeMapping.vertices, typeMapping.recoParticles); - assoCollVec.emplace_back(name, std::move(mc_a)); + linksCollVec.emplace_back(name, std::move(mc_a)); } else if (fromType == "CalorimeterHit" && toType == "MCParticle") { auto assoc = createLinkCollection(relations, typeMapping.caloHits, typeMapping.mcParticles); - assoCollVec.emplace_back(name, std::move(assoc)); + linksCollVec.emplace_back(name, std::move(assoc)); } else if (fromType == "MCParticle" && toType == "CalorimeterHit") { auto assoc = createLinkCollection( relations, typeMapping.mcParticles, typeMapping.caloHits); - assoCollVec.emplace_back(name, std::move(assoc)); + linksCollVec.emplace_back(name, std::move(assoc)); } else { std::cout << "Relation from: " << fromType << " to: " << toType << " (" << name << ") is not beeing handled during creation of associations" << std::endl; } } - return assoCollVec; + return linksCollVec; } template diff --git a/k4EDM4hep2LcioConv/src/k4EDM4hep2LcioConv.cpp b/k4EDM4hep2LcioConv/src/k4EDM4hep2LcioConv.cpp index b643d8c..2075816 100644 --- a/k4EDM4hep2LcioConv/src/k4EDM4hep2LcioConv.cpp +++ b/k4EDM4hep2LcioConv/src/k4EDM4hep2LcioConv.cpp @@ -75,7 +75,7 @@ std::unique_ptr convertEvent(const podio::Frame& edmEvent, co // We convert these at the very end, once all the necessary information is // available - std::vector> associations{}; + std::vector> linkCollections{}; std::vector dQdxCollections{}; const auto& collections = edmEvent.getAvailableCollections(); @@ -131,7 +131,7 @@ std::unique_ptr convertEvent(const podio::Frame& edmEvent, co // "converted" during relation resolving later continue; } else if (edmCollection->getTypeName().find("Link") != std::string_view::npos) { - associations.emplace_back(name, edmCollection); + linkCollections.emplace_back(name, edmCollection); } else { std::cerr << "Error trying to convert requested " << edmCollection->getValueTypeName() << " with name " << name << "\n" @@ -155,7 +155,7 @@ std::unique_ptr convertEvent(const podio::Frame& edmEvent, co resolveRelations(objectMappings); - for (auto& [name, coll] : createLCRelationCollections(associations, objectMappings)) { + for (auto& [name, coll] : createLCRelationCollections(linkCollections, objectMappings)) { lcioEvent->addCollection(coll.release(), name); } diff --git a/k4EDM4hep2LcioConv/src/k4Lcio2EDM4hepConv.cpp b/k4EDM4hep2LcioConv/src/k4Lcio2EDM4hepConv.cpp index 18e91a8..6c58f94 100644 --- a/k4EDM4hep2LcioConv/src/k4Lcio2EDM4hepConv.cpp +++ b/k4EDM4hep2LcioConv/src/k4Lcio2EDM4hepConv.cpp @@ -86,7 +86,7 @@ podio::Frame convertEvent(EVENT::LCEvent* evt, const std::vectorgetTypeName(); if (lciotype == "LCRelation") { LCRelations.push_back(std::make_pair(lcioname, lcioColl)); - // We handle Relations (aka Associations) once we have converted all the + // We handle Relations (aka Links) once we have converted all the // data parts. continue; } @@ -112,9 +112,9 @@ podio::Frame convertEvent(EVENT::LCEvent* evt, const std::vector -bool compare(const AssociationCollT& origColl, const AssociationCollT& roundtripColl) { +template +bool compare(const LinkCollT& origColl, const LinkCollT& roundtripColl) { REQUIRE_SAME(origColl.size(), roundtripColl.size(), "collection sizes"); for (size_t i = 0; i < origColl.size(); ++i) { - const auto origAssoc = origColl[i]; - const auto assoc = roundtripColl[i]; + const auto origLink = origColl[i]; + const auto link = roundtripColl[i]; - REQUIRE_SAME(origAssoc.getWeight(), assoc.getWeight(), "weight in association " << i); - REQUIRE_SAME(origAssoc.getTo().id(), assoc.getTo().id(), "MC part(icle) in association " << i); - REQUIRE_SAME(origAssoc.getFrom().id(), assoc.getFrom().id(), "reco part(icle) in association " << i); + REQUIRE_SAME(origLink.getWeight(), link.getWeight(), "weight in link " << i); + REQUIRE_SAME(origLink.getTo().id(), link.getTo().id(), "MC part(icle) in link " << i); + REQUIRE_SAME(origLink.getFrom().id(), link.getFrom().id(), "reco part(icle) in link " << i); } return true; } diff --git a/tests/src/CompareEDM4hepLCIO.cc b/tests/src/CompareEDM4hepLCIO.cc index c83a032..4442f92 100644 --- a/tests/src/CompareEDM4hepLCIO.cc +++ b/tests/src/CompareEDM4hepLCIO.cc @@ -474,19 +474,19 @@ bool compareEventHeader(const EVENT::LCEvent* lcevt, const podio::Frame* edmEven return true; } -// bool compareStartVertexRelations(const edm4hep::VertexRecoParticleLinkCollection& startVtxAssociations, const +// bool compareStartVertexRelations(const edm4hep::VertexRecoParticleLinkCollection& startVtxLinks, const // ObjectMappings& objectMaps, const podio::Frame& event) { -// for (const auto& assoc : startVtxAssociations) { -// const auto edmVtx = assoc.getVertex(); -// const auto edmReco = assoc.getRec(); +// for (const auto& link : startVtxLinks) { +// const auto edmVtx = link.getVertex(); +// const auto edmReco = link.getRec(); // } // } bool compareStartVertexRelations(const EVENT::ReconstructedParticle* lcioReco, - const edm4hep::VertexRecoParticleLink& association, const ObjectMappings& objectMaps) { + const edm4hep::VertexRecoParticleLink& link, const ObjectMappings& objectMaps) { const auto lcioVertex = lcioReco->getStartVertex(); - const auto edm4hepVertex = association.getFrom(); + const auto edm4hepVertex = link.getFrom(); if (!compareRelation(lcioVertex, edm4hepVertex, objectMaps.vertices, "")) { return false; } @@ -494,7 +494,7 @@ bool compareStartVertexRelations(const EVENT::ReconstructedParticle* lcioReco, return true; } -bool compareVertexRecoAssociation(const EVENT::Vertex*, const edm4hep::VertexRecoParticleLink&, const ObjectMappings&) { +bool compareVertexRecoLink(const EVENT::Vertex*, const edm4hep::VertexRecoParticleLink&, const ObjectMappings&) { // TODO: Actually implement the checks // TODO: Figure out if this is even the right interface here return false; diff --git a/tests/src/CompareEDM4hepLCIO.h b/tests/src/CompareEDM4hepLCIO.h index 929dc59..42cf3bc 100644 --- a/tests/src/CompareEDM4hepLCIO.h +++ b/tests/src/CompareEDM4hepLCIO.h @@ -118,14 +118,14 @@ bool compare(const EVENT::ParticleID* lcio, const edm4hep::ParticleID& edm4hep); bool compareEventHeader(const EVENT::LCEvent* lcevt, const podio::Frame* edmEvent); -template -bool compare(const lcio::LCCollection* lcioCollection, const AssocCollT& edm4hepCollection, +template +bool compare(const lcio::LCCollection* lcioCollection, const LinkCollT& edm4hepCollection, const ObjectMappings& objectMaps) { return compareCollection(lcioCollection, edm4hepCollection, objectMaps); } namespace detail { -template +template struct LcioFromToTypeHelper; template <> @@ -170,11 +170,11 @@ struct LcioFromToTypeHelper { using to_type = EVENT::Vertex; }; -template -using getLcioFromType = typename LcioFromToTypeHelper::from_type; +template +using getLcioFromType = typename LcioFromToTypeHelper::from_type; -template -using getLcioToType = typename LcioFromToTypeHelper::to_type; +template +using getLcioToType = typename LcioFromToTypeHelper::to_type; template const auto& getObjectMap(const ObjectMappings& maps) { @@ -201,25 +201,24 @@ const auto& getObjectMap(const ObjectMappings& maps) { } // namespace detail -template -bool compare(const EVENT::LCRelation* lcio, const AssocT& edm4hep, const ObjectMappings& objectMaps) { +template +bool compare(const EVENT::LCRelation* lcio, const LinkT& edm4hep, const ObjectMappings& objectMaps) { - ASSERT_COMPARE(lcio, edm4hep, getWeight, "weight in relation / association"); + ASSERT_COMPARE(lcio, edm4hep, getWeight, "weight in relation / link"); - using LcioFromT = detail::getLcioFromType; - using LcioToT = detail::getLcioToType; + using LcioFromT = detail::getLcioFromType; + using LcioToT = detail::getLcioToType; const auto lcioFrom = static_cast(lcio->getFrom()); const auto edm4hepFrom = edm4hep.getFrom(); if (!compareRelation(lcioFrom, edm4hepFrom, detail::getObjectMap(objectMaps), - "from object in relation / association")) { + "from object in relation / link")) { return false; } const auto lcioTo = static_cast(lcio->getTo()); const auto edm4hepTo = edm4hep.getTo(); - if (!compareRelation(lcioTo, edm4hepTo, detail::getObjectMap(objectMaps), - "to object in relation / association")) { + if (!compareRelation(lcioTo, edm4hepTo, detail::getObjectMap(objectMaps), "to object in relation / link")) { return false; } @@ -229,11 +228,11 @@ bool compare(const EVENT::LCRelation* lcio, const AssocT& edm4hep, const ObjectM /// Compare the information stored in startVertex in LCIO bool compareStartVertexRelations(const EVENT::ReconstructedParticle* lcioReco, - const edm4hep::VertexRecoParticleLink& association, const ObjectMappings& objectMaps); + const edm4hep::VertexRecoParticleLink& link, const ObjectMappings& objectMaps); /// Compare the information stored in associatedParticle in LCIO -bool compareVertexRecoAssociation(const EVENT::Vertex* lcioVtx, const edm4hep::VertexRecoParticleLink& association, - const ObjectMappings& objectMaps); +bool compareVertexRecoLink(const EVENT::Vertex* lcioVtx, const edm4hep::VertexRecoParticleLink& link, + const ObjectMappings& objectMaps); #define ASSERT_COMPARE_OR_EXIT(collType) \ if (type == #collType) { \ diff --git a/tests/src/EDM4hep2LCIOUtilities.cc b/tests/src/EDM4hep2LCIOUtilities.cc index b527b64..693bffa 100644 --- a/tests/src/EDM4hep2LCIOUtilities.cc +++ b/tests/src/EDM4hep2LCIOUtilities.cc @@ -348,32 +348,32 @@ createParticleIDs(const std::vector>& recoIdcs, return collections; } -template -AssocCollT createAssociationCollection(const CollT& collA, const CollU& collB) { +template +LinkCollT createLinkCollection(const CollT& collA, const CollU& collB) { const auto maxSize = std::min(collA.size(), collB.size()); - auto assocs = AssocCollT{}; + auto links = LinkCollT{}; for (size_t i = 0; i < maxSize; ++i) { - auto assoc = assocs.create(); - assoc.setWeight(i * 10.f / maxSize); - assoc.setTo(collA[i]); - assoc.setFrom(collB[maxSize - 1 - i]); + auto link = links.create(); + link.setWeight(i * 10.f / maxSize); + link.setTo(collA[i]); + link.setFrom(collB[maxSize - 1 - i]); } - return assocs; + return links; } edm4hep::RecoMCParticleLinkCollection -createMCRecoParticleAssocs(const edm4hep::MCParticleCollection& mcParticles, - const edm4hep::ReconstructedParticleCollection& recoParticles) { - return createAssociationCollection(mcParticles, recoParticles); +createMCRecoParticleLinks(const edm4hep::MCParticleCollection& mcParticles, + const edm4hep::ReconstructedParticleCollection& recoParticles) { + return createLinkCollection(mcParticles, recoParticles); } -edm4hep::CaloHitSimCaloHitLinkCollection createMCCaloAssocs(const edm4hep::SimCalorimeterHitCollection& simHits, - const edm4hep::CalorimeterHitCollection& caloHits) { +edm4hep::CaloHitSimCaloHitLinkCollection createMCCaloLinks(const edm4hep::SimCalorimeterHitCollection& simHits, + const edm4hep::CalorimeterHitCollection& caloHits) { - return createAssociationCollection(simHits, caloHits); + return createLinkCollection(simHits, caloHits); } std::tuple createExampleEvent() { @@ -454,14 +454,14 @@ std::tuple createExampleEvent() { algoId++; } - event.put(createMCRecoParticleAssocs(mcParticles, recoColl), "mcRecoAssocs"); - event.put(createMCCaloAssocs(simCaloHits, caloHits), "mcCaloHitsAssocs"); + event.put(createMCRecoParticleLinks(mcParticles, recoColl), "mcRecoLinks"); + event.put(createMCCaloLinks(simCaloHits, caloHits), "mcCaloHitsLinks"); - auto [vtxColl, vtxRecos, startVtxAssocs] = + auto [vtxColl, vtxRecos, startVtxLinks] = createVertices(test_config::nVertices, recoColl, test_config::vtxParticleIdcs, test_config::recoVtxIdcs); event.put(std::move(vtxColl), "vertices"); event.put(std::move(vtxRecos), "vtx_recos"); - event.put(std::move(startVtxAssocs), "startVtxAssocs"); + event.put(std::move(startVtxLinks), "startVtxLinks"); return retTuple; } diff --git a/tests/src/EDM4hep2LCIOUtilities.h b/tests/src/EDM4hep2LCIOUtilities.h index ec00438..c747bf1 100644 --- a/tests/src/EDM4hep2LCIOUtilities.h +++ b/tests/src/EDM4hep2LCIOUtilities.h @@ -183,8 +183,8 @@ createParticleIDs(const std::vector>& recoIdcs, const edm4hep::ReconstructedParticleCollection& recoParticles); edm4hep::RecoMCParticleLinkCollection -createMCRecoParticleAssocs(const edm4hep::MCParticleCollection& mcParticles, - const edm4hep::ReconstructedParticleCollection& recoParticles); +createMCRecoParticleLinks(const edm4hep::MCParticleCollection& mcParticles, + const edm4hep::ReconstructedParticleCollection& recoParticles); edm4hep::CaloHitSimCaloHitLinkCollection createMCCaloAssocs(const edm4hep::SimCalorimeterHitCollection& simHits, const edm4hep::CalorimeterHitCollection& caloHits);