Skip to content

Commit

Permalink
feat: support EDM4hep-0.99 relations to MCParticle
Browse files Browse the repository at this point in the history
  • Loading branch information
wdconinc committed Jan 20, 2025
1 parent 7dfe026 commit 106eed4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions JugDigi/src/components/PhotoMultiplierDigi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

// Event Model related classes
#include "edm4eic/RawTrackerHitCollection.h"
#include "edm4hep/EDM4hepVersion.h"
#include "edm4hep/MCParticleCollection.h"
#include "edm4hep/SimTrackerHitCollection.h"

Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions JugDigi/src/components/SiliconTrackerDigi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

// Event Model related classes
// edm4hep's tracker hit is the input collectiopn
#include "edm4hep/MCParticleCollection.h"
#include "edm4hep/MCParticle.h"
#include "edm4hep/SimTrackerHitCollection.h"
// edm4eic's RawTrackerHit is the output
Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit 106eed4

Please sign in to comment.