Project
Loading...
Searching...
No Matches
Utils.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
15
16#ifndef ALICEO2_COMMON_MATH_UTILS_
17#define ALICEO2_COMMON_MATH_UTILS_
18
24
25namespace o2
26{
27namespace math_utils
28{
29
30GPUdi() float to02Pi(float phi)
31{
32 return detail::to02Pi<float>(phi);
33}
34
35GPUdi() double to02Pid(double phi)
36{
37 return detail::to02Pi<double>(phi);
38}
39
40GPUdi() void bringTo02Pi(float& phi)
41{
42 detail::bringTo02Pi<float>(phi);
43}
44
45GPUdi() void bringTo02Pid(double& phi)
46{
47 detail::bringTo02Pi<double>(phi);
48}
49
50inline float toPMPiGen(float phi)
51{
52 return detail::toPMPiGen<float>(phi);
53}
54
55inline double toPMPiGend(double phi)
56{
57 return detail::toPMPiGen<double>(phi);
58}
59
60inline void bringToPMPiGen(float& phi)
61{
62 detail::bringToPMPiGen<float>(phi);
63}
64
65inline void bringToPMPiGend(double& phi)
66{
67 detail::bringToPMPiGen<double>(phi);
68}
69
70inline float to02PiGen(float phi)
71{
72 return detail::to02PiGen<float>(phi);
73}
74
75inline double to02PiGend(double phi)
76{
77 return detail::to02PiGen<double>(phi);
78}
79
80inline void bringTo02PiGen(float& phi)
81{
82 detail::bringTo02PiGen<float>(phi);
83}
84
85inline void bringTo02PiGend(double& phi)
86{
87 detail::bringTo02PiGen<double>(phi);
88}
89
90inline float toPMPi(float phi)
91{
92 return detail::toPMPi<float>(phi);
93}
94
95inline double toPMPid(double phi)
96{
97 return detail::toPMPi<double>(phi);
98}
99
100inline void bringToPMPi(float& phi)
101{
102 return detail::bringToPMPi<float>(phi);
103}
104
105inline void bringToPMPid(double& phi)
106{
107 return detail::bringToPMPi<double>(phi);
108}
109
110GPUdi() void sincos(float ang, float& s, float& c)
111{
112 detail::sincos<float>(ang, s, c);
113}
114#if !defined(__OPENCL__) && !defined(__METAL__)
115GPUdi() void sincosd(double ang, double& s, double& c)
116{
117 detail::sincos<double>(ang, s, c);
118}
119#endif
120
121GPUdi() void rotateZ(float xL, float yL, float& xG, float& yG, float snAlp, float csAlp)
122{
123 return detail::rotateZ<float>(xL, yL, xG, yG, snAlp, csAlp);
124}
125
126GPUdi() void rotateZd(double xL, double yL, double& xG, double& yG, double snAlp, double csAlp)
127{
128 return detail::rotateZ<double>(xL, yL, xG, yG, snAlp, csAlp);
129}
130
131GPUdi() void rotateZInv(float xG, float yG, float& xL, float& yL, float snAlp, float csAlp)
132{
133 detail::rotateZInv<float>(xG, yG, xL, yL, snAlp, csAlp);
134}
135
136GPUdi() void rotateZInvd(double xG, double yG, double& xL, double& yL, double snAlp, double csAlp)
137{
138 detail::rotateZInv<double>(xG, yG, xL, yL, snAlp, csAlp);
139}
140
141#ifndef GPUCA_GPUCODE_DEVICE
142inline std::tuple<float, float> rotateZInv(float xG, float yG, float snAlp, float csAlp)
143{
144 return detail::rotateZInv<float>(xG, yG, snAlp, csAlp);
145}
146
147inline std::tuple<double, double> rotateZInvd(double xG, double yG, double snAlp, double csAlp)
148{
149 return detail::rotateZInv<double>(xG, yG, snAlp, csAlp);
150}
151
152GPUdi() std::tuple<float, float> sincos(float ang)
153{
154 return detail::sincos<float>(ang);
155}
156
157GPUdi() std::tuple<double, double> sincosd(double ang)
158{
159 return detail::sincos<double>(ang);
160}
161
162inline std::tuple<float, float> rotateZ(float xL, float yL, float snAlp, float csAlp)
163{
164 return detail::rotateZ<float>(xL, yL, snAlp, csAlp);
165}
166
167inline std::tuple<double, double> rotateZd(double xL, double yL, double snAlp, double csAlp)
168{
169 return detail::rotateZ<double>(xL, yL, snAlp, csAlp);
170}
171
172inline void rotateZ(std::array<float, 3>& xy, float alpha)
173{
174 detail::rotateZ<float>(xy, alpha);
175}
176
177inline void rotateZd(std::array<double, 3>& xy, double alpha)
178{
179 detail::rotateZ<double>(xy, alpha);
180}
181#endif
182
183inline int angle2Sector(float phi)
184{
185 return detail::angle2Sector<float>(phi);
186}
187
188inline int angle2Sectord(double phi)
189{
190 return detail::angle2Sector<double>(phi);
191}
192
193inline float sector2Angle(int sect)
194{
195 return detail::sector2Angle<float>(sect);
196}
197
198inline double sector2Angled(int sect)
199{
200 return detail::sector2Angle<double>(sect);
201}
202
203inline float angle2Alpha(float phi)
204{
205 return detail::angle2Alpha<float>(phi);
206}
207
208inline double angle2Alphad(double phi)
209{
210 return detail::angle2Alpha<double>(phi);
211}
212
213GPUhdi() constexpr float fastATan2(float y, float x)
214{
215 return detail::fastATan2<float>(y, x);
216}
217
218GPUhdi() constexpr double fastATan2d(double y, double x)
219{
220 return detail::fastATan2<double>(y, x);
221}
222
223template <class T>
224GPUhdi() T min(const T x, const T y)
225{
226 return detail::min<T>(x, y);
227};
228
229GPUhdi() double mind(const double x, const double y)
230{
231 return detail::min<double>(x, y);
232};
233
234template <class T>
235GPUhdi() T max(const T x, const T y)
236{
237 return detail::max<T>(x, y);
238};
239
240GPUhdi() double maxd(const double x, const double y)
241{
242 return detail::max<double>(x, y);
243};
244
245GPUhdi() float sqrt(float x)
246{
247 return detail::sqrt<float>(x);
248};
249
250GPUhdi() double sqrtd(double x)
251{
252 return detail::sqrt<double>(x);
253};
254
255GPUhdi() float abs(float x)
256{
257 return detail::abs<float>(x);
258};
259
260GPUhdi() double absd(double x)
261{
262 return detail::abs<double>(x);
263};
264
265GPUdi() float asin(float x)
266{
267 return detail::asin<float>(x);
268};
269
270GPUdi() double asind(double x)
271{
272 return detail::asin<double>(x);
273};
274
275GPUdi() float atan(float x)
276{
277 return detail::atan<float>(x);
278};
279
280GPUdi() double atand(double x)
281{
282 return detail::atan<double>(x);
283};
284
285GPUdi() float atan2(float y, float x)
286{
287 return detail::atan2<float>(y, x);
288};
289
290GPUdi() double atan2d(double y, double x)
291{
292 return detail::atan2<double>(y, x);
293};
294
295GPUdi() float sin(float x)
296{
297 return detail::sin<float>(x);
298};
299
300GPUdi() double sind(double x)
301{
302 return detail::sin<double>(x);
303};
304
305GPUdi() float cos(float x)
306{
307 return detail::cos<float>(x);
308};
309
310GPUdi() double cosd(double x)
311{
312 return detail::cos<double>(x);
313};
314
315GPUdi() float tan(float x)
316{
317 return detail::tan<float>(x);
318};
319
320GPUdi() double tand(double x)
321{
322 return detail::tan<double>(x);
323};
324
325GPUdi() float twoPi()
326{
327 return detail::twoPi<float>();
328};
329
330GPUdi() double twoPid()
331{
332 return detail::twoPi<double>();
333};
334
335GPUdi() float pi()
336{
337 return detail::pi<float>();
338}
339
340GPUdi() double pid()
341{
342 return detail::pi<double>();
343}
344
345GPUdi() int nint(float x)
346{
347 return detail::nint<float>(x);
348};
349
350GPUdi() int nintd(double x)
351{
352 return detail::nint<double>(x);
353};
354
355GPUdi() bool finite(float x)
356{
357 return detail::finite<float>(x);
358}
359
360GPUdi() bool finited(double x)
361{
362 return detail::finite<double>(x);
363}
364
365GPUdi() unsigned int clz(unsigned int val)
366{
367 return detail::clz(val);
368};
369
370GPUdi() unsigned int popcount(unsigned int val)
371{
372 return detail::popcount(val);
373};
374
375GPUdi() float log(float x)
376{
377 return detail::log<float>(x);
378};
379
380GPUdi() double logd(double x)
381{
382 return detail::log<double>(x);
383};
384
385using detail::StatAccumulator;
386
387using detail::bit2Mask;
389using detail::truncateFloatFraction;
390
391} // namespace math_utils
392} // namespace o2
393
394#endif
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 bool
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 tan(phi) dependence of tracklet error due to radial misalignment(centered at 0 angle)") AddOptionRTC(maxChi2Red
configStandalone Reconstruction rec_tpc float
GLfloat GLfloat GLfloat alpha
Definition glcorearb.h:279
GLint GLenum GLint x
Definition glcorearb.h:403
GLint y
Definition glcorearb.h:270
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLuint GLfloat * val
Definition glcorearb.h:1582
int numberOfBitsSet(uint32_t x)
Definition bitOps.h:30
constexpr uint32_t bit2Mask(T v)
Definition bitOps.h:40
void bringToPMPiGen(float &phi)
Definition Utils.h:60
float & s
Definition Utils.h:110
float float & xG
Definition Utils.h:121
double angle2Alphad(double phi)
Definition Utils.h:208
GPUdi() float to02Pi(float phi)
Definition Utils.h:30
std::tuple< double, double > rotateZd(double xL, double yL, double snAlp, double csAlp)
Definition Utils.h:167
std::tuple< double, double > rotateZInvd(double xG, double yG, double snAlp, double csAlp)
Definition Utils.h:147
float float float float snAlp
Definition Utils.h:121
void bringTo02PiGend(double &phi)
Definition Utils.h:85
float float float float float csAlp
Definition Utils.h:122
float angle2Alpha(float phi)
Definition Utils.h:203
int angle2Sector(float phi)
Definition Utils.h:183
float float float & yG
Definition Utils.h:121
void bringTo02PiGen(float &phi)
Definition Utils.h:80
void bringToPMPid(double &phi)
Definition Utils.h:105
float toPMPi(float phi)
Definition Utils.h:90
double sector2Angled(int sect)
Definition Utils.h:198
void bringToPMPiGend(double &phi)
Definition Utils.h:65
float toPMPiGen(float phi)
Definition Utils.h:50
float to02PiGen(float phi)
Definition Utils.h:70
std::tuple< float, float > rotateZ(float xL, float yL, float snAlp, float csAlp)
Definition Utils.h:162
std::tuple< float, float > rotateZInv(float xG, float yG, float snAlp, float csAlp)
Definition Utils.h:142
double to02PiGend(double phi)
Definition Utils.h:75
float sector2Angle(int sect)
Definition Utils.h:193
double toPMPiGend(double phi)
Definition Utils.h:55
double toPMPid(double phi)
Definition Utils.h:95
void bringToPMPi(float &phi)
Definition Utils.h:100
GPUhdi() const expr float fastATan2(float y
Definition Utils.h:245
float float & c
Definition Utils.h:111
float float & xL
Definition Utils.h:131
int angle2Sectord(double phi)
Definition Utils.h:188
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
constexpr size_t min
constexpr size_t max