Hello all,
evaluating strange behavior of my program I have found strange place in G4ParticleHPContEnergyAngular::Sample(…) function. As I understood It tries to interpolate two datasets:
fCacheAngular.Get()->BuildByInterpolation(anEnergy, theManager.GetScheme(0),
(theAngular[it-1]), (theAngular[it]) );
but sometimes the datasets “theAngular” have different dimensions. Nevertheless the function
“BuildInterpolation” expect that the both datasets have the same size:
for (G4int ip = 0; ip < nAngularParameters; ++ip) {
val1 = theInt.Interpolate2(theManager.GetScheme(ie),
e1Interp,
copyAngpar1.theAngular[ie1Prev].GetLabel(),
copyAngpar1.theAngular[ie1].GetLabel(),
copyAngpar1.theAngular[ie1Prev].GetValue(ip),
copyAngpar1.theAngular[ie1].GetValue(ip)) * (maxEner1-minEner1);
val2 = theInt.Interpolate2(theManager.GetScheme(ie),
e2Interp,
copyAngpar2.theAngular[ie2Prev].GetLabel(),
copyAngpar2.theAngular[ie2].GetLabel(),
copyAngpar2.theAngular[ie2Prev].GetValue(ip),
copyAngpar2.theAngular[ie2].GetValue(ip)) * (maxEner2-minEner2);
Of course the internal protection in the function:
G4ParticleHPList::GetValue(G4int i)
{
…
if (i >= GetListLength())
i = GetListLength() - 1;
…
}
prevents possible crashes, but anyway the mentioned code looks very suspicious…
Additionally the class G4ParticleHPList uses memory management witch could be simplified with std::vector<…>
May it helps somebody to do the world better…
Vyacheslav