Skip to content

Commit 7911e66

Browse files
authored
Merge pull request #950 from niermann999/test-detray-main2
Update to detray version 0.95.0
2 parents 0e32d52 + 4f24559 commit 7911e66

19 files changed

Lines changed: 197 additions & 40 deletions

File tree

core/include/traccc/finding/actors/ckf_aborter.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ struct ckf_aborter : detray::actor {
4343
abrt_state.count++;
4444
abrt_state.path_from_surface += stepping.step_size();
4545

46-
// Abort at the next sensitive surface
46+
// Stop at the next sensitive surface
4747
if (navigation.is_on_sensitive() &&
4848
abrt_state.path_from_surface > abrt_state.min_step_length) {
49-
prop_state._heartbeat &= navigation.abort();
49+
prop_state._heartbeat &= navigation.pause();
5050
abrt_state.success = true;
5151
}
5252

@@ -57,7 +57,9 @@ struct ckf_aborter : detray::actor {
5757
}
5858

5959
if (abrt_state.count > abrt_state.max_count) {
60-
prop_state._heartbeat &= navigation.abort();
60+
prop_state._heartbeat &= navigation.abort(
61+
"CKF: Maximum number of steps to reach next sensitive surface "
62+
"exceeded");
6163
}
6264
}
6365
};

