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;
202 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;
205 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;
212 GPUd()
void convPadTimeToUVinTimeFrame(int32_t slice, int32_t
row,
float pad,
float time,
float&
u,
float&
v,
float maxTimeBin)
const;
213 GPUd()
void convTimeToVinTimeFrame(int32_t slice,
float time,
float&
v,
float maxTimeBin)
const;
216 GPUd()
void convUVtoPadTimeInTimeFrame(int32_t slice, int32_t
row,
float u,
float v,
float&
pad,
float&
time,
float maxTimeBin)
const;
219 GPUd()
float convTimeToZinTimeFrame(int32_t slice,
float time,
float maxTimeBin)
const;
220 GPUd()
float convZtoTimeInTimeFrame(int32_t slice,
float z,
float maxTimeBin)
const;
221 GPUd()
float convDeltaTimeToDeltaZinTimeFrame(int32_t slice,
float deltaTime)
const;
222 GPUd()
float convDeltaZtoDeltaTimeInTimeFrame(int32_t slice,
float deltaZ)
const;
223 GPUd()
float convDeltaZtoDeltaTimeInTimeFrameAbs(
float deltaZ)
const;
224 GPUd()
float convZOffsetToVertexTime(int32_t slice,
float zOffset,
float maxTimeBin)
const;
227 GPUd()
void getTOFcorrection(int32_t slice, int32_t
row,
float x,
float y,
float z,
float& dz)
const;
239 GPUd() int64_t getTimeStamp()
const {
return mTimeStamp; }
248 GPUd()
float getVdriftCorrY()
const {
return mVdriftCorrY; }
251 GPUd()
float getLdriftCorr()
const {
return mLdriftCorr; }
262 GPUd()
float getLumiError()
const {
return mLumiError; }
272 GPUd()
float getCTP2IDCFallBackThreshold()
const {
return mCTP2IDCFallBackThreshold; }
275 GPUd()
float getLumiScaleFactor()
const {
return mLumiScaleFactor; }
286#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
307 enum ConstructionExtraState : uint32_t {
308 CalibrationIsSet = 0x4
324 TPCFastSpaceChargeCorrection mCorrection;
326 bool mApplyCorrection;
352 float mLumiScaleFactor;
356 float mCTP2IDCFallBackThreshold;
359 TPCSlowSpaceChargeCorrection* mCorrectionSlow{
nullptr};
372 bool sideC = (slice >= getGeometry().getNumberOfSlicesA());
374 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
375 const TPCFastTransformGeo::SliceInfo& sliceInfo = getGeometry().getSliceInfo(slice);
378 u = (
pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
380 float y = sideC ? -
u :
u;
381 float yLab =
y * sliceInfo.cosAlpha +
x * sliceInfo.sinAlpha;
383 v = (
time - mT0 -
vertexTime) * (mVdrift + mVdriftCorrY * yLab) + mLdriftCorr;
388 v = (
time - mT0 - maxTimeBin) * mVdrift + mLdriftCorr;
389 if (slice < getGeometry().getNumberOfSlicesA()) {
390 v += getGeometry().getTPCzLengthA();
392 v += getGeometry().getTPCzLengthC();
398 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
399 u = (
pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
400 convTimeToVinTimeFrame(slice,
time,
v, maxTimeBin);
405 if (slice < getGeometry().getNumberOfSlicesA()) {
406 return maxTimeBin - (getGeometry().getTPCzLengthA() +
zOffset) / mVdrift;
408 return maxTimeBin - (getGeometry().getTPCzLengthC() -
zOffset) / mVdrift;
414 if (slice < getGeometry().getNumberOfSlicesA()) {
415 return (maxTimeBin -
vertexTime) * mVdrift - getGeometry().getTPCzLengthA();
417 return -((maxTimeBin -
vertexTime) * mVdrift - getGeometry().getTPCzLengthC());
423 bool sideC = (slice >= getGeometry().getNumberOfSlicesA());
425 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
426 const TPCFastTransformGeo::SliceInfo& sliceInfo = getGeometry().getSliceInfo(slice);
428 pad =
u / rowInfo.padWidth + 0.5f * rowInfo.maxPad;
431 float y = sideC ? -
u :
u;
432 float yLab =
y * sliceInfo.cosAlpha +
x * sliceInfo.sinAlpha;
433 time = mT0 +
vertexTime + (
v - mLdriftCorr) / (mVdrift + mVdriftCorrY * yLab);
439 time = mT0 +
vertexTime + (
v - mLdriftCorr) / (mVdrift + mVdriftCorrY * yLab);
444 if (slice < getGeometry().getNumberOfSlicesA()) {
445 v -= getGeometry().getTPCzLengthA();
447 v -= getGeometry().getTPCzLengthC();
449 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
450 pad =
u / rowInfo.padWidth + 0.5f * rowInfo.maxPad;
451 time = mT0 + maxTimeBin + (
v - mLdriftCorr) / mVdrift;
458 bool sideC = (slice >= getGeometry().getNumberOfSlicesA());
459 float distZ =
z - mPrimVtxZ;
460 float dv = -GPUCommonMath::Sqrt(
x *
x +
y *
y + distZ * distZ) * mTOFcorr;
461 dz = sideC ? dv : -dv;
467 if (mApplyCorrection) {
468 float dx = 0.f, du = 0.f, dv = 0.f;
471 if (mCorrectionSlow) {
473 getGeometry().convUVtoLocal(slice,
u,
v, ly, lz);
475 getGeometry().convLocalToGlobal(slice,
x, ly, lz, gx, gy, gz);
477 float gdxC, gdyC, gdzC;
478 mCorrectionSlow->
getCorrections(gx, gy, gz, slice, gdxC, gdyC, gdzC);
479 getGeometry().convGlobalToLocal(slice, gdxC, gdyC, gdzC, dx, du, dv);
489 mCorrection.getCorrection(slice,
row,
u,
v, dx, du, dv);
492 float dxRef, duRef, dvRef;
493 ref->mCorrection.getCorrection(slice,
row,
u,
v, dxRef, duRef, dvRef);
494 dx = (dx - dxRef) *
scale + dxRef;
495 du = (du - duRef) *
scale + duRef;
496 dv = (dv - dvRef) *
scale + dvRef;
498 float dxRef, duRef, dvRef;
499 ref->mCorrection.getCorrection(slice,
row,
u,
v, dxRef, duRef, dvRef);
500 dx = dxRef *
scale + dx;
501 du = duRef *
scale + du;
502 dv = dvRef *
scale + dv;
506 float dxRef, duRef, dvRef;
507 ref2->mCorrection.getCorrection(slice,
row,
u,
v, dxRef, duRef, dvRef);
516 getGeometry().convUVtoLocal(slice,
u,
v, ly, lz);
519 getGeometry().convLocalToGlobal(slice,
x, ly, lz, gx, gy, gz);
522 float uCorr =
u + du;
523 float vCorr =
v + dv;
525 getGeometry().convUVtoLocal(slice, uCorr, vCorr, lyT, lzT);
527 float invYZtoXScaled;
531 InverseTransformYZtoX(slice,
row, lyT, lzT, invYZtoX);
535 InverseTransformYZtoNominalYZ(slice,
row, lyT, lzT, YZtoNominalY, YZtoNominalZ);
537 float YZtoNominalYScaled;
538 float YZtoNominalZScaled;
539 InverseTransformYZtoNominalYZ(slice,
row, lyT, lzT, YZtoNominalYScaled, YZtoNominalZScaled,
ref,
ref2,
scale,
scale2,
scaleMode);
541 float dxRef, duRef, dvRef;
543 ref->mCorrection.getCorrection(slice,
row,
u,
v, dxRef, duRef, dvRef);
546 float dxRef2, duRef2, dvRef2;
548 ref2->mCorrection.getCorrection(slice,
row,
u,
v, dxRef2, duRef2, dvRef2);
551 float dxOrig, duOrig, dvOrig;
552 mCorrection.getCorrection(slice,
row,
u,
v, dxOrig, duOrig, dvOrig);
554 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_Transform").data()
556 <<
"dxOrig=" << dxOrig
557 <<
"duOrig=" << duOrig
558 <<
"dvOrig=" << dvOrig
562 <<
"dxRef2=" << dxRef2
563 <<
"duRef2=" << duRef2
564 <<
"dvRef2=" << dvRef2
587 <<
"invYZtoX=" << invYZtoX
588 <<
"invYZtoXScaled=" << invYZtoXScaled
589 <<
"YZtoNominalY=" << YZtoNominalY
590 <<
"YZtoNominalYScaled=" << YZtoNominalYScaled
591 <<
"YZtoNominalZ=" << YZtoNominalZ
592 <<
"YZtoNominalZScaled=" << YZtoNominalZScaled
606 getGeometry().convLocalToUV(slice,
y,
z,
u,
v);
608 getGeometry().convUVtoLocal(slice,
u,
v,
y,
z);
610 getTOFcorrection(slice,
row,
x,
y,
z, dzTOF);
614GPUdi()
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
622 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
633 getGeometry().convUVtoLocal(slice,
u,
v,
y,
z);
636 getTOFcorrection(slice,
row,
x,
y,
z, dzTOF);
643 convTimeToVinTimeFrame(slice,
time,
v, maxTimeBin);
644 getGeometry().convVtoLocal(slice,
v,
z);
655 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
658 convPadTimeToUVinTimeFrame(slice,
row,
pad,
time,
u,
v, maxTimeBin);
659 getGeometry().convUVtoLocal(slice,
u,
v,
y,
z);
666 getGeometry().convLocalToUV(slice,
y,
z,
u,
v);
667 convUVtoPadTimeInTimeFrame(slice,
row,
u,
v,
pad,
time, maxTimeBin);
680 getGeometry().convVtoLocal(slice,
v,
z);
692 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
695 float u = (
pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
698 getGeometry().convUVtoLocal(slice,
u,
v,
y,
z);
710 float v = (
time - mT0 - maxTimeBin) * mVdrift + mLdriftCorr;
711 float z = getGeometry().getTPCalignmentZ();
712 if (slice < getGeometry().getNumberOfSlicesA()) {
724 if (slice < getGeometry().getNumberOfSlicesA()) {
725 v = getGeometry().getTPCalignmentZ() -
z;
727 v =
z - getGeometry().getTPCalignmentZ();
729 return mT0 + maxTimeBin + (
v - mLdriftCorr) / mVdrift;
734 float deltaZ = deltaTime * mVdrift;
735 return slice < getGeometry().getNumberOfSlicesA() ? -deltaZ : deltaZ;
740 return deltaZ / mVdrift;
745 float deltaT = deltaZ / mVdrift;
746 return slice < getGeometry().getNumberOfSlicesA() ? -deltaT : deltaT;
753 float u, v, pad, time;
754 getGeometry().convScaledUVtoUV(slice, 0, 0.f, 1.f, u, v);
755 convUVtoPadTime(slice, 0, u, v, pad, time, 0);
763 float maxL = mCorrection.getMaxDriftLength(slice,
row,
pad);
765 bool sideC = (slice >= getGeometry().getNumberOfSlicesA());
766 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
767 const TPCFastTransformGeo::SliceInfo& sliceInfo = getGeometry().getSliceInfo(slice);
770 float u = (
pad - 0.5f * rowInfo.maxPad) * rowInfo.padWidth;
772 float y = sideC ? -
u :
u;
773 float yLab =
y * sliceInfo.cosAlpha +
x * sliceInfo.sinAlpha;
774 return mT0 + (maxL - mLdriftCorr) / (mVdrift + mVdriftCorrY * yLab);
780 float maxL = mCorrection.getMaxDriftLength(slice,
row);
782 convVtoTime(maxL, maxTime, 0.f);
789 float maxL = mCorrection.getMaxDriftLength(slice);
791 convVtoTime(maxL, maxTime, 0.f);
800 getGeometry().convLocalToUV(slice,
y,
z,
u,
v);
802 mCorrection.getCorrectionInvCorrectedX(slice,
row,
u,
v,
x);
806 ref->mCorrection.getCorrectionInvCorrectedX(slice,
row,
u,
v, xr);
810 ref->mCorrection.getCorrectionInvCorrectedX(slice,
row,
u,
v, xr);
811 x = (xr - getGeometry().getRowInfo(
row).x) *
scale +
x;
816 ref2->mCorrection.getCorrectionInvCorrectedX(slice,
row,
u,
v, xr);
817 x = (xr - getGeometry().getRowInfo(
row).x) *
scale2 +
x;
820 x = mCorrection.getGeometry().getRowInfo(
row).
x;
823 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_InverseTransformYZtoX").data()
836GPUdi()
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
840 float u = 0,
v = 0, un = 0, vn = 0;
841 getGeometry().convLocalToUV(slice,
y,
z,
u,
v);
843 mCorrection.getCorrectionInvUV(slice,
row,
u,
v, un, vn);
846 float unr = 0, vnr = 0;
847 ref->mCorrection.getCorrectionInvUV(slice,
row,
u,
v, unr, vnr);
848 un = (un - unr) *
scale + unr;
849 vn = (vn - vnr) *
scale + vnr;
851 float unr = 0, vnr = 0;
852 ref->mCorrection.getCorrectionInvUV(slice,
row,
u,
v, unr, vnr);
853 un = (unr -
u) *
scale + un;
854 vn = (vnr -
v) *
scale + vn;
857 float unr = 0, vnr = 0;
858 ref2->mCorrection.getCorrectionInvUV(slice,
row,
u,
v, unr, vnr);
867 getGeometry().convUVtoLocal(slice, un, vn,
ny,
nz);
870 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_InverseTransformYZtoNominalYZ").data()
886GPUdi()
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
889 int32_t row2 =
row + 1;
890 if (row2 >= getGeometry().getNumberOfRows()) {
895 nx1 = getGeometry().getRowInfo(
row).
x;
896 nx2 = getGeometry().getRowInfo(row2).x;
897 InverseTransformYZtoNominalYZ(slice,
row,
y,
z, ny1, nz1,
ref,
ref2,
scale,
scale2,
scaleMode);
898 InverseTransformYZtoNominalYZ(slice, row2,
y,
z, ny2, nz2,
ref,
ref2,
scale,
scale2,
scaleMode);
899 float c1 = (nx2 -
nx) / (nx2 - nx1);
900 float c2 = (
nx - nx1) / (nx2 - nx1);
902 ny = (ny1 *
c1 + ny2 *
c2);
903 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