Skip to content
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

Fix edge case detection in CPU track finding #884

Merged
merged 2 commits into from
Feb 22, 2025
Merged
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
33 changes: 20 additions & 13 deletions core/include/traccc/finding/details/find_tracks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,11 @@ track_candidate_container_types::host find_tracks(
out_params.reserve(n_in_params);

// Previous step ID
const unsigned int previous_step =
(step == 0u) ? std::numeric_limits<int>::max() : step - 1u;
const candidate_link::link_index_type::first_type previous_step =
(step == 0u)
? std::numeric_limits<
candidate_link::link_index_type::first_type>::max()
: step - 1u;

std::fill(n_trks_per_seed.begin(), n_trks_per_seed.end(), 0u);

Expand Down Expand Up @@ -284,7 +287,7 @@ track_candidate_container_types::host find_tracks(
const std::size_t n_links = links[step].size();
for (unsigned int link_id = 0; link_id < n_links; link_id++) {

const unsigned int seed_idx = links[step][link_id].seed_idx;
const unsigned int seed_idx = links.at(step).at(link_id).seed_idx;
n_trks_per_seed[seed_idx]++;

if (n_trks_per_seed[seed_idx] > config.max_num_branches_per_seed) {
Expand All @@ -293,7 +296,7 @@ track_candidate_container_types::host find_tracks(

// If number of skips is larger than the maximum value, consider the
// link to be a tip
if (links[step][link_id].n_skipped >
if (links.at(step).at(link_id).n_skipped >
config.max_num_skipping_per_cand) {
tips.push_back({step, link_id});
continue;
Expand Down Expand Up @@ -360,7 +363,7 @@ track_candidate_container_types::host find_tracks(

for (const auto& tip : tips) {
// Get the link corresponding to tip
auto L = links[tip.first][tip.second];
auto L = links.at(tip.first).at(tip.second);

// Count the number of skipped steps
unsigned int n_skipped{0u};
Expand All @@ -375,8 +378,8 @@ track_candidate_container_types::host find_tracks(
}

const unsigned long link_pos =
param_to_link[L.previous.first][L.previous.second];
L = links[L.previous.first][link_pos];
param_to_link.at(L.previous.first).at(L.previous.second);
L = links.at(L.previous.first).at(link_pos);
}

const unsigned int n_cands = tip.first + 1 - n_skipped;
Expand All @@ -388,7 +391,7 @@ track_candidate_container_types::host find_tracks(
}

// Retrieve tip
L = links[tip.first][tip.second];
L = links.at(tip.first).at(tip.second);

vecmem::vector<track_candidate> cands_per_track;
cands_per_track.resize(n_cands);
Expand All @@ -401,11 +404,15 @@ track_candidate_container_types::host find_tracks(
for (auto it = cands_per_track.rbegin(); it != cands_per_track.rend();
it++) {

while (L.meas_idx >= n_meas) {
while (
L.meas_idx >= n_meas &&
L.previous.first !=
std::numeric_limits<
candidate_link::link_index_type::first_type>::max()) {
const auto link_pos =
param_to_link[L.previous.first][L.previous.second];
param_to_link.at(L.previous.first).at(L.previous.second);

L = links[L.previous.first][link_pos];
L = links.at(L.previous.first).at(link_pos);
}

// Break if the measurement is still invalid
Expand Down Expand Up @@ -436,9 +443,9 @@ track_candidate_container_types::host find_tracks(
cands_per_track);
} else {
const auto l_pos =
param_to_link[L.previous.first][L.previous.second];
param_to_link.at(L.previous.first).at(L.previous.second);

L = links[L.previous.first][l_pos];
L = links.at(L.previous.first).at(l_pos);
}
}
}
Expand Down
Loading