core/include/traccc/finding/details/find_tracks.hpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ track_candidate_container_types::host find_tracks(
7373

7474
using actor_type = detray::actor_chain<
7575
detray::pathlimit_aborter<scalar_type>, transporter_type,
76-
interaction_register<interactor_type>, interactor_type, ckf_aborter>;
76+
interaction_register<interactor_type>, interactor_type,
77+
detray::momentum_aborter<scalar_type>, ckf_aborter>;
7778

7879
using propagator_type =
7980
detray::propagator<stepper_t, navigator_t, actor_type>;
@@ -314,12 +315,18 @@ track_candidate_container_types::host find_tracks(
314315
config.propagation.stepping.step_constraint);
315316

316317
typename detray::pathlimit_aborter<scalar_type>::state s0;
317-
typename detray::parameter_transporter<algebra_type>::state s1;
318-
typename interactor_type::state s3;
319-
typename interaction_register<interactor_type>::state s2{s3};
318+
typename interactor_type::state s2;
319+
typename interaction_register<interactor_type>::state s1{s2};
320+
typename detray::momentum_aborter<scalar_type>::state s3{};
320321
typename ckf_aborter::state s4;
322+
// Update the actor config
321323
s4.min_step_length = config.min_step_length_for_next_surface;
322324
s4.max_count = config.max_step_counts_for_next_surface;
325+
if (config.is_min_pT) {
326+
s3.min_pT(static_cast<scalar_type>(config.min_p_mag));
327+
} else {
328+
s3.min_p(static_cast<scalar_type>(config.min_p_mag));
329+
}
323330

324331
// Propagate to the next surface
325332
propagator.propagate_sync(propagation,
@@ -328,6 +335,7 @@ track_candidate_container_types::host find_tracks(
328335
// If a surface found, add the parameter for the next
329336
// step
330337
if (s4.success) {
338+
assert(propagation._navigation.is_on_sensitive());
331339
out_params.push_back(propagation._stepping.bound_params());
332340
param_to_link[step].push_back(link_id);
333341
}

core/include/traccc/finding/finding_config.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ struct finding_config {
4545
/// Propagation configuration
4646
detray::propagation::config propagation{};
4747

48+
/// Minimum momentum for reconstructed tracks
49+
bool is_min_pT = true;
50+
float min_p_mag = 100.f * traccc::unit<float>::MeV;
51+
4852
/// Particle hypothesis
4953
traccc::pdg_particle<traccc::scalar> ptc_hypothesis =
5054
traccc::muon<traccc::scalar>();
@@ -64,6 +68,20 @@ struct finding_config {
6468
/// @note This parameter affects GPU-based track finding only.
6569
unsigned int initial_links_per_seed = 100;
6670
/// @}
71+
72+
/// Set the momentum limit to @param p
73+
TRACCC_HOST_DEVICE
74+
inline void min_p(const float p) {
75+
is_min_pT = false;
76+
min_p_mag = p;
77+
}
78+
79+
/// Set the transverse momentum limit to @param p
80+
TRACCC_HOST_DEVICE
81+
inline void min_pT(const float p) {
82+
is_min_pT = true;
83+
min_p_mag = p;
84+
}
6785
};
6886

6987
} // namespace traccc

core/include/traccc/fitting/kalman_filter/kalman_actor.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ struct kalman_actor : detray::actor {
109109

110110
// If the iterator reaches the end, terminate the propagation
111111
if (actor_state.is_complete()) {
112-
propagation._heartbeat &= navigation.abort();
112+
propagation._heartbeat &= navigation.exit();
113113
return;
114114
}
115115

@@ -153,7 +153,8 @@ struct kalman_actor : detray::actor {
153153

154154
// Abort if the Kalman update fails
155155
if (res != kalman_fitter_status::SUCCESS) {
156-
propagation._heartbeat &= navigation.abort();
156+
propagation._heartbeat &=
157+
navigation.abort(fitter_debug_msg{res});
157158
return;
158159
}
159160

core/include/traccc/fitting/kalman_filter/kalman_step_aborter.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ struct kalman_step_aborter : public detray::actor {
5656
// Abort if the step count exceeds the maximum allowed
5757
if (++(abrt_state.step) > abrt_state.max_steps) {
5858
VECMEM_DEBUG_MSG(1, "Kalman fitter step aborter triggered");
59-
prop_state._heartbeat &= navigation.abort();
59+
prop_state._heartbeat &= navigation.abort(
60+
"Kalman Fitter: Maximum number of steps to reach next "
61+
"sensitive surface exceeded");
6062
}
6163
}
6264

core/include/traccc/fitting/status_codes.hpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#pragma once
99

1010
#include <cstdint>
11+
#include <string>
12+
1113
namespace traccc {
1214
enum class kalman_fitter_status : uint32_t {
1315
SUCCESS,
@@ -22,4 +24,47 @@ enum class kalman_fitter_status : uint32_t {
2224
ERROR_OTHER,
2325
MAX_STATUS
2426
};
27+
28+
/// Convert a status code into a human readable string
29+
struct fitter_debug_msg {
30+
31+
TRACCC_HOST std::string operator()() const {
32+
const std::string msg{"Kalman Fitter: "};
33+
switch (m_error_code) {
34+
using enum kalman_fitter_status;
35+
case ERROR_QOP_ZERO: {
36+
return msg + "Track qop is zero";
37+
}
38+
case ERROR_THETA_ZERO: {
39+
return msg + "Track theta is zero";
40+
}
41+
case ERROR_INVERSION: {
42+
return msg + "Failed matrix inversion";
43+
}
44+
case ERROR_SMOOTHER_CHI2_NEGATIVE: {
45+
return msg + "Negative chi2 in smoother";
46+
}
47+
case ERROR_SMOOTHER_CHI2_NOT_FINITE: {
48+
return msg + "Invalid chi2 in smoother";
49+
}
50+
case ERROR_UPDATER_CHI2_NEGATIVE: {
51+
return msg + "Negative chi2 in gain matrix update";
52+
}
53+
case ERROR_UPDATER_CHI2_NOT_FINITE: {
54+
return msg + "Invalid chi2 in gain matrix update";
55+
}
56+
case ERROR_BARCODE_SEQUENCE_OVERFLOW: {
57+
return msg + "Barcode sequence overflow in direct navigator";
58+
}
59+
case ERROR_OTHER: {
60+
return msg + "Unspecified error";
61+
}
62+
default: {
63+
return "";
64+
}
65+
}
66+
}
67+
68+
kalman_fitter_status m_error_code{kalman_fitter_status::MAX_STATUS};
69+
};
2570
} // namespace traccc

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ TRACCC_HOST_DEVICE inline void fill_pixel_spacepoint(edm::spacepoint<soa_t>& sp,
3030

3131
// Get the global position of this silicon pixel measurement.
3232
const detray::tracking_surface sf{det, meas.surface_link};
33-
const auto global = sf.bound_to_global({}, meas.local, {});
33+
const auto global = sf.local_to_global({}, meas.local, {});
3434

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

device/alpaka/include/traccc/alpaka/finding/finding_algorithm.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class finding_algorithm
5454
detray::actor_chain<detray::pathlimit_aborter<scalar_type>,
5555
detray::parameter_transporter<algebra_type>,
5656
interaction_register<interactor>, interactor,
57-
ckf_aborter>;
57+
detray::momentum_aborter<scalar_type>, ckf_aborter>;
5858

5959
using propagator_type =
6060
detray::propagator<stepper_t, navigator_t, actor_type>;

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ TRACCC_HOST_DEVICE inline void propagate_to_next_surface(
2121
const global_index_t globalIndex, const finding_config& cfg,
2222
const propagate_to_next_surface_payload<propagator_t, bfield_t>& payload) {
2323

24+
using scalar_t = propagator_t::detector_type::scalar_type;
25+
2426
if (globalIndex >= payload.n_in_params) {
2527
return;
2628
}
@@ -100,14 +102,23 @@ TRACCC_HOST_DEVICE inline void propagate_to_next_surface(
100102
typename detray::detail::tuple_element<2, actor_tuple_type>::type::state s2{
101103
s3};
102104
typename detray::detail::tuple_element<4, actor_tuple_type>::type::state s4;
103-
s4.min_step_length = cfg.min_step_length_for_next_surface;
104-
s4.max_count = cfg.max_step_counts_for_next_surface;
105+
106+
typename detray::detail::tuple_element<5, actor_tuple_type>::type::state s5;
107+
s5.min_step_length = cfg.min_step_length_for_next_surface;
108+
s5.max_count = cfg.max_step_counts_for_next_surface;
109+
if (cfg.is_min_pT) {
110+
s4.min_pT(static_cast<scalar_t>(cfg.min_p_mag));
111+
} else {
112+
s4.min_p(static_cast<scalar_t>(cfg.min_p_mag));
113+
}
105114

106115
// Propagate to the next surface
107-
propagator.propagate_sync(propagation, detray::tie(s0, s2, s3, s4));
116+
propagator.propagate_sync(propagation, detray::tie(s0, s2, s3, s4, s5));
108117

109118
// If a surface found, add the parameter for the next step
110-
if (s4.success) {
119+
if (s5.success) {
120+
assert(propagation._navigation.is_on_sensitive());
121+
111122
params[param_id] = propagation._stepping.bound_params();
112123

113124
if (payload.step == cfg.max_track_candidates_per_track - 1) {

device/cuda/include/traccc/cuda/finding/finding_algorithm.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class finding_algorithm
5656
detray::actor_chain<detray::pathlimit_aborter<scalar_type>,
5757
detray::parameter_transporter<algebra_type>,
5858
interaction_register<interactor>, interactor,
59-
ckf_aborter>;
59+
detray::momentum_aborter<scalar_type>, ckf_aborter>;
6060

6161
using propagator_type =
6262
detray::propagator<stepper_t, navigator_t, actor_type>;

0 commit comments

Comments
 (0)