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 authored Jan 16, 2025
1 parent fddfc5f commit 0219a65
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/algorithms/digi/SiliconTrackerDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <Evaluator/DD4hepUnits.h>
#include <edm4eic/EDM4eicVersion.h>
#include <edm4hep/EDM4hepVersion.h>
#include <edm4hep/MCParticleCollection.h>
#include <edm4hep/Vector3d.h>
#include <edm4hep/Vector3f.h>
Expand Down Expand Up @@ -54,7 +55,11 @@ void SiliconTrackerDigi::process(
debug(" momentum = ({:.2f}, {:.2f}, {:.2f})", sim_hit.getMomentum().x, sim_hit.getMomentum().y, sim_hit.getMomentum().z);
debug(" edep = {:.2f}", sim_hit.getEDep());
debug(" time = {:.4f}[ns]", sim_hit.getTime());
#if EDM4HEP_BUILD_VERSION >= EDM4HEP_VERSION(0, 99, 0)
debug(" particle time = {}[ns]", sim_hit.getParticle().getTime());
#else
debug(" particle time = {}[ns]", sim_hit.getMCParticle().getTime());
#endif
debug(" time smearing: {:.4f}, resulting time = {:.4f} [ns]", time_smearing, result_time);
debug(" hit_time_stamp: {} [~ps]", hit_time_stamp);

Expand Down
5 changes: 5 additions & 0 deletions src/algorithms/pid/IrtCherenkovParticleID.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <edm4eic/CherenkovParticleIDHypothesis.h>
#include <edm4eic/EDM4eicVersion.h>
#include <edm4eic/TrackPoint.h>
#include <edm4hep/EDM4hepVersion.h>
#include <edm4hep/MCParticleCollection.h>
#include <edm4hep/SimTrackerHitCollection.h>
#include <edm4hep/Vector2f.h>
Expand Down Expand Up @@ -218,7 +219,11 @@ void IrtCherenkovParticleID::process(
if(hit_assoc.getRawHit().isAvailable()) {
if(hit_assoc.getRawHit().id() == raw_hit.id()) {
#if EDM4EIC_VERSION_MAJOR >= 6
# if EDM4HEP_BUILD_VERSION >= EDM4HEP_VERSION(0, 99, 0)
mc_photon = hit_assoc.getSimHit().getParticle();
# else
mc_photon = hit_assoc.getSimHit().getMCParticle();
# endif
#else
// hit association found, get the MC photon and break the loop
if(hit_assoc.simHits_size() > 0) {
Expand Down
5 changes: 5 additions & 0 deletions src/algorithms/tracking/ActsToTracks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <edm4eic/EDM4eicVersion.h>
#include <edm4eic/RawTrackerHit.h>
#include <edm4eic/TrackerHit.h>
#include <edm4hep/EDM4hepVersion.h>
#include <edm4hep/MCParticleCollection.h>
#include <edm4hep/SimTrackerHit.h>
#include <edm4hep/Vector2f.h>
Expand Down Expand Up @@ -196,7 +197,11 @@ void ActsToTracks::process(const Input& input, const Output& output) const {
for (const auto raw_hit_assoc : *raw_hit_assocs) {
if (raw_hit_assoc.getRawHit() == raw_hit) {
auto sim_hit = raw_hit_assoc.getSimHit();
#if EDM4HEP_BUILD_VERSION >= EDM4HEP_VERSION(0, 99, 0)
auto mc_particle = sim_hit.getParticle();
#else
auto mc_particle = sim_hit.getMCParticle();
#endif
mcparticle_weight_by_hit_count[mc_particle]++;
}
}
Expand Down

0 comments on commit 0219a65

Please sign in to comment.