Commit d4d86bc
committed
Make isFromRadDecay walk the mother chain on trackIDs
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.1 parent 2be94fd commit d4d86bc
2 files changed
Lines changed: 68 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
| 27 | + | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
211 | 210 | | |
212 | 211 | | |
213 | 212 | | |
214 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
215 | 217 | | |
216 | 218 | | |
217 | 219 | | |
| |||
349 | 351 | | |
350 | 352 | | |
351 | 353 | | |
352 | | - | |
| 354 | + | |
353 | 355 | | |
354 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
355 | 359 | | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
380 | 373 | | |
381 | | - | |
382 | | - | |
| 374 | + | |
383 | 375 | | |
384 | | - | |
| 376 | + | |
385 | 377 | | |
386 | 378 | | |
387 | 379 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
0 commit comments