Skip to content

Commit 095c45e

Browse files
cbmswdavidrohr
authored andcommitted
TPCFastTransform: adjust the test macro to the new code and add test for POD version
1 parent ce3e013 commit 095c45e

1 file changed

Lines changed: 49 additions & 15 deletions

File tree

GPU/TPCFastTransformation/macro/TPCFastTransformInit.C

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

181181
const char* fileName = outFileName;
182182

183-
// fileName = "~/test/master/TPCFastTransform_VoxRes.root";
183+
//fileName = "~/alidock/test/master/TPCFastTransform_VoxRes.root";
184184

185185
std::cout << "load corrections from file " << fileName << std::endl;
186186

@@ -212,6 +212,14 @@ void TPCFastTransformInit(const char* fileName = "debugVoxRes.root", const char*
212212

213213
o2::gpu::TPCFastSpaceChargeCorrection& corr = fastTransform->getCorrection();
214214

215+
aligned_unique_buffer_ptr<TPCFastTransformPOD> podBuffer;
216+
TPCFastTransformPOD* corrPODptr = TPCFastTransformPOD::create(podBuffer, *fastTransform);
217+
218+
if (!corrPODptr) {
219+
throw std::runtime_error("Failed to create TPCFastTransformPOD");
220+
}
221+
const TPCFastTransformPOD& corrPOD = *corrPODptr;
222+
215223
// a debug file with some NTuples
216224

217225
TDirectory* currDir = gDirectory;
@@ -304,24 +312,35 @@ void TPCFastTransformInit(const char* fileName = "debugVoxRes.root", const char*
304312

305313
const o2::gpu::TPCFastTransformGeo& geo = helper->getGeometry();
306314

315+
float maxPodDiff[6] = {0., 0., 0., 0., 0., 0.};
316+
307317
auto getInvCorrections = [&](int iSector, int iRow, float realY, float realZ, float& ix, float& iy, float& iz) {
308318
// get the inverse corrections ix, iy, iz at x,y,z
309-
ix = corr.getCorrectionXatRealYZ(iSector, iRow, realY, realZ);
310-
const auto c = corr.getCorrectionYZatRealYZ(iSector, iRow, realY, realZ);
311-
iy = c[0];
312-
iz = c[1];
319+
ix = corr.getCorrectionXatRealYZ(iSector, iRow, realY, realZ);
320+
corr.getCorrectionYZatRealYZ(iSector, iRow, realY, realZ, iy, iz);
321+
322+
float ixPod = corrPOD.getCorrectionXatRealYZ(iSector, iRow, realY, realZ);
323+
float iyPod, izPod;
324+
corrPOD.getCorrectionYZatRealYZ(iSector, iRow, realY, realZ, iyPod, izPod);
325+
326+
maxPodDiff[3] = std::max(maxPodDiff[3], fabs(ix - ixPod));
327+
maxPodDiff[4] = std::max(maxPodDiff[4], fabs(iy - iyPod));
328+
maxPodDiff[5] = std::max(maxPodDiff[5], fabs(iz - izPod));
313329
};
314330

315331
auto getAllCorrections = [&](int iSector, int iRow, float y, float z, float& cx, float& cy, float& cz, float& ix, float& iy, float& iz) {
316332
// get the corrections cx,cy,cz at x,y,z
317-
const auto c = corr.getCorrectionLocal(iSector, iRow, y, z);
318-
cx = c[0];
319-
cy = c[1];
320-
cz = c[2];
333+
corr.getCorrectionLocal(iSector, iRow, y, z, cx, cy, cz);
321334
getInvCorrections(iSector, iRow, y + cy, z + cz, ix, iy, iz);
335+
336+
float cxPod, cyPod, czPod;
337+
corrPOD.getCorrectionLocal(iSector, iRow, y, z, cxPod, cyPod, czPod);
338+
maxPodDiff[0] = std::max(maxPodDiff[0], fabs(cx - cxPod));
339+
maxPodDiff[1] = std::max(maxPodDiff[1], fabs(cy - cyPod));
340+
maxPodDiff[2] = std::max(maxPodDiff[2], fabs(cz - czPod));
322341
};
323342

324-
for (int direction = 0; direction < 2; direction++) { // 0 - normal, 1 - inverse
343+
for (int direction = 0; direction < 2; direction++) { // 0 - direct, 1 - inverse
325344

326345
std::string directionName = (direction == 0) ? "direct" : "inverse";
327346

@@ -582,15 +601,15 @@ void TPCFastTransformInit(const char* fileName = "debugVoxRes.root", const char*
582601
float correctionY = point.mDy;
583602
float correctionZ = point.mDz;
584603
if (direction == 0) {
585-
auto [cx, cy, cz] =
586-
corr.getCorrectionLocal(iSector, iRow, y, z);
604+
float cx, cy, cz;
605+
corr.getCorrectionLocal(iSector, iRow, y, z, cx, cy, cz);
587606
ntFitPoints->Fill(iSector, iRow, x, y, z, correctionX, correctionY,
588607
correctionZ, cx, cy, cz);
589608
} else {
590609
float cx =
591610
corr.getCorrectionXatRealYZ(iSector, iRow, y, z);
592-
auto [cy, cz] =
593-
corr.getCorrectionYZatRealYZ(iSector, iRow, y, z);
611+
float cy, cz;
612+
corr.getCorrectionYZatRealYZ(iSector, iRow, y, z, cy, cz);
594613
ntInvFitPoints->Fill(iSector, iRow, x, y, z, correctionX, correctionY,
595614
correctionZ, cx, cy, cz);
596615
}
@@ -601,7 +620,9 @@ void TPCFastTransformInit(const char* fileName = "debugVoxRes.root", const char*
601620
for (int32_t i = 0; i < 3; i++) {
602621
sumDiff[i] = sqrt(sumDiff[i]) / nDiff;
603622
}
623+
604624
LOG(info) << directionName << " correction: max and mean differences between spline and voxel corrections:";
625+
605626
LOG(info) << "Max difference in x : " << maxDiff[0] << " at Sector "
606627
<< maxDiffSector[0] << " row " << maxDiffRow[0];
607628

@@ -612,9 +633,22 @@ void TPCFastTransformInit(const char* fileName = "debugVoxRes.root", const char*
612633
<< maxDiffSector[2] << " row " << maxDiffRow[2];
613634

614635
LOG(info) << "Mean difference in x,y,z : " << sumDiff[0] << " " << sumDiff[1]
615-
<< " " << sumDiff[2] << std::endl;
636+
<< " " << sumDiff[2];
637+
638+
LOG(info) << std::endl;
639+
616640
} // direction
617641

642+
LOG(info) << " max difference between POD and original corrections: ";
643+
LOG(info) << " x " << maxPodDiff[0];
644+
LOG(info) << " y " << maxPodDiff[1];
645+
LOG(info) << " z " << maxPodDiff[2];
646+
LOG(info) << " inverse x " << maxPodDiff[3];
647+
LOG(info) << " inverse y " << maxPodDiff[4];
648+
LOG(info) << " inverse z " << maxPodDiff[5];
649+
650+
LOG(info) << std::endl;
651+
618652
corr.testInverse(true);
619653

620654
debugFile->cd();

0 commit comments

Comments
 (0)