Fix get_parent same-time-tag bug in LineageClustering#383
Open
DonNabla wants to merge 3 commits into
Open
Conversation
Tie-break by spatial proximity to the daughter's creation position when
multiple parent interactions share the same time tag.
For fast gammas that Compton-scatter at one site and photoabsorb at
another within G4's sub-ns time-tag precision (~0.1 ns / 3 cm), the
original time-cut + array-last logic returned whichever same-time
parent step happened to be last in the array. This mis-attributed the
Compton e- daughter at site A to the gamma's photoabsorbtion vertex at
site B, collapsing the two scatter sites into one cluster.
Net effect on single-gamma decays (e.g. K40, Co60):
~65 % of physically multi-scatter events get reclassified as single-
scatter at the recon stage, biasing the MS templates by ~50 %.
Chain isotopes (Th232, Ra226, etc.) and intrinsic-β isotopes (Pb212
with nucleusLimits excluding daughter chain) are unaffected because
their secondaries do not produce same-time-tag γ Compton+phot pairs.
Validated across 5 isotopes (20 jobs × 100k primaries each):
isotope | vanilla MS-ratio | patched MS-ratio | vs WFsim 2026
K40 | 0.385 | 1.006 | reference 1.000
Co60 | 0.351 | 0.998 | reference 1.000
Th232 | 0.997 | 0.996 | reference 1.000
Ra226 | 1.002 | 1.000 | reference 1.000
Pb212 | 1.000 | 1.000 | bit-identical h5
The fix preserves the existing nearest-in-time fallback when no parent
step satisfies t <= particle.t.
Full validation report and forensic walkthrough:
/project/lgrandi/mpierre/high-ER-analysis/Inference_highER/
template_builder/notebooks/WFsim_fuse_comparison_checks/
Report_get_parent_patch_validation.md
Investigate_one_K40_event_stage_by_stage.ipynb
25c4017 to
2668d76
Compare
Author
|
Happy to get the opinion of the fuse expert for this change. Mostly relevant for material ER simulation. |
The docformatter v1.7.7 hook fails on the default Python pre-commit picks in CI; pinning language_version restores a working interpreter (suggested fix from a fuse maintainer).
for more information, see https://pre-commit.ci
HenningSE
approved these changes
May 18, 2026
HenningSE
left a comment
Collaborator
There was a problem hiding this comment.
Looks good to me, approved
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.
Fix
get_parentsame-time-tag bug inLineageClusteringSummary
Tie-break by spatial proximity to the daughter's creation position when multiple parent interactions in
lineage_cluster.get_parentshare the same time tag.For fast γ events that Compton-scatter at one site and photoabsorb at another within G4's sub-ns time-tag precision (~0.1 ns of travel time, bit-identical
float64t), the original time-cut + array-last logic returned the last same-time parent step in array order — which can be the wrong vertex. The Compton e⁻ daughter at site A then inherited the lineage of the γ's photoabsorbtion step at site B, collapsing the two physical scatter sites into a single cluster.What's affected
Empirically the bug only flips event-level SS/MS classification for single-γ-decay isotopes (K40, Co60). Cascade chains (Th, U, Ra) and β-only sources (Pb212 with
nucleusLimitsexcluding daughter chain) are unaffected, because either (a) cascade γ's have distinct decay-time tags soget_parent's time-cut already disambiguates, or (b) there's no γ Compton+phot pair to trigger the same-time-tag tie in the first place.For K40/Co60, ~65 % of physically multi-scatter events end up reclassified as single-scatter, biasing the MS templates by ~50 % vs WFsim.
Validation
5 isotopes × 20 jobs × 100k primaries each (InnerCryostatFlange for K40/Co60/Th232/Ra226; WholeLXe for Pb212; SR0 Fermi-Dirac SS/MS classifier):
Single-event spot check (K40
g4id=39232):The diff
The existing nearest-in-time fallback (when no parent step satisfies
t <= particle.t) is preserved unchanged.Alternatives considered
I also prototyped and validated two position-free alternatives:
daughter.creaproc == parent.edproc(G4's causal mapping). Closes ~85 % of the gap.{trackid: parent_step_index}map computed once per event using process-match → spatial fallback, makingget_parentO(1). Also ~85 %.Both are causally explicit but converge on the same coverage. The spatial tie-break in this PR catches the additional ~15 % of edge cases (daughters whose
creaprocisn't directly in the parent'sedprocset, e.g. secondary brems and cascaded photo-absorptions). A true hybrid (process-match prefilter on the same-time-max candidate set with spatial tie-break inside) is the principled long-term refinement — worth a follow-up PR but not blocking.Test plan
g4id=39232produces the 423/1037 keV split documented above