17#ifndef ALICEO2_GPU_TPCFastTransformPOD_H
18#define ALICEO2_GPU_TPCFastTransformPOD_H
69 GPUd()
void TransformXYZ(int32_t sector, int32_t
row,
float&
x,
float&
y,
float&
z)
const;
72 GPUd()
void TransformInTimeFrame(int32_t sector, int32_t
row,
float pad,
float time,
float&
x,
float&
y,
float&
z,
float maxTimeBin)
const;
73 GPUd()
void TransformInTimeFrame(int32_t sector,
float time,
float&
z,
float maxTimeBin)
const;
76 GPUd()
void InverseTransformInTimeFrame(int32_t sector, int32_t
row,
float ,
float y,
float z,
float&
pad,
float&
time,
float maxTimeBin)
const;
77 GPUd()
float InverseTransformInTimeFrame(int32_t sector,
float z,
float maxTimeBin)
const;
80 GPUd()
void InverseTransformYZtoX(int32_t sector, int32_t
row,
float y,
float z,
float&
x)
const;
83 GPUd()
void InverseTransformYZtoNominalYZ(int32_t sector, int32_t
row,
float y,
float z,
float&
ny,
float& nz)
const;
86 GPUd()
void InverseTransformXYZtoNominalXYZ(int32_t sector, int32_t
row,
float x,
float y,
float z,
float&
nx,
float&
ny,
float& nz)
const;
93 GPUd()
void convPadTimeToLocalInTimeFrame(int32_t sector, int32_t
row,
float pad,
float time,
float&
y,
float&
z,
float maxTimeBin)
const;
96 GPUd()
void convLocalToPadTimeInTimeFrame(int32_t sector, int32_t
row,
float y,
float z,
float&
pad,
float&
time,
float maxTimeBin)
const;
98 GPUd()
float convTimeToZinTimeFrame(int32_t sector,
float time,
float maxTimeBin)
const;
99 GPUd()
float convZtoTimeInTimeFrame(int32_t sector,
float z,
float maxTimeBin)
const;
100 GPUd()
float convDeltaTimeToDeltaZinTimeFrame(int32_t sector,
float deltaTime)
const;
101 GPUd()
float convDeltaZtoDeltaTimeInTimeFrame(int32_t sector,
float deltaZ)
const;
102 GPUd()
float convDeltaZtoDeltaTimeInTimeFrameAbs(
float deltaZ)
const;
103 GPUd()
float convZOffsetToVertexTime(int32_t sector,
float zOffset,
float maxTimeBin)
const;
124 GPUd()
long int getTimeStamp()
const {
return mTimeStamp; }
148 GPUd()
void setTimeStamp(
long int v) { mTimeStamp =
v; }
168 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]); }
174 GPUd()
const float* getCorrectionDataInvX(int32_t sector, int32_t
row)
const {
return getCorrectionData(sector,
row, 1); }
180 GPUd()
const float* getCorrectionDataInvYZ(int32_t sector, int32_t
row)
const {
return getCorrectionData(sector,
row, 2); }
183 GPUdi()
void getCorrectionLocal(int32_t sector, int32_t
row,
float y,
float z,
float& dx,
float& dy,
float& dz)
const;
192 GPUd()
void TransformLocal(int32_t sector, int32_t
row,
float&
x,
float&
y,
float&
z)
const;
198 GPUd()
void convLocalToGrid(int32_t sector, int32_t
row,
float y,
float z,
float&
u,
float&
v,
float& s)
const;
202 GPUd()
void convGridToLocal(int32_t sector, int32_t
row,
float u,
float v,
float&
y,
float&
z)
const;
206 GPUd()
void convRealLocalToGrid(int32_t sector, int32_t
row,
float y,
float z,
float&
u,
float&
v,
float& s)
const;
210 GPUd()
void convGridToRealLocal(int32_t sector, int32_t
row,
float u,
float v,
float&
y,
float&
z)
const;
212 GPUd()
bool isLocalInsideGrid(int32_t sector, int32_t
row,
float y,
float z)
const;
213 GPUd()
bool isRealLocalInsideGrid(int32_t sector, int32_t
row,
float y,
float z)
const;
215#if !defined(GPUCA_GPUCODE)
225 std::memcpy(destVector.
get(), &
src,
src.size());
226 return destVector.
get();
243 static constexpr
int NROWS =
o2::tpc::constants::MAXGLOBALPADROW;
244 static constexpr
int NSECTORS =
o2::tpc::constants::MAXSECTOR;
245 static constexpr
int NSECTORSA =
o2::tpc::constants::MAXSECTOR / 2;
249#if !defined(GPUCA_GPUCODE)
250 static constexpr size_t AlignmentBytes = 8;
251 static size_t alignOffset(
size_t offs)
253 auto res = offs % AlignmentBytes;
254 return res ? offs + (AlignmentBytes -
res) : offs;
260 GPUd()
const char* getThis()
const {
return reinterpret_cast<const char*
>(
this); }
263 GPUd() size_t getScenarioOffset(
int s)
const {
return (
reinterpret_cast<const size_t*
>(getThis() + mOffsScenariosOffsets))[s]; }
265 GPUd() size_t getFlatBufferOffset(
int s)
const {
return (
reinterpret_cast<const size_t*
>(getThis() + mOffsFlatBufferOffsets))[
s]; }
269 GPUd()
const char* getSplineFlatBuffer(int32_t isc)
const
271 const size_t* offs =
reinterpret_cast<const size_t*
>(getThis() + mOffsFlatBufferOffsets);
272 return getThis() + offs[isc];
278 template <
typename SplineT>
279 GPUd()
const char* getGridX2FlatBuffer(
const SplineT& spline, int32_t isc)
const
281 const size_t g1sz = spline.getGridX1().getFlatBufferSize();
282 const size_t g2align = spline.getGridX2().getBufferAlignmentBytes();
286 bool mApplyCorrection{};
287 int mNumberOfScenarios{};
289 size_t mOffsScenariosOffsets{};
290 size_t mOffsFlatBufferOffsets{};
292 long int mTimeStamp{};
298 TPCFastTransformGeoPOD mGeo;
301 ClassDefNV(TPCFastTransformPOD, 0);
304GPUdi()
void TPCFastTransformPOD::getCorrectionLocal(int32_t sector, int32_t
row,
float y,
float z,
float& dx,
float& dy,
float& dz)
const
306 const auto&
info = getRowInfo(
row);
307 const int32_t isc =
info.splineScenarioID;
308 const SplineType& spline = getSplineForRow(
row);
309 const float* splineData = getCorrectionData(sector,
row);
312 convLocalToGrid(sector,
row,
y,
z, u,
v, s);
314 const char* g1buf = getSplineFlatBuffer(isc);
315 const char* g2buf = getGridX2FlatBuffer(spline, isc);
318 spline.interpolateAtUZeroCopy(g1buf, g2buf, splineData, u,
v, dxyz);
320 if (CAMath::Abs(dxyz[0]) > TPCFastSpaceChargeCorrection::kMaxCorrection || CAMath::Abs(dxyz[1]) > TPCFastSpaceChargeCorrection::kMaxCorrection || CAMath::Abs(dxyz[2]) > TPCFastSpaceChargeCorrection::kMaxCorrection) {
329GPUdi() float TPCFastTransformPOD::getCorrectionXatRealYZ(int32_t sector, int32_t
row,
float realY,
float realZ)
const
331 const auto&
info = getRowInfo(
row);
333 convRealLocalToGrid(sector,
row, realY, realZ, u,
v, s);
335 const int32_t isc =
info.splineScenarioID;
336 const auto& spline = getSplineInvXforRow(
row);
337 const char* g1buf = getSplineFlatBuffer(isc);
338 const char* g2buf = getGridX2FlatBuffer(spline, isc);
341 spline.interpolateAtUZeroCopy(g1buf, g2buf, getCorrectionDataInvX(sector,
row), u,
v, &dx);
342 if (CAMath::Abs(dx) > TPCFastSpaceChargeCorrection::kMaxCorrection) {
349GPUdi()
void TPCFastTransformPOD::getCorrectionYZatRealYZ(int32_t sector, int32_t
row,
float realY,
float realZ,
float&
y,
float&
z)
const
352 convRealLocalToGrid(sector,
row, realY, realZ, u,
v, s);
353 const auto&
info = getRowInfo(
row);
354 const int32_t isc =
info.splineScenarioID;
355 const auto& spline = getSplineInvYZforRow(
row);
356 const char* g1buf = getSplineFlatBuffer(isc);
357 const char* g2buf = getGridX2FlatBuffer(spline, isc);
360 spline.interpolateAtUZeroCopy(g1buf, g2buf, getCorrectionDataInvYZ(sector,
row), u,
v, dyz);
361 if (CAMath::Abs(dyz[0]) > TPCFastSpaceChargeCorrection::kMaxCorrection || CAMath::Abs(dyz[1]) > TPCFastSpaceChargeCorrection::kMaxCorrection) {
368GPUdi()
void TPCFastTransformPOD::convLocalToGrid(int32_t sector, int32_t
row,
float y,
float z,
float& u,
float&
v,
float& s)
const
372 const SplineType& spline = getSplineForRow(
row);
373 getRowInfo(
row).gridMeasured.convLocalToGridUntruncated(sector,
y,
z, u,
v, s);
375 u = GPUCommonMath::Clamp(u, 0.f, (
float)spline.getGridX1().getUmax());
376 v = GPUCommonMath::Clamp(
v, 0.f, (
float)spline.getGridX2().getUmax());
379GPUdi()
void TPCFastTransformPOD::convGridToLocal(int32_t sector, int32_t
row,
float gridU,
float gridV,
float&
y,
float&
z)
const
382 getRowInfo(
row).gridMeasured.convGridToLocal(sector, gridU, gridV,
y,
z);
385GPUdi()
void TPCFastTransformPOD::convRealLocalToGrid(int32_t sector, int32_t
row,
float y,
float z,
float& u,
float&
v,
float& s)
const
388 const SplineType& spline = getSplineForRow(
row);
389 getRowInfo(
row).gridReal.convLocalToGridUntruncated(sector,
y,
z, u,
v, s);
391 u = GPUCommonMath::Clamp(u, 0.f, (
float)spline.getGridX1().getUmax());
392 v = GPUCommonMath::Clamp(
v, 0.f, (
float)spline.getGridX2().getUmax());
395GPUdi()
void TPCFastTransformPOD::convGridToRealLocal(int32_t sector, int32_t
row,
float gridU,
float gridV,
float&
y,
float&
z)
const
398 getRowInfo(
row).gridReal.convGridToLocal(sector, gridU, gridV,
y,
z);
401GPUdi() bool TPCFastTransformPOD::isLocalInsideGrid(int32_t sector, int32_t
row,
float y,
float z)
const
405 getRowInfo(
row).gridMeasured.convLocalToGridUntruncated(sector,
y,
z, u,
v, s);
406 const auto& spline = getSplineForRow(
row);
408 if (u < 0.f || u > (
float)spline.getGridX1().getUmax() ||
409 v < 0.f || v > (
float)spline.getGridX2().getUmax()) {
415GPUdi() bool TPCFastTransformPOD::isRealLocalInsideGrid(int32_t sector, int32_t
row,
float y,
float z)
const
419 getRowInfo(
row).gridReal.convLocalToGridUntruncated(sector,
y,
z, u,
v, s);
420 const auto& spline = getSplineForRow(
row);
422 if (u < 0.f || u > (
float)spline.getGridX1().getUmax() ||
423 v < 0.f || v > (
float)spline.getGridX2().getUmax()) {
429GPUdi()
void TPCFastTransformPOD::TransformLocal(int32_t sector, int32_t
row,
float&
x,
float&
y,
float&
z)
const
431 if (!mApplyCorrection) {
435 getCorrectionLocal(sector,
row,
y,
z, dx, dy, dz);
438 float lx =
x, ly =
y, lz =
z;
440 getGeometry().convLocalToGlobal(sector, lx, ly, lz, gx, gy, gz);
445 InverseTransformYZtoX(sector,
row, lyT, lzT, invYZtoX);
449 InverseTransformYZtoNominalYZ(sector,
row, lyT, lzT, YZtoNominalY, YZtoNominalZ);
451 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_Transform").data()
457 <<
"sector=" << sector
471 <<
"invYZtoX=" << invYZtoX
472 <<
"YZtoNominalY=" << YZtoNominalY
473 <<
"YZtoNominalZ=" << YZtoNominalZ
482GPUdi()
void TPCFastTransformPOD::Transform(int32_t sector, int32_t
row,
float pad,
float time,
float&
x,
float&
y,
float&
z,
float vertexTime)
const
490 x = getGeometry().getRowInfoX(
row);
491 convPadTimeToLocal(sector,
row, pad,
time,
y,
z, vertexTime);
492 TransformLocal(sector,
row,
x,
y,
z);
495GPUdi()
void TPCFastTransformPOD::TransformXYZ(int32_t sector, int32_t
row,
float&
x,
float&
y,
float&
z)
const
498 TransformLocal(sector,
row,
x,
y,
z);
501GPUdi()
void TPCFastTransformPOD::TransformInTimeFrame(int32_t sector,
float time,
float&
z,
float maxTimeBin)
const
503 float l = (
time - mT0 - maxTimeBin) * mVdrift;
504 z = getGeometry().convDriftLengthToZ(sector, l);
507GPUdi()
void TPCFastTransformPOD::TransformInTimeFrame(int32_t sector, int32_t
row,
float pad,
float time,
float&
x,
float&
y,
float&
z,
float maxTimeBin)
const
515 x = getGeometry().getRowInfoX(
row);
516 convPadTimeToLocalInTimeFrame(sector,
row, pad,
time,
y,
z, maxTimeBin);
519GPUdi()
void TPCFastTransformPOD::InverseTransformInTimeFrame(int32_t sector, int32_t
row,
float ,
float y,
float z,
float& pad,
float&
time,
float maxTimeBin)
const
522 convLocalToPadTimeInTimeFrame(sector,
row,
y,
z, pad,
time, maxTimeBin);
525GPUdi() float TPCFastTransformPOD::InverseTransformInTimeFrame(int32_t sector,
float z,
float maxTimeBin)
const
528 InverseTransformInTimeFrame(sector, 0, 0, 0,
z, pad,
time, maxTimeBin);
532GPUdi()
void TPCFastTransformPOD::TransformIdealZ(int32_t sector,
float time,
float&
z,
float vertexTime)
const
541 float l = (
time - mT0 - vertexTime) * mVdrift;
542 z = getGeometry().convDriftLengthToZ(sector, l);
545GPUdi()
void TPCFastTransformPOD::TransformIdeal(int32_t sector, int32_t
row,
float pad,
float time,
float&
x,
float&
y,
float&
z,
float vertexTime)
const
554 x = getGeometry().getRowInfoX(
row);
555 float driftLength = (
time - mT0 - vertexTime) * mVdrift;
556 getGeometry().convPadDriftLengthToLocal(sector,
row, pad, driftLength,
y,
z);
559GPUdi() float TPCFastTransformPOD::convTimeToZinTimeFrame(int32_t sector,
float time,
float maxTimeBin)
const
568 float v = (
time - mT0 - maxTimeBin) * mVdrift;
569 float z = (sector < getGeometry().getNumberOfSectorsA()) ? -
v :
v;
573GPUdi() float TPCFastTransformPOD::convZtoTimeInTimeFrame(int32_t sector,
float z,
float maxTimeBin)
const
576 float v = (sector < getGeometry().getNumberOfSectorsA()) ? -
z :
z;
577 return mT0 + maxTimeBin +
v / mVdrift;
580GPUdi() float TPCFastTransformPOD::convDeltaTimeToDeltaZinTimeFrame(int32_t sector,
float deltaTime)
const
582 float deltaZ = deltaTime * mVdrift;
583 return sector < getGeometry().getNumberOfSectorsA() ? -deltaZ : deltaZ;
586GPUdi() float TPCFastTransformPOD::convDeltaZtoDeltaTimeInTimeFrameAbs(
float deltaZ)
const
588 return deltaZ / mVdrift;
591GPUdi() float TPCFastTransformPOD::convDeltaZtoDeltaTimeInTimeFrame(int32_t sector,
float deltaZ)
const
593 float deltaT = deltaZ / mVdrift;
594 return sector < getGeometry().getNumberOfSectorsA() ? -deltaT : deltaT;
597GPUdi() float TPCFastTransformPOD::getMaxDriftTime(int32_t sector, int32_t
row,
float pad)
const
600 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
603GPUdi() float TPCFastTransformPOD::getMaxDriftTime(int32_t sector, int32_t
row)
const
606 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
609GPUdi() float TPCFastTransformPOD::getMaxDriftTime(int32_t sector)
const
612 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
615GPUdi()
void TPCFastTransformPOD::InverseTransformYZtoX(int32_t sector, int32_t
row,
float realY,
float realZ,
float& realX)
const
619 dx = getCorrectionXatRealYZ(sector,
row, realY, realZ);
620 realX = getGeometry().getRowInfoX(
row) + dx;
623 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_InverseTransformYZtoX").data()
624 <<
"sector=" << sector
633GPUdi()
void TPCFastTransformPOD::InverseTransformYZtoNominalYZ(int32_t sector, int32_t
row,
float realY,
float realZ,
float& measuredY,
float& measuredZ)
const
637 getCorrectionYZatRealYZ(sector,
row, realY, realZ, dy, dz);
638 measuredY = realY - dy;
639 measuredZ = realZ - dz;
642 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_InverseTransformYZtoNominalYZ").data()
643 <<
"sector=" << sector
645 <<
"real y=" << realY
646 <<
"real z=" << realZ
647 <<
"measured y=" << measuredY
648 <<
"measured z=" << measuredZ
653GPUdi()
void TPCFastTransformPOD::convPadTimeToLocal(int32_t sector, int32_t
row,
float pad,
float time,
float&
y,
float&
z,
float vertexTime)
const
655 float l = (
time - mT0 - vertexTime) * mVdrift;
656 getGeometry().convPadDriftLengthToLocal(sector,
row, pad, l,
y,
z);
659GPUdi()
void TPCFastTransformPOD::convPadTimeToLocalInTimeFrame(int32_t sector, int32_t
row,
float pad,
float time,
float&
y,
float&
z,
float maxTimeBin)
const
661 float l = getGeometry().getTPCzLength() + (
time - mT0 - maxTimeBin) * mVdrift;
662 getGeometry().convPadDriftLengthToLocal(sector,
row, pad, l,
y,
z);
665GPUdi()
void TPCFastTransformPOD::convLocalToPadTimeInTimeFrame(int32_t sector, int32_t
row,
float y,
float z,
float& pad,
float&
time,
float maxTimeBin)
const
668 getGeometry().convLocalToPadDriftLength(sector,
row,
y,
z, pad,
length);
669 time = convDriftLengthToTime(
length, maxTimeBin);
672GPUdi() float TPCFastTransformPOD::convDriftLengthToTime(
float driftLength,
float vertexTime)
const
674 return (mT0 + vertexTime + driftLength / mVdrift);
677GPUdi() float TPCFastTransformPOD::convZOffsetToVertexTime(int32_t sector,
float zOffset,
float maxTimeBin)
const
679 if (sector < getGeometry().getNumberOfSectorsA()) {
680 return maxTimeBin - (getGeometry().getTPCzLength() + zOffset) / mVdrift;
682 return maxTimeBin - (getGeometry().getTPCzLength() - zOffset) / mVdrift;
686GPUdi() float TPCFastTransformPOD::convVertexTimeToZOffset(int32_t sector,
float vertexTime,
float maxTimeBin)
const
688 if (sector < getGeometry().getNumberOfSectorsA()) {
689 return (maxTimeBin - vertexTime) * mVdrift - getGeometry().getTPCzLength();
691 return -((maxTimeBin - vertexTime) * mVdrift - getGeometry().getTPCzLength());
695#ifndef GPUCA_GPUCODE_DEVICE
696GPUdi()
void TPCFastTransformPOD::setCalibration(
int64_t timeStamp,
float t0,
float vDrift)
698 mTimeStamp = timeStamp;
703GPUdi()
void TPCFastTransformPOD::InverseTransformXYZtoNominalXYZ(int32_t sector, int32_t
row,
float x,
float y,
float z,
float& nx,
float& ny,
float& nz)
const
706 int32_t row2 =
row + 1;
707 if (row2 >= getGeometry().getNumberOfRows()) {
712 nx1 = getGeometry().getRowInfoX(
row);
713 nx2 = getGeometry().getRowInfoX(row2);
714 InverseTransformYZtoNominalYZ(sector,
row,
y,
z, ny1, nz1);
715 InverseTransformYZtoNominalYZ(sector, row2,
y,
z, ny2, nz2);
716 float c1 = (nx2 - nx) / (nx2 - nx1);
717 float c2 = (nx - nx1) / (nx2 - nx1);
719 ny = (ny1 * c1 + ny2 * c2);
720 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
@ streamFastTransform
stream tpc fast transform
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...