Skip to content

Commit b1825e3

Browse files
committed
Make traccc::edm::spacepoint<T> use the point3 type natively.
Also, make at least some of the code use the new vecmem::edm::host::push_back(...) functionality.
1 parent fb8b38d commit b1825e3

7 files changed

+116
-183
lines changed

core/include/traccc/edm/impl/seed_collection.ipp

-19
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,6 @@
99

1010
namespace traccc::edm {
1111

12-
template <typename BASE>
13-
TRACCC_HOST_DEVICE seed<BASE>& seed<BASE>::operator=(const seed& other) {
14-
15-
top_index() = other.top_index();
16-
middle_index() = other.middle_index();
17-
bottom_index() = other.bottom_index();
18-
return *this;
19-
}
20-
21-
template <typename BASE>
22-
template <typename T, std::enable_if_t<!std::is_same_v<BASE, T>, bool> >
23-
TRACCC_HOST_DEVICE seed<BASE>& seed<BASE>::operator=(const seed<T>& other) {
24-
25-
top_index() = other.top_index();
26-
middle_index() = other.middle_index();
27-
bottom_index() = other.bottom_index();
28-
return *this;
29-
}
30-
3112
template <typename BASE>
3213
template <typename T>
3314
TRACCC_HOST_DEVICE bool seed<BASE>::operator==(const seed<T>& other) const {

core/include/traccc/edm/impl/spacepoint_collection.ipp

+32-27
Original file line numberDiff line numberDiff line change
@@ -13,48 +13,53 @@
1313
namespace traccc::edm {
1414

1515
template <typename BASE>
16-
TRACCC_HOST_DEVICE auto spacepoint<BASE>::radius() const {
16+
TRACCC_HOST_DEVICE auto& spacepoint<BASE>::x() {
1717

18-
return math::sqrt(x() * x() + y() * y());
18+
return global()[0];
1919
}
2020

2121
template <typename BASE>
22-
TRACCC_HOST_DEVICE auto spacepoint<BASE>::phi() const {
22+
TRACCC_HOST_DEVICE const auto& spacepoint<BASE>::x() const {
2323

24-
return math::atan2(y(), x());
24+
return global()[0];
25+
}
26+
27+
template <typename BASE>
28+
TRACCC_HOST_DEVICE auto& spacepoint<BASE>::y() {
29+
30+
return global()[1];
31+
}
32+
33+
template <typename BASE>
34+
TRACCC_HOST_DEVICE const auto& spacepoint<BASE>::y() const {
35+
36+
return global()[1];
37+
}
38+
39+
template <typename BASE>
40+
TRACCC_HOST_DEVICE auto& spacepoint<BASE>::z() {
41+
42+
return global()[2];
2543
}
2644

2745
template <typename BASE>
28-
TRACCC_HOST_DEVICE auto spacepoint<BASE>::global() const {
46+
TRACCC_HOST_DEVICE const auto& spacepoint<BASE>::z() const {
2947

30-
return point3{x(), y(), z()};
48+
return global()[2];
3149
}
3250

3351
template <typename BASE>
34-
TRACCC_HOST_DEVICE spacepoint<BASE>& spacepoint<BASE>::operator=(
35-
const spacepoint& other) {
36-
37-
measurement_index() = other.measurement_index();
38-
x() = other.x();
39-
y() = other.y();
40-
z() = other.z();
41-
z_variance() = other.z_variance();
42-
radius_variance() = other.radius_variance();
43-
return *this;
52+
TRACCC_HOST_DEVICE auto spacepoint<BASE>::radius() const {
53+
54+
const scalar xx = x();
55+
const scalar yy = y();
56+
return math::sqrt(xx * xx + yy * yy);
4457
}
4558

4659
template <typename BASE>
47-
template <typename T, std::enable_if_t<!std::is_same_v<BASE, T>, bool> >
48-
TRACCC_HOST_DEVICE spacepoint<BASE>& spacepoint<BASE>::operator=(
49-
const spacepoint<T>& other) {
50-
51-
measurement_index() = other.measurement_index();
52-
x() = other.x();
53-
y() = other.y();
54-
z() = other.z();
55-
z_variance() = other.z_variance();
56-
radius_variance() = other.radius_variance();
57-
return *this;
60+
TRACCC_HOST_DEVICE auto spacepoint<BASE>::phi() const {
61+
62+
return math::atan2(y(), x());
5863
}
5964

6065
template <typename BASE>

core/include/traccc/edm/seed_collection.hpp

+3-21
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@ template <typename BASE>
2626
class seed : public BASE {
2727

2828
public:
29-
/// @name Constructors
29+
/// @name Functions inherited from the base class
3030
/// @{
3131

3232
/// Inherit the base class's constructor(s)
3333
using BASE::BASE;
34-
/// Use a default copy constructor
35-
seed(const seed& other) = default;
36-
/// Use a default move constructor
37-
seed(seed&& other) = default;
34+
/// Inherit the base class's assignment operator(s).
35+
using BASE::operator=;
3836

3937
/// @}
4038

@@ -85,22 +83,6 @@ class seed : public BASE {
8583
/// @name Utility functions
8684
/// @{
8785

88-
/// Assignment operator
89-
///
90-
/// @param[in] other The object to assign from
91-
/// @return A reference to this object
92-
///
93-
TRACCC_HOST_DEVICE seed& operator=(const seed& other);
94-
95-
/// Assignment operator
96-
///
97-
/// @param[in] other The object to assign from
98-
/// @return A reference to this object
99-
///
100-
template <typename T,
101-
std::enable_if_t<!std::is_same_v<BASE, T>, bool> = false>
102-
TRACCC_HOST_DEVICE seed& operator=(const seed<T>& other);
103-
10486
/// Equality operator
10587
///
10688
/// @note This function must only be used on proxy objects, not on

core/include/traccc/edm/spacepoint_collection.hpp

+53-51
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@ template <typename BASE>
2626
class spacepoint : public BASE {
2727

2828
public:
29-
/// @name Constructors
29+
/// @name Functions inherited from the base class
3030
/// @{
3131

3232
/// Inherit the base class's constructor(s)
3333
using BASE::BASE;
34-
/// Use a default copy constructor
35-
spacepoint(const spacepoint& other) = default;
36-
/// Use a default move constructor
37-
spacepoint(spacepoint&& other) = default;
34+
/// Inherit the base class's assignment operator(s).
35+
using BASE::operator=;
3836

3937
/// @}
4038

@@ -54,55 +52,84 @@ class spacepoint : public BASE {
5452
TRACCC_HOST_DEVICE
5553
const auto& measurement_index() const { return BASE::template get<0>(); }
5654

55+
/// Global / 3D position of the spacepoint
56+
///
57+
/// @return A (non-const) vector of @c traccc::point3 values
58+
///
59+
TRACCC_HOST_DEVICE auto& global() { return BASE::template get<1>(); }
60+
/// Global / 3D position of the spacepoint
61+
///
62+
/// @return A (const) vector of @c traccc::point3 values
63+
///
64+
TRACCC_HOST_DEVICE const auto& global() const {
65+
return BASE::template get<1>();
66+
}
67+
5768
/// The X position of the spacepoint (non-const)
5869
///
59-
/// @return A (non-const) vector of @c traccc::scalar values
70+
/// @note This function must only be used on proxy objects, not on
71+
/// containers!
72+
///
73+
/// @return A (non-const) reference to a @c traccc::scalar value
6074
///
6175
TRACCC_HOST_DEVICE
62-
auto& x() { return BASE::template get<1>(); }
76+
auto& x();
6377
/// The X position of the spacepoint (const)
6478
///
65-
/// @return A (const) vector of @c traccc::scalar values
79+
/// @note This function must only be used on proxy objects, not on
80+
/// containers!
81+
///
82+
/// @return A (const) reference to a @c traccc::scalar value
6683
///
6784
TRACCC_HOST_DEVICE
68-
const auto& x() const { return BASE::template get<1>(); }
85+
const auto& x() const;
6986

7087
/// The Y position of the spacepoint (non-const)
7188
///
72-
/// @return A (non-const) vector of @c traccc::scalar values
89+
/// @note This function must only be used on proxy objects, not on
90+
/// containers!
91+
///
92+
/// @return A (non-const) reference to a @c traccc::scalar value
7393
///
7494
TRACCC_HOST_DEVICE
75-
auto& y() { return BASE::template get<2>(); }
95+
auto& y();
7696
/// The Y position of the spacepoint (const)
7797
///
78-
/// @return A (const) vector of @c traccc::scalar values
98+
/// @return A (const) reference to a @c traccc::scalar value
7999
///
80100
TRACCC_HOST_DEVICE
81-
const auto& y() const { return BASE::template get<2>(); }
101+
const auto& y() const;
82102

83103
/// The Z position of the spacepoint (non-const)
84104
///
85-
/// @return A (non-const) vector of @c traccc::scalar values
105+
/// @note This function must only be used on proxy objects, not on
106+
/// containers!
107+
///
108+
/// @return A (non-const) reference to a @c traccc::scalar value
86109
///
87110
TRACCC_HOST_DEVICE
88-
auto& z() { return BASE::template get<3>(); }
111+
auto& z();
89112
/// The Z position of the spacepoint (const)
90113
///
91-
/// @return A (const) vector of @c traccc::scalar values
114+
/// @note This function must only be used on proxy objects, not on
115+
/// containers!
116+
///
117+
/// @return A (const) reference to a @c traccc::scalar value
92118
///
93119
TRACCC_HOST_DEVICE
94-
const auto& z() const { return BASE::template get<3>(); }
120+
const auto& z() const;
121+
95122
/// The variation on the spacepoint's Z coordinate (non-const)
96123
///
97124
/// @return A (non-const) vector of @c traccc::scalar values
98125
///
99-
TRACCC_HOST_DEVICE auto& z_variance() { return BASE::template get<4>(); }
126+
TRACCC_HOST_DEVICE auto& z_variance() { return BASE::template get<2>(); }
100127
/// The variation on the spacepoint's Z coordinate (const)
101128
///
102129
/// @return A (const) vector of @c traccc::scalar values
103130
///
104131
TRACCC_HOST_DEVICE const auto& z_variance() const {
105-
return BASE::template get<4>();
132+
return BASE::template get<2>();
106133
}
107134

108135
/// The radius of the spacepoint in the XY plane (non-const)
@@ -119,14 +146,14 @@ class spacepoint : public BASE {
119146
/// @return A (non-const) vector of @c traccc::scalar values
120147
///
121148
TRACCC_HOST_DEVICE auto& radius_variance() {
122-
return BASE::template get<5>();
149+
return BASE::template get<3>();
123150
}
124151
/// The variation on the spacepoint radious (const)
125152
///
126153
/// @return A (non-const) vector of @c traccc::scalar values
127154
///
128155
TRACCC_HOST_DEVICE const auto& radius_variance() const {
129-
return BASE::template get<5>();
156+
return BASE::template get<3>();
130157
}
131158

132159
/// The azimuthal angle of the spacepoint in the XY plane (non-const)
@@ -138,36 +165,11 @@ class spacepoint : public BASE {
138165
///
139166
TRACCC_HOST_DEVICE auto phi() const;
140167

141-
/// Global / 3D position of the spacepoint
142-
///
143-
/// @note This function must only be used on proxy objects, not on
144-
/// containers!
145-
///
146-
/// @return A @c traccc::point3 value
147-
///
148-
TRACCC_HOST_DEVICE auto global() const;
149-
150168
/// @}
151169

152170
/// @name Utility functions
153171
/// @{
154172

155-
/// Assignment operator
156-
///
157-
/// @param[in] other The object to assign from
158-
/// @return A reference to this object
159-
///
160-
TRACCC_HOST_DEVICE spacepoint& operator=(const spacepoint& other);
161-
162-
/// Assignment operator
163-
///
164-
/// @param[in] other The object to assign from
165-
/// @return A reference to this object
166-
///
167-
template <typename T,
168-
std::enable_if_t<!std::is_same_v<BASE, T>, bool> = false>
169-
TRACCC_HOST_DEVICE spacepoint& operator=(const spacepoint<T>& other);
170-
171173
/// Equality operator
172174
///
173175
/// @note This function must only be used on proxy objects, not on
@@ -197,11 +199,11 @@ class spacepoint : public BASE {
197199
}; // class spacepoint
198200

199201
/// SoA container describing reconstructed spacepoints
200-
using spacepoint_collection = vecmem::edm::container<
201-
spacepoint, vecmem::edm::type::vector<unsigned int>,
202-
vecmem::edm::type::vector<scalar>, vecmem::edm::type::vector<scalar>,
203-
vecmem::edm::type::vector<scalar>, vecmem::edm::type::vector<scalar>,
204-
vecmem::edm::type::vector<scalar> >;
202+
using spacepoint_collection =
203+
vecmem::edm::container<spacepoint, vecmem::edm::type::vector<unsigned int>,
204+
vecmem::edm::type::vector<point3>,
205+
vecmem::edm::type::vector<scalar>,
206+
vecmem::edm::type::vector<scalar> >;
205207

206208
} // namespace traccc::edm
207209

io/src/csv/read_spacepoints.cpp

+2-9
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,8 @@ void read_spacepoints(edm::spacepoint_collection::host& spacepoints,
5959
: static_cast<unsigned int>(-1);
6060

6161
// Create a new spacepoint for the SoA container.
62-
const std::size_t i = spacepoints.size();
63-
spacepoints.resize(i + 1);
64-
auto spacepoint = spacepoints[i];
65-
spacepoint.measurement_index() = measurement_index;
66-
spacepoint.x() = iohit.tx;
67-
spacepoint.y() = iohit.ty;
68-
spacepoint.z() = iohit.tz;
69-
spacepoint.radius_variance() = 0.f;
70-
spacepoint.z_variance() = 0.f;
62+
spacepoints.push_back(
63+
{measurement_index, {iohit.tx, iohit.ty, iohit.tz}, 0.f, 0.f});
7164
}
7265
}
7366

0 commit comments

Comments
 (0)