Skip to content

Fix isFromRadDecay ancestry walk and add a unit test for it - #15674

Closed
sawenzel wants to merge 1 commit into
AliceO2Group:devfrom
sawenzel:fix-isFromRadDecay-ancestry-walk
Closed

Fix isFromRadDecay ancestry walk and add a unit test for it#15674
sawenzel wants to merge 1 commit into
AliceO2Group:devfrom
sawenzel:fix-isFromRadDecay-ancestry-walk

Conversation

@sawenzel

@sawenzel sawenzel commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

This PR adds a unit test and fixes two bugs in the isFromRadDecay query introduced in #15470.

  • New test case in testStack.cxx — builds a small stack with a radioactive decay as the first secondary of its primary. Four of its checks fail on dev today.
  • Primaries wrongly returned truemTrackIDtoParticlesEntry is meaningless for a primary, since primaries never enter mParticles, so the lookup landed on an unrelated secondary.
  • Descendants of a radioactive decay wrongly returned falsewhile (imo > 0) skipped buffer entry 0, which after FinishPrimary() is the first secondary of the current primary.
  • Fix: walk trackIDs, stop at mNumberOfPrimaryParticles — the same primary test selectTracks() uses, so the mapping is never consulted for a primary.
  • Const correctness, reference-vs-copy, and include fixes.

The new query returned the wrong answer for two common cases, both of
which come down to how the stack stores its particles during transport.

Primaries never enter mParticles - only secondaries do - and
mTrackIDtoParticlesEntry is written for every pushed track, so for a
primary it points at whichever secondary happened to be next in the
buffer. Asking about a primary therefore inspected an unrelated
secondary, and returned true whenever that secondary came from a
radioactive decay. Since the buffer is emptied after every primary, its
first entry is the first secondary of the current primary, so the
`imo > 0` loop guard also skipped exactly that particle and lost any
radioactive decay recorded there, together with all of its descendants.

Walking the chain on trackIDs instead of on buffer entries removes both
problems: primaries are the first mNumberOfPrimaryParticles trackIDs, so
that single comparison ends the search without a lookup, and every
remaining step is a genuine secondary. The method becomes const and takes
the parameter by value like its neighbours, the two includes are dropped
again because MCTrack.h already provides TMCProcess, and the declaration
gains the note that the answer is only meaningful during transport, since
selectTracks() rewrites the mother indices afterwards.

The accompanying test builds a small stack with a radioactive decay as
the first secondary of its primary and checks the direct, indirect and
negative cases; it fails on all four of the affected checks before this
change.
@sawenzel
sawenzel requested a review from shahor02 as a code owner August 10, 2026 12:37
@sawenzel sawenzel closed this Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant