From 900b2a11413f74cb5320ce936e0d7a8ed5a5824a Mon Sep 17 00:00:00 2001 From: Andreas Morsch Date: Tue, 2 Jun 2026 12:21:35 +0200 Subject: [PATCH 1/3] Add method isFromRadDecay(const int id). Checks whether particle results from radioactive decay in its history. --- Detectors/Base/include/DetectorsBase/Stack.h | 39 +++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/Detectors/Base/include/DetectorsBase/Stack.h b/Detectors/Base/include/DetectorsBase/Stack.h index 69d221000e493..718122d5e3328 100644 --- a/Detectors/Base/include/DetectorsBase/Stack.h +++ b/Detectors/Base/include/DetectorsBase/Stack.h @@ -24,7 +24,8 @@ #include "SimulationDataFormat/ParticleStatus.h" #include "Rtypes.h" #include "TParticle.h" - +#include "TVirtualMC.h" +#include "TMCProcess.h" #include #include #include @@ -210,7 +211,7 @@ class Stack : public FairGenericStack /// query if a track is a direct **or** indirect daughter of a parentID /// if trackid is same as parentid it returns true bool isTrackDaughterOf(int /*trackid*/, int /*parentid*/) const; - + bool isFromRadDecay(const int id); bool isCurrentTrackDaughterOf(int parentid) const; // returns the index of the currently transported primary @@ -348,6 +349,40 @@ inline int Stack::getMotherTrackId(int trackid) const return mParticles[entryinParticles].getMotherTrackId(); } +inline bool Stack::isFromRadDecay(const int id) +{ + // Check whether particle originates directly or indirectly from radioactive decay + // + if (id < 0 || id >= static_cast(mTrackIDtoParticlesEntry.size())) { + return false; + } + const auto entry = mTrackIDtoParticlesEntry[id]; + if (entry < 0 || entry >= static_cast(mParticles.size())) return false; + auto part = (mParticles[entry]); + + // primary particle ? + if (part.getProcess() == 0 ) return false; + // particle directly from radioactive decay ? + if (part.getProcess() == kPRadDecay) { + return true; + } + + // search in particle history + auto imo = mTrackIDtoParticlesEntry[part.getMotherTrackId()]; + auto isRad = false; + + while (imo > 0 ) { + auto mother = (mParticles[imo]); + if (mother.getProcess() == kPRadDecay) { + isRad = true; + break; + } + part = mother; + imo = mTrackIDtoParticlesEntry[mother.getMotherTrackId()]; + } + return isRad; +} + inline bool Stack::isCurrentTrackDaughterOf(int parentid) const { // if parentid is current primary the answer is certainly yes From 106d380b4766e93dc6fcc57811e9169e57de5fef Mon Sep 17 00:00:00 2001 From: Andreas Morsch Date: Tue, 2 Jun 2026 12:34:24 +0200 Subject: [PATCH 2/3] Fix formatting issue in Stack.h --- Detectors/Base/include/DetectorsBase/Stack.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Detectors/Base/include/DetectorsBase/Stack.h b/Detectors/Base/include/DetectorsBase/Stack.h index 718122d5e3328..4eb7d2a59e762 100644 --- a/Detectors/Base/include/DetectorsBase/Stack.h +++ b/Detectors/Base/include/DetectorsBase/Stack.h @@ -368,9 +368,8 @@ inline bool Stack::isFromRadDecay(const int id) } // search in particle history - auto imo = mTrackIDtoParticlesEntry[part.getMotherTrackId()]; + auto imo = mTrackIDtoParticlesEntry[part.getMotherTrackId()]; auto isRad = false; - while (imo > 0 ) { auto mother = (mParticles[imo]); if (mother.getProcess() == kPRadDecay) { From f85bd6367455085cdd0a53b4f07aa1f03aa70053 Mon Sep 17 00:00:00 2001 From: Andreas Morsch Date: Tue, 2 Jun 2026 12:36:30 +0200 Subject: [PATCH 3/3] Fix formatting in Stack.h while loop condition --- Detectors/Base/include/DetectorsBase/Stack.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/Base/include/DetectorsBase/Stack.h b/Detectors/Base/include/DetectorsBase/Stack.h index 4eb7d2a59e762..a893cdd4b7bc7 100644 --- a/Detectors/Base/include/DetectorsBase/Stack.h +++ b/Detectors/Base/include/DetectorsBase/Stack.h @@ -370,7 +370,7 @@ inline bool Stack::isFromRadDecay(const int id) // search in particle history auto imo = mTrackIDtoParticlesEntry[part.getMotherTrackId()]; auto isRad = false; - while (imo > 0 ) { + while (imo > 0) { auto mother = (mParticles[imo]); if (mother.getProcess() == kPRadDecay) { isRad = true;