Skip to content

Commit 7416b3e

Browse files
sgorbunocbmsw
authored andcommitted
TPC Splines: disable smoothing
1 parent e329718 commit 7416b3e

File tree

1 file changed

+61
-45
lines changed

1 file changed

+61
-45
lines changed

Detectors/TPC/calibration/src/TPCFastSpaceChargeCorrectionHelper.cxx

Lines changed: 61 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,14 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
411411
int nY2Xbins = trackResiduals.getNY2XBins();
412412
int nZ2Xbins = trackResiduals.getNZ2XBins();
413413

414+
double marginY2X = trackResiduals.getY2X(0, 2) - trackResiduals.getY2X(0, 0);
415+
double marginZ2X = trackResiduals.getZ2X(1) - trackResiduals.getZ2X(0);
416+
414417
std::vector<int> yBinsInt;
415418
{
416419
std::vector<double> yBins;
417-
yBins.reserve(nY2Xbins);
420+
yBins.reserve(nY2Xbins + 2);
421+
yBins.push_back(trackResiduals.getY2X(0, 0) - marginY2X);
418422
for (int i = 0, j = nY2Xbins - 1; i <= j; i += 2, j -= 2) {
419423
if (i == j) {
420424
yBins.push_back(trackResiduals.getY2X(0, i));
@@ -425,6 +429,8 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
425429
yBins.push_back(trackResiduals.getY2X(0, j));
426430
}
427431
}
432+
yBins.push_back(trackResiduals.getY2X(0, nY2Xbins - 1) + marginY2X);
433+
428434
std::sort(yBins.begin(), yBins.end());
429435
double dy = yBins[1] - yBins[0];
430436
for (int i = 1; i < yBins.size(); i++) {
@@ -452,10 +458,13 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
452458
std::vector<int> zBinsInt;
453459
{
454460
std::vector<double> zBins;
455-
zBins.reserve(nZ2Xbins);
461+
zBins.reserve(nZ2Xbins + 2);
462+
zBins.push_back(-(trackResiduals.getZ2X(0) - marginZ2X));
456463
for (int i = 0; i < nZ2Xbins; i += 2) {
457464
zBins.push_back(-trackResiduals.getZ2X(i));
458465
}
466+
zBins.push_back(-(trackResiduals.getZ2X(nZ2Xbins - 1) + 2. * marginZ2X));
467+
459468
std::sort(zBins.begin(), zBins.end());
460469
double dz = zBins[1] - zBins[0];
461470
for (int i = 1; i < zBins.size(); i++) {
@@ -465,7 +474,7 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
465474
}
466475
zBinsInt.reserve(zBins.size());
467476
// spline knots must be positioned on the grid with an integer internal coordinate
468-
// lets copy the knot positions with the accuracy of 0.1*dz
477+
// lets copy the knot positions with the accuracy of 0.01*dz
469478
dz = dz / 10.;
470479
double z0 = zBins[0];
471480
double z1 = zBins[zBins.size() - 1];
@@ -525,10 +534,10 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
525534
const auto& rowInfo = geo.getRowInfo(iRow);
526535
auto& info = correction.getSliceRowInfo(iRoc, iRow);
527536
const auto& spline = correction.getSpline(iRoc, iRow);
528-
double yMin = rowInfo.x * trackResiduals.getY2X(iRow, 0);
529-
double yMax = rowInfo.x * trackResiduals.getY2X(iRow, trackResiduals.getNY2XBins() - 1);
530-
double zMin = rowInfo.x * trackResiduals.getZ2X(0);
531-
double zMax = rowInfo.x * trackResiduals.getZ2X(trackResiduals.getNZ2XBins() - 1);
537+
double yMin = rowInfo.x * (trackResiduals.getY2X(iRow, 0) - marginY2X);
538+
double yMax = rowInfo.x * (trackResiduals.getY2X(iRow, trackResiduals.getNY2XBins() - 1) + marginY2X);
539+
double zMin = rowInfo.x * (trackResiduals.getZ2X(0) - marginZ2X);
540+
double zMax = rowInfo.x * (trackResiduals.getZ2X(trackResiduals.getNZ2XBins() - 1) + 2. * marginZ2X);
532541
double uMin = yMin;
533542
double uMax = yMax;
534543
double vMin = geo.getTPCzLength(iRoc) - zMax;
@@ -585,6 +594,12 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
585594
vox.mCx = useSmoothed ? v->DS[o2::tpc::TrackResiduals::ResX] : v->D[o2::tpc::TrackResiduals::ResX];
586595
vox.mCy = useSmoothed ? v->DS[o2::tpc::TrackResiduals::ResY] : v->D[o2::tpc::TrackResiduals::ResY];
587596
vox.mCz = useSmoothed ? v->DS[o2::tpc::TrackResiduals::ResZ] : v->D[o2::tpc::TrackResiduals::ResZ];
597+
if (0 && vox.mNentries < 1) {
598+
vox.mCx = 0.;
599+
vox.mCy = 0.;
600+
vox.mCz = 0.;
601+
vox.mNentries = 1;
602+
}
588603
}
589604
};
590605
processor.Process(myThread);
@@ -711,29 +726,27 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
711726

712727
// feed the row data to the helper
713728

714-
double yMin = 0., yMax = 0.;
729+
double yMin = 0., yMax = 0., zMin = 0.;
730+
731+
auto& info = correction.getSliceRowInfo(iRoc, iRow);
732+
const auto& spline = correction.getSpline(iRoc, iRow);
715733

716734
{
717-
float u, v;
718-
if (iRoc < geo.getNumberOfSlicesA()) {
719-
geo.convScaledUVtoUV(iRoc, iRow, 0., 0., u, v);
720-
} else {
721-
geo.convScaledUVtoUV(iRoc, iRow, 1., 0., u, v);
722-
}
723-
float py, pz;
724-
geo.convUVtoLocal(iRoc, u, v, py, pz);
725-
yMin = py;
726-
}
727-
{
728-
float u, v;
735+
float u0, u1, v0, v1;
736+
correction.convGridToUV(iRoc, iRow, 0., 0., u0, v0);
737+
correction.convGridToUV(iRoc, iRow,
738+
spline.getGridX1().getUmax(), spline.getGridX2().getUmax(), u1, v1);
739+
float y0, y1, z0, z1;
740+
geo.convUVtoLocal(iRoc, u0, v0, y0, z0);
741+
geo.convUVtoLocal(iRoc, u1, v1, y1, z1);
729742
if (iRoc < geo.getNumberOfSlicesA()) {
730-
geo.convScaledUVtoUV(iRoc, iRow, 1., 0., u, v);
743+
yMin = y0;
744+
yMax = y1;
731745
} else {
732-
geo.convScaledUVtoUV(iRoc, iRow, 0., 0., u, v);
746+
yMin = y1;
747+
yMax = y0;
733748
}
734-
float py, pz;
735-
geo.convUVtoLocal(iRoc, u, v, py, pz);
736-
yMax = py;
749+
zMin = z1;
737750
}
738751

739752
double zEdge = 0.;
@@ -759,28 +772,22 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
759772
double correctionY = data.mCy;
760773
double correctionZ = data.mCz;
761774

762-
double yFirst = y - dy / 2.;
763-
double yLast = y + dy / 2.;
775+
double yStep = dy / 2.;
776+
double zStep = dz / 2.;
777+
778+
double yFirst = y;
779+
double yLast = y;
780+
double zFirst = z;
781+
double zLast = z;
764782

765783
if (iy == 0) { // extend value of the first Y bin to the row edge
766784
yFirst = yMin;
785+
yStep = (yLast - yFirst) / 2.;
767786
}
768787

769788
if (iy == nY2Xbins - 1) { // extend value of the last Y bin to the row edge
770789
yLast = yMax;
771-
}
772-
773-
double yStep = (yLast - yFirst) / 2;
774-
775-
double zFirst = z - dz / 2.;
776-
double zLast = z + dz / 2.;
777-
double zStep = (zLast - zFirst) / 2.;
778-
779-
if (0) { // no smoothing
780-
yFirst = y;
781-
yLast = y;
782-
zFirst = z;
783-
zLast = z;
790+
yStep = (yLast - yFirst) / 2.;
784791
}
785792

786793
for (double py = yFirst; py <= yLast + yStep / 2.; py += yStep) {
@@ -790,9 +797,19 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
790797
correctionZ);
791798
}
792799

800+
if (iz == 0) { // extend value of the first Z bin to Z=0.
801+
int nZsteps = 2;
802+
for (int is = 0; is < nZsteps; is++) {
803+
double pz = z + (zMin - z) * (is + 1.) / nZsteps;
804+
double s = 1.; //(nZsteps - 1. - is) / nZsteps;
805+
map.addCorrectionPoint(iRoc, iRow, py, pz, s * correctionX,
806+
s * correctionY, s * correctionZ);
807+
}
808+
}
809+
793810
if (iz == nZ2Xbins - 1) {
794-
// extend value of the first Z bin to the readout, linear decrease of all values to 0.
795-
int nZsteps = 3;
811+
// extend value of the last Z bin to the readout, linear decrease of all values to 0.
812+
int nZsteps = 2;
796813
for (int is = 0; is < nZsteps; is++) {
797814
double pz = z + (zEdge - z) * (is + 1.) / nZsteps;
798815
double s = (nZsteps - 1. - is) / nZsteps;
@@ -803,9 +820,8 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
803820
}
804821
} // iz
805822
} // iy
806-
807-
} // iRow
808-
}; // myThread
823+
} // iRow
824+
}; // myThread
809825

810826
// run n threads
811827

0 commit comments

Comments
 (0)