17#ifndef ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_TPCFASTSPACECHARGECORRECTION_H
18#define ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_TPCFASTSPACECHARGECORRECTION_H
135 GPUd()
void setTimeStamp(int64_t
v) { mTimeStamp =
v; }
139 GPUd()
void setInterpolationSafetyMargin(
float val) { fInterpolationSafetyMargin =
val; }
155 GPUd() int32_t getCorrection(int32_t slice, int32_t
row,
float u,
float v,
float&
dx,
float&
du,
float& dv)
const;
164 GPUd()
float getMaxDriftLength(int32_t slice, int32_t
row,
float pad)
const;
199 GPUd() float getInterpolationSafetyMargin()
const {
return fInterpolationSafetyMargin; }
207 return mSliceInfo[slice];
213 return mSliceInfo[slice];
219 return mSliceRowInfoPtr[mGeo.getNumberOfRows() * slice +
row];
225 return mSliceRowInfoPtr[mGeo.getNumberOfRows() * slice +
row];
228#if !defined(GPUCA_GPUCODE)
231 GPUh() double testInverse(
bool prn = 0);
236 void relocateBufferPointers(
const char* oldBuffer,
char* newBuffer);
238 void releaseConstructionMemory();
241 GPUd() int32_t getCorrectionOld(int32_t slice, int32_t
row,
float u,
float v,
float&
dx,
float&
du,
float& dv)
const;
247 RowInfo* mConstructionRowInfos =
nullptr;
254 int32_t mNumberOfScenarios;
266 char* mSplineData[3];
268 size_t mSliceDataSizeBytes[3];
270 float fInterpolationSafetyMargin{0.1f};
279GPUdi() const TPCFastSpaceChargeCorrection::SplineType& TPCFastSpaceChargeCorrection::getSpline(int32_t slice, int32_t
row)
const
282 const RowInfo& rowInfo = mRowInfoPtr[
row];
283 return mScenarioPtr[rowInfo.splineScenarioID];
286GPUdi() TPCFastSpaceChargeCorrection::SplineType& TPCFastSpaceChargeCorrection::getSpline(int32_t slice, int32_t
row)
289 const RowInfo& rowInfo = mRowInfoPtr[
row];
290 return mScenarioPtr[rowInfo.splineScenarioID];
293GPUdi() float* TPCFastSpaceChargeCorrection::getSplineData(int32_t slice, int32_t
row, int32_t iSpline)
296 const RowInfo& rowInfo = mRowInfoPtr[
row];
297 return reinterpret_cast<float*
>(mSplineData[iSpline] + mSliceDataSizeBytes[iSpline] * slice + rowInfo.dataOffsetBytes[iSpline]);
300GPUdi() const
float* TPCFastSpaceChargeCorrection::getSplineData(int32_t slice, int32_t
row, int32_t iSpline)
const
303 const RowInfo& rowInfo = mRowInfoPtr[
row];
304 return reinterpret_cast<float*
>(mSplineData[iSpline] + mSliceDataSizeBytes[iSpline] * slice + rowInfo.dataOffsetBytes[iSpline]);
307GPUdi()
void TPCFastSpaceChargeCorrection::schrinkUV(int32_t slice, int32_t
row,
float& u,
float&
v)
const
311 const TPCFastTransformGeo::RowInfo& rowInfo = mGeo.getRowInfo(
row);
313 float uWidth05 = rowInfo.getUwidth() * (0.5f + fInterpolationSafetyMargin);
314 float vWidth = mGeo.getTPCzLength(slice);
322 if (
v < -0.1f * vWidth) {
325 if (
v > 1.1f * vWidth) {
330GPUdi()
void TPCFastSpaceChargeCorrection::schrinkCorrectedUV(int32_t slice, int32_t
row,
float& corrU,
float& corrV)
const
334 const TPCFastTransformGeo::RowInfo& rowInfo = mGeo.getRowInfo(
row);
335 const SliceRowInfo& sliceRowInfo = getSliceRowInfo(slice,
row);
337 float uMargin = fInterpolationSafetyMargin * rowInfo.getUwidth();
338 float vMargin = fInterpolationSafetyMargin * mGeo.getTPCzLength(slice);
340 if (corrU < sliceRowInfo.activeArea.cuMin - uMargin) {
341 corrU = sliceRowInfo.activeArea.cuMin - uMargin;
344 if (corrU > sliceRowInfo.activeArea.cuMax + uMargin) {
345 corrU = sliceRowInfo.activeArea.cuMax + uMargin;
348 if (corrV < 0.f - vMargin) {
349 corrV = 0.f - vMargin;
352 if (corrV > sliceRowInfo.activeArea.cvMax + vMargin) {
353 corrV = sliceRowInfo.activeArea.cvMax + vMargin;
357GPUdi()
void TPCFastSpaceChargeCorrection::convUVtoGrid(int32_t slice, int32_t
row,
float u,
float v,
float& gu,
float& gv)
const
363 schrinkUV(slice,
row, u,
v);
365 const SliceRowInfo& info = getSliceRowInfo(slice,
row);
366 const SplineType& spline = getSpline(slice,
row);
368 float su0 = 0.f, sv0 = 0.f;
369 mGeo.convUVtoScaledUV(slice,
row, u, info.gridV0, su0, sv0);
370 mGeo.convUVtoScaledUV(slice,
row, u,
v, gu, gv);
372 gv = (gv - sv0) / (1.f - sv0);
373 gu *= spline.getGridX1().getUmax();
374 gv *= spline.getGridX2().getUmax();
377GPUdi()
void TPCFastSpaceChargeCorrection::convGridToUV(int32_t slice, int32_t
row,
float gridU,
float gridV,
float& u,
float&
v)
const
381 float su0 = 0.f, sv0 = 0.f;
382 const SliceRowInfo& info = getSliceRowInfo(slice,
row);
383 const SplineType& spline = getSpline(slice,
row);
384 mGeo.convUVtoScaledUV(slice,
row, 0.f, info.gridV0, su0, sv0);
385 float su = gridU / spline.getGridX1().getUmax();
386 float sv = sv0 + gridV / spline.getGridX2().getUmax() * (1.f - sv0);
387 mGeo.convScaledUVtoUV(slice,
row, su, sv, u,
v);
390GPUdi()
void TPCFastSpaceChargeCorrection::convCorrectedUVtoGrid(int32_t slice, int32_t
row,
float corrU,
float corrV,
float& gridU,
float& gridV)
const
392 schrinkCorrectedUV(slice,
row, corrU, corrV);
394 const SliceRowInfo& sliceRowInfo = getSliceRowInfo(slice,
row);
396 gridU = (corrU - sliceRowInfo.gridCorrU0) * sliceRowInfo.scaleCorrUtoGrid;
397 gridV = (corrV - sliceRowInfo.gridCorrV0) * sliceRowInfo.scaleCorrVtoGrid;
400GPUdi() int32_t TPCFastSpaceChargeCorrection::getCorrection(int32_t slice, int32_t
row,
float u,
float v,
float& dx,
float& du,
float& dv)
const
402 const SplineType& spline = getSpline(slice,
row);
403 const float* splineData = getSplineData(slice,
row);
404 float gridU = 0, gridV = 0;
405 convUVtoGrid(slice,
row, u,
v, gridU, gridV);
407 spline.interpolateU(splineData, gridU, gridV, dxuv);
408 if (CAMath::Abs(dxuv[0]) > 100 || CAMath::Abs(dxuv[1]) > 100 || CAMath::Abs(dxuv[2]) > 100) {
409 dxuv[0] = dxuv[1] = dxuv[2] = 0;
417GPUdi() int32_t TPCFastSpaceChargeCorrection::getCorrectionOld(int32_t slice, int32_t
row,
float u,
float v,
float& dx,
float& du,
float& dv)
const
419 const SplineType& spline = getSpline(slice,
row);
420 const float* splineData = getSplineData(slice,
row);
421 float gridU = 0, gridV = 0;
422 convUVtoGrid(slice,
row, u,
v, gridU, gridV);
424 spline.interpolateUold(splineData, gridU, gridV, dxuv);
425 if (CAMath::Abs(dxuv[0]) > 100 || CAMath::Abs(dxuv[1]) > 100 || CAMath::Abs(dxuv[2]) > 100) {
426 dxuv[0] = dxuv[1] = dxuv[2] = 0;
434GPUdi()
void TPCFastSpaceChargeCorrection::getCorrectionInvCorrectedX(
435 int32_t slice, int32_t
row,
float corrU,
float corrV,
float&
x)
const
438 convCorrectedUVtoGrid(slice,
row, corrU, corrV, gridU, gridV);
440 const Spline2D<float, 1>& spline =
reinterpret_cast<const Spline2D<float, 1>&
>(getSpline(slice,
row));
441 const float* splineData = getSplineData(slice,
row, 1);
443 spline.interpolateU(splineData, gridU, gridV, &dx);
444 if (CAMath::Abs(dx) > 100) {
447 x = mGeo.getRowInfo(
row).x + dx;
450GPUdi()
void TPCFastSpaceChargeCorrection::getCorrectionInvUV(
451 int32_t slice, int32_t
row,
float corrU,
float corrV,
float& nomU,
float& nomV)
const
454 convCorrectedUVtoGrid(slice,
row, corrU, corrV, gridU, gridV);
456 const Spline2D<float, 2>& spline =
reinterpret_cast<const Spline2D<float, 2>&
>(getSpline(slice,
row));
457 const float* splineData = getSplineData(slice,
row, 2);
460 spline.interpolateU(splineData, gridU, gridV, duv);
461 if (CAMath::Abs(duv[0]) > 100 || CAMath::Abs(duv[1]) > 100) {
464 nomU = corrU - duv[0];
465 nomV = corrV - duv[1];
468GPUdi() float TPCFastSpaceChargeCorrection::getMaxDriftLength(int32_t slice, int32_t
row,
float pad)
const
470 const RowActiveArea&
area = getSliceRowInfo(slice,
row).activeArea;
471 const float*
c =
area.maxDriftLengthCheb;
472 float x = -1.f + 2.f * pad / mGeo.getRowInfo(
row).maxPad;
473 float y =
c[0] +
c[1] *
x;
477 for (int32_t
i = 2;
i < 5;
i++) {
478 double f =
x *
f1 - f0;
486GPUdi() float TPCFastSpaceChargeCorrection::getMaxDriftLength(int32_t slice, int32_t
row)
const
488 return getSliceRowInfo(slice,
row).activeArea.vMax;
491GPUdi() float TPCFastSpaceChargeCorrection::getMaxDriftLength(int32_t slice)
const
493 return getSliceInfo(slice).vMax;
Definition of FlatObject class.
Definition of Spline2D class.
char * releaseInternalBuffer()
_____________ Methods for making the data buffer external __________________________
static constexpr size_t getBufferAlignmentBytes()
Gives minimal alignment in bytes required for the flat buffer.
void startConstruction()
_____________ Construction _________
static constexpr size_t getClassAlignmentBytes()
_____________ Memory alignment __________________________
GPUd() void setInterpolationSafetyMargin(float val)
void moveBufferTo(char *newBufferPtr)
GPUd() void setNoCorrection()
_______________ Initialization interface ________________________
TPCFastSpaceChargeCorrection()
_____________ Constructors / destructors __________________________
Spline2D< float, 3 > SplineType
void setSplineScenario(int32_t scenarioIndex, const SplineType &spline)
Sets approximation scenario.
TPCFastSpaceChargeCorrection & operator=(const TPCFastSpaceChargeCorrection &)=delete
Assignment operator: disabled to avoid ambiguity. Use cloneTo[In/Ex]ternalBuffer() instead.
void setRowScenarioID(int32_t iRow, int32_t iScenario)
Initializes a TPC row.
void print() const
Print method.
int32_t float float float & nomU
~TPCFastSpaceChargeCorrection()
Destructor.
int32_t float float float & dx
void finishConstruction()
Finishes construction: puts everything to the flat buffer, releases temporary memory.
GPUh() double testInverse(bool prn=0)
GPUd() float getInterpolationSafetyMargin() const
Gives the interpolation safety marging around the TPC row.
int32_t float float gridV
GPUd() SliceInfo &getSliceInfo(int32_t slice)
Gives TPC slice info.
void setFutureBufferAddress(char *futureFlatBufferPtr)
TPCFastSpaceChargeCorrection(const TPCFastSpaceChargeCorrection &)=delete
Copy constructor: disabled to avoid ambiguity. Use cloneTo[In/Ex]ternalBuffer() instead.
GPUd() const SliceInfo &getSliceInfo(int32_t slice) const
Gives TPC slice info.
void constructWithNoCorrection(const TPCFastTransformGeo &geo)
int32_t float float float & gridU
int64_t getTimeStamp() const
Gives the time stamp of the current calibaration parameters.
GPUd() const SliceRowInfo &getSliceRowInfo(int32_t slice
Gives TPC slice & row info.
void setActualBufferAddress(char *actualFlatBufferPtr)
Moving the class with its external buffer to another location.
GPUd() SliceRowInfo &getSliceRowInfo(int32_t slice
Gives TPC slice & row info.
int32_t float float corrV
void cloneFromObject(const TPCFastSpaceChargeCorrection &obj, char *newFlatBufferPtr)
Construction interface.
int32_t float float float float & du
GPUd() const RowInfo &getRowInfo(int32_t row) const
Gives TPC row info.
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
ClassDefNV(RowActiveArea, 1)
float maxDriftLengthCheb[5]
The struct contains necessary info for TPC padrow.
int32_t splineScenarioID
scenario index (which of Spline2D splines to use)
size_t dataOffsetBytes[3]
offset for the spline data withing a TPC slice
float vMax
Max value of V coordinate.
ClassDefNV(SliceRowInfo, 1)
float scaleCorrUtoGrid
scale corrected U to U-grid coordinate
float scaleCorrVtoGrid
scale corrected V to V-grid coordinate
float gridCorrU0
U coordinate of the U-grid start for corrected U.
float gridV0
V coordinate of the V-grid start.
float gridCorrV0
V coordinate of the V-grid start for corrected V.