Skip to content

Commit eaf4dc6

Browse files
authored
Merge pull request #949 from niermann999/ref-use-track-param
ref: Use track parameter vector directly in seeding
2 parents 04bdbe8 + e69825f commit eaf4dc6

File tree

6 files changed

+33
-55
lines changed

6 files changed

+33
-55
lines changed

core/include/traccc/edm/track_parameters.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ using free_track_parameters = detray::free_track_parameters<algebra_t>;
2626
template <detray::concepts::algebra algebra_t = traccc::default_algebra>
2727
using bound_track_parameters = detray::bound_track_parameters<algebra_t>;
2828

29+
template <detray::concepts::algebra algebra_t = traccc::default_algebra>
30+
using bound_parameters_vector = detray::bound_parameters_vector<algebra_t>;
31+
2932
template <detray::concepts::algebra algebra_t = traccc::default_algebra>
3033
using free_vector = typename free_track_parameters<algebra_t>::vector_type;
3134

3235
template <detray::concepts::algebra algebra_t = traccc::default_algebra>
33-
using bound_vector = typename bound_track_parameters<algebra_t>::vector_type;
36+
using bound_vector = typename bound_parameters_vector<algebra_t>::vector_type;
3437

3538
template <detray::concepts::algebra algebra_t = traccc::default_algebra>
3639
using bound_covariance =

core/include/traccc/seeding/detail/spacepoint_formation.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ TRACCC_HOST_DEVICE inline bool is_valid_measurement(const measurement& meas);
2424
/// @param[out] sp The spacepoint to fill
2525
/// @param[in] det The tracking geometry
2626
/// @param[in] measurement The measurement to create the spacepoint out of
27+
/// @param[in] gctx The current geometry context
2728
///
2829
template <typename soa_t, typename detector_t>
29-
TRACCC_HOST_DEVICE inline void fill_pixel_spacepoint(edm::spacepoint<soa_t>& sp,
30-
const detector_t& det,
31-
const measurement& meas);
30+
TRACCC_HOST_DEVICE inline void fill_pixel_spacepoint(
31+
edm::spacepoint<soa_t>& sp, const detector_t& det, const measurement& meas,
32+
const typename detector_t::geometry_context gctx = {});
3233

3334
} // namespace traccc::details
3435

