Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AlignmentError.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AlignmentError.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 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 ActsAlignment {
16 // This is the custom error code enum
17 enum class AlignmentError {
18  NoAlignmentDofOnTrack = 1,
19  AlignmentParametersUpdateFailure = 2,
20  ConvergeFailure = 3
21 };
22 
23 namespace detail {
24 // Define a custom error code category derived from std::error_category
25 class AlignmentErrorCategory : public std::error_category {
26  public:
27  // Return a short descriptive name for the category
28  const char* name() const noexcept final { return "AlignmentError"; }
29  // Return what each enum means in text
30  std::string message(int c) const final {
31  switch (static_cast<AlignmentError>(c)) {
32  case AlignmentError::NoAlignmentDofOnTrack:
33  return "No alignment parameters on the track";
34  case AlignmentError::AlignmentParametersUpdateFailure:
35  return "Update to alignment parameters failure";
36  case AlignmentError::ConvergeFailure:
37  return "The alignment is not converged";
38  default:
39  return "unknown";
40  }
41  }
42 };
43 } // namespace detail
44 
45 // Declare a global function returning a static instance of the custom category
48  return c;
49 }
50 
52  return {static_cast<int>(e), ActsAlignment::AlignmentErrorCategory()};
53 }
54 } // namespace ActsAlignment
55 
56 namespace std {
57 // register with STL
58 template <>
59 struct is_error_code_enum<ActsAlignment::AlignmentError> : std::true_type {};
60 } // namespace std