Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions src/algorithms/pid/IrtCherenkovParticleID.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <fmt/ranges.h>
#include <podio/ObjectID.h>
#include <podio/RelationRange.h>
#include <podio/detail/LinkCollectionImpl.h>
#include <podio/detail/LinkCollectionIterator.h>
#include <algorithm>
#include <cmath>
#include <cstddef>
Expand All @@ -30,6 +32,7 @@
#include <memory>
#include <set>
#include <stdexcept>
#include <tuple>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -134,14 +137,14 @@ void IrtCherenkovParticleID::init(CherenkovDetectorCollection* irt_det_coll) {

void IrtCherenkovParticleID::process(const IrtCherenkovParticleID::Input& input,
const IrtCherenkovParticleID::Output& output) const {
const auto [in_aerogel_tracks, in_gas_tracks, in_merged_tracks, in_raw_hits, in_hit_assocs] =
input;
const auto [in_aerogel_tracks, in_gas_tracks, in_merged_tracks, in_raw_hits, in_hit_links,
in_hit_assocs] = input;
auto [out_aerogel_particleIDs, out_gas_particleIDs] = output;

// logging
trace("{:=^70}", " call IrtCherenkovParticleID::AlgorithmProcess ");
trace("number of raw sensor hits: {}", in_raw_hits->size());
trace("number of raw sensor hit with associated photons: {}", in_hit_assocs->size());
trace("number of raw sensor hits with associated photons: {}", in_hit_links->size());

std::map<std::string, const edm4eic::TrackSegmentCollection*> in_charged_particles{
{"Aerogel", in_aerogel_tracks},
Expand Down Expand Up @@ -222,21 +225,22 @@ void IrtCherenkovParticleID::process(const IrtCherenkovParticleID::Input& input,
for (const auto& raw_hit : *in_raw_hits) {

// get MC photon(s), typically only used by cheat modes or trace logging
// - loop over `in_hit_assocs`, searching for the matching hit association
// - loop over `in_hit_links`, searching for the matching raw-hit ↔ sim-hit link
// - will not exist for noise hits
edm4hep::MCParticle mc_photon;
bool mc_photon_found = false;
if (m_cfg.cheatPhotonVertex || m_cfg.cheatTrueRadiator) {
for (const auto& hit_assoc : *in_hit_assocs) {
if (hit_assoc.getRawHit().isAvailable()) {
if (hit_assoc.getRawHit().id() == raw_hit.id()) {
mc_photon = hit_assoc.getSimHit().getParticle();
mc_photon_found = true;
if (mc_photon.getPDG() != -22) {
warning("non-opticalphoton hit: PDG = {}", mc_photon.getPDG());
}
break;
for (const auto& hit_link : *in_hit_links) {
if (!hit_link.getFrom().isAvailable() || !hit_link.getTo().isAvailable()) {
continue;
}
if (hit_link.getFrom().id() == raw_hit.id()) {
mc_photon = hit_link.getTo().getParticle();
mc_photon_found = true;
if (mc_photon.getPDG() != -22) {
warning("non-opticalphoton hit: PDG = {}", mc_photon.getPDG());
}
break;
}
}
}
Expand Down Expand Up @@ -312,7 +316,7 @@ void IrtCherenkovParticleID::process(const IrtCherenkovParticleID::Input& input,
* a region of sensors where we expect to see this `irt_particle`'s
* Cherenkov photons; this should also combat sensor noise
*/
} // end `in_hit_assocs` loop
} // end `in_raw_hits` loop

} // end radiator loop

Expand Down Expand Up @@ -463,7 +467,7 @@ void IrtCherenkovParticleID::process(const IrtCherenkovParticleID::Input& input,
error("Cannot find radiator 'Merged' in `in_charged_particles`");
}

// relate hit associations
// keep the legacy association relation while consuming links for MC truth lookup
for (const auto& hit_assoc : *in_hit_assocs) {
out_cherenkov_pid.addToRawHitAssociations(hit_assoc);
}
Expand Down
11 changes: 8 additions & 3 deletions src/algorithms/pid/IrtCherenkovParticleID.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <algorithms/algorithm.h>
#include <edm4eic/CherenkovParticleIDCollection.h>
#include <edm4eic/MCRecoTrackerHitAssociationCollection.h>
#include <edm4eic/MCRecoTrackerHitLinkCollection.h>
#include <edm4eic/RawTrackerHitCollection.h>
#include <edm4eic/TrackSegmentCollection.h>
#include <stdint.h>
Expand All @@ -26,14 +27,18 @@
namespace eicrecon {

// - `in_raw_hits` is a collection of digitized (raw) sensor hits, possibly including noise hits
// - `in_hit_assocs` is a collection of digitized (raw) sensor hits, associated with MC (simulated) hits;
// noise hits are not included since there is no associated simulated photon
// - `in_hit_links` is a collection of raw-hit ↔ sim-hit link objects
// (`edm4eic::MCRecoTrackerHitLink`); noise hits are not included since they have no associated
// simulated photon
// - `in_hit_assocs` is the association collection for compatibility with
// CherenkovParticleID::rawHitAssociations output relations
// - `in_charged_particles` is a map of a radiator name to a collection of TrackSegments
// - each TrackSegment has a list of TrackPoints: the propagation of reconstructed track (trajectory) points
// - the output is a map: radiator name -> collection of particle ID objects
using IrtCherenkovParticleIDAlgorithm = algorithms::Algorithm<
algorithms::Input<const edm4eic::TrackSegmentCollection, const edm4eic::TrackSegmentCollection,
const edm4eic::TrackSegmentCollection, const edm4eic::RawTrackerHitCollection,
const edm4eic::MCRecoTrackerHitLinkCollection,
const edm4eic::MCRecoTrackerHitAssociationCollection>,
algorithms::Output<edm4eic::CherenkovParticleIDCollection,
edm4eic::CherenkovParticleIDCollection>>;
Expand All @@ -46,7 +51,7 @@ class IrtCherenkovParticleID : public IrtCherenkovParticleIDAlgorithm,
: IrtCherenkovParticleIDAlgorithm{name,
{"inputAerogelTrackSegments", "inputGasTrackSegments",
"inputMergedTrackSegments", "inputRawHits",
"inputRawHitAssociations"},
"inputRawHitLinks", "inputRawHitAssociations"},
{"outputAerogelParticleIDs", "outputGasParticleIDs"},
"Effectively 'zip' the input particle IDs"} {}

Expand Down
2 changes: 1 addition & 1 deletion src/detectors/DRICH/DRICH.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void InitPlugin(JApplication* app) {
app->Add(new JOmniFactoryGeneratorT<IrtCherenkovParticleID_factory>(
"DRICHIrtCherenkovParticleID",
{"DRICHAerogelTracks", "DRICHGasTracks", "DRICHMergedTracks", "DRICHRawHits",
"DRICHRawHitsAssociations"},
"DRICHRawHitsLinks", "DRICHRawHitsAssociations"},
Comment thread
wdconinc marked this conversation as resolved.
{"DRICHAerogelIrtCherenkovParticleID", "DRICHGasIrtCherenkovParticleID"}, irt_cfg, app));

// merge aerogel and gas PID results
Expand Down
5 changes: 4 additions & 1 deletion src/factories/pid/IrtCherenkovParticleID_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <IRT/CherenkovDetectorCollection.h>
#include <JANA/JEvent.h>
#include <edm4eic/CherenkovParticleIDCollection.h>
#include <edm4eic/MCRecoTrackerHitAssociationCollection.h>
#include <edm4eic/MCRecoTrackerHitLinkCollection.h>
#include <algorithm>
#include <memory>
#include <string>
Expand All @@ -31,6 +33,7 @@ class IrtCherenkovParticleID_factory
PodioInput<edm4eic::TrackSegment> m_gas_tracks_input{this};
PodioInput<edm4eic::TrackSegment> m_merged_tracks_input{this};
PodioInput<edm4eic::RawTrackerHit> m_raw_hits_input{this};
PodioInput<edm4eic::MCRecoTrackerHitLink> m_raw_hit_links_input{this};
PodioInput<edm4eic::MCRecoTrackerHitAssociation> m_raw_hit_assoc_input{this};
PodioOutput<edm4eic::CherenkovParticleID> m_aerogel_particleIDs_output{this};
PodioOutput<edm4eic::CherenkovParticleID> m_gas_particleIDs_output{this};
Expand Down Expand Up @@ -71,7 +74,7 @@ class IrtCherenkovParticleID_factory

void Process(int32_t /* run_number */, uint64_t /* event_number */) {
m_algo->process({m_aerogel_tracks_input(), m_gas_tracks_input(), m_merged_tracks_input(),
m_raw_hits_input(), m_raw_hit_assoc_input()},
m_raw_hits_input(), m_raw_hit_links_input(), m_raw_hit_assoc_input()},
{m_aerogel_particleIDs_output().get(), m_gas_particleIDs_output().get()});
}
};
Expand Down
Loading