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
117#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE) && defined(GPUCA_O2_LIB)
120 delete mCorrectionSlow;
159 void setCalibration(int64_t timeStamp,
float t0,
float vDrift,
float vDriftCorrY,
float lDriftCorr,
float tofCorr,
float primVtxZ);
183 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;
187 GPUd()
void TransformInTimeFrame(int32_t slice, int32_t
row,
float pad,
float time,
float&
x,
float&
y,
float&
z,
float maxTimeBin)
const;
188 GPUd()
void TransformInTimeFrame(int32_t slice,
float time,
float&
z,
float maxTimeBin)
const;
191 GPUd()
void InverseTransformInTimeFrame(int32_t slice, int32_t
row,
float ,
float y,
float z,
float&
pad,
float&
time,
float maxTimeBin)
const;
197 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;
200 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;
207 GPUd()
void convPadTimeToUVinTimeFrame(int32_t slice, int32_t
row,
float pad,
float time,
float&
u,
float&
v,
float maxTimeBin)
const;
208 GPUd()
void convTimeToVinTimeFrame(int32_t slice,
float time,
float&
v,
float maxTimeBin)
const;
211 GPUd()
void convUVtoPadTimeInTimeFrame(int32_t slice, int32_t
row,
float u,
float v,
float&
pad,
float&
time,
float maxTimeBin)
const;
214 GPUd()
float convTimeToZinTimeFrame(int32_t slice,
float time,
float maxTimeBin)
const;
215 GPUd()
float convZtoTimeInTimeFrame(int32_t slice,
float z,
float maxTimeBin)
const;
216 GPUd()
float convDeltaTimeToDeltaZinTimeFrame(int32_t slice,
float deltaTime)
const;
217 GPUd()
float convDeltaZtoDeltaTimeInTimeFrame(int32_t slice,
float deltaZ)
const;
218 GPUd()
float convDeltaZtoDeltaTimeInTimeFrameAbs(
float deltaZ)
const;
219 GPUd()
float convZOffsetToVertexTime(int32_t slice,
float zOffset,
float maxTimeBin)
const;
222 GPUd()
void getTOFcorrection(int32_t slice, int32_t
row,
float x,
float y,
float z,
float& dz)
const;
234 GPUd() int64_t getTimeStamp()
const {
return mTimeStamp; }
243 GPUd()
float getVdriftCorrY()
const {
return mVdriftCorrY; }
246 GPUd()
float getLdriftCorr()
const {
return mLdriftCorr; }
255 GPUd()
float getLumiError()
const {
return mLumiError; }
258 GPUd()
float getLumiScaleFactor()
const {
return mLumiScaleFactor; }
269#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
290 enum ConstructionExtraState : uint32_t {
291 CalibrationIsSet = 0x4
307 TPCFastSpaceChargeCorrection mCorrection;
309 bool mApplyCorrection;
335 float mLumiScaleFactor;
338 TPCSlowSpaceChargeCorrection* mCorrectionSlow{
nullptr};
351 bool sideC = (slice >= getGeometry().getNumberOfSlicesA());
353 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
354 const TPCFastTransformGeo::SliceInfo& sliceInfo = getGeometry().getSliceInfo(slice);
357 u = (
pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
359 float y = sideC ? -
u :
u;
360 float yLab =
y * sliceInfo.cosAlpha +
x * sliceInfo.sinAlpha;
362 v = (
time - mT0 -
vertexTime) * (mVdrift + mVdriftCorrY * yLab) + mLdriftCorr;
367 v = (
time - mT0 - maxTimeBin) * mVdrift + mLdriftCorr;
368 if (slice < getGeometry().getNumberOfSlicesA()) {
369 v += getGeometry().getTPCzLengthA();
371 v += getGeometry().getTPCzLengthC();
377 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
378 u = (
pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
379 convTimeToVinTimeFrame(slice,
time,
v, maxTimeBin);
384 if (slice < getGeometry().getNumberOfSlicesA()) {
385 return maxTimeBin - (getGeometry().getTPCzLengthA() +
zOffset) / mVdrift;
387 return maxTimeBin - (getGeometry().getTPCzLengthC() -
zOffset) / mVdrift;
393 if (slice < getGeometry().getNumberOfSlicesA()) {
394 return (maxTimeBin -
vertexTime) * mVdrift - getGeometry().getTPCzLengthA();
396 return -((maxTimeBin -
vertexTime) * mVdrift - getGeometry().getTPCzLengthC());
402 bool sideC = (slice >= getGeometry().getNumberOfSlicesA());
404 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
405 const TPCFastTransformGeo::SliceInfo& sliceInfo = getGeometry().getSliceInfo(slice);
407 pad =
u / rowInfo.padWidth + 0.5f * rowInfo.maxPad;
410 float y = sideC ? -
u :
u;
411 float yLab =
y * sliceInfo.cosAlpha +
x * sliceInfo.sinAlpha;
412 time = mT0 +
vertexTime + (
v - mLdriftCorr) / (mVdrift + mVdriftCorrY * yLab);
418 time = mT0 +
vertexTime + (
v - mLdriftCorr) / (mVdrift + mVdriftCorrY * yLab);
423 if (slice < getGeometry().getNumberOfSlicesA()) {
424 v -= getGeometry().getTPCzLengthA();
426 v -= getGeometry().getTPCzLengthC();
428 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
429 pad =
u / rowInfo.padWidth + 0.5f * rowInfo.maxPad;
430 time = mT0 + maxTimeBin + (
v - mLdriftCorr) / mVdrift;
437 bool sideC = (slice >= getGeometry().getNumberOfSlicesA());
438 float distZ =
z - mPrimVtxZ;
439 float dv = -GPUCommonMath::Sqrt(
x *
x +
y *
y + distZ * distZ) * mTOFcorr;
440 dz = sideC ? dv : -dv;
446 if (mApplyCorrection) {
447 float dx = 0.f, du = 0.f, dv = 0.f;
450 if (mCorrectionSlow) {
452 getGeometry().convUVtoLocal(slice,
u,
v, ly, lz);
454 getGeometry().convLocalToGlobal(slice,
x, ly, lz, gx, gy, gz);
456 float gdxC, gdyC, gdzC;
457 mCorrectionSlow->
getCorrections(gx, gy, gz, slice, gdxC, gdyC, gdzC);
458 getGeometry().convGlobalToLocal(slice, gdxC, gdyC, gdzC, dx, du, dv);
468 mCorrection.getCorrection(slice,
row,
u,
v, dx, du, dv);
471 float dxRef, duRef, dvRef;
472 ref->mCorrection.getCorrection(slice,
row,
u,
v, dxRef, duRef, dvRef);
473 dx = (dx - dxRef) *
scale + dxRef;
474 du = (du - duRef) *
scale + duRef;
475 dv = (dv - dvRef) *
scale + dvRef;
477 float dxRef, duRef, dvRef;
478 ref->mCorrection.getCorrection(slice,
row,
u,
v, dxRef, duRef, dvRef);
479 dx = dxRef *
scale + dx;
480 du = duRef *
scale + du;
481 dv = dvRef *
scale + dv;
485 float dxRef, duRef, dvRef;
486 ref2->mCorrection.getCorrection(slice,
row,
u,
v, dxRef, duRef, dvRef);
495 getGeometry().convUVtoLocal(slice,
u,
v, ly, lz);
498 getGeometry().convLocalToGlobal(slice,
x, ly, lz, gx, gy, gz);
501 float uCorr =
u + du;
502 float vCorr =
v + dv;
504 getGeometry().convUVtoLocal(slice, uCorr, vCorr, lyT, lzT);
506 float invYZtoXScaled;
510 InverseTransformYZtoX(slice,
row, lyT, lzT, invYZtoX);
514 InverseTransformYZtoNominalYZ(slice,
row, lyT, lzT, YZtoNominalY, YZtoNominalZ);
516 float YZtoNominalYScaled;
517 float YZtoNominalZScaled;
518 InverseTransformYZtoNominalYZ(slice,
row, lyT, lzT, YZtoNominalYScaled, YZtoNominalZScaled,
ref,
ref2,
scale,
scale2,
scaleMode);
520 float dxRef, duRef, dvRef;
522 ref->mCorrection.getCorrection(slice,
row,
u,
v, dxRef, duRef, dvRef);
525 float dxRef2, duRef2, dvRef2;
527 ref2->mCorrection.getCorrection(slice,
row,
u,
v, dxRef2, duRef2, dvRef2);
530 float dxOrig, duOrig, dvOrig;
531 mCorrection.getCorrection(slice,
row,
u,
v, dxOrig, duOrig, dvOrig);
533 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_Transform").data()
535 <<
"dxOrig=" << dxOrig
536 <<
"duOrig=" << duOrig
537 <<
"dvOrig=" << dvOrig
541 <<
"dxRef2=" << dxRef2
542 <<
"duRef2=" << duRef2
543 <<
"dvRef2=" << dvRef2
566 <<
"invYZtoX=" << invYZtoX
567 <<
"invYZtoXScaled=" << invYZtoXScaled
568 <<
"YZtoNominalY=" << YZtoNominalY
569 <<
"YZtoNominalYScaled=" << YZtoNominalYScaled
570 <<
"YZtoNominalZ=" << YZtoNominalZ
571 <<
"YZtoNominalZScaled=" << YZtoNominalZScaled
585 getGeometry().convLocalToUV(slice,
y,
z,
u,
v);
587 getGeometry().convUVtoLocal(slice,
u,
v,
y,
z);
589 getTOFcorrection(slice,
row,
x,
y,
z, dzTOF);
593GPUdi()
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
601 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
612 getGeometry().convUVtoLocal(slice,
u,
v,
y,
z);
615 getTOFcorrection(slice,
row,
x,
y,
z, dzTOF);
622 convTimeToVinTimeFrame(slice,
time,
v, maxTimeBin);
623 getGeometry().convVtoLocal(slice,
v,
z);
634 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
637 convPadTimeToUVinTimeFrame(slice,
row,
pad,
time,
u,
v, maxTimeBin);
638 getGeometry().convUVtoLocal(slice,
u,
v,
y,
z);
645 getGeometry().convLocalToUV(slice,
y,
z,
u,
v);
646 convUVtoPadTimeInTimeFrame(slice,
row,
u,
v,
pad,
time, maxTimeBin);
659 getGeometry().convVtoLocal(slice,
v,
z);
671 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
674 float u = (
pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
677 getGeometry().convUVtoLocal(slice,
u,
v,
y,
z);
689 float v = (
time - mT0 - maxTimeBin) * mVdrift + mLdriftCorr;
690 float z = getGeometry().getTPCalignmentZ();
691 if (slice < getGeometry().getNumberOfSlicesA()) {
703 if (slice < getGeometry().getNumberOfSlicesA()) {
704 v = getGeometry().getTPCalignmentZ() -
z;
706 v =
z - getGeometry().getTPCalignmentZ();
708 return mT0 + maxTimeBin + (
v - mLdriftCorr) / mVdrift;
713 float deltaZ = deltaTime * mVdrift;
714 return slice < getGeometry().getNumberOfSlicesA() ? -deltaZ : deltaZ;
719 return deltaZ / mVdrift;
724 float deltaT = deltaZ / mVdrift;
725 return slice < getGeometry().getNumberOfSlicesA() ? -deltaT : deltaT;
732 float u, v, pad, time;
733 getGeometry().convScaledUVtoUV(slice, 0, 0.f, 1.f, u, v);
734 convUVtoPadTime(slice, 0, u, v, pad, time, 0);
742 float maxL = mCorrection.getMaxDriftLength(slice,
row,
pad);
744 bool sideC = (slice >= getGeometry().getNumberOfSlicesA());
745 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
746 const TPCFastTransformGeo::SliceInfo& sliceInfo = getGeometry().getSliceInfo(slice);
749 float u = (
pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
751 float y = sideC ? -
u :
u;
752 float yLab =
y * sliceInfo.cosAlpha +
x * sliceInfo.sinAlpha;
753 return mT0 + (maxL - mLdriftCorr) / (mVdrift + mVdriftCorrY * yLab);
759 float maxL = mCorrection.getMaxDriftLength(slice,
row);
761 convVtoTime(maxL, maxTime, 0.f);
768 float maxL = mCorrection.getMaxDriftLength(slice);
770 convVtoTime(maxL, maxTime, 0.f);
779 getGeometry().convLocalToUV(slice,
y,
z,
u,
v);
781 mCorrection.getCorrectionInvCorrectedX(slice,
row,
u,
v,
x);
785 ref->mCorrection.getCorrectionInvCorrectedX(slice,
row,
u,
v, xr);
789 ref->mCorrection.getCorrectionInvCorrectedX(slice,
row,
u,
v, xr);
790 x = (xr - getGeometry().getRowInfo(
row).x) *
scale +
x;
795 ref2->mCorrection.getCorrectionInvCorrectedX(slice,
row,
u,
v, xr);
796 x = (xr - getGeometry().getRowInfo(
row).x) *
scale2 +
x;
799 x = mCorrection.getGeometry().getRowInfo(
row).
x;
802 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_InverseTransformYZtoX").data()
815GPUdi()
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
819 float u = 0,
v = 0, un = 0, vn = 0;
820 getGeometry().convLocalToUV(slice,
y,
z,
u,
v);
822 mCorrection.getCorrectionInvUV(slice,
row,
u,
v, un, vn);
825 float unr = 0, vnr = 0;
826 ref->mCorrection.getCorrectionInvUV(slice,
row,
u,
v, unr, vnr);
827 un = (un - unr) *
scale + unr;
828 vn = (vn - vnr) *
scale + vnr;
830 float unr = 0, vnr = 0;
831 ref->mCorrection.getCorrectionInvUV(slice,
row,
u,
v, unr, vnr);
832 un = (unr -
u) *
scale + un;
833 vn = (vnr -
v) *
scale + vn;
836 float unr = 0, vnr = 0;
837 ref2->mCorrection.getCorrectionInvUV(slice,
row,
u,
v, unr, vnr);
846 getGeometry().convUVtoLocal(slice, un, vn,
ny,
nz);
849 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_InverseTransformYZtoNominalYZ").data()
865GPUdi()
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
868 int32_t row2 =
row + 1;
869 if (row2 >= getGeometry().getNumberOfRows()) {
874 nx1 = getGeometry().getRowInfo(
row).
x;
875 nx2 = getGeometry().getRowInfo(row2).x;
876 InverseTransformYZtoNominalYZ(slice,
row,
y,
z, ny1, nz1,
ref,
ref2,
scale,
scale2,
scaleMode);
877 InverseTransformYZtoNominalYZ(slice, row2,
y,
z, ny2, nz2,
ref,
ref2,
scale,
scale2,
scaleMode);
878 float c1 = (nx2 -
nx) / (nx2 - nx1);
879 float c2 = (
nx - nx1) / (nx2 - nx1);
881 ny = (ny1 *
c1 + ny2 *
c2);
882 nz = (nz1 *
c1 + nz2 *
c2);
Definition of FlatObject class.
#define GPUCA_DEBUG_STREAMER_CHECK(...)
#define GPUCA_RTC_SPECIAL_CODE(...)
bool const GPUTPCGMMerger::trackCluster * c1
bool const GPUTPCGMMerger::trackCluster const clcomparestruct * c2
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