@@ -79,11 +79,11 @@ struct TPCClusterResiduals {
7979struct UnbinnedResid {
8080 UnbinnedResid () = default ;
8181 UnbinnedResid (float dyIn, float dzIn, float tgSlpIn, float yIn, float zIn,
82- unsigned char rowIn, unsigned char secIn, short chanIn = -1 , bool rejFlag = false ) : dy(pack (dyIn, param::MaxResid)),
83- dz (pack (dzIn, param::MaxResid)),
84- tgSlp(pack (tgSlpIn, param::MaxTgSlp, std::abs(tgSlpIn) < param::MaxTgSlp ? 0x7fff - 1 : 0x7fff)),
85- y(pack (yIn, param::MaxY)),
86- z(pack (zIn, param::MaxZ)),
82+ unsigned char rowIn, unsigned char secIn, short chanIn = -1 , bool rejFlag = false ) : dy(packToShort (dyIn, param::MaxResid)),
83+ dz (packToShort (dzIn, param::MaxResid)),
84+ tgSlp(packToShort (tgSlpIn, param::MaxTgSlp, std::abs(tgSlpIn) < param::MaxTgSlp ? 0x7fff - 1 : 0x7fff)),
85+ y(packToShort (yIn, param::MaxY)),
86+ z(packToShort (zIn, param::MaxZ)),
8787 row(rowIn),
8888 sec(secIn),
8989 channel(chanIn),
@@ -98,10 +98,12 @@ struct UnbinnedResid {
9898 short channel{-1 }; // /< extra channel info (ITS chip ID, TRD chamber, TOF main pad within the sector)
9999 bool rejected{false }; // /< residual is flagged as rejected in the validateTrack
100100
101- // / value (|value| <= maximum) packed into a short, rounded to the nearest of the 0x7fff steps per maximum and limited to +-limit.
102- // / A plain cast would truncate towards zero, i.e. move every value towards zero by up to one step: the decoded cluster position
103- // / y + dy then depends on the sign of dy below the step size, which biases residuals binned by the cluster position on sub-pad scales
104- static short pack (float value, float maximum, int limit = 0x7fff )
101+ // / value (|value| <= maximum) packed into a signed short, rounded to the nearest step. The scale is fixed at 0x7fff steps per maximum
102+ // / (decoded everywhere as short * maximum / 0x7fff); limit only clips the result to +-limit (e.g. 0x7fff - 1 for an unclamped tgSlp, to
103+ // / keep 0x7fff as the clamp marker), it does not change the scale. A plain cast would truncate towards zero, i.e. move every value
104+ // / towards zero by up to one step: the decoded cluster position y + dy then depends on the sign of dy below the step size, which
105+ // / biases residuals binned by the cluster position on sub-pad scales
106+ static short packToShort (float value, float maximum, int limit = 0x7fff )
105107 {
106108 return static_cast <short >(std::clamp<long >(std::lround (value * 0x7fff / maximum), -limit, limit));
107109 }
0 commit comments