17#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
23#if !defined(GPUCA_GPUCODE)
27#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
45template <
typename DataT>
52 mParameters =
nullptr;
56template <
typename DataT>
63 const size_t u2Offset = alignSize(mGridX1.getFlatBufferSize(), mGridX2.getBufferAlignmentBytes());
64 int32_t parametersOffset = u2Offset;
66 mParameters =
nullptr;
68 parametersOffset = alignSize(u2Offset + mGridX2.getFlatBufferSize(), getParameterAlignmentBytes());
70 mParameters =
reinterpret_cast<DataT*
>(mFlatBufferPtr + parametersOffset);
72 mGridX1.setActualBufferAddress(mFlatBufferPtr);
73 mGridX2.setActualBufferAddress(mFlatBufferPtr + u2Offset);
76template <
typename DataT>
80 char* bufferU = relocatePointer(mFlatBufferPtr, futureFlatBufferPtr, mGridX1.getFlatBufferPtr());
81 char* bufferV = relocatePointer(mFlatBufferPtr, futureFlatBufferPtr, mGridX2.getFlatBufferPtr());
82 mGridX1.setFutureBufferAddress(bufferU);
83 mGridX2.setFutureBufferAddress(bufferV);
84 mParameters = relocatePointer(mFlatBufferPtr, futureFlatBufferPtr, mParameters);
88template <
typename DataT>
91 printf(
" Irregular Spline 2D: \n");
92 printf(
" grid U1: \n");
94 printf(
" grid U2: \n");
98#if !defined(GPUCA_GPUCODE)
100template <
typename DataT>
113 mGridX1.cloneFromObject(obj.
mGridX1, bufferU);
114 mGridX2.cloneFromObject(obj.
mGridX2, bufferV);
118template <
typename DataT>
122 char* oldFlatBufferPtr = mFlatBufferPtr;
124 char* currFlatBufferPtr = mFlatBufferPtr;
125 mFlatBufferPtr = oldFlatBufferPtr;
126 setActualBufferAddress(currFlatBufferPtr);
129template <
typename DataT>
132 int32_t numberOfKnotsU1,
const int32_t knotsU1[], int32_t numberOfKnotsU2,
const int32_t knotsU2[])
139 mGridX1.recreate(0, numberOfKnotsU1, knotsU1);
140 mGridX2.recreate(0, numberOfKnotsU2, knotsU2);
142 const size_t u2Offset = alignSize(mGridX1.getFlatBufferSize(), mGridX2.getBufferAlignmentBytes());
143 int32_t parametersOffset = u2Offset + mGridX2.getFlatBufferSize();
144 int32_t bufferSize = parametersOffset;
145 mParameters =
nullptr;
147 parametersOffset = alignSize(bufferSize, getParameterAlignmentBytes());
148 bufferSize = parametersOffset + getSizeOfParameters();
152 mGridX1.moveBufferTo(mFlatBufferPtr);
153 mGridX2.moveBufferTo(mFlatBufferPtr + u2Offset);
155 mParameters =
reinterpret_cast<DataT*
>(mFlatBufferPtr + parametersOffset);
156 for (int32_t
i = 0;
i < getNumberOfParameters();
i++) {
161template <
typename DataT>
163 int32_t numberOfKnotsU1, int32_t numberOfKnotsU2)
170 mGridX1.recreate(0, numberOfKnotsU1);
171 mGridX2.recreate(0, numberOfKnotsU2);
173 const size_t u2Offset = alignSize(mGridX1.getFlatBufferSize(), mGridX2.getBufferAlignmentBytes());
174 int32_t parametersOffset = u2Offset + mGridX2.getFlatBufferSize();
175 int32_t bufferSize = parametersOffset;
176 mParameters =
nullptr;
178 parametersOffset = alignSize(bufferSize, getParameterAlignmentBytes());
179 bufferSize = parametersOffset + getSizeOfParameters();
183 mGridX1.moveBufferTo(mFlatBufferPtr);
184 mGridX2.moveBufferTo(mFlatBufferPtr + u2Offset);
186 mParameters =
reinterpret_cast<DataT*
>(mFlatBufferPtr + parametersOffset);
187 for (int32_t
i = 0;
i < getNumberOfParameters();
i++) {
194#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
196template <
typename DataT>
198 double x1Min,
double x1Max,
double x2Min,
double x2Max,
199 std::function<
void(
double x1,
double x2,
double f[])> F,
200 int32_t nAuxiliaryDataPointsX1, int32_t nAuxiliaryDataPointsX2)
207template <
typename DataT>
209 double x1Min,
double x1Max,
double x2Min,
double x2Max,
210 std::function<
void(
double x1,
double x2,
double f[])> F,
211 int32_t nAuxiliaryDataPointsX1, int32_t nAuxiliaryDataPointsX2)
218template <
typename DataT>
225template <
typename DataT>
227 TFile& inpf,
const char*
name)
230 return FlatObject::readFromFile<Spline2DContainer<DataT>>(inpf,
name);
233template <
typename DataT>
Definition of Spline2DHelper class.
templateClassImp(o2::gpu::Spline2DContainer)
Definition of Spline2DSpec class.
void setFutureBufferAddress(char *futureFlatBufferPtr)
void destroy()
_______________ Utilities _______________________________________________
static T * relocatePointer(const char *oldBase, char *newBase, const T *ptr)
Relocates a pointer inside a buffer to the new buffer address.
void setActualBufferAddress(char *actualFlatBufferPtr)
_____________ Methods for moving the class with its external buffer to another location _____________...
static int32_t writeToFile(T &obj, TFile &outf, const char *name)
write a child class object to the file
void startConstruction()
_____________ Construction _________
void moveBufferTo(char *newBufferPtr)
void finishConstruction(int32_t flatBufferSize)
void cloneFromObject(const FlatObject &obj, char *newFlatBufferPtr)
void cloneFromObject(const Spline2DContainer &obj, char *newFlatBufferPtr)
void approximateFunction(double x1Min, double x1Max, double x2Min, double x2Max, std::function< void(double x1, double x2, double f[])> F, int32_t nAuxiliaryDataPointsU1=4, int32_t nAuxiliaryDataPointsU2=4)
_______________ Construction interface ________________________
void recreate(int32_t nYdim, int32_t nKnotsX1, int32_t nKnotsX2)
Constructor for a regular spline.
void setActualBufferAddress(char *actualFlatBufferPtr)
void print() const
Print method.
Spline1D< DataT > mGridX2
grid for V axis
int32_t mYdim
_____________ Data members ____________
void moveBufferTo(char *newBufferPtr)
int32_t writeToFile(TFile &outf, const char *name)
_______________ IO ________________________
static Spline2DContainer * readFromFile(TFile &inpf, const char *name)
read a class object from the file
static int32_t test(const bool draw=0, const bool drawDataPoints=1)
_______________ Test tools _______________
Spline1D< DataT > mGridX1
grid for U axis
void setFutureBufferAddress(char *futureFlatBufferPtr)
void approximateFunctionViaDataPoints(double x1Min, double x1Max, double x2Min, double x2Max, std::function< void(double x1, double x2, double f[])> F, int32_t nAuxiliaryDataPointsX1, int32_t nAuxiliaryDataPointsX2)
void approximateFunction(Spline2DContainer< DataT > &spline, double x1Min, double x1Max, double x2Min, double x2Max, std::function< void(double x1, double x2, double f[])> F, int32_t nAuxiliaryDataPointsU1=4, int32_t nAuxiliaryDataPointsU2=4)
_______________ Main functionality ________________________
void approximateFunctionViaDataPoints(Spline2DContainer< DataT > &spline, double x1Min, double x1Max, double x2Min, double x2Max, std::function< void(double x1, double x2, double f[])> F, int32_t nAuxiliaryDataPointsU1=4, int32_t nAuxiliaryDataPointsU2=4)
static int32_t test(const bool draw=0, const bool drawDataPoints=1)
Test the Spline2D class functionality.
GLuint GLfloat GLfloat GLfloat x1
GLuint const GLchar * name
Defining DataPointCompositeObject explicitly as copiable.
TCanvas * drawDataPoints(TMultiGraph *mg, double min, double max)