Skip to content

Commit ff11af3

Browse files
committed
ITS: slim down cluster class
Signed-off-by: Felix Schlepper <felix.schlepper@cern.ch>
1 parent babe031 commit ff11af3

3 files changed

Lines changed: 28 additions & 93 deletions

File tree

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

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <array>
2020
#include "ITStracking/Constants.h"
21+
#include "ITStracking/MathUtils.h"
2122
#include "GPUCommonRtypes.h"
2223
#include "GPUCommonDef.h"
2324

@@ -29,26 +30,21 @@ class IndexTableUtils;
2930

3031
struct Cluster final {
3132
GPUhdDefault() Cluster() = default;
32-
GPUhd() Cluster(const float x, const float y, const float z, const int idx);
33-
template <int nLayers>
34-
GPUhd() Cluster(const int, const IndexTableUtils<nLayers>& utils, const Cluster&);
35-
template <int nLayers>
36-
GPUhd() Cluster(const int, const float3&, const IndexTableUtils<nLayers>& utils, const Cluster&);
37-
GPUhdDefault() Cluster(const Cluster&) = default;
38-
GPUhdDefault() Cluster(Cluster&&) noexcept = default;
39-
GPUhdDefault() ~Cluster() = default;
40-
41-
GPUhdDefault() Cluster& operator=(const Cluster&) = default;
42-
GPUhdDefault() Cluster& operator=(Cluster&&) noexcept = default;
43-
GPUhdDefault() bool operator==(const Cluster&) const = default;
44-
33+
GPUhd() Cluster(const float x, const float y, const float z, const int idx)
34+
: xCoordinate(x),
35+
yCoordinate(y),
36+
zCoordinate(z),
37+
phi(math_utils::computeNormalizedPhi(x, y)),
38+
radius(math_utils::hypot(x, y)),
39+
clusterId(idx),
40+
indexTableBinIndex(0) {}
4541
GPUhd() void print() const;
4642

47-
float xCoordinate{-999.f};
48-
float yCoordinate{-999.f};
49-
float zCoordinate{-999.f};
50-
float phi{-999.f};
51-
float radius{-999.f};
43+
float xCoordinate{constants::UnsetValue};
44+
float yCoordinate{constants::UnsetValue};
45+
float zCoordinate{constants::UnsetValue};
46+
float phi{constants::UnsetValue};
47+
float radius{constants::UnsetValue};
5248
int clusterId{constants::UnusedIndex};
5349
int indexTableBinIndex{constants::UnusedIndex};
5450

@@ -57,23 +53,18 @@ struct Cluster final {
5753

5854
struct TrackingFrameInfo final {
5955
GPUhdDefault() TrackingFrameInfo() = default;
60-
GPUhd() TrackingFrameInfo(float x, float y, float z, float xTF, float alpha, std::array<float, 2>&& posTF, std::array<float, 3>&& covTF);
61-
GPUhdDefault() TrackingFrameInfo(const TrackingFrameInfo&) = default;
62-
GPUhdDefault() TrackingFrameInfo(TrackingFrameInfo&&) noexcept = default;
63-
GPUhdDefault() ~TrackingFrameInfo() = default;
64-
65-
GPUhdDefault() TrackingFrameInfo& operator=(const TrackingFrameInfo&) = default;
66-
GPUhdDefault() TrackingFrameInfo& operator=(TrackingFrameInfo&&) = default;
56+
GPUhd() TrackingFrameInfo(float x, float y, float z, float xTF, float alpha, const std::array<float, 2>& posTF, const std::array<float, 3>& covTF)
57+
: xCoordinate(x), yCoordinate(y), zCoordinate(z), xTrackingFrame(xTF), alphaTrackingFrame(alpha), positionTrackingFrame(posTF), covarianceTrackingFrame(covTF) {}
6758

6859
GPUhd() void print() const;
6960

70-
float xCoordinate{-999.f};
71-
float yCoordinate{-999.f};
72-
float zCoordinate{-999.f};
73-
float xTrackingFrame{-999.f};
74-
float alphaTrackingFrame{-999.f};
75-
std::array<float, 2> positionTrackingFrame = {-999.f, -999.f};
76-
std::array<float, 3> covarianceTrackingFrame = {-999.f, -999.f, -999.f};
61+
float xCoordinate{constants::UnsetValue};
62+
float yCoordinate{constants::UnsetValue};
63+
float zCoordinate{constants::UnsetValue};
64+
float xTrackingFrame{constants::UnsetValue};
65+
float alphaTrackingFrame{constants::UnsetValue};
66+
std::array<float, 2> positionTrackingFrame = constants::helpers::initArray<float, 2, constants::UnsetValue>();
67+
std::array<float, 3> covarianceTrackingFrame = constants::helpers::initArray<float, 3, constants::UnsetValue>();
7768

7869
ClassDefNV(TrackingFrameInfo, 1);
7970
};

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ GPUhdi() constexpr float getNormalizedPhi(float phi)
4343
return phi;
4444
}
4545

46+
GPUhdi() constexpr float computeNormalizedPhi(float x, float y)
47+
{
48+
return getNormalizedPhi(computePhi(x, y));
49+
}
50+
4651
GPUhdi() float computeCurvature(float x1, float y1, float x2, float y2, float x3, float y3)
4752
{
4853
// in case the triangle is degenerate we return infinite curvature.

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

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -8,77 +8,16 @@
88
// In applying this license CERN does not waive the privileges and immunities
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
11-
///
12-
/// \file Cluster.cxx
13-
/// \brief
14-
///
15-
#include "GPUCommonMath.h"
16-
#include "GPUCommonArray.h"
1711

1812
#include "ITStracking/Cluster.h"
19-
#include "ITStracking/Definitions.h"
20-
#include "ITStracking/MathUtils.h"
21-
#include "ITStracking/IndexTableUtils.h"
2213

2314
using namespace o2::its;
2415

25-
using math_utils::computePhi;
26-
using math_utils::getNormalizedPhi;
27-
28-
Cluster::Cluster(const float x, const float y, const float z, const int index)
29-
: xCoordinate{x},
30-
yCoordinate{y},
31-
zCoordinate{z},
32-
phi{getNormalizedPhi(computePhi(x, y))},
33-
radius{o2::gpu::GPUCommonMath::Hypot(x, y)},
34-
clusterId{index},
35-
indexTableBinIndex{0}
36-
{
37-
// Nothing to do
38-
}
39-
40-
template <int nLayers>
41-
Cluster::Cluster(const int layerIndex, const IndexTableUtils<nLayers>& utils, const Cluster& other)
42-
: xCoordinate{other.xCoordinate},
43-
yCoordinate{other.yCoordinate},
44-
zCoordinate{other.zCoordinate},
45-
phi{getNormalizedPhi(computePhi(other.xCoordinate, other.yCoordinate))},
46-
radius{o2::gpu::GPUCommonMath::Hypot(other.xCoordinate, other.yCoordinate)},
47-
clusterId{other.clusterId},
48-
indexTableBinIndex{utils.getBinIndex(utils.getZBinIndex(layerIndex, zCoordinate),
49-
utils.getPhiBinIndex(phi))}
50-
//, montecarloId{ other.montecarloId }
51-
{
52-
// Nothing to do
53-
}
54-
55-
template <int nLayers>
56-
Cluster::Cluster(const int layerIndex, const float3& primaryVertex, const IndexTableUtils<nLayers>& utils, const Cluster& other)
57-
: xCoordinate{other.xCoordinate},
58-
yCoordinate{other.yCoordinate},
59-
zCoordinate{other.zCoordinate},
60-
phi{getNormalizedPhi(
61-
computePhi(xCoordinate - primaryVertex.x, yCoordinate - primaryVertex.y))},
62-
radius{o2::gpu::GPUCommonMath::Hypot(xCoordinate - primaryVertex.x, yCoordinate - primaryVertex.y)},
63-
clusterId{other.clusterId},
64-
indexTableBinIndex{utils.getBinIndex(utils.getZBinIndex(layerIndex, zCoordinate),
65-
utils.getPhiBinIndex(phi))}
66-
{
67-
// Nothing to do
68-
}
69-
7016
GPUhd() void Cluster::print() const
7117
{
7218
printf("Cluster: %f %f %f %f %f %d %d\n", xCoordinate, yCoordinate, zCoordinate, phi, radius, clusterId, indexTableBinIndex);
7319
}
7420

75-
TrackingFrameInfo::TrackingFrameInfo(float x, float y, float z, float xTF, float alpha, std::array<float, 2>&& posTF,
76-
std::array<float, 3>&& covTF)
77-
: xCoordinate{x}, yCoordinate{y}, zCoordinate{z}, xTrackingFrame{xTF}, alphaTrackingFrame{alpha}, positionTrackingFrame{posTF}, covarianceTrackingFrame{covTF}
78-
{
79-
// Nothing to do
80-
}
81-
8221
GPUhd() void TrackingFrameInfo::print() const
8322
{
8423
printf("x: %f y: %f z: %f xTF: %f alphaTF: %f posTF: %f %f covTF: %f %f %f\n",

0 commit comments

Comments
 (0)