Skip to content

Commit 6b2534c

Browse files
committed
GPU TPC: Interpolate missing pad rows when rebuilding track
1 parent a01be27 commit 6b2534c

File tree

3 files changed

+35
-21
lines changed

3 files changed

+35
-21
lines changed

GPU/GPUTracking/Merger/GPUTPCGMMergerTypes.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ enum attachTypes { attachProtect = 0x80000000,
3434
struct InterpolationErrorHit {
3535
float posY, posZ;
3636
GPUCA_PAR_MERGER_INTERPOLATION_ERROR_TYPE_A errorY, errorZ;
37+
bool isValid() const { return errorY >= (GPUCA_PAR_MERGER_INTERPOLATION_ERROR_TYPE_A)0; }
38+
void markInvalid() { errorY = (GPUCA_PAR_MERGER_INTERPOLATION_ERROR_TYPE_A)-1; }
3739
};
3840

3941
struct InterpolationErrors {
40-
InterpolationErrorHit hit[GPUCA_MERGER_MAX_TRACK_CLUSTERS];
4142
static constexpr size_t size = GPUCA_MERGER_MAX_TRACK_CLUSTERS;
43+
InterpolationErrorHit hit[size];
4244
};
4345

4446
struct GPUResolveSharedMemory : public GPUKernelTemplate::GPUSharedMemoryScan64<int16_t, GPUCA_GET_THREAD_COUNT(GPUCA_LB_GPUTPCGMMergerResolve_step3)> {

GPU/GPUTracking/Merger/GPUTPCGMTrackParam.cxx

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger& GPUrestrict() merger, int32_
6767
prop.SetPolynomialField(&param.polynomialField);
6868
prop.SetMaxSinPhi(maxSinPhi);
6969
if (param.rec.tpc.mergerInterpolateErrors && !rebuilt) {
70-
for (uint32_t i = 0; i < interpolation.size; i++) { // TODO: Tune the zeroing size
71-
interpolation.hit[i].errorY = -1;
70+
for (uint32_t i = 0; i < interpolation.size; i++) { // TODO: Tune the zeroing range
71+
interpolation.hit[i].markInvalid();
7272
}
7373
if (param.rec.tpc.rebuildTrackInFit) {
74-
merger.TrackRebuildHelper()[iTrk].highInclRowLow = 255;
75-
merger.TrackRebuildHelper()[iTrk].highInclRowHigh = 255;
74+
merger.TrackRebuildHelper()[iTrk].highInclRowLow = merger.TrackRebuildHelper()[iTrk].highInclRowHigh = 255;
7675
}
7776
}
7877

@@ -140,22 +139,24 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger& GPUrestrict() merger, int32_
140139
CADEBUG(printf("\tHit %3d/%3d Row %3d: Cluster Alpha %8.3f %3d, X %8.3f - Y %8.3f, Z %8.3f (Missed %d)\n", ihit, maxN, (int32_t)clusters[ihit].row, clAlpha, (int32_t)clusters[ihit].sector, xx, yy, zz, nMissed));
141140

142141
uint8_t dEdxSubThresholdRow = 255;
143-
bool doInterpolate = param.rec.tpc.rebuildTrackInFit && (iWay == nWays - 3 || iWay == nWays - 2);
144142
if (lastPropagateRow != 255 && CAMath::Abs(cluster.row - lastPropagateRow) > 1) {
145-
bool dodEdx = param.dodEdxEnabled && param.rec.tpc.adddEdxSubThresholdClusters && finalFit && CAMath::Abs(cluster.row - lastUpdateRow) == 2 && cluster.sector == lastSector && currentClusterStatus == 0;
146-
bool doAttach = allowChangeClusters && !param.rec.tpc.rebuildTrackInFit && !(merger.Param().rec.tpc.disableRefitAttachment & 2);
147-
if (dodEdx || doAttach || doInterpolate) {
143+
const bool dodEdx = param.dodEdxEnabled && param.rec.tpc.adddEdxSubThresholdClusters && finalFit && CAMath::Abs(cluster.row - lastUpdateRow) == 2 && cluster.sector == lastSector && currentClusterStatus == 0;
144+
const bool doAttach = allowChangeClusters && !param.rec.tpc.rebuildTrackInFit && !(merger.Param().rec.tpc.disableRefitAttachment & 2);
145+
const uint8_t doInterpolate = (param.rec.tpc.rebuildTrackInFit && iWay == nWays - 3) ? 1 : ((param.rec.tpc.rebuildTrackInFit && iWay == nWays - 2) ? 2 : 0);
146+
if (lastUpdateRow != 255 && ( dodEdx || doAttach || doInterpolate)) {
148147
int32_t step = cluster.row > lastPropagateRow ? 1 : -1;
149-
for (int32_t iRow = lastPropagateRow + step; iRow != cluster.row; iRow += step) {
148+
uint8_t sector = lastSector;
149+
150+
for (int32_t iRow = lastPropagateRow + step, index = interpolationIndex; iRow != cluster.row; iRow += step, index += wayDirection) {
150151
float tmpX, tmpY, tmpZ;
151-
if (prop.GetPropagatedYZ(mX - GPUTPCGeometry::Row2X(iRow - step) + GPUTPCGeometry::Row2X(iRow), tmpY, tmpZ)) {
152+
if (prop.GetPropagatedYZ(GPUTPCGeometry::Row2X(iRow), tmpY, tmpZ)) {
152153
break;
153154
}
154-
merger.GetConstantMem()->calibObjects.fastTransformHelper->InverseTransformYZtoX(cluster.sector, iRow, tmpY, tmpZ, tmpX);
155+
merger.GetConstantMem()->calibObjects.fastTransformHelper->InverseTransformYZtoX(sector, iRow, tmpY, tmpZ, tmpX);
155156
if (prop.PropagateToXAlpha(tmpX, prop.GetAlpha(), inFlyDirection)) {
156157
break;
157158
}
158-
FitAddRow(iRow, cluster.sector, iTrk, track, prop, inFlyDirection, merger, &dEdxSubThresholdRow, dodEdx, doAttach, doInterpolate);
159+
FitAddRow(iRow, sector, iTrk, track, prop, inFlyDirection, merger, &dEdxSubThresholdRow, dodEdx, doAttach, doInterpolate, interpolation.hit[index], deltaZ, sumInvSqrtCharge, nAvgCharge);
159160
}
160161
}
161162
interpolationIndex += (CAMath::Abs(cluster.row - lastPropagateRow) - 1) * wayDirection;
@@ -239,6 +240,7 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger& GPUrestrict() merger, int32_
239240
merger.TrackRebuildHelper()[iTrk].highInclRowHigh = cluster.row;
240241
}
241242
}
243+
// TODO: We can perhaps break here, if we pick up remaining rows
242244
}
243245
continue;
244246
}
@@ -304,7 +306,7 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger& GPUrestrict() merger, int32_
304306
return true;
305307
}
306308

307-
GPUdii() void GPUTPCGMTrackParam::FitAddRow(const int32_t iRow, const uint8_t sector, const int32_t iTrk, const GPUTPCGMMergedTrack& GPUrestrict() track, GPUTPCGMPropagator& GPUrestrict() prop, const bool inFlyDirection, GPUTPCGMMerger& GPUrestrict() merger, uint8_t* GPUrestrict() dEdxSubThresholdRow, const bool dodEdx, const bool doAttach, const bool doInterpolate)
309+
GPUdii() void GPUTPCGMTrackParam::FitAddRow(const int32_t iRow, const uint8_t sector, const int32_t iTrk, const GPUTPCGMMergedTrack& GPUrestrict() track, GPUTPCGMPropagator& GPUrestrict() prop, const bool inFlyDirection, GPUTPCGMMerger& GPUrestrict() merger, uint8_t* GPUrestrict() dEdxSubThresholdRow, const bool dodEdx, const bool doAttach, const uint8_t doInterpolate, gputpcgmmergertypes::InterpolationErrorHit& GPUrestrict() inter, const float deltaZ, const float sumInvSqrtCharge, const int32_t nAvgCharge)
308310
{
309311
if (CAMath::Abs(mP[2]) > GPUCA_MAX_SIN_PHI || CAMath::Abs(mP[0]) > CAMath::Abs(mX) * CAMath::Tan(GPUTPCGeometry::kSectAngle() / 2.f)) {
310312
return;
@@ -323,6 +325,16 @@ GPUdii() void GPUTPCGMTrackParam::FitAddRow(const int32_t iRow, const uint8_t se
323325
if (doAttach) {
324326
AttachClusters(merger, sector, iRow, iTrk, track.Leg() == 0, prop);
325327
}
328+
if (doInterpolate) {
329+
if (doInterpolate == 2) {
330+
if (inter.isValid() && CAMath::Abs(inter.posY - mP[0]) < 4.f) {
331+
inter.markInvalid();
332+
}
333+
FindBestInterpolatedHit(merger, inter, sector, iRow, deltaZ, sumInvSqrtCharge, nAvgCharge, prop, iTrk, false);
334+
} else {
335+
prop.InterpolateFill(&inter);
336+
}
337+
}
326338
}
327339

328340
GPUdii() void GPUTPCGMTrackParam::HandleCrossCE(const GPUParam& GPUrestrict() param, const uint8_t sector, const uint8_t& lastSector)
@@ -369,10 +381,10 @@ GPUdii() int32_t GPUTPCGMTrackParam::FitHit(GPUTPCGMMerger& GPUrestrict() merger
369381
if (param.rec.tpc.mergerInterpolateErrors) {
370382
if (iWay == nWays - 2) {
371383
if (!param.rec.tpc.rebuildTrackInFit) {
372-
if (inter.errorY < (GPUCA_PAR_MERGER_INTERPOLATION_ERROR_TYPE_A)0) {
373-
rejectChi2 = true;
374-
} else {
384+
if (inter.isValid()) {
375385
retValInt = prop.InterpolateReject(param, yy, zz, clusterState, &inter, err2Y, err2Z, deltaZ);
386+
} else {
387+
rejectChi2 = true;
376388
}
377389
}
378390
} else if (iWay == nWays - 1) {
@@ -435,7 +447,7 @@ GPUdii() float GPUTPCGMTrackParam::FindBestInterpolatedHit(GPUTPCGMMerger& GPUre
435447
GPUglobalref() const cahit2* hits = tracker.HitData(rowData);
436448
GPUglobalref() const calink* firsthit = tracker.FirstHitInBin(rowData);
437449
float uncorrectedY = -1e6f, uncorrectedZ;
438-
if (rowData.NHits() && (inter.errorY >= (GPUCA_PAR_MERGER_INTERPOLATION_ERROR_TYPE_A)0 || (!interOnly && param.rec.tpc.rebuildTrackMaxNonIntCov > 0 && mC[0] < param.rec.tpc.rebuildTrackMaxNonIntCov && mC[2] < param.rec.tpc.rebuildTrackMaxNonIntCov))) {
450+
if (rowData.NHits() && (inter.isValid() || (!interOnly && param.rec.tpc.rebuildTrackMaxNonIntCov > 0 && mC[0] < param.rec.tpc.rebuildTrackMaxNonIntCov && mC[2] < param.rec.tpc.rebuildTrackMaxNonIntCov))) {
439451
const float zOffset = param.par.continuousTracking ? merger.GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(sector, mTOffset, param.continuousMaxTimeBin) : 0;
440452
const float y0 = rowData.Grid().YMin();
441453
const float stepY = rowData.HstepY();
@@ -449,7 +461,7 @@ GPUdii() float GPUTPCGMTrackParam::FindBestInterpolatedHit(GPUTPCGMMerger& GPUre
449461
ImP1 = (float)inter.posZ + deltaZ;
450462
ImC0 = (float)inter.errorY;
451463
ImC2 = (float)inter.errorZ;
452-
} else if (inter.errorY >= (GPUCA_PAR_MERGER_INTERPOLATION_ERROR_TYPE_A)0) {
464+
} else if (inter.isValid()) {
453465
const float Iz0 = (float)inter.posY - mP[0];
454466
const float Iz1 = (float)inter.posZ + deltaZ - mP[1];
455467
const float Iw0 = 1.f / (mC[0] + (float)inter.errorY);
@@ -526,7 +538,7 @@ GPUdii() float GPUTPCGMTrackParam::FindBestInterpolatedHit(GPUTPCGMMerger& GPUre
526538
if (insert < param.rec.tpc.rebuildTrackInFitClusterCandidates) {
527539
for (int32_t c = CAMath::Min(nCandidates, param.rec.tpc.rebuildTrackInFitClusterCandidates - 1); c > insert; c--) {
528540
merger.ClusterCandidates()[(iTrk * GPUCA_ROW_COUNT + row) * param.rec.tpc.rebuildTrackInFitClusterCandidates + c] = merger.ClusterCandidates()[(iTrk * GPUCA_ROW_COUNT + row) * param.rec.tpc.rebuildTrackInFitClusterCandidates + c - 1];
529-
}
541+
} // TODO: Downweight non-interpolated candidates
530542
merger.ClusterCandidates()[(iTrk * GPUCA_ROW_COUNT + row) * param.rec.tpc.rebuildTrackInFitClusterCandidates + insert] = {.id = (uint32_t)(idOffset + ids[ih] + 2), .row = row, .sector = sector, .error = err, .weight = 0, .best = 0};
531543
nCandidates += (nCandidates < param.rec.tpc.rebuildTrackInFitClusterCandidates);
532544
}

GPU/GPUTracking/Merger/GPUTPCGMTrackParam.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class GPUTPCGMTrackParam
157157
GPUd() bool Fit(GPUTPCGMMerger& merger, int32_t iTrk, int32_t& N, int32_t& NTolerated, float& Alpha, GPUTPCGMMergedTrack& track, bool rebuilt);
158158
GPUd() void DodEdx(GPUdEdx& dEdx, GPUdEdx& dEdxAlt, GPUTPCGMMerger& merger, bool finalFit, int ihit, int ihitMergeFirst, int wayDirection, const GPUTPCGMMergedTrackHit* clusters, uint8_t clusterState, float zz, uint8_t dEdxSubThresholdRow);
159159
GPUd() int32_t FitHit(GPUTPCGMMerger& merger, const int32_t iTrk, const GPUTPCGMMergedTrack& track, const float xx, const float yy, const float zz, const uint8_t clusterState, const float clAlpha, const int32_t iWay, const bool inFlyDirection, float& deltaZ, float& lastUpdateX, GPUTPCGMMergedTrackHit* clusters, GPUTPCGMPropagator& prop, gputpcgmmergertypes::InterpolationErrorHit& inter, GPUdEdx& dEdx, GPUdEdx& dEdxAlt, float& sumInvSqrtCharge, int32_t& nAvgCharge, const int32_t ihit, const int32_t ihitMergeFirst, const bool allowChangeClusters, const bool refit, const bool finalFit, int32_t& nMissed, int32_t& nMissed2, int32_t& resetT0, float uncorrectedY);
160-
GPUd() void FitAddRow(const int32_t iRow, const uint8_t sector, const int32_t iTrk, const GPUTPCGMMergedTrack& track, GPUTPCGMPropagator& prop, const bool inFlyDirection, GPUTPCGMMerger& merger, uint8_t* dEdxSubThresholdRow, const bool dodEdx, const bool doAttach, const bool doInterpolate);
160+
GPUd() void FitAddRow(const int32_t iRow, const uint8_t sector, const int32_t iTrk, const GPUTPCGMMergedTrack& track, GPUTPCGMPropagator& prop, const bool inFlyDirection, GPUTPCGMMerger& merger, uint8_t* dEdxSubThresholdRow, const bool dodEdx, const bool doAttach, const uint8_t doInterpolate, gputpcgmmergertypes::InterpolationErrorHit& inter, const float deltaZ, const float sumInvSqrtCharge, const int32_t nAvgCharge);
161161
GPUd() void HandleCrossCE(const GPUParam& param, const uint8_t sector, const uint8_t& lastSector);
162162
GPUd() static void RefitTrack(GPUTPCGMMergedTrack& track, int32_t iTrk, GPUTPCGMMerger& merger, bool rebuilt);
163163
GPUd() void MoveToReference(GPUTPCGMPropagator& prop, const GPUParam& param, float& alpha);

0 commit comments

Comments
 (0)