ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CombinatorialKalmanFilterError.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file CombinatorialKalmanFilterError.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2019 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
11 #include <iostream>
12 #include <string> // for string printing
13 #include <system_error> // bring in std::error_code et al
14 
15 namespace Acts {
16 // This is the custom error code enum
18  UpdateFailed = 1,
19  SmoothFailed = 2,
20  OutputConversionFailed = 3,
21  SourcelinkSelectionFailed = 4,
22  NoTracksFound = 5,
23  PropagationReachesMaxSteps = 6
24 };
25 
26 namespace detail {
27 // Define a custom error code category derived from std::error_category
28 class CombinatorialKalmanFilterErrorCategory : public std::error_category {
29  public:
30  // Return a short descriptive name for the category
31  const char* name() const noexcept final {
32  return "CombinatorialKalmanFilterError";
33  }
34  // Return what each enum means in text
35  std::string message(int c) const final {
36  switch (static_cast<CombinatorialKalmanFilterError>(c)) {
37  case CombinatorialKalmanFilterError::UpdateFailed:
38  return "Kalman update failed";
39  case CombinatorialKalmanFilterError::SmoothFailed:
40  return "Kalman smooth failed";
41  case CombinatorialKalmanFilterError::OutputConversionFailed:
42  return "Kalman output conversion failed";
43  case CombinatorialKalmanFilterError::SourcelinkSelectionFailed:
44  return "Source link selection failed";
45  case CombinatorialKalmanFilterError::NoTracksFound:
46  return "No track is found";
47  case CombinatorialKalmanFilterError::PropagationReachesMaxSteps:
48  return "Propagation reaches max steps before track finding is "
49  "finished";
50  default:
51  return "unknown";
52  }
53  }
54 };
55 } // namespace detail
56 
57 // Declare a global function returning a static instance of the custom category
61  return c;
62 }
63 
65  return {static_cast<int>(e), Acts::CombinatorialKalmanFilterErrorCategory()};
66 }
67 } // namespace Acts
68 
69 namespace std {
70 // register with STL
71 template <>
72 struct is_error_code_enum<Acts::CombinatorialKalmanFilterError>
73  : std::true_type {};
74 } // namespace std