Skip to content

Commit e725bd9

Browse files
committed
ITS: speedup vertexer
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent db7c727 commit e725bd9

File tree

5 files changed

+141
-76
lines changed

5 files changed

+141
-76
lines changed

Detectors/ITSMFT/ITS/tracking/include/ITStracking/ClusterLines.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ struct Line final {
3131

3232
Line() = default;
3333
Line(const Tracklet&, const Cluster*, const Cluster*);
34+
bool operator==(const Line&) const = default;
3435

36+
static float getDistance2FromPoint(const Line& line, const std::array<float, 3>& point);
3537
static float getDistanceFromPoint(const Line& line, const std::array<float, 3>& point);
3638
static SMatrix3f getDCAComponents(const Line& line, const std::array<float, 3>& point);
39+
static float getDCA2(const Line&, const Line&, const float precision = constants::Tolerance);
3740
static float getDCA(const Line&, const Line&, const float precision = constants::Tolerance);
3841
bool isEmpty() const noexcept;
39-
bool operator==(const Line&) const = default;
42+
void print() const;
4043

4144
SVector3f originPoint;
4245
SVector3f cosinesDirector;

Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ struct TimeFrame {
108108

109109
float getBeamX() const { return mBeamPos[0]; }
110110
float getBeamY() const { return mBeamPos[1]; }
111+
std::array<float, 2>& getBeamXY() { return mBeamPos; }
112+
111113
auto& getMinRs() { return mMinR; }
112114
auto& getMaxRs() { return mMaxR; }
113115
float getMinR(int layer) const { return mMinR[layer]; }
@@ -230,7 +232,6 @@ struct TimeFrame {
230232
gsl::span<int> getExclusiveNTrackletsCluster(int rofId, int combId);
231233
uint32_t getTotalTrackletsTF(const int iLayer) { return mTotalTracklets[iLayer]; }
232234
int getTotalClustersPerROFrange(int rofMin, int range, int layerId) const;
233-
std::array<float, 2>& getBeamXY() { return mBeamPos; }
234235
// \Vertexer
235236

236237
int hasBogusClusters() const { return std::accumulate(mBogusClusters.begin(), mBogusClusters.end(), 0); }

Detectors/ITSMFT/ITS/tracking/src/ClusterLines.cxx

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// or submit itself to any jurisdiction.
1111

1212
#include <cmath>
13+
#include "Framework/Logger.h"
1314
#include "ITStracking/ClusterLines.h"
1415

1516
namespace 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

5668
Line::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, "\tLine: 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

131151
void 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

141161
void ClusterLines::computeClusterCentroid()

Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,6 @@ void TrackerTraits<NLayers>::setNThreads(int n, std::shared_ptr<tbb::task_arena>
981981
LOGP(info, "Setting tracker with {} threads.", n);
982982
} else {
983983
mTaskArena = arena;
984-
LOGP(info, "Attaching tracker to calling thread's arena");
985984
}
986985
#endif
987986
}

0 commit comments

Comments
 (0)