Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 36 additions & 2 deletions Detectors/Base/include/DetectorsBase/Stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
#include "SimulationDataFormat/ParticleStatus.h"
#include "Rtypes.h"
#include "TParticle.h"

#include "TVirtualMC.h"
#include "TMCProcess.h"
#include <map>
#include <memory>
#include <stack>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -348,6 +349,39 @@ 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<int>(mTrackIDtoParticlesEntry.size())) {
return false;
}
const auto entry = mTrackIDtoParticlesEntry[id];
if (entry < 0 || entry >= static_cast<int>(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
Expand Down
Loading