Fix the KalTrack isolation shared hits sort (and downstream effects on MC hit matching etc) - #1179
Merged
Merged
Conversation
sensor.hits is shared by every track with a hit on that SiModule, and ms.hitID indexes into it as populated at pattern recognition time. Sorting it in place corrupted that ordering for every other track sharing the sensor and made the subsequent ms.hitID lookup stale. Sort a private copy instead and locate the hit on track by identity in the sorted copy. Also add Preselection2021.java, an LCSim driver for truth-based electron/positron track and V0 preselection with per-layer isolation diagnostics (including an exact iso==0 counter used to confirm the residual zero-isolation entries in the innermost SiStriplet layers are genuine, not an artifact of the sorting bug above).
Contributor
Author
|
I also added Preselection2021 (a mockup of the hpstr preselection in hps-java) which I was using to debug the truth. |
mgignac
approved these changes
Aug 14, 2026
EBerzin
approved these changes
Aug 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.





This PR fixes the issue of misidentifying reco tracks from made up of SimTrackerHit-matched hits as unmatched to an MCParticle.
The issue in the code was from this snippet in KalTrack (hat-tip to Lauren for finding this):
// KalTrack.java:533-546
List allHits = sensor.hits; // NOT a copy
if (allHits.size() > 1 && ms.hitID > -1) {
Measurement hitOnTrack = allHits.get(ms.hitID); // read pre-sort: OK
...
Collections.sort(allHits, Measurement.MeasurementComparatorUp); // :546 mutates SiModule.hits
int isoID = ms.hitID + awayFromBeam*nSteps; // :550 stale index into the new order
... in words, the measurement list in the first line just points to the list on the SiModule and the sort then changes the order of these hits. After this, the ms.hitID is basically meaningless.
This bug effected a few collections after this snippet gets first run in KalmanPatRecDriver.java:
KFTrackData isolations
KFGBLStripClusterData (potentially used for using KF in alignment)
KFUnbiasRes