From 9bea391de146e8bf44032e7fc903754177067c9e Mon Sep 17 00:00:00 2001 From: sungbinoh Date: Mon, 20 Oct 2025 09:54:23 -0500 Subject: [PATCH 1/9] adding TrackLikePidLabel in CAFMakerParams.h --- sbncode/CAFMaker/CAFMakerParams.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sbncode/CAFMaker/CAFMakerParams.h b/sbncode/CAFMaker/CAFMakerParams.h index a7740263e..322d9fd27 100644 --- a/sbncode/CAFMaker/CAFMakerParams.h +++ b/sbncode/CAFMaker/CAFMakerParams.h @@ -255,6 +255,12 @@ namespace caf "pandoraPid" }; + Atom TrackLikePidLabel { + Name("TrackLikePidLabel"), + Comment("Base label of track likelihood particle-id producer."), + "pandoraLikePid" + }; + Atom TrackScatterClosestApproachLabel { Name("TrackScatterClosestApproachLabel"), Comment("Base label of track track scatter closestapproach producer."), From 2af2c087a8e0f1b33596f0ef9d18130b954a025a Mon Sep 17 00:00:00 2001 From: sungbinoh Date: Mon, 20 Oct 2025 10:55:45 -0500 Subject: [PATCH 2/9] updating FillReco for likelihood pid --- sbncode/CAFMaker/FillReco.cxx | 47 +++++++++++++++++++++++++++++++++++ sbncode/CAFMaker/FillReco.h | 4 +++ 2 files changed, 51 insertions(+) diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index 76c9a50b7..c53ef9296 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -892,6 +892,53 @@ namespace caf } } + void FillPlaneLikePID(const anab::ParticleID &particle_id, caf::SRTrkLikePID &srlikepid) { + + // Assign dummy values. + + srlikepid.lambda_muon = 0.; + srlikepid.lambda_pion = 0.; + srlikepid.lambda_proton = 0.; + srlikepid.pid_ndof = 0; + + // Loop over algorithm scores and extract the ones we want. + // Get the ndof from any likelihood pid algorithm + + std::vector AlgScoresVec = particle_id.ParticleIDAlgScores(); + for (size_t i_algscore=0; i_algscore> particleIDs, + caf::SRTrack& srtrack, + bool allowEmpty) + { + // get the particle ID's + for (unsigned i = 0; i < particleIDs.size(); i++) { + const anab::ParticleID &particle_id = *particleIDs[i]; + if (particle_id.PlaneID()) { + unsigned plane_id = particle_id.PlaneID().Plane; + assert(plane_id < 3); + FillPlaneLikePID(particle_id, srtrack.likepid[plane_id]); + } + } + } + void FillTrackPlaneCalo(const anab::Calorimetry &calo, const std::vector> &hits, bool fill_calo_points, float fillhit_rrstart, float fillhit_rrend, diff --git a/sbncode/CAFMaker/FillReco.h b/sbncode/CAFMaker/FillReco.h index 85d0a3e67..6a1e19bdc 100644 --- a/sbncode/CAFMaker/FillReco.h +++ b/sbncode/CAFMaker/FillReco.h @@ -226,6 +226,10 @@ namespace caf void FillTrackChi2PID(const std::vector> particleIDs, caf::SRTrack& srtrack, bool allowEmpty = false); + void FillPlaneLikePID(const anab::ParticleID &particle_id, caf::SRTrkLikePID &srlikepid); + void FillTrackLikePID(const std::vector> particleIDs, + caf::SRTrack& srtrack, + bool allowEmptySRTrkLikePID); void FillTrackPlaneCalo(const anab::Calorimetry &calo, const std::vector> &hits, From 3eeef15ed262020e5b29c3ad10634d4002dfe2f7 Mon Sep 17 00:00:00 2001 From: sungbinoh Date: Mon, 20 Oct 2025 11:47:50 -0500 Subject: [PATCH 3/9] update CAFMaker_module.cc for likelihood pid --- sbncode/CAFMaker/CAFMaker_module.cc | 7 +++++++ sbncode/CAFMaker/FillReco.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/sbncode/CAFMaker/CAFMaker_module.cc b/sbncode/CAFMaker/CAFMaker_module.cc index 7baf6ef0c..060bd5b6d 100644 --- a/sbncode/CAFMaker/CAFMaker_module.cc +++ b/sbncode/CAFMaker/CAFMaker_module.cc @@ -2125,6 +2125,10 @@ void CAFMaker::produce(art::Event& evt) noexcept { FindManyPStrict(slcTracks, evt, fParams.TrackChi2PidLabel() + slice_tag_suff); + art::FindManyP fmLikePID = + FindManyPStrict(slcTracks, evt, + fParams.TrackLikePidLabel() + slice_tag_suff); + art::FindManyP fmScatterClosestApproach = FindManyPStrict(slcTracks, evt, fParams.TrackScatterClosestApproachLabel() + slice_tag_suff); @@ -2416,6 +2420,9 @@ void CAFMaker::produce(art::Event& evt) noexcept { if (fmChi2PID.isValid()) { FillTrackChi2PID(fmChi2PID.at(iPart), trk); } + if (fmLikePID.isValid()) { + FillTrackLikePID(fmLikePID.at(iPart), trk); + } if (fmScatterClosestApproach.isValid() && fmScatterClosestApproach.at(iPart).size()==1) { FillTrackScatterClosestApproach(fmScatterClosestApproach.at(iPart).front(), trk); } diff --git a/sbncode/CAFMaker/FillReco.h b/sbncode/CAFMaker/FillReco.h index 6a1e19bdc..57ea88d37 100644 --- a/sbncode/CAFMaker/FillReco.h +++ b/sbncode/CAFMaker/FillReco.h @@ -229,7 +229,7 @@ namespace caf void FillPlaneLikePID(const anab::ParticleID &particle_id, caf::SRTrkLikePID &srlikepid); void FillTrackLikePID(const std::vector> particleIDs, caf::SRTrack& srtrack, - bool allowEmptySRTrkLikePID); + bool allowEmpty = false); void FillTrackPlaneCalo(const anab::Calorimetry &calo, const std::vector> &hits, From 2af891e210e6cdc3633d2d1085c7db6d0e12eff9 Mon Sep 17 00:00:00 2001 From: sungbinoh Date: Tue, 21 Oct 2025 09:50:04 -0500 Subject: [PATCH 4/9] likepid default values to -5. --- sbncode/CAFMaker/FillReco.cxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index c53ef9296..d5680696f 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -896,10 +896,10 @@ namespace caf // Assign dummy values. - srlikepid.lambda_muon = 0.; - srlikepid.lambda_pion = 0.; - srlikepid.lambda_proton = 0.; - srlikepid.pid_ndof = 0; + srlikepid.lambda_muon = -5.; + srlikepid.lambda_pion = -5.; + srlikepid.lambda_proton = -5.; + srlikepid.pid_ndof = -5; // Loop over algorithm scores and extract the ones we want. // Get the ndof from any likelihood pid algorithm From 2651da1f53e759296af6e3a457f28fd6483c3e94 Mon Sep 17 00:00:00 2001 From: sungbinoh Date: Tue, 21 Oct 2025 09:52:24 -0500 Subject: [PATCH 5/9] like pid lambda default value to -99999. --- sbncode/CAFMaker/FillReco.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index d5680696f..123ea3d84 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -896,9 +896,9 @@ namespace caf // Assign dummy values. - srlikepid.lambda_muon = -5.; - srlikepid.lambda_pion = -5.; - srlikepid.lambda_proton = -5.; + srlikepid.lambda_muon = -9999.; + srlikepid.lambda_pion = -9999.; + srlikepid.lambda_proton = -9999.; srlikepid.pid_ndof = -5; // Loop over algorithm scores and extract the ones we want. From ff96233dab3f548e4d56cb5e31ab848cf4072eb4 Mon Sep 17 00:00:00 2001 From: sungbinoh Date: Tue, 21 Oct 2025 10:04:18 -0500 Subject: [PATCH 6/9] updating SRTrkLikePID to SRTrkLikelihoodPID --- sbncode/CAFMaker/FillReco.cxx | 2 +- sbncode/CAFMaker/FillReco.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index 123ea3d84..6b35c66fc 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -892,7 +892,7 @@ namespace caf } } - void FillPlaneLikePID(const anab::ParticleID &particle_id, caf::SRTrkLikePID &srlikepid) { + void FillPlaneLikePID(const anab::ParticleID &particle_id, caf::SRTrkLikelihoodPID &srlikepid) { // Assign dummy values. diff --git a/sbncode/CAFMaker/FillReco.h b/sbncode/CAFMaker/FillReco.h index 57ea88d37..039f09c8a 100644 --- a/sbncode/CAFMaker/FillReco.h +++ b/sbncode/CAFMaker/FillReco.h @@ -226,7 +226,7 @@ namespace caf void FillTrackChi2PID(const std::vector> particleIDs, caf::SRTrack& srtrack, bool allowEmpty = false); - void FillPlaneLikePID(const anab::ParticleID &particle_id, caf::SRTrkLikePID &srlikepid); + void FillPlaneLikePID(const anab::ParticleID &particle_id, caf::SRTrkLikelihoodPID &srlikepid); void FillTrackLikePID(const std::vector> particleIDs, caf::SRTrack& srtrack, bool allowEmpty = false); From 264bd4f2a3b09a23c4735680ac627a75bd62a9a0 Mon Sep 17 00:00:00 2001 From: sungbinoh Date: Thu, 23 Oct 2025 09:11:44 -0500 Subject: [PATCH 7/9] removing defaulting part for likelihood pid --- sbncode/CAFMaker/FillReco.cxx | 7 ------- 1 file changed, 7 deletions(-) diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index 6b35c66fc..b861bf0b1 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -894,13 +894,6 @@ namespace caf void FillPlaneLikePID(const anab::ParticleID &particle_id, caf::SRTrkLikelihoodPID &srlikepid) { - // Assign dummy values. - - srlikepid.lambda_muon = -9999.; - srlikepid.lambda_pion = -9999.; - srlikepid.lambda_proton = -9999.; - srlikepid.pid_ndof = -5; - // Loop over algorithm scores and extract the ones we want. // Get the ndof from any likelihood pid algorithm From 4c47688c87f99ad37761ffda84918b1f1f40bcde Mon Sep 17 00:00:00 2001 From: sungbinoh Date: Tue, 28 Oct 2025 10:24:30 -0500 Subject: [PATCH 8/9] Following Gianluca's comments --- sbncode/CAFMaker/FillReco.cxx | 35 ++++++++++++++++++----------------- sbncode/CAFMaker/FillReco.h | 2 +- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index b861bf0b1..afeeaefb8 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -897,33 +897,34 @@ namespace caf // Loop over algorithm scores and extract the ones we want. // Get the ndof from any likelihood pid algorithm - std::vector AlgScoresVec = particle_id.ParticleIDAlgScores(); - for (size_t i_algscore=0; i_algscore const& AlgScoresVec = particle_id.ParticleIDAlgScores(); + for (anab::sParticleIDAlgScores const& AlgScore: AlgScoresVec){ if (AlgScore.fAlgName == "Likelihood"){ - if (TMath::Abs(AlgScore.fAssumedPdg) == 13) { // lambda_mu - srlikepid.lambda_muon = AlgScore.fValue; - srlikepid.pid_ndof = AlgScore.fNdf; - } - else if (TMath::Abs(AlgScore.fAssumedPdg) == 211) { // lambda_pi - srlikepid.lambda_pion = AlgScore.fValue; - srlikepid.pid_ndof = AlgScore.fNdf; - } - else if (TMath::Abs(AlgScore.fAssumedPdg) == 2212) { // lambda_pr - srlikepid.lambda_proton = AlgScore.fValue; - srlikepid.pid_ndof = AlgScore.fNdf; + switch (std::abs(AlgScore.fAssumedPdg)) { + case 13: // lambda_mu + srlikepid.lambda_muon = AlgScore.fValue; + srlikepid.pid_ndof = AlgScore.fNdf; + break; + case 211: // lambda_pi + srlikepid.lambda_pion = AlgScore.fValue; + srlikepid.pid_ndof = AlgScore.fNdf; + break; + case 2212: // lambda_pr + srlikepid.lambda_proton = AlgScore.fValue; + srlikepid.pid_ndof = AlgScore.fNdf; + break; } } } } - void FillTrackLikePID(const std::vector> particleIDs, + void FillTrackLikePID(const std::vector>& particleIDs, caf::SRTrack& srtrack, bool allowEmpty) { // get the particle ID's - for (unsigned i = 0; i < particleIDs.size(); i++) { - const anab::ParticleID &particle_id = *particleIDs[i]; + for (art::Ptr const& pidPtr: particleIDs) { + const anab::ParticleID &particle_id = *pidPtr; if (particle_id.PlaneID()) { unsigned plane_id = particle_id.PlaneID().Plane; assert(plane_id < 3); diff --git a/sbncode/CAFMaker/FillReco.h b/sbncode/CAFMaker/FillReco.h index 039f09c8a..77c807b22 100644 --- a/sbncode/CAFMaker/FillReco.h +++ b/sbncode/CAFMaker/FillReco.h @@ -227,7 +227,7 @@ namespace caf caf::SRTrack& srtrack, bool allowEmpty = false); void FillPlaneLikePID(const anab::ParticleID &particle_id, caf::SRTrkLikelihoodPID &srlikepid); - void FillTrackLikePID(const std::vector> particleIDs, + void FillTrackLikePID(const std::vector>& particleIDs, caf::SRTrack& srtrack, bool allowEmpty = false); From ad25a042fa3f21db9cde399f30c27332924d1586 Mon Sep 17 00:00:00 2001 From: sungbinoh Date: Tue, 28 Oct 2025 11:06:42 -0500 Subject: [PATCH 9/9] adding setDefault for likelihood pid --- sbncode/CAFMaker/FillReco.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/sbncode/CAFMaker/FillReco.cxx b/sbncode/CAFMaker/FillReco.cxx index afeeaefb8..f8baad172 100644 --- a/sbncode/CAFMaker/FillReco.cxx +++ b/sbncode/CAFMaker/FillReco.cxx @@ -896,6 +896,7 @@ namespace caf // Loop over algorithm scores and extract the ones we want. // Get the ndof from any likelihood pid algorithm + srlikepid.setDefault(); std::vector const& AlgScoresVec = particle_id.ParticleIDAlgScores(); for (anab::sParticleIDAlgScores const& AlgScore: AlgScoresVec){