Skip to content

Commit fcdecb0

Browse files
committed
GPU TPC: Fix deltaTimeFwd/deltaTimeBwd after track rebuild
1 parent 8c95b22 commit fcdecb0

3 files changed

Lines changed: 31 additions & 23 deletions

File tree

‎GPU/GPUTracking/Merger/GPUTPCGMO2Output.cxx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,11 @@ GPUdii() void GPUTPCGMO2Output::Thread<GPUTPCGMO2Output::output>(int32_t nBlocks
215215

216216
if (track.PrevSegment() >= 0) {
217217
const GPUTPCGMMergedTrack* chkTrk = track.GetFirstSegment(tracks, merger.Param().rec.enableCyclicGraphWorkarounds);
218-
const auto& firstPrevCluster = trackClusters[chkTrk->FirstClusterRef()];
219-
t1 = clusters->clustersLinear[firstPrevCluster.num].getTime();
220-
sector1 = firstPrevCluster.sector;
218+
if (chkTrk->NClusters()) { // First segment can have lost all its clusters in the rebuild, then its cluster reference is invalid
219+
const auto& firstPrevCluster = trackClusters[chkTrk->FirstClusterRef()];
220+
t1 = clusters->clustersLinear[firstPrevCluster.num].getTime();
221+
sector1 = firstPrevCluster.sector;
222+
}
221223
}
222224

223225
bool cce = track.CCE() && ((sector1 < MAXSECTOR / 2) ^ (sector2 < MAXSECTOR / 2));

‎GPU/GPUTracking/Merger/GPUTPCGMTrackParam.cxx‎

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger& GPUrestrict() merger, int32_
8181

8282
const int32_t nWays = param.rec.tpc.nWays;
8383
const int32_t maxN = N;
84+
if (rebuilt && maxN > 0 && param.par.continuousTracking && !track.CCE() && !track.Looper()) { // The rebuilt track can have other first / last clusters than the track the Z shift was computed for
85+
const float t0 = merger.GetConstantMem()->ioPtrs.clustersNative->clustersLinear[clusters[0].num].getTime(), tN = merger.GetConstantMem()->ioPtrs.clustersNative->clustersLinear[clusters[maxN - 1].num].getTime();
86+
ConstrainZ(merger, clusters[0].sector, CAMath::Max(t0, tN), CAMath::Min(t0, tN));
87+
}
8488
int32_t ihitStart = 0;
8589
int32_t interpolatedStart = 0;
8690
float covYYUpd = 0.f;
@@ -1327,28 +1331,29 @@ GPUd() float GPUTPCGMTrackParam::ShiftZ(const GPUTPCGMMerger& GPUrestrict() merg
13271331
merger.GetConstantMem()->calibObjects.fastTransform->TransformIdealZ(sector, cltmax, basez, mTOffset);
13281332
deltaZ = basez - refZ;
13291333
}
1330-
{
1331-
float deltaT = merger.GetConstantMem()->calibObjects.fastTransform->convDeltaZtoDeltaTimeInTimeFrame(sector, deltaZ);
1334+
mTOffset += merger.GetConstantMem()->calibObjects.fastTransform->convDeltaZtoDeltaTimeInTimeFrame(sector, deltaZ);
1335+
return -ConstrainZ(merger, sector, cltmax, cltmin, deltaZ);
1336+
}
1337+
1338+
GPUd() float GPUTPCGMTrackParam::ConstrainZ(const GPUTPCGMMerger& GPUrestrict() merger, uint32_t sector, float cltmax, float cltmin, float deltaZ)
1339+
{
1340+
const float maxT = cltmin - merger.GetConstantMem()->calibObjects.fastTransform->getT0();
1341+
const float minT = cltmax - merger.GetConstantMem()->calibObjects.fastTransform->getMaxDriftTime(sector);
1342+
// printf("T Check: Clusters %f %f, min %f max %f vtx %f\n", tz1, tz2, minT, maxT, mTOffset);
1343+
float deltaT = 0.f;
1344+
if (mTOffset < minT) {
1345+
deltaT = minT - mTOffset;
1346+
}
1347+
if (mTOffset + deltaT > maxT) {
1348+
deltaT = maxT - mTOffset;
1349+
}
1350+
if (deltaT != 0.f) {
1351+
deltaZ += merger.GetConstantMem()->calibObjects.fastTransform->convDeltaTimeToDeltaZinTimeFrame(sector, deltaT);
1352+
// printf("Moving clusters to TPC Range: QPt %f, New mTOffset %f, t1 %f, t2 %f, Shift %f in Z: %f to %f --> %f to %f in T\n", mP[4], mTOffset + deltaT, tz1, tz2, deltaZ, tz2 - mTOffset, tz1 - mTOffset, tz2 - mTOffset - deltaT, tz1 - mTOffset - deltaT);
13321353
mTOffset += deltaT;
1333-
const float maxT = cltmin - merger.GetConstantMem()->calibObjects.fastTransform->getT0();
1334-
const float minT = cltmax - merger.GetConstantMem()->calibObjects.fastTransform->getMaxDriftTime(sector);
1335-
// printf("T Check: Clusters %f %f, min %f max %f vtx %f\n", tz1, tz2, minT, maxT, mTOffset);
1336-
deltaT = 0.f;
1337-
if (mTOffset < minT) {
1338-
deltaT = minT - mTOffset;
1339-
}
1340-
if (mTOffset + deltaT > maxT) {
1341-
deltaT = maxT - mTOffset;
1342-
}
1343-
if (deltaT != 0.f) {
1344-
deltaZ += merger.GetConstantMem()->calibObjects.fastTransform->convDeltaTimeToDeltaZinTimeFrame(sector, deltaT);
1345-
// printf("Moving clusters to TPC Range: QPt %f, New mTOffset %f, t1 %f, t2 %f, Shift %f in Z: %f to %f --> %f to %f in T\n", mP[4], mTOffset + deltaT, tz1, tz2, deltaZ, tz2 - mTOffset, tz1 - mTOffset, tz2 - mTOffset - deltaT, tz1 - mTOffset - deltaT);
1346-
mTOffset += deltaT;
1347-
}
1348-
mP[1] -= deltaZ;
13491354
}
1350-
// printf("\n");
1351-
return -deltaZ;
1355+
mP[1] -= deltaZ;
1356+
return deltaZ;
13521357
}
13531358

13541359
GPUd() bool GPUTPCGMTrackParam::CheckCov() const

‎GPU/GPUTracking/Merger/GPUTPCGMTrackParam.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ class GPUTPCGMTrackParam
203203
GPUd() void Rotate(float alpha);
204204
GPUd() float ShiftZ(const GPUTPCGMMerger& merger, uint32_t sector, float cltmax, float cltmin, float clx);
205205
GPUd() float ShiftZ(const GPUTPCGMMergedTrackHit* clusters, const GPUTPCGMMerger& merger, int32_t N);
206+
GPUd() float ConstrainZ(const GPUTPCGMMerger& merger, uint32_t sector, float cltmax, float cltmin, float deltaZ = 0.f); // Shift Z / TOffset such that the clusters are within the TPC drift volume, applies in addition the pending shift deltaZ to Z, returns the total shift
206207

207208
GPUd() static float Reciprocal(float x) { return 1.f / x; }
208209
GPUdi() static void Assign(float& x, bool mask, float v)

0 commit comments

Comments
 (0)