Skip to content

Commit 15b22b2

Browse files
committed
Huzzah
1 parent 819ddb0 commit 15b22b2

26 files changed

+829
-113
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2023-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/device/global_index.hpp"
12+
13+
// Project include(s).
14+
#include "traccc/definitions/qualifiers.hpp"
15+
#include "traccc/edm/track_candidate_container.hpp"
16+
#include "traccc/edm/track_parameters.hpp"
17+
#include "traccc/edm/track_state.hpp"
18+
#include "traccc/finding/candidate_link.hpp"
19+
#include "traccc/finding/finding_config.hpp"
20+
21+
// VecMem include(s).
22+
#include <vecmem/containers/data/jagged_vector_view.hpp>
23+
#include <vecmem/containers/data/vector_view.hpp>
24+
25+
namespace traccc::device {
26+
27+
/// (Event Data) Payload for the @c traccc::device::build_tracks function
28+
struct build_fitted_tracks_payload {
29+
/**
30+
* @brief View objects to the vector of measurements
31+
*/
32+
const measurement_collection_types::const_view measurements_view;
33+
34+
/**
35+
* @brief View object to the vector of seeds
36+
*/
37+
bound_track_parameters_collection_types::const_view seeds_view;
38+
39+
/**
40+
* @brief View object to the track parameters
41+
*/
42+
bound_track_parameters_collection_types::const_view track_param_view;
43+
44+
/**
45+
* @brief View object to the vector of candidate links
46+
*/
47+
vecmem::data::vector_view<const candidate_link> links_view;
48+
49+
/**
50+
* @brief View object to the vector of tips
51+
*/
52+
vecmem::data::vector_view<const unsigned int> tips_view;
53+
54+
/**
55+
* @brief View object to the vector of track candidates
56+
*/
57+
track_state_container_types::view track_states_view;
58+
};
59+
60+
/// Function for building full tracks from the link container:
61+
/// The full tracks are built using the link container and tip link container.
62+
/// Since every link holds an information of the link from the previous step,
63+
/// we can build a full track by iterating from a tip link backwardly.
64+
///
65+
/// @param[in] globalIndex The index of the current thread
66+
/// @param[in] cfg Track finding config object
67+
/// @param[inout] payload The function call payload
68+
///
69+
TRACCC_HOST_DEVICE inline void build_fitted_tracks(
70+
global_index_t globalIndex, const build_fitted_tracks_payload& payload);
71+
72+
} // namespace traccc::device
73+
74+
// Include the implementation.
75+
#include "./impl/build_fitted_tracks.ipp"

device/common/include/traccc/finding/device/build_tracks.hpp renamed to device/common/include/traccc/finding/device/build_unfitted_tracks.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323

