Skip to content

Commit

Permalink
fix: protect TrackSelector against eta=nan (#3785)
Browse files Browse the repository at this point in the history
Protect against η=`nan` in `Acts::TrackSelector::isValidTrack()`, which would `throw std::invalid_argument{"Eta is outside the abs eta bin edges"}` exception. This can come about if somehow the track θ<0 or θ>π. We should try to prevent these out-of-range values, but having them shouldn't raise an exception.

Co-authored-by: Paul Gessinger <1058585+paulgessinger@users.noreply.github.com>
  • Loading branch information
timadye and paulgessinger authored Oct 30, 2024
1 parent 0b8e768 commit 6797a56
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ class CombinatorialKalmanFilter {
measurementSelector(trackStateCandidates, isOutlier, logger);
if (!selectorResult.ok()) {
ACTS_ERROR("Selection of calibrated measurements failed: "
<< selectorResult.error());
<< selectorResult.error().message());
resultTrackStateList =
ResultTrackStateList::failure(selectorResult.error());
} else {
Expand Down
5 changes: 3 additions & 2 deletions Core/include/Acts/TrackFinding/TrackSelector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,9 @@ bool TrackSelector::isValidTrack(const track_proxy_t& track) const {

const Config* cutsPtr{nullptr};
if (!m_isUnbinned) {
if (absEta() < m_cfg.absEtaEdges.front() ||
_absEta >= m_cfg.absEtaEdges.back()) {
// return false if |eta| is outside its range, or nan.
if (!(absEta() >= m_cfg.absEtaEdges.front() &&
_absEta < m_cfg.absEtaEdges.back())) {
return false;
}
cutsPtr = &m_cfg.getCuts(_eta);
Expand Down
5 changes: 5 additions & 0 deletions Core/src/TrackFinding/MeasurementSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ MeasurementSelector::MeasurementSelector(const MeasurementSelectorCuts& cuts)
: MeasurementSelector({{GeometryIdentifier(), cuts}}) {}

MeasurementSelector::MeasurementSelector(const Config& config) {
if (config.empty()) {
throw std::invalid_argument(
"MeasurementSelector: Configuration must not be empty");
}

std::vector<InternalConfig::InputElement> tmp;
tmp.reserve(config.size());
for (std::size_t i = 0; i < config.size(); ++i) {
Expand Down

0 comments on commit 6797a56

Please sign in to comment.