17#ifndef ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_TPCFASTTRANSFORM_H
18#define ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_TPCFASTTRANSFORM_H
26#if !defined(GPUCA_GPUCODE)
42#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
47 void getCorrections(
const float gx,
const float gy,
const float gz,
const int32_t sector,
float& gdxC,
float& gdyC,
float& gdzC)
const;
54 GPUdi()
void getCorrections(const
float gx, const
float gy, const
float gz, const int32_t sector,
float& gdxC,
float& gdyC,
float& gdzC)
const
98 static constexpr float DEFIDC = -1e6f;
118#if !defined(GPUCA_GPUCODE)
121 delete mCorrectionSlow;
186 GPUd()
void Transform(int32_t sector, 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;
190 GPUd()
void TransformInTimeFrame(int32_t sector, int32_t
row,
float pad,
float time,
float&
x,
float&
y,
float&
z,
float maxTimeBin)
const;
191 GPUd()
void TransformInTimeFrame(int32_t sector,
float time,
float&
z,
float maxTimeBin)
const;
194 GPUd()
void InverseTransformInTimeFrame(int32_t sector, int32_t
row,
float ,
float y,
float z,
float&
pad,
float&
time,
float maxTimeBin)
const;
195 GPUd()
float InverseTransformInTimeFrame(int32_t sector,
float z,
float maxTimeBin)
const;
201 GPUd()
void InverseTransformYZtoNominalYZ(int32_t sector, 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;
204 GPUd()
void InverseTransformXYZtoNominalXYZ(int32_t sector, 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;
211 GPUd()
void convPadTimeToLocalInTimeFrame(int32_t sector, int32_t
row,
float pad,
float time,
float&
y,
float&
z,
float maxTimeBin)
const;
214 GPUd()
void convLocalToPadTimeInTimeFrame(int32_t sector, int32_t
row,
float y,
float z,
float&
pad,
float&
time,
float maxTimeBin)
const;
216 GPUd()
float convTimeToZinTimeFrame(int32_t sector,
float time,
float maxTimeBin)
const;
217 GPUd()
float convZtoTimeInTimeFrame(int32_t sector,
float z,
float maxTimeBin)
const;
218 GPUd()
float convDeltaTimeToDeltaZinTimeFrame(int32_t sector,
float deltaTime)
const;
219 GPUd()
float convDeltaZtoDeltaTimeInTimeFrame(int32_t sector,
float deltaZ)
const;
220 GPUd()
float convDeltaZtoDeltaTimeInTimeFrameAbs(
float deltaZ)
const;
221 GPUd()
float convZOffsetToVertexTime(int32_t sector,
float zOffset,
float maxTimeBin)
const;
258 GPUdi()
float getCTP2IDCFallBackThreshold()
const {
return mCTP2IDCFallBackThreshold; }
261 GPUdi()
float getLumiScaleFactor()
const {
return mLumiScaleFactor; }
272#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
295 enum ConstructionExtraState : uint32_t {
296 CalibrationIsSet = 0x4
314 bool mApplyCorrection;
327 float mLumiScaleFactor;
331 float mCTP2IDCFallBackThreshold;
350 getGeometry().convPadDriftLengthToLocal(sector,
row,
pad, l,
y,
z);
355 float l = getGeometry().getTPCzLength() + (
time - mT0 - maxTimeBin) * mVdrift;
356 getGeometry().convPadDriftLengthToLocal(sector,
row,
pad, l,
y,
z);
363 if (sector < getGeometry().getNumberOfSectorsA()) {
364 return maxTimeBin - (getGeometry().getTPCzLength() +
zOffset) / mVdrift;
366 return maxTimeBin - (getGeometry().getTPCzLength() -
zOffset) / mVdrift;
372 if (sector < getGeometry().getNumberOfSectorsA()) {
373 return (maxTimeBin -
vertexTime) * mVdrift - getGeometry().getTPCzLength();
375 return -((maxTimeBin -
vertexTime) * mVdrift - getGeometry().getTPCzLength());
381 return (mT0 +
vertexTime + driftLength / mVdrift);
389 getGeometry().convLocalToPadDriftLength(sector,
row,
y,
z,
pad, l);
396 getGeometry().convLocalToPadDriftLength(sector,
row,
y,
z,
pad, l);
397 time = convDriftLengthToTime(l, maxTimeBin);
406 if (!mApplyCorrection) {
410 float dx = 0.f, dy = 0.f, dz = 0.f;
414 if (mCorrectionSlow) {
416 getGeometry().convLocalToGlobal(sector,
x,
y,
z, gx, gy, gz);
417 float gdxC, gdyC, gdzC;
418 mCorrectionSlow->
getCorrections(gx, gy, gz, sector, gdxC, gdyC, gdzC);
419 getGeometry().convGlobalToLocal(sector, gdxC, gdyC, gdzC, dx, dy, dz);
423 mCorrection.getCorrectionLocal(sector,
row,
y,
z, dx, dy, dz);
427 ref->mCorrection.getCorrectionLocal(sector,
row,
y,
z, dx1, dy1, dz1);
430 dz = (dz - dz1) *
scale + dz1;
433 ref->mCorrection.getCorrectionLocal(sector,
row,
y,
z, dx1, dy1, dz1);
436 dz = dz1 *
scale + dz;
441 ref2->mCorrection.getCorrectionLocal(sector,
row,
y,
z, dx1, dy1, dz1);
450 float lx =
x, ly =
y, lz =
z;
453 getGeometry().convLocalToGlobal(sector, lx, ly, lz, gx, gy, gz);
459 float invYZtoXScaled;
463 InverseTransformYZtoX(sector,
row, lyT, lzT, invYZtoX);
467 InverseTransformYZtoNominalYZ(sector,
row, lyT, lzT, YZtoNominalY, YZtoNominalZ);
469 float YZtoNominalYScaled;
470 float YZtoNominalZScaled;
471 InverseTransformYZtoNominalYZ(sector,
row, lyT, lzT, YZtoNominalYScaled, YZtoNominalZScaled,
ref,
ref2,
scale,
scale2,
scaleMode);
473 float dxRef = 0.f, dyRef = 0.f, dzRef = 0.f;
475 ref->mCorrection.getCorrectionLocal(sector,
row,
y,
z, dxRef, dyRef, dzRef);
478 float dxRef2 = 0.f, dyRef2 = 0.f, dzRef2 = 0.f;
480 ref2->mCorrection.getCorrectionLocal(sector,
row,
y,
z, dxRef2, dyRef2, dzRef2);
483 float dxOrig, dyOrig, dzOrig;
484 mCorrection.getCorrectionLocal(sector,
row,
y,
z, dxOrig, dyOrig, dzOrig);
486 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_Transform").data()
488 <<
"dxOrig=" << dxOrig
489 <<
"dyOrig=" << dyOrig
490 <<
"dzOrig=" << dzOrig
494 <<
"dxRef2=" << dxRef2
495 <<
"dyRef2=" << dyRef2
496 <<
"dzRef2=" << dzRef2
501 <<
"sector=" << sector
517 <<
"invYZtoX=" << invYZtoX
518 <<
"invYZtoXScaled=" << invYZtoXScaled
519 <<
"YZtoNominalY=" << YZtoNominalY
520 <<
"YZtoNominalYScaled=" << YZtoNominalYScaled
521 <<
"YZtoNominalZ=" << YZtoNominalZ
522 <<
"YZtoNominalZScaled=" << YZtoNominalZScaled
538GPUdi()
void TPCFastTransform::Transform(int32_t sector, 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
546 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
555 float l = (
time - mT0 - maxTimeBin) * mVdrift;
556 z = getGeometry().convDriftLengthToZ(sector, l);
567 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
569 convPadTimeToLocalInTimeFrame(sector,
row,
pad,
time,
y,
z, maxTimeBin);
575 convLocalToPadTimeInTimeFrame(sector,
row,
y,
z,
pad,
time, maxTimeBin);
581 InverseTransformInTimeFrame(sector, 0, 0, 0,
z,
pad,
time, maxTimeBin);
595 z = getGeometry().convDriftLengthToZ(sector, l);
607 x = getGeometry().getRowInfo(
row).x;
609 getGeometry().convPadDriftLengthToLocal(sector,
row,
pad, driftLength,
y,
z);
621 float v = (
time - mT0 - maxTimeBin) * mVdrift;
622 float z = (sector < getGeometry().getNumberOfSectorsA()) ? -
v :
v;
629 float v = (sector < getGeometry().getNumberOfSectorsA()) ? -
z :
z;
630 return mT0 + maxTimeBin +
v / mVdrift;
635 float deltaZ = deltaTime * mVdrift;
636 return sector < getGeometry().getNumberOfSectorsA() ? -deltaZ : deltaZ;
641 return deltaZ / mVdrift;
646 float deltaT = deltaZ / mVdrift;
647 return sector < getGeometry().getNumberOfSectorsA() ? -deltaT : deltaT;
653 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
659 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
665 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
676 dx = mCorrection.getCorrectionXatRealYZ(sector,
row, realY, realZ);
679 float dxref =
ref->mCorrection.getCorrectionXatRealYZ(sector,
row, realY, realZ);
680 dx = (dx - dxref) *
scale + dxref;
682 float dxref =
ref->mCorrection.getCorrectionXatRealYZ(sector,
row, realY, realZ);
683 dx = dxref *
scale + dx;
687 float dxref =
ref2->mCorrection.getCorrectionXatRealYZ(sector,
row, realY, realZ);
692 realX = mCorrection.getGeometry().getRowInfo(
row).x + dx;
695 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_InverseTransformYZtoX").data()
696 <<
"sector=" << sector
706GPUdi()
void TPCFastTransform::InverseTransformYZtoNominalYZ(int32_t sector, int32_t
row,
float realY,
float realZ,
float& measuredY,
float& measuredZ,
const TPCFastTransform*
ref,
const TPCFastTransform*
ref2,
float scale,
float scale2, int32_t
scaleMode)
const
716 mCorrection.getCorrectionYZatRealYZ(sector,
row, realY, realZ, dy, dz);
721 ref->mCorrection.getCorrectionYZatRealYZ(sector,
row, realY, realZ, dy1, dz1);
723 dz = (dz - dz1) *
scale + dz1;
726 ref->mCorrection.getCorrectionYZatRealYZ(sector,
row, realY, realZ, dy1, dz1);
728 dz = dz1 *
scale + dz;
732 ref2->mCorrection.getCorrectionYZatRealYZ(sector,
row, realY, realZ, dy1, dz1);
739 measuredY = realY - dy;
740 measuredZ = realZ - dz;
743 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_InverseTransformYZtoNominalYZ").data()
744 <<
"sector=" << sector
747 <<
"real y=" << realY
748 <<
"real z=" << realZ
749 <<
"measured y=" << measuredY
750 <<
"measured z=" << measuredZ
755GPUdi()
void TPCFastTransform::InverseTransformXYZtoNominalXYZ(int32_t sector, 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
758 int32_t row2 =
row + 1;
759 if (row2 >= getGeometry().getNumberOfRows()) {
764 nx1 = getGeometry().getRowInfo(
row).
x;
765 nx2 = getGeometry().getRowInfo(row2).x;
766 InverseTransformYZtoNominalYZ(sector,
row,
y,
z, ny1, nz1,
ref,
ref2,
scale,
scale2,
scaleMode);
767 InverseTransformYZtoNominalYZ(sector, row2,
y,
z, ny2, nz2,
ref,
ref2,
scale,
scale2,
scaleMode);
768 float c1 = (nx2 -
nx) / (nx2 - nx1);
769 float c2 = (
nx - nx1) / (nx2 - nx1);
771 ny = (ny1 * c1 + ny2 * c2);
772 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()
GPUCA_GPUCODE.
GLuint const GLchar * name
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat t0
GLdouble GLdouble GLdouble z
Global TPC definitions and constants.
@ streamFastTransform
stream tpc fast transform
simple struct to hold the space charge object which can be used for CPU reconstruction only
~TPCSlowSpaceChargeCorrection()
destructor
ClassDefNV(TPCSlowSpaceChargeCorrection, 2)
void getCorrections(const float gx, const float gy, const float gz, const int32_t sector, float &gdxC, float &gdyC, float &gdzC) const
getting the corrections for global coordinates
o2::tpc::SpaceCharge< float > * mCorr
reference space charge corrections