Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for OneToOne relation to SimHit in MCRecoTrackerHitAssociation #1399

Merged
merged 7 commits into from
Apr 29, 2024
14 changes: 10 additions & 4 deletions src/algorithms/digi/PhotoMultiplierHitDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <Evaluator/DD4hepUnits.h>
#include <algorithms/logger.h>
#include <edm4eic/EDM4eicVersion.h>
#include <edm4hep/Vector3d.h>
#include <fmt/core.h>
#include <math.h>
Expand Down Expand Up @@ -168,11 +169,16 @@ void PhotoMultiplierHitDigi::process(

// build `MCRecoTrackerHitAssociation` (for non-noise hits only)
if(!data.sim_hit_indices.empty()) {
auto hit_assoc = hit_assocs->create();
hit_assoc.setWeight(1.0); // not used
hit_assoc.setRawHit(raw_hit);
for(auto i : data.sim_hit_indices)
for(auto i : data.sim_hit_indices) {
auto hit_assoc = hit_assocs->create();
hit_assoc.setWeight(1.0 / data.sim_hit_indices.size()); // not used
hit_assoc.setRawHit(raw_hit);
#if EDM4EIC_VERSION_MAJOR >= 6
hit_assoc.setSimHit(sim_hits->at(i));
#else
hit_assoc.addToSimHits(sim_hits->at(i));
#endif
}
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/algorithms/digi/SiliconTrackerDigi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "SiliconTrackerDigi.h"

#include <Evaluator/DD4hepUnits.h>
#include <edm4eic/EDM4eicVersion.h>
#include <edm4hep/MCParticleCollection.h>
#include <edm4hep/Vector3d.h>
#include <edm4hep/Vector3f.h>
Expand Down Expand Up @@ -97,7 +98,11 @@ void SiliconTrackerDigi::process(
auto hitassoc = associations->create();
hitassoc.setWeight(1.0);
hitassoc.setRawHit(item.second);
#if EDM4EIC_VERSION_MAJOR >= 6
hitassoc.setSimHit(sim_hit);
#else
hitassoc.addToSimHits(sim_hit);
#endif
}
}

Expand Down
10 changes: 8 additions & 2 deletions src/algorithms/pid/IrtCherenkovParticleID.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <TString.h>
#include <TVector3.h>
#include <edm4eic/CherenkovParticleIDHypothesis.h>
#include <edm4eic/EDM4eicVersion.h>
#include <edm4eic/TrackPoint.h>
#include <edm4hep/MCParticleCollection.h>
#include <edm4hep/SimTrackerHitCollection.h>
Expand Down Expand Up @@ -218,17 +219,22 @@ std::map<std::string, std::unique_ptr<edm4eic::CherenkovParticleIDCollection>> e
for(const auto& hit_assoc : *in_hit_assocs) {
if(hit_assoc.getRawHit().isAvailable()) {
if(hit_assoc.getRawHit().id() == raw_hit.id()) {
#if EDM4EIC_VERSION_MAJOR >= 6
mc_photon = hit_assoc.getSimHit().getMCParticle();
#else
// hit association found, get the MC photon and break the loop
// FIXME: occasionally there will be more than one photon associated with a hit;
// for now let's just take the first one...
if(hit_assoc.simHits_size() > 0) {
mc_photon = hit_assoc.getSimHits(0).getMCParticle();
#endif
mc_photon_found = true;
if(mc_photon.getPDG() != -22)
m_log->warn("non-opticalphoton hit: PDG = {}",mc_photon.getPDG());
#if EDM4EIC_VERSION_MAJOR >= 6
#else
}
else if(m_cfg.CheatModeEnabled())
m_log->error("cheat mode enabled, but no MC photons provided");
#endif
break;
}
}
Expand Down
Loading