Project
Loading...
Searching...
No Matches
Spline2DSpec.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
16
17#if !defined(GPUCA_STANDALONE) // code invisible in the standalone compilation
18#include "Rtypes.h"
19#endif
20
21#include "Spline2DSpec.h"
22
23#include <iostream>
24
25#if !defined(GPUCA_STANDALONE) // code invisible in the standalone compilation
26#include "TRandom.h"
27#include "Riostream.h"
28#include "TMath.h"
29#include "Spline2DHelper.h"
30#include "TFile.h"
31#include "GPUCommonMath.h"
32
35
36#endif
37
38using namespace std;
39using namespace o2::gpu;
40
41template <typename DataT, class FlatBase>
43{
45 mGridX1.destroy();
46 mGridX2.destroy();
47 mYdim = 0;
48 mParameters = nullptr;
49 if constexpr (!std::is_same_v<FlatBase, NoFlatObject>) {
50 FlatBase::destroy();
51 }
52}
53
54template <typename DataT, class FlatBase>
56{
58 if constexpr (!std::is_same_v<FlatBase, NoFlatObject>) {
59 FlatBase::setActualBufferAddress(actualFlatBufferPtr);
60
61 const size_t u2Offset = this->alignSize(mGridX1.getFlatBufferSize(), mGridX2.getBufferAlignmentBytes());
62 mParameters = nullptr;
63
64 const int32_t parametersOffset = this->alignSize(u2Offset + mGridX2.getFlatBufferSize(), getParameterAlignmentBytes());
65 mParameters = reinterpret_cast<DataT*>(this->mFlatBufferPtr + parametersOffset);
66
67 mGridX1.setActualBufferAddress(this->mFlatBufferPtr);
68 mGridX2.setActualBufferAddress(this->mFlatBufferPtr + u2Offset);
69 }
70}
71
72template <typename DataT, class FlatBase>
74{
76 if constexpr (!std::is_same_v<FlatBase, NoFlatObject>) {
77 char* bufferU = FlatBase::relocatePointer(this->mFlatBufferPtr, futureFlatBufferPtr, mGridX1.getFlatBufferPtr());
78 char* bufferV = FlatBase::relocatePointer(this->mFlatBufferPtr, futureFlatBufferPtr, mGridX2.getFlatBufferPtr());
79 mGridX1.setFutureBufferAddress(bufferU);
80 mGridX2.setFutureBufferAddress(bufferV);
81 mParameters = FlatBase::relocatePointer(this->mFlatBufferPtr, futureFlatBufferPtr, mParameters);
82 FlatBase::setFutureBufferAddress(futureFlatBufferPtr);
83 }
84}
85
86template <typename DataT, class FlatBase>
88{
89 if constexpr (!std::is_same_v<FlatBase, NoFlatObject>) {
90 printf(" Irregular Spline 2D: \n");
91 printf(" grid U1: \n");
92 mGridX1.print();
93 printf(" grid U2: \n");
94 mGridX2.print();
95 }
96}
97
98template <typename DataT, class FlatBase>
100{
102 if constexpr (!std::is_same_v<FlatBase, NoFlatObject>) {
103 const char* oldFlatBufferPtr = obj.mFlatBufferPtr;
104
105 FlatBase::cloneFromObject(obj, newFlatBufferPtr);
106
107 mYdim = obj.mYdim;
108 char* bufferU = FlatBase::relocatePointer(oldFlatBufferPtr, this->mFlatBufferPtr, obj.mGridX1.getFlatBufferPtr());
109 char* bufferV = FlatBase::relocatePointer(oldFlatBufferPtr, this->mFlatBufferPtr, obj.mGridX2.getFlatBufferPtr());
110
111 mGridX1.cloneFromObject(obj.mGridX1, bufferU);
112 mGridX2.cloneFromObject(obj.mGridX2, bufferV);
113 mParameters = FlatBase::relocatePointer(oldFlatBufferPtr, this->mFlatBufferPtr, obj.mParameters);
114 }
115}
116
117template <typename DataT, class FlatBase>
119{
121 if constexpr (!std::is_same_v<FlatBase, NoFlatObject>) {
122 char* oldFlatBufferPtr = this->mFlatBufferPtr;
123 FlatBase::moveBufferTo(newFlatBufferPtr);
124 char* currFlatBufferPtr = this->mFlatBufferPtr;
125 this->mFlatBufferPtr = oldFlatBufferPtr;
126 setActualBufferAddress(currFlatBufferPtr);
127 }
128}
129
130template <typename DataT, class FlatBase>
131template <class OtherFlatBase>
133{
136 mYdim = src.getYdimensions();
137 this->mFlatBufferSize = src.getFlatBufferSize();
138 mGridX1.importFrom(src.getGridX1());
139 mGridX2.importFrom(src.getGridX2());
140 mParameters = nullptr;
141}
142
143template <typename DataT, class FlatBase>
145 int32_t nYdim,
146 int32_t numberOfKnotsU1, const int32_t knotsU1[], int32_t numberOfKnotsU2, const int32_t knotsU2[])
147{
149 if constexpr (!std::is_same_v<FlatBase, NoFlatObject>) {
150 mYdim = nYdim;
151 FlatBase::startConstruction();
152
153 mGridX1.recreate(0, numberOfKnotsU1, knotsU1);
154 mGridX2.recreate(0, numberOfKnotsU2, knotsU2);
155
156 const size_t u2Offset = this->alignSize(mGridX1.getFlatBufferSize(), mGridX2.getBufferAlignmentBytes());
157 int32_t parametersOffset = u2Offset + mGridX2.getFlatBufferSize();
158 int32_t bufferSize = parametersOffset;
159 mParameters = nullptr;
160
161 parametersOffset = this->alignSize(bufferSize, getParameterAlignmentBytes());
162 bufferSize = parametersOffset + getSizeOfParameters();
163
164 FlatBase::finishConstruction(bufferSize);
165
166 mGridX1.moveBufferTo(this->mFlatBufferPtr);
167 mGridX2.moveBufferTo(this->mFlatBufferPtr + u2Offset);
168
169 mParameters = reinterpret_cast<DataT*>(this->mFlatBufferPtr + parametersOffset);
170 for (int32_t i = 0; i < getNumberOfParameters(); i++) {
171 mParameters[i] = 0;
172 }
173 }
174}
175
176template <typename DataT, class FlatBase>
178 int32_t numberOfKnotsU1, int32_t numberOfKnotsU2)
179{
181 if constexpr (!std::is_same_v<FlatBase, NoFlatObject>) {
182 mYdim = nYdim;
183 FlatBase::startConstruction();
184
185 mGridX1.recreate(0, numberOfKnotsU1);
186 mGridX2.recreate(0, numberOfKnotsU2);
187
188 const size_t u2Offset = this->alignSize(mGridX1.getFlatBufferSize(), mGridX2.getBufferAlignmentBytes());
189 int32_t parametersOffset = u2Offset + mGridX2.getFlatBufferSize();
190 int32_t bufferSize = parametersOffset;
191 mParameters = nullptr;
192
193 parametersOffset = this->alignSize(bufferSize, getParameterAlignmentBytes());
194 bufferSize = parametersOffset + getSizeOfParameters();
195
196 FlatBase::finishConstruction(bufferSize);
197
198 mGridX1.moveBufferTo(this->mFlatBufferPtr);
199 mGridX2.moveBufferTo(this->mFlatBufferPtr + u2Offset);
200
201 mParameters = reinterpret_cast<DataT*>(this->mFlatBufferPtr + parametersOffset);
202 for (int32_t i = 0; i < getNumberOfParameters(); i++) {
203 mParameters[i] = 0;
204 }
205 }
206}
207
208#if !defined(GPUCA_STANDALONE) // code invisible in the standalone compilation
209
210template <typename DataT, class FlatBase>
212 double x1Min, double x1Max, double x2Min, double x2Max,
213 std::function<void(double x1, double x2, double f[])> F,
214 int32_t nAuxiliaryDataPointsX1, int32_t nAuxiliaryDataPointsX2)
215{
218 helper.approximateFunction(*reinterpret_cast<Spline2D<DataT>*>(this), x1Min, x1Max, x2Min, x2Max, F, nAuxiliaryDataPointsX1, nAuxiliaryDataPointsX2);
219}
220
221template <typename DataT, class FlatBase>
223 double x1Min, double x1Max, double x2Min, double x2Max,
224 std::function<void(double x1, double x2, double f[])> F,
225 int32_t nAuxiliaryDataPointsX1, int32_t nAuxiliaryDataPointsX2)
226{
229 helper.approximateFunctionViaDataPoints(*reinterpret_cast<Spline2D<DataT>*>(this), x1Min, x1Max, x2Min, x2Max, F, nAuxiliaryDataPointsX1, nAuxiliaryDataPointsX2);
230}
231
232template <typename DataT, class FlatBase>
234{
236 if constexpr (std::is_same_v<FlatBase, FlatObject>) {
237 return FlatObject::writeToFile(*this, outf, name);
238 } else {
239 return -1;
240 }
241}
242
243template <typename DataT, class FlatBase>
245{
247 if constexpr (std::is_same_v<FlatBase, FlatObject>) {
248 return FlatObject::readFromFile<Spline2DContainerBase<DataT, FlatBase>>(inpf, name);
249 } else {
250 return nullptr;
251 }
252}
253
254template <typename DataT, class FlatBase>
256{
258}
259
260#endif // !GPUCA_STANDALONE
261
264
265// Explicit instantiations for NoFlatObject (used by TPCFastTransformPOD)
268// importFrom instantiation for the FlatObject -> NoFlatObject conversion used in create()
int32_t i
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
Definition of Spline2DHelper class.
templateClassImp(o2::gpu::Spline2DContainerBase)
Definition of Spline2DSpec class.
static int32_t writeToFile(T &obj, TFile &outf, const char *name)
write a child class object to the file
Definition FlatObject.h:492
void importFrom(const Spline2DContainerBase< DataT, OtherFlatBase > &src)
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)
int32_t mYdim
_____________ Data members ____________
void setFutureBufferAddress(char *futureFlatBufferPtr)
void moveBufferTo(char *newBufferPtr)
void recreate(int32_t nYdim, int32_t nKnotsX1, int32_t nKnotsX2)
Constructor for a regular spline.
static int32_t test(const bool draw=0, const bool drawDataPoints=1)
_______________ Test tools _______________
void setActualBufferAddress(char *actualFlatBufferPtr)
static Spline2DContainerBase * readFromFile(TFile &inpf, const char *name)
read a class object from the file
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 ________________________
int32_t writeToFile(TFile &outf, const char *name)
_______________ IO ________________________
void cloneFromObject(const Spline2DContainerBase &obj, char *newFlatBufferPtr)
_____________ FlatObject functionality, see FlatObject class for description ____________
Spline1D< DataT, 0, FlatBase > mGridX1
grid for U axis
Spline1D< DataT, 0, FlatBase > mGridX2
grid for V axis
void approximateFunctionViaDataPoints(Spline2DContainerBase< DataT, FlatObject > &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)
void approximateFunction(Spline2DContainerBase< DataT, FlatObject > &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 ________________________
static int32_t test(const bool draw=0, const bool drawDataPoints=1)
Test the Spline2D class functionality.
Forward declaration — specializations below select ClassDefNV based on FlatBase.
Definition Spline2D.h:104
GLuint GLfloat GLfloat GLfloat x1
Definition glcorearb.h:5034
GLuint const GLchar * name
Definition glcorearb.h:781
GLdouble f
Definition glcorearb.h:310
size_t alignSize(size_t sizeBytes)
align size to given diven number of bytes
TCanvas * drawDataPoints(TMultiGraph *mg, double min, double max)