12#ifndef O2_ITS_CLUSTERLINES_H
13#define O2_ITS_CLUSTERLINES_H
41 bool operator==(const
Line&) const;
42 bool operator!=(const
Line&) const;
62 for (
int i{0};
i < 3; ++
i) {
64 cosinesDirector[
i] =
other.cosinesDirector[
i];
69 for (
int i{0};
i < 2; ++
i) {
74GPUhdi() Line::Line(const Tracklet& tracklet, const
Cluster* innerClusters, const
Cluster* outerClusters)
76 originPoint[0] = innerClusters[tracklet.firstClusterIndex].xCoordinate;
77 originPoint[1] = innerClusters[tracklet.firstClusterIndex].yCoordinate;
78 originPoint[2] = innerClusters[tracklet.firstClusterIndex].zCoordinate;
80 cosinesDirector[0] = outerClusters[tracklet.secondClusterIndex].xCoordinate - innerClusters[tracklet.firstClusterIndex].xCoordinate;
81 cosinesDirector[1] = outerClusters[tracklet.secondClusterIndex].yCoordinate - innerClusters[tracklet.firstClusterIndex].yCoordinate;
82 cosinesDirector[2] = outerClusters[tracklet.secondClusterIndex].zCoordinate - innerClusters[tracklet.firstClusterIndex].zCoordinate;
84 float inverseNorm{1.f / o2::gpu::CAMath::Hypot(cosinesDirector[0], cosinesDirector[1], cosinesDirector[2])};
85 cosinesDirector[0] *= inverseNorm;
86 cosinesDirector[1] *= inverseNorm;
87 cosinesDirector[2] *= inverseNorm;
89 rof[0] = tracklet.rof[0];
90 rof[1] = tracklet.rof[1];
98 for (
int i{0};
i < 3; ++
i) {
99 cdelta -= line.cosinesDirector[
i] * (line.originPoint[
i] -
point[
i]);
101 for (
int i{0};
i < 3; ++
i) {
102 DCASquared += (line.originPoint[
i] -
point[
i] + line.cosinesDirector[
i] * cdelta) *
103 (line.originPoint[
i] -
point[
i] + line.cosinesDirector[
i] * cdelta);
105 return o2::gpu::CAMath::Sqrt(DCASquared);
108GPUhdi() float
Line::getDistanceFromPoint(const
Line& line, const
float point[3])
110 const float dx = point[0] - line.originPoint[0];
111 const float dy = point[1] - line.originPoint[1];
112 const float dz = point[2] - line.originPoint[2];
113 const float d = (dx * line.cosinesDirector[0]) + (dy * line.cosinesDirector[1]) + (dz * line.cosinesDirector[2]);
115 const float vx = dx - (d * line.cosinesDirector[0]);
116 const float vy = dy - (d * line.cosinesDirector[1]);
117 const float vz = dz - (d * line.cosinesDirector[2]);
119 return o2::gpu::CAMath::Hypot(vx, vy, vz);
122GPUhdi() float Line::getDCA(const Line& firstLine, const Line& secondLine, const
float precision)
124 const float nx = (firstLine.cosinesDirector[1] * secondLine.cosinesDirector[2]) -
125 (firstLine.cosinesDirector[2] * secondLine.cosinesDirector[1]);
126 const float ny = -(firstLine.cosinesDirector[0] * secondLine.cosinesDirector[2]) +
127 (firstLine.cosinesDirector[2] * secondLine.cosinesDirector[0]);
128 const float nz = (firstLine.cosinesDirector[0] * secondLine.cosinesDirector[1]) -
129 (firstLine.cosinesDirector[1] * secondLine.cosinesDirector[0]);
130 const float norm2 = (nx * nx) + (ny * ny) + (nz * nz);
133 return getDistanceFromPoint(firstLine, secondLine.originPoint);
136 const float dx = secondLine.originPoint[0] - firstLine.originPoint[0];
137 const float dy = secondLine.originPoint[1] - firstLine.originPoint[1];
138 const float dz = secondLine.originPoint[2] - firstLine.originPoint[2];
139 const float triple = (dx * nx) + (dy * ny) + (dz * nz);
141 return o2::gpu::CAMath::Abs(triple) / o2::gpu::CAMath::Sqrt(norm2);
144GPUhdi()
void Line::getDCAComponents(const Line& line, const
float point[3],
float destArray[6])
147 for (
int i{0};
i < 3; ++
i) {
148 cdelta -=
line.cosinesDirector[
i] * (
line.originPoint[
i] - point[
i]);
151 destArray[0] =
line.originPoint[0] - point[0] +
line.cosinesDirector[0] * cdelta;
152 destArray[3] =
line.originPoint[1] - point[1] +
line.cosinesDirector[1] * cdelta;
153 destArray[5] =
line.originPoint[2] - point[2] +
line.cosinesDirector[2] * cdelta;
154 destArray[1] = o2::gpu::CAMath::Sqrt(destArray[0] * destArray[0] + destArray[3] * destArray[3]);
155 destArray[2] = o2::gpu::CAMath::Sqrt(destArray[0] * destArray[0] + destArray[5] * destArray[5]);
156 destArray[4] = o2::gpu::CAMath::Sqrt(destArray[3] * destArray[3] + destArray[5] * destArray[5]);
162 for (
int i{0};
i < 3; ++
i) {
170 return !(*
this == rhs);
175 printf(
"Line: originPoint = (%f, %f, %f), cosinesDirector = (%f, %f, %f), rofs = (%hd, %hd)\n",
176 originPoint[0], originPoint[1], originPoint[2], cosinesDirector[0], cosinesDirector[1], cosinesDirector[2], rof[0], rof[1]);
179class ClusterLines final
182 ClusterLines() =
default;
183 ClusterLines(
const int firstLabel,
const Line& firstLine,
const int secondLabel,
const Line& secondLine,
184 const bool weight =
false);
185 ClusterLines(
const Line& firstLine,
const Line& secondLine);
186 void add(
const int& lineLabel,
const Line& line,
const bool&
weight =
false);
187 void computeClusterCentroid();
188 void updateROFPoll(
const Line&);
189 inline std::vector<int>& getLabels()
193 inline int getSize()
const {
return mLabels.size(); }
194 inline short getROF()
const {
return mROF; }
195 inline std::array<float, 3> getVertex()
const {
return mVertex; }
196 inline std::array<float, 6> getRMS2()
const {
return mRMS2; }
197 inline float getAvgDistance2()
const {
return mAvgDistance2; }
202 std::array<double, 6> mAMatrix;
203 std::array<double, 3> mBMatrix;
204 std::vector<int> mLabels;
205 std::array<float, 9> mWeightMatrix = {0.f};
206 std::array<float, 3> mVertex = {0.f};
207 std::array<float, 6> mRMS2 = {0.f};
208 float mAvgDistance2 = 0.f;
210 short mROF = constants::UnusedIndex;
HMPID cluster implementation.
GLuint GLuint GLfloat weight
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLenum GLint GLint * precision
int32_t const char int32_t line
constexpr int UnusedIndex
Defining DataPointCompositeObject explicitly as copiable.
bool operator!=(const Line &) const
GPUhd() void print() const
static std::array< float, 6 > getDCAComponents(const Line &line, const std::array< float, 3 > point)
GPUhd() unsigned char isEmpty() const
const float float destArray[6]
bool operator==(const Line &) const
GPUhdi() auto getDeltaROF() const
GPUhdDefault() Line()=default
const Cluster const Cluster *static float getDistanceFromPoint(const Line &line, const std::array< float, 3 > &point)
static bool areParallel(const Line &, const Line &, const float precision=constants::Tolerance)
VectorOfTObjectPtrs other