Skip to content

Commit f033b79

Browse files
committed
ITS: allow cluster classes to be trivially moveable
1 parent 075f1e1 commit f033b79

File tree

4 files changed

+47
-90
lines changed

4 files changed

+47
-90
lines changed

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

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,26 @@
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+
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+
GPUhd() ~Cell() = default;
42+
GPUhd() Cell(const Cell&) = default;
43+
GPUhd() Cell(Cell&&) = default;
44+
GPUhd() Cell& operator=(const Cell&) = default;
45+
GPUhd() Cell& operator=(Cell&&) = default;
3646

3747
GPUhd() int getFirstClusterIndex() const { return mFirstClusterIndex; };
3848
GPUhd() int getSecondClusterIndex() const { return mSecondClusterIndex; };
@@ -44,37 +54,14 @@ class Cell final
4454
GPUhd() int* getLevelPtr() { return &mLevel; }
4555

4656
private:
47-
const int mFirstClusterIndex;
48-
const int mSecondClusterIndex;
49-
const int mThirdClusterIndex;
50-
const int mFirstTrackletIndex;
51-
const int mSecondTrackletIndex;
52-
int mLevel;
57+
int mFirstClusterIndex{0};
58+
int mSecondClusterIndex{0};
59+
int mThirdClusterIndex{0};
60+
int mFirstTrackletIndex{0};
61+
int mSecondTrackletIndex{0};
62+
int mLevel{0};
5363
};
5464

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-
7865
class CellSeed final : public o2::track::TrackParCovF
7966
{
8067
public:
@@ -90,6 +77,7 @@ class CellSeed final : public o2::track::TrackParCovF
9077
mTracklets[0] = trkl0;
9178
mTracklets[1] = trkl1;
9279
}
80+
9381
GPUhd() int getFirstClusterIndex() const { return mClusters[getUserField()]; };
9482
GPUhd() int getSecondClusterIndex() const { return mClusters[getUserField() + 1]; };
9583
GPUhd() int getThirdClusterIndex() const { return mClusters[getUserField() + 2]; };
@@ -104,20 +92,18 @@ class CellSeed final : public o2::track::TrackParCovF
10492
GPUhd() int* getLevelPtr() { return &mLevel; }
10593
GPUhd() int* getClusters() { return mClusters; }
10694
GPUhd() int getCluster(int i) const { return mClusters[i]; }
107-
GPUhdi() void printCell() const;
95+
GPUhd() void printCell() const
96+
{
97+
printf("trkl: %d, %d\t lvl: %d\t chi2: %f\n", mTracklets[0], mTracklets[1], mLevel, mChi2);
98+
}
10899

109100
private:
110-
int mClusters[7] = {-1, -1, -1, -1, -1, -1, -1};
111-
int mTracklets[2] = {-1, -1};
112-
int mLevel = 0;
113101
float mChi2 = 0.f;
102+
int mLevel = 0;
103+
int mTracklets[2] = {-1, -1};
104+
int mClusters[7] = {-1, -1, -1, -1, -1, -1, -1};
114105
};
115106

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-
}
107+
} // namespace o2::its
120108

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

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

Lines changed: 3 additions & 23 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

@@ -31,8 +29,7 @@ struct Cluster final {
3129
Cluster(const float x, const float y, const float z, const int idx);
3230
Cluster(const int, const IndexTableUtils& utils, const Cluster&);
3331
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;
32+
bool operator==(const Cluster&) const = default;
3633
GPUhd() void print() const;
3734

3835
float xCoordinate{-999.f};
@@ -42,20 +39,12 @@ struct Cluster final {
4239
float radius{-999.f};
4340
int clusterId{-1};
4441
int indexTableBinIndex{-1};
45-
46-
ClassDefNV(Cluster, 1);
4742
};
4843

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-
56-
struct TrackingFrameInfo {
44+
struct TrackingFrameInfo final {
5745
TrackingFrameInfo() = default;
5846
TrackingFrameInfo(float x, float y, float z, float xTF, float alpha, std::array<float, 2>&& posTF, std::array<float, 3>&& covTF);
47+
GPUhd() void print() const;
5948

6049
float xCoordinate{-999.f};
6150
float yCoordinate{-999.f};
@@ -64,15 +53,6 @@ struct TrackingFrameInfo {
6453
float alphaTrackingFrame{-999.f};
6554
std::array<float, 2> positionTrackingFrame = {-1., -1.};
6655
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-
}
7656
};
7757

7858
} // namespace o2::its

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/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)