Problem with Short-Lifetime Decays
I've discovered a problem with the new way that decays are handled in nptool simulations. The mother nucleus for decays with a short lifetime ends up having a kinetic energy that is far below what it should be.
Within the file
Process/Decay.cc, we have the following lines:
double energy = PrimaryTrack->GetKineticEnergy(); double time = PrimaryTrack->GetGlobalTime(); // Randomize within the step // Assume energy loss is linear within the step // Assume no scattering double rand = G4RandFlat::shoot(); double length = rand*(m_PreviousLength); energy += (1-rand)*(m_PreviousEnergy-energy);
The intent is that the initial kinetic energy for the decay process is chosen randomly from within the step where the decay is supposed to happen. However, this causes a problem for very short lifetime decays, where the decay happens in the first step following the reaction that proceeds the decay.
When this happens,
PreviousEnergy is equal to zero, and so the generated energy ends up being randomly distributed between 0 and the correct energy.
The easiest way I can think of to fix this is to have a check
if(PreviousEnergy > 0) before doing the randomization (otherwise just leave
energy = PrimaryTrack->GetKineticEnergy();). But maybe there is a more robust way, for example checking the step number or something like that.