Skip to content

Commit 73d4d71

Browse files
davidrohrcbmsw
authored andcommitted
TPCFastTransform: fix compilation on GPU with the new splines
1 parent 2a4f577 commit 73d4d71

File tree

5 files changed

+80
-69
lines changed

5 files changed

+80
-69
lines changed

GPU/GPUTracking/Merger/GPUTPCGMMerger.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1938,7 +1938,6 @@ GPUd() void GPUTPCGMMerger::MergeLoopersInit(int32_t nBlocks, int32_t nThreads,
19381938
const auto& p = trk.GetParam();
19391939
const float qptabs = CAMath::Abs(p.GetQPt());
19401940
if (trk.OK() && trk.NClusters() && trk.Leg() == 0 && qptabs * Param().qptB5Scaler > 5.f && qptabs * Param().qptB5Scaler <= lowPtThresh) {
1941-
const int32_t sector = mClusters[trk.FirstClusterRef() + trk.NClusters() - 1].sector;
19421941
const float refz = p.GetZ() + GetConstantMem()->calibObjects.fastTransformHelper->getCorrMap()->convVertexTimeToZOffset(p.GetTOffset(), Param().continuousMaxTimeBin) + (trk.CSide() ? -100 : 100);
19431942
float sinA, cosA;
19441943
CAMath::SinCos(trk.GetAlpha(), sinA, cosA);

GPU/TPCFastTransformation/Spline1DSpec.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,11 @@ class Spline1DSpec<DataT, YdimT, 0> : public Spline1DContainer<DataT>
314314
const auto nYdimTmp = SplineUtil::getNdim<YdimT>(inpYdim);
315315
const auto nYdim = nYdimTmp.get();
316316

317-
auto [dSdSl, dSdDl, dSdSr, dSdDr] = getSderivativesOverParsAtU<T>(knotL, u);
317+
auto val = getSderivativesOverParsAtU<T>(knotL, u);
318+
const auto& dSdSl = val[0];
319+
const auto& dSdDl = val[1];
320+
const auto& dSdSr = val[2];
321+
const auto& dSdDr = val[3];
318322
for (int32_t dim = 0; dim < nYdim; ++dim) {
319323
S[dim] = dSdSr * Sr[dim] + dSdSl * Sl[dim] + dSdDl * Dl[dim] + dSdDr * Dr[dim];
320324
}

GPU/TPCFastTransformation/Spline2DSpec.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,16 @@ class Spline2DSpec<DataT, YdimT, 0>
334334
const DataT* A = Parameters + (nu * iv + iu) * nYdim4; // values { {Y1,Y2,Y3}, {Y1,Y2,Y3}'v, {Y1,Y2,Y3}'u, {Y1,Y2,Y3}''vu } at {u0, v0}
335335
const DataT* B = A + nYdim4 * nu; // values { ... } at {u0, v1}
336336

337-
auto [dSl, dDl, dSr, dDr] = mGridX1.template getSderivativesOverParsAtU<DataT>(knotU, u);
338-
auto [dSd, dDd, dSu, dDu] = mGridX2.template getSderivativesOverParsAtU<DataT>(knotV, v);
337+
auto val1 = mGridX1.template getSderivativesOverParsAtU<DataT>(knotU, u);
338+
auto val2 = mGridX2.template getSderivativesOverParsAtU<DataT>(knotV, v);
339+
const auto& dSl = val1[0];
340+
const auto& dDl = val1[1];
341+
const auto& dSr = val1[2];
342+
const auto& dDr = val1[3];
343+
const auto& dSd = val2[0];
344+
const auto& dDd = val2[1];
345+
const auto& dSu = val2[2];
346+
const auto& dDu = val2[3];
339347

340348
// when nYdim == 1:
341349
// S = dSl * (dSd * A[0] + dDd * A[1]) + dDl * (dSd * A[2] + dDd * A[3]) +

GPU/TPCFastTransformation/TPCFastSpaceChargeCorrection.h

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -56,29 +56,29 @@ class TPCFastSpaceChargeCorrection : public FlatObject
5656
float splineScalingWithZ{0.f}; ///< spline scaling factor in the Z region between the zOut and the readout plane
5757

5858
public:
59-
void set(float y0, float yScale, float z0, float zScale, float zOut, float zReadout)
59+
void set(float y0_, float yScale_, float z0_, float zScale_, float zOut_, float zReadout_)
6060
{
61-
this->y0 = y0;
62-
this->yScale = yScale;
63-
this->z0 = z0;
64-
this->zScale = zScale;
65-
this->zOut = zOut;
61+
this->y0 = y0_;
62+
this->yScale = yScale_;
63+
this->z0 = z0_;
64+
this->zScale = zScale_;
65+
this->zOut = zOut_;
6666
// no scaling when the distance to the readout is too small
67-
this->splineScalingWithZ = fabs(zReadout - zOut) > 1. ? 1. / (zReadout - zOut) : 0.;
67+
this->splineScalingWithZ = fabs(zReadout_ - zOut_) > 1. ? 1. / (zReadout_ - zOut_) : 0.;
6868
}
6969

7070
float getY0() const { return y0; }
7171
float getYscale() const { return yScale; }
7272
float getZ0() const { return z0; }
7373
float getZscale() const { return zScale; }
7474

75-
float getSpineScaleForZ(float z) const
75+
GPUd() float getSpineScaleForZ(float z) const
7676
{
7777
return 1.f - GPUCommonMath::Clamp((z - zOut) * splineScalingWithZ, 0.f, 1.f);
7878
}
7979

8080
/// convert local y, z to internal grid coordinates u,v, and spline scale
81-
std::array<float, 3> convLocalToGridUntruncated(float y, float z) const
81+
GPUd() std::array<float, 3> convLocalToGridUntruncated(float y, float z) const
8282
{
8383
return {(y - y0) * yScale, (z - z0) * zScale, getSpineScaleForZ(z)};
8484
}
@@ -458,21 +458,21 @@ GPUdi() std::array<float, 3> TPCFastSpaceChargeCorrection::convLocalToGrid(int32
458458
/// convert local y, z to internal grid coordinates u,v
459459
/// return values: u, v, scaling factor
460460
const SplineType& spline = getSpline(sector, row);
461-
auto [gridU, gridV, scale] = getSectorRowInfo(sector, row).gridMeasured.convLocalToGridUntruncated(y, z);
461+
auto val = getSectorRowInfo(sector, row).gridMeasured.convLocalToGridUntruncated(y, z);
462462
// shrink to the grid
463-
gridU = GPUCommonMath::Clamp(gridU, 0.f, (float)spline.getGridX1().getUmax());
464-
gridV = GPUCommonMath::Clamp(gridV, 0.f, (float)spline.getGridX2().getUmax());
465-
return {gridU, gridV, scale};
463+
val[0] = GPUCommonMath::Clamp(val[0], 0.f, (float)spline.getGridX1().getUmax());
464+
val[1] = GPUCommonMath::Clamp(val[1], 0.f, (float)spline.getGridX2().getUmax());
465+
return val;
466466
}
467467

468468
GPUdi() bool TPCFastSpaceChargeCorrection::isLocalInsideGrid(int32_t sector, int32_t row, float y, float z) const
469469
{
470470
/// check if local y, z are inside the grid
471-
auto [gridU, gridV, scale] = getSectorRowInfo(sector, row).gridMeasured.convLocalToGridUntruncated(y, z);
471+
auto val = getSectorRowInfo(sector, row).gridMeasured.convLocalToGridUntruncated(y, z);
472472
const auto& spline = getSpline(sector, row);
473473
// shrink to the grid
474-
if (gridU < 0.f || gridU > (float)spline.getGridX1().getUmax() || //
475-
gridV < 0.f || gridV > (float)spline.getGridX2().getUmax()) {
474+
if (val[0] < 0.f || val[0] > (float)spline.getGridX1().getUmax() || //
475+
val[1] < 0.f || val[1] > (float)spline.getGridX2().getUmax()) {
476476
return false;
477477
}
478478
return true;
@@ -481,11 +481,11 @@ GPUdi() bool TPCFastSpaceChargeCorrection::isLocalInsideGrid(int32_t sector, int
481481
GPUdi() bool TPCFastSpaceChargeCorrection::isRealLocalInsideGrid(int32_t sector, int32_t row, float y, float z) const
482482
{
483483
/// check if local y, z are inside the grid
484-
auto [gridU, gridV, scale] = getSectorRowInfo(sector, row).gridReal.convLocalToGridUntruncated(y, z);
484+
auto val = getSectorRowInfo(sector, row).gridReal.convLocalToGridUntruncated(y, z);
485485
const auto& spline = getSpline(sector, row);
486486
// shrink to the grid
487-
if (gridU < 0.f || gridU > (float)spline.getGridX1().getUmax() || //
488-
gridV < 0.f || gridV > (float)spline.getGridX2().getUmax()) {
487+
if (val[0] < 0.f || val[0] > (float)spline.getGridX1().getUmax() || //
488+
val[1] < 0.f || val[1] > (float)spline.getGridX2().getUmax()) {
489489
return false;
490490
}
491491
return true;
@@ -501,11 +501,11 @@ GPUdi() std::array<float, 3> TPCFastSpaceChargeCorrection::convRealLocalToGrid(i
501501
{
502502
/// convert real y, z to the internal grid coordinates + scale
503503
const SplineType& spline = getSpline(sector, row);
504-
auto [gridU, gridV, scale] = getSectorRowInfo(sector, row).gridReal.convLocalToGridUntruncated(y, z);
504+
auto val = getSectorRowInfo(sector, row).gridReal.convLocalToGridUntruncated(y, z);
505505
// shrink to the grid
506-
gridU = GPUCommonMath::Clamp(gridU, 0.f, (float)spline.getGridX1().getUmax());
507-
gridV = GPUCommonMath::Clamp(gridV, 0.f, (float)spline.getGridX2().getUmax());
508-
return {gridU, gridV, scale};
506+
val[0] = GPUCommonMath::Clamp(val[0], 0.f, (float)spline.getGridX1().getUmax());
507+
val[1] = GPUCommonMath::Clamp(val[1], 0.f, (float)spline.getGridX2().getUmax());
508+
return val;
509509
}
510510

511511
GPUdi() std::array<float, 2> TPCFastSpaceChargeCorrection::convGridToRealLocal(int32_t sector, int32_t row, float gridU, float gridV) const
@@ -520,35 +520,35 @@ GPUdi() std::array<float, 3> TPCFastSpaceChargeCorrection::getCorrectionLocal(in
520520
const SplineType& spline = getSpline(sector, row);
521521
const float* splineData = getSplineData(sector, row);
522522

523-
auto [gridU, gridV, scale] = convLocalToGrid(sector, row, y, z);
523+
auto val = convLocalToGrid(sector, row, y, z);
524524

525525
float dxyz[3];
526-
spline.interpolateAtU(splineData, gridU, gridV, dxyz);
526+
spline.interpolateAtU(splineData, val[0], val[1], dxyz);
527527

528-
float dx = scale * GPUCommonMath::Clamp(dxyz[0], info.minCorr[0], info.maxCorr[0]);
529-
float dy = scale * GPUCommonMath::Clamp(dxyz[1], info.minCorr[1], info.maxCorr[1]);
530-
float dz = scale * GPUCommonMath::Clamp(dxyz[2], info.minCorr[2], info.maxCorr[2]);
528+
float dx = val[2] * GPUCommonMath::Clamp(dxyz[0], info.minCorr[0], info.maxCorr[0]);
529+
float dy = val[2] * GPUCommonMath::Clamp(dxyz[1], info.minCorr[1], info.maxCorr[1]);
530+
float dz = val[2] * GPUCommonMath::Clamp(dxyz[2], info.minCorr[2], info.maxCorr[2]);
531531
return {dx, dy, dz};
532532
}
533533

534534
GPUdi() float TPCFastSpaceChargeCorrection::getCorrectionXatRealYZ(int32_t sector, int32_t row, float realY, float realZ) const
535535
{
536536
const auto& info = getSectorRowInfo(sector, row);
537-
auto [gridU, gridV, scale] = convRealLocalToGrid(sector, row, realY, realZ);
537+
auto val = convRealLocalToGrid(sector, row, realY, realZ);
538538
float dx = 0;
539-
getSplineInvX(sector, row).interpolateAtU(getSplineDataInvX(sector, row), gridU, gridV, &dx);
540-
dx = scale * GPUCommonMath::Clamp(dx, info.minCorr[0], info.maxCorr[0]);
539+
getSplineInvX(sector, row).interpolateAtU(getSplineDataInvX(sector, row), val[0], val[1], &dx);
540+
dx = val[2] * GPUCommonMath::Clamp(dx, info.minCorr[0], info.maxCorr[0]);
541541
return dx;
542542
}
543543

544544
GPUdi() std::array<float, 2> TPCFastSpaceChargeCorrection::getCorrectionYZatRealYZ(int32_t sector, int32_t row, float realY, float realZ) const
545545
{
546-
auto [gridU, gridV, scale] = convRealLocalToGrid(sector, row, realY, realZ);
546+
auto val = convRealLocalToGrid(sector, row, realY, realZ);
547547
const auto& info = getSectorRowInfo(sector, row);
548548
float dyz[2];
549-
getSplineInvYZ(sector, row).interpolateAtU(getSplineDataInvYZ(sector, row), gridU, gridV, dyz);
550-
dyz[0] = scale * GPUCommonMath::Clamp(dyz[0], info.minCorr[1], info.maxCorr[1]);
551-
dyz[1] = scale * GPUCommonMath::Clamp(dyz[1], info.minCorr[2], info.maxCorr[2]);
549+
getSplineInvYZ(sector, row).interpolateAtU(getSplineDataInvYZ(sector, row), val[0], val[1], dyz);
550+
dyz[0] = val[2] * GPUCommonMath::Clamp(dyz[0], info.minCorr[1], info.maxCorr[1]);
551+
dyz[1] = val[2] * GPUCommonMath::Clamp(dyz[1], info.minCorr[2], info.maxCorr[2]);
552552
return {dyz[0], dyz[1]};
553553
}
554554

GPU/TPCFastTransformation/TPCFastTransform.h

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -348,17 +348,17 @@ class TPCFastTransform : public FlatObject
348348
GPUdi() void TPCFastTransform::convPadTimeToLocal(int32_t sector, int32_t row, float pad, float time, float& y, float& z, float vertexTime) const
349349
{
350350
float l = (time - mT0 - vertexTime) * mVdrift; // drift length [cm]
351-
const auto local = getGeometry().convPadDriftLengthToLocal(sector, row, pad, l);
352-
y = local[0];
353-
z = local[1];
351+
const auto localval = getGeometry().convPadDriftLengthToLocal(sector, row, pad, l);
352+
y = localval[0];
353+
z = localval[1];
354354
}
355355

356356
GPUdi() void TPCFastTransform::convPadTimeToLocalInTimeFrame(int32_t sector, int32_t row, float pad, float time, float& y, float& z, float maxTimeBin) const
357357
{
358358
float l = (time - mT0 - maxTimeBin) * mVdrift; // drift length [cm]
359-
const auto local = getGeometry().convPadDriftLengthToLocal(sector, row, pad, l);
360-
y = local[0];
361-
z = local[1];
359+
const auto localval = getGeometry().convPadDriftLengthToLocal(sector, row, pad, l);
360+
y = localval[0];
361+
z = localval[1];
362362
}
363363

364364
// ----------------------------------------------------------------------
@@ -423,22 +423,22 @@ GPUdi() void TPCFastTransform::TransformLocal(int32_t sector, int32_t row, float
423423
dz = corrLocal[2];
424424
if (ref) {
425425
if ((scale > 0.f) && (scaleMode == 0)) { // scaling was requested
426-
auto [dxRef, dyRef, dzRef] = ref->mCorrection.getCorrectionLocal(sector, row, y, z);
427-
dx = (dx - dxRef) * scale + dxRef;
428-
dy = (dy - dyRef) * scale + dyRef;
429-
dz = (dz - dzRef) * scale + dzRef;
426+
auto val = ref->mCorrection.getCorrectionLocal(sector, row, y, z);
427+
dx = (dx - val[0]) * scale + val[0];
428+
dy = (dy - val[1]) * scale + val[1];
429+
dz = (dz - val[2]) * scale + val[2];
430430
} else if ((scale != 0.f) && ((scaleMode == 1) || (scaleMode == 2))) {
431-
auto [dxRef, dyRef, dzRef] = ref->mCorrection.getCorrectionLocal(sector, row, y, z);
432-
dx = dxRef * scale + dx;
433-
dy = dyRef * scale + dy;
434-
dz = dzRef * scale + dz;
431+
auto val = ref->mCorrection.getCorrectionLocal(sector, row, y, z);
432+
dx = val[0] * scale + dx;
433+
dy = val[1] * scale + dy;
434+
dz = val[2] * scale + dz;
435435
}
436436
}
437437
if (ref2 && (scale2 != 0)) {
438-
auto [dxRef, dyRef, dzRef] = ref2->mCorrection.getCorrectionLocal(sector, row, y, z);
439-
dx = dxRef * scale2 + dx;
440-
dy = dyRef * scale2 + dy;
441-
dz = dzRef * scale2 + dz;
438+
auto val = ref2->mCorrection.getCorrectionLocal(sector, row, y, z);
439+
dx = val[0] * scale2 + dx;
440+
dy = val[1] * scale2 + dy;
441+
dz = val[2] * scale2 + dz;
442442
}
443443
}
444444
}
@@ -601,9 +601,9 @@ GPUdi() void TPCFastTransform::TransformIdeal(int32_t sector, int32_t row, float
601601

602602
x = getGeometry().getRowInfo(row).x;
603603
float driftLength = (time - mT0 - vertexTime) * mVdrift; // drift length cm
604-
const auto local = getGeometry().convPadDriftLengthToLocal(sector, row, pad, driftLength);
605-
y = local[0];
606-
z = local[1];
604+
const auto localval = getGeometry().convPadDriftLengthToLocal(sector, row, pad, driftLength);
605+
y = localval[0];
606+
z = localval[1];
607607
}
608608

609609
GPUdi() float TPCFastTransform::convTimeToZinTimeFrame(int32_t sector, float time, float maxTimeBin) const
@@ -716,18 +716,18 @@ GPUdi() void TPCFastTransform::InverseTransformYZtoNominalYZ(int32_t sector, int
716716

717717
if (ref) { // scaling was requested
718718
if (scaleMode == 0 && scale > 0.f) {
719-
const auto [dyRef, dzRef] = ref->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ);
720-
dy = (dy - dyRef) * scale + dyRef;
721-
dz = (dz - dzRef) * scale + dzRef;
719+
const auto val = ref->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ);
720+
dy = (dy - val[0]) * scale + val[0];
721+
dz = (dz - val[1]) * scale + val[1];
722722
} else if ((scale != 0) && ((scaleMode == 1) || (scaleMode == 2))) {
723-
const auto [dyRef, dzRef] = ref->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ);
724-
dy = dyRef * scale + dy;
725-
dz = dzRef * scale + dz;
723+
const auto val = ref->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ);
724+
dy = val[0] * scale + dy;
725+
dz = val[1] * scale + dz;
726726
}
727727
if (ref2 && (scale2 != 0)) {
728-
const auto [dyRef, dzRef] = ref2->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ);
729-
dy = dyRef * scale2 + dy;
730-
dz = dzRef * scale2 + dz;
728+
const auto val = ref2->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ);
729+
dy = val[0] * scale2 + dy;
730+
dz = val[1] * scale2 + dz;
731731
}
732732
}
733733
}

0 commit comments

Comments
 (0)