Skip to content

Commit 261ba2d

Browse files
TPC SCD: rename UnbinnedResid::pack to packToShort, document the fixed 0x7fff scale
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent faef6b7 commit 261ba2d

2 files changed

Lines changed: 14 additions & 12 deletions

File tree

‎Detectors/TPC/calibration/SpacePoints/include/SpacePoints/TrackInterpolation.h‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ struct TPCClusterResiduals {
7979
struct 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
}

‎Detectors/TPC/calibration/SpacePoints/src/TrackInterpolation.cxx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ void TrackInterpolation::interpolateTrack(int iSeed)
913913
auto dy = yv - trkWorkITS.getY();
914914
auto dz = zv - trkWorkITS.getZ();
915915
if ((std::abs(dy) < param::MaxResid) && (std::abs(dz) < param::MaxResid) && (std::abs(trkWorkITS.getY()) < param::MaxY) && (std::abs(trkWorkITS.getZ()) < param::MaxZ) && std::abs(xv) < param::MaxVtxX) {
916-
short compXV = UnbinnedResid::pack(xv, param::MaxVtxX);
916+
short compXV = UnbinnedResid::packToShort(xv, param::MaxVtxX);
917917
mClRes.emplace_back(dy, dz, alpha / TMath::Pi(), trkWorkITS.getY(), trkWorkITS.getZ(), 190, -1, compXV);
918918
if (!gidTable[GTrackID::ITSTPC].isIndexSet()) {
919919
LOGP(fatal, "ITS-TPC seed index is not set for TOF track");
@@ -985,7 +985,7 @@ int TrackInterpolation::processTRDLayer(const o2::trd::TrackTRD& trkTRD, int iLa
985985
if (trkData) {
986986
auto slope = trdSP.getDy();
987987
if (std::abs(slope) < param::MaxTRDSlope) {
988-
trkData->TRDTrkltSlope[iLayer] = UnbinnedResid::pack(slope, param::MaxTRDSlope);
988+
trkData->TRDTrkltSlope[iLayer] = UnbinnedResid::packToShort(slope, param::MaxTRDSlope);
989989
}
990990
}
991991
if (trk64) {
@@ -1308,7 +1308,7 @@ void TrackInterpolation::extrapolateTrack(int iSeed)
13081308
auto dy = yv - trkWorkITS.getY();
13091309
auto dz = zv - trkWorkITS.getZ();
13101310
if ((std::abs(dy) < param::MaxResid) && (std::abs(dz) < param::MaxResid) && (std::abs(trkWorkITS.getY()) < param::MaxY) && (std::abs(trkWorkITS.getZ()) < param::MaxZ) && std::abs(xv) < param::MaxVtxX) {
1311-
short compXV = UnbinnedResid::pack(xv, param::MaxVtxX);
1311+
short compXV = UnbinnedResid::packToShort(xv, param::MaxVtxX);
13121312
mClRes.emplace_back(dy, dz, alpha / TMath::Pi(), trkWorkITS.getY(), trkWorkITS.getZ(), 190, -1, compXV);
13131313
if (!gidTableFull[GTrackID::ITSTPC].isIndexSet()) {
13141314
LOGP(fatal, "ITS-TPC seed index is not set for TOF track");

0 commit comments

Comments
 (0)