Skip to content

Commit 7d39c18

Browse files
cbmswdavidrohr
authored andcommitted
TPCFastTransform: reduce the metadata: the same spline setup for all the sectors
1 parent 8fe64f3 commit 7d39c18

8 files changed

Lines changed: 244 additions & 276 deletions

Detectors/TPC/calibration/src/TPCFastSpaceChargeCorrectionHelper.cxx

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ void TPCFastSpaceChargeCorrectionHelper::fillSpaceChargeCorrectionFromMap(TPCFas
137137
auto myThread = [&](int iThread) {
138138
for (int row = iThread; row < correction.getGeometry().getNumberOfRows(); row += mNthreads) {
139139

140-
TPCFastSpaceChargeCorrection::SplineType& spline = correction.getSpline(sector, row);
140+
TPCFastSpaceChargeCorrection::SplineType& spline = correction.getSplineForRow(row);
141141
Spline2DHelper<float> helper;
142142
std::vector<float> splineParameters;
143143
splineParameters.resize(spline.getNumberOfParameters());
@@ -256,14 +256,12 @@ std::unique_ptr<TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrectionHelper
256256
correction.startConstruction(mGeo, nCorrectionScenarios);
257257

258258
// assign spline type for TPC rows
259-
for (int sector = 0; sector < mGeo.getNumberOfSectors(); sector++) {
260-
for (int row = 0; row < mGeo.getNumberOfRows(); row++) {
261-
int scenario = row / 10;
262-
if (scenario >= nCorrectionScenarios) {
263-
scenario = nCorrectionScenarios - 1;
264-
}
265-
correction.setRowScenarioID(sector, row, scenario);
259+
for (int row = 0; row < mGeo.getNumberOfRows(); row++) {
260+
int scenario = row / 10;
261+
if (scenario >= nCorrectionScenarios) {
262+
scenario = nCorrectionScenarios - 1;
266263
}
264+
correction.setRowScenarioID(row, scenario);
267265
}
268266

269267
for (int scenario = 0; scenario < nCorrectionScenarios; scenario++) {
@@ -473,47 +471,41 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
473471

474472
{ // create the correction object
475473

476-
const int nCorrectionScenarios = 2; // different grids for TPC A and TPC C sides
474+
const int nCorrectionScenarios = 1;
477475

478476
correction.startConstruction(geo, nCorrectionScenarios);
479477

480478
// init rows
481-
for (int iSector = 0; iSector < nSectors; iSector++) {
482-
int id = iSector < geo.getNumberOfSectorsA() ? 0 : 1;
483-
for (int row = 0; row < geo.getNumberOfRows(); row++) {
484-
correction.setRowScenarioID(iSector, row, id);
485-
}
479+
for (int row = 0; row < geo.getNumberOfRows(); row++) {
480+
correction.setRowScenarioID(row, 0);
486481
}
482+
487483
{ // init spline scenario
488484
TPCFastSpaceChargeCorrection::SplineType spline;
489485
spline.recreate(nKnotsY, &yKnotsInt[0], nKnotsZ, &zKnotsInt[0]);
490486
correction.setSplineScenario(0, spline);
491-
spline.recreate(nKnotsY, &yKnotsInt[0], nKnotsZ, &zKnotsInt[0]);
492-
correction.setSplineScenario(1, spline);
493487
}
494488
correction.finishConstruction();
495489
} // .. create the correction object
496490

497491
// set the grid borders
498-
for (int iSector = 0; iSector < geo.getNumberOfSectors(); iSector++) {
499-
for (int iRow = 0; iRow < geo.getNumberOfRows(); iRow++) {
500-
auto& info = correction.getSectorRowInfo(iSector, iRow);
501-
const auto& spline = correction.getSpline(iSector, iRow);
502-
double rowX = geo.getRowInfo(iRow).x;
503-
double yMin = rowX * trackResiduals.getY2X(iRow, 0);
504-
double yMax = rowX * trackResiduals.getY2X(iRow, trackResiduals.getNY2XBins() - 1);
505-
double zMin = rowX * trackResiduals.getZ2X(0);
506-
double zMax = rowX * trackResiduals.getZ2X(trackResiduals.getNZ2XBins() - 1);
507-
double zOut = zMax;
508-
info.gridMeasured.set(yMin, spline.getGridX1().getUmax() / (yMax - yMin), // y
509-
zMin, spline.getGridX2().getUmax() / (zMax - zMin), // z
510-
zOut, geo.getTPCzLength()); // correction scaling region
511-
512-
info.gridReal = info.gridMeasured;
513-
514-
// std::cout << " iSector " << iSector << " iRow " << iRow << " uMin: " << uMin << " uMax: " << uMax << " vMin: " << vMin << " vMax: " << vMax
515-
//<< " grid scale u "<< info.scaleUtoGrid << " grid scale v "<< info.scaleVtoGrid<< std::endl;
516-
}
492+
for (int iRow = 0; iRow < geo.getNumberOfRows(); iRow++) {
493+
auto& info = correction.getRowInfo(iRow);
494+
const auto& spline = correction.getSplineForRow(iRow);
495+
double rowX = geo.getRowInfo(iRow).x;
496+
double yMin = rowX * trackResiduals.getY2X(iRow, 0);
497+
double yMax = rowX * trackResiduals.getY2X(iRow, trackResiduals.getNY2XBins() - 1);
498+
double zMin = rowX * trackResiduals.getZ2X(0);
499+
double zMax = rowX * trackResiduals.getZ2X(trackResiduals.getNZ2XBins() - 1);
500+
double zOut = zMax;
501+
info.gridMeasured.set(yMin, spline.getGridX1().getUmax() / (yMax - yMin), // y
502+
zMin, spline.getGridX2().getUmax() / (zMax - zMin), // z
503+
zOut, geo.getTPCzLength()); // correction scaling region
504+
505+
info.gridReal = info.gridMeasured;
506+
507+
// std::cout << " iSector " << iSector << " iRow " << iRow << " uMin: " << uMin << " uMax: " << uMax << " vMin: " << vMin << " vMax: " << vMax
508+
//<< " grid scale u "<< info.scaleUtoGrid << " grid scale v "<< info.scaleVtoGrid<< std::endl;
517509
}
518510

519511
LOG(info) << "fast space charge correction helper: preparation took " << watch1.RealTime() << "s";
@@ -765,8 +757,8 @@ std::unique_ptr<o2::gpu::TPCFastSpaceChargeCorrection> TPCFastSpaceChargeCorrect
765757

766758
// feed the row data to the helper
767759

768-
auto& info = correction.getSectorRowInfo(iSector, iRow);
769-
const auto& spline = correction.getSpline(iSector, iRow);
760+
auto& info = correction.getRowInfo(iRow);
761+
const auto& spline = correction.getSplineForRow(iRow);
770762

771763
auto addVoxel = [&](int iy, int iz, double weight) {
772764
auto& vox = vRowVoxels[iy * nZ2Xbins + iz];
@@ -910,6 +902,11 @@ void TPCFastSpaceChargeCorrectionHelper::initInverse(std::vector<o2::gpu::TPCFas
910902
tpcR2max = tpcR2max / cos(2 * M_PI / mGeo.getNumberOfSectorsA() / 2) + 1.;
911903
tpcR2max = tpcR2max * tpcR2max;
912904

905+
for (int row = 0; row < mGeo.getNumberOfRows(); row++) {
906+
auto& rowInfo = correction.getRowInfo(row);
907+
rowInfo.gridReal = rowInfo.gridMeasured;
908+
}
909+
913910
for (int sector = 0; sector < mGeo.getNumberOfSectors(); sector++) {
914911
// LOG(info) << "inverse transform for sector " << sector ;
915912

@@ -918,10 +915,9 @@ void TPCFastSpaceChargeCorrectionHelper::initInverse(std::vector<o2::gpu::TPCFas
918915
std::vector<float> splineParameters;
919916

920917
for (int row = iThread; row < mGeo.getNumberOfRows(); row += mNthreads) {
921-
auto& sectorRowInfo = correction.getSectorRowInfo(sector, row);
922-
sectorRowInfo.gridReal = sectorRowInfo.gridMeasured;
918+
auto& rowInfo = correction.getRowInfo(row);
923919

924-
TPCFastSpaceChargeCorrection::SplineType spline = correction.getSpline(sector, row);
920+
TPCFastSpaceChargeCorrection::SplineType spline = correction.getSplineForRow(row);
925921
helper.setSpline(spline, 10, 10);
926922

927923
std::vector<double> gridU;
@@ -1032,14 +1028,13 @@ void TPCFastSpaceChargeCorrectionHelper::mergeCorrections(
10321028

10331029
auto myThread = [&](int iThread) {
10341030
for (int row = iThread; row < geo.getNumberOfRows(); row += mNthreads) {
1035-
const auto& spline = mainCorrection.getSpline(sector, row);
1031+
auto& rowInfo = mainCorrection.getRowInfo(row);
1032+
const auto& spline = mainCorrection.getSplineForRow(row);
10361033

10371034
float* splineParameters = mainCorrection.getCorrectionData(sector, row);
10381035
float* splineParametersInvX = mainCorrection.getCorrectionDataInvX(sector, row);
10391036
float* splineParametersInvYZ = mainCorrection.getCorrectionDataInvYZ(sector, row);
10401037

1041-
auto& secRowInfo = mainCorrection.getSectorRowInfo(sector, row);
1042-
10431038
constexpr int nKnotPar1d = 4;
10441039
constexpr int nKnotPar2d = nKnotPar1d * 2;
10451040
constexpr int nKnotPar3d = nKnotPar1d * 3;
@@ -1078,12 +1073,12 @@ void TPCFastSpaceChargeCorrectionHelper::mergeCorrections(
10781073
for (int icorr = 0; icorr < additionalCorrections.size(); ++icorr) {
10791074
const auto& corr = *(additionalCorrections[icorr].first);
10801075
double scale = additionalCorrections[icorr].second;
1081-
auto& linfo = corr.getSectorRowInfo(sector, row);
1076+
auto& linfo = corr.getRowInfo(row);
10821077

1083-
double scaleU = secRowInfo.gridMeasured.getYscale() / linfo.gridMeasured.getYscale();
1084-
double scaleV = secRowInfo.gridMeasured.getZscale() / linfo.gridMeasured.getZscale();
1085-
double scaleRealU = secRowInfo.gridReal.getYscale() / linfo.gridReal.getYscale();
1086-
double scaleRealV = secRowInfo.gridReal.getZscale() / linfo.gridReal.getZscale();
1078+
double scaleU = rowInfo.gridMeasured.getYscale() / linfo.gridMeasured.getYscale();
1079+
double scaleV = rowInfo.gridMeasured.getZscale() / linfo.gridMeasured.getZscale();
1080+
double scaleRealU = rowInfo.gridReal.getYscale() / linfo.gridReal.getYscale();
1081+
double scaleRealV = rowInfo.gridReal.getZscale() / linfo.gridReal.getZscale();
10871082

10881083
for (int iu = 0; iu < gridU.getNumberOfKnots(); iu++) {
10891084
double u = gridU.getKnot(iu).u;
@@ -1100,7 +1095,7 @@ void TPCFastSpaceChargeCorrectionHelper::mergeCorrections(
11001095
corr.convLocalToGrid(sector, row, y, z, lu, lv, ls);
11011096
ls *= scale;
11021097
double parscale[4] = {ls, ls * scaleU, ls * scaleV, ls * ls * scaleU * scaleV};
1103-
const auto& spl = corr.getSpline(sector, row);
1098+
const auto& spl = corr.getSplineForRow(row);
11041099
spl.interpolateParametersAtU(corr.getCorrectionData(sector, row), lu, lv, P);
11051100
for (int ipar = 0, ind = 0; ipar < nKnotPar1d; ++ipar) {
11061101
for (int idim = 0; idim < 3; idim++, ind++) {
@@ -1118,7 +1113,7 @@ void TPCFastSpaceChargeCorrectionHelper::mergeCorrections(
11181113
double parscale[4] = {ls, ls * scaleRealU, ls * scaleRealV, ls * ls * scaleRealU * scaleRealV};
11191114

11201115
{ // inverse X correction
1121-
corr.getSplineInvX(sector, row).interpolateParametersAtU(corr.getCorrectionDataInvX(sector, row), lu, lv, P);
1116+
corr.getSplineInvXforRow(row).interpolateParametersAtU(corr.getCorrectionDataInvX(sector, row), lu, lv, P);
11221117
for (int ipar = 0, ind = 0; ipar < nKnotPar1d; ++ipar) {
11231118
for (int idim = 0; idim < 1; idim++, ind++) {
11241119
splineParametersInvX[knotIndex * nKnotPar1d + ind] += parscale[ipar] * P[ind];
@@ -1127,7 +1122,7 @@ void TPCFastSpaceChargeCorrectionHelper::mergeCorrections(
11271122
}
11281123

11291124
{ // inverse YZ correction
1130-
corr.getSplineInvYZ(sector, row).interpolateParametersAtU(corr.getCorrectionDataInvYZ(sector, row), lu, lv, P);
1125+
corr.getSplineInvYZforRow(row).interpolateParametersAtU(corr.getCorrectionDataInvYZ(sector, row), lu, lv, P);
11311126
for (int ipar = 0, ind = 0; ipar < nKnotPar1d; ++ipar) {
11321127
for (int idim = 0; idim < 2; idim++, ind++) {
11331128
splineParametersInvYZ[knotIndex * nKnotPar2d + ind] += parscale[ipar] * P[ind];

GPU/TPCFastTransformation/CorrectionMapsHelper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class CorrectionMapsHelper
122122
{
123123
if (mCorrMapMShape) {
124124
// just check for the first spline the number of knots which are 4 in case of default spline object
125-
return mCorrMapMShape->getCorrection().getSpline(0, 0).getNumberOfKnots() == 4;
125+
return mCorrMapMShape->getCorrection().getSplineForRow(0).getNumberOfKnots() == 4;
126126
}
127127
return true;
128128
}

0 commit comments

Comments
 (0)