From 41935b5e2b064227d4b400877773f98f482c7cc0 Mon Sep 17 00:00:00 2001 From: Wouter Deconinck Date: Mon, 20 Jan 2025 16:07:50 +0000 Subject: [PATCH] feat: support EDM4hep-0.99 relations to MCParticle --- JugDigi/src/components/PhotoMultiplierDigi.cpp | 5 +++++ JugDigi/src/components/SiliconTrackerDigi.cpp | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/JugDigi/src/components/PhotoMultiplierDigi.cpp b/JugDigi/src/components/PhotoMultiplierDigi.cpp index 82160a0..daf42e6 100644 --- a/JugDigi/src/components/PhotoMultiplierDigi.cpp +++ b/JugDigi/src/components/PhotoMultiplierDigi.cpp @@ -25,6 +25,7 @@ // Event Model related classes #include "edm4eic/RawTrackerHitCollection.h" +#include "edm4hep/EDM4hepVersion.h" #include "edm4hep/MCParticleCollection.h" #include "edm4hep/SimTrackerHitCollection.h" @@ -99,7 +100,11 @@ class PhotoMultiplierDigi : public GaudiAlgorithm } // cell id, time, signal amplitude uint64_t id = ahit.getCellID(); +#if EDM4HEP_BUILD_VERSION >= EDM4HEP_VERSION(0, 99, 0) + double time = ahit.getParticle().getTime(); +#else double time = ahit.getMCParticle().getTime(); +#endif double amp = m_speMean + m_rngNorm()*m_speError; // group hits diff --git a/JugDigi/src/components/SiliconTrackerDigi.cpp b/JugDigi/src/components/SiliconTrackerDigi.cpp index c54dbfe..18face7 100644 --- a/JugDigi/src/components/SiliconTrackerDigi.cpp +++ b/JugDigi/src/components/SiliconTrackerDigi.cpp @@ -15,7 +15,8 @@ // Event Model related classes // edm4hep's tracker hit is the input collectiopn -#include "edm4hep/MCParticle.h" +#include "edm4hep/EDM4hepVersion.h" +#include "edm4hep/MCParticleCollection.h" #include "edm4hep/SimTrackerHitCollection.h" // edm4eic's RawTrackerHit is the output #include "edm4eic/RawTrackerHitCollection.h" @@ -85,12 +86,20 @@ class SiliconTrackerDigi : public GaudiAlgorithm { cell_hit_map[ahit.getCellID()] = rawhits->size(); rawhits->create( ahit.getCellID(), +#if EDM4HEP_BUILD_VERSION >= EDM4HEP_VERSION(0, 99, 0) + ahit.getParticle().getTime() * 1e6 + m_gaussDist() * 1e3, // ns->fs +#else ahit.getMCParticle().getTime() * 1e6 + m_gaussDist() * 1e3, // ns->fs +#endif std::llround(ahit.getEDep() * 1e6) ); } else { auto hit = (*rawhits)[cell_hit_map[ahit.getCellID()]]; +#if EDM4HEP_BUILD_VERSION >= EDM4HEP_VERSION(0, 99, 0) + hit.setTimeStamp(ahit.getParticle().getTime() * 1e6 + m_gaussDist() * 1e3); +#else hit.setTimeStamp(ahit.getMCParticle().getTime() * 1e6 + m_gaussDist() * 1e3); +#endif auto ch = hit.getCharge(); hit.setCharge(ch + std::llround(ahit.getEDep() * 1e6)); }