1010// Project include(s)
1111#include " traccc/definitions/primitives.hpp"
1212#include " traccc/definitions/qualifiers.hpp"
13+ #include " traccc/utils/logging.hpp"
1314
1415// detray include(s)
16+ #include < detray/definitions/indexing.hpp>
1517#include < detray/propagator/base_actor.hpp>
1618
1719// System include(s)
@@ -24,37 +26,55 @@ struct ckf_aborter : detray::actor {
2426 struct state {
2527 // minimal step length to prevent from staying on the same surface
2628 scalar min_step_length = 0 .5f ;
29+
2730 // / Maximum step counts that track can make to reach the next surface
28- unsigned int max_count = 100 ;
31+ unsigned int max_count = 100u ;
32+ unsigned int count = 0u ;
2933
30- bool success = false ;
31- unsigned int count = 0 ;
34+ // / Previous sensitive surface index
35+ detray::dindex prev_surface_index{detray::dindex_invalid};
36+ // / Current sensitive surface index
37+ detray::dindex surface_index{detray::dindex_invalid};
3238
33- scalar path_from_surface{0 .f };
39+ // / Whether a surface was found
40+ bool success = false ;
3441 };
3542
3643 template <typename propagator_state_t >
3744 TRACCC_HOST_DEVICE void operator ()(state &abrt_state,
3845 propagator_state_t &prop_state) const {
3946
4047 auto &navigation = prop_state._navigation ;
41- const auto &stepping = prop_state._stepping ;
4248
4349 abrt_state.count ++;
44- abrt_state.path_from_surface += stepping.step_size ();
4550
46- // Stop at the next sensitive surface
47- if (navigation.is_on_sensitive () &&
48- abrt_state.path_from_surface > abrt_state.min_step_length ) {
49- prop_state._heartbeat &= navigation.pause ();
50- abrt_state.success = navigation.is_alive ();
51- }
51+ TRACCC_VERBOSE_HOST_DEVICE (" Checking CKF aborter" );
52+ TRACCC_DEBUG_HOST_DEVICE (" => second last sensitive: %d" ,
53+ abrt_state.prev_surface_index );
54+ TRACCC_DEBUG_HOST_DEVICE (" => last sensitive: %d" ,
55+ abrt_state.surface_index );
5256
53- // Reset path from surface
54- if (navigation.is_on_sensitive ()) {
55- abrt_state.path_from_surface = 0 .f ;
57+ // Is this a valid sensitive surface to run the CKF on?
58+ const detray::dindex sf_idx{navigation.barcode ().index ()};
59+ if (!navigation.is_on_sensitive () ||
60+ (abrt_state.surface_index == sf_idx) ||
61+ (abrt_state.prev_surface_index == sf_idx)) {
62+ return ;
5663 }
5764
65+ // Update the visited sensitive surfaces and pause the propagation
66+ abrt_state.prev_surface_index = abrt_state.surface_index ;
67+ abrt_state.surface_index = sf_idx;
68+
69+ TRACCC_VERBOSE_HOST_DEVICE (" Found sensitive surface: %d" ,
70+ abrt_state.surface_index );
71+
72+ prop_state._heartbeat &= navigation.pause ();
73+ abrt_state.success = true ;
74+
75+ assert (abrt_state.surface_index <
76+ navigation.detector ().surfaces ().size ());
77+
5878 if (abrt_state.count > abrt_state.max_count ) {
5979 prop_state._heartbeat &= navigation.abort (
6080 " CKF: Maximum number of steps to reach next sensitive surface "
0 commit comments