Skip to content

Commit

Permalink
feat: GlobalChiSquareFitterError framework for Gx2f (#2417)
Browse files Browse the repository at this point in the history
This mostly adds the framework for the fitter specific error handling. Currently it only contains a single error case. During the next steps in development we can figure out which other errors might occur and they can be added easily.
  • Loading branch information
AJPfleger committed Sep 6, 2023
1 parent 07c292a commit 1d768b7
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Core/include/Acts/TrackFitting/GlobalChiSquareFitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "Acts/Propagator/StandardAborters.hpp"
#include "Acts/Propagator/StraightLineStepper.hpp"
#include "Acts/Propagator/detail/PointwiseMaterialInteraction.hpp"
#include "Acts/TrackFitting/GlobalChiSquareFitterError.hpp"
#include "Acts/TrackFitting/detail/KalmanUpdateHelpers.hpp"
#include "Acts/TrackFitting/detail/VoidFitterComponents.hpp"
#include "Acts/Utilities/CalibrationContext.hpp"
Expand Down Expand Up @@ -602,9 +603,8 @@ class Gx2Fitter {
aMatrix.topLeftCorner<reducedMatrixSize, reducedMatrixSize>()
.inverse();
} else if (gx2fOptions.nUpdateMax > 0) {
// TODO
std::cout << "det(a) == 0. This shouldn't happen. Implement real ERROR"
<< std::endl;
ACTS_ERROR("det(a) == 0. This should not happen ever.");
return Experimental::GlobalChiSquareFitterError::DetAIsZero;
}

// Prepare track for return
Expand Down
33 changes: 33 additions & 0 deletions Core/include/Acts/TrackFitting/GlobalChiSquareFitterError.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// This file is part of the Acts project.
//
// Copyright (C) 2023 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#pragma once

#include <system_error>
#include <type_traits>

namespace Acts {
namespace Experimental {

enum class GlobalChiSquareFitterError {
// ensure all values are non-zero
DetAIsZero = 1,
};

std::error_code make_error_code(
Acts::Experimental::GlobalChiSquareFitterError e);

} // namespace Experimental
} // namespace Acts

namespace std {
// register with STL
template <>
struct is_error_code_enum<Acts::Experimental::GlobalChiSquareFitterError>
: std::true_type {};
} // namespace std
1 change: 1 addition & 0 deletions Core/src/TrackFitting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ target_sources(
KalmanFitterError.cpp
GainMatrixUpdater.cpp
GainMatrixSmoother.cpp
GlobalChiSquareFitterError.cpp
GsfError.cpp
GsfUtils.cpp
BetheHeitlerApprox.cpp
Expand Down
41 changes: 41 additions & 0 deletions Core/src/TrackFitting/GlobalChiSquareFitterError.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// This file is part of the Acts project.
//
// Copyright (C) 2023 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#include "Acts/TrackFitting/GlobalChiSquareFitterError.hpp"

#include <string>

namespace {

class GlobalChiSquareFitterErrorCategory : public std::error_category {
public:
// Return a short descriptive name for the category.
const char* name() const noexcept final {
return "GlobalChiSquareFitterError";
}

// Return what each enum means in text.
std::string message(int c) const final {
using Acts::Experimental::GlobalChiSquareFitterError;

switch (static_cast<GlobalChiSquareFitterError>(c)) {
case GlobalChiSquareFitterError::DetAIsZero:
return "Gx2f has det(a) == 0 during update.";
default:
return "unknown";
}
}
};

} // namespace

std::error_code Acts::Experimental::make_error_code(
Acts::Experimental::GlobalChiSquareFitterError e) {
static GlobalChiSquareFitterErrorCategory c;
return {static_cast<int>(e), c};
}

0 comments on commit 1d768b7

Please sign in to comment.