Skip to content

Commit 01a6b74

Browse files
committed
GPU TPC: Fix cluster adjacent flags with Rebuild (and improve without)
1 parent d410115 commit 01a6b74

6 files changed

Lines changed: 21 additions & 20 deletions

File tree

‎GPU/GPUTracking/DataCompression/GPUTPCCompressionKernels.cxx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ GPUdii() void GPUTPCCompressionKernels::Thread<GPUTPCCompressionKernels::step0at
5353

5454
int32_t hitId = hit.num;
5555
int32_t attach = ioPtrs.mergedTrackHitAttachment[hitId];
56-
if ((attach & gputpcgmmergertypes::attachTrackMask) != i) {
56+
if (gputpcgmmergertypes::getAttachedTrackId(attach) != i) {
5757
continue; // Main attachment to different track
5858
}
5959
bool rejectCluster = processors.param.rec.tpc.rejectionStrategy >= GPUSettings::RejectionStrategyA && !(attach & gputpcgmmergertypes::attachProtect) && (rejectTrk || GPUTPCClusterRejection::GetIsRejected(attach));
@@ -206,7 +206,7 @@ GPUd() bool GPUTPCCompression::rejectCluster(int32_t idx, const GPUParam& GPUres
206206
if (attach & gputpcgmmergertypes::attachProtect) {
207207
return false;
208208
}
209-
int32_t id = attach & gputpcgmmergertypes::attachTrackMask;
209+
int32_t id = gputpcgmmergertypes::getAttachedTrackId(attach);
210210
auto& trk = ioPtrs.mergedTracks[id];
211211
if (GPUTPCClusterRejection::IsTrackRejected(trk, param)) {
212212
return true;

‎GPU/GPUTracking/Merger/GPUTPCGMMerger.cxx‎

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,13 +1878,10 @@ GPUd() void GPUTPCGMMerger::PrepareForFit1(int32_t nBlocks, int32_t nThreads, in
18781878
mTrackOrderAttach[mTrackSort[i]] = i;
18791879
GPUTPCGMMergedTrack& trk = mMergedTracks[i];
18801880
if (trk.OK()) {
1881+
const bool protect = CAMath::Abs(trk.GetParam().GetQPt() * Param().qptB5Scaler) <= Param().rec.tpc.rejectQPtB5 && !trk.MergedLooper() && trk.Leg() == 0;
18811882
for (uint32_t j = 0; j < trk.NClusters(); j++) {
1882-
if (!Param().rec.tpc.rebuildTrackInFit) {
1883-
uint32_t weight = attachAttached | attachGood;
1884-
if (CAMath::Abs(trk.GetParam().GetQPt() * Param().qptB5Scaler) <= Param().rec.tpc.rejectQPtB5 && !trk.MergedLooper() && trk.Leg() == 0) {
1885-
weight |= attachProtect;
1886-
}
1887-
CAMath::AtomicMax(&mClusterAttachment[mClusters[trk.FirstClusterRef() + j].num], weight);
1883+
if (protect) { // Protect the clusters of the initial tracks. No track id on purpose, any entry of a final track for the cluster shall win
1884+
CAMath::AtomicMax(&mClusterAttachment[mClusters[trk.FirstClusterRef() + j].num], (uint32_t)(attachAttached | attachProtect | (Param().rec.tpc.rebuildTrackInFit ? 0 : attachGood)));
18881885
}
18891886
CAMath::AtomicAdd(&mSharedCount[mClusters[trk.FirstClusterRef() + j].num], 1u);
18901887
}
@@ -1933,8 +1930,8 @@ GPUd() void GPUTPCGMMerger::Finalize0(int32_t nBlocks, int32_t nThreads, int32_t
19331930
mTrackSort[mTrackOrderAttach[i]] = i;
19341931
}
19351932
for (uint32_t i = iBlock * nThreads + iThread; i < mMemory->nMergedTrackClusters; i += nThreads * nBlocks) {
1936-
if (!(mClusterAttachment[mClusters[i].num] & attachProtect)) {
1937-
mClusterAttachment[mClusters[i].num] = 0; // Reset adjacent attachment for attached clusters, set correctly below
1933+
if (!(mClusterAttachment[mClusters[i].num] & attachProtect)) { // Protected entries are kept on purpose: resetting them could release clusters of the initial tracks that were used for the seeding, and removing such clusters can make the tracking not find the track again
1934+
mClusterAttachment[mClusters[i].num] = 0; // Reset adjacent attachment for attached clusters, set correctly below
19381935
}
19391936
}
19401937
}
@@ -1948,11 +1945,12 @@ GPUd() void GPUTPCGMMerger::Finalize1(int32_t nBlocks, int32_t nThreads, int32_t
19481945
}
19491946
for (uint32_t j = 0; j < trk.NClusters(); j++) {
19501947
int32_t id = mClusters[trk.FirstClusterRef() + j].num;
1951-
uint32_t weight = mTrackOrderAttach[i] | attachAttached;
1948+
uint32_t weight = (mTrackOrderAttach[i] << nPureFlags) | attachAttached;
19521949
uint8_t clusterState = mClusters[trk.FirstClusterRef() + j].state;
19531950
if (!(clusterState & GPUTPCGMMergedTrackHit::flagReject)) {
19541951
weight |= attachGood;
1955-
} else if (clusterState & GPUTPCGMMergedTrackHit::flagHighIncl) {
1952+
}
1953+
if (clusterState & GPUTPCGMMergedTrackHit::flagHighIncl) {
19561954
weight |= attachHighIncl;
19571955
}
19581956
if (trk.Leg() == 0) {
@@ -1970,7 +1968,7 @@ GPUd() void GPUTPCGMMerger::Finalize2(int32_t nBlocks, int32_t nThreads, int32_t
19701968
{
19711969
for (uint32_t i = iBlock * nThreads + iThread; i < mNClusters; i += nThreads * nBlocks) {
19721970
if (mClusterAttachment[i] != 0) {
1973-
mClusterAttachment[i] = (mClusterAttachment[i] & attachFlagMask) | mTrackSort[mClusterAttachment[i] & attachTrackMask];
1971+
mClusterAttachment[i] = (mClusterAttachment[i] & attachFlagMask) | (mTrackSort[getAttachedTrackId(mClusterAttachment[i])] << nPureFlags);
19741972
}
19751973
}
19761974
}

‎GPU/GPUTracking/Merger/GPUTPCGMMergerDump.cxx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void GPUTPCGMMerger::DumpFitPrepare(std::ostream& out) const
206206
if (j++ % 10 == 0) {
207207
out << "\n Cluster attachment ";
208208
}
209-
out << i << ": " << (mClusterAttachment[i] & attachTrackMask) << " / " << (mClusterAttachment[i] & attachFlagMask) << " - ";
209+
out << i << ": " << getAttachedTrackId(mClusterAttachment[i]) << " / " << (mClusterAttachment[i] & attachFlagMask) << " - ";
210210
}
211211
}
212212
out << "\n";
@@ -255,7 +255,7 @@ void GPUTPCGMMerger::DumpFinal(std::ostream& out) const
255255
if (++j % 10 == 0) {
256256
out << " Cluster attachment ";
257257
}
258-
out << i << ": " << (mClusterAttachment[i] & attachTrackMask) << " / " << (mClusterAttachment[i] & attachFlagMask) << " - ";
258+
out << i << ": " << getAttachedTrackId(mClusterAttachment[i]) << " / " << (mClusterAttachment[i] & attachFlagMask) << " - ";
259259
if (j % 10 == 0) {
260260
out << "\n";
261261
}

‎GPU/GPUTracking/Merger/GPUTPCGMMergerTypes.h‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ enum attachTypes { attachProtect = 0x80000000,
2626
attachGood = 0x20000000,
2727
attachGoodLeg = 0x10000000,
2828
attachTube = 0x08000000,
29-
attachHighIncl = 0x04000000,
30-
attachTrackMask = 0x03FFFFFF,
31-
attachFlagMask = 0xFC000000,
29+
attachHighIncl = 0x1,
30+
attachTrackMask = 0x07FFFFFE,
31+
attachFlagMask = 0xF8000001,
32+
nPureFlags = 1, // Number of flag bits below the track id (do not influence which track wins the attachment), the track id is shifted by this number of bits
3233
attachZero = 0 };
3334

35+
GPUdi() static constexpr uint32_t getAttachedTrackId(uint32_t v) { return (v & attachTrackMask) >> nPureFlags; }
36+
3437
struct InterpolationErrorHit {
3538
float posY, posZ;
3639
GPUCA_PAR_MERGER_INTERPOLATION_ERROR_TYPE_A errorY, errorZ;

‎GPU/GPUTracking/Merger/GPUTPCGMTrackParam.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ GPUd() void GPUTPCGMTrackParam::FindAdjacentClustersUncorrectedPos(const GPUTPCG
11551155
const int32_t nBinsY = row.Grid().Ny();
11561156
const int32_t idOffset = tracker.Data().ClusterIdOffset();
11571157
const int32_t* ids = &(tracker.Data().ClusterDataIndex()[row.HitNumberOffset()]);
1158-
uint32_t myWeight = merger.TrackOrderAttach()[iTrack] | gputpcgmmergertypes::attachAttached | gputpcgmmergertypes::attachTube;
1158+
uint32_t myWeight = (merger.TrackOrderAttach()[iTrack] << gputpcgmmergertypes::nPureFlags) | gputpcgmmergertypes::attachAttached | gputpcgmmergertypes::attachTube;
11591159
GPUAtomic(uint32_t)* const weights = merger.ClusterAttachment();
11601160
if (goodLeg) {
11611161
myWeight |= gputpcgmmergertypes::attachGoodLeg;

‎GPU/GPUTracking/display/render/GPUDisplayDraw.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ void GPUDisplay::DrawClusters(int32_t iSector)
170170
} else if ((mCfgH.markAdjacentClusters & 16) && (attach & gputpcgmmergertypes::attachHighIncl)) {
171171
select = tMARKED;
172172
} else if (mCfgH.markAdjacentClusters & 8) {
173-
if (fabsf(mIOPtrs->mergedTracks[attach & gputpcgmmergertypes::attachTrackMask].GetParam().GetQPt()) > 20.f) {
173+
if (fabsf(mIOPtrs->mergedTracks[gputpcgmmergertypes::getAttachedTrackId(attach)].GetParam().GetQPt()) > 20.f) {
174174
select = tMARKED;
175175
}
176176
}

0 commit comments

Comments
 (0)