Skip to content

Commit b998ec6

Browse files
cbmswdavidrohr
authored andcommitted
TPCFastTransform: mirror Z-´of the spline grid for the C side
1 parent 09aab99 commit b998ec6

6 files changed

Lines changed: 39 additions & 72 deletions

File tree

Detectors/TPC/calibration/src/TPCFastSpaceChargeCorrectionHelper.cxx

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -401,11 +401,10 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
401401
int nY2Xbins = trackResiduals.getNY2XBins();
402402
int nZ2Xbins = trackResiduals.getNZ2XBins();
403403

404-
std::vector<double> knotsDouble[3];
404+
std::vector<double> knotsDouble[2];
405405

406406
knotsDouble[0].reserve(nY2Xbins);
407407
knotsDouble[1].reserve(nZ2Xbins);
408-
knotsDouble[2].reserve(nZ2Xbins);
409408

410409
// to get enouth measurements, make a spline knot at every second bin. Boundary bins are always included.
411410

@@ -418,16 +417,14 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
418417

419418
for (int i = 0, j = nZ2Xbins - 1; i <= j; i += 2, j -= 2) {
420419
knotsDouble[1].push_back(trackResiduals.getZ2X(i));
421-
knotsDouble[2].push_back(-trackResiduals.getZ2X(i));
422420
if (j >= i + 1) {
423421
knotsDouble[1].push_back(trackResiduals.getZ2X(j));
424-
knotsDouble[2].push_back(-trackResiduals.getZ2X(j));
425422
}
426423
}
427424

428-
std::vector<int> knotsInt[3];
425+
std::vector<int> knotsInt[2];
429426

430-
for (int dim = 0; dim < 3; dim++) {
427+
for (int dim = 0; dim < 2; dim++) {
431428
auto& knotsD = knotsDouble[dim];
432429
std::sort(knotsD.begin(), knotsD.end());
433430

@@ -463,12 +460,10 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
463460
}
464461

465462
auto& yKnotsInt = knotsInt[0];
466-
auto& zKnotsIntA = knotsInt[1];
467-
auto& zKnotsIntC = knotsInt[2];
463+
auto& zKnotsInt = knotsInt[1];
468464

469465
int nKnotsY = yKnotsInt.size();
470-
int nKnotsZA = zKnotsIntA.size();
471-
int nKnotsZC = zKnotsIntC.size();
466+
int nKnotsZ = zKnotsInt.size();
472467

473468
// std::cout << "n knots Y: " << nKnotsY << std::endl;
474469
// std::cout << "n knots Z: " << nKnotsZA << ", " << nKnotsZC << std::endl;
@@ -491,9 +486,9 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
491486
}
492487
{ // init spline scenario
493488
TPCFastSpaceChargeCorrection::SplineType spline;
494-
spline.recreate(nKnotsY, &yKnotsInt[0], nKnotsZA, &zKnotsIntA[0]);
489+
spline.recreate(nKnotsY, &yKnotsInt[0], nKnotsZ, &zKnotsInt[0]);
495490
correction.setSplineScenario(0, spline);
496-
spline.recreate(nKnotsY, &yKnotsInt[0], nKnotsZC, &zKnotsIntC[0]);
491+
spline.recreate(nKnotsY, &yKnotsInt[0], nKnotsZ, &zKnotsInt[0]);
497492
correction.setSplineScenario(1, spline);
498493
}
499494
correction.finishConstruction();
@@ -510,15 +505,9 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
510505
double zMin = rowX * trackResiduals.getZ2X(0);
511506
double zMax = rowX * trackResiduals.getZ2X(trackResiduals.getNZ2XBins() - 1);
512507
double zOut = zMax;
513-
if (iSector >= geo.getNumberOfSectorsA()) {
514-
// TPC C side
515-
zOut = -zOut;
516-
zMax = -zMin;
517-
zMin = zOut;
518-
}
519508
info.gridMeasured.set(yMin, spline.getGridX1().getUmax() / (yMax - yMin), // y
520509
zMin, spline.getGridX2().getUmax() / (zMax - zMin), // z
521-
zOut, geo.getZreadout(iSector)); // correction scaling region
510+
zOut, geo.getTPCzLength()); // correction scaling region
522511

523512
info.gridReal = info.gridMeasured;
524513

