Project
Loading...
Searching...
No Matches
IrregularSpline2D3D.h
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#ifndef ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_IRREGULARSPLINE2D3D_H
18#define ALICEO2_GPUCOMMON_TPCFASTTRANSFORMATION_IRREGULARSPLINE2D3D_H
19
20#include "IrregularSpline1D.h"
21#include "FlatObject.h"
22#include "GPUCommonDef.h"
23
24#if !defined(__CLING__) && !defined(G__ROOT) && !defined(GPUCA_GPUCODE) && !defined(GPUCA_NO_VC)
25#include <Vc/Vc>
26#include <Vc/SimdArray>
27#endif
28
29namespace o2
30{
31namespace gpu
32{
33
65{
66 public:
68
71
74
77
80
82
84
87
89
90 void cloneFromObject(const IrregularSpline2D3D& obj, char* newFlatBufferPtr);
91 void destroy();
92
94
96 void moveBufferTo(char* newBufferPtr);
97
99
100 void setActualBufferAddress(char* actualFlatBufferPtr);
101 void setFutureBufferAddress(char* futureFlatBufferPtr);
102
104
125 void construct(int32_t numberOfKnotsU, const float knotsU[], int32_t numberOfAxisBinsU, int32_t numberOfKnotsV, const float knotsV[], int32_t numberOfAxisBinsV);
126
128 void constructRegular(int32_t numberOfKnotsU, int32_t numberOfKnotsV);
129
131
137 template <typename T>
138 GPUd() void correctEdges(T* data) const;
139
141 template <typename T>
142 GPUd() void getSpline(GPUgeneric() const T* correctedData, float u, float v, GPUgeneric() T& x, GPUgeneric() T& y, GPUgeneric() T& z) const;
143
146 GPUd() void getSplineVec(const float* correctedData, float u, float v, float& x, float& y, float& z) const;
147
149 GPUd() int32_t getNumberOfKnots() const { return mGridU.getNumberOfKnots() * mGridV.getNumberOfKnots(); }
150
152 GPUd() const IrregularSpline1D& getGridU() const { return mGridU; }
153
155 GPUd() const IrregularSpline1D& getGridV() const { return mGridV; }
156
158 GPUd() const IrregularSpline1D& getGrid(int32_t uv) const { return (uv == 0) ? mGridU : mGridV; }
159
161 GPUd() void getKnotUV(int32_t iKnot, float& u, float& v) const;
162
164 size_t getFlatBufferSize() const { return mFlatBufferSize; }
165
167 const char* getFlatBufferPtr() const { return mFlatBufferPtr; }
168
170 static constexpr size_t getClassAlignmentBytes() { return 8; }
171
173 static constexpr size_t getBufferAlignmentBytes() { return 8; }
174
176 static constexpr size_t getDataAlignmentBytes() { return 8; }
177
179
181 size_t getGridUOffset() const { return mGridU.getFlatBufferPtr() - mFlatBufferPtr; }
182
184 size_t getGridVOffset() const { return mGridV.getFlatBufferPtr() - mFlatBufferPtr; }
185
187 void print() const;
188
189 private:
193
194 IrregularSpline1D mGridU;
195 IrregularSpline1D mGridV;
196
197 ClassDefNV(IrregularSpline2D3D, 1);
198};
199
203
204GPUdi() void IrregularSpline2D3D::getKnotUV(int32_t iKnot, float& u, float& v) const
205{
207 const IrregularSpline1D& gridU = getGridU();
208 const IrregularSpline1D& gridV = getGridV();
209 int32_t nu = gridU.getNumberOfKnots();
210 int32_t iv = iKnot / nu;
211 int32_t iu = iKnot % nu;
212 u = gridU.getKnot(iu).u;
213 v = gridV.getKnot(iv).u;
214}
215
216template <typename T>
217GPUd() void IrregularSpline2D3D::correctEdges(T* data) const
218{
219 const IrregularSpline1D& gridU = getGridU();
220 const IrregularSpline1D& gridV = getGridV();
221 int32_t nu = gridU.getNumberOfKnots();
222 int32_t nv = gridV.getNumberOfKnots();
223
224 { // left edge of U
225 int32_t iu = 0;
226 const IrregularSpline1D::Knot* s = gridU.getKnots() + iu;
227 double c0, c1, c2, c3;
228 gridU.getEdgeCorrectionCoefficients(s[0].u, s[1].u, s[2].u, s[3].u, c0, c1, c2, c3);
229 for (int32_t iv = 0; iv < nv; iv++) {
230 T* f0 = data + (nu * (iv) + iu) * 3;
231 T* f1 = f0 + 3;
232 T* f2 = f0 + 6;
233 T* f3 = f0 + 9;
234 for (int32_t idim = 0; idim < 3; idim++) {
235 f0[idim] = (T)(c0 * f0[idim] + c1 * f1[idim] + c2 * f2[idim] + c3 * f3[idim]);
236 }
237 }
238 }
239
240 { // right edge of U
241 int32_t iu = nu - 4;
242 const IrregularSpline1D::Knot* s = gridU.getKnots() + iu;
243 double c0, c1, c2, c3;
244 gridU.getEdgeCorrectionCoefficients(s[3].u, s[2].u, s[1].u, s[0].u, c3, c2, c1, c0);
245 for (int32_t iv = 0; iv < nv; iv++) {
246 T* f0 = data + (nu * (iv) + iu) * 3;
247 T* f1 = f0 + 3;
248 T* f2 = f0 + 6;
249 T* f3 = f0 + 9;
250 for (int32_t idim = 0; idim < 3; idim++) {
251 f3[idim] = (T)(c0 * f0[idim] + c1 * f1[idim] + c2 * f2[idim] + c3 * f3[idim]);
252 }
253 }
254 }
255
256 { // low edge of V
257 int32_t iv = 0;
258 const IrregularSpline1D::Knot* s = gridV.getKnots() + iv;
259 double c0, c1, c2, c3;
260 gridV.getEdgeCorrectionCoefficients(s[0].u, s[1].u, s[2].u, s[3].u, c0, c1, c2, c3);
261 for (int32_t iu = 0; iu < nu; iu++) {
262 T* f0 = data + (nu * iv + iu) * 3;
263 T* f1 = f0 + nu * 3;
264 T* f2 = f0 + nu * 6;
265 T* f3 = f0 + nu * 9;
266 for (int32_t idim = 0; idim < 3; idim++) {
267 f0[idim] = (T)(c0 * f0[idim] + c1 * f1[idim] + c2 * f2[idim] + c3 * f3[idim]);
268 }
269 }
270 }
271
272 { // high edge of V
273 int32_t iv = nv - 4;
274 const IrregularSpline1D::Knot* s = gridV.getKnots() + iv;
275 double c0, c1, c2, c3;
276 gridV.getEdgeCorrectionCoefficients(s[3].u, s[2].u, s[1].u, s[0].u, c3, c2, c1, c0);
277 for (int32_t iu = 0; iu < nu; iu++) {
278 T* f0 = data + (nu * iv + iu) * 3;
279 T* f1 = f0 + nu * 3;
280 T* f2 = f0 + nu * 6;
281 T* f3 = f0 + nu * 9;
282 for (int32_t idim = 0; idim < 3; idim++) {
283 f3[idim] = (T)(c0 * f0[idim] + c1 * f1[idim] + c2 * f2[idim] + c3 * f3[idim]);
284 }
285 }
286 }
287}
288
289template <typename T>
290GPUdi() void IrregularSpline2D3D::getSpline(GPUgeneric() const T* correctedData, float u, float v, GPUgeneric() T& x, GPUgeneric() T& y, GPUgeneric() T& z) const
291{
292 // Get interpolated value for f(u,v) using data array correctedData[getNumberOfKnots()] with corrected edges
293
294 const IrregularSpline1D& gridU = getGridU();
295 const IrregularSpline1D& gridV = getGridV();
296 int32_t nu = gridU.getNumberOfKnots();
297 int32_t iu = gridU.getKnotIndex(u);
298 int32_t iv = gridV.getKnotIndex(v);
299
300 const IrregularSpline1D::Knot& knotU = gridU.getKnot(iu);
301 const IrregularSpline1D::Knot& knotV = gridV.getKnot(iv);
302
303 const T* dataV0 = correctedData + (nu * (iv - 1) + iu - 1) * 3;
304 const T* dataV1 = dataV0 + 3 * nu;
305 const T* dataV2 = dataV0 + 6 * nu;
306 const T* dataV3 = dataV0 + 9 * nu;
307
308 T dataV[12];
309 for (int32_t i = 0; i < 12; i++) {
310 dataV[i] = gridV.getSpline(knotV, dataV0[i], dataV1[i], dataV2[i], dataV3[i], v);
311 }
312
313 T* dataU0 = dataV + 0;
314 T* dataU1 = dataV + 3;
315 T* dataU2 = dataV + 6;
316 T* dataU3 = dataV + 9;
317
318 T res[3];
319 for (int32_t i = 0; i < 3; i++) {
320 res[i] = gridU.getSpline(knotU, dataU0[i], dataU1[i], dataU2[i], dataU3[i], u);
321 }
322 x = res[0];
323 y = res[1];
324 z = res[2];
325}
326
327GPUdi() void IrregularSpline2D3D::getSplineVec(const float* correctedData, float u, float v, float& x, float& y, float& z) const
328{
329 // Same as getSpline, but using vectorized calculation.
330 // \param correctedData should be at least 128-bit aligned
331
332#if !defined(__CLING__) && !defined(G__ROOT) && !defined(GPUCA_GPUCODE) && !defined(GPUCA_NO_VC)
333 const IrregularSpline1D& gridU = getGridU();
334 const IrregularSpline1D& gridV = getGridV();
335 int32_t nu = gridU.getNumberOfKnots();
336 int32_t iu = gridU.getKnotIndex(u);
337 int32_t iv = gridV.getKnotIndex(v);
338 const IrregularSpline1D::Knot& knotU = gridU.getKnot(iu);
339 const IrregularSpline1D::Knot& knotV = gridV.getKnot(iv);
340
341 const float* dataV0 = correctedData + (nu * (iv - 1) + iu - 1) * 3;
342 const float* dataV1 = dataV0 + 3 * nu;
343 const float* dataV2 = dataV0 + 6 * nu;
344 const float* dataV3 = dataV0 + 9 * nu;
345
346 // calculate F values at V==v and U == Ui of knots
347
348 Vc::SimdArray<float, 12> dataV0vec(dataV0), dataV1vec(dataV1), dataV2vec(dataV2), dataV3vec(dataV3), dataVvec = gridV.getSpline(knotV, dataV0vec, dataV1vec, dataV2vec, dataV3vec, v);
349
350 using V = std::conditional_t<(Vc::float_v::size() >= 4),
351 Vc::float_v,
352 Vc::SimdArray<float, 3>>;
353
354 float dataV[9 + V::size()];
355 // dataVvec.scatter( dataV, Vc::SimdArray<float,12>::IndexType::IndexesFromZero() );
356 // dataVvec.scatter(dataV, Vc::SimdArray<uint32_t, 12>(Vc::IndexesFromZero));
357 dataVvec.store(dataV, Vc::Unaligned);
358
359 for (uint32_t i = 12; i < 9 + V::size(); i++) { // fill not used part of the vector with 0
360 dataV[i] = 0.f;
361 }
362 // calculate F values at V==v and U == u
363 V dataU0vec(dataV), dataU1vec(dataV + 3), dataU2vec(dataV + 6), dataU3vec(dataV + 9);
364
365 V dataUVvec = gridU.getSpline(knotU, dataU0vec, dataU1vec, dataU2vec, dataU3vec, u);
366
367 x = dataUVvec[0];
368 y = dataUVvec[1];
369 z = dataUVvec[2];
370#else
371 getSpline(correctedData, u, v, x, y, z);
372#endif
373}
374} // namespace gpu
375} // namespace o2
376
377#endif
unsigned int uint32_t
Definition of FlatObject class.
int32_t i
#define GPUgeneric()
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
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 IrregularSpline1D class.
uint32_t res
Definition RawData.h:0
char * releaseInternalBuffer()
_____________ Methods for making the data buffer external __________________________
Definition FlatObject.h:538
int32_t mFlatBufferSize
size of the flat buffer
Definition FlatObject.h:320
static constexpr size_t getBufferAlignmentBytes()
Gives minimal alignment in bytes required for the flat buffer.
Definition FlatObject.h:195
static constexpr size_t getClassAlignmentBytes()
GPUCA_GPUCODE.
Definition FlatObject.h:192
void construct(int32_t numberOfKnotsU, const float knotsU[], int32_t numberOfAxisBinsU, int32_t numberOfKnotsV, const float knotsV[], int32_t numberOfAxisBinsV)
_______________ Construction interface ________________________
IrregularSpline2D3D & operator=(const IrregularSpline2D3D &)=delete
Assignment operator: disabled to avoid ambiguity. Use cloneFromObject() instead.
IrregularSpline2D3D(const IrregularSpline2D3D &)=delete
Copy constructor: disabled to avoid ambiguity. Use cloneFromObject() instead.
GPUd() const IrregularSpline1D &getGridU() const
Get 1-D grid for U coordinate.
static constexpr size_t getDataAlignmentBytes()
Get minimal required alignment for the spline data.
IrregularSpline2D3D()
_____________ Constructors / destructors __________________________
static constexpr size_t getClassAlignmentBytes()
Get minimal required alignment for the class.
void cloneFromObject(const IrregularSpline2D3D &obj, char *newFlatBufferPtr)
Construction interface.
~IrregularSpline2D3D()=default
Destructor.
GPUd() void correctEdges(T *data) const
_______________ Main functionality ________________________
void setFutureBufferAddress(char *futureFlatBufferPtr)
float float float float float &z const
void moveBufferTo(char *newBufferPtr)
size_t getGridVOffset() const
Get offset of GridV flat data in the flat buffer.
GPUd() const IrregularSpline1D &getGrid(int32_t uv) const
Get 1-D grid for U or V coordinate.
size_t getFlatBufferSize() const
Get size of the mFlatBuffer data.
GPUd() const IrregularSpline1D &getGridV() const
Get 1-D grid for V coordinate.
void setActualBufferAddress(char *actualFlatBufferPtr)
Moving the class with its external buffer to another location.
static constexpr size_t getBufferAlignmentBytes()
Get minimal required alignment for the flat buffer.
void print() const
Print method.
size_t getGridUOffset() const
technical stuff
void constructRegular(int32_t numberOfKnotsU, int32_t numberOfKnotsV)
Constructor for a regular spline.
const char * getFlatBufferPtr() const
Get pointer to the flat buffer.
GLint GLenum GLint x
Definition glcorearb.h:403
const GLdouble * v
Definition glcorearb.h:832
GLint y
Definition glcorearb.h:270
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
GPUdi() o2
Definition TrackTRD.h:39
GPUd() const expr uint32_t MultivariatePolynomialHelper< Dim
value_T f3
Definition TrackUtils.h:93
value_T f1
Definition TrackUtils.h:91
value_T f2
Definition TrackUtils.h:92
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...