12#ifndef O2_ITS_CLUSTERLINES_H
13#define O2_ITS_CLUSTERLINES_H
41 bool operator==(const
Line&) const;
42 bool operator!=(const
Line&) const;
65 for (
int i{0};
i < 3; ++
i) {
67 cosinesDirector[
i] =
other.cosinesDirector[
i];
69 for (
int i{0};
i < 6; ++
i) {
70 weightMatrix[
i] =
other.weightMatrix[
i];
72 for (
int i{0};
i < 2; ++
i) {
77GPUhdi() Line::Line(const
float firstPoint[3], const
float secondPoint[3])
79 for (
int i{0};
i < 3; ++
i) {
80 originPoint[
i] = firstPoint[
i];
81 cosinesDirector[
i] = secondPoint[
i] - firstPoint[
i];
84 float inverseNorm{1.f / o2::gpu::CAMath::Sqrt(cosinesDirector[0] * cosinesDirector[0] + cosinesDirector[1] * cosinesDirector[1] +
85 cosinesDirector[2] * cosinesDirector[2])};
88 cosinesDirector[
index] *= inverseNorm;
95GPUhdi() Line::Line(const Tracklet& tracklet, const
Cluster* innerClusters, const
Cluster* outerClusters)
97 originPoint[0] = innerClusters[tracklet.firstClusterIndex].xCoordinate;
98 originPoint[1] = innerClusters[tracklet.firstClusterIndex].yCoordinate;
99 originPoint[2] = innerClusters[tracklet.firstClusterIndex].zCoordinate;
101 cosinesDirector[0] = outerClusters[tracklet.secondClusterIndex].xCoordinate - innerClusters[tracklet.firstClusterIndex].xCoordinate;
102 cosinesDirector[1] = outerClusters[tracklet.secondClusterIndex].yCoordinate - innerClusters[tracklet.firstClusterIndex].yCoordinate;
103 cosinesDirector[2] = outerClusters[tracklet.secondClusterIndex].zCoordinate - innerClusters[tracklet.firstClusterIndex].zCoordinate;
105 float inverseNorm{1.f / o2::gpu::CAMath::Sqrt(cosinesDirector[0] * cosinesDirector[0] + cosinesDirector[1] * cosinesDirector[1] +
106 cosinesDirector[2] * cosinesDirector[2])};
109 cosinesDirector[
index] *= inverseNorm;
112 rof[0] = tracklet.rof[0];
113 rof[1] = tracklet.rof[1];
121 for (
int i{0};
i < 3; ++
i) {
124 for (
int i{0};
i < 3; ++
i) {
128 return o2::gpu::CAMath::Sqrt(DCASquared);
131GPUhdi() float
Line::getDistanceFromPoint(const
Line& line, const
float point[3])
135 for (
int i{0};
i < 3; ++
i) {
138 for (
int i{0};
i < 3; ++
i) {
139 DCASquared += (line.originPoint[
i] - point[
i] + line.cosinesDirector[
i] * cdelta) *
140 (line.originPoint[
i] - point[
i] + line.cosinesDirector[
i] * cdelta);
142 return o2::gpu::CAMath::Sqrt(DCASquared);
145GPUhdi() float Line::getDCA(const Line& firstLine, const Line& secondLine, const
float precision)
147 float normalVector[3];
148 normalVector[0] = firstLine.cosinesDirector[1] * secondLine.cosinesDirector[2] -
149 firstLine.cosinesDirector[2] * secondLine.cosinesDirector[1];
150 normalVector[1] = -firstLine.cosinesDirector[0] * secondLine.cosinesDirector[2] +
151 firstLine.cosinesDirector[2] * secondLine.cosinesDirector[0];
152 normalVector[2] = firstLine.cosinesDirector[0] * secondLine.cosinesDirector[1] -
153 firstLine.cosinesDirector[1] * secondLine.cosinesDirector[0];
156 for (
int i{0};
i < 3; ++
i) {
157 norm += normalVector[
i] * normalVector[
i];
158 distance += (secondLine.originPoint[
i] - firstLine.originPoint[
i]) * normalVector[
i];
161 return o2::gpu::CAMath::Abs(
distance / o2::gpu::CAMath::Sqrt(norm));
163#if defined(__CUDACC__) || defined(__HIPCC__)
164 float stdOriginPoint[3];
165 for (
int i{0};
i < 3; ++
i) {
166 stdOriginPoint[
i] = secondLine.originPoint[1];
169 std::array<float, 3> stdOriginPoint = {};
170 std::copy_n(secondLine.originPoint, 3, stdOriginPoint.begin());
172 return getDistanceFromPoint(firstLine, stdOriginPoint);
176GPUhdi()
void Line::getDCAComponents(const Line& line, const
float point[3],
float destArray[6])
179 for (
int i{0};
i < 3; ++
i) {
180 cdelta -= line.cosinesDirector[
i] * (line.originPoint[
i] - point[
i]);
183 destArray[0] = line.originPoint[0] - point[0] + line.cosinesDirector[0] * cdelta;
184 destArray[3] = line.originPoint[1] - point[1] + line.cosinesDirector[1] * cdelta;
185 destArray[5] = line.originPoint[2] - point[2] + line.cosinesDirector[2] * cdelta;
186 destArray[1] = o2::gpu::CAMath::Sqrt(destArray[0] * destArray[0] + destArray[3] * destArray[3]);
187 destArray[2] = o2::gpu::CAMath::Sqrt(destArray[0] * destArray[0] + destArray[5] * destArray[5]);
188 destArray[4] = o2::gpu::CAMath::Sqrt(destArray[3] * destArray[3] + destArray[5] * destArray[5]);
194 for (
int i{0};
i < 3; ++
i) {
203 for (
int i{0};
i < 3; ++
i) {
211 printf(
"Line: originPoint = (%f, %f, %f), cosinesDirector = (%f, %f, %f), rofs = (%hd, %hd)\n",
212 originPoint[0], originPoint[1], originPoint[2], cosinesDirector[0], cosinesDirector[1], cosinesDirector[2], rof[0], rof[1]);
215class ClusterLines final
218 ClusterLines() =
default;
219 ClusterLines(
const int firstLabel,
const Line& firstLine,
const int secondLabel,
const Line& secondLine,
220 const bool weight =
false);
221 ClusterLines(
const Line& firstLine,
const Line& secondLine);
222 void add(
const int& lineLabel,
const Line& line,
const bool&
weight =
false);
223 void computeClusterCentroid();
224 void updateROFPoll(
const Line&);
225 inline std::vector<int>& getLabels()
229 inline int getSize()
const {
return mLabels.size(); }
230 inline short getROF()
const {
return mROF; }
231 inline std::array<float, 3> getVertex()
const {
return mVertex; }
232 inline std::array<float, 6> getRMS2()
const {
return mRMS2; }
233 inline float getAvgDistance2()
const {
return mAvgDistance2; }
238 std::array<double, 6> mAMatrix;
239 std::array<double, 3> mBMatrix;
240 std::vector<int> mLabels;
241 std::array<float, 9> mWeightMatrix = {0.f};
242 std::array<float, 3> mVertex = {0.f};
243 std::array<float, 6> mRMS2 = {0.f};
244 float mAvgDistance2 = 0.f;
HMPID cluster implementation.
GLuint GLuint GLfloat weight
GLsizei GLsizei GLfloat distance
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLenum GLint GLint * precision
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)
const float float destArray[6]
bool operator==(const Line &) const
GPUhdi() auto getDeltaROF() const
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=1e-14)
const float secondPoint[3]
VectorOfTObjectPtrs other