Skip to content

Commit 7c4eedb

Browse files
cbmswdavidrohr
authored andcommitted
TPC Splines: bugfix in ZOffset
1 parent 4408af2 commit 7c4eedb

File tree

6 files changed

+29
-20
lines changed

6 files changed

+29
-20
lines changed

GPU/GPUTracking/Merger/GPUTPCGMMerger.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ GPUd() int32_t GPUTPCGMMerger::RefitSectorTrack(GPUTPCGMSectorTrack& sectorTrack
564564
trk.SinPhi() = inTrack->Param().GetSinPhi();
565565
trk.DzDs() = inTrack->Param().GetDzDs();
566566
trk.QPt() = inTrack->Param().GetQPt();
567-
trk.TOffset() = Param().par.continuousTracking ? GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convZOffsetToVertexTime(inTrack->Param().GetZOffset(), Param().continuousMaxTimeBin) : 0;
567+
trk.TOffset() = Param().par.continuousTracking ? GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convZOffsetToVertexTime(sector, inTrack->Param().GetZOffset(), Param().continuousMaxTimeBin) : 0;
568568
const auto tmp = sectorTrack.ClusterTN() > sectorTrack.ClusterT0() ? std::array<float, 2>{sectorTrack.ClusterTN(), sectorTrack.ClusterT0()} : std::array<float, 2>{sectorTrack.ClusterT0(), sectorTrack.ClusterTN()};
569569
trk.ShiftZ(this, sector, tmp[0], tmp[1], inTrack->Param().GetX()); // We do not store the inner / outer cluster X, so we just use the track X instead
570570
sectorTrack.SetX2(0.f);
@@ -1950,7 +1950,8 @@ GPUd() void GPUTPCGMMerger::MergeLoopersInit(int32_t nBlocks, int32_t nThreads,
19501950
const auto& p = trk.GetParam();
19511951
const float qptabs = CAMath::Abs(p.GetQPt());
19521952
if (trk.OK() && trk.NClusters() && trk.Leg() == 0 && qptabs * Param().qptB5Scaler > 5.f && qptabs * Param().qptB5Scaler <= lowPtThresh) {
1953-
const float refz = p.GetZ() + (Param().par.continuousTracking ? GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(p.GetTOffset(), Param().continuousMaxTimeBin) : 0) + (trk.CSide() ? -100 : 100);
1953+
const int32_t sector = mClusters[trk.FirstClusterRef() + trk.NClusters() - 1].sector;
1954+
const float refz = p.GetZ() + (Param().par.continuousTracking ? GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(sector, p.GetTOffset(), Param().continuousMaxTimeBin) : 0) + (trk.CSide() ? -100 : 100);
19541955
float sinA, cosA;
19551956
CAMath::SinCos(trk.GetAlpha(), sinA, cosA);
19561957
float gx = cosA * p.GetX() - sinA * p.GetY();

GPU/GPUTracking/Merger/GPUTPCGMSectorTrack.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ GPUd() void GPUTPCGMSectorTrack::Set(const GPUTPCGMMerger* merger, const GPUTPCT
3737
mParam.mSecPhi = 1.f / mParam.mCosPhi;
3838
mAlpha = alpha;
3939
mSector = sector;
40-
mTOffset = merger->Param().par.continuousTracking ? merger->GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convZOffsetToVertexTime(t.GetZOffset(), merger->Param().continuousMaxTimeBin) : 0;
40+
mTOffset = merger->Param().par.continuousTracking ? merger->GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convZOffsetToVertexTime(mSector, t.GetZOffset(), merger->Param().continuousMaxTimeBin) : 0;
4141
mNClusters = sectorTr->NHits();
4242
}
4343

@@ -323,7 +323,7 @@ GPUd() bool GPUTPCGMSectorTrack::TransportToX(GPUTPCGMMerger* merger, float x, f
323323
b.SetPar(2, ey1);
324324
b.SetPar(3, param.mDzDs);
325325
b.SetPar(4, param.mQPt);
326-
b.SetZOffsetLinear(merger->Param().par.continuousTracking ? merger->GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(mTOffset, merger->Param().continuousMaxTimeBin) : 0);
326+
b.SetZOffsetLinear(merger->Param().par.continuousTracking ? merger->GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(mSector, mTOffset, merger->Param().continuousMaxTimeBin) : 0);
327327

328328
if (!doCov) {
329329
return (1);
@@ -478,7 +478,7 @@ GPUd() bool GPUTPCGMSectorTrack::TransportToXAlpha(GPUTPCGMMerger* merger, float
478478
b.SetPar(2, ey1);
479479
b.SetPar(3, dzds);
480480
b.SetPar(4, qpt);
481-
b.SetZOffsetLinear(merger->Param().par.continuousTracking ? merger->GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(mTOffset, merger->Param().continuousMaxTimeBin) : 0);
481+
b.SetZOffsetLinear(merger->Param().par.continuousTracking ? merger->GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(mSector, mTOffset, merger->Param().continuousMaxTimeBin) : 0);
482482

483483
b.SetCov(0, c00 + h2 * h2c22 + h4 * h4c44 + 2.f * (h2 * c20ph4c42 + h4 * c40));
484484
b.SetCov(1, c11 + dS * (c31 + n7));

GPU/GPUTracking/Merger/GPUTPCGMTrackParam.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ GPUd() float GPUTPCGMTrackParam::AttachClusters(const GPUTPCGMMerger* GPUrestric
502502
return -1e6f;
503503
}
504504

505-
const float zOffset = param.par.continuousTracking ? Merger->GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(mTOffset, param.continuousMaxTimeBin) : 0; // TODO: do some validatiomns for the transform conv functions...
505+
const float zOffset = param.par.continuousTracking ? Merger->GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(sector, mTOffset, param.continuousMaxTimeBin) : 0; // TODO: do some validatiomns for the transform conv functions...
506506
const float y0 = row.Grid().YMin();
507507
const float stepY = row.HstepY();
508508
const float z0 = row.Grid().ZMin() - zOffset; // We can use our own ZOffset, since this is only used temporarily anyway
@@ -522,7 +522,7 @@ GPUd() float GPUTPCGMTrackParam::AttachClusters(const GPUTPCGMMerger* GPUrestric
522522
const float tubeMinSize2 = protect ? param.rec.tpc.tubeProtectMinSize2 : 0.f;
523523
float tubeSigma2 = protect ? param.rec.tpc.tubeProtectSigma2 : param.rec.tpc.tubeRemoveSigma2;
524524
uint32_t pad = CAMath::Float2UIntRn(GPUTPCGeometry::LinearY2Pad(sector, iRow, uncorrectedY));
525-
float time = Merger->GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->InverseTransformInTimeFrame(sector, uncorrectedZ + (param.par.continuousTracking ? Merger->GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(mTOffset, param.continuousMaxTimeBin) : 0), param.continuousMaxTimeBin); // TODO: Simplify this call in TPCFastTransform
525+
float time = Merger->GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->InverseTransformInTimeFrame(sector, uncorrectedZ + (param.par.continuousTracking ? Merger->GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(sector, mTOffset, param.continuousMaxTimeBin) : 0), param.continuousMaxTimeBin); // TODO: Simplify this call in TPCFastTransform
526526
if (iRow < param.rec.tpc.tubeExtraProtectMinRow ||
527527
pad < param.rec.tpc.tubeExtraProtectEdgePads || pad >= (uint32_t)(GPUTPCGeometry::NPads(iRow) - param.rec.tpc.tubeExtraProtectEdgePads) ||
528528
param.GetUnscaledMult(time) / GPUTPCGeometry::Row2X(iRow) > param.rec.tpc.tubeExtraProtectMinOccupancy) {

GPU/GPUTracking/display/render/GPUDisplayDraw.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -556,12 +556,12 @@ void GPUDisplay::DrawFinal(int32_t iSector, int32_t /*iCol*/, const GPUTPCGMProp
556556
auto cl = mIOPtrs->mergedTrackHits[track->FirstClusterRef() + lastCluster];
557557
const auto& cln = mIOPtrs->clustersNative->clustersLinear[cl.num];
558558
GPUTPCConvertImpl::convert(*mCalib->fastTransform, *mParam, cl.sector, cl.row, cln.getPad(), cln.getTime(), x, y, z);
559-
ZOffset = mCalib->fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(track->GetParam().GetTOffset(), mParam->continuousMaxTimeBin);
559+
ZOffset = mCalib->fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(iSector, track->GetParam().GetTOffset(), mParam->continuousMaxTimeBin);
560560
} else {
561561
uint8_t sector, row;
562562
auto cln = track->getCluster(mIOPtrs->outputClusRefsTPCO2, lastCluster, *mIOPtrs->clustersNative, sector, row);
563563
GPUTPCConvertImpl::convert(*mCalib->fastTransform, *mParam, sector, row, cln.getPad(), cln.getTime(), x, y, z);
564-
ZOffset = mCalib->fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(track->getTime0(), mParam->continuousMaxTimeBin);
564+
ZOffset = mCalib->fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(sector, track->getTime0(), mParam->continuousMaxTimeBin);
565565
}
566566
} else {
567567
const GPUTPCMCInfo& mc = mIOPtrs->mcInfosTPC[i];
@@ -593,7 +593,7 @@ void GPUDisplay::DrawFinal(int32_t iSector, int32_t /*iCol*/, const GPUTPCGMProp
593593
#ifdef GPUCA_TPC_GEOMETRY_O2
594594
trkParam.Set(mclocal[0], mclocal[1], mc.z, mclocal[2], mclocal[3], mc.pZ, -charge); // TODO: DR: unclear to me why we need -charge here
595595
if (mParam->par.continuousTracking) {
596-
ZOffset = fabsf(mCalib->fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(mc.t0, mParam->continuousMaxTimeBin)) * (mc.z < 0 ? -1 : 1);
596+
ZOffset = fabsf(mCalib->fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(0, mc.t0, mParam->continuousMaxTimeBin)) * (mc.z < 0 ? -1 : 1);
597597
}
598598
#else
599599
if (fabsf(mc.z) > GPUTPCGeometry::TPCLength()) {

GPU/GPUTracking/display/render/GPUDisplayImportEvent.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ void GPUDisplay::DrawGLScene_updateEventData()
180180
while (mParam->par.continuousTracking && trdTriggerRecord < (int32_t)mIOPtrs->nTRDTriggerRecords - 1 && mIOPtrs->trdTrackletIdxFirst[trdTriggerRecord + 1] <= i) {
181181
trdTriggerRecord++; // This requires to go through the data in order I believe
182182
float trdTime = mIOPtrs->trdTriggerTimes[trdTriggerRecord] * 1e3 / o2::constants::lhc::LHCBunchSpacingNS / o2::tpc::constants::LHCBCPERTIMEBIN;
183-
trdZoffset = fabsf(mCalib->fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(trdTime, mParam->continuousMaxTimeBin));
183+
trdZoffset = fabsf(mCalib->fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(0, trdTime, mParam->continuousMaxTimeBin));
184184
}
185185
const auto& sp = mIOPtrs->trdSpacePoints[i];
186186
int32_t iSec = trdGeometry()->GetSector(mIOPtrs->trdTracklets[i].GetDetector());
@@ -218,7 +218,7 @@ void GPUDisplay::DrawGLScene_updateEventData()
218218
float ZOffset = 0;
219219
if (mParam->par.continuousTracking) {
220220
float tofTime = mIOPtrs->tofClusters[i].getTime() * 1e-3 / o2::constants::lhc::LHCBunchSpacingNS / o2::tpc::constants::LHCBCPERTIMEBIN;
221-
ZOffset = fabsf(mCalib->fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(tofTime, mParam->continuousMaxTimeBin));
221+
ZOffset = fabsf(mCalib->fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(0, tofTime, mParam->continuousMaxTimeBin));
222222
ptr->z += ptr->z > 0 ? ZOffset : -ZOffset;
223223
}
224224
if (fabsf(ptr->z) > maxClusterZ) {
@@ -249,7 +249,7 @@ void GPUDisplay::DrawGLScene_updateEventData()
249249
if (mParam->par.continuousTracking) {
250250
o2::InteractionRecord startIR = o2::InteractionRecord(0, mIOPtrs->settingsTF && mIOPtrs->settingsTF->hasTfStartOrbit ? mIOPtrs->settingsTF->tfStartOrbit : 0);
251251
float itsROFtime = mIOPtrs->itsClusterROF[j].getBCData().differenceInBC(startIR) / (float)o2::tpc::constants::LHCBCPERTIMEBIN;
252-
ZOffset = fabsf(mCalib->fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(itsROFtime + itsROFhalfLen, mParam->continuousMaxTimeBin));
252+
ZOffset = fabsf(mCalib->fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(0, itsROFtime + itsROFhalfLen, mParam->continuousMaxTimeBin));
253253
}
254254
if (i != mIOPtrs->itsClusterROF[j].getFirstEntry()) {
255255
throw std::runtime_error("Inconsistent ITS data, number of clusters does not match ROF content");

GPU/TPCFastTransformation/TPCFastTransform.h

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class TPCFastTransform : public FlatObject
194194

195195
/// Inverse transformation
196196
GPUd() void InverseTransformInTimeFrame(int32_t sector, int32_t row, float /*x*/, float y, float z, float& pad, float& time, float maxTimeBin) const;
197-
GPUd() float InverseTransformInTimeFrame(int32_t roc, float z, float maxTimeBin) const;
197+
GPUd() float InverseTransformInTimeFrame(int32_t sector, float z, float maxTimeBin) const;
198198

199199
/// Inverse transformation: Transformed Y and Z -> transformed X
200200
GPUd() void InverseTransformYZtoX(int32_t sector, int32_t row, float y, float z, float& x, const TPCFastTransform* ref = nullptr, const TPCFastTransform* ref2 = nullptr, float scale = 0.f, float scale2 = 0.f, int32_t scaleMode = 0) const;
@@ -220,8 +220,8 @@ class TPCFastTransform : public FlatObject
220220
GPUd() float convDeltaTimeToDeltaZinTimeFrame(int32_t sector, float deltaTime) const;
221221
GPUd() float convDeltaZtoDeltaTimeInTimeFrame(int32_t sector, float deltaZ) const;
222222
GPUd() float convDeltaZtoDeltaTimeInTimeFrameAbs(float deltaZ) const;
223-
GPUd() float convZOffsetToVertexTime(float zOffset, float maxTimeBin) const;
224-
GPUd() float convVertexTimeToZOffset(float vertexTime, float maxTimeBin) const;
223+
GPUd() float convZOffsetToVertexTime(int32_t sector, float zOffset, float maxTimeBin) const;
224+
GPUd() float convVertexTimeToZOffset(int32_t sector, float vertexTime, float maxTimeBin) const;
225225

226226
void setApplyCorrectionOn() { mApplyCorrection = 1; }
227227
void setApplyCorrectionOff() { mApplyCorrection = 0; }
@@ -364,14 +364,22 @@ GPUdi() void TPCFastTransform::convPadTimeToLocalInTimeFrame(int32_t sector, int
364364

365365
// ----------------------------------------------------------------------
366366

367-
GPUdi() float TPCFastTransform::convZOffsetToVertexTime(float zOffset, float maxTimeBin) const
367+
GPUdi() float TPCFastTransform::convZOffsetToVertexTime(int32_t sector, float zOffset, float maxTimeBin) const
368368
{
369-
return maxTimeBin - (getGeometry().getTPCzLength() + zOffset) / mVdrift;
369+
if (sector < getGeometry().getNumberOfSectorsA()) {
370+
return maxTimeBin - (getGeometry().getTPCzLength() + zOffset) / mVdrift;
371+
} else {
372+
return maxTimeBin - (getGeometry().getTPCzLength() - zOffset) / mVdrift;
373+
}
370374
}
371375

372-
GPUdi() float TPCFastTransform::convVertexTimeToZOffset(float vertexTime, float maxTimeBin) const
376+
GPUdi() float TPCFastTransform::convVertexTimeToZOffset(int32_t sector, float vertexTime, float maxTimeBin) const
373377
{
374-
return (maxTimeBin - vertexTime) * mVdrift - getGeometry().getTPCzLength();
378+
if (sector < getGeometry().getNumberOfSectorsA()) {
379+
return (maxTimeBin - vertexTime) * mVdrift - getGeometry().getTPCzLength();
380+
} else {
381+
return -((maxTimeBin - vertexTime) * mVdrift - getGeometry().getTPCzLength());
382+
}
375383
}
376384

377385
GPUdi() float TPCFastTransform::convDriftLengthToTime(float driftLength, float vertexTime) const

0 commit comments

Comments
 (0)