ATLAS Offline Software
Enums.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include <string>
7 #include <sstream>
8 #include <iostream>
9 
10 using namespace HLT;
11 const std::string ActionNames [4] = {"CONTINUE", "ABORT_CHAIN", "ABORT_EVENT", "ABORT_JOB"};
12 
13 const std::string& strAction(const Action::Code code) {
14  return ActionNames[code & 0x3];
15 }
16 
17 Action::Code getActionFromString(const std::string& str) {
18  if (str == "CONTINUE") return Action::CONTINUE;
19  else if (str == "ABORT_CHAIN") return Action::ABORT_CHAIN;
20  else if (str == "ABORT_EVENT") return Action::ABORT_EVENT;
21  else if (str == "ABORT_JOB") return Action::ABORT_JOB;
22  return Action::UNSPECIFIED_;
23 }
24 
25 
26 namespace HLTEnums {
27  const std::string ReasonNames [16] = {"UNKNOWN", "MISSING_FEATURE",
28  "GAUDI_EXCEPTION", "EFORMAT_EXCEPTION",
29  "STD_EXCEPTION", "UNKNOWN_EXCEPTION",
30  "NAV_ERROR",
31  "MISSING_ROD", "CORRUPTED_ROD", "TIMEOUT",
32  "BAD_JOB_SETUP",
33  "USERDEF_1", "USERDEF_2", "USERDEF_3", "USERDEF_4",
34  "LAST_" };
35 }
36 
37 const std::string strReason(const Reason::Code code) {
38  return HLTEnums::ReasonNames[code & 0xf];
39 }
40 
41 Reason::Code getReasonFromString(const std::string& str) {
42  bool found = false;
43  int i=0;
44  for ( i = 0; i < HLT::Reason::LAST_; ++i ) {
45  if (str == HLTEnums::ReasonNames[i]) {
46  found = true;
47  break;
48  }
49  }
50  if ( ! found )
51  return Reason::UNSPECIFIED_;
52  return Reason::Code(i);
53 }
54 
55 
56 namespace HLTEnums {
57  const std::string SteeringInternalReasonNames [] = { "UNKNOWN",
58  "NO_LVL1_ITEMS",
59  "NO_LVL2_CHAINS",
60  "NO_LVL1_RESULT",
61  "WRONG_HLT_RESULT",
62  "NO_HLT_RESULT",
63  "ALGO_ERROR",
64  "TIMEOUT",
65  "BUSY",
66  "BAD_JOB_SETUP",
67  "MISSING_CALO_ROI",
68  "MISSING_MUON_ROI",
69  "MISSING_OTHER_ROI",
70  "LAST_"};
71 }
72 
73 
75  bool found = false;
76  unsigned int i=0;
77 
78  for ( i = 0; i < HLT::SteeringInternalReason::LAST_; ++i ) {
80  found = true;
81  break;
82  }
83  }
84  if ( ! found )
87 }
88 
89 
90 
91 
93  if ( unsigned(code) < HLT::SteeringInternalReason::LAST_ )
95  return "UNSPECIFIED_";
96 }
97 
98 
99 std::string HLT::strErrorCode(const ErrorCode code) {
100  return ""+strAction(code.action())
101  + " " + strSteeringInternalReason(code.steeringInternalReason())
102  + " " + strReason(code.reason()) ;
103 }
104 
105 int HLT::getErrorCodePosFromStr(const std::string& ec) {
106  std::istringstream ss(ec);
107 
108  std::string actionStr;
109  std::string reasonStr;
110  std::string steeringStr;
111 
112  // parse input
113  ss >> actionStr >> steeringStr >> reasonStr;
114 
115 
116  Action::Code actionCode = getActionFromString(actionStr);
117 
118  if ( actionCode == Action::UNSPECIFIED_ )
119  return -1;
120 
121  Reason::Code reasonCode = getReasonFromString(reasonStr);
122  if ( reasonCode == Reason::UNSPECIFIED_ )
123  return -1;
124 
125 
127  if ( steeringCode == SteeringInternalReason::UNSPECIFIED_ )
128  return -1;
129 
130  return ErrorCode(actionCode, reasonCode, steeringCode );
131 }
132 
133 
134 std::string HLT::ErrorCode::str() {
135  return strErrorCode(*this);
136 }
HLT::Reason::Code
Code
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/Enums.h:26
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
strAction
const std::string & strAction(const Action::Code code)
Definition: Enums.cxx:13
HLT::Action::ABORT_EVENT
@ ABORT_EVENT
if things went wrong severely, event corruption suspected
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/Enums.h:18
HLT::ErrorCode
The definition of error codes in HLT. This is a class (note; before was simple enum) to enable safer ...
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/Enums.h:80
HLT::Action::ABORT_JOB
@ ABORT_JOB
if things go really wrong, i.e.
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/Enums.h:19
HLT::SteeringInternalReason::Code
Code
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/Enums.h:52
Enums.h
strReason
const std::string strReason(const Reason::Code code)
Definition: Enums.cxx:37
HLT::ErrorCode::str
std::string str()
Definition: Enums.cxx:134
HLT::Reason::UNSPECIFIED_
@ UNSPECIFIED_
do not use
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/Enums.h:44
HLT::Action::UNSPECIFIED_
@ UNSPECIFIED_
do not use
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/Enums.h:20
HLT::strErrorCode
std::string strErrorCode(const ErrorCode code)
Definition: Enums.cxx:99
HTXS::ErrorCode
ErrorCode
Error code: whether the classification was successful or failed.
Definition: HiggsTemplateCrossSectionsDefs.h:12
HLTEnums::ReasonNames
const std::string ReasonNames[16]
Definition: Enums.cxx:27
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
lumiFormat.i
int i
Definition: lumiFormat.py:92
getActionFromString
Action::Code getActionFromString(const std::string &str)
Definition: Enums.cxx:17
HLT::SteeringInternalReason::LAST_
@ LAST_
there is basically no restriction on size since these errors are not saved per chain so do not need t...
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/Enums.h:66
HLT::getErrorCodePosFromStr
int getErrorCodePosFromStr(const std::string &ec)
Definition: Enums.cxx:105
HLT::Action::Code
Code
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/Enums.h:15
strSteeringInternalReason
const std::string strSteeringInternalReason(const SteeringInternalReason::Code code)
Definition: Enums.cxx:92
HLT::Action::ABORT_CHAIN
@ ABORT_CHAIN
if things went wrong but it is not severe, other unrelated chains will continue
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/Enums.h:17
pmontree.code
code
Definition: pmontree.py:443
HLT::Action::CONTINUE
@ CONTINUE
if all is OK the processing should be continued
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/Enums.h:16
HLT::Reason::LAST_
@ LAST_
and can't be higher because of serialization in the chain
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/Enums.h:43
CondAlgsOpts.found
int found
Definition: CondAlgsOpts.py:101
getSteeringInternalReasonFromString
SteeringInternalReason::Code getSteeringInternalReasonFromString(const std::string &str)
Definition: Enums.cxx:74
getReasonFromString
Reason::Code getReasonFromString(const std::string &str)
Definition: Enums.cxx:41
str
Definition: BTagTrackIpAccessor.cxx:11
HLTEnums::SteeringInternalReasonNames
const std::string SteeringInternalReasonNames[]
Definition: Enums.cxx:57
HLT::SteeringInternalReason::UNSPECIFIED_
@ UNSPECIFIED_
do not use
Definition: Trigger/TrigEvent/TrigSteeringEvent/TrigSteeringEvent/Enums.h:67
ActionNames
const std::string ActionNames[4]
Definition: Enums.cxx:11
HLTEnums
Definition: Enums.cxx:26