1010// or submit itself to any jurisdiction.
1111
1212#include < cmath>
13+ #include " Framework/Logger.h"
1314#include " ITStracking/ClusterLines.h"
1415
1516namespace o2 ::its
@@ -27,16 +28,21 @@ Line::Line(const Tracklet& tracklet, const Cluster* innerClusters, const Cluster
2728 cosinesDirector /= std::sqrt (ROOT::Math::Dot (cosinesDirector, cosinesDirector));
2829}
2930
30- float Line::getDistanceFromPoint (const Line& line, const std::array<float , 3 >& point)
31+ float Line::getDistance2FromPoint (const Line& line, const std::array<float , 3 >& point)
3132{
3233 const SVector3f p (point.data (), 3 );
3334 const SVector3f delta = p - line.originPoint ;
3435 const float proj = ROOT::Math::Dot (delta, line.cosinesDirector );
3536 const SVector3f residual = delta - proj * line.cosinesDirector ;
36- return std::sqrt ( ROOT::Math::Dot (residual, residual) );
37+ return ROOT::Math::Dot (residual, residual);
3738}
3839
39- float Line::getDCA (const Line& firstLine, const Line& secondLine, const float precision)
40+ float Line::getDistanceFromPoint (const Line& line, const std::array<float , 3 >& point)
41+ {
42+ return std::sqrt (getDistance2FromPoint (line, point));
43+ }
44+
45+ float Line::getDCA2 (const Line& firstLine, const Line& secondLine, const float precision)
4046{
4147 const SVector3f n = ROOT::Math::Cross (firstLine.cosinesDirector , secondLine.cosinesDirector );
4248 const float norm2 = ROOT::Math::Dot (n, n);
@@ -46,11 +52,17 @@ float Line::getDCA(const Line& firstLine, const Line& secondLine, const float pr
4652 const SVector3f d = secondLine.originPoint - firstLine.originPoint ;
4753 const float proj = ROOT::Math::Dot (d, firstLine.cosinesDirector );
4854 const SVector3f residual = d - proj * firstLine.cosinesDirector ;
49- return std::sqrt ( ROOT::Math::Dot (residual, residual) );
55+ return ROOT::Math::Dot (residual, residual);
5056 }
5157
5258 const SVector3f delta = secondLine.originPoint - firstLine.originPoint ;
53- return std::abs (ROOT::Math::Dot (delta, n)) / std::sqrt (norm2);
59+ const float numerator = ROOT::Math::Dot (delta, n);
60+ return (numerator * numerator) / norm2;
61+ }
62+
63+ float Line::getDCA (const Line& firstLine, const Line& secondLine, const float precision)
64+ {
65+ return std::sqrt (getDCA2 (firstLine, secondLine, precision));
5466}
5567
5668Line::SMatrix3f Line::getDCAComponents (const Line& line, const std::array<float , 3 >& point)
@@ -77,6 +89,14 @@ bool Line::isEmpty() const noexcept
7789 ROOT::Math::Dot (cosinesDirector, cosinesDirector) == 0 .f ;
7890}
7991
92+ void Line::print () const
93+ {
94+ LOGP (info, " \t Line: originPoint = ({}, {}, {}), cosinesDirector = ({}, {}, {}) ts={}+-{}" ,
95+ originPoint (0 ), originPoint (1 ), originPoint (2 ),
96+ cosinesDirector (0 ), cosinesDirector (1 ), cosinesDirector (2 ),
97+ mTime .getTimeStamp (), mTime .getTimeStampError ());
98+ }
99+
80100// Accumulate the weighted normal equation contributions (A matrix and B vector)
81101// from a single line into the running sums. The covariance is assumed to be
82102// diagonal and uniform ({1,1,1}) so the weights simplify accordingly.
@@ -124,8 +144,8 @@ ClusterLines::ClusterLines(const int firstLabel, const Line& firstLine, const in
124144 mRMS2 += (tmpRMS2 - mRMS2 ) * (1 .f / static_cast <float >(getSize ()));
125145
126146 // AvgDistance2
127- mAvgDistance2 = Line::getDistanceFromPoint (firstLine, mVertex ) * Line::getDistanceFromPoint (firstLine, mVertex );
128- mAvgDistance2 += (Line::getDistanceFromPoint (secondLine, mVertex ) * Line::getDistanceFromPoint (secondLine, mVertex ) - mAvgDistance2 ) / (float )getSize ();
147+ mAvgDistance2 = Line::getDistance2FromPoint (firstLine, mVertex );
148+ mAvgDistance2 += (Line::getDistance2FromPoint (secondLine, mVertex ) - mAvgDistance2 ) / (float )getSize ();
129149}
130150
131151void ClusterLines::add (const int lineLabel, const Line& line)
@@ -135,7 +155,7 @@ void ClusterLines::add(const int lineLabel, const Line& line)
135155
136156 accumulate (line);
137157 computeClusterCentroid ();
138- mAvgDistance2 += (Line::getDistanceFromPoint (line, mVertex ) * Line::getDistanceFromPoint (line, mVertex ) - mAvgDistance2 ) / (float )getSize ();
158+ mAvgDistance2 += (Line::getDistance2FromPoint (line, mVertex ) - mAvgDistance2 ) / (float )getSize ();
139159}
140160
141161void ClusterLines::computeClusterCentroid ()
0 commit comments