Skip to content

Commit 40f84cb

Browse files
committed
GPU TPC: Let fallback clusters compete for ambiguity solving as all other clusters
1 parent f8a3f63 commit 40f84cb

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

‎GPU/GPUTracking/Definitions/GPUSettingsList.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ AddOptionRTC(rebuildTrackMaxSharedFraction, float, 0.1f, "", 0, "Max fraction of
106106
AddOptionRTC(rebuildTrackMaxNonIntCov, float, 4.f, "", 0, "Max Err2 allowed for non-interpolated cluster attachment during rebuild")
107107
AddOptionRTC(rebuildErrorWeightFactor, float, 5.f, "", 0, "Factor for the error (distance^2) of a cluster candidate in its hit weight 1 / (1 + factor * error) during rebuild")
108108
AddOptionRTC(rebuildTrackExtrMaxAvgChi2, float, 4.f, "", 0, "Max average chi2 per cluster to accept an extrapolated segment (0 = disabled)")
109+
AddOptionRTC(rebuildTrackFallbackErr, float, 1.f, "", 0, "Error (distance^2) assigned to the original clusters of a track used as fallback candidates in rows that could not be searched during rebuild")
110+
AddOptionRTC(rebuildTrackFallbackTrackChi2, float, 4.f, "", 0, "Chi2 per cluster assumed for the hit weight of tracks without successful fit (NDF <= 0) during rebuild")
109111
AddOptionRTC(rebuildTrackAltCandidateMaxErrFactor, float, 2.f, "", 0, "Alternative cluster candidates of a row are used only if their distance^2 is below this factor times the distance^2 of the best candidate")
110112
AddOptionRTC(rebuildTrackAltCandidateGoodErr, float, 0.25f, "", 0, "Alternative cluster candidates of a row with distance^2 below this value are always used")
111113
AddOptionRTC(rebuildTrackErrFactorOneSided, float, 1.5f, "", 0, "Factor applied to the error (distance^2) of cluster candidates found with the track position from only one side during rebuild")

‎GPU/GPUTracking/Merger/GPUTPCGMMerger.cxx‎

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,15 +2178,18 @@ GPUd() void GPUTPCGMMerger::PrepareHitWeights(int32_t nBlocks, int32_t nThreads,
21782178
}
21792179
mTrackRebuildHelper[i].reverse = mClusters[trk.FirstClusterRef()].row < mClusters[trk.FirstClusterRef() + trk.NClusters() - 1].row;
21802180
if (!(Param().rec.tpc.disableRebuildAttachment & 8)) {
2181+
const uint32_t nMaxCandidates = Param().rec.tpc.rebuildTrackInFitClusterCandidates;
21812182
int lastRow = -1;
21822183
for (uint32_t j = 0; j < trk.NClusters(); j++) {
21832184
const auto& cl = mClusters[trk.FirstClusterRef() + j];
2184-
auto* candidates = &mClusterCandidates[(i * GPUTPCGeometry::NROWS + cl.row) * Param().rec.tpc.rebuildTrackInFitClusterCandidates];
2185-
if (cl.row != lastRow && candidates[0].id == 0 && (!(cl.state & GPUTPCGMMergedTrackHit::flagReject) || trk.GetParam().GetNDF() <= 0)) {
2186-
candidates[0].id = cl.num + 2;
2187-
candidates[0].best = 128; // TODO: Needs better handling in the future, particularly should be marked as shared correctly. Tracks with NDF <= 0 get no fallback in rows with candidates, and get those back only via the shared recovery
2188-
candidates[0].weight = cl.state;
2189-
candidates[0].sector = cl.sector;
2185+
auto* candidates = &mClusterCandidates[(i * GPUTPCGeometry::NROWS + cl.row) * nMaxCandidates];
2186+
if ((!(cl.state & GPUTPCGMMergedTrackHit::flagReject) || trk.GetParam().GetNDF() <= 0) && (candidates[0].id == 0 || cl.row == lastRow)) { // Row not searched: the original clusters of the row compete as normal candidates with fixed error
2187+
for (uint32_t k = 0; k < nMaxCandidates; k++) {
2188+
if (candidates[k].id == 0) {
2189+
candidates[k] = {.id = cl.num + 2, .row = cl.row, .sector = cl.sector, .error = Param().rec.tpc.rebuildTrackFallbackErr, .weight = 0, .best = 0};
2190+
break;
2191+
}
2192+
}
21902193
lastRow = cl.row;
21912194
}
21922195
}
@@ -2198,15 +2201,15 @@ GPUd() void GPUTPCGMMerger::ComputeHitWeights(int32_t nBlocks, int32_t nThreads,
21982201
{
21992202
for (int32_t i = get_global_id(0); i < NMergedTracks(); i += get_global_size(0)) {
22002203
const auto& trk = mMergedTracks[i];
2201-
if (!trk.OK() || trk.GetParam().GetNDF() <= 0) {
2204+
if (!trk.OK()) {
22022205
continue;
22032206
}
22042207
for (uint32_t j = 0; j < GPUTPCGeometry::NROWS; j++) {
22052208
auto* candidates = &mClusterCandidates[(i * GPUTPCGeometry::NROWS + j) * Param().rec.tpc.rebuildTrackInFitClusterCandidates];
22062209
if (candidates[0].best == 0) {
2207-
if (candidates[iteration].id >= 2 && (iteration == 0 || candidates[iteration].error <= CAMath::Max(Param().rec.tpc.rebuildTrackAltCandidateGoodErr, candidates[0].error * Param().rec.tpc.rebuildTrackAltCandidateMaxErrFactor))) { // Don't fall back to a much worse candidate, the best one is then rather a shared cluster
2208-
float weightf = (trk.GetParam().GetNDF() + 5) * trk.GetParam().GetNDF() * 64 / trk.GetParam().GetChi2() / (1.f + Param().rec.tpc.rebuildErrorWeightFactor * candidates[iteration].error);
2209-
int32_t weight = weightf < 0.f ? 0 : (weightf > 2e9f ? 2e9f : (int32_t)weightf);
2210+
if (candidates[iteration].id >= 2 && (iteration == 0 || candidates[iteration].error <= CAMath::Max(Param().rec.tpc.rebuildTrackAltCandidateGoodErr, candidates[0].error * Param().rec.tpc.rebuildTrackAltCandidateMaxErrFactor))) { // Don't fall back to a much worse candidate, the best one is then rather a shared cluster
2211+
float weightf = (trk.GetParam().GetNDF() > 0 ? (trk.GetParam().GetNDF() + 5) * trk.GetParam().GetNDF() * 64 / trk.GetParam().GetChi2() : (2 * (int32_t)trk.NClusters() - 5) * 128 / Param().rec.tpc.rebuildTrackFallbackTrackChi2) / (1.f + Param().rec.tpc.rebuildErrorWeightFactor * candidates[iteration].error); // Tracks with NDF <= 0 use their nominal number of clusters and assume a fixed chi2 per cluster
2212+
int32_t weight = weightf > 0.f ? (weightf > 2e9f ? 2e9f : (int32_t)weightf) : 0;
22102213
candidates[iteration].weight = weight;
22112214
CAMath::AtomicMax(&mHitWeights[candidates[iteration].id - 2], weight);
22122215
CADEBUG(printf("REBUILD: iTrk %d Iteration %d Row %d Cluster %d Weight %d\n", i, iteration, j, candidates[iteration].id - 2, weight));
@@ -2222,7 +2225,7 @@ GPUd() void GPUTPCGMMerger::ResolveHitWeights1(int32_t nBlocks, int32_t nThreads
22222225
{
22232226
for (int32_t i = get_global_id(0); i < NMergedTracks(); i += get_global_size(0)) {
22242227
auto& trk = mMergedTracks[i];
2225-
if (!trk.OK() || trk.GetParam().GetNDF() <= 0) {
2228+
if (!trk.OK()) {
22262229
continue;
22272230
}
22282231
for (unsigned int j = 0; j < GPUTPCGeometry::NROWS; j++) {
@@ -2250,12 +2253,12 @@ GPUd() void GPUTPCGMMerger::ResolveHitWeights2(int32_t nBlocks, int32_t nThreads
22502253
uint8_t nSharedRowCandidates = 0;
22512254
for (unsigned int j = 0; j < GPUTPCGeometry::NROWS; j++) {
22522255
auto* candidates = &mClusterCandidates[(i * GPUTPCGeometry::NROWS + j) * Param().rec.tpc.rebuildTrackInFitClusterCandidates];
2253-
if (trk.GetParam().GetNDF() > 0 && candidates[0].best == 0 && candidates[nIter - 1].weight == mHitWeights[candidates[nIter - 1].id - 2]) {
2256+
if (candidates[0].best == 0 && candidates[nIter - 1].weight == mHitWeights[candidates[nIter - 1].id - 2]) {
22542257
candidates[0].best = nIter;
22552258
}
22562259
if (candidates[0].best > 0) {
22572260
nHits++;
2258-
if (candidates[0].best != 128 && candidates[candidates[0].best - 1].weight != mHitWeights[candidates[candidates[0].best - 1].id - 2]) {
2261+
if (candidates[candidates[0].best - 1].weight != mHitWeights[candidates[candidates[0].best - 1].id - 2]) {
22592262
mSharedCount2[candidates[candidates[0].best - 1].id - 2] = 1; // shared between tracks of different iterations
22602263
}
22612264
} else if (candidates[0].best != -1 && candidates[0].id >= 2) {
@@ -2300,11 +2303,6 @@ GPUd() void GPUTPCGMMerger::ResolveHitWeights2(int32_t nBlocks, int32_t nThreads
23002303
const auto& candidates = &mClusterCandidates[(i * GPUTPCGeometry::NROWS + j) * Param().rec.tpc.rebuildTrackInFitClusterCandidates];
23012304
if (candidates[0].best > 0) {
23022305
auto& outCl = mClusters[iOut + (reverse ? (written) : (nHits - 1 - written))];
2303-
if (candidates[0].best == 128) {
2304-
outCl = {.num = candidates[0].id - 2, .sector = candidates[0].sector, .row = (uint8_t)j, .state = (uint8_t)candidates[0].weight};
2305-
written++;
2306-
continue;
2307-
}
23082306
const auto& best = candidates[candidates[0].best - 1];
23092307
const ClusterNative& GPUrestrict() cl = GetConstantMem()->ioPtrs.clustersNative->clustersLinear[best.id - 2];
23102308
uint8_t flags = (uint8_t)(cl.getFlags() & GPUTPCGMMergedTrackHit::clustererAndSharedFlags);

0 commit comments

Comments
 (0)