Skip to content

Commit

Permalink
Fix GPUTPCGeometry LinearPad2Y/Y2Pad methods, define biased ones in G…
Browse files Browse the repository at this point in the history
…PUTPCCompressionTrackModel
  • Loading branch information
shahor02 committed Jan 22, 2025
1 parent e082562 commit 7b2c021
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
4 changes: 2 additions & 2 deletions GPU/GPUTracking/DataCompression/GPUTPCCompressionKernels.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ GPUdii() void GPUTPCCompressionKernels::Thread<GPUTPCCompressionKernels::step0at
}
const ClusterNative& GPUrestrict() orgCl = clusters->clusters[hit.slice][hit.row][hit.num - clusters->clusterOffset[hit.slice][hit.row]];
float x = param.tpcGeometry.Row2X(hit.row);
float y = param.tpcGeometry.LinearPad2Y(hit.slice, hit.row, orgCl.getPad());
float y = track.LinearPad2Y(hit.slice, orgCl.getPad(), param.tpcGeometry.PadWidth(hit.row), param.tpcGeometry.NPads(hit.row));
float z = param.tpcGeometry.LinearTime2Z(hit.slice, orgCl.getTime());
if (nClustersStored) {
if ((hit.slice < GPUCA_NSLICES) ^ (lastSlice < GPUCA_NSLICES)) {
Expand Down Expand Up @@ -115,7 +115,7 @@ GPUdii() void GPUTPCCompressionKernels::Thread<GPUTPCCompressionKernels::step0at
}
c.rowDiffA[cidx] = row;
c.sliceLegDiffA[cidx] = (hit.leg == lastLeg ? 0 : compressor.NSLICES) + slice;
float pad = CAMath::Max(0.f, CAMath::Min((float)param.tpcGeometry.NPads(GPUCA_ROW_COUNT - 1), param.tpcGeometry.LinearY2Pad(hit.slice, hit.row, track.Y())));
float pad = CAMath::Max(0.f, CAMath::Min((float)param.tpcGeometry.NPads(GPUCA_ROW_COUNT - 1), track.LinearY2Pad(hit.slice, track.Y(), param.tpcGeometry.PadWidth(hit.row), param.tpcGeometry.NPads(hit.row))));
c.padResA[cidx] = orgCl.padPacked - orgCl.packPad(pad);
float time = CAMath::Max(0.f, param.tpcGeometry.LinearZ2Time(hit.slice, track.Z() + zOffset));
c.timeResA[cidx] = (orgCl.getTimePacked() - orgCl.packTime(time)) & 0xFFFFFF;
Expand Down
12 changes: 12 additions & 0 deletions GPU/GPUTracking/DataCompression/GPUTPCCompressionTrackModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,18 @@ class GPUTPCCompressionTrackModel
GPUd() void getClusterErrors2(int32_t iRow, float z, float sinPhi, float DzDs, float& ErrY2, float& ErrZ2) const;
GPUd() void resetCovariance();

GPUd() float LinearPad2Y(int32_t slice, float pad, float padWidth, int8_t npads) const
{
const float u = (pad - 0.5f * npads) * padWidth;
return (slice >= GPUCA_NSLICES / 2) ? -u : u;
}

GPUd() float LinearY2Pad(int32_t slice, float y, float padWidth, int8_t npads) const
{
const float u = (slice >= GPUCA_NSLICES / 2) ? -y : y;
return u / padWidth + 0.5f * npads;
}

#endif

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class TPCClusterDecompressionCore
timeTmp |= 0xFF000000;
}
time = timeTmp + ClusterNative::packTime(CAMath::Max(0.f, param.tpcGeometry.LinearZ2Time(slice, track.Z() + zOffset)));
float tmpPad = CAMath::Max(0.f, CAMath::Min((float)param.tpcGeometry.NPads(GPUCA_ROW_COUNT - 1), param.tpcGeometry.LinearY2Pad(slice, row, track.Y())));
float tmpPad = CAMath::Max(0.f, CAMath::Min((float)param.tpcGeometry.NPads(GPUCA_ROW_COUNT - 1), track.LinearY2Pad(slice, track.Y(), param.tpcGeometry.PadWidth(row), param.tpcGeometry.NPads(row))));
pad = cmprClusters.padResA[clusterOffset - trackIndex - 1] + ClusterNative::packPad(tmpPad);
time = time & 0xFFFFFF;
pad = (uint16_t)pad;
Expand All @@ -136,7 +136,7 @@ class TPCClusterDecompressionCore
pad = cmprClusters.padA[trackIndex];
}
const auto cluster = decompressTrackStore(cmprClusters, clusterOffset, slice, row, pad, time, args...);
float y = param.tpcGeometry.LinearPad2Y(slice, row, cluster.getPad());
float y = track.LinearPad2Y(slice, cluster.getPad(), param.tpcGeometry.PadWidth(row), param.tpcGeometry.NPads(row));
float z = param.tpcGeometry.LinearTime2Z(slice, cluster.getTime());
if (clusterIndex == 0) {
zOffset = z;
Expand Down Expand Up @@ -187,4 +187,4 @@ class TPCClusterDecompressionCore
};
} // namespace GPUCA_NAMESPACE::gpu

#endif
#endif
8 changes: 8 additions & 0 deletions GPU/GPUTracking/DataTypes/GPUTPCGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ class GPUTPCGeometry // TODO: Make values constexpr

GPUd() float LinearPad2Y(int32_t slice, int32_t row, float pad) const
{
#ifdef GPUCA_TPC_GEOMETRY_O2
const float u = (pad - 0.5f * (mNPads[row] - 1)) * PadWidth(row);
#else
const float u = (pad - 0.5f * mNPads[row]) * PadWidth(row);
#endif
return (slice >= GPUCA_NSLICES / 2) ? -u : u;
}

Expand All @@ -127,7 +131,11 @@ class GPUTPCGeometry // TODO: Make values constexpr
GPUd() float LinearY2Pad(int32_t slice, int32_t row, float y) const
{
const float u = (slice >= GPUCA_NSLICES / 2) ? -y : y;
#ifdef GPUCA_TPC_GEOMETRY_O2
return u / PadWidth(row) + 0.5f * (mNPads[row] - 1);
#else
return u / PadWidth(row) + 0.5f * mNPads[row];
#endif
}

GPUd() static float LinearZ2Time(int32_t slice, float z)
Expand Down

0 comments on commit 7b2c021

Please sign in to comment.