GPU/TPCFastTransformation/TPCFastSpaceChargeCorrection.cxx

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -256,30 +256,12 @@ void TPCFastSpaceChargeCorrection::setActualBufferAddress(char* actualFlatBuffer
256256
{ // grid for the measured coordinates
257257
float y0 = mGeo.getRowInfo(iRow).yMin;
258258
float yScale = spline.getGridX1().getUmax() / mGeo.getRowInfo(iRow).getYwidth();
259-
float zReadout = mGeo.getZreadout(iSector);
260259
float zOut = mGeo.getTPCzLength() - oldSectorRowInfo.gridV0;
261260
float z0 = -3.;
262261
float zScale = spline.getGridX2().getUmax() / (zOut - z0);
263-
if (iSector >= mGeo.getNumberOfSectorsA()) {
264-
zOut = -zOut;
265-
z0 = zOut;
266-
}
267-
newSectorRow.gridMeasured.set(y0, yScale, z0, zScale, zOut, zReadout);
268-
}
269-
270-
{ // grid for the real coordinates
271-
float y0 = oldSectorRowInfo.gridCorrU0;
272-
float yScale = oldSectorRowInfo.scaleCorrUtoGrid;
273-
float zReadout = mGeo.getZreadout(iSector);
274-
float zOut = mGeo.getTPCzLength() - oldSectorRowInfo.gridCorrV0;
275-
float zScale = oldSectorRowInfo.scaleCorrVtoGrid;
276-
float z0 = zOut - spline.getGridX2().getUmax() / zScale;
277-
if (iSector >= mGeo.getNumberOfSectorsA()) {
278-
zOut = -zOut;
279-
z0 = zOut;
280-
}
281-
newSectorRow.gridReal.set(y0, yScale, z0, zScale, zOut, zReadout);
262+
newSectorRow.gridMeasured.set(y0, yScale, z0, zScale, zOut, mGeo.getTPCzLength());
282263
}
264+
newSectorRow.gridReal = newSectorRow.gridMeasured;
283265
}
284266
}
285267
}
@@ -344,17 +326,17 @@ void TPCFastSpaceChargeCorrection::setActualBufferAddress(char* actualFlatBuffer
344326
}
345327
};
346328

347-
// reorder knots for the A side Y == old U, Z == - old V
329+
// reorder knots for the A side U == old U, V == - old V
348330
if (isAside) {
349331
for (int32_t i = 0; i < spline.getGridX1().getNumberOfKnots(); i++) {
350332
for (int32_t j = 0; j < spline.getGridX2().getNumberOfKnots() / 2; j++) {
351333
swapKnots(i, j, i, spline.getGridX2().getNumberOfKnots() - 1 - j);
352334
}
353335
}
354-
} else { // reorder knots for the C side Y == - old U, Z == old V
336+
} else { // reorder knots for the C side U == - old U, V == - old V
355337
for (int32_t i = 0; i < spline.getGridX1().getNumberOfKnots() / 2; i++) {
356338
for (int32_t j = 0; j < spline.getGridX2().getNumberOfKnots(); j++) {
357-
swapKnots(i, j, spline.getGridX1().getNumberOfKnots() - 1 - i, j);
339+
swapKnots(i, j, spline.getGridX1().getNumberOfKnots() - 1 - i, spline.getGridX2().getNumberOfKnots() - 1 - j);
358340
}
359341
}
360342
}
@@ -366,10 +348,11 @@ void TPCFastSpaceChargeCorrection::setActualBufferAddress(char* actualFlatBuffer
366348
for (int iDim = 0; iDim < nDim; iDim++) {
367349
if (isAside) {
368350
data[nKnotParameters * iKnot + nDim * 1 + iDim] *= -1; // invert Z derivatives on A side
351+
data[nKnotParameters * iKnot + nDim * 3 + iDim] *= -1; // invert cross derivatives on A side
369352
} else {
353+
data[nKnotParameters * iKnot + nDim * 1 + iDim] *= -1; // invert Z derivatives on C side
370354
data[nKnotParameters * iKnot + nDim * 2 + iDim] *= -1; // invert Y derivatives on C side
371355
}
372-
data[nKnotParameters * iKnot + nDim * 3 + iDim] *= -1; // invert cross derivatives on both sides
373356
}
374357
// new correction directions
375358
if (iSpline == 0) { // dX,dU,dV -> dX,dY,dZ
@@ -631,9 +614,7 @@ GPUd() void TPCFastSpaceChargeCorrection::setNoCorrection()
631614
float yScale = spline.getGridX1().getUmax() / mGeo.getRowInfo(row).getYwidth();
632615
float z0 = mGeo.getZmin(sector);
633616
float zScale = spline.getGridX2().getUmax() / mGeo.getTPCzLength();
634-
float zReadout = mGeo.getZreadout(sector);
635-
info.gridMeasured.set(y0, yScale, z0, zScale, zReadout, zReadout);
636-
617+
info.gridMeasured.set(y0, yScale, z0, zScale, mGeo.getTPCzLength(), mGeo.getTPCzLength());
637618
info.gridReal = info.gridMeasured;
638619
} // row
639620
} // sector

