fix the calculation of a mc position at a given z
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
Activity
Dear @v.friese,
you have been identified as code owner of at least one file which was changed with this merge request.
Please check the changes and approve them or request changes.
added CodeOwners label
added 5 commits
-
fc525224...6dabb4fa - 4 commits from branch
computing:master
- f853ff05 - fix the calculation of a mc position at a given z
-
fc525224...6dabb4fa - 4 commits from branch
- Resolved by Volker Friese
The method is meant for interpolation of the trajectory within the sensor, so the valid z range is [fZ, fZ_out]. Using it outside of the sensor, i.e. for z < fZ or z > fZ_out is questionable, but of course mathematically possible.
The current implementation returns the coordinates at the mid-plane of the sensor if z is outside. This is probably not a good recipe, apart from that, as you rightly pointed out, it also happens at the sensor surface.
The possible options are:
- Throw an error for illegal z arguments;
- Allow extrapolation outside of the sensor. This is what you propose. However, your implementation is not correct; it should read
if (fabs(dz) < 1.e-4) return fX_out;
added 5 commits
-
f853ff05...e283f472 - 4 commits from branch
computing:master
- ac16e4ac - fix the calculation of a mc position at a given z
-
f853ff05...e283f472 - 4 commits from branch
enabled an automatic merge when the pipeline for ac16e4ac succeeds