Skip to content

fix the calculation of a mc position at a given z

Sergey Gorbunov requested to merge se.gorbunov/cbmroot:StsPoints into master

In CbmStsPoint.cxx the GetX(z) calculation produces unexpected output when z is outside of the (fX, fX_out) interval.

For example, when z==fZ or z==fZ_out, the method is expected to return fX and fX_out respectively, but it returns the mean value (fX_out+fX)/2 instead.

The MR fixes the calculation.

// -----   Point x coordinate from linear extrapolation   ------------------
double CbmStsPoint::GetX(double z) const
{
  //  LOG(info) << fZ << " " << z << " " << fZ_out;
  if ((fZ_out - z) * (fZ - z) >= 0.) return (fX_out + fX) / 2.;
  double dz = fZ_out - fZ;
  return (fX + (z - fZ) / dz * (fX_out - fX));
}
// -------------------------------------------------------------------------

Merge request reports