Project
Loading...
Searching...
No Matches
ClusterLines.cxx
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
12#include <cmath>
13#include "Framework/Logger.h"
15
16namespace o2::its
17{
18
19Line::Line(const Tracklet& tracklet, const Cluster* innerClusters, const Cluster* outerClusters)
20{
21 const auto& inner = innerClusters[tracklet.firstClusterIndex];
22 const auto& outer = outerClusters[tracklet.secondClusterIndex];
23
24 const float origin[3] = {inner.xCoordinate, inner.yCoordinate, inner.zCoordinate};
25 const float direction[3] = {outer.xCoordinate - inner.xCoordinate,
26 outer.yCoordinate - inner.yCoordinate,
27 outer.zCoordinate - inner.zCoordinate};
28 *this = Line(origin, direction, tracklet.mTime);
29}
30
31float Line::getDistanceFromPoint(const Line& line, const std::array<float, 3>& point)
32{
33 return std::sqrt(getDistance2FromPoint(line, point.data()));
34}
35
36float Line::getDCA2(const Line& firstLine, const Line& secondLine, const float precision)
37{
38 const auto& a = firstLine.cosinesDirector;
39 const auto& b = secondLine.cosinesDirector;
40 const float n[3] = {a[1] * b[2] - a[2] * b[1],
41 a[2] * b[0] - a[0] * b[2],
42 a[0] * b[1] - a[1] * b[0]};
43 const float norm2 = n[0] * n[0] + n[1] * n[1] + n[2] * n[2];
44
45 float d[3];
46 for (int i = 0; i < 3; ++i) {
47 d[i] = secondLine.originPoint[i] - firstLine.originPoint[i];
48 }
49
50 if (norm2 <= precision * precision) {
51 // lines are parallel, fall back to point-to-line distance
52 float proj = 0.f;
53 for (int i = 0; i < 3; ++i) {
54 proj += d[i] * a[i];
55 }
56 float res2 = 0.f;
57 for (int i = 0; i < 3; ++i) {
58 const float residual = d[i] - proj * a[i];
59 res2 += residual * residual;
60 }
61 return res2;
62 }
63
64 const float numerator = d[0] * n[0] + d[1] * n[1] + d[2] * n[2];
65 return (numerator * numerator) / norm2;
66}
67
68float Line::getDCA(const Line& firstLine, const Line& secondLine, const float precision)
69{
70 return std::sqrt(getDCA2(firstLine, secondLine, precision));
71}
72
73void Line::print() const
74{
75 LOGP(info, "\tLine: originPoint = ({}, {}, {}), cosinesDirector = ({}, {}, {}) ts={}+-{}",
78 mTime.getTimeStamp(), mTime.getTimeStampError());
79}
80
81ClusterLines::ClusterLines(gsl::span<const int> lineIndices, gsl::span<const Line> lines)
82{
83 if (lineIndices.size() < 2) {
84 return;
85 }
86 for (const auto idx : lineIndices) {
87 add(lines[idx]);
88 }
89 computeClusterCentroid();
90 if (!mIsValid) {
91 return;
92 }
93 for (const auto idx : lineIndices) {
94 addResidual(lines[idx]);
95 }
96}
97
98bool ClusterLines::operator==(const ClusterLines& rhs) const noexcept
99{
100 for (int i = 0; i < 6; ++i) {
101 if (mRMS2[i] != rhs.mRMS2[i]) {
102 return false;
103 }
104 }
105 for (int i = 0; i < 3; ++i) {
106 if (mVertex[i] != rhs.mVertex[i]) {
107 return false;
108 }
109 }
110 return mNContributors == rhs.mNContributors && mAvgDistance2 == rhs.mAvgDistance2;
111}
112
113} // namespace o2::its
int32_t i
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
Least-squares vertex fit over a set of lines (the normal equations AX = -B).
bool operator==(const ClusterLines &rhs) const noexcept
ClusterLines(gsl::span< const int > lineIndices, gsl::span< const Line > lines)
Fit over lines[lineIndices[i]]; lineIndices must be sorted and unique.
GLdouble n
Definition glcorearb.h:1982
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLenum GLint GLint * precision
Definition glcorearb.h:1899
const float const float const float const float std::array< float, 3 > & origin
float xCoordinate
Definition Cluster.h:43
void print() const
const float direction[3]
static float getDistance2FromPoint(const Line &line, const std::array< float, 3 > &point)
float cosinesDirector[3]
static float getDCA2(const Line &, const Line &, const float precision=constants::Tolerance)
static float getDCA(const Line &, const Line &, const float precision=constants::Tolerance)
TimeEstBC mTime
Line(const Tracklet &, const Cluster *, const Cluster *)
const float point[3]
static float getDistanceFromPoint(const Line &line, const std::array< float, 3 > &point)
float originPoint[3]
TimeEstBC mTime
Definition Tracklet.h:68