2424
namespace traccc::device {
2525

26-
/// (Event Data) Payload for the @c traccc::device::build_tracks function
27-
struct build_tracks_payload {
26+
/// (Event Data) Payload for the @c traccc::device::build_unfitted_tracks
27+
/// function
28+
struct build_unfitted_tracks_payload {
2829
/**
2930
* @brief View object to the vector of measurements
3031
*/
@@ -55,10 +56,10 @@ struct build_tracks_payload {
5556
/// @param[in] cfg Track finding config object
5657
/// @param[inout] payload The function call payload
5758
///
58-
TRACCC_HOST_DEVICE inline void build_tracks(
59-
global_index_t globalIndex, const build_tracks_payload& payload);
59+
TRACCC_HOST_DEVICE inline void build_unfitted_tracks(
60+
global_index_t globalIndex, const build_unfitted_tracks_payload& payload);
6061

6162
} // namespace traccc::device
6263

6364
// Include the implementation.
64-
#include "./impl/build_tracks.ipp"
65+
#include "./impl/build_unfitted_tracks.ipp"

device/common/include/traccc/finding/device/find_tracks.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@ struct find_tracks_payload {
125125
* @brief View object to the temporary link vector
126126
*/
127127
vecmem::data::vector_view<candidate_link> tmp_links_view;
128+
129+
/**
130+
* @brief View object to the persistent track parameters, estabilishing
131+
* a direct map between links and parameters at the same index.
132+
*/
133+
bound_track_parameters_collection_types::view persistent_parameters_view;
134+
135+
/**
136+
* @brief Flag that, if true, indicates whether holes should be counted
137+
* in the length of the tip in the tip length output.
138+
*/
139+
bool count_holes = false;
128140
};
129141

130142
/// (Shared Event Data) Payload for the @c traccc::device::find_tracks function
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2023-2025 CERN for the benefit of the ACTS project
4+
*
5+
* Mozilla Public License Version 2.0
6+
*/
7+
8+
#pragma once
9+
10+
// Project include(s).
11+
#include "traccc/utils/prob.hpp"
12+
13+
namespace traccc::device {
14+
15+
TRACCC_HOST_DEVICE inline void build_fitted_tracks(
16+
const global_index_t globalIndex,
17+
const build_fitted_tracks_payload& payload) {
18+
19+
const measurement_collection_types::const_device measurements(
20+
payload.measurements_view);
21+
22+
const bound_track_parameters_collection_types::const_device track_params(
23+
payload.track_param_view);
24+
const bound_track_parameters_collection_types::const_device seeds(
25+
payload.seeds_view);
26+
27+
const vecmem::device_vector<const candidate_link> links(payload.links_view);
28+
29+
const vecmem::device_vector<const unsigned int> tips(payload.tips_view);
30+
31+
track_state_container_types::device track_states(payload.track_states_view);
32+
33+
if (globalIndex >= tips.size()) {
34+
return;
35+
}
36+
37+
const auto tip = tips.at(globalIndex);
38+
39+
auto track = track_states.at(globalIndex).items;
40+
auto header = track_states.at(globalIndex).header;
41+
42+
// Get the link corresponding to tip
43+
unsigned int link_idx = tip;
44+
auto L = links.at(link_idx);
45+
const unsigned int n_meas = measurements.size();
46+
47+
// Track summary variables
48+
scalar ndf_sum = 0.f;
49+
scalar chi2_sum = 0.f;
50+
51+
// Reversely iterate to fill the track candidates
52+
for (auto it = track.rbegin(); it != track.rend(); it++) {
53+
if (L.meas_idx >= n_meas) {
54+
it->is_hole = true;
55+
} else {
56+
*it = track_state<default_algebra>(measurements.at(L.meas_idx));
57+
it->is_hole = false;
58+
it->filtered_chi2() = L.chi2;
59+
it->filtered() = track_params.at(link_idx);
60+
61+
// Sanity check on chi2
62+
assert(L.chi2 < std::numeric_limits<traccc::scalar>::max());
63+
assert(L.chi2 >= 0.f);
64+
65+
ndf_sum +=
66+
static_cast<scalar>(measurements.at(L.meas_idx).meas_dim);
67+
chi2_sum += L.chi2;
68+
}
69+
70+
// Break the loop if the iterator is at the first candidate and fill the
71+
// seed and track quality
72+
if (it != track.rend() - 1) {
73+
link_idx = L.previous_candidate_idx;
74+
L = links.at(link_idx);
75+
}
76+
}
77+
78+
header.fit_outcome = fitter_outcome::SUCCESS;
79+
header.fit_params = seeds.at(L.seed_idx);
80+
header.trk_quality.ndf = ndf_sum - 5.f;
81+
header.trk_quality.chi2 = chi2_sum;
82+
header.trk_quality.pval =
83+
prob(header.trk_quality.chi2, header.trk_quality.ndf);
84+
header.trk_quality.n_holes = L.n_skipped;
85+
}
86+
87+
} // namespace traccc::device

device/common/include/traccc/finding/device/impl/build_tracks.ipp renamed to device/common/include/traccc/finding/device/impl/build_unfitted_tracks.ipp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212

1313
namespace traccc::device {
1414

15-
TRACCC_HOST_DEVICE inline void build_tracks(
16-
const global_index_t globalIndex, const build_tracks_payload& payload) {
15+
TRACCC_HOST_DEVICE inline void build_unfitted_tracks(
16+
const global_index_t globalIndex,
17+
const build_unfitted_tracks_payload& payload) {
1718

1819
const measurement_collection_types::const_device measurements(
1920
payload.track_candidates_view.measurements);

device/common/include/traccc/finding/device/impl/find_tracks.ipp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ TRACCC_HOST_DEVICE inline void find_tracks(
8888
vecmem::device_vector<candidate_link> tmp_links(payload.tmp_links_view);
8989
bound_track_parameters_collection_types::device tmp_params(
9090
payload.tmp_params_view);
91+
bound_track_parameters_collection_types::device persistent_params(
92+
payload.persistent_parameters_view);
9193
vecmem::device_vector<const detray::geometry::barcode> barcodes(
9294
payload.barcodes_view);
9395
vecmem::device_vector<const unsigned int> upper_bounds(
@@ -630,6 +632,10 @@ TRACCC_HOST_DEVICE inline void find_tracks(
630632
.chi2 = std::numeric_limits<traccc::scalar>::max(),
631633
.chi2_sum = prev_chi2_sum,
632634
.ndf_sum = prev_ndf_sum};
635+
if (persistent_params.capacity() > 0) {
636+
persistent_params.at(out_offset) =
637+
in_params.at(in_param_id);
638+
}
633639

634640
unsigned int param_pos = out_offset - payload.curr_links_idx;
635641

@@ -641,7 +647,12 @@ TRACCC_HOST_DEVICE inline void find_tracks(
641647

642648
if (n_cands >= cfg.min_track_candidates_per_track) {
643649
auto tip_pos = tips.push_back(prev_link_idx);
644-
tip_lengths.at(tip_pos) = n_cands;
650+
651+
if (payload.count_holes) {
652+
tip_lengths.at(tip_pos) = payload.step + 1u;
653+
} else {
654+
tip_lengths.at(tip_pos) = n_cands;
655+
}
645656
}
646657
}
647658
} else {
@@ -659,13 +670,21 @@ TRACCC_HOST_DEVICE inline void find_tracks(
659670
out_params_liveness.at(param_pos) =
660671
static_cast<unsigned int>(!last_step);
661672
links.at(out_offset) = tmp_links.at(in_offset);
673+
if (persistent_params.capacity() > 0) {
674+
persistent_params.at(out_offset) = tmp_params.at(in_offset);
675+
}
662676

663677
const unsigned int n_cands = payload.step + 1 - n_skipped;
664678

665679
if (last_step &&
666680
n_cands >= cfg.min_track_candidates_per_track) {
667681
auto tip_pos = tips.push_back(param_pos);
668-
tip_lengths.at(tip_pos) = n_cands;
682+
683+
if (payload.count_holes) {
684+
tip_lengths.at(tip_pos) = payload.step + 1u;
685+
} else {
686+
tip_lengths.at(tip_pos) = n_cands;
687+
}
669688
}
670689
}
671690
}

device/common/include/traccc/finding/device/impl/propagate_to_next_surface.ipp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,12 @@ TRACCC_HOST_DEVICE inline void propagate_to_next_surface(
109109

110110
if (n_cands >= cfg.min_track_candidates_per_track) {
111111
auto tip_pos = tips.push_back(link_idx);
112-
tip_lengths.at(tip_pos) = n_cands;
112+
113+
if (payload.count_holes) {
114+
tip_lengths.at(tip_pos) = link.step + 1;
115+
} else {
116+
tip_lengths.at(tip_pos) = n_cands;
117+
}
113118
}
114119
}
115120
}

device/common/include/traccc/finding/device/propagate_to_next_surface.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ struct propagate_to_next_surface_payload {
7979
* @brief Vector to hold the number of track states per tip
8080
*/
8181
vecmem::data::vector_view<unsigned int> tip_lengths_view;
82+
83+
/**
84+
* @brief Flag that, if true, indicates whether holes should be counted
85+
* in the length of the tip in the tip length output.
86+
*/
87+
bool count_holes = false;
8288
};
8389

8490
/// Function for propagating the kalman-updated tracks to the next surface
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 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::device {
11+
/**
12+
* @defgroup Track finding return type specifiers
13+
*
14+
* Optional parameters to track finding algorithms which instruct the
15+
* algorithm to return either unfitted tracks or fitted tracks directly.
16+
*
17+
* @{
18+
* @brief Return tracks with fitted track states.
19+
*/
20+
struct finding_return_fitted {};
21+
/*
22+
* @brief Return tracks with unfitted track states.
23+
*/
24+
struct finding_return_unfitted {};
25+
/*
26+
* @}
27+
*/
28+
} // namespace traccc::device
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/** TRACCC library, part of the ACTS project (R&D line)
2+
*
3+
* (c) 2024-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/device/global_index.hpp"
12+
#include "traccc/edm/device/sort_key.hpp"
13+
14+
// Project include(s).
15+
#include "traccc/edm/track_state.hpp"
16+
17+
namespace traccc::device {
18+
19+
/// Function used to fill key container
20+
///
21+
/// @param[in] globalIndex The index of the current thread
22+
/// @param[in] track_candidates_view The input track states
23+
/// @param[out] keys_view The key values
24+
/// @param[out] ids_view The param ids
25+
///
26+
TRACCC_HOST_DEVICE inline void fill_fitting_state_sort_keys(
27+
global_index_t globalIndex,
28+
track_state_container_types::const_view& track_states_view,
29+
vecmem::data::vector_view<device::sort_key> keys_view,
30+
vecmem::data::vector_view<unsigned int> ids_view) {
31+
const track_state_container_types::const_device track_states(
32+
track_states_view);
33+
34+
// Keys
35+
vecmem::device_vector<device::sort_key> keys_device(keys_view);
36+
37+
// Param id
38+
vecmem::device_vector<unsigned int> ids_device(ids_view);
39+
40+
if (globalIndex >= keys_device.size()) {
41+
return;
42+
}
43+
44+
// Key = The number of measurements
45+
keys_device.at(globalIndex) =
46+
static_cast<traccc::scalar>(track_states.at(globalIndex).items.size());
47+
ids_device.at(globalIndex) = globalIndex;
48+
}
49+
50+
} // namespace traccc::device

0 commit comments

Comments
 (0)