core/include/traccc/seeding/impl/spacepoint_formation.ipp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,17 @@ namespace traccc::details {
1717

1818
TRACCC_HOST_DEVICE inline bool is_valid_measurement(const measurement& meas) {
1919
// We use 2D (pixel) measurements only for spacepoint creation
20-
if (meas.meas_dim == 2u) {
21-
return true;
22-
}
23-
return false;
20+
return (meas.meas_dim == 2u);
2421
}
2522

2623
template <typename soa_t, typename detector_t>
27-
TRACCC_HOST_DEVICE inline void fill_pixel_spacepoint(edm::spacepoint<soa_t>& sp,
28-
const detector_t& det,
29-
const measurement& meas) {
24+
TRACCC_HOST_DEVICE inline void fill_pixel_spacepoint(
25+
edm::spacepoint<soa_t>& sp, const detector_t& det, const measurement& meas,
26+
const typename detector_t::geometry_context gctx) {
3027

3128
// Get the global position of this silicon pixel measurement.
3229
const detray::tracking_surface sf{det, meas.surface_link};
33-
const auto global = sf.local_to_global({}, meas.local, {});
30+
const auto global = sf.local_to_global(gctx, meas.local, {});
3431

3532
// Fill the spacepoint with the global position and the measurement.
3633
sp.x() = global[0];

core/include/traccc/seeding/track_params_estimation_helper.hpp

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,19 @@ inline TRACCC_HOST_DEVICE vector2 uv_transform(const scalar& x,
3636
/// helper functions (for both cpu and gpu) to calculate bound track parameter
3737
/// at the bottom spacepoint
3838
///
39-
/// @param measurements is the measurement collection
40-
/// @param spacepoints is the spacepoint collection
41-
/// @param seed is the input seed
42-
/// @param bfield is the magnetic field
39+
/// @param [out] params the bound track parameter vector to be filled
40+
/// @param [in] measurements is the measurement collection
41+
/// @param [in] spacepoints is the spacepoint collection
42+
/// @param [in] seed is the input seed
43+
/// @param [in] bfield is the magnetic field
4344
///
4445
template <typename T>
45-
inline TRACCC_HOST_DEVICE bound_vector<> seed_to_bound_vector(
46+
inline TRACCC_HOST_DEVICE void seed_to_bound_param_vector(
47+
bound_track_parameters<>& params,
4648
const measurement_collection_types::const_device& measurements,
4749
const edm::spacepoint_collection::const_device& spacepoints,
4850
const edm::seed<T>& seed, const vector3& bfield) {
4951

50-
bound_vector<> params = matrix::zero<bound_vector<>>();
51-
5252
const edm::spacepoint_collection::const_device::const_proxy_type spB =
5353
spacepoints.at(seed.bottom_index());
5454
const edm::spacepoint_collection::const_device::const_proxy_type spM =
@@ -70,9 +70,9 @@ inline TRACCC_HOST_DEVICE bound_vector<> seed_to_bound_vector(
7070
vector3 newXAxis = vector::cross(newYAxis, newZAxis);
7171

7272
// The center of the new frame is at the bottom space point
73-
vector3 translation = sp_global_positions[0];
73+
const vector3& translation = sp_global_positions[0];
7474

75-
transform3 trans(translation, newZAxis, newXAxis);
75+
transform3 trans(translation, newXAxis, newYAxis, newZAxis);
7676

7777
// The coordinate of the middle and top space point in the new frame
7878
const point3 local1 = trans.point_to_local(sp_global_positions[1]);
@@ -102,28 +102,25 @@ inline TRACCC_HOST_DEVICE bound_vector<> seed_to_bound_vector(
102102
transform3::rotate(trans._data, vector::normalize(transDirection));
103103

104104
// The estimated phi and theta
105-
getter::element(params, e_bound_phi, 0) = vector::phi(direction);
106-
getter::element(params, e_bound_theta, 0) = vector::theta(direction);
105+
params.set_phi(vector::phi(direction));
106+
params.set_theta(vector::theta(direction));
107107

108108
// The measured loc0 and loc1
109109
assert(spB.measurement_index_2() ==
110110
edm::spacepoint_collection::device::INVALID_MEASUREMENT_INDEX);
111111
const measurement& meas_for_spB =
112112
measurements.at(spB.measurement_index_1());
113-
getter::element(params, e_bound_loc0, 0) = meas_for_spB.local[0];
114-
getter::element(params, e_bound_loc1, 0) = meas_for_spB.local[1];
113+
params.set_surface_link(meas_for_spB.surface_link);
114+
params.set_bound_local(meas_for_spB.local);
115115

116116
// The estimated q/pt in [GeV/c]^-1 (note that the pt is the
117117
// projection of momentum on the transverse plane of the new frame)
118118
scalar qOverPt = 1.f / (R * vector::norm(bfield));
119119
// The estimated q/p in [GeV/c]^-1
120-
getter::element(params, e_bound_qoverp, 0) =
121-
qOverPt / vector::perp(vector2{1.f, invTanTheta});
120+
params.set_qop(qOverPt / vector::perp(vector2{1.f, invTanTheta}));
122121

123122
// Make sure the time is a finite value
124-
assert(std::isfinite(getter::element(params, e_bound_time, 0)));
125-
126-
return params;
123+
assert(std::isfinite(params.time()));
127124
}
128125

129126
} // namespace traccc

core/src/seeding/track_params_estimation.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,14 @@ track_params_estimation::output_type track_params_estimation::operator()(
5656

5757
// Calculate the track parameter vector.
5858
bound_track_parameters<>& track_params = result[i];
59-
track_params.set_vector(
60-
seed_to_bound_vector(measurements, spacepoints, seeds[i], bfield));
59+
seed_to_bound_param_vector(track_params, measurements, spacepoints,
60+
seeds[i], bfield);
6161

6262
// Set Covariance
6363
for (std::size_t j = 0; j < e_bound_size; ++j) {
6464
getter::element(track_params.covariance(), j, j) =
6565
stddev[j] * stddev[j];
6666
}
67-
68-
// Get geometry ID for bottom spacepoint
69-
const edm::spacepoint_collection::const_device::const_proxy_type spB =
70-
spacepoints.at(seeds[i].bottom_index());
71-
assert(spB.measurement_index_2() ==
72-
edm::spacepoint_collection::host::INVALID_MEASUREMENT_INDEX);
73-
track_params.set_surface_link(
74-
measurements.at(spB.measurement_index_1()).surface_link);
75-
TRACCC_VERBOSE(" - bound track parameters: " << track_params);
7667
}
7768

7869
// Return the result.

device/common/include/traccc/seeding/device/impl/estimate_track_params.ipp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,15 @@ inline void estimate_track_params(
4242
seeds_device.at(globalIndex);
4343

4444
// Get bound track parameter
45-
bound_track_parameters<> track_params;
46-
track_params.set_vector(seed_to_bound_vector(
47-
measurements_device, spacepoints_device, this_seed, bfield));
45+
bound_track_parameters<>& track_params = params_device.at(globalIndex);
46+
seed_to_bound_param_vector(track_params, measurements_device,
47+
spacepoints_device, this_seed, bfield);
4848

4949
// Set Covariance
5050
for (std::size_t i = 0; i < e_bound_size; i++) {
5151
getter::element(track_params.covariance(), i, i) =
5252
stddev[i] * stddev[i];
5353
}
54-
55-
// Get geometry ID for bottom spacepoint
56-
const edm::spacepoint_collection::const_device::const_proxy_type spB =
57-
spacepoints_device.at(this_seed.bottom_index());
58-
assert(spB.measurement_index_2() ==
59-
edm::spacepoint_collection::const_device::INVALID_MEASUREMENT_INDEX);
60-
track_params.set_surface_link(
61-
measurements_device.at(spB.measurement_index_1()).surface_link);
62-
63-
// Save the object into global memory.
64-
params_device.at(globalIndex) = track_params;
6554
}
6655

6756
} // namespace traccc::device

0 commit comments

Comments
 (0)