|
24 | 24 | #include "SimulationDataFormat/ParticleStatus.h" |
25 | 25 | #include "Rtypes.h" |
26 | 26 | #include "TParticle.h" |
27 | | - |
| 27 | +#include "TVirtualMC.h" |
| 28 | +#include "TMCProcess.h" |
28 | 29 | #include <map> |
29 | 30 | #include <memory> |
30 | 31 | #include <stack> |
@@ -210,7 +211,7 @@ class Stack : public FairGenericStack |
210 | 211 | /// query if a track is a direct **or** indirect daughter of a parentID |
211 | 212 | /// if trackid is same as parentid it returns true |
212 | 213 | bool isTrackDaughterOf(int /*trackid*/, int /*parentid*/) const; |
213 | | - |
| 214 | + bool isFromRadDecay(const int id); |
214 | 215 | bool isCurrentTrackDaughterOf(int parentid) const; |
215 | 216 |
|
216 | 217 | // returns the index of the currently transported primary |
@@ -348,6 +349,40 @@ inline int Stack::getMotherTrackId(int trackid) const |
348 | 349 | return mParticles[entryinParticles].getMotherTrackId(); |
349 | 350 | } |
350 | 351 |
|
| 352 | +inline bool Stack::isFromRadDecay(const int id) |
| 353 | +{ |
| 354 | + // Check whether particle originates directly or indirectly from radioactive decay |
| 355 | + // |
| 356 | + if (id < 0 || id >= static_cast<int>(mTrackIDtoParticlesEntry.size())) { |
| 357 | + return false; |
| 358 | + } |
| 359 | + const auto entry = mTrackIDtoParticlesEntry[id]; |
| 360 | + if (entry < 0 || entry >= static_cast<int>(mParticles.size())) return false; |
| 361 | + auto part = (mParticles[entry]); |
| 362 | + |
| 363 | + // primary particle ? |
| 364 | + if (part.getProcess() == 0 ) return false; |
| 365 | + // particle directly from radioactive decay ? |
| 366 | + if (part.getProcess() == kPRadDecay) { |
| 367 | + return true; |
| 368 | + } |
| 369 | + |
| 370 | + // search in particle history |
| 371 | + auto imo = mTrackIDtoParticlesEntry[part.getMotherTrackId()]; |
| 372 | + auto isRad = false; |
| 373 | + |
| 374 | + while (imo > 0 ) { |
| 375 | + auto mother = (mParticles[imo]); |
| 376 | + if (mother.getProcess() == kPRadDecay) { |
| 377 | + isRad = true; |
| 378 | + break; |
| 379 | + } |
| 380 | + part = mother; |
| 381 | + imo = mTrackIDtoParticlesEntry[mother.getMotherTrackId()]; |
| 382 | + } |
| 383 | + return isRad; |
| 384 | +} |
| 385 | + |
351 | 386 | inline bool Stack::isCurrentTrackDaughterOf(int parentid) const |
352 | 387 | { |
353 | 388 | // if parentid is current primary the answer is certainly yes |
|
0 commit comments