Project
Loading...
Searching...
No Matches
Error.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
18#include "MCHBase/Error.h"
19
20#include <fmt/format.h>
21
22namespace o2::mch
23{
24
25const std::map<ErrorGroup, std::string> Error::groupNames = {
26 {ErrorGroup::Unassigned, "Unassigned"},
27 {ErrorGroup::Decoding, "Decoding"},
28 {ErrorGroup::Filtering, "Filtering"},
29 {ErrorGroup::TimeClustering, "TimeClustering"},
30 {ErrorGroup::PreClustering, "PreClustering"},
31 {ErrorGroup::Clustering, "Clustering"},
32 {ErrorGroup::Tracking, "Tracking"}};
33
34const std::map<ErrorType, std::string> Error::typeNames = {
35 {ErrorType::PreClustering_MultipleDigitsInSamePad, "MultipleDigitsInSamePad"},
37 {ErrorType::Clustering_TooManyLocalMaxima, "TooManyLocalMaxima"},
38 {ErrorType::Tracking_TooManyCandidates, "TooManyCandidates"},
39 {ErrorType::Tracking_TooLong, "TooLong"}};
40
41const std::map<ErrorType, std::string> Error::typeDescriptions = {
42 {ErrorType::PreClustering_MultipleDigitsInSamePad, "multiple digits on the same pad"},
44 {ErrorType::Clustering_TooManyLocalMaxima, "too many local maxima"},
45 {ErrorType::Tracking_TooManyCandidates, "too many track candidates"},
46 {ErrorType::Tracking_TooLong, "too long"}};
47
48const std::map<ErrorType, std::string> Error::getTypeNames(ErrorGroup group)
49{
50 std::map<ErrorType, std::string> groupTypeNames{};
51 for (const auto& typeName : typeNames) {
52 if (errorGroup(typeName.first) == group) {
53 groupTypeNames.emplace(typeName);
54 }
55 }
56 return groupTypeNames;
57}
58
59std::string Error::getGroupName() const
60{
61 const auto itName = groupNames.find(getGroup());
62 if (itName != groupNames.end()) {
63 return itName->second;
64 }
65 return "Unknown";
66}
67
68std::string Error::getTypeName() const
69{
70 const auto itName = typeNames.find(type);
71 if (itName != typeNames.end()) {
72 return itName->second;
73 }
74 return "Unknown";
75}
76
77std::string Error::getTypeDescription() const
78{
79 const auto itDescription = typeDescriptions.find(type);
80 if (itDescription != typeDescriptions.end()) {
81 return itDescription->second;
82 }
83 return "";
84}
85
86std::string Error::asString() const
87{
88 auto description = fmt::format("{} error: {}", getGroupName(), getTypeDescription());
89
90 // add extra description when relevant
91 switch (type) {
93 description += fmt::format(" (DE {} pad {})", id0, id1);
94 break;
96 description += fmt::format(" (DE {})", id0);
97 break;
98 default:
99 break;
100 }
101
102 return description + fmt::format(": seen {} time{}", count, count > 1 ? "s" : "");
103}
104
105} // namespace o2::mch
definition of the MCH processing errors
GLint GLsizei count
Definition glcorearb.h:399
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
GLboolean GLuint group
Definition glcorearb.h:3991
constexpr ErrorGroup errorGroup(ErrorType error)
Definition Error.h:66
ErrorGroup
Definition Error.h:31
@ PreClustering_MultipleDigitsInSamePad
static const std::map< ErrorType, std::string > typeNames
names of known error type
Definition Error.h:71
std::string getTypeDescription() const
Definition Error.cxx:77
uint32_t id1
additional descriptor used for certain error types
Definition Error.h:76
static const std::map< ErrorType, std::string > getTypeNames(ErrorGroup group)
Definition Error.cxx:48
std::string getGroupName() const
Definition Error.cxx:59
ErrorGroup getGroup() const
Definition Error.h:86
uint32_t id0
additional descriptor used for certain error types
Definition Error.h:75
std::string asString() const
Definition Error.cxx:86
static const std::map< ErrorType, std::string > typeDescriptions
descriptions of known error type
Definition Error.h:72
std::string getTypeName() const
Definition Error.cxx:68
static const std::map< ErrorGroup, std::string > groupNames
names of known error group
Definition Error.h:70