Skip to content

Commit 7ff62fe

Browse files
committed
Introduced an SoA EDM for the track fit in traccc::core.
1 parent 5c0f1ea commit 7ff62fe

20 files changed

+917
-474
lines changed

core/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ traccc_add_library( traccc_core core TYPE SHARED
2424
"include/traccc/edm/particle.hpp"
2525
"include/traccc/edm/track_parameters.hpp"
2626
"include/traccc/edm/container.hpp"
27-
"include/traccc/edm/track_state.hpp"
2827
"include/traccc/edm/silicon_cell_collection.hpp"
2928
"include/traccc/edm/impl/silicon_cell_collection.ipp"
3029
"include/traccc/edm/silicon_cluster_collection.hpp"
@@ -35,6 +34,10 @@ traccc_add_library( traccc_core core TYPE SHARED
3534
"include/traccc/edm/track_candidate_collection.hpp"
3635
"include/traccc/edm/impl/track_candidate_collection.ipp"
3736
"include/traccc/edm/track_candidate_container.hpp"
37+
"include/traccc/edm/track_state_collection.hpp"
38+
"include/traccc/edm/impl/track_state_collection.ipp"
39+
"include/traccc/edm/track_fit_outcome.hpp"
40+
"include/traccc/edm/track_fit_collection.hpp"
3841
# Magnetic field description.
3942
"include/traccc/bfield/magnetic_field_types.hpp"
4043
"include/traccc/bfield/magnetic_field.hpp"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2022-2025 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
#pragma once
9+
10+
namespace traccc::edm {
11+
12+
template <typename BASE>
13+
TRACCC_HOST_DEVICE void track_fit<BASE>::reset_quality() {
14+
15+
ndf() = {};
16+
chi2() = {};
17+
pval() = {};
18+
nholes() = {};
19+
}
20+
21+
} // namespace traccc::edm
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2022-2025 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
#pragma once
9+
10+
namespace traccc::edm {
11+
12+
template <typename BASE>
13+
TRACCC_HOST_DEVICE bool track_state<BASE>::is_hole() const {
14+
15+
return (state() & IS_HOLE_MASK);
16+
}
17+
18+
template <typename BASE>
19+
TRACCC_HOST_DEVICE void track_state<BASE>::set_hole(bool value) {
20+
21+
if (value) {
22+
state() |= IS_HOLE_MASK;
23+
} else {
24+
state() &= ~IS_HOLE_MASK;
25+
}
26+
}
27+
28+
template <typename BASE>
29+
TRACCC_HOST_DEVICE bool track_state<BASE>::is_smoothed() const {
30+
31+
return (state() & IS_SMOOTHED_MASK);
32+
}
33+
34+
template <typename BASE>
35+
TRACCC_HOST_DEVICE void track_state<BASE>::set_smoothed(bool value) {
36+
37+
if (value) {
38+
state() |= IS_SMOOTHED_MASK;
39+
} else {
40+
state() &= ~IS_SMOOTHED_MASK;
41+
}
42+
}
43+
44+
template <typename BASE>
45+
template <detray::concepts::algebra ALGEBRA, std::integral size_type,
46+
size_type D>
47+
TRACCC_HOST_DEVICE void track_state<BASE>::get_measurement_local(
48+
const measurement_collection_types::const_device& measurements,
49+
detray::dmatrix<ALGEBRA, D, 1>& pos) const {
50+
51+
static_assert(((D == 1u) || (D == 2u)),
52+
"The measurement dimension must be 1 or 2");
53+
54+
assert((measurements.at(measurement_index()).subs.get_indices()[0] ==
55+
e_bound_loc0) ||
56+
(measurements.at(measurement_index()).subs.get_indices()[0] ==
57+
e_bound_loc1));
58+
59+
const point2& local = measurements.at(measurement_index()).local;
60+
61+
switch (measurements.at(measurement_index()).subs.get_indices()[0]) {
62+
case e_bound_loc0:
63+
getter::element(pos, 0, 0) = local[0];
64+
if constexpr (D == 2u) {
65+
getter::element(pos, 1, 0) = local[1];
66+
}
67+
break;
68+
case e_bound_loc1:
69+
getter::element(pos, 0, 0) = local[1];
70+
if constexpr (D == 2u) {
71+
getter::element(pos, 1, 0) = local[0];
72+
}
73+
break;
74+
default:
75+
#if defined(__GNUC__)
76+
__builtin_unreachable();
77+
#endif
78+
}
79+
}
80+
81+
template <typename BASE>
82+
template <detray::concepts::algebra ALGEBRA, std::integral size_type,
83+
size_type D>
84+
TRACCC_HOST_DEVICE void track_state<BASE>::get_measurement_covariance(
85+
const measurement_collection_types::const_device& measurements,
86+
detray::dmatrix<ALGEBRA, D, D>& cov) const {
87+
88+
static_assert(((D == 1u) || (D == 2u)),
89+
"The measurement dimension must be 1 or 2");
90+
91+
assert((measurements.at(measurement_index()).subs.get_indices()[0] ==
92+
e_bound_loc0) ||
93+
(measurements.at(measurement_index()).subs.get_indices()[0] ==
94+
e_bound_loc1));
95+
96+
const variance2& variance = measurements.at(measurement_index()).variance;
97+
98+
switch (measurements.at(measurement_index()).subs.get_indices()[0]) {
99+
case e_bound_loc0:
100+
getter::element(cov, 0, 0) = variance[0];
101+
if constexpr (D == 2u) {
102+
getter::element(cov, 0, 1) = 0.f;
103+
getter::element(cov, 1, 0) = 0.f;
104+
getter::element(cov, 1, 1) = variance[1];
105+
}
106+
break;
107+
case e_bound_loc1:
108+
getter::element(cov, 0, 0) = variance[1];
109+
if constexpr (D == 2u) {
110+
getter::element(cov, 0, 1) = 0.f;
111+
getter::element(cov, 1, 0) = 0.f;
112+
getter::element(cov, 1, 1) = variance[0];
113+
}
114+
break;
115+
default:
116+
#if defined(__GNUC__)
117+
__builtin_unreachable();
118+
#endif
119+
}
120+
}
121+
122+
} // namespace traccc::edm
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2022-2025 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
#pragma once
9+
10+
// Local include(s).
11+
#include "traccc/definitions/qualifiers.hpp"
12+
#include "traccc/edm/track_fit_outcome.hpp"
13+
#include "traccc/edm/track_parameters.hpp"
14+
15+
// Detray include(s).
16+
#include <detray/definitions/algebra.hpp>
17+
18+
// VecMem include(s).
19+
#include <vecmem/edm/container.hpp>
20+
21+
namespace traccc::edm {
22+
23+
/// Interface for the @c traccc::edm::track_fit_collection type.
24+
///
25+
/// It provides the API that users would interact with, while using the
26+
/// columns/arrays of the SoA containers, or the variables of the AoS proxies
27+
/// created on top of the SoA containers.
28+
///
29+
template <typename BASE>
30+
class track_fit : public BASE {
31+
32+
public:
33+
/// @name Functions inherited from the base class
34+
/// @{
35+
36+
/// Inherit the base class's constructor(s)
37+
using BASE::BASE;
38+
/// Inherit the base class's assignment operator(s).
39+
using BASE::operator=;
40+
41+
/// @}
42+
43+
/// @name Track Candidate Information
44+
/// @{
45+
46+
/// The outcome of the track fit (non-const)
47+
///
48+
/// @return A (non-const) vector of @c traccc::track_fit_outcome
49+
///
50+
TRACCC_HOST_DEVICE
51+
auto& fit_outcome() { return BASE::template get<0>(); }
52+
/// The outcome of the track fit (non-const)
53+
///
54+
/// @return A (const) vector of @c traccc::track_fit_outcome
55+
///
56+
TRACCC_HOST_DEVICE
57+
const auto& fit_outcome() const { return BASE::template get<0>(); }
58+
59+
/// The parameters of the track (non-const)
60+
///
61+
/// @return A (non-const) vector of bound track parameters
62+
///
63+
TRACCC_HOST_DEVICE
64+
auto& params() { return BASE::template get<1>(); }
65+
/// The parameters of the track (const)
66+
///
67+
/// @return A (const) vector of bound track parameters
68+
///
69+
TRACCC_HOST_DEVICE
70+
const auto& params() const { return BASE::template get<1>(); }
71+
72+
/// The number of degrees of freedom of the track fit (non-const)
73+
///
74+
/// @return A (non-const) vector of scalar values
75+
///
76+
TRACCC_HOST_DEVICE
77+
auto& ndf() { return BASE::template get<2>(); }
78+
/// The number of degrees of freedom of the track fit (const)
79+
///
80+
/// @return A (const) vector of scalar values
81+
///
82+
TRACCC_HOST_DEVICE
83+
const auto& ndf() const { return BASE::template get<2>(); }
84+
85+
/// The chi square of the track fit (non-const)
86+
///
87+
/// @return A (non-const) vector of scalar values
88+
///
89+
TRACCC_HOST_DEVICE
90+
auto& chi2() { return BASE::template get<3>(); }
91+
/// The chi square of the track fit (const)
92+
///
93+
/// @return A (const) vector of scalar values
94+
///
95+
TRACCC_HOST_DEVICE
96+
const auto& chi2() const { return BASE::template get<3>(); }
97+
98+
/// The p-value of the track fit (non-const)
99+
///
100+
/// @return A (non-const) vector of scalar values
101+
///
102+
TRACCC_HOST_DEVICE
103+
auto& pval() { return BASE::template get<4>(); }
104+
/// The p-value of the track fit (const)
105+
///
106+
/// @return A (const) vector of scalar values
107+
///
108+
TRACCC_HOST_DEVICE
109+
const auto& pval() const { return BASE::template get<4>(); }
110+
111+
/// The number of holes in the track pattern (non-const)
112+
///
113+
/// @return A (non-const) vector of unsigned integers
114+
///
115+
TRACCC_HOST_DEVICE
116+
auto& nholes() { return BASE::template get<5>(); }
117+
/// The number of holes in the track pattern (const)
118+
///
119+
/// @return A (const) vector of unsigned integers
120+
///
121+
TRACCC_HOST_DEVICE
122+
const auto& nholes() const { return BASE::template get<5>(); }
123+
124+
/// The indices of the track states associated to the track fit (non-const)
125+
///
126+
/// @return A (non-const) jagged vector of unsigned integers
127+
///
128+
TRACCC_HOST_DEVICE
129+
auto& state_indices() { return BASE::template get<6>(); }
130+
/// The indices of the track states associated to the track fit (const)
131+
///
132+
/// @return A (const) jagged vector of unsigned integers
133+
///
134+
TRACCC_HOST_DEVICE
135+
const auto& state_indices() const { return BASE::template get<6>(); }
136+
137+
/// @}
138+
139+
/// @name Utility functions
140+
/// @{
141+
142+
/// Reset the fit quality variables
143+
TRACCC_HOST_DEVICE
144+
void reset_quality();
145+
146+
/// @}
147+
148+
}; // class track_fit
149+
150+
/// SoA container describing the fitted tracks
151+
///
152+
/// @tparam ALGEBRA The algebra type used to describe the tracks
153+
///
154+
template <detray::concepts::algebra ALGEBRA>
155+
using track_fit_collection = vecmem::edm::container<
156+
track_fit,
157+
// fit_outcome
158+
vecmem::edm::type::vector<track_fit_outcome>,
159+
// params
160+
vecmem::edm::type::vector<bound_track_parameters<ALGEBRA>>,
161+
// ndf
162+
vecmem::edm::type::vector<detray::dscalar<ALGEBRA>>,
163+
// chi2
164+
vecmem::edm::type::vector<detray::dscalar<ALGEBRA>>,
165+
// pval
166+
vecmem::edm::type::vector<detray::dscalar<ALGEBRA>>,
167+
// nholes
168+
vecmem::edm::type::vector<unsigned int>,
169+
// state_indices
170+
vecmem::edm::type::jagged_vector<unsigned int>>;
171+
172+
} // namespace traccc::edm
173+
174+
// Include the implementation.
175+
#include "traccc/edm/impl/track_fit_collection.ipp"

0 commit comments

Comments
 (0)