Skip to content

Commit 09aab99

Browse files
cbmswdavidrohr
authored andcommitted
TPCFastTransform: remove row-wise max correction values
1 parent a011950 commit 09aab99

4 files changed

Lines changed: 21 additions & 87 deletions

File tree

Detectors/TPC/calibration/src/TPCFastSpaceChargeCorrectionHelper.cxx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,6 @@ void TPCFastSpaceChargeCorrectionHelper::fillSpaceChargeCorrectionFromMap(TPCFas
144144

145145
const std::vector<o2::gpu::TPCFastSpaceChargeCorrectionMap::CorrectionPoint>& data = mCorrectionMap.getPoints(sector, row);
146146
int nDataPoints = data.size();
147-
auto& info = correction.getSectorRowInfo(sector, row);
148-
if (!processingInverseCorrection) {
149-
info.resetMaxValues();
150-
}
151-
info.updateMaxValues(1., 1., 1.);
152-
info.updateMaxValues(-1., -1., -1.);
153147

154148
if (nDataPoints >= 4) {
155149
std::vector<double> pointGU(nDataPoints);
@@ -170,7 +164,6 @@ void TPCFastSpaceChargeCorrectionHelper::fillSpaceChargeCorrectionFromMap(TPCFas
170164
pointCorr[3 * i + 0] = p.mDx;
171165
pointCorr[3 * i + 1] = p.mDy;
172166
pointCorr[3 * i + 2] = p.mDz;
173-
info.updateMaxValues(5. * p.mDx, 5. * p.mDy, 5. * p.mDz);
174167
}
175168
helper.approximateDataPoints(spline, splineParameters.data(), 0., spline.getGridX1().getUmax(), 0., spline.getGridX2().getUmax(), pointGU.data(),
176169
pointGV.data(), pointCorr.data(), pointWeight.data(), nDataPoints);
@@ -1063,10 +1056,7 @@ void TPCFastSpaceChargeCorrectionHelper::mergeCorrections(
10631056
constexpr int nKnotPar3d = nKnotPar1d * 3;
10641057

10651058
{ // scale the main correction
1066-
for (int i = 0; i < 3; i++) {
1067-
secRowInfo.maxCorr[i] *= mainScale;
1068-
secRowInfo.minCorr[i] *= mainScale;
1069-
}
1059+
10701060
double parscale[4] = {mainScale, mainScale, mainScale, mainScale * mainScale};
10711061
for (int iknot = 0, ind = 0; iknot < spline.getNumberOfKnots(); iknot++) {
10721062
for (int ipar = 0; ipar < nKnotPar1d; ++ipar) {
@@ -1100,8 +1090,6 @@ void TPCFastSpaceChargeCorrectionHelper::mergeCorrections(
11001090
const auto& corr = *(additionalCorrections[icorr].first);
11011091
double scale = additionalCorrections[icorr].second;
11021092
auto& linfo = corr.getSectorRowInfo(sector, row);
1103-
secRowInfo.updateMaxValues(linfo.getMaxValues(), scale);
1104-
secRowInfo.updateMaxValues(linfo.getMinValues(), scale);
11051093

11061094
double scaleU = secRowInfo.gridMeasured.getYscale() / linfo.gridMeasured.getYscale();
11071095
double scaleV = secRowInfo.gridMeasured.getZscale() / linfo.gridMeasured.getZscale();

GPU/TPCFastTransformation/TPCFastSpaceChargeCorrection.cxx

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,6 @@ void TPCFastSpaceChargeCorrection::setActualBufferAddress(char* actualFlatBuffer
280280
}
281281
newSectorRow.gridReal.set(y0, yScale, z0, zScale, zOut, zReadout);
282282
}
283-
284-
newSectorRow.resetMaxValues();
285-
newSectorRow.updateMaxValues(-100.f, -100.f, -100.f);
286-
newSectorRow.updateMaxValues(100.f, 100.f, 100.f);
287283
}
288284
}
289285
}
@@ -497,12 +493,6 @@ void TPCFastSpaceChargeCorrection::startConstruction(const TPCFastTransformGeo&
497493
row.dataOffsetBytes[0] = 0;
498494
row.dataOffsetBytes[1] = 0;
499495
row.dataOffsetBytes[2] = 0;
500-
row.minCorr[0] = 0;
501-
row.minCorr[1] = 0;
502-
row.minCorr[2] = 0;
503-
row.maxCorr[0] = 0;
504-
row.maxCorr[1] = 0;
505-
row.maxCorr[2] = 0;
506496
}
507497
}
508498

GPU/TPCFastTransformation/TPCFastSpaceChargeCorrection.h

Lines changed: 11 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -102,51 +102,6 @@ class TPCFastSpaceChargeCorrection : public FlatObject
102102
GridInfo gridMeasured; ///< grid info for measured coordinates
103103
GridInfo gridReal; ///< grid info for real coordinates
104104

105-
float minCorr[3]{-10.f, -10.f, -10.f}; ///< min correction for dX, dY, dZ
106-
float maxCorr[3]{10.f, 10.f, 10.f}; ///< max correction for dX, dY, dZ
107-
108-
void resetMaxValues()
109-
{
110-
minCorr[0] = -1.f;
111-
maxCorr[0] = 1.f;
112-
minCorr[1] = -1.f;
113-
maxCorr[1] = 1.f;
114-
minCorr[2] = -1.f;
115-
maxCorr[2] = 1.f;
116-
}
117-
118-
void updateMaxValues(float dx, float du, float dv)
119-
{
120-
minCorr[0] = GPUCommonMath::Min(minCorr[0], dx);
121-
maxCorr[0] = GPUCommonMath::Max(maxCorr[0], dx);
122-
123-
minCorr[1] = GPUCommonMath::Min(minCorr[1], du);
124-
maxCorr[1] = GPUCommonMath::Max(maxCorr[1], du);
125-
126-
minCorr[2] = GPUCommonMath::Min(minCorr[2], dv);
127-
maxCorr[2] = GPUCommonMath::Max(maxCorr[2], dv);
128-
}
129-
130-
#ifndef GPUCA_GPUCODE_DEVICE
131-
void updateMaxValues(std::array<float, 3> dxdudv, float scale)
132-
{
133-
float dx = dxdudv[0] * scale;
134-
float du = dxdudv[1] * scale;
135-
float dv = dxdudv[2] * scale;
136-
updateMaxValues(dx, du, dv);
137-
}
138-
139-
std::array<float, 3> getMaxValues() const
140-
{
141-
return {maxCorr[0], maxCorr[1], maxCorr[2]};
142-
}
143-
144-
std::array<float, 3> getMinValues() const
145-
{
146-
return {minCorr[0], minCorr[1], minCorr[2]};
147-
}
148-
#endif
149-
150105
ClassDefNV(SectorRowInfo, 2);
151106
};
152107

@@ -325,6 +280,8 @@ class TPCFastSpaceChargeCorrection : public FlatObject
325280
/// release temporary memory used during construction
326281
void releaseConstructionMemory();
327282

283+
static constexpr float kMaxCorrection = 100.f; ///< maximum correction value, used to protect from FPEs
284+
328285
/// _______________ Data members _______________________________________________
329286

330287
/// _______________ Construction control _______________________________________________
@@ -506,13 +463,13 @@ GPUdi() void TPCFastSpaceChargeCorrection::getCorrectionLocal(int32_t sector, in
506463
float dxyz[3];
507464
spline.interpolateAtU(splineData, u, v, dxyz);
508465

509-
if (CAMath::Abs(dxyz[0]) > 100.f || CAMath::Abs(dxyz[1]) > 100.f || CAMath::Abs(dxyz[2]) > 100.f) {
466+
if (CAMath::Abs(dxyz[0]) > kMaxCorrection || CAMath::Abs(dxyz[1]) > kMaxCorrection || CAMath::Abs(dxyz[2]) > kMaxCorrection) {
510467
s = 0.f; // TODO: DR: Protect from FPEs, fix upstream and remove once guaranteed that it is fixed
511468
}
512469

513-
dx = s * GPUCommonMath::Clamp(dxyz[0], info.minCorr[0], info.maxCorr[0]);
514-
dy = s * GPUCommonMath::Clamp(dxyz[1], info.minCorr[1], info.maxCorr[1]);
515-
dz = s * GPUCommonMath::Clamp(dxyz[2], info.minCorr[2], info.maxCorr[2]);
470+
dx = s * dxyz[0];
471+
dy = s * dxyz[1];
472+
dz = s * dxyz[2];
516473
}
517474

518475
GPUdi() float TPCFastSpaceChargeCorrection::getCorrectionXatRealYZ(int32_t sector, int32_t row, float realY, float realZ) const
@@ -522,11 +479,10 @@ GPUdi() float TPCFastSpaceChargeCorrection::getCorrectionXatRealYZ(int32_t secto
522479
convRealLocalToGrid(sector, row, realY, realZ, u, v, s);
523480
float dx = 0;
524481
getSplineInvX(sector, row).interpolateAtU(getCorrectionDataInvX(sector, row), u, v, &dx);
525-
if (CAMath::Abs(dx) > 100.f) {
482+
if (CAMath::Abs(dx) > kMaxCorrection) {
526483
s = 0.f; // TODO: DR: Protect from FPEs, fix upstream and remove once guaranteed that it is fixed
527484
}
528-
dx = s * GPUCommonMath::Clamp(dx, info.minCorr[0], info.maxCorr[0]);
529-
return dx;
485+
return s * dx;
530486
}
531487

532488
GPUdi() void TPCFastSpaceChargeCorrection::getCorrectionYZatRealYZ(int32_t sector, int32_t row, float realY, float realZ, float& y, float& z) const
@@ -536,11 +492,11 @@ GPUdi() void TPCFastSpaceChargeCorrection::getCorrectionYZatRealYZ(int32_t secto
536492
const auto& info = getSectorRowInfo(sector, row);
537493
float dyz[2];
538494
getSplineInvYZ(sector, row).interpolateAtU(getCorrectionDataInvYZ(sector, row), u, v, dyz);
539-
if (CAMath::Abs(dyz[0]) > 100.f || CAMath::Abs(dyz[1]) > 100.f) {
495+
if (CAMath::Abs(dyz[0]) > kMaxCorrection || CAMath::Abs(dyz[1]) > kMaxCorrection) {
540496
s = 0.f; // TODO: DR: Protect from FPEs, fix upstream and remove once guaranteed that it is fixed
541497
}
542-
y = s * GPUCommonMath::Clamp(dyz[0], info.minCorr[1], info.maxCorr[1]);
543-
z = s * GPUCommonMath::Clamp(dyz[1], info.minCorr[2], info.maxCorr[2]);
498+
y = s * dyz[0];
499+
z = s * dyz[1];
544500
}
545501

546502
} // namespace o2::gpu

GPU/TPCFastTransformation/TPCFastTransformPOD.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,13 @@ GPUdi() void TPCFastTransformPOD::getCorrectionLocal(int32_t sector, int32_t row
316316
float dxyz[3];
317317
spline.interpolateAtUZeroCopy(g1buf, g2buf, splineData, u, v, dxyz);
318318

319-
if (CAMath::Abs(dxyz[0]) > 100.f || CAMath::Abs(dxyz[1]) > 100.f || CAMath::Abs(dxyz[2]) > 100.f) {
319+
if (CAMath::Abs(dxyz[0]) > TPCFastSpaceChargeCorrection::kMaxCorrection || CAMath::Abs(dxyz[1]) > TPCFastSpaceChargeCorrection::kMaxCorrection || CAMath::Abs(dxyz[2]) > TPCFastSpaceChargeCorrection::kMaxCorrection) {
320320
s = 0.f; // TODO: DR: Protect from FPEs, fix upstream and remove once guaranteed that it is fixed
321321
}
322322

323-
dx = s * GPUCommonMath::Clamp(dxyz[0], info.minCorr[0], info.maxCorr[0]);
324-
dy = s * GPUCommonMath::Clamp(dxyz[1], info.minCorr[1], info.maxCorr[1]);
325-
dz = s * GPUCommonMath::Clamp(dxyz[2], info.minCorr[2], info.maxCorr[2]);
323+
dx = s * dxyz[0];
324+
dy = s * dxyz[1];
325+
dz = s * dxyz[2];
326326
}
327327

328328
GPUdi() float TPCFastTransformPOD::getCorrectionXatRealYZ(int32_t sector, int32_t row, float realY, float realZ) const
@@ -338,10 +338,10 @@ GPUdi() float TPCFastTransformPOD::getCorrectionXatRealYZ(int32_t sector, int32_
338338

339339
float dx = 0;
340340
spline.interpolateAtUZeroCopy(g1buf, g2buf, getCorrectionDataInvX(sector, row), u, v, &dx);
341-
if (CAMath::Abs(dx) > 100.f) {
341+
if (CAMath::Abs(dx) > TPCFastSpaceChargeCorrection::kMaxCorrection) {
342342
s = 0.f; // TODO: DR: Protect from FPEs, fix upstream and remove once guaranteed that it is fixed
343343
}
344-
dx = s * GPUCommonMath::Clamp(dx, info.minCorr[0], info.maxCorr[0]);
344+
dx = s * dx;
345345
return dx;
346346
}
347347

@@ -357,11 +357,11 @@ GPUdi() void TPCFastTransformPOD::getCorrectionYZatRealYZ(int32_t sector, int32_
357357

358358
float dyz[2];
359359
spline.interpolateAtUZeroCopy(g1buf, g2buf, getCorrectionDataInvYZ(sector, row), u, v, dyz);
360-
if (CAMath::Abs(dyz[0]) > 100.f || CAMath::Abs(dyz[1]) > 100.f) {
360+
if (CAMath::Abs(dyz[0]) > TPCFastSpaceChargeCorrection::kMaxCorrection || CAMath::Abs(dyz[1]) > TPCFastSpaceChargeCorrection::kMaxCorrection) {
361361
s = 0.f; // TODO: DR: Protect from FPEs, fix upstream and remove once guaranteed that it is fixed
362362
}
363-
y = s * GPUCommonMath::Clamp(dyz[0], info.minCorr[1], info.maxCorr[1]);
364-
z = s * GPUCommonMath::Clamp(dyz[1], info.minCorr[2], info.maxCorr[2]);
363+
y = s * dyz[0];
364+
z = s * dyz[1];
365365
}
366366

367367
GPUdi() void TPCFastTransformPOD::convLocalToGrid(int32_t sector, int32_t row, float y, float z, float& u, float& v, float& s) const

0 commit comments

Comments
 (0)