Skip to content

Commit 50e48a3

Browse files
committed
TPCFastTransform: fix compilation on GPU with the new splines
1 parent ae8683c commit 50e48a3

File tree

4 files changed

+80
-68
lines changed

4 files changed

+80
-68
lines changed

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
@@ -349,17 +349,17 @@ class TPCFastTransform : public FlatObject
349349
GPUdi() void TPCFastTransform::convPadTimeToLocal(int32_t sector, int32_t row, float pad, float time, float& y, float& z, float vertexTime) const
350350
{
351351
float l = (time - mT0 - vertexTime) * mVdrift; // drift length [cm]
352-
const auto local = getGeometry().convPadDriftLengthToLocal(sector, row, pad, l);
353-
y = local[0];
354-
z = local[1];
352+
const auto localval = getGeometry().convPadDriftLengthToLocal(sector, row, pad, l);
353+
y = localval[0];
354+
z = localval[1];
355355
}
356356

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

365365
// ----------------------------------------------------------------------
@@ -432,22 +432,22 @@ GPUdi() void TPCFastTransform::TransformLocal(int32_t sector, int32_t row, float
432432
dz = corrLocal[2];
433433
if (ref) {
434434
if ((scale > 0.f) && (scaleMode == 0)) { // scaling was requested
435-
auto [dxRef, dyRef, dzRef] = ref->mCorrection.getCorrectionLocal(sector, row, y, z);
436-
dx = (dx - dxRef) * scale + dxRef;
437-
dy = (dy - dyRef) * scale + dyRef;
438-
dz = (dz - dzRef) * scale + dzRef;
435+
auto val = ref->mCorrection.getCorrectionLocal(sector, row, y, z);
436+
dx = (dx - val[0]) * scale + val[0];
437+
dy = (dy - val[1]) * scale + val[1];
438+
dz = (dz - val[2]) * scale + val[2];
439439
} else if ((scale != 0.f) && ((scaleMode == 1) || (scaleMode == 2))) {
440-
auto [dxRef, dyRef, dzRef] = ref->mCorrection.getCorrectionLocal(sector, row, y, z);
441-
dx = dxRef * scale + dx;
442-
dy = dyRef * scale + dy;
443-
dz = dzRef * scale + dz;
440+
auto val = ref->mCorrection.getCorrectionLocal(sector, row, y, z);
441+
dx = val[0] * scale + dx;
442+
dy = val[1] * scale + dy;
443+
dz = val[2] * scale + dz;
444444
}
445445
}
446446
if (ref2 && (scale2 != 0)) {
447-
auto [dxRef, dyRef, dzRef] = ref2->mCorrection.getCorrectionLocal(sector, row, y, z);
448-
dx = dxRef * scale2 + dx;
449-
dy = dyRef * scale2 + dy;
450-
dz = dzRef * scale2 + dz;
447+
auto val = ref2->mCorrection.getCorrectionLocal(sector, row, y, z);
448+
dx = val[0] * scale2 + dx;
449+
dy = val[1] * scale2 + dy;
450+
dz = val[2] * scale2 + dz;
451451
}
452452
}
453453
}
@@ -617,9 +617,9 @@ GPUdi() void TPCFastTransform::TransformIdeal(int32_t sector, int32_t row, float
617617

618618
x = getGeometry().getRowInfo(row).x;
619619
float driftLength = (time - mT0 - vertexTime) * mVdrift; // drift length cm
620-
const auto local = getGeometry().convPadDriftLengthToLocal(sector, row, pad, driftLength);
621-
y = local[0];
622-
z = local[1];
620+
const auto localval = getGeometry().convPadDriftLengthToLocal(sector, row, pad, driftLength);
621+
y = localval[0];
622+
z = localval[1];
623623
}
624624

625625
GPUdi() float TPCFastTransform::convTimeToZinTimeFrame(int32_t sector, float time, float maxTimeBin) const
@@ -732,18 +732,18 @@ GPUdi() void TPCFastTransform::InverseTransformYZtoNominalYZ(int32_t sector, int
732732

733733
if (ref) { // scaling was requested
734734
if (scaleMode == 0 && scale > 0.f) {
735-
const auto [dyRef, dzRef] = ref->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ);
736-
dy = (dy - dyRef) * scale + dyRef;
737-
dz = (dz - dzRef) * scale + dzRef;
735+
const auto val = ref->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ);
736+
dy = (dy - val[0]) * scale + val[0];
737+
dz = (dz - val[1]) * scale + val[1];
738738
} else if ((scale != 0) && ((scaleMode == 1) || (scaleMode == 2))) {
739-
const auto [dyRef, dzRef] = ref->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ);
740-
dy = dyRef * scale + dy;
741-
dz = dzRef * scale + dz;
739+
const auto val = ref->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ);
740+
dy = val[0] * scale + dy;
741+
dz = val[1] * scale + dz;
742742
}
743743
if (ref2 && (scale2 != 0)) {
744-
const auto [dyRef, dzRef] = ref2->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ);
745-
dy = dyRef * scale2 + dy;
746-
dz = dzRef * scale2 + dz;
744+
const auto val = ref2->mCorrection.getCorrectionYZatRealYZ(sector, row, realY, realZ);
745+
dy = val[0] * scale2 + dy;
746+
dz = val[1] * scale2 + dz;
747747
}
748748
}
749749
}

0 commit comments

Comments
 (0)