17#ifndef ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_SPLINE1DSPEC_H
18#define ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_SPLINE1DSPEC_H
24#if !defined(GPUCA_GPUCODE)
36template <
typename DataT>
57template <
typename DataT,
class FlatBase = FlatObject>
86 GPUd() size_t getParameterAlignmentBytes()
const
88 size_t s = 2 *
sizeof(DataT) *
mYdim;
89 return (
s < 16) ?
s : 16;
96 GPUd() size_t getSizeOfParameters()
const {
return sizeof(DataT) * getNumberOfParameters(); }
124 GPUd()
int32_t calcNumberOfParameters(
int32_t nYdim)
const {
return (2 * nYdim) * getNumberOfKnots(); }
134template <
typename DataT,
typename FlatBase = FlatObject>
137template <
typename DataT>
142 GPUd() const
int32_t* getUtoKnotMap()
const {
return mUtoKnotMap; }
145 GPUd() const
Knot<DataT>* getKnots()
const {
return reinterpret_cast<const Knot<DataT>*
>(this->mFlatBufferPtr); }
148 template <SafetyLevel SafeT = SafetyLevel::kSafe>
152 i = (
i < 0) ? 0 : (
i >= this->getNumberOfKnots() ? this->getNumberOfKnots() - 1 :
i);
154 return getKnots()[
i];
158 template <SafetyLevel SafeT = SafetyLevel::kSafe>
162 GPUd() DataT* getParameters() {
return mParameters; }
165 GPUd() const DataT* getParameters()
const {
return mParameters; }
167#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE)
184#if !defined(GPUCA_GPUCODE)
190 template <
class OtherFlatBase>
199#if !defined(GPUCA_GPUCODE)
211 DataT* mParameters =
nullptr;
216template <
typename DataT>
221 GPUd() const
int32_t* getUtoKnotMapFromBuffer(const
char* flatBuf)
const
223 return reinterpret_cast<const int32_t*
>(flatBuf + this->getNumberOfKnots() *
sizeof(
Knot<DataT>));
228 template <SafetyLevel SafeT = SafetyLevel::kSafe>
229 GPUd()
int32_t getLeftKnotIndexForUFromBuffer(const
char* flatBuf, DataT u)
const
231 int32_t iu = u < 0 ? 0 : (u > (
float)this->mUmax ? this->mUmax : (
int32_t)u);
233 iu = (iu < 0) ? 0 : (iu > this->mUmax ? this->mUmax : iu);
241 GPUd() const
Knot<DataT>* getKnotsFromBuffer(const
char* flatBuf)
const {
return reinterpret_cast<const Knot<DataT>*
>(flatBuf); }
245 template <SafetyLevel SafeT = SafetyLevel::kSafe>
249 i = (
i < 0) ? 0 : (
i >= this->getNumberOfKnots() ? this->getNumberOfKnots() - 1 :
i);
251 return getKnotsFromBuffer(flatBuf)[
i];
257 this->mNumberOfKnots = 0;
261 this->mXtoUscale = 1.;
262 this->mFlatBufferSize = 0;
267#if !defined(GPUCA_GPUCODE)
269 template <
class OtherFlatBase>
272 this->mYdim =
src.getYdimensions();
273 this->mNumberOfKnots =
src.getNumberOfKnots();
274 this->mUmax =
src.getUmax();
275 this->mXmin =
src.getXmin();
276 this->mXtoUscale =
src.getXtoUscale();
277 this->mFlatBufferSize =
src.getFlatBufferSize();
282template <
typename DataT>
283template <SafetyLevel SafeT>
284GPUdi()
int32_t Spline1DContainer<DataT, FlatObject>::getLeftKnotIndexForU(DataT u)
const
288 int32_t iu = u < 0 ? 0 : (u > (
float)this->mUmax ? this->mUmax : (
int32_t)u);
290 iu = (iu < 0) ? 0 : (iu > this->mUmax ? this->mUmax : iu);
292 return getUtoKnotMap()[iu];
295template <
typename DataT,
class FlatBase>
296GPUdi()
void Spline1DContainerBase<DataT, FlatBase>::setXrange(DataT xMin, DataT xMax)
299 double l = ((double)xMax) - xMin;
303 mXtoUscale = this->mUmax / l;
326template <
typename DataT,
int32_t YdimT,
int32_t SpecT,
class FlatBase = FlatObject>
333template <
typename DataT,
int32_t YdimT,
class FlatBase>
346 if constexpr (std::is_same_v<FlatBase, FlatObject>) {
347 interpolateAtU<SafetyLevel::kSafe>(this->mYdim, this->mParameters, this->convXtoU(
x),
S);
352 template <SafetyLevel SafeT = SafetyLevel::kSafe>
355 if constexpr (std::is_same_v<FlatBase, FlatObject>) {
356 const auto nYdimTmp = SplineUtil::getNdim<YdimT>(inpYdim);
357 const auto nYdim = nYdimTmp.get();
358 int32_t iknot = this->
template getLeftKnotIndexForU<SafeT>(u);
360 interpolateAtU(nYdim, this->getKnots()[iknot], &(
d[0]), &(
d[nYdim]), &(
d[2 * nYdim]), &(
d[3 * nYdim]), u,
S);
367 template <
typename T>
373 const auto nYdimTmp = SplineUtil::getNdim<YdimT>(inpYdim);
374 const auto nYdim = nYdimTmp.get();
376 T dSdSl, dSdDl, dSdSr, dSdDr;
377 getSderivativesOverParsAtU<T>(knotL, u, dSdSl, dSdDl, dSdSr, dSdDr);
379 for (
int32_t dim = 0; dim < nYdim; ++dim) {
380 S[dim] = dSdSr * Sr[dim] + dSdSl * Sl[dim] + dSdDl * Dl[dim] + dSdDr * Dr[dim];
405 template <
typename T>
406 GPUd()
void getSderivativesOverParsAtU(const
KnotType& knotL, DataT u, T& dSdSl, T& dSdDl, T& dSdSr, T& dSdDr)
const
414 if (u > (DataT)Container::getUmax()) {
415 u = (DataT)Container::getUmax();
419 T
v = u * T(knotL.Li);
424 dSdSl = T(1.) - dSdSr;
430 template <
typename T>
431 GPUd()
void getSDderivativesOverParsAtU(const
KnotType& knotL, DataT u, T& dSdSl, T& dSdDl, T& dSdSr, T& dSdDr, T& dDdSl, T& dDdDl, T& dDdSr, T& dDdDr)
const
439 if (u > (DataT)Container::getUmax()) {
440 u = (DataT)Container::getUmax();
444 T
v = u * T(knotL.Li);
448 dSdSr =
v2 * (T(3.) -
v -
v);
449 dSdSl = T(1.) - dSdSr;
454 dDdSr = T(6.) *
v * (T(1.) -
v) * dv;
456 dDdDl = vm1 * (
v +
v + vm1);
457 dDdDr =
v * (
v + vm1 + vm1);
467template <
typename DataT,
int32_t YdimT,
class FlatBase>
473#if !defined(GPUCA_GPUCODE)
477 if constexpr (!std::is_same_v<FlatBase, NoFlatObject>) {
502 GPUd() constexpr
size_t getParameterAlignmentBytes()
const
504 size_t s = 2 *
sizeof(DataT) * YdimT;
505 return (
s < 16) ?
s : 16;
509 GPUd()
int32_t getNumberOfParameters()
const {
return (2 * YdimT) * this->getNumberOfKnots(); }
512 GPUd() size_t getSizeOfParameters()
const {
return (
sizeof(DataT) * 2 * YdimT) * this->getNumberOfKnots(); }
517 template <SafetyLevel SafeT = SafetyLevel::kSafe>
520 ParentSpec::template interpolateAtU<SafeT>(YdimT,
Parameters, u,
S);
525 template <
typename T>
526 GPUd()
void interpolateAtU(const typename ParentSpec::KnotType& knotL,
531 ParentSpec::interpolateAtU(YdimT, knotL, Sl, Dl, Sr, Dr, u,
S);
539template <
typename DataT,
int32_t YdimT,
class FlatBase>
546#if !defined(GPUCA_GPUCODE)
550 if constexpr (!std::is_same_v<FlatBase, NoFlatObject>) {
551 ParentSpec::recreate(0, 2);
558 ParentSpec::recreate(nYdim, numberOfKnots);
564 ParentSpec::recreate(nYdim, numberOfKnots, knotU);
570 Container::cloneFromObject(
v,
nullptr);
584template <
typename DataT,
class FlatBase>
591 GPUd() DataT interpolate(DataT
x)
const
594 ParentSpec::interpolate(
x, &
S);
Definition of FlatObject class.
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
GPUd() int32_t getNumberOfParameters() const
Number of parameters.
GPUd() DataT convXtoU(DataT x) const
_______________ Technical stuff ________________________
GPUd() size_t getSizeOfParameters() const
Size of the parameter array in bytes.
GPUd() DataT getXmin() const
Get Xmin.
GPUd() int32_t getUmax() const
_______________ Getters ________________________
DataT mXtoUscale
a scaling factor to convert X to U
int32_t mYdim
_____________ Data members ____________
GPUd() static const expr int32_t getVersion()
_____________ Version control __________________________
Spline1DContainerBase(const Spline1DContainerBase &)=delete
Disable all other constructors.
~Spline1DContainerBase()=default
Destructor.
GPUd() DataT convUtoX(DataT u) const
Convert U coordinate to X.
GPUd() int32_t getNumberOfKnots() const
Get a number of knots.
DataT mXmin
X of the first knot.
GPUd() size_t getParameterAlignmentBytes() const
Get minimal required alignment for the spline parameters.
int32_t mNumberOfKnots
n knots on the grid
GPUd() DataT getXmax() const
Get Xmax.
GPUd() DataT getXtoUscale() const
Get XtoUscale.
GPUd() void setXrange(DataT xMin
Set X range.
GPUd() int32_t getYdimensions() const
Get number of Y dimensions.
Spline1DContainerBase()=default
_____________ C++ constructors / destructors __________________________
int32_t mUmax
U of the last knot.
void setFutureBufferAddress(char *futureFlatBufferPtr)
void importFrom(const Spline1DContainerBase< DataT, OtherFlatBase > &src)
Knot< DataT > * getKnots()
Non-const accessor to the knots array.
static Spline1DContainer * readFromFile(TFile &inpf, const char *name)
read a class object from the file
void recreate(int32_t nYdim, int32_t numberOfKnots, const int32_t knotU[])
ClassDefNV(Spline1DContainer, 1)
(transient!!) pointer to F-dependent parameters inside the mFlatBufferPtr array
void print() const
Print method.
GPUd() int32_t getLeftKnotIndexForU(DataT u) const
Get index of an associated knot for a given U coordinate. Performs a boundary check.
void moveBufferTo(char *newBufferPtr)
void setActualBufferAddress(char *actualFlatBufferPtr)
void recreate(int32_t nYdim, int32_t numberOfKnots)
GPUd() const Knot< DataT > *getKnots() const
Get the array of knots.
void approximateFunction(double xMin, double xMax, std::function< void(double x, double f[])> F, int32_t nAuxiliaryDataPoints=4)
approximate a function F with this spline
GPUd() const int32_t *getUtoKnotMap() const
Get a map (integer U -> corresponding knot index)
GPUd() const Knot< DataT > &getKnot(int32_t i) const
Get i-th knot.
int32_t writeToFile(TFile &outf, const char *name)
write a class object to the file
GPUd() const DataT *getParameters() const
Get spline parameters const.
int32_t * getUtoKnotMap()
Non-const accessor to U->knots map.
static int32_t test(const bool draw=0, const bool drawDataPoints=1)
Test the class functionality.
void cloneFromObject(const Spline1DContainer &obj, char *newFlatBufferPtr)
return getUtoKnotMapFromBuffer(flatBuf)[iu]
GPUdi() void setActualBufferAddress(char *)
void importFrom(const Spline1DContainerBase< DataT, OtherFlatBase > &src)
Copy schema fields from a spline with a different FlatBase (no pointer members to copy).
GPUd() const int32_t *getUtoKnotMapFromBuffer(const char *flatBuf) const
Get the U->knot-index map from an explicit flat buffer pointer.
GPUdi() void setFutureBufferAddress(char *)
GPUd() const Knot< DataT > *getKnotsFromBuffer(const char *flatBuf) const
GPUd() DataT interpolate(DataT x) const
Simplified interface for 1D: return the interpolated value.
GPUd() void interpolateAtU(int32_t inpYdim
Get interpolated value for an nYdim-dimensional S(u) using spline parameters Parameters.
GPUd() void interpolate(DataT x
_______________ Interpolation math ________________________
GPUd() size_t getSizeOfParameters() const
Size of the parameter array in bytes.
Spline1DSpec(int32_t numberOfKnots, const int32_t knotU[])
Constructor for an irregular spline.
void recreate(int32_t numberOfKnots)
Constructor for a regular spline.
void recreate(int32_t numberOfKnots, const int32_t knotU[])
Constructor for an irregular spline.
GPUd() void interpolateAtU(GPUgeneric() const DataT Parameters[]
_______ Expert tools: interpolation with given nYdim and external Parameters _______
Spline1DSpec()
Default constructor — skips recreate for NoFlatObject (no owned buffer)
GPUd() int32_t getNumberOfParameters() const
Number of parameters.
Spline1DSpec(int32_t numberOfKnots)
Constructor for a regular spline.
GPUd() const expr int32_t getYdimensions() const
Get number of Y dimensions.
Spline1DSpec(const Spline1DSpec &v)
Copy constructor.
GPUd() const expr size_t getParameterAlignmentBytes() const
Get minimal required alignment for the spline parameters.
Spline1DSpec(const Spline1DSpec &v)
Copy constructor.
void recreate(int32_t nYdim, int32_t numberOfKnots)
Constructor for a regular spline.
void recreate(int32_t nYdim, int32_t numberOfKnots, const int32_t knotU[])
Constructor for an irregular spline.
Spline1DSpec()
Default constructor — skips recreate for NoFlatObject (no owned buffer)
Spline1DSpec(int32_t nYdim, int32_t numberOfKnots, const int32_t knotU[])
Constructor for an irregular spline.
Spline1DSpec(int32_t nYdim, int32_t numberOfKnots)
Constructor for a regular spline.
static constexpr int32_t getSpec(int32_t nXdim, int32_t nYdim)
GLuint const GLchar * name
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLboolean GLboolean GLboolean GLboolean a
GLfloat GLfloat GLfloat v2
SafetyLevel
Named enumeration for the safety level used by some methods.
GPUd() const expr uint32_t MultivariatePolynomialHelper< Dim
TCanvas * drawDataPoints(TMultiGraph *mg, double min, double max)
GPUd() int32_t getU() const
Get u as an integer.
DataT u
u coordinate of the knot i (an integer number in float format)