17#ifndef ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_TPCFASTTRANSFORM_H
18#define ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_TPCFASTTRANSFORM_H
28#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 sector,
float& gdxC,
float& gdyC,
float& gdzC)
const;
56 GPUdi()
void getCorrections(const
float gx, const
float gy, const
float gz, const int32_t sector,
float& gdxC,
float& gdyC,
float& gdzC)
const
120#if !defined(GPUCA_GPUCODE)
123 delete mCorrectionSlow;
188 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;
192 GPUd()
void TransformInTimeFrame(int32_t sector, int32_t
row,
float pad,
float time,
float&
x,
float&
y,
float&
z,
float maxTimeBin)
const;
193 GPUd()
void TransformInTimeFrame(int32_t sector,
float time,
float&
z,
float maxTimeBin)
const;
196 GPUd()
void InverseTransformInTimeFrame(int32_t sector, int32_t
row,
float ,
float y,
float z,
float&
pad,
float&
time,
float maxTimeBin)
const;
197 GPUd()
float InverseTransformInTimeFrame(int32_t sector,
float z,
float maxTimeBin)
const;
203 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;
206 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;
213 GPUd()
void convPadTimeToLocalInTimeFrame(int32_t sector, int32_t
row,
float pad,
float time,
float&
y,
float&
z,
float maxTimeBin)
const;
216 GPUd()
void convLocalToPadTimeInTimeFrame(int32_t sector, int32_t
row,
float y,
float z,
float&
pad,
float&
time,
float maxTimeBin)
const;
218 GPUd()
float convTimeToZinTimeFrame(int32_t sector,
float time,
float maxTimeBin)
const;
219 GPUd()
float convZtoTimeInTimeFrame(int32_t sector,
float z,
float maxTimeBin)
const;
220 GPUd()
float convDeltaTimeToDeltaZinTimeFrame(int32_t sector,
float deltaTime)
const;
221 GPUd()
float convDeltaZtoDeltaTimeInTimeFrame(int32_t sector,
float deltaZ)
const;
222 GPUd()
float convDeltaZtoDeltaTimeInTimeFrameAbs(
float deltaZ)
const;
223 GPUd()
float convZOffsetToVertexTime(int32_t sector,
float zOffset,
float maxTimeBin)
const;
255 GPUdi()
bool isIDCSet()
const {
return mIDC != DEFIDC; }
260 GPUdi()
float getCTP2IDCFallBackThreshold()
const {
return mCTP2IDCFallBackThreshold; }
263 GPUdi()
float getLumiScaleFactor()
const {
return mLumiScaleFactor; }
274#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
297 enum ConstructionExtraState : uint32_t {
298 CalibrationIsSet = 0x4
316 bool mApplyCorrection;
329 float mLumiScaleFactor;
333 float mCTP2IDCFallBackThreshold;
352 getGeometry().convPadDriftLengthToLocal(sector,
row,
pad, l,
y,
z);
357 float l = getGeometry().getTPCzLength() + (
time - mT0 - maxTimeBin) * mVdrift;
358 getGeometry().convPadDriftLengthToLocal(sector,
row,
pad, l,
y,
z);
365 if (sector < getGeometry().getNumberOfSectorsA()) {
366 return maxTimeBin - (getGeometry().getTPCzLength() +
zOffset) / mVdrift;
368 return maxTimeBin - (getGeometry().getTPCzLength() -
zOffset) / mVdrift;
374 if (sector < getGeometry().getNumberOfSectorsA()) {
375 return (maxTimeBin -
vertexTime) * mVdrift - getGeometry().getTPCzLength();
377 return -((maxTimeBin -
vertexTime) * mVdrift - getGeometry().getTPCzLength());
383 return (mT0 +
vertexTime + driftLength / mVdrift);
391 getGeometry().convLocalToPadDriftLength(sector,
row,
y,
z,
pad, l);
398 getGeometry().convLocalToPadDriftLength(sector,
row,
y,
z,
pad, l);
399 time = convDriftLengthToTime(l, maxTimeBin);
408 if (!mApplyCorrection) {
412 float dx = 0.f, dy = 0.f, dz = 0.f;
416 if (mCorrectionSlow) {
418 getGeometry().convLocalToGlobal(sector,
x,
y,
z, gx, gy, gz);
419 float gdxC, gdyC, gdzC;
420 mCorrectionSlow->
getCorrections(gx, gy, gz, sector, gdxC, gdyC, gdzC);
421 getGeometry().convGlobalToLocal(sector, gdxC, gdyC, gdzC, dx, dy, dz);
425 mCorrection.getCorrectionLocal(sector,
row,
y,
z, dx, dy, dz);
429 ref->mCorrection.getCorrectionLocal(sector,
row,
y,
z, dx1, dy1, dz1);
432 dz = (dz - dz1) *
scale + dz1;
435 ref->mCorrection.getCorrectionLocal(sector,
row,
y,
z, dx1, dy1, dz1);
438 dz = dz1 *
scale + dz;
443 ref2->mCorrection.getCorrectionLocal(sector,
row,
y,
z, dx1, dy1, dz1);
452 float lx =
x, ly =
y, lz =
z;
455 getGeometry().convLocalToGlobal(sector, lx, ly, lz, gx, gy, gz);
461 float invYZtoXScaled;
465 InverseTransformYZtoX(sector,
row, lyT, lzT, invYZtoX);
469 InverseTransformYZtoNominalYZ(sector,
row, lyT, lzT, YZtoNominalY, YZtoNominalZ);
471 float YZtoNominalYScaled;
472 float YZtoNominalZScaled;
473 InverseTransformYZtoNominalYZ(sector,
row, lyT, lzT, YZtoNominalYScaled, YZtoNominalZScaled,
ref,
ref2,
scale,
scale2,
scaleMode);
475 float dxRef = 0.f, dyRef = 0.f, dzRef = 0.f;
477 ref->mCorrection.getCorrectionLocal(sector,
row,
y,
z, dxRef, dyRef, dzRef);
480 float dxRef2 = 0.f, dyRef2 = 0.f, dzRef2 = 0.f;
482 ref2->mCorrection.getCorrectionLocal(sector,
row,
y,
z, dxRef2, dyRef2, dzRef2);
485 float dxOrig, dyOrig, dzOrig;
486 mCorrection.getCorrectionLocal(sector,
row,
y,
z, dxOrig, dyOrig, dzOrig);
488 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_Transform").data()
490 <<
"dxOrig=" << dxOrig
491 <<
"dyOrig=" << dyOrig
492 <<
"dzOrig=" << dzOrig
496 <<
"dxRef2=" << dxRef2
497 <<
"dyRef2=" << dyRef2
498 <<
"dzRef2=" << dzRef2
503 <<
"sector=" << sector
519 <<
"invYZtoX=" << invYZtoX
520 <<
"invYZtoXScaled=" << invYZtoXScaled
521 <<
"YZtoNominalY=" << YZtoNominalY
522 <<
"YZtoNominalYScaled=" << YZtoNominalYScaled
523 <<
"YZtoNominalZ=" << YZtoNominalZ
524 <<
"YZtoNominalZScaled=" << YZtoNominalZScaled
540GPUdi()
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
548 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
557 float l = (
time - mT0 - maxTimeBin) * mVdrift;
558 z = getGeometry().convDriftLengthToZ(sector, l);
569 const TPCFastTransformGeo::RowInfo& rowInfo = getGeometry().getRowInfo(
row);
571 convPadTimeToLocalInTimeFrame(sector,
row,
pad,
time,
y,
z, maxTimeBin);
577 convLocalToPadTimeInTimeFrame(sector,
row,
y,
z,
pad,
time, maxTimeBin);
583 InverseTransformInTimeFrame(sector, 0, 0, 0,
z,
pad,
time, maxTimeBin);
597 z = getGeometry().convDriftLengthToZ(sector, l);
609 x = getGeometry().getRowInfo(
row).x;
611 getGeometry().convPadDriftLengthToLocal(sector,
row,
pad, driftLength,
y,
z);
623 float v = (
time - mT0 - maxTimeBin) * mVdrift;
624 float z = (sector < getGeometry().getNumberOfSectorsA()) ? -
v :
v;
631 float v = (sector < getGeometry().getNumberOfSectorsA()) ? -
z :
z;
632 return mT0 + maxTimeBin +
v / mVdrift;
637 float deltaZ = deltaTime * mVdrift;
638 return sector < getGeometry().getNumberOfSectorsA() ? -deltaZ : deltaZ;
643 return deltaZ / mVdrift;
648 float deltaT = deltaZ / mVdrift;
649 return sector < getGeometry().getNumberOfSectorsA() ? -deltaT : deltaT;
655 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
661 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
667 return convDriftLengthToTime(getGeometry().getTPCzLength(), 0.f);
678 dx = mCorrection.getCorrectionXatRealYZ(sector,
row, realY, realZ);
681 float dxref =
ref->mCorrection.getCorrectionXatRealYZ(sector,
row, realY, realZ);
682 dx = (dx - dxref) *
scale + dxref;
684 float dxref =
ref->mCorrection.getCorrectionXatRealYZ(sector,
row, realY, realZ);
685 dx = dxref *
scale + dx;
689 float dxref =
ref2->mCorrection.getCorrectionXatRealYZ(sector,
row, realY, realZ);
694 realX = mCorrection.getGeometry().getRowInfo(
row).x + dx;
697 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_InverseTransformYZtoX").data()
698 <<
"sector=" << sector
708GPUdi()
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
718 mCorrection.getCorrectionYZatRealYZ(sector,
row, realY, realZ, dy, dz);
723 ref->mCorrection.getCorrectionYZatRealYZ(sector,
row, realY, realZ, dy1, dz1);
725 dz = (dz - dz1) *
scale + dz1;
728 ref->mCorrection.getCorrectionYZatRealYZ(sector,
row, realY, realZ, dy1, dz1);
730 dz = dz1 *
scale + dz;
734 ref2->mCorrection.getCorrectionYZatRealYZ(sector,
row, realY, realZ, dy1, dz1);
741 measuredY = realY - dy;
742 measuredZ = realZ - dz;
745 o2::utils::DebugStreamer::instance()->getStreamer(
"debug_fasttransform",
"UPDATE") << o2::utils::DebugStreamer::instance()->getUniqueTreeName(
"tree_InverseTransformYZtoNominalYZ").data()
746 <<
"sector=" << sector
749 <<
"real y=" << realY
750 <<
"real z=" << realZ
751 <<
"measured y=" << measuredY
752 <<
"measured z=" << measuredZ
757GPUdi()
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
760 int32_t row2 =
row + 1;
761 if (row2 >= getGeometry().getNumberOfRows()) {
766 nx1 = getGeometry().getRowInfo(
row).
x;
767 nx2 = getGeometry().getRowInfo(row2).x;
768 InverseTransformYZtoNominalYZ(sector,
row,
y,
z, ny1, nz1,
ref,
ref2,
scale,
scale2,
scaleMode);
769 InverseTransformYZtoNominalYZ(sector, row2,
y,
z, ny2, nz2,
ref,
ref2,
scale,
scale2,
scaleMode);
770 float c1 = (nx2 -
nx) / (nx2 - nx1);
771 float c2 = (
nx - nx1) / (nx2 - nx1);
773 ny = (ny1 * c1 + ny2 * c2);
774 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