Skip to content

ref: Use track parameter vector directly in seeding #949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/include/traccc/edm/track_parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ using free_track_parameters = detray::free_track_parameters<algebra_t>;
template <detray::concepts::algebra algebra_t = traccc::default_algebra>
using bound_track_parameters = detray::bound_track_parameters<algebra_t>;

template <detray::concepts::algebra algebra_t = traccc::default_algebra>
using bound_parameters_vector = detray::bound_parameters_vector<algebra_t>;

template <detray::concepts::algebra algebra_t = traccc::default_algebra>
using free_vector = typename free_track_parameters<algebra_t>::vector_type;

template <detray::concepts::algebra algebra_t = traccc::default_algebra>
using bound_vector = typename bound_track_parameters<algebra_t>::vector_type;
using bound_vector = typename bound_parameters_vector<algebra_t>::vector_type;

template <detray::concepts::algebra algebra_t = traccc::default_algebra>
using bound_covariance =
Expand Down
7 changes: 4 additions & 3 deletions core/include/traccc/seeding/detail/spacepoint_formation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ TRACCC_HOST_DEVICE inline bool is_valid_measurement(const measurement& meas);
/// @param[out] sp The spacepoint to fill
/// @param[in] det The tracking geometry
/// @param[in] measurement The measurement to create the spacepoint out of
/// @param[in] gctx The current geometry context
///
template <typename soa_t, typename detector_t>
TRACCC_HOST_DEVICE inline void fill_pixel_spacepoint(edm::spacepoint<soa_t>& sp,
const detector_t& det,
const measurement& meas);
TRACCC_HOST_DEVICE inline void fill_pixel_spacepoint(
edm::spacepoint<soa_t>& sp, const detector_t& det, const measurement& meas,
const typename detector_t::geometry_context gctx = {});

} // namespace traccc::details

Expand Down
13 changes: 5 additions & 8 deletions core/include/traccc/seeding/impl/spacepoint_formation.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@ namespace traccc::details {

TRACCC_HOST_DEVICE inline bool is_valid_measurement(const measurement& meas) {
// We use 2D (pixel) measurements only for spacepoint creation
if (meas.meas_dim == 2u) {
return true;
}
return false;
return (meas.meas_dim == 2u);
}

template <typename soa_t, typename detector_t>
TRACCC_HOST_DEVICE inline void fill_pixel_spacepoint(edm::spacepoint<soa_t>& sp,
const detector_t& det,
const measurement& meas) {
TRACCC_HOST_DEVICE inline void fill_pixel_spacepoint(
edm::spacepoint<soa_t>& sp, const detector_t& det, const measurement& meas,
const typename detector_t::geometry_context gctx) {

// Get the global position of this silicon pixel measurement.
const detray::tracking_surface sf{det, meas.surface_link};
const auto global = sf.bound_to_global({}, meas.local, {});
const auto global = sf.bound_to_global(gctx, meas.local, {});

// Fill the spacepoint with the global position and the measurement.
sp.x() = global[0];
Expand Down
33 changes: 15 additions & 18 deletions core/include/traccc/seeding/track_params_estimation_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ inline TRACCC_HOST_DEVICE vector2 uv_transform(const scalar& x,
/// helper functions (for both cpu and gpu) to calculate bound track parameter
/// at the bottom spacepoint
///
/// @param measurements is the measurement collection
/// @param spacepoints is the spacepoint collection
/// @param seed is the input seed
/// @param bfield is the magnetic field
/// @param [out] params the bound track parameter vector to be filled
/// @param [in] measurements is the measurement collection
/// @param [in] spacepoints is the spacepoint collection
/// @param [in] seed is the input seed
/// @param [in] bfield is the magnetic field
///
template <typename T>
inline TRACCC_HOST_DEVICE bound_vector<> seed_to_bound_vector(
inline TRACCC_HOST_DEVICE void seed_to_bound_param_vector(
bound_track_parameters<>& params,
const measurement_collection_types::const_device& measurements,
const edm::spacepoint_collection::const_device& spacepoints,
const edm::seed<T>& seed, const vector3& bfield) {

bound_vector<> params = matrix::zero<bound_vector<>>();

const edm::spacepoint_collection::const_device::const_proxy_type spB =
spacepoints.at(seed.bottom_index());
const edm::spacepoint_collection::const_device::const_proxy_type spM =
Expand All @@ -69,9 +69,9 @@ inline TRACCC_HOST_DEVICE bound_vector<> seed_to_bound_vector(
vector3 newXAxis = vector::cross(newYAxis, newZAxis);

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

transform3 trans(translation, newZAxis, newXAxis);
transform3 trans(translation, newXAxis, newYAxis, newZAxis);

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

// The estimated phi and theta
getter::element(params, e_bound_phi, 0) = vector::phi(direction);
getter::element(params, e_bound_theta, 0) = vector::theta(direction);
params.set_phi(vector::phi(direction));
params.set_theta(vector::theta(direction));

// The measured loc0 and loc1
const measurement& meas_for_spB = measurements.at(spB.measurement_index());
getter::element(params, e_bound_loc0, 0) = meas_for_spB.local[0];
getter::element(params, e_bound_loc1, 0) = meas_for_spB.local[1];
params.set_surface_link(meas_for_spB.surface_link);
params.set_bound_local(meas_for_spB.local);

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

// Make sure the time is a finite value
assert(std::isfinite(getter::element(params, e_bound_time, 0)));

return params;
assert(std::isfinite(params.time()));
}

} // namespace traccc
10 changes: 2 additions & 8 deletions core/src/seeding/track_params_estimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,14 @@ track_params_estimation::output_type track_params_estimation::operator()(

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

// Set Covariance
for (std::size_t j = 0; j < e_bound_size; ++j) {
getter::element(track_params.covariance(), j, j) =
stddev[j] * stddev[j];
}

// Get geometry ID for bottom spacepoint
const edm::spacepoint_collection::const_device::const_proxy_type spB =
spacepoints.at(seeds[i].bottom_index());
track_params.set_surface_link(
measurements.at(spB.measurement_index()).surface_link);
}

// Return the result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,15 @@ inline void estimate_track_params(
seeds_device.at(globalIndex);

// Get bound track parameter
bound_track_parameters<> track_params;
track_params.set_vector(seed_to_bound_vector(
measurements_device, spacepoints_device, this_seed, bfield));
bound_track_parameters<>& track_params = params_device.at(globalIndex);
seed_to_bound_param_vector(track_params, measurements_device,
spacepoints_device, this_seed, bfield);

// Set Covariance
for (std::size_t i = 0; i < e_bound_size; i++) {
getter::element(track_params.covariance(), i, i) =
stddev[i] * stddev[i];
}

// Get geometry ID for bottom spacepoint
const edm::spacepoint_collection::const_device::const_proxy_type spB =
spacepoints_device.at(this_seed.bottom_index());
track_params.set_surface_link(
measurements_device.at(spB.measurement_index()).surface_link);

// Save the object into global memory.
params_device.at(globalIndex) = track_params;
}

} // namespace traccc::device
Loading