Skip to content

Commit 23d5424

Browse files
committed
ITS: allow cluster classes to be trivially moveable
1 parent ee966e1 commit 23d5424

File tree

7 files changed

+104
-167
lines changed

7 files changed

+104
-167
lines changed

Detectors/ITSMFT/ITS/tracking/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ o2_add_library(ITStracking
1919
src/TimeFrame.cxx
2020
src/IOUtils.cxx
2121
src/Label.cxx
22-
src/Road.cxx
2322
src/Tracker.cxx
2423
src/TrackerTraits.cxx
2524
src/TrackingConfigParam.cxx

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

Lines changed: 37 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,27 @@
2323

2424
#include "GPUCommonDef.h"
2525

26-
namespace o2
27-
{
28-
namespace its
26+
namespace o2::its
2927
{
3028

3129
class Cell final
3230
{
3331
public:
34-
GPUhd() Cell();
35-
GPUd() Cell(const int, const int, const int, const int, const int);
32+
GPUhdDefault() Cell() = default;
33+
GPUhd() Cell(const int firstClusterIndex, const int secondClusterIndex, const int thirdClusterIndex,
34+
const int firstTrackletIndex, const int secondTrackletIndex)
35+
: mFirstClusterIndex(firstClusterIndex),
36+
mSecondClusterIndex(secondClusterIndex),
37+
mThirdClusterIndex(thirdClusterIndex),
38+
mFirstTrackletIndex(firstTrackletIndex),
39+
mSecondTrackletIndex(secondTrackletIndex),
40+
mLevel(1) {}
41+
GPUhdDefault() Cell(const Cell&) = default;
42+
GPUhdDefault() Cell(Cell&&) = default;
43+
GPUhdDefault() ~Cell() = default;
44+
45+
GPUhdDefault() Cell& operator=(const Cell&) = default;
46+
GPUhdDefault() Cell& operator=(Cell&&) noexcept = default;
3647

3748
GPUhd() int getFirstClusterIndex() const { return mFirstClusterIndex; };
3849
GPUhd() int getSecondClusterIndex() const { return mSecondClusterIndex; };
@@ -44,44 +55,19 @@ class Cell final
4455
GPUhd() int* getLevelPtr() { return &mLevel; }
4556

4657
private:
47-
const int mFirstClusterIndex;
48-
const int mSecondClusterIndex;
49-
const int mThirdClusterIndex;
50-
const int mFirstTrackletIndex;
51-
const int mSecondTrackletIndex;
52-
int mLevel;
58+
int mFirstClusterIndex{0};
59+
int mSecondClusterIndex{0};
60+
int mThirdClusterIndex{0};
61+
int mFirstTrackletIndex{0};
62+
int mSecondTrackletIndex{0};
63+
int mLevel{0};
5364
};
5465

55-
GPUhdi() Cell::Cell()
56-
: mFirstClusterIndex{0},
57-
mSecondClusterIndex{0},
58-
mThirdClusterIndex{0},
59-
mFirstTrackletIndex{0},
60-
mSecondTrackletIndex{0},
61-
mLevel{0}
62-
{
63-
// Nothing to do
64-
}
65-
66-
GPUdi() Cell::Cell(const int firstClusterIndex, const int secondClusterIndex, const int thirdClusterIndex,
67-
const int firstTrackletIndex, const int secondTrackletIndex)
68-
: mFirstClusterIndex{firstClusterIndex},
69-
mSecondClusterIndex{secondClusterIndex},
70-
mThirdClusterIndex{thirdClusterIndex},
71-
mFirstTrackletIndex{firstTrackletIndex},
72-
mSecondTrackletIndex{secondTrackletIndex},
73-
mLevel{1}
74-
{
75-
// Nothing to do
76-
}
77-
7866
class CellSeed final : public o2::track::TrackParCovF
7967
{
8068
public:
8169
GPUhdDefault() CellSeed() = default;
82-
GPUhdDefault() CellSeed(const CellSeed&) = default;
83-
GPUhdDefault() ~CellSeed() = default;
84-
GPUd() CellSeed(int innerL, int cl0, int cl1, int cl2, int trkl0, int trkl1, o2::track::TrackParCovF& tpc, float chi2) : o2::track::TrackParCovF{tpc}, mLevel{1}, mChi2{chi2}
70+
GPUhd() CellSeed(int innerL, int cl0, int cl1, int cl2, int trkl0, int trkl1, o2::track::TrackParCovF& tpc, float chi2) : o2::track::TrackParCovF{tpc}, mLevel{1}, mChi2{chi2}
8571
{
8672
setUserField(innerL);
8773
mClusters[innerL + 0] = cl0;
@@ -90,6 +76,12 @@ class CellSeed final : public o2::track::TrackParCovF
9076
mTracklets[0] = trkl0;
9177
mTracklets[1] = trkl1;
9278
}
79+
GPUhdDefault() CellSeed(const CellSeed&) = default;
80+
GPUhdDefault() ~CellSeed() = default;
81+
GPUhdDefault() CellSeed(CellSeed&&) = default;
82+
GPUhdDefault() CellSeed& operator=(const CellSeed&) = default;
83+
GPUhdDefault() CellSeed& operator=(CellSeed&&) = default;
84+
9385
GPUhd() int getFirstClusterIndex() const { return mClusters[getUserField()]; };
9486
GPUhd() int getSecondClusterIndex() const { return mClusters[getUserField() + 1]; };
9587
GPUhd() int getThirdClusterIndex() const { return mClusters[getUserField() + 2]; };
@@ -104,20 +96,18 @@ class CellSeed final : public o2::track::TrackParCovF
10496
GPUhd() int* getLevelPtr() { return &mLevel; }
10597
GPUhd() int* getClusters() { return mClusters; }
10698
GPUhd() int getCluster(int i) const { return mClusters[i]; }
107-
GPUhdi() void printCell() const;
99+
GPUhd() void printCell() const
100+
{
101+
printf("trkl: %d, %d\t lvl: %d\t chi2: %f\n", mTracklets[0], mTracklets[1], mLevel, mChi2);
102+
}
108103

109104
private:
110-
int mClusters[7] = {-1, -1, -1, -1, -1, -1, -1};
111-
int mTracklets[2] = {-1, -1};
112-
int mLevel = 0;
113105
float mChi2 = 0.f;
106+
int mLevel = 0;
107+
int mTracklets[2] = {-1, -1};
108+
int mClusters[7] = {-1, -1, -1, -1, -1, -1, -1};
114109
};
115110

116-
GPUhdi() void CellSeed::printCell() const
117-
{
118-
printf("trkl: %d, %d\t lvl: %d\t chi2: %f\n", mTracklets[0], mTracklets[1], mLevel, mChi2);
119-
}
111+
} // namespace o2::its
120112

121-
} // namespace its
122-
} // namespace o2
123113
#endif /* TRACKINGITSU_INCLUDE_CACELL_H_ */

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

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#ifndef TRACKINGITSU_INCLUDE_CACLUSTER_H_
1717
#define TRACKINGITSU_INCLUDE_CACLUSTER_H_
1818

19-
#include <array>
20-
2119
#include "GPUCommonRtypes.h"
2220
#include "GPUCommonArray.h"
2321

@@ -27,12 +25,30 @@ namespace o2::its
2725
class IndexTableUtils;
2826

2927
struct Cluster final {
30-
Cluster() = default;
31-
Cluster(const float x, const float y, const float z, const int idx);
32-
Cluster(const int, const IndexTableUtils& utils, const Cluster&);
33-
Cluster(const int, const float3&, const IndexTableUtils& utils, const Cluster&);
34-
void Init(const int, const float3&, const IndexTableUtils& utils, const Cluster&);
35-
bool operator==(const Cluster&) const;
28+
GPUhdDefault() Cluster() = default;
29+
GPUhd() Cluster(const float x, const float y, const float z, const int idx);
30+
GPUhd() Cluster(const int, const IndexTableUtils& utils, const Cluster&);
31+
GPUhd() Cluster(const int, const float3&, const IndexTableUtils& utils, const Cluster&);
32+
GPUhdDefault() Cluster(const Cluster&) = default;
33+
GPUhdDefault() Cluster(Cluster&&) noexcept = default;
34+
GPUhdDefault() ~Cluster() = default;
35+
36+
GPUhdDefault() Cluster& operator=(const Cluster&) = default;
37+
GPUhdDefault() Cluster& operator=(Cluster&&) noexcept = default;
38+
39+
// TODO
40+
/*GPUhdDefault() bool operator==(const Cluster&) const = default;*/
41+
GPUhd() bool operator==(const Cluster& other) const
42+
{
43+
return xCoordinate == other.xCoordinate &&
44+
yCoordinate == other.yCoordinate &&
45+
zCoordinate == other.zCoordinate &&
46+
phi == other.phi &&
47+
radius == other.radius &&
48+
clusterId == other.clusterId &&
49+
indexTableBinIndex == other.indexTableBinIndex;
50+
}
51+
3652
GPUhd() void print() const;
3753

3854
float xCoordinate{-999.f};
@@ -42,20 +58,19 @@ struct Cluster final {
4258
float radius{-999.f};
4359
int clusterId{-1};
4460
int indexTableBinIndex{-1};
45-
46-
ClassDefNV(Cluster, 1);
4761
};
4862

49-
GPUhdi() void Cluster::print() const
50-
{
51-
#if !defined(GPUCA_GPUCODE_DEVICE) || (!defined(__OPENCL__) && defined(GPUCA_GPU_DEBUG_PRINT))
52-
printf("Cluster: %f %f %f %f %f %d %d\n", xCoordinate, yCoordinate, zCoordinate, phi, radius, clusterId, indexTableBinIndex);
53-
#endif
54-
}
63+
struct TrackingFrameInfo final {
64+
GPUhdDefault() TrackingFrameInfo() = default;
65+
GPUhd() TrackingFrameInfo(float x, float y, float z, float xTF, float alpha, std::array<float, 2>&& posTF, std::array<float, 3>&& covTF);
66+
GPUhdDefault() TrackingFrameInfo(const TrackingFrameInfo&) = default;
67+
GPUhdDefault() TrackingFrameInfo(TrackingFrameInfo&&) noexcept = default;
68+
GPUhdDefault() ~TrackingFrameInfo() = default;
69+
70+
GPUhdDefault() TrackingFrameInfo& operator=(const TrackingFrameInfo&) = default;
71+
GPUhdDefault() TrackingFrameInfo& operator=(TrackingFrameInfo&&) = default;
5572

56-
struct TrackingFrameInfo {
57-
TrackingFrameInfo() = default;
58-
TrackingFrameInfo(float x, float y, float z, float xTF, float alpha, std::array<float, 2>&& posTF, std::array<float, 3>&& covTF);
73+
GPUhd() void print() const;
5974

6075
float xCoordinate{-999.f};
6176
float yCoordinate{-999.f};
@@ -64,15 +79,6 @@ struct TrackingFrameInfo {
6479
float alphaTrackingFrame{-999.f};
6580
std::array<float, 2> positionTrackingFrame = {-1., -1.};
6681
std::array<float, 3> covarianceTrackingFrame = {999., 999., 999.};
67-
GPUdi() void print() const
68-
{
69-
#if !defined(GPUCA_GPUCODE_DEVICE) || (!defined(__OPENCL__) && defined(GPUCA_GPU_DEBUG_PRINT))
70-
printf("x: %f y: %f z: %f xTF: %f alphaTF: %f posTF: %f %f covTF: %f %f %f\n",
71-
xCoordinate, yCoordinate, zCoordinate, xTrackingFrame, alphaTrackingFrame,
72-
positionTrackingFrame[0], positionTrackingFrame[1],
73-
covarianceTrackingFrame[0], covarianceTrackingFrame[1], covarianceTrackingFrame[2]);
74-
#endif
75-
}
7682
};
7783

7884
} // namespace o2::its

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

Lines changed: 19 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -16,32 +16,31 @@
1616
#ifndef TRACKINGCA_INCLUDE_ROAD_H
1717
#define TRACKINGCA_INCLUDE_ROAD_H
1818

19-
#ifndef GPUCA_GPUCODE_DEVICE
20-
#include <array>
21-
#endif
22-
2319
#include "ITStracking/Constants.h"
2420
#include "GPUCommonDef.h"
2521

26-
namespace o2
27-
{
28-
namespace its
22+
namespace o2::its
2923
{
3024

3125
template <unsigned char maxRoadSize = 5>
3226
class Road final
3327
{
3428
public:
35-
GPUhd() Road() : mCellIds{}, mRoadSize{}, mIsFakeRoad{} { resetRoad(); }
29+
GPUhdDefault() Road() = default;
3630
GPUhd() Road(int cellLayer, int cellId) : Road() { addCell(cellLayer, cellId); }
3731

38-
GPUhd() int getRoadSize() const;
39-
int getLabel() const;
40-
void setLabel(const int);
41-
GPUhd() bool isFakeRoad() const;
42-
void setFakeRoad(const bool);
43-
GPUhd() int& operator[](const int&);
44-
GPUhd() int operator[](const int&) const;
32+
GPUhdDefault() Road(const Road&) = default;
33+
GPUhdDefault() Road(Road&&) noexcept = default;
34+
GPUhdDefault() ~Road() = default;
35+
36+
GPUhdDefault() Road& operator=(const Road&) = default;
37+
GPUhdDefault() Road& operator=(Road&&) noexcept = default;
38+
39+
GPUhdi() uint8_t getRoadSize() const { return mRoadSize; }
40+
GPUhdi() bool isFakeRoad() const { return mIsFakeRoad; }
41+
GPUhdi() void setFakeRoad(const bool fake) { mIsFakeRoad = fake; }
42+
GPUhdi() int& operator[](const int& i) { return mCellIds[i]; }
43+
GPUhdi() int operator[](const int& i) const { return mCellIds[i]; }
4544

4645
GPUhd() void resetRoad()
4746
{
@@ -61,42 +60,12 @@ class Road final
6160
}
6261

6362
private:
64-
int mCellIds[maxRoadSize];
63+
int mCellIds[maxRoadSize]{constants::its::UnusedIndex};
6564
// int mLabel;
66-
unsigned char mRoadSize;
67-
bool mIsFakeRoad;
65+
unsigned char mRoadSize{0};
66+
bool mIsFakeRoad{false};
6867
};
6968

70-
template <unsigned char maxRoadSize>
71-
GPUhdi() int Road<maxRoadSize>::getRoadSize() const
72-
{
73-
return mRoadSize;
74-
}
75-
76-
template <unsigned char maxRoadSize>
77-
GPUhdi() int& Road<maxRoadSize>::operator[](const int& i)
78-
{
79-
return mCellIds[i];
80-
}
69+
} // namespace o2::its
8170

82-
template <unsigned char maxRoadSize>
83-
GPUhdi() int Road<maxRoadSize>::operator[](const int& i) const
84-
{
85-
return mCellIds[i];
86-
}
87-
88-
template <unsigned char maxRoadSize>
89-
GPUhdi() bool Road<maxRoadSize>::isFakeRoad() const
90-
{
91-
return mIsFakeRoad;
92-
}
93-
94-
template <unsigned char maxRoadSize>
95-
inline void Road<maxRoadSize>::setFakeRoad(const bool isFakeRoad)
96-
{
97-
mIsFakeRoad = isFakeRoad;
98-
}
99-
} // namespace its
100-
} // namespace o2
101-
102-
#endif
71+
#endif

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

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,11 @@ Cluster::Cluster(const int layerIndex, const float3& primaryVertex, const IndexT
6666
// Nothing to do
6767
}
6868

69-
void Cluster::Init(const int layerIndex, const float3& primaryVertex, const IndexTableUtils& utils, const Cluster& other)
69+
GPUhd() void Cluster::print() const
7070
{
71-
xCoordinate = other.xCoordinate;
72-
yCoordinate = other.yCoordinate;
73-
zCoordinate = other.zCoordinate;
74-
phi = getNormalizedPhi(
75-
computePhi(xCoordinate - primaryVertex.x, yCoordinate - primaryVertex.y));
76-
radius = o2::gpu::GPUCommonMath::Hypot(xCoordinate - primaryVertex.x, yCoordinate - primaryVertex.y);
77-
clusterId = other.clusterId;
78-
indexTableBinIndex = utils.getBinIndex(utils.getZBinIndex(layerIndex, zCoordinate),
79-
utils.getPhiBinIndex(phi));
80-
}
81-
82-
bool Cluster::operator==(const Cluster& rhs) const
83-
{
84-
return this->xCoordinate == rhs.xCoordinate &&
85-
this->yCoordinate == rhs.yCoordinate &&
86-
this->zCoordinate == rhs.zCoordinate &&
87-
this->phi == rhs.phi &&
88-
this->radius == rhs.radius &&
89-
this->clusterId == rhs.clusterId &&
90-
this->indexTableBinIndex == rhs.indexTableBinIndex;
71+
#if !defined(GPUCA_GPUCODE_DEVICE) || (!defined(__OPENCL__) && defined(GPUCA_GPU_DEBUG_PRINT))
72+
printf("Cluster: %f %f %f %f %f %d %d\n", xCoordinate, yCoordinate, zCoordinate, phi, radius, clusterId, indexTableBinIndex);
73+
#endif
9174
}
9275

9376
TrackingFrameInfo::TrackingFrameInfo(float x, float y, float z, float xTF, float alpha, std::array<float, 2>&& posTF,
@@ -96,3 +79,13 @@ TrackingFrameInfo::TrackingFrameInfo(float x, float y, float z, float xTF, float
9679
{
9780
// Nothing to do
9881
}
82+
83+
GPUhd() void TrackingFrameInfo::print() const
84+
{
85+
#if !defined(GPUCA_GPUCODE_DEVICE) || (!defined(__OPENCL__) && defined(GPUCA_GPU_DEBUG_PRINT))
86+
printf("x: %f y: %f z: %f xTF: %f alphaTF: %f posTF: %f %f covTF: %f %f %f\n",
87+
xCoordinate, yCoordinate, zCoordinate, xTrackingFrame, alphaTrackingFrame,
88+
positionTrackingFrame[0], positionTrackingFrame[1],
89+
covarianceTrackingFrame[0], covarianceTrackingFrame[1], covarianceTrackingFrame[2]);
90+
#endif
91+
}

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

Lines changed: 0 additions & 18 deletions
This file was deleted.

Detectors/ITSMFT/ITS/tracking/src/TrackingLinkDef.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
#pragma link C++ class o2::its::Line + ;
2121
#pragma link C++ class std::vector < o2::its::Tracklet> + ;
2222
#pragma link C++ class std::vector < o2::its::Line> + ;
23-
#pragma link C++ class o2::its::Cluster + ;
24-
#pragma link C++ class std::vector < o2::its::Cluster> + ;
2523
#pragma link C++ class std::vector < o2::its::ClusterLines> + ;
2624

2725
#pragma link C++ class o2::its::VertexerParamConfig + ;

0 commit comments

Comments
 (0)