Skip to content

Commit fc37110

Browse files
authored
[EMCAL-792] Catch std::out_of_range if no checkerParam is defined (#2236)
1 parent 66154b5 commit fc37110

1 file changed

Lines changed: 96 additions & 91 deletions

File tree

Modules/EMCAL/src/RawErrorCheck.cxx

Lines changed: 96 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -60,118 +60,123 @@ void RawErrorCheck::configure()
6060
keyThresRawFitError = "ThresholdRFE",
6161
keyThresholdGeometryError = "ThresholdGEE",
6262
keyThresholdGainTypeError = "ThresholdGTE";
63-
for (auto [param, value] : mCustomParameters.getAllDefaults()) {
64-
if (param.find(keyThreshRawdataErrors) == 0) {
65-
auto errortype = param.substr(keyThreshRawdataErrors.length());
66-
auto errorcode = findErrorCodeRDE(errortype);
67-
if (errorcode > -1) {
68-
try {
69-
auto threshold = std::stoi(value);
70-
ILOG(Info) << "Setting custom threshold in Histogram RawDataErrors: " << errortype << " <= " << threshold << ENDM;
71-
mErrorCountThresholdRDE[errorcode] = threshold;
72-
} catch (...) {
73-
ILOG(Error) << "Thresholds for histogram RawDataErrors: Failure in decoding threshold value (" << value << ") for error type " << errortype << ENDM;
63+
try {
64+
for (auto& [param, value] : mCustomParameters.getAllDefaults()) {
65+
if (param.find(keyThreshRawdataErrors) == 0) {
66+
auto errortype = param.substr(keyThreshRawdataErrors.length());
67+
auto errorcode = findErrorCodeRDE(errortype);
68+
if (errorcode > -1) {
69+
try {
70+
auto threshold = std::stoi(value);
71+
ILOG(Info) << "Setting custom threshold in Histogram RawDataErrors: " << errortype << " <= " << threshold << ENDM;
72+
mErrorCountThresholdRDE[errorcode] = threshold;
73+
} catch (...) {
74+
ILOG(Error) << "Thresholds for histogram RawDataErrors: Failure in decoding threshold value (" << value << ") for error type " << errortype << ENDM;
75+
}
76+
} else {
77+
ILOG(Error) << "Thresholds for histogram RawDataErrors: Requested error type " << errortype << " not found" << ENDM;
7478
}
75-
} else {
76-
ILOG(Error) << "Thresholds for histogram RawDataErrors: Requested error type " << errortype << " not found" << ENDM;
7779
}
78-
}
7980

80-
if (param.find(keyThreshPageError) == 0) {
81-
auto errortype = param.substr(keyThreshPageError.length());
82-
auto errorcode = findErrorCodePE(errortype);
83-
if (errorcode > -1) {
84-
try {
85-
auto threshold = std::stoi(value);
86-
ILOG(Info) << "Setting custom threshold in Histogram PageErrors: " << errortype << " <= " << threshold << ENDM;
87-
mErrorCountThresholdPE[errorcode] = threshold;
88-
} catch (...) {
89-
ILOG(Error) << "Thresholds for histogram PageErrors: Failure in decoding threshold value (" << value << ") for error type " << errortype << ENDM;
81+
if (param.find(keyThreshPageError) == 0) {
82+
auto errortype = param.substr(keyThreshPageError.length());
83+
auto errorcode = findErrorCodePE(errortype);
84+
if (errorcode > -1) {
85+
try {
86+
auto threshold = std::stoi(value);
87+
ILOG(Info) << "Setting custom threshold in Histogram PageErrors: " << errortype << " <= " << threshold << ENDM;
88+
mErrorCountThresholdPE[errorcode] = threshold;
89+
} catch (...) {
90+
ILOG(Error) << "Thresholds for histogram PageErrors: Failure in decoding threshold value (" << value << ") for error type " << errortype << ENDM;
91+
}
92+
} else {
93+
ILOG(Error) << "Thresholds for histogram PageErrors: Requested error type " << errortype << " not found" << ENDM;
9094
}
91-
} else {
92-
ILOG(Error) << "Thresholds for histogram PageErrors: Requested error type " << errortype << " not found" << ENDM;
9395
}
94-
}
9596

96-
if (param.find(keyThreshMajorAltroError) == 0) {
97-
auto errortype = param.substr(keyThreshMajorAltroError.length());
98-
auto errorcode = findErrorCodeMAAE(errortype);
99-
if (errorcode > -1) {
100-
try {
101-
auto threshold = std::stoi(value);
102-
ILOG(Info) << "Setting custom threshold in Histogram MajorAltroErrors: " << errortype << " <= " << threshold << ENDM;
103-
mErrorCountThresholdMAAE[errorcode] = threshold;
104-
} catch (...) {
105-
ILOG(Error) << "Thresholds for histogram MajorAltroErrors: Failure in decoding threshold value (" << value << ") for error type " << errortype << ENDM;
97+
if (param.find(keyThreshMajorAltroError) == 0) {
98+
auto errortype = param.substr(keyThreshMajorAltroError.length());
99+
auto errorcode = findErrorCodeMAAE(errortype);
100+
if (errorcode > -1) {
101+
try {
102+
auto threshold = std::stoi(value);
103+
ILOG(Info) << "Setting custom threshold in Histogram MajorAltroErrors: " << errortype << " <= " << threshold << ENDM;
104+
mErrorCountThresholdMAAE[errorcode] = threshold;
105+
} catch (...) {
106+
ILOG(Error) << "Thresholds for histogram MajorAltroErrors: Failure in decoding threshold value (" << value << ") for error type " << errortype << ENDM;
107+
}
108+
} else {
109+
ILOG(Error) << "Thresholds for histogram MajorAltroErrors: Requested error type " << errortype << " not found" << ENDM;
106110
}
107-
} else {
108-
ILOG(Error) << "Thresholds for histogram MajorAltroErrors: Requested error type " << errortype << " not found" << ENDM;
109111
}
110-
}
111112

112-
if (param.find(keyThreshMinorAltroError) == 0) {
113-
auto errortype = param.substr(keyThreshMinorAltroError.length());
114-
auto errorcode = findErrorCodeMIAE(errortype);
115-
if (errorcode > -1) {
116-
try {
117-
auto threshold = std::stoi(value);
118-
ILOG(Info) << "Setting custom threshold in Histogram MinorAltroError: " << errortype << " <= " << threshold << ENDM;
119-
mErrorCountThresholdMAAE[errorcode] = threshold;
120-
} catch (...) {
121-
ILOG(Error) << "Thresholds for histogram MinorAltroError: Failure in decoding threshold value (" << value << ") for error type " << errortype << ENDM;
113+
if (param.find(keyThreshMinorAltroError) == 0) {
114+
auto errortype = param.substr(keyThreshMinorAltroError.length());
115+
auto errorcode = findErrorCodeMIAE(errortype);
116+
if (errorcode > -1) {
117+
try {
118+
auto threshold = std::stoi(value);
119+
ILOG(Info) << "Setting custom threshold in Histogram MinorAltroError: " << errortype << " <= " << threshold << ENDM;
120+
mErrorCountThresholdMAAE[errorcode] = threshold;
121+
} catch (...) {
122+
ILOG(Error) << "Thresholds for histogram MinorAltroError: Failure in decoding threshold value (" << value << ") for error type " << errortype << ENDM;
123+
}
124+
} else {
125+
ILOG(Error) << "Thresholds for histogram MinorAltroError: Requested error type " << errortype << " not found" << ENDM;
122126
}
123-
} else {
124-
ILOG(Error) << "Thresholds for histogram MinorAltroError: Requested error type " << errortype << " not found" << ENDM;
125127
}
126-
}
127128

128-
if (param.find(keyThresRawFitError) == 0) {
129-
auto errortype = param.substr(keyThresRawFitError.length());
130-
auto errorcode = findErrorCodeRFE(errortype);
131-
if (errorcode > -1) {
132-
try {
133-
auto threshold = std::stoi(value);
134-
ILOG(Info) << "Setting custom threshold in Histogram RawFitError: " << errortype << " <= " << threshold << ENDM;
135-
mErrorCountThresholdRFE[errorcode] = threshold;
136-
} catch (...) {
137-
ILOG(Error) << "Thresholds for histogram RawFitError: Failure in decoding threshold value (" << value << ") for error type " << errortype << ENDM;
129+
std::cout << "IAMHERE6" << std::endl;
130+
if (param.find(keyThresRawFitError) == 0) {
131+
auto errortype = param.substr(keyThresRawFitError.length());
132+
auto errorcode = findErrorCodeRFE(errortype);
133+
if (errorcode > -1) {
134+
try {
135+
auto threshold = std::stoi(value);
136+
ILOG(Info) << "Setting custom threshold in Histogram RawFitError: " << errortype << " <= " << threshold << ENDM;
137+
mErrorCountThresholdRFE[errorcode] = threshold;
138+
} catch (...) {
139+
ILOG(Error) << "Thresholds for histogram RawFitError: Failure in decoding threshold value (" << value << ") for error type " << errortype << ENDM;
140+
}
141+
} else {
142+
ILOG(Error) << "Thresholds for histogram RawFitError: Requested error type " << errortype << " not found" << ENDM;
138143
}
139-
} else {
140-
ILOG(Error) << "Thresholds for histogram RawFitError: Requested error type " << errortype << " not found" << ENDM;
141144
}
142-
}
143145

144-
if (param.find(keyThresholdGeometryError) == 0) {
145-
auto errortype = param.substr(keyThresholdGeometryError.length());
146-
auto errorcode = findErrorCodeGEE(errortype);
147-
if (errorcode > -1) {
148-
try {
149-
auto threshold = std::stoi(value);
150-
ILOG(Info) << "Setting custom threshold in Histogram GeometryError: " << errortype << " <= " << threshold << ENDM;
151-
mErrorCountThresholdGEE[errorcode] = threshold;
152-
} catch (...) {
153-
ILOG(Error) << "Thresholds for histogram GeometryError: Failure in decoding threshold value (" << value << ") for error type " << errortype << ENDM;
146+
if (param.find(keyThresholdGeometryError) == 0) {
147+
auto errortype = param.substr(keyThresholdGeometryError.length());
148+
auto errorcode = findErrorCodeGEE(errortype);
149+
if (errorcode > -1) {
150+
try {
151+
auto threshold = std::stoi(value);
152+
ILOG(Info) << "Setting custom threshold in Histogram GeometryError: " << errortype << " <= " << threshold << ENDM;
153+
mErrorCountThresholdGEE[errorcode] = threshold;
154+
} catch (...) {
155+
ILOG(Error) << "Thresholds for histogram GeometryError: Failure in decoding threshold value (" << value << ") for error type " << errortype << ENDM;
156+
}
157+
} else {
158+
ILOG(Error) << "Thresholds for histogram GeometryError: Requested error type " << errortype << " not found" << ENDM;
154159
}
155-
} else {
156-
ILOG(Error) << "Thresholds for histogram GeometryError: Requested error type " << errortype << " not found" << ENDM;
157160
}
158-
}
159161

160-
if (param.find(keyThresholdGainTypeError) == 0) {
161-
auto errortype = param.substr(keyThresholdGainTypeError.length());
162-
auto errorcode = findErrorCodeGTE(errortype);
163-
if (errorcode > -1) {
164-
try {
165-
auto threshold = std::stoi(value);
166-
ILOG(Info) << "Setting custom threshold in Histogram GainTypeError: " << errortype << " <= " << threshold << ENDM;
167-
mErrorCountThresholdGTE[errorcode] = threshold;
168-
} catch (...) {
169-
ILOG(Error) << "Thresholds for histogram GainTypeError: Failure in decoding threshold value (" << value << ") for error type " << errortype << ENDM;
162+
if (param.find(keyThresholdGainTypeError) == 0) {
163+
auto errortype = param.substr(keyThresholdGainTypeError.length());
164+
auto errorcode = findErrorCodeGTE(errortype);
165+
if (errorcode > -1) {
166+
try {
167+
auto threshold = std::stoi(value);
168+
ILOG(Info) << "Setting custom threshold in Histogram GainTypeError: " << errortype << " <= " << threshold << ENDM;
169+
mErrorCountThresholdGTE[errorcode] = threshold;
170+
} catch (...) {
171+
ILOG(Error) << "Thresholds for histogram GainTypeError: Failure in decoding threshold value (" << value << ") for error type " << errortype << ENDM;
172+
}
173+
} else {
174+
ILOG(Error) << "Thresholds for histogram GainTypeError: Requested error type " << errortype << " not found" << ENDM;
170175
}
171-
} else {
172-
ILOG(Error) << "Thresholds for histogram GainTypeError: Requested error type " << errortype << " not found" << ENDM;
173176
}
174177
}
178+
} catch (std::out_of_range& e) {
179+
// Nothing to be done, no parameter found.
175180
}
176181
}
177182

0 commit comments

Comments
 (0)