Project
Loading...
Searching...
No Matches
MathUtils.h
Go to the documentation of this file.
1// Copyright 2019-2026 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.
15
16#ifndef O2_ITS_TRACKING_MATHUTILS_H_
17#define O2_ITS_TRACKING_MATHUTILS_H_
18
21#include "MathUtils/Utils.h"
22#include "GPUCommonMath.h"
23#include "GPUCommonDef.h"
24
26{
27
28GPUhdi() constexpr float computePhi(float x, float y)
29{
30 return o2::math_utils::fastATan2(-y, -x) + o2::constants::math::PI;
31}
32
33GPUhdi() constexpr float hypot(float x, float y)
34{
35 return o2::gpu::CAMath::Hypot(x, y);
36}
37
38GPUhdi() constexpr float getNormalizedPhi(float phi)
39{
40 phi -= o2::constants::math::TwoPI * o2::gpu::CAMath::Floor(phi * (1.f / o2::constants::math::TwoPI));
41 return phi;
42}
43
44GPUhdi() constexpr float computeNormalizedPhi(float x, float y)
45{
46 return getNormalizedPhi(computePhi(x, y));
47}
48
49GPUhdi() float computeCurvature(float x1, float y1, float x2, float y2, float x3, float y3)
50{
51 // in case the triangle is degenerate we return infinite curvature.
52 const float area = ((x2 - x1) * (y3 - y1)) - ((x3 - x1) * (y2 - y1));
53 if (o2::gpu::CAMath::Abs(area) < constants::Tolerance) {
54 return o2::constants::math::Almost0;
55 }
56 const float dx1 = x2 - x1, dy1 = y2 - y1;
57 const float dx2 = x3 - x2, dy2 = y3 - y2;
58 const float dx3 = x1 - x3, dy3 = y1 - y3;
59 const float d1 = o2::gpu::CAMath::Sqrt((dx1 * dx1) + (dy1 * dy1));
60 const float d2 = o2::gpu::CAMath::Sqrt((dx2 * dx2) + (dy2 * dy2));
61 const float d3 = o2::gpu::CAMath::Sqrt((dx3 * dx3) + (dy3 * dy3));
62 return -2.f * area / (d1 * d2 * d3);
63}
64
65GPUhdi() float computeCurvatureCentreX(float x1, float y1, float x2, float y2, float x3, float y3)
66{
67 // in case the triangle is degenerate we return set the centre to infinity.
68 float dx21 = x2 - x1, dx32 = x3 - x2;
69 if (o2::gpu::CAMath::Abs(dx21) < o2::its::constants::Tolerance ||
70 o2::gpu::CAMath::Abs(dx32) < o2::its::constants::Tolerance) { // add small offset
71 x2 += 1e-4f;
72 dx21 = x2 - x1;
73 dx32 = x3 - x2;
74 }
75 const float k1 = (y2 - y1) / dx21, k2 = (y3 - y2) / dx32;
76 if (o2::gpu::CAMath::Abs(k2 - k1) < o2::its::constants::Tolerance) {
77 return o2::constants::math::VeryBig;
78 }
79 return 0.5f * (k1 * k2 * (y1 - y3) + k2 * (x1 + x2) - k1 * (x2 + x3)) / (k2 - k1);
80}
81
82GPUhdi() float computeTanDipAngle(float x1, float y1, float x2, float y2, float z1, float z2)
83{
84 // in case the points vertically align we go to pos/neg infinity.
85 const float d = o2::gpu::CAMath::Hypot(x1 - x2, y1 - y2);
86 if (o2::gpu::CAMath::Abs(d) < o2::its::constants::Tolerance) {
87 return ((z1 > z2) ? -1.f : 1.f) * o2::constants::math::VeryBig;
88 }
89 return (z1 - z2) / d;
90}
91
92GPUhdi() float smallestAngleDifference(float a, float b)
93{
94 return o2::gpu::CAMath::Remainderf(b - a, o2::constants::math::TwoPI);
95}
96
97GPUhdi() bool isPhiDifferenceBelow(const float phiA, const float phiB, const float phiCut)
98{
99 const float deltaPhi = o2::gpu::CAMath::Abs(phiA - phiB);
100 return deltaPhi < phiCut || deltaPhi > o2::constants::math::TwoPI - phiCut;
101}
102
103GPUhdi() constexpr float Sq(float v)
104{
105 return v * v;
106}
107
108GPUhdi() constexpr float SqSum(float v, float w)
109{
110 return Sq(v) + Sq(w);
111}
112
113GPUhdi() constexpr float SqSum(float u, float v, float w)
114{
115 return Sq(u) + SqSum(v, w);
116}
117
118GPUhdi() constexpr float SqDiff(float x, float y)
119{
120 return Sq(x - y);
121}
122
123GPUhdi() float MSangle(float mass, float p, float xX0)
124{
125 if (xX0 <= 0.f) {
126 return 0.f;
127 }
128 float beta = p / o2::gpu::CAMath::Hypot(mass, p);
129 return 0.0136f * o2::gpu::CAMath::Sqrt(xX0) * (1.f + 0.038f * o2::gpu::CAMath::Log(xX0)) / (beta * p);
130}
131
132GPUhdi() float cellDeltaPhiBound(const float bz, const float ptMin,
133 const float rIn, const float rMid, const float rOut,
134 const float msAngle)
135{
136 if (ptMin <= 0.f) {
137 return o2::constants::math::TwoPI;
138 }
139 const float oneOverR = 0.001f * 0.3f * o2::gpu::CAMath::Abs(bz) / ptMin; // 1 / curvature radius [1/cm]
140 const float sA = o2::gpu::CAMath::Min(0.25f * (rIn + rMid) * oneOverR, 1.f - 1.e-6f);
141 const float sB = o2::gpu::CAMath::Min(0.25f * (rMid + rOut) * oneOverR, 1.f - 1.e-6f);
142 const float bound = 2.f * (o2::gpu::CAMath::ASin(sB) - o2::gpu::CAMath::ASin(sA)) + 2.f * msAngle;
143 return o2::gpu::CAMath::Min(bound, static_cast<float>(o2::constants::math::PI));
144}
145
146} // namespace o2::its::math_utils
147
148#endif
General auxilliary methods.
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 bool
configStandalone Reconstruction rec_tpc float
useful math constants
GLint GLenum GLint x
Definition glcorearb.h:403
GLuint GLfloat GLfloat GLfloat GLfloat y1
Definition glcorearb.h:5034
const GLdouble * v
Definition glcorearb.h:832
GLuint GLfloat GLfloat GLfloat x1
Definition glcorearb.h:5034
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLint y
Definition glcorearb.h:270
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLubyte GLubyte GLubyte GLubyte w
Definition glcorearb.h:852
constexpr float Tolerance
Definition Constants.h:30
float float x2
Definition MathUtils.h:49
float float xX0
Definition MathUtils.h:124
return *o2::gpu::CAMath::Sqrt(xX0) *(1.f+0.038f *o2 const float const float const float const float rOut
Definition MathUtils.h:133
float float float float float z2
Definition MathUtils.h:83
float float float float float y3
Definition MathUtils.h:50
return *o2::gpu::CAMath::Sqrt(xX0) *(1.f+0.038f *o2 const float const float rIn
Definition MathUtils.h:133
float float float float x3
Definition MathUtils.h:49
const float bound
Definition MathUtils.h:142
const float d3
Definition MathUtils.h:61
const float d1
Definition MathUtils.h:59
const float dx3
Definition MathUtils.h:58
const float dx1
Definition MathUtils.h:56
const float k1
Definition MathUtils.h:75
const float dy3
Definition MathUtils.h:58
const float dy2
Definition MathUtils.h:57
const float phiB
Definition MathUtils.h:97
return *o2::gpu::CAMath::Sqrt(xX0) *(1.f+0.038f *o2 const float ptMin
Definition MathUtils.h:132
const float k2
Definition MathUtils.h:75
return *o2::gpu::CAMath::Sqrt(xX0) *(1.f+0.038f *o2 const float const float const float const float const float msAngle
Definition MathUtils.h:135
return f * area(d1 *d2 *d3)
GPUhdi() const expr float computePhi(float x
Definition MathUtils.h:38
const float dy1
Definition MathUtils.h:56
float float float float z1
Definition MathUtils.h:82
float float float y2
Definition MathUtils.h:49
return *o2::gpu::CAMath::Sqrt(xX0) *(1.f+0.038f *o2 const float const float const float rMid
Definition MathUtils.h:133
const float dx2
Definition MathUtils.h:57
const float d2
Definition MathUtils.h:60
const float const float phiCut
Definition MathUtils.h:98
const float const float const float bz