17#ifndef ALICEO2_GPU_TPCFastTransformPOD_H
18#define ALICEO2_GPU_TPCFastTransformPOD_H
71 GPUd()
void TransformXYZ(int32_t sector, int32_t
row,
float&
x,
float&
y,
float&
z)
const;
74 GPUd()
void TransformInTimeFrame(int32_t sector, int32_t
row,
float pad,
float time,
float&
x,
float&
y,
float&
z,
float maxTimeBin)
const;
75 GPUd()
void TransformInTimeFrame(int32_t sector,
float time,
float&
z,
float maxTimeBin)
const;
78 GPUd()
void InverseTransformInTimeFrame(int32_t sector, int32_t
row,
float ,
float y,
float z,
float&
pad,
float&
time,
float maxTimeBin)
const;
79 GPUd()
float InverseTransformInTimeFrame(int32_t sector,
float z,
float maxTimeBin)
const;
82 GPUd()
void InverseTransformYZtoX(int32_t sector, int32_t
row,
float y,
float z,
float&
x)
const;
85 GPUd()
void InverseTransformYZtoNominalYZ(int32_t sector, int32_t
row,
float y,
float z,
float&
ny,
float& nz)
const;
88 GPUd()
void InverseTransformXYZtoNominalXYZ(int32_t sector, int32_t
row,
float x,
float y,
float z,
float&
nx,
float&
ny,
float& nz)
const;
95 GPUd()
void convPadTimeToLocalInTimeFrame(int32_t sector, int32_t
row,
float pad,
float time,
float&
y,
float&
z,
float maxTimeBin)
const;
98 GPUd()
void convLocalToPadTimeInTimeFrame(int32_t sector, int32_t
row,
float y,
float z,
float&
pad,
float&
time,
float maxTimeBin)
const;
100 GPUd()
float convTimeToZinTimeFrame(int32_t sector,
float time,
float maxTimeBin)
const;
101 GPUd()
float convZtoTimeInTimeFrame(int32_t sector,
float z,
float maxTimeBin)
const;
102 GPUd()
float convDeltaTimeToDeltaZinTimeFrame(int32_t sector,
float deltaTime)
const;
103 GPUd()
float convDeltaZtoDeltaTimeInTimeFrame(int32_t sector,
float deltaZ)
const;
104 GPUd()
float convDeltaZtoDeltaTimeInTimeFrameAbs(
float deltaZ)
const;
105 GPUd()
float convZOffsetToVertexTime(int32_t sector,
float zOffset,
float maxTimeBin)
const;
126 GPUd()
long int getTimeStamp()
const {
return mTimeStamp; }
150 GPUd()
void setTimeStamp(
long int v) { mTimeStamp =
v; }
170 GPUd()
const float* getCorrectionData(int32_t sector, int32_t
row, int32_t
iSpline = 0)
const {
return reinterpret_cast<const float*
>(getThis() + mSplineDataOffsets[sector][
iSpline] + getRowInfo(
row).dataOffsetBytes[
iSpline]); }
176 GPUd()
const float* getCorrectionDataInvX(int32_t sector, int32_t
row)
const {
return getCorrectionData(sector,
row, 1); }
182 GPUd()
const float* getCorrectionDataInvYZ(int32_t sector, int32_t
row)
const {
return getCorrectionData(sector,
row, 2); }
185 GPUdi()
void getCorrectionLocal(int32_t sector, int32_t
row,
float y,
float z,
float& dx,
float& dy,
float& dz)
const;
194 GPUd()
void TransformLocal(int32_t sector, int32_t
row,
float&
x,
float&
y,
float&
z)
const;
200 GPUd()
void convLocalToGrid(int32_t sector, int32_t
row,
float y,
float z,
float&
u,
float&
v,
float& s)
const;
204 GPUd()
void convGridToLocal(int32_t sector, int32_t
row,
float u,
float v,
float&
y,
float&
z)
const;
208 GPUd()
void convRealLocalToGrid(int32_t sector, int32_t
row,
float y,
float z,
float&
u,
float&
v,
float& s)
const;
212 GPUd()
void convGridToRealLocal(int32_t sector, int32_t
row,
float u,
float v,
float&
y,
float&
z)
const;
214 GPUd()
bool isLocalInsideGrid(int32_t sector, int32_t
row,
float y,
float z)
const;
215 GPUd()
bool isRealLocalInsideGrid(int32_t sector, int32_t
row,
float y,
float z)
const;
217#if !defined(GPUCA_GPUCODE)
227 std::memcpy(destVector.
get(), &
src,
src.size());
228 return destVector.
get();
251#if !defined(GPUCA_GPUCODE)
252 static constexpr size_t AlignmentBytes = 8;
253 static size_t alignOffset(
size_t offs)
255 auto res = offs % AlignmentBytes;
256 return res ? offs + (AlignmentBytes -
res) : offs;
262 GPUd()
const char* getThis()
const {
return reinterpret_cast<const char*
>(
this); }
265 GPUd() size_t getScenarioOffset(
int s)
const {
return (
reinterpret_cast<const size_t*
>(getThis() + mOffsScenariosOffsets))[s]; }
267 GPUd() size_t getFlatBufferOffset(
int s)
const {
return (
reinterpret_cast<const size_t*
>(getThis() + mOffsFlatBufferOffsets))[
s]; }
271 GPUd()
const char* getSplineFlatBuffer(int32_t isc)
const
273 const size_t* offs =
reinterpret_cast<const size_t*
>(getThis() + mOffsFlatBufferOffsets);
274 return getThis() + offs[isc];
280 template <
typename SplineT>
281 GPUd()
const char* getGridX2FlatBuffer(
const SplineT& spline, int32_t isc)
const
283 const size_t g1sz = spline.getGridX1().getFlatBufferSize();
284 const size_t g2align = spline.getGridX2().getBufferAlignmentBytes();
288 bool mApplyCorrection{};
289 int mNumberOfScenarios{};
291 size_t mOffsScenariosOffsets{};
292 size_t mOffsFlatBufferOffsets{};
294 long int mTimeStamp{};
300 TPCFastTransformGeoPOD mGeo;
303 ClassDefNV(TPCFastTransformPOD, 0);
306GPUdi()
void TPCFastTransformPOD::getCorrectionLocal(int32_t sector, int32_t
row,
float y,
float z,
float& dx,
float& dy,
float& dz)
const
308 const auto&
info = getRowInfo(
row);
309 const int32_t isc =
info.splineScenarioID;
310 const SplineType& spline = getSplineForRow(
row);
311 const float* splineData = getCorrectionData(sector,
row);
314 convLocalToGrid(sector,
row,
y,
z, u,
v, s);
316 const char* g1buf = getSplineFlatBuffer(isc);
317 const char* g2buf = getGridX2FlatBuffer(spline, isc);
320 spline.interpolateAtUZeroCopy(g1buf, g2buf, splineData, u,
v, dxyz);
322 if (CAMath::Abs(dxyz[0]) > TPCFastSpaceChargeCorrection::kMaxCorrection || CAMath::Abs(dxyz[1]) > TPCFastSpaceChargeCorrection::kMaxCorrection || CAMath::Abs(dxyz[2]) > TPCFastSpaceChargeCorrection::kMaxCorrection) {
331GPUdi() float TPCFastTransformPOD::getCorrectionXatRealYZ(int32_t sector, int32_t
row,
float realY,
float realZ)
const
333 const auto&
info = getRowInfo(
row);
335 convRealLocalToGrid(sector,
row, realY, realZ, u,
v, s);
337 const int32_t isc =
info.splineScenarioID;
338 const auto& spline = getSplineInvXforRow(
row);
339 const char* g1buf = getSplineFlatBuffer(isc);
340 const char* g2buf = getGridX2FlatBuffer(spline, isc);
343 spline.interpolateAtUZeroCopy(g1buf, g2buf, getCorrectionDataInvX(sector,
row), u,
v, &dx);
344 if (CAMath::Abs(dx) > TPCFastSpaceChargeCorrection::kMaxCorrection) {
351GPUdi()
void TPCFastTransformPOD::getCorrectionYZatRealYZ(int32_t sector, int32_t
row,
float realY,
float realZ,
float&
y,
float&
z)
const
354 convRealLocalToGrid(sector,
row, realY, realZ, u,
v, s);
355 const auto&
info = getRowInfo(
row);
356 const int32_t isc =
info.splineScenarioID;
357 const auto& spline = getSplineInvYZforRow(
row);
358 const char* g1buf = getSplineFlatBuffer(isc);
359 const char* g2buf = getGridX2FlatBuffer(spline, isc);
362 spline.interpolateAtUZeroCopy(g1buf, g2buf, getCorrectionDataInvYZ(sector,
row), u,
v, dyz);
363 if (CAMath::Abs(dyz[0]) > TPCFastSpaceChargeCorrection::kMaxCorrection || CAMath::Abs(dyz[1]) > TPCFastSpaceChargeCorrection::kMaxCorrection) {
370GPUdi()
void TPCFastTransformPOD::convLocalToGrid(int32_t sector, int32_t
row,
float y,
float z,
float& u,
float&
v,
float& s)
const
374 const SplineType& spline = getSplineForRow(
row);
375 getRowInfo(
row).gridMeasured.convLocalToGridUntruncated(sector,
y,
z, u,
v, s);
377 u = GPUCommonMath::Clamp(u, 0.f, (
float)spline.getGridX1().getUmax());
378 v = GPUCommonMath::Clamp(
v, 0.f, (
float)spline.getGridX2().getUmax());
381GPUdi()
void TPCFastTransformPOD::convGridToLocal(int32_t sector, int32_t
row,
float gridU,
float gridV,
float&
y,
float&
z)
const
384 getRowInfo(
row).gridMeasured.convGridToLocal(sector, gridU, gridV,
y,
z);
387GPUdi()
void TPCFastTransformPOD::convRealLocalToGrid(int32_t sector, int32_t
row,
float y,
float z,
float& u,
float&
v,
float& s)
const
390 const SplineType& spline = getSplineForRow(
row);
391 getRowInfo(
row).gridReal.convLocalToGridUntruncated(sector,
y,
z, u,
v, s);
393 u = GPUCommonMath::Clamp(u, 0.f, (
float)spline.getGridX1().getUmax());
394 v = GPUCommonMath::Clamp(
v, 0.f, (
float)spline.getGridX2().getUmax());
397GPUdi()
void TPCFastTransformPOD::convGridToRealLocal(int32_t sector, int32_t
row,
float gridU,
float gridV,
float&
y,
float&
z)
const
400 getRowInfo(
row).gridReal.convGridToLocal(sector, gridU, gridV,
y,
z);
403GPUdi() bool TPCFastTransformPOD::isLocalInsideGrid(int32_t sector, int32_t
row,
float y,
float z)
const
407 getRowInfo(
row).gridMeasured.convLocalToGridUntruncated(sector,
y,
z, u,
v, s);
408 const auto& spline = getSplineForRow(
row);
410 if (u < 0.f || u > (
float)spline.getGridX1().getUmax() ||
411 v < 0.f || v > (
float)spline.getGridX2().getUmax()) {
417GPUdi() bool TPCFastTransformPOD::isRealLocalInsideGrid(int32_t sector, int32_t
row,
float y,
float z)
const
421 getRowInfo(
row).gridReal.convLocalToGridUntruncated(sector,
y,
z, u,
v, s);
422 const auto& spline = getSplineForRow(
row);
424 if (u < 0.f || u > (
float)spline.getGridX1().getUmax() ||
425 v < 0.f || v > (
float)spline.getGridX2().getUmax()) {
431GPUdi()
void TPCFastTransformPOD::TransformLocal(int32_t sector, int32_t
row,
float&
x,
float&
y,
float&
z)
const
433 if (!mApplyCorrection) {
437 getCorrectionLocal(sector,
row,
y,
z, dx, dy, dz);
440 float lx =
x, ly =
y, lz =
z;
442 getGeometry().convLocalToGlobal(sector, lx, ly, lz, gx, gy, gz);
447 InverseTransformYZtoX(sector,
row, lyT, lzT, invYZtoX);
451 InverseTransformYZtoNominalYZ(sector,
row, lyT, lzT, YZtoNominalY, YZtoNominalZ);
453 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_Transform").data()
459 <<
"sector=" << sector
473 <<
"invYZtoX=" << invYZtoX
474 <<
"YZtoNominalY=" << YZtoNominalY
475 <<
"YZtoNominalZ=" << YZtoNominalZ
484GPUdi()
void TPCFastTransformPOD::Transform(int32_t sector, int32_t
row,
float pad,
float time,
float&
x,
float&
y,
float&
z,
float vertexTime)
const
492 x = getGeometry().getRowInfoX(
row);
493 convPadTimeToLocal(sector,
row, pad,
time,
y,
z, vertexTime);
494 TransformLocal(sector,
row,
x,
y,
z);
497GPUdi()
void TPCFastTransformPOD::TransformXYZ(int32_t sector, int32_t
row,
float&
x,
float&
y,
float&
z)
const
500 TransformLocal(sector,
row,
x,
y,
z);
503GPUdi()
void TPCFastTransformPOD::TransformInTimeFrame(int32_t sector,
float time,
float&
z,
float maxTimeBin)
const
505 float l = (
time - mT0 - maxTimeBin) * mVdrift;
506 z = getGeometry().convDriftLengthToZ(sector, l);
509GPUdi()
void TPCFastTransformPOD::TransformInTimeFrame(int32_t sector, int32_t
row,
float pad,
float time,
float&
x,
float&
y,
float&
z,
float maxTimeBin)
const
517 x = getGeometry().getRowInfoX(
row);
518 convPadTimeToLocalInTimeFrame(sector,
row, pad,
time,
y,
z, maxTimeBin);
521GPUdi()
void TPCFastTransformPOD::InverseTransformInTimeFrame(int32_t sector, int32_t
row,
float ,
float y,
float z,
float& pad,
float&
time,
float maxTimeBin)
const
524 convLocalToPadTimeInTimeFrame(sector,
row,
y,
z, pad,
time, maxTimeBin);
527GPUdi() float TPCFastTransformPOD::InverseTransformInTimeFrame(int32_t sector,
float z,
float maxTimeBin)
const
530 InverseTransformInTimeFrame(sector, 0, 0, 0,
z, pad,
time, maxTimeBin);
534GPUdi()
void TPCFastTransformPOD::TransformIdealZ(int32_t sector,
float time,
float&
z,
float vertexTime)
const
543 float l = (
time - mT0 - vertexTime) * mVdrift;
544 z = getGeometry().convDriftLengthToZ(sector, l);
547GPUdi()
void TPCFastTransformPOD::TransformIdeal(int32_t sector, int32_t
row,
float pad,
float time,
float&
x,
float&
y,
float&
z,
float vertexTime)
const
556 x = getGeometry().getRowInfoX(
row);
557 float driftLength = (
time - mT0 - vertexTime) * mVdrift;
558 getGeometry().convPadDriftLengthToLocal(sector,
row, pad, driftLength,
y,
z);
561GPUdi() float TPCFastTransformPOD::convTimeToZinTimeFrame(int32_t sector,
float time,
float maxTimeBin)
const
570 float v = (
time - mT0 - maxTimeBin) * mVdrift;
571 float z = (sector < getGeometry().getNumberOfSectorsA()) ? -
v :
v;
575GPUdi() float TPCFastTransformPOD::convZtoTimeInTimeFrame(int32_t sector,
float z,
float maxTimeBin)
const
578 float v = (sector < getGeometry().getNumberOfSectorsA()) ? -
z :
z;
579 return mT0 + maxTimeBin +
v / mVdrift;
582GPUdi() float TPCFastTransformPOD::convDeltaTimeToDeltaZinTimeFrame(int32_t sector,
float deltaTime)
const
584 float deltaZ = deltaTime * mVdrift;
585 return sector < getGeometry().getNumberOfSectorsA() ? -deltaZ : deltaZ;
588GPUdi() float TPCFastTransformPOD::convDeltaZtoDeltaTimeInTimeFrameAbs(
float deltaZ)
const
590 return deltaZ / mVdrift;
593GPUdi() float TPCFastTransformPOD::convDeltaZtoDeltaTimeInTimeFrame(int32_t sector,
float deltaZ)
const
595 float deltaT = deltaZ / mVdrift;
596 return sector < getGeometry().getNumberOfSectorsA() ? -deltaT : deltaT;
599GPUdi() float TPCFastTransformPOD::getMaxDriftTime(int32_t sector, int32_t
row,
float pad)
const
602 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
605GPUdi() float TPCFastTransformPOD::getMaxDriftTime(int32_t sector, int32_t
row)
const
608 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
611GPUdi() float TPCFastTransformPOD::getMaxDriftTime(int32_t sector)
const
614 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
617GPUdi()
void TPCFastTransformPOD::InverseTransformYZtoX(int32_t sector, int32_t
row,
float realY,
float realZ,
float& realX)
const
621 dx = getCorrectionXatRealYZ(sector,
row, realY, realZ);
622 realX = getGeometry().getRowInfoX(
row) + dx;
625 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_InverseTransformYZtoX").data()
626 <<
"sector=" << sector
635GPUdi()
void TPCFastTransformPOD::InverseTransformYZtoNominalYZ(int32_t sector, int32_t
row,
float realY,
float realZ,
float& measuredY,
float& measuredZ)
const
639 getCorrectionYZatRealYZ(sector,
row, realY, realZ, dy, dz);
640 measuredY = realY - dy;
641 measuredZ = realZ - dz;
644 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_InverseTransformYZtoNominalYZ").data()
645 <<
"sector=" << sector
647 <<
"real y=" << realY
648 <<
"real z=" << realZ
649 <<
"measured y=" << measuredY
650 <<
"measured z=" << measuredZ
655GPUdi()
void TPCFastTransformPOD::convPadTimeToLocal(int32_t sector, int32_t
row,
float pad,
float time,
float&
y,
float&
z,
float vertexTime)
const
657 float l = (
time - mT0 - vertexTime) * mVdrift;
658 getGeometry().convPadDriftLengthToLocal(sector,
row, pad, l,
y,
z);
661GPUdi()
void TPCFastTransformPOD::convPadTimeToLocalInTimeFrame(int32_t sector, int32_t
row,
float pad,
float time,
float&
y,
float&
z,
float maxTimeBin)
const
663 float l = getGeometry().getTPCzLength() + (
time - mT0 - maxTimeBin) * mVdrift;
664 getGeometry().convPadDriftLengthToLocal(sector,
row, pad, l,
y,
z);
667GPUdi()
void TPCFastTransformPOD::convLocalToPadTimeInTimeFrame(int32_t sector, int32_t
row,
float y,
float z,
float& pad,
float&
time,
float maxTimeBin)
const
670 getGeometry().convLocalToPadDriftLength(sector,
row,
y,
z, pad,
length);
671 time = convDriftLengthToTime(
length, maxTimeBin);
674GPUdi() float TPCFastTransformPOD::convDriftLengthToTime(
float driftLength,
float vertexTime)
const
676 return (mT0 + vertexTime + driftLength / mVdrift);
679GPUdi() float TPCFastTransformPOD::convZOffsetToVertexTime(int32_t sector,
float zOffset,
float maxTimeBin)
const
681 if (sector < getGeometry().getNumberOfSectorsA()) {
682 return maxTimeBin - (getGeometry().getTPCzLength() + zOffset) / mVdrift;
684 return maxTimeBin - (getGeometry().getTPCzLength() - zOffset) / mVdrift;
688GPUdi() float TPCFastTransformPOD::convVertexTimeToZOffset(int32_t sector,
float vertexTime,
float maxTimeBin)
const
690 if (sector < getGeometry().getNumberOfSectorsA()) {
691 return (maxTimeBin - vertexTime) * mVdrift - getGeometry().getTPCzLength();
693 return -((maxTimeBin - vertexTime) * mVdrift - getGeometry().getTPCzLength());
697#ifndef GPUCA_GPUCODE_DEVICE
698GPUdi()
void TPCFastTransformPOD::setCalibration(
int64_t timeStamp,
float t0,
float vDrift)
700 mTimeStamp = timeStamp;
705GPUdi()
void TPCFastTransformPOD::InverseTransformXYZtoNominalXYZ(int32_t sector, int32_t
row,
float x,
float y,
float z,
float& nx,
float& ny,
float& nz)
const
708 int32_t row2 =
row + 1;
709 if (row2 >= getGeometry().getNumberOfRows()) {
714 nx1 = getGeometry().getRowInfoX(
row);
715 nx2 = getGeometry().getRowInfoX(row2);
716 InverseTransformYZtoNominalYZ(sector,
row,
y,
z, ny1, nz1);
717 InverseTransformYZtoNominalYZ(sector, row2,
y,
z, ny2, nz2);
718 float c1 = (nx2 - nx) / (nx2 - nx1);
719 float c2 = (nx - nx1) / (nx2 - nx1);
721 ny = (ny1 * c1 + ny2 * c2);
722 nz = (nz1 * c1 + nz2 * c2);
#define GPUCA_DEBUG_STREAMER_CHECK(...)
static constexpr size_t alignSize(size_t sizeBytes, size_t alignmentBytes)
_______________ Generic utilities _______________________________________________
Forward declaration — specializations below select ClassDefNV based on FlatBase.
SlimSplineTypeXYZ SlimSplineType
Spline2D< float, 2, NoFlatObject > SlimSplineTypeInvYZ
Spline2D< float, 3, NoFlatObject > SlimSplineTypeXYZ
Slim variants (NoFlatObject base) for use in TPCFastTransformPOD.
Spline2D< float, 1, NoFlatObject > SlimSplineTypeInvX
GLuint GLsizei GLsizei * length
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
GLdouble GLdouble GLdouble z
constexpr unsigned int NROWS
@ streamFastTransform
stream tpc fast transform
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...