-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: GlobalChiSquareFitterError framework for Gx2f (#2417)
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
Showing
4 changed files
with
78 additions
and
3 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
33 changes: 33 additions & 0 deletions
33
Core/include/Acts/TrackFitting/GlobalChiSquareFitterError.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,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 |
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
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}; | ||
} |