Skip to content

Commit

Permalink
chore: update to newer podio versions (#2606)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
asalzburger and paulgessinger authored Nov 22, 2023
1 parent 3639e04 commit 60ff980
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,19 @@ void writeTrajectory(const Acts::GeometryContext& gctx, double Bz,
const Acts::ParticleHypothesis& particleHypothesis,
const IndexMultimap<ActsFatras::Barcode>& 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 <typename T>
uint64_t podioObjectIDToInteger(T&& o) {
if constexpr (!std::is_same_v<T, podio::ObjectID>) {
return o;
} else {
return o.index;
}
}

} // namespace EDM4hepUtil
} // namespace ActsExamples
3 changes: 1 addition & 2 deletions Examples/Io/EDM4hep/src/EDM4hepParticleReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions Examples/Io/EDM4hep/src/EDM4hepSimHitReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion Examples/Io/EDM4hep/src/EDM4hepUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Index>(podioObjectIDToInteger(from.id()))};

auto pos = from.getPosition();
auto cov = from.getCovMatrix();
Expand Down

0 comments on commit 60ff980

Please sign in to comment.