From 60ff9805719ea948b9ff8ef35b1870d39eae2864 Mon Sep 17 00:00:00 2001 From: Andreas Salzburger Date: Wed, 22 Nov 2023 10:17:20 +0100 Subject: [PATCH] chore: update to newer podio versions (#2606) This PR has a small modification to access the index of `podio::ObjectID` directly, and thus makes ACTS compatible with newer `podio` versions. Co-authored-by: Paul Gessinger <1058585+paulgessinger@users.noreply.github.com> --- .../ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp | 14 ++++++++++++++ Examples/Io/EDM4hep/src/EDM4hepParticleReader.cpp | 3 +-- Examples/Io/EDM4hep/src/EDM4hepSimHitReader.cpp | 7 +++---- Examples/Io/EDM4hep/src/EDM4hepUtil.cpp | 3 ++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp index 4574b0c0407..11b731125bc 100644 --- a/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp +++ b/Examples/Io/EDM4hep/include/ActsExamples/Io/EDM4hep/EDM4hepUtil.hpp @@ -118,5 +118,19 @@ void writeTrajectory(const Acts::GeometryContext& gctx, double Bz, const Acts::ParticleHypothesis& particleHypothesis, const IndexMultimap& hitParticlesMap); +/// Helper function to either return an id as is, or unpack an index from it +/// if it is a podio::ObjectID. +/// @tparam T The type of the id. +/// @param o The id to convert. +/// @return The id as an unsigned integer. +template +uint64_t podioObjectIDToInteger(T&& o) { + if constexpr (!std::is_same_v) { + return o; + } else { + return o.index; + } +} + } // namespace EDM4hepUtil } // namespace ActsExamples diff --git a/Examples/Io/EDM4hep/src/EDM4hepParticleReader.cpp b/Examples/Io/EDM4hep/src/EDM4hepParticleReader.cpp index 0cbf3ee9a1a..96c6d5572b2 100644 --- a/Examples/Io/EDM4hep/src/EDM4hepParticleReader.cpp +++ b/Examples/Io/EDM4hep/src/EDM4hepParticleReader.cpp @@ -55,8 +55,7 @@ ProcessCode EDM4hepParticleReader::read(const AlgorithmContext& ctx) { auto particle = EDM4hepUtil::readParticle(mcParticle, [](const edm4hep::MCParticle& p) { ActsFatras::Barcode result; - // TODO dont use podio internal id - result.setParticle(p.id()); + result.setParticle(EDM4hepUtil::podioObjectIDToInteger(p.id())); return result; }); unordered.push_back(particle); diff --git a/Examples/Io/EDM4hep/src/EDM4hepSimHitReader.cpp b/Examples/Io/EDM4hep/src/EDM4hepSimHitReader.cpp index 00b5de279d9..aa036811f3f 100644 --- a/Examples/Io/EDM4hep/src/EDM4hepSimHitReader.cpp +++ b/Examples/Io/EDM4hep/src/EDM4hepSimHitReader.cpp @@ -54,8 +54,7 @@ ProcessCode EDM4hepSimHitReader::read(const AlgorithmContext& ctx) { auto particle = EDM4hepUtil::readParticle( mcParticle, [](const edm4hep::MCParticle& p) { ActsFatras::Barcode result; - // TODO dont use podio internal id - result.setParticle(p.id()); + result.setParticle(EDM4hepUtil::podioObjectIDToInteger(p.id())); return result; }); unordered.push_back(particle); @@ -78,8 +77,8 @@ ProcessCode EDM4hepSimHitReader::read(const AlgorithmContext& ctx) { simTrackerHit, [](const edm4hep::MCParticle& particle) { ActsFatras::Barcode result; - // TODO dont use podio internal id - result.setParticle(particle.id()); + result.setParticle( + EDM4hepUtil::podioObjectIDToInteger(particle.id())); return result; }, [&](std::uint64_t cellId) { diff --git a/Examples/Io/EDM4hep/src/EDM4hepUtil.cpp b/Examples/Io/EDM4hep/src/EDM4hepUtil.cpp index 7fe55d41bfe..aef0d6cb191 100644 --- a/Examples/Io/EDM4hep/src/EDM4hepUtil.cpp +++ b/Examples/Io/EDM4hep/src/EDM4hepUtil.cpp @@ -152,7 +152,8 @@ Measurement EDM4hepUtil::readMeasurement( // no need for digitization as we only want to identify the sensor Acts::GeometryIdentifier geometryId = geometryMapper(from.getCellID()); - IndexSourceLink sourceLink{geometryId, from.id()}; + IndexSourceLink sourceLink{ + geometryId, static_cast(podioObjectIDToInteger(from.id()))}; auto pos = from.getPosition(); auto cov = from.getCovMatrix();