17#ifndef ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_TPCFASTTRANSFORM_H
18#define ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_TPCFASTTRANSFORM_H
26#if !defined(GPUCA_GPUCODE)
44#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
49 void getCorrections(
const float gx,
const float gy,
const float gz,
const int32_t slice,
float& gdxC,
float& gdyC,
float& gdzC)
const;
56 GPUd()
void getCorrections(const
float gx, const
float gy, const
float gz, const int32_t slice,
float& gdxC,
float& gdyC,
float& gdzC)
const
120#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE) && defined(GPUCA_O2_LIB)
123 delete mCorrectionSlow;
162 void setCalibration(int64_t timeStamp,
float t0,
float vDrift,
float vDriftCorrY,
float lDriftCorr,
float tofCorr,
float primVtxZ);
188 GPUd()
void Transform(int32_t slice, int32_t
row,
float pad,
float time,
float&
x,
float&
y,
float&
z,
float vertexTime = 0,
const TPCFastTransform*
ref =
nullptr,
const TPCFastTransform*
ref2 =
nullptr,
float scale = 0.
f,
float scale2 = 0.
f, int32_t
scaleMode = 0)
const;
192 GPUd()
void TransformInTimeFrame(int32_t slice, int32_t
row,
float pad,
float time,
float&
x,
float&
y,
float&
z,
float maxTimeBin)
const;
193 GPUd()
void TransformInTimeFrame(int32_t slice,
float time,
float&
z,
float maxTimeBin)
const;
196 GPUd()
void InverseTransformInTimeFrame(int32_t slice, int32_t
row,
float ,
float y,
float z,
float&
pad,
float&
time,
float maxTimeBin)
const;
197 GPUd()
float InverseTransformInTimeFrame(int32_t slice,
float z,
float maxTimeBin)
const;
203 GPUd()
void InverseTransformYZtoNominalYZ(int32_t slice, int32_t
row,
float y,
float z,
float&
ny,
float&
nz,
const TPCFastTransform*
ref =
nullptr,
const TPCFastTransform*
ref2 =
nullptr,
float scale = 0.
f,
float scale2 = 0.
f, int32_t
scaleMode = 0)
const;
206 GPUd()
void InverseTransformXYZtoNominalXYZ(int32_t slice, int32_t
row,
float x,
float y,
float z,
float&
nx,
float&
ny,
float&
nz,
const TPCFastTransform*
ref =
nullptr,
const TPCFastTransform*
ref2 =
nullptr,
float scale = 0.
f,
float scale2 = 0.
f, int32_t
scaleMode = 0)
const;
213 GPUd()
void convPadTimeToUVinTimeFrame(int32_t slice, int32_t
row,
float pad,
float time,
float&
u,
float&
v,
float maxTimeBin)
const;
214 GPUd()
void convTimeToVinTimeFrame(int32_t slice,
float time,
float&
v,
float maxTimeBin)
const;
217 GPUd()
void convUVtoPadTimeInTimeFrame(int32_t slice, int32_t
row,
float u,
float v,
float&
pad,
float&
time,
float maxTimeBin)
const;
220 GPUd()
float convTimeToZinTimeFrame(int32_t slice,
float time,
float maxTimeBin)
const;
221 GPUd()
float convZtoTimeInTimeFrame(int32_t slice,
float z,
float maxTimeBin)
const;
222 GPUd()
float convDeltaTimeToDeltaZinTimeFrame(int32_t slice,
float deltaTime)
const;
223 GPUd()
float convDeltaZtoDeltaTimeInTimeFrame(int32_t slice,
float deltaZ)
const;
224 GPUd()
float convDeltaZtoDeltaTimeInTimeFrameAbs(
float deltaZ)
const;
225 GPUd()
float convZOffsetToVertexTime(int32_t slice,
float zOffset,
float maxTimeBin)
const;
228 GPUd()
void getTOFcorrection(int32_t slice, int32_t
row,
float x,
float y,
float z,
float& dz)
const;
240 GPUd() int64_t getTimeStamp()
const {
return mTimeStamp; }
249 GPUd()
float getVdriftCorrY()
const {
return mVdriftCorrY; }
252 GPUd()
float getLdriftCorr()
const {
return mLdriftCorr; }
263 GPUd()
float getLumiError()
const {
return mLumiError; }
273 GPUd()
float getCTP2IDCFallBackThreshold()
const {
return mCTP2IDCFallBackThreshold; }
276 GPUd()
float getLumiScaleFactor()
const {
return mLumiScaleFactor; }
287#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
308 enum ConstructionExtraState : uint32_t {
309 CalibrationIsSet = 0x4
325 TPCFastSpaceChargeCorrection mCorrection;
327 bool mApplyCorrection;
353 float mLumiScaleFactor;
357 float mCTP2IDCFallBackThreshold;
360 TPCSlowSpaceChargeCorrection* mCorrectionSlow{
nullptr};
373 bool sideC = (slice >= getGeometry().getNumberOfSlicesA());
375 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
376 const TPCFastTransformGeo::SliceInfo& sliceInfo = getGeometry().getSliceInfo(slice);
379 u = (
pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
381 float y = sideC ? -
u :
u;
382 float yLab =
y * sliceInfo.cosAlpha +
x * sliceInfo.sinAlpha;
384 v = (
time - mT0 -
vertexTime) * (mVdrift + mVdriftCorrY * yLab) + mLdriftCorr;
389 v = (
time - mT0 - maxTimeBin) * mVdrift + mLdriftCorr;
390 if (slice < getGeometry().getNumberOfSlicesA()) {
391 v += getGeometry().getTPCzLengthA();
393 v += getGeometry().getTPCzLengthC();
399 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
400 u = (
pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
401 convTimeToVinTimeFrame(slice,
time,
v, maxTimeBin);
406 if (slice < getGeometry().getNumberOfSlicesA()) {
407 return maxTimeBin - (getGeometry().getTPCzLengthA() +
zOffset) / mVdrift;
409 return maxTimeBin - (getGeometry().getTPCzLengthC() -
zOffset) / mVdrift;
415 if (slice < getGeometry().getNumberOfSlicesA()) {
416 return (maxTimeBin -
vertexTime) * mVdrift - getGeometry().getTPCzLengthA();
418 return -((maxTimeBin -
vertexTime) * mVdrift - getGeometry().getTPCzLengthC());
424 bool sideC = (slice >= getGeometry().getNumberOfSlicesA());
426 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
427 const TPCFastTransformGeo::SliceInfo& sliceInfo = getGeometry().getSliceInfo(slice);
429 pad =
u / rowInfo.padWidth + 0.5f * rowInfo.maxPad;
432 float y = sideC ? -
u :
u;
433 float yLab =
y * sliceInfo.cosAlpha +
x * sliceInfo.sinAlpha;
434 time = mT0 +
vertexTime + (
v - mLdriftCorr) / (mVdrift + mVdriftCorrY * yLab);
440 time = mT0 +
vertexTime + (
v - mLdriftCorr) / (mVdrift + mVdriftCorrY * yLab);
445 if (slice < getGeometry().getNumberOfSlicesA()) {
446 v -= getGeometry().getTPCzLengthA();
448 v -= getGeometry().getTPCzLengthC();
450 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
451 pad =
u / rowInfo.padWidth + 0.5f * rowInfo.maxPad;
452 time = mT0 + maxTimeBin + (
v - mLdriftCorr) / mVdrift;
459 bool sideC = (slice >= getGeometry().getNumberOfSlicesA());
460 float distZ =
z - mPrimVtxZ;
461 float dv = -GPUCommonMath::Sqrt(
x *
x +
y *
y + distZ * distZ) * mTOFcorr;
462 dz = sideC ? dv : -dv;
468 if (mApplyCorrection) {
469 float dx = 0.f, du = 0.f, dv = 0.f;
472 if (mCorrectionSlow) {
474 getGeometry().convUVtoLocal(slice,
u,
v, ly, lz);
476 getGeometry().convLocalToGlobal(slice,
x, ly, lz, gx, gy, gz);
478 float gdxC, gdyC, gdzC;
479 mCorrectionSlow->
getCorrections(gx, gy, gz, slice, gdxC, gdyC, gdzC);
480 getGeometry().convGlobalToLocal(slice, gdxC, gdyC, gdzC, dx, du, dv);
490 mCorrection.getCorrection(slice,
row,
u,
v, dx, du, dv);
493 float dxRef, duRef, dvRef;
494 ref->mCorrection.getCorrection(slice,
row,
u,
v, dxRef, duRef, dvRef);
495 dx = (dx - dxRef) *
scale + dxRef;
496 du = (du - duRef) *
scale + duRef;
497 dv = (dv - dvRef) *
scale + dvRef;
499 float dxRef, duRef, dvRef;
500 ref->mCorrection.getCorrection(slice,
row,
u,
v, dxRef, duRef, dvRef);
501 dx = dxRef *
scale + dx;
502 du = duRef *
scale + du;
503 dv = dvRef *
scale + dv;
507 float dxRef, duRef, dvRef;
508 ref2->mCorrection.getCorrection(slice,
row,
u,
v, dxRef, duRef, dvRef);
517 getGeometry().convUVtoLocal(slice,
u,
v, ly, lz);
520 getGeometry().convLocalToGlobal(slice,
x, ly, lz, gx, gy, gz);
523 float uCorr =
u + du;
524 float vCorr =
v + dv;
526 getGeometry().convUVtoLocal(slice, uCorr, vCorr, lyT, lzT);
528 float invYZtoXScaled;
532 InverseTransformYZtoX(slice,
row, lyT, lzT, invYZtoX);
536 InverseTransformYZtoNominalYZ(slice,
row, lyT, lzT, YZtoNominalY, YZtoNominalZ);
538 float YZtoNominalYScaled;
539 float YZtoNominalZScaled;
540 InverseTransformYZtoNominalYZ(slice,
row, lyT, lzT, YZtoNominalYScaled, YZtoNominalZScaled,
ref,
ref2,
scale,
scale2,
scaleMode);
542 float dxRef, duRef, dvRef;
544 ref->mCorrection.getCorrection(slice,
row,
u,
v, dxRef, duRef, dvRef);
547 float dxRef2, duRef2, dvRef2;
549 ref2->mCorrection.getCorrection(slice,
row,
u,
v, dxRef2, duRef2, dvRef2);
552 float dxOrig, duOrig, dvOrig;
553 mCorrection.getCorrection(slice,
row,
u,
v, dxOrig, duOrig, dvOrig);
555 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_Transform").data()
557 <<
"dxOrig=" << dxOrig
558 <<
"duOrig=" << duOrig
559 <<
"dvOrig=" << dvOrig
563 <<
"dxRef2=" << dxRef2
564 <<
"duRef2=" << duRef2
565 <<
"dvRef2=" << dvRef2
588 <<
"invYZtoX=" << invYZtoX
589 <<
"invYZtoXScaled=" << invYZtoXScaled
590 <<
"YZtoNominalY=" << YZtoNominalY
591 <<
"YZtoNominalYScaled=" << YZtoNominalYScaled
592 <<
"YZtoNominalZ=" << YZtoNominalZ
593 <<
"YZtoNominalZScaled=" << YZtoNominalZScaled
607 getGeometry().convLocalToUV(slice,
y,
z,
u,
v);
609 getGeometry().convUVtoLocal(slice,
u,
v,
y,
z);
611 getTOFcorrection(slice,
row,
x,
y,
z, dzTOF);
615GPUdi()
void TPCFastTransform::Transform(int32_t slice, int32_t
row,
float pad,
float time,
float&
x,
float&
y,
float&
z,
float vertexTime,
const TPCFastTransform*
ref,
const TPCFastTransform*
ref2,
float scale,
float scale2, int32_t
scaleMode)
const
623 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
634 getGeometry().convUVtoLocal(slice,
u,
v,
y,
z);
637 getTOFcorrection(slice,
row,
x,
y,
z, dzTOF);
644 convTimeToVinTimeFrame(slice,
time,
v, maxTimeBin);
645 getGeometry().convVtoLocal(slice,
v,
z);
656 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
659 convPadTimeToUVinTimeFrame(slice,
row,
pad,
time,
u,
v, maxTimeBin);
660 getGeometry().convUVtoLocal(slice,
u,
v,
y,
z);
667 getGeometry().convLocalToUV(slice,
y,
z,
u,
v);
668 convUVtoPadTimeInTimeFrame(slice,
row,
u,
v,
pad,
time, maxTimeBin);
674 InverseTransformInTimeFrame(slice, 0, 0, 0,
z,
pad,
time, maxTimeBin);
688 getGeometry().convVtoLocal(slice,
v,
z);
700 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
703 float u = (
pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
706 getGeometry().convUVtoLocal(slice,
u,
v,
y,
z);
718 float v = (
time - mT0 - maxTimeBin) * mVdrift + mLdriftCorr;
719 float z = getGeometry().getTPCalignmentZ();
720 if (slice < getGeometry().getNumberOfSlicesA()) {
732 if (slice < getGeometry().getNumberOfSlicesA()) {
733 v = getGeometry().getTPCalignmentZ() -
z;
735 v =
z - getGeometry().getTPCalignmentZ();
737 return mT0 + maxTimeBin + (
v - mLdriftCorr) / mVdrift;
742 float deltaZ = deltaTime * mVdrift;
743 return slice < getGeometry().getNumberOfSlicesA() ? -deltaZ : deltaZ;
748 return deltaZ / mVdrift;
753 float deltaT = deltaZ / mVdrift;
754 return slice < getGeometry().getNumberOfSlicesA() ? -deltaT : deltaT;
761 float u, v, pad, time;
762 getGeometry().convScaledUVtoUV(slice, 0, 0.f, 1.f, u, v);
763 convUVtoPadTime(slice, 0, u, v, pad, time, 0);
771 float maxL = mCorrection.getMaxDriftLength(slice,
row,
pad);
773 bool sideC = (slice >= getGeometry().getNumberOfSlicesA());
774 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
775 const TPCFastTransformGeo::SliceInfo& sliceInfo = getGeometry().getSliceInfo(slice);
778 float u = (
pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
780 float y = sideC ? -
u :
u;
781 float yLab =
y * sliceInfo.cosAlpha +
x * sliceInfo.sinAlpha;
782 return mT0 + (maxL - mLdriftCorr) / (mVdrift + mVdriftCorrY * yLab);
788 float maxL = mCorrection.getMaxDriftLength(slice,
row);
790 convVtoTime(maxL, maxTime, 0.f);
797 float maxL = mCorrection.getMaxDriftLength(slice);
799 convVtoTime(maxL, maxTime, 0.f);
808 getGeometry().convLocalToUV(slice,
y,
z,
u,
v);
810 mCorrection.getCorrectionInvCorrectedX(slice,
row,
u,
v,
x);
814 ref->mCorrection.getCorrectionInvCorrectedX(slice,
row,
u,
v, xr);
818 ref->mCorrection.getCorrectionInvCorrectedX(slice,
row,
u,
v, xr);
819 x = (xr - getGeometry().getRowInfo(
row).x) *
scale +
x;
824 ref2->mCorrection.getCorrectionInvCorrectedX(slice,
row,
u,
v, xr);
825 x = (xr - getGeometry().getRowInfo(
row).x) *
scale2 +
x;
828 x = mCorrection.getGeometry().getRowInfo(
row).
x;
831 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_InverseTransformYZtoX").data()
844GPUdi()
void TPCFastTransform::InverseTransformYZtoNominalYZ(int32_t slice, int32_t
row,
float y,
float z,
float&
ny,
float&
nz,
const TPCFastTransform*
ref,
const TPCFastTransform*
ref2,
float scale,
float scale2, int32_t
scaleMode)
const
848 float u = 0,
v = 0, un = 0, vn = 0;
849 getGeometry().convLocalToUV(slice,
y,
z,
u,
v);
851 mCorrection.getCorrectionInvUV(slice,
row,
u,
v, un, vn);
854 float unr = 0, vnr = 0;
855 ref->mCorrection.getCorrectionInvUV(slice,
row,
u,
v, unr, vnr);
856 un = (un - unr) *
scale + unr;
857 vn = (vn - vnr) *
scale + vnr;
859 float unr = 0, vnr = 0;
860 ref->mCorrection.getCorrectionInvUV(slice,
row,
u,
v, unr, vnr);
861 un = (unr -
u) *
scale + un;
862 vn = (vnr -
v) *
scale + vn;
865 float unr = 0, vnr = 0;
866 ref2->mCorrection.getCorrectionInvUV(slice,
row,
u,
v, unr, vnr);
875 getGeometry().convUVtoLocal(slice, un, vn,
ny,
nz);
878 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_InverseTransformYZtoNominalYZ").data()
894GPUdi()
void TPCFastTransform::InverseTransformXYZtoNominalXYZ(int32_t slice, int32_t
row,
float x,
float y,
float z,
float&
nx,
float&
ny,
float&
nz,
const TPCFastTransform*
ref,
const TPCFastTransform*
ref2,
float scale,
float scale2, int32_t
scaleMode)
const
897 int32_t row2 =
row + 1;
898 if (row2 >= getGeometry().getNumberOfRows()) {
903 nx1 = getGeometry().getRowInfo(
row).
x;
904 nx2 = getGeometry().getRowInfo(row2).x;
905 InverseTransformYZtoNominalYZ(slice,
row,
y,
z, ny1, nz1,
ref,
ref2,
scale,
scale2,
scaleMode);
906 InverseTransformYZtoNominalYZ(slice, row2,
y,
z, ny2, nz2,
ref,
ref2,
scale,
scale2,
scaleMode);
907 float c1 = (nx2 -
nx) / (nx2 - nx1);
908 float c2 = (
nx - nx1) / (nx2 - nx1);
910 ny = (ny1 * c1 + ny2 * c2);
911 nz = (nz1 * c1 + nz2 * c2);
Definition of FlatObject class.
#define GPUCA_DEBUG_STREAMER_CHECK(...)
#define GPUCA_RTC_SPECIAL_CODE(...)
Definition of TPCFastSpaceChargeCorrection class.
char * releaseInternalBuffer()
_____________ Methods for making the data buffer external __________________________
void destroy()
_______________ Utilities _______________________________________________
void startConstruction()
_____________ Construction _________
static constexpr size_t getBufferAlignmentBytes()
_____________ FlatObject functionality, see FlatObject class for description ____________
static constexpr size_t getClassAlignmentBytes()
_____________ Memory alignment __________________________
GLuint const GLchar * name
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
GLdouble GLdouble GLdouble z
GPUd() const expr uint32_t MultivariatePolynomialHelper< Dim
Global TPC definitions and constants.
@ streamFastTransform
stream tpc fast transform
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
simple struct to hold the space charge object which can be used for CPU reconstruction only
~TPCSlowSpaceChargeCorrection()
destructor
ClassDefNV(TPCSlowSpaceChargeCorrection, 2)
o2::tpc::SpaceCharge< float > * mCorr
reference space charge corrections
void getCorrections(const float gx, const float gy, const float gz, const int32_t slice, float &gdxC, float &gdyC, float &gdzC) const
getting the corrections for global coordinates