GPU/TPCFastTransformation/TPCFastSpaceChargeCorrection.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,24 @@ class TPCFastSpaceChargeCorrection : public FlatObject
7979
}
8080

8181
/// convert local y, z to internal grid coordinates u,v, and spline scale
82-
GPUdi() void convLocalToGridUntruncated(float y, float z, float& u, float& v, float& s) const
82+
GPUdi() void convLocalToGridUntruncated(int sector, float y, float z, float& u, float& v, float& s) const
8383
{
84+
if (sector >= TPCFastTransformGeo::getNumberOfSectorsA()) {
85+
z = -z;
86+
}
8487
u = (y - y0) * yScale;
8588
v = (z - z0) * zScale;
8689
s = getSpineScaleForZ(z);
8790
}
8891

8992
/// convert internal grid coordinates u,v to local y, z
90-
GPUdi() void convGridToLocal(float gridU, float gridV, float& y, float& z) const
93+
GPUdi() void convGridToLocal(int sector, float gridU, float gridV, float& y, float& z) const
9194
{
9295
y = y0 + gridU / yScale;
9396
z = z0 + gridV / zScale;
97+
if (sector >= TPCFastTransformGeo::getNumberOfSectorsA()) {
98+
z = -z;
99+
}
94100
}
95101
ClassDefNV(GridInfo, 1);
96102
};
@@ -395,7 +401,7 @@ GPUdi() void TPCFastSpaceChargeCorrection::convLocalToGrid(int32_t sector, int32
395401
/// convert local y, z to internal grid coordinates u,v
396402
/// return values: u, v, scaling factor
397403
const SplineType& spline = getSpline(sector, row);
398-
getSectorRowInfo(sector, row).gridMeasured.convLocalToGridUntruncated(y, z, u, v, s);
404+
getSectorRowInfo(sector, row).gridMeasured.convLocalToGridUntruncated(sector, y, z, u, v, s);
399405
// shrink to the grid
400406
u = GPUCommonMath::Clamp(u, 0.f, (float)spline.getGridX1().getUmax());
401407
v = GPUCommonMath::Clamp(v, 0.f, (float)spline.getGridX2().getUmax());
@@ -405,7 +411,7 @@ GPUdi() bool TPCFastSpaceChargeCorrection::isLocalInsideGrid(int32_t sector, int
405411
{
406412
/// check if local y, z are inside the grid
407413
float u, v, s;
408-
getSectorRowInfo(sector, row).gridMeasured.convLocalToGridUntruncated(y, z, u, v, s);
414+
getSectorRowInfo(sector, row).gridMeasured.convLocalToGridUntruncated(sector, y, z, u, v, s);
409415
const auto& spline = getSpline(sector, row);
410416
// shrink to the grid
411417
if (u < 0.f || u > (float)spline.getGridX1().getUmax() || //
@@ -419,7 +425,7 @@ GPUdi() bool TPCFastSpaceChargeCorrection::isRealLocalInsideGrid(int32_t sector,
419425
{
420426
/// check if local y, z are inside the grid
421427
float u, v, s;
422-
getSectorRowInfo(sector, row).gridReal.convLocalToGridUntruncated(y, z, u, v, s);
428+
getSectorRowInfo(sector, row).gridReal.convLocalToGridUntruncated(sector, y, z, u, v, s);
423429
const auto& spline = getSpline(sector, row);
424430
// shrink to the grid
425431
if (u < 0.f || u > (float)spline.getGridX1().getUmax() || //
@@ -432,14 +438,14 @@ GPUdi() bool TPCFastSpaceChargeCorrection::isRealLocalInsideGrid(int32_t sector,
432438
GPUdi() void TPCFastSpaceChargeCorrection::convGridToLocal(int32_t sector, int32_t row, float gridU, float gridV, float& y, float& z) const
433439
{
434440
/// convert internal grid coordinates u,v to local y, z
435-
getSectorRowInfo(sector, row).gridMeasured.convGridToLocal(gridU, gridV, y, z);
441+
getSectorRowInfo(sector, row).gridMeasured.convGridToLocal(sector, gridU, gridV, y, z);
436442
}
437443

438444
GPUdi() void TPCFastSpaceChargeCorrection::convRealLocalToGrid(int32_t sector, int32_t row, float y, float z, float& u, float& v, float& s) const
439445
{
440446
/// convert real y, z to the internal grid coordinates + scale
441447
const SplineType& spline = getSpline(sector, row);
442-
getSectorRowInfo(sector, row).gridReal.convLocalToGridUntruncated(y, z, u, v, s);
448+
getSectorRowInfo(sector, row).gridReal.convLocalToGridUntruncated(sector, y, z, u, v, s);
443449
// shrink to the grid
444450
u = GPUCommonMath::Clamp(u, 0.f, (float)spline.getGridX1().getUmax());
445451
v = GPUCommonMath::Clamp(v, 0.f, (float)spline.getGridX2().getUmax());
@@ -448,7 +454,7 @@ GPUdi() void TPCFastSpaceChargeCorrection::convRealLocalToGrid(int32_t sector, i
448454
GPUdi() void TPCFastSpaceChargeCorrection::convGridToRealLocal(int32_t sector, int32_t row, float gridU, float gridV, float& y, float& z) const
449455
{
450456
/// convert internal grid coordinates u,v to the real y, z
451-
getSectorRowInfo(sector, row).gridReal.convGridToLocal(gridU, gridV, y, z);
457+
getSectorRowInfo(sector, row).gridReal.convGridToLocal(sector, gridU, gridV, y, z);
452458
}
453459

454460
GPUdi() void TPCFastSpaceChargeCorrection::getCorrectionLocal(int32_t sector, int32_t row, float y, float z, float& dx, float& dy, float& dz) const

GPU/TPCFastTransformation/TPCFastTransformGeo.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ class TPCFastTransformGeo
142142
#endif
143143
GPUd() float getZmin(int32_t sector) const;
144144
GPUd() float getZmax(int32_t sector) const;
145-
GPUd() float getZreadout(int32_t sector) const;
146145

147146
/// _______________ Conversion of coordinate systems __________
148147

@@ -294,16 +293,6 @@ GPUdi() float TPCFastTransformGeo::getZmax(int32_t sector) const
294293
}
295294
}
296295

297-
GPUdi() float TPCFastTransformGeo::getZreadout(int32_t sector) const
298-
{
299-
/// z readout for the sector
300-
if (sector < NumberOfSectorsA) { // TPC side A
301-
return mTPCzLength;
302-
} else { // TPC side C
303-
return -mTPCzLength;
304-
}
305-
}
306-
307296
GPUdi() void TPCFastTransformGeo::convLocalToPadDriftLength(int32_t sector, int32_t row, float y, float z, float& pad, float& l) const
308297
{
309298
/// convert Local c.s. -> Pad, DriftLength

GPU/TPCFastTransformation/TPCFastTransformPOD.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ class TPCFastTransformPOD
242242

243243
static constexpr int NROWS = o2::tpc::constants::MAXGLOBALPADROW;
244244
static constexpr int NSECTORS = o2::tpc::constants::MAXSECTOR;
245+
static constexpr int NSECTORSA = o2::tpc::constants::MAXSECTOR / 2;
245246
static constexpr int NSplineIDs = 3; ///< number of spline data sets for each sector/row
246247

247248
private:
@@ -369,7 +370,7 @@ GPUdi() void TPCFastTransformPOD::convLocalToGrid(int32_t sector, int32_t row, f
369370
/// convert local y, z to internal grid coordinates u,v
370371
/// return values: u, v, scaling factor
371372
const SplineType& spline = getSpline(sector, row);
372-
getSectorRowInfo(sector, row).gridMeasured.convLocalToGridUntruncated(y, z, u, v, s);
373+
getSectorRowInfo(sector, row).gridMeasured.convLocalToGridUntruncated(sector, y, z, u, v, s);
373374
// shrink to the grid
374375
u = GPUCommonMath::Clamp(u, 0.f, (float)spline.getGridX1().getUmax());
375376
v = GPUCommonMath::Clamp(v, 0.f, (float)spline.getGridX2().getUmax());
@@ -378,14 +379,14 @@ GPUdi() void TPCFastTransformPOD::convLocalToGrid(int32_t sector, int32_t row, f
378379
GPUdi() void TPCFastTransformPOD::convGridToLocal(int32_t sector, int32_t row, float gridU, float gridV, float& y, float& z) const
379380
{
380381
/// convert internal grid coordinates u,v to local y, z
381-
getSectorRowInfo(sector, row).gridMeasured.convGridToLocal(gridU, gridV, y, z);
382+
getSectorRowInfo(sector, row).gridMeasured.convGridToLocal(sector, gridU, gridV, y, z);
382383
}
383384

384385
GPUdi() void TPCFastTransformPOD::convRealLocalToGrid(int32_t sector, int32_t row, float y, float z, float& u, float& v, float& s) const
385386
{
386387
/// convert real y, z to the internal grid coordinates + scale
387388
const SplineType& spline = getSpline(sector, row);
388-
getSectorRowInfo(sector, row).gridReal.convLocalToGridUntruncated(y, z, u, v, s);
389+
getSectorRowInfo(sector, row).gridReal.convLocalToGridUntruncated(sector, y, z, u, v, s);
389390
// shrink to the grid
390391
u = GPUCommonMath::Clamp(u, 0.f, (float)spline.getGridX1().getUmax());
391392
v = GPUCommonMath::Clamp(v, 0.f, (float)spline.getGridX2().getUmax());
@@ -394,14 +395,14 @@ GPUdi() void TPCFastTransformPOD::convRealLocalToGrid(int32_t sector, int32_t ro
394395
GPUdi() void TPCFastTransformPOD::convGridToRealLocal(int32_t sector, int32_t row, float gridU, float gridV, float& y, float& z) const
395396
{
396397
/// convert internal grid coordinates u,v to the real y, z
397-
getSectorRowInfo(sector, row).gridReal.convGridToLocal(gridU, gridV, y, z);
398+
getSectorRowInfo(sector, row).gridReal.convGridToLocal(sector, gridU, gridV, y, z);
398399
}
399400

400401
GPUdi() bool TPCFastTransformPOD::isLocalInsideGrid(int32_t sector, int32_t row, float y, float z) const
401402
{
402403
/// check if local y, z are inside the grid
403404
float u, v, s;
404-
getSectorRowInfo(sector, row).gridMeasured.convLocalToGridUntruncated(y, z, u, v, s);
405+
getSectorRowInfo(sector, row).gridMeasured.convLocalToGridUntruncated(sector, y, z, u, v, s);
405406
const auto& spline = getSpline(sector, row);
406407
// shrink to the grid
407408
if (u < 0.f || u > (float)spline.getGridX1().getUmax() || //
@@ -415,7 +416,7 @@ GPUdi() bool TPCFastTransformPOD::isRealLocalInsideGrid(int32_t sector, int32_t
415416
{
416417
/// check if local y, z are inside the grid
417418
float u, v, s;
418-
getSectorRowInfo(sector, row).gridReal.convLocalToGridUntruncated(y, z, u, v, s);
419+
getSectorRowInfo(sector, row).gridReal.convLocalToGridUntruncated(sector, y, z, u, v, s);
419420
const auto& spline = getSpline(sector, row);
420421
// shrink to the grid
421422
if (u < 0.f || u > (float)spline.getGridX1().getUmax() || //

GPU/TPCFastTransformation/macro/TPCFastTransformInit.C

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ void TPCFastTransformInit(const char* fileName = "debugVoxRes.root", const char*
180180

181181
const char* fileName = outFileName;
182182

183-
//fileName = "~/alidock/test/master/TPCFastTransform_VoxRes.root";
183+
// file with the old data format
184+
// fileName = "~/alidock/test/master/TPCFastTransform_VoxRes.root";
184185

185186
std::cout << "load corrections from file " << fileName << std::endl;
186187

0 commit comments

Comments
 (0)