12#ifndef O2_ITS_CLUSTERLINES_H
13#define O2_ITS_CLUSTERLINES_H
39 for (
int i = 0;
i < 3; ++
i) {
42 const float norm = o2::gpu::GPUCommonMath::Sqrt(norm2);
43 for (
int i = 0;
i < 3; ++
i) {
54 float delta[3], proj = 0.f;
55 for (
int i = 0;
i < 3; ++
i) {
56 delta[
i] =
point[
i] - line.originPoint[
i];
57 proj += delta[
i] * line.cosinesDirector[
i];
60 for (
int i = 0;
i < 3; ++
i) {
61 const float residual = delta[
i] - proj * line.cosinesDirector[
i];
62 d2 += residual * residual;
70 float delta[3], proj = 0.f;
71 for (
int i = 0;
i < 3; ++
i) {
72 delta[
i] = line.originPoint[
i] -
point[
i];
73 proj += delta[
i] * line.cosinesDirector[
i];
76 for (
int i = 0;
i < 3; ++
i) {
77 r[
i] = delta[
i] - proj * line.cosinesDirector[
i];
83 out[1] = std::hypot(
r[0],
r[1]);
84 out[3] = std::hypot(
r[0],
r[2]);
85 out[4] = std::hypot(
r[1],
r[2]);
87 out[1] = o2::gpu::GPUCommonMath::Hypot(
r[0],
r[1]);
88 out[3] = o2::gpu::GPUCommonMath::Hypot(
r[0],
r[2]);
89 out[4] = o2::gpu::GPUCommonMath::Hypot(
r[1],
r[2]);
95 const float ux = line.cosinesDirector[0];
96 const float uy = line.cosinesDirector[1];
104 z = line.originPoint[2] +
s0 * line.cosinesDirector[2];
136 if (
par.propagateParamToDCA({beamX, beamY, 0.f},
bz)) {
154 const double d0 = line.cosinesDirector[0], d1 = line.cosinesDirector[1], d2 = line.cosinesDirector[2];
155 const double o0 = line.originPoint[0], o1 = line.originPoint[1],
o2 = line.originPoint[2];
156 const double det = d0 * d0 + d1 * d1 + d2 * d2;
160 mA[0] += (det - d0 * d0) / det;
161 mA[1] += (-d0 * d1) / det;
162 mA[2] += (-d0 * d2) / det;
163 mA[3] += (det - d1 * d1) / det;
164 mA[4] += (-d1 * d2) / det;
165 mA[5] += (det - d2 * d2) / det;
166 const double dDotO = d0 * o0 + d1 * o1 + d2 *
o2;
167 mB[0] += (d0 * dDotO - det * o0) / det;
168 mB[1] += (d1 * dDotO - det * o1) / det;
169 mB[2] += (d2 * dDotO - det *
o2) / det;
176 const double c00 =
mA[3] *
mA[5] -
mA[4] *
mA[4];
177 const double c01 =
mA[2] *
mA[4] -
mA[1] *
mA[5];
178 const double c02 =
mA[1] *
mA[4] -
mA[2] *
mA[3];
179 const double c11 =
mA[0] *
mA[5] -
mA[2] *
mA[2];
180 const double c12 =
mA[1] *
mA[2] -
mA[0] *
mA[4];
181 const double c22 =
mA[0] *
mA[3] -
mA[1] *
mA[1];
182 const double det =
mA[0] * c00 +
mA[1] * c01 +
mA[2] * c02;
183 if (o2::gpu::GPUCommonMath::Abs(det) < 1.e-12) {
186 const double invDet = 1. / det;
187 const double x0 = (c00 *
mB[0] + c01 *
mB[1] + c02 *
mB[2]) * invDet;
188 const double x1 = (c01 *
mB[0] + c11 *
mB[1] + c12 *
mB[2]) * invDet;
189 const double x2 = (c02 *
mB[0] + c12 *
mB[1] + c22 *
mB[2]) * invDet;
190 vertex[0] =
static_cast<float>(-
x0);
191 vertex[1] =
static_cast<float>(-
x1);
192 vertex[2] =
static_cast<float>(-x2);
205 GPUhdi() float getR() const noexcept {
return o2::gpu::GPUCommonMath::Sqrt(getR2()); }
210 double mA[6] = {0., 0., 0., 0., 0., 0.};
211 double mB[3] = {0., 0., 0.};
213 float mRMS2[6] = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
231 if (!LineFit::add(line)) {
253 for (
int i = 0;
i < 6; ++
i) {
268struct WarpFit :
public LineFit {
269 uint32_t tLo = 0, tHi = 0xffffffffu;
271 GPUdi()
void add(
const Line& l)
273 if (LineFit::add(l)) {
274 tLo = o2::gpu::GPUCommonMath::Max(tLo, l.mTime.lower());
275 tHi = o2::gpu::GPUCommonMath::Min(tHi, l.mTime.upper());
283 for (
int i = 0;
i < 6; ++
i) {
284 mA[
i] = warp_reduce_add<Width>(mA[
i]);
286 for (
int i = 0;
i < 3; ++
i) {
287 mB[
i] = warp_reduce_add<Width>(mB[
i]);
289 tLo = warp_reduce_max<Width>(tLo);
290 tHi = warp_reduce_min<Width>(tHi);
291 mNContributors = warp_reduce_add<Width>(mNContributors);
292 mTime = TimeEstBC{tLo, tHi - tLo};
298 Line::getDCAComponents(l,
vertex, dca);
299 for (
int i = 0;
i < 6; ++
i) {
300 rms2Sum[
i] += dca[
i];
302 dist2Sum += Line::getDistance2FromPoint(l,
vertex);
309 for (
int i = 0;
i < 6; ++
i) {
310 mRMS2[
i] = warp_reduce_add<Width>(rms2Sum[
i]) /
n;
312 mAvgDistance2 = warp_reduce_add<Width>(dist2Sum) /
n;
315 double rms2Sum[6] = {0., 0., 0., 0., 0., 0.};
316 double dist2Sum = 0.;
CellSeed: connections of three clusters.
Least-squares vertex fit over a set of lines (the normal equations AX = -B).
GPUhdDefault() ClusterLines()=default
GPUhdi() void addResidual(const Line &line)
Running-mean update of the RMS2 and average distance about the stored vertex.
bool operator==(const ClusterLines &rhs) const noexcept
GPUhdi() void addResidual(const Line &line
Running-mean update about an externally solved vertex.
Line::getDCAComponents(line, vertex, dca)
GPUhdi() float getR2() const noexcept
GPUhdi() int getNContributors() const noexcept
GPUhdi() const float *getRMS2() const noexcept
GPUhdi() bool solve(float vertex[3]) const
Solve the symmetric 3x3 system into vertex (= -A^-1 B); false if it is singular.
GPUhdi() const TimeEstBC &getTimeStamp() const noexcept
GPUhdi() bool add(const Line &line)
Accumulate one line.
GPUhdi() const float *getVertex() const noexcept
GPUhdi() float getAvgDistance2() const noexcept
GPUhdi() bool isValid() const noexcept
GPUhdi() float getR() const noexcept
GPUhdi() void computeClusterCentroid()
Solve into the stored vertex, setting the validity flag.
GPUhdi() int getSize() const noexcept
GLuint GLfloat GLfloat GLfloat x1
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLenum GLint GLint * precision
GLdouble GLdouble GLdouble z
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s0
constexpr float Tolerance
const float const float const float const float curvatureScale
o2::track::TrackParametrization< float > par
std::array< float, 3 > dcaOrigin
const float const float beamY
const float const float const float bz
const float const float const float const float std::array< float, 3 > std::array< float, 3 > & direction
std::array< float, 3 > dcaDirection
const float const float const float const float std::array< float, 3 > & origin
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
bool isValid(std::string alias)
GPUhdi() bool isEmpty() const noexcept
bool operator==(const Line &) const =default
static float getDistance2FromPoint(const Line &line, const std::array< float, 3 > &point)
GPUhdi() static float getDistance2FromPoint(const Line &line
static float getDCA2(const Line &, const Line &, const float precision=constants::Tolerance)
static float getDCA(const Line &, const Line &, const float precision=constants::Tolerance)
GPUhdi() Line(const float origin[3]
GPUhdi() static void getDCAComponents(const Line &line
Packed symmetric DCA components in {XX, XY, YY, XZ, YZ, ZZ} order.
Line(const std::array< float, 3 > &origin, const std::array< float, 3 > &direction, const TimeEstBC &time)
GPUhdDefault() Line()=default
const float const TimeEstBC & time
static float getDistanceFromPoint(const Line &line, const std::array< float, 3 > &point)
const float const float beamY