-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a "step count aborter" to the fitting.
To prevent the track fitting from going into an endless loop, this simple failsafe will abort the propagation of a track if it cannot find the next detector surface in a maximal number of steps.
- Loading branch information
Showing
3 changed files
with
70 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
core/include/traccc/fitting/kalman_filter/kalman_step_aborter.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** TRACCC library, part of the ACTS project (R&D line) | ||
* | ||
* (c) 2024 CERN for the benefit of the ACTS project | ||
* | ||
* Mozilla Public License Version 2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
// Project include(s). | ||
#include "traccc/definitions/qualifiers.hpp" | ||
|
||
// Detray include(s). | ||
#include "detray/propagator/base_actor.hpp" | ||
|
||
// VecMem include(s). | ||
#include <vecmem/utils/debug.hpp> | ||
|
||
namespace traccc { | ||
|
||
/// Aborter making sure that propagation would not exceed a certain step count | ||
/// | ||
/// It is used mostly as a failsafe during the fitting stage. As long as | ||
/// everything works well, this aborter should never trigger. It is here to | ||
/// serve as a failsafe in case of a bug in the track finding / fitting | ||
/// algorithm. | ||
/// | ||
struct kalman_step_aborter : public detray::actor { | ||
|
||
/// The state of the aborter | ||
struct state { | ||
/// Maximum step count that a track can take to reach the next surface | ||
unsigned int max_steps = 100u; | ||
/// The current step count | ||
unsigned int step = 0u; | ||
}; | ||
|
||
/// The operator to be called by the propagator | ||
/// | ||
/// @tparam propagator_state_t The type of the propagator state | ||
/// @param abrt_state The state of the aborter | ||
/// @param prop_state The state of the propagator | ||
/// | ||
template <typename propagator_state_t> | ||
TRACCC_HOST_DEVICE void operator()(state& abrt_state, | ||
propagator_state_t& prop_state) const { | ||
|
||
// Convenience reference to the navigation state. | ||
auto& navigation = prop_state._navigation; | ||
|
||
// Reset the step count if the track is on a sensitive surface. | ||
if (navigation.is_on_sensitive()) { | ||
abrt_state.step = 0u; | ||
} | ||
|
||
// Abort if the step count exceeds the maximum allowed | ||
if (++(abrt_state.step) > abrt_state.max_steps) { | ||
VECMEM_DEBUG_MSG(1, "Kalman fitter step aborter triggered"); | ||
prop_state._heartbeat &= navigation.abort(); | ||
} | ||
} | ||
|
||
}; // struct kalman_step_aborter | ||
|
||
} // namespace traccc |