Fix isFromRadDecay ancestry walk and add a unit test for it - #15674
Closed
sawenzel wants to merge 1 commit into
Closed
Fix isFromRadDecay ancestry walk and add a unit test for it#15674sawenzel wants to merge 1 commit into
sawenzel wants to merge 1 commit into
Conversation
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.
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 adds a unit test and fixes two bugs in the
isFromRadDecayquery introduced in #15470.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.mTrackIDtoParticlesEntryis meaningless for a primary, since primaries never entermParticles, so the lookup landed on an unrelated secondary.while (imo > 0)skipped buffer entry 0, which afterFinishPrimary()is the first secondary of the current primary.mNumberOfPrimaryParticles— the same primary testselectTracks()uses, so the mapping is never consulted for a primary.