Skip to content

Commit bef99a5

Browse files
committed
ITS: allow cluster classes to be trivially moveable
1 parent 81ec36f commit bef99a5

File tree

3 files changed

+41
-74
lines changed

3 files changed

+41
-74
lines changed

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

Lines changed: 25 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,21 @@
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+
GPUhd() Cell() = default;
33+
GPUdi() 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) {}
3641

3742
GPUhd() int getFirstClusterIndex() const { return mFirstClusterIndex; };
3843
GPUhd() int getSecondClusterIndex() const { return mSecondClusterIndex; };
@@ -44,43 +49,18 @@ class Cell final
4449
GPUhd() int* getLevelPtr() { return &mLevel; }
4550

4651
private:
47-
const int mFirstClusterIndex;
48-
const int mSecondClusterIndex;
49-
const int mThirdClusterIndex;
50-
const int mFirstTrackletIndex;
51-
const int mSecondTrackletIndex;
52-
int mLevel;
52+
int mFirstClusterIndex{0};
53+
int mSecondClusterIndex{0};
54+
int mThirdClusterIndex{0};
55+
int mFirstTrackletIndex{0};
56+
int mSecondTrackletIndex{0};
57+
int mLevel{0};
5358
};
5459

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-
7860
class CellSeed final : public o2::track::TrackParCovF
7961
{
8062
public:
81-
GPUhdDefault() CellSeed() = default;
82-
GPUhdDefault() CellSeed(const CellSeed&) = default;
83-
GPUhdDefault() ~CellSeed() = default;
63+
GPUd() CellSeed() = default;
8464
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}
8565
{
8666
setUserField(innerL);
@@ -104,20 +84,18 @@ class CellSeed final : public o2::track::TrackParCovF
10484
GPUhd() int* getLevelPtr() { return &mLevel; }
10585
GPUhd() int* getClusters() { return mClusters; }
10686
GPUhd() int getCluster(int i) const { return mClusters[i]; }
107-
GPUhdi() void printCell() const;
87+
GPUhdi() void printCell() const
88+
{
89+
printf("trkl: %d, %d\t lvl: %d\t chi2: %f\n", mTracklets[0], mTracklets[1], mLevel, mChi2);
90+
}
10891

10992
private:
110-
int mClusters[7] = {-1, -1, -1, -1, -1, -1, -1};
111-
int mTracklets[2] = {-1, -1};
112-
int mLevel = 0;
11393
float mChi2 = 0.f;
94+
int mLevel = 0;
95+
int mTracklets[2] = {-1, -1};
96+
int mClusters[7] = {-1, -1, -1, -1, -1, -1, -1};
11497
};
11598

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-
}
99+
} // namespace o2::its
120100

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

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

Lines changed: 2 additions & 19 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

@@ -32,7 +30,7 @@ struct Cluster final {
3230
Cluster(const int, const IndexTableUtils& utils, const Cluster&);
3331
Cluster(const int, const float3&, const IndexTableUtils& utils, const Cluster&);
3432
void Init(const int, const float3&, const IndexTableUtils& utils, const Cluster&);
35-
bool operator==(const Cluster&) const;
33+
bool operator==(const Cluster&) const = default;
3634
GPUhd() void print() const;
3735

3836
float xCoordinate{-999.f};
@@ -46,13 +44,6 @@ struct Cluster final {
4644
ClassDefNV(Cluster, 1);
4745
};
4846

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-
}
55-
5647
struct TrackingFrameInfo {
5748
TrackingFrameInfo() = default;
5849
TrackingFrameInfo(float x, float y, float z, float xTF, float alpha, std::array<float, 2>&& posTF, std::array<float, 3>&& covTF);
@@ -64,15 +55,7 @@ struct TrackingFrameInfo {
6455
float alphaTrackingFrame{-999.f};
6556
std::array<float, 2> positionTrackingFrame = {-1., -1.};
6657
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-
}
58+
GPUdi() void print() const;
7659
};
7760

7861
} // namespace o2::its

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,11 @@ void Cluster::Init(const int layerIndex, const float3& primaryVertex, const Inde
7979
utils.getPhiBinIndex(phi));
8080
}
8181

82-
bool Cluster::operator==(const Cluster& rhs) const
82+
GPUhd() void Cluster::print() const
8383
{
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;
84+
#if !defined(GPUCA_GPUCODE_DEVICE) || (!defined(__OPENCL__) && defined(GPUCA_GPU_DEBUG_PRINT))
85+
printf("Cluster: %f %f %f %f %f %d %d\n", xCoordinate, yCoordinate, zCoordinate, phi, radius, clusterId, indexTableBinIndex);
86+
#endif
9187
}
9288

9389
TrackingFrameInfo::TrackingFrameInfo(float x, float y, float z, float xTF, float alpha, std::array<float, 2>&& posTF,
@@ -96,3 +92,13 @@ TrackingFrameInfo::TrackingFrameInfo(float x, float y, float z, float xTF, float
9692
{
9793
// Nothing to do
9894
}
95+
96+
GPUdi() void TrackingFrameInfo::print() const
97+
{
98+
#if !defined(GPUCA_GPUCODE_DEVICE) || (!defined(__OPENCL__) && defined(GPUCA_GPU_DEBUG_PRINT))
99+
printf("x: %f y: %f z: %f xTF: %f alphaTF: %f posTF: %f %f covTF: %f %f %f\n",
100+
xCoordinate, yCoordinate, zCoordinate, xTrackingFrame, alphaTrackingFrame,
101+
positionTrackingFrame[0], positionTrackingFrame[1],
102+
covarianceTrackingFrame[0], covarianceTrackingFrame[1], covarianceTrackingFrame[2]);
103+
#endif
104+
}

0 commit comments

Comments
 (0)