From d6329f40b5b3b9628fc75d6c1e3489b1927a77e5 Mon Sep 17 00:00:00 2001
From: Philip Chang
Date: Thu, 19 Feb 2026 14:50:19 -0500
Subject: [PATCH] Fix pLS hit position retrieval using correct seed index
ipLS does not correspond to the seed index in the tracking ntuple
because prepareInput filters seeds by algo type (4/22) and pt cuts.
Use pixelSeeds.seedIdx()[ipLS] to get the original seed index when
indexing into trk_see_hitIdx and trk_see_hitType.
---
.../LSTCore/standalone/code/core/write_lst_ntuple.cc | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc b/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc
index 51c91e69319d4..e6e1f1ae67562 100644
--- a/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc
+++ b/RecoTracker/LSTCore/standalone/code/core/write_lst_ntuple.cc
@@ -1770,9 +1770,10 @@ std::map setPixelLineSegmentBranches(LSTEvent* event
ana.tx->pushbackToBranch("pLS_charge", pixelSeeds.charge()[ipLS]);
ana.tx->pushbackToBranch("pLS_deltaPhi", pixelSeeds.deltaPhi()[ipLS]);
ana.tx->pushbackToBranch("pLS_nhit", hit_idx.size());
- for (size_t ihit = 0; ihit < trk_see_hitIdx[ipLS].size(); ++ihit) {
- int hitidx = trk_see_hitIdx[ipLS][ihit];
- int hittype = trk_see_hitType[ipLS][ihit];
+ unsigned int seedIdx = pixelSeeds.seedIdx()[ipLS];
+ for (size_t ihit = 0; ihit < trk_see_hitIdx[seedIdx].size(); ++ihit) {
+ int hitidx = trk_see_hitIdx[seedIdx][ihit];
+ int hittype = trk_see_hitType[seedIdx][ihit];
auto const& x = trk_pix_x[hitidx];
auto const& y = trk_pix_y[hitidx];
auto const& z = trk_pix_z[hitidx];
@@ -1780,7 +1781,7 @@ std::map setPixelLineSegmentBranches(LSTEvent* event
ana.tx->pushbackToBranch(TString::Format("pLS_hit%zu_y", ihit), y);
ana.tx->pushbackToBranch(TString::Format("pLS_hit%zu_z", ihit), z);
}
- if (trk_see_hitIdx[ipLS].size() == 3) {
+ if (trk_see_hitIdx[seedIdx].size() == 3) {
ana.tx->pushbackToBranch("pLS_hit3_x", -999);
ana.tx->pushbackToBranch("pLS_hit3_y", -999);
ana.tx->pushbackToBranch("pLS_hit3_z", -999);