Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:10:43

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include <iostream>
0012 #include <string>        // for string printing
0013 #include <system_error>  // bring in std::error_code et al
0014 
0015 namespace ActsAlignment {
0016 // This is the custom error code enum
0017 enum class AlignmentError {
0018   NoAlignmentDofOnTrack = 1,
0019   AlignmentParametersUpdateFailure = 2,
0020   ConvergeFailure = 3
0021 };
0022 
0023 namespace detail {
0024 // Define a custom error code category derived from std::error_category
0025 class AlignmentErrorCategory : public std::error_category {
0026  public:
0027   // Return a short descriptive name for the category
0028   const char* name() const noexcept final { return "AlignmentError"; }
0029   // Return what each enum means in text
0030   std::string message(int c) const final {
0031     switch (static_cast<AlignmentError>(c)) {
0032       case AlignmentError::NoAlignmentDofOnTrack:
0033         return "No alignment parameters on the track";
0034       case AlignmentError::AlignmentParametersUpdateFailure:
0035         return "Update to alignment parameters failure";
0036       case AlignmentError::ConvergeFailure:
0037         return "The alignment is not converged";
0038       default:
0039         return "unknown";
0040     }
0041   }
0042 };
0043 }  // namespace detail
0044 
0045 // Declare a global function returning a static instance of the custom category
0046 extern inline const detail::AlignmentErrorCategory& AlignmentErrorCategory() {
0047   static detail::AlignmentErrorCategory c;
0048   return c;
0049 }
0050 
0051 inline std::error_code make_error_code(ActsAlignment::AlignmentError e) {
0052   return {static_cast<int>(e), ActsAlignment::AlignmentErrorCategory()};
0053 }
0054 }  // namespace ActsAlignment
0055 
0056 namespace std {
0057 // register with STL
0058 template <>
0059 struct is_error_code_enum<ActsAlignment::AlignmentError> : std::true_type {};
0060 }  // namespace std