Skip to content

Commit 3244d13

Browse files
authored
[EMCAL-792] Make threshods for all error classes adjustable (#2229)
- Threshods defined per error class and error histogram - Threshold on errors from all links summed up
1 parent 13e5952 commit 3244d13

2 files changed

Lines changed: 300 additions & 15 deletions

File tree

Modules/EMCAL/include/EMCAL/RawErrorCheck.h

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
#include "QualityControl/CheckInterface.h"
2121

22+
#include <map>
23+
2224
namespace o2::emcal
2325
{
2426
class Geometry;
@@ -36,15 +38,26 @@ namespace o2::quality_control_modules::emcal
3638
class RawErrorCheck : public o2::quality_control::checker::CheckInterface
3739
{
3840
public:
39-
/// Default constructor
41+
/// \brief Default constructor
4042
RawErrorCheck() = default;
41-
/// Destructor
43+
/// \brief Destructor
4244
~RawErrorCheck() override = default;
4345

44-
// Override interface
46+
/// \brief Configure checker setting thresholds from taskParameters where specified
4547
void configure() override;
48+
49+
/// \brief Check for each object whether the number of errors of type is above the expected threshold
50+
/// \param moMap List of histos to check
51+
/// \return Quality of the selection
4652
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
53+
54+
/// \brief Beautify the monitoring objects showing the quality determination and a supermodule grid for channel based histograms
55+
/// \param mo Monitoring object to beautify
56+
/// \param checkResult Quality status of this checker
4757
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult = Quality::Null) override;
58+
59+
/// \brief Accept only TH2 histograms as input
60+
/// \return Name of the accepted object: TH2
4861
std::string getAcceptedType() override;
4962

5063
ClassDefOverride(RawErrorCheck, 2);
@@ -56,8 +69,50 @@ class RawErrorCheck : public o2::quality_control::checker::CheckInterface
5669
/// \throw std::runtime_error in case value is not a boolean value
5770
bool decodeBool(std::string value) const;
5871

59-
o2::emcal::Geometry* mGeometry; ///< Geometry for mapping position between SM and full EMCAL
60-
bool mNotifyInfologger = true; ///< Switch for notification to infologger
72+
/// \brief Find error code of the raw decoder error
73+
/// \param errorname Name of the raw decoder error
74+
/// \return Error code of the error name (-1 in case not found)
75+
int findErrorCodeRDE(const std::string_view errorname) const;
76+
77+
/// \brief Find error code of the page error
78+
/// \param errorname Name of the page error
79+
/// \return Error code of the error name (-1 in case not found)
80+
int findErrorCodePE(const std::string_view errorname) const;
81+
82+
/// \brief Find error code of the major ALTRO decoding error
83+
/// \param errorname Name of the major ALTRO decoding error
84+
/// \return Error code of the error name (-1 in case not found)
85+
int findErrorCodeMAAE(const std::string_view errorname) const;
86+
87+
/// \brief Find error code of the minor ALTRO decoding error
88+
/// \param errorname Name of minor ALTRO decoding error
89+
/// \return Error code of the error name (-1 in case not found)
90+
int findErrorCodeMIAE(const std::string_view errorname) const;
91+
92+
/// \brief Find error code of the raw fit error
93+
/// \param errorname Name of the raw fit error
94+
/// \return Error code of the error name (-1 in case not found)
95+
int findErrorCodeRFE(const std::string_view errorname) const;
96+
97+
/// \brief Find error code of the geometry error
98+
/// \param errorname Name of the geometry error
99+
/// \return Error code of the error name (-1 in case not found)
100+
int findErrorCodeGEE(const std::string_view errorname) const;
101+
102+
/// \brief Find error code of the gain type error
103+
/// \param errorname Name of the gain type error
104+
/// \return Error code of the error name (-1 in case not found)
105+
int findErrorCodeGTE(const std::string_view errorname) const;
106+
107+
o2::emcal::Geometry* mGeometry; ///< Geometry for mapping position between SM and full EMCAL
108+
bool mNotifyInfologger = true; ///< Switch for notification to infologger
109+
std::map<int, int> mErrorCountThresholdRDE; ///< Thresholds for Raw Decoder Error histogram
110+
std::map<int, int> mErrorCountThresholdPE; ///< Thresholds for Page Error histogram
111+
std::map<int, int> mErrorCountThresholdMAAE; ///< Thresholds for Major ALTRO Error histogram
112+
std::map<int, int> mErrorCountThresholdMIAE; ///< Thresholds for Minor ALTRO Error histogram
113+
std::map<int, int> mErrorCountThresholdRFE; ///< Thresholds for Raw Fit Error histogram
114+
std::map<int, int> mErrorCountThresholdGEE; ///< Thresholds for Geometry Error histogram
115+
std::map<int, int> mErrorCountThresholdGTE; ///< Thresholds for Gain Type Error histogram
61116
};
62117

63118
} // namespace o2::quality_control_modules::emcal

Modules/EMCAL/src/RawErrorCheck.cxx

Lines changed: 240 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
#include <string>
1515
#include <boost/algorithm/string.hpp>
1616

17+
#include "DataFormatsEMCAL/ErrorTypeFEE.h"
1718
#include "EMCALBase/Geometry.h"
19+
#include "EMCALReconstruction/AltroDecoder.h"
20+
#include "EMCALReconstruction/CaloRawFitter.h"
21+
#include "EMCALReconstruction/RawDecodingError.h"
22+
#include "EMCALReconstruction/ReconstructionErrors.h"
1823

1924
#include "EMCAL/RawErrorCheck.h"
2025
#include "QualityControl/MonitorObject.h"
@@ -48,6 +53,126 @@ void RawErrorCheck::configure()
4853
ILOG(Error, Support) << e.what() << ENDM;
4954
}
5055
}
56+
const std::string keyThreshRawdataErrors = "ThresholdRDE",
57+
keyThreshPageError = "ThresholdPE",
58+
keyThreshMajorAltroError = "ThresholdMAAE",
59+
keyThreshMinorAltroError = "ThresholdMIAE",
60+
keyThresRawFitError = "ThresholdRFE",
61+
keyThresholdGeometryError = "ThresholdGEE",
62+
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;
74+
}
75+
} else {
76+
ILOG(Error) << "Thresholds for histogram RawDataErrors: Requested error type " << errortype << " not found" << ENDM;
77+
}
78+
}
79+
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;
90+
}
91+
} else {
92+
ILOG(Error) << "Thresholds for histogram PageErrors: Requested error type " << errortype << " not found" << ENDM;
93+
}
94+
}
95+
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;
106+
}
107+
} else {
108+
ILOG(Error) << "Thresholds for histogram MajorAltroErrors: Requested error type " << errortype << " not found" << ENDM;
109+
}
110+
}
111+
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;
122+
}
123+
} else {
124+
ILOG(Error) << "Thresholds for histogram MinorAltroError: Requested error type " << errortype << " not found" << ENDM;
125+
}
126+
}
127+
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;
138+
}
139+
} else {
140+
ILOG(Error) << "Thresholds for histogram RawFitError: Requested error type " << errortype << " not found" << ENDM;
141+
}
142+
}
143+
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;
154+
}
155+
} else {
156+
ILOG(Error) << "Thresholds for histogram GeometryError: Requested error type " << errortype << " not found" << ENDM;
157+
}
158+
}
159+
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;
170+
}
171+
} else {
172+
ILOG(Error) << "Thresholds for histogram GainTypeError: Requested error type " << errortype << " not found" << ENDM;
173+
}
174+
}
175+
}
51176
}
52177

53178
Quality RawErrorCheck::check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap)
@@ -57,20 +182,41 @@ Quality RawErrorCheck::check(std::map<std::string, std::shared_ptr<MonitorObject
57182
std::array<std::string, 2> channelgainhists = { { "ChannelLGnoHG", "ChannelHGnoLG" } };
58183
Quality result = Quality::Good;
59184

185+
std::map<std::string, const std::map<int, int>*> thresholdConfigErrorHists = {
186+
{ "RawDataErrors", &mErrorCountThresholdRDE },
187+
{ "PageErrors", &mErrorCountThresholdPE },
188+
{ "MajorAltroErrors", &mErrorCountThresholdMAAE },
189+
{ "MinorAltroError", &mErrorCountThresholdMIAE },
190+
{ "RawFitError", &mErrorCountThresholdRFE },
191+
{ "GeometryError", &mErrorCountThresholdGEE },
192+
{ "GainTypeError", &mErrorCountThresholdGTE }
193+
};
194+
60195
for (auto& [moName, mo] : *moMap) {
61196
if (std::find(errorhists.begin(), errorhists.end(), mo->getName()) != errorhists.end()) {
62197
// Check for presence of error codes
63198
auto* errorhist = dynamic_cast<TH2*>(mo->getObject());
64199

65-
for (int linkID = 0; linkID < errorhist->GetXaxis()->GetNbins(); linkID++) {
66-
for (int errorcode = 0; errorcode < errorhist->GetYaxis()->GetNbins(); errorcode++) {
67-
if (errorhist->GetBinContent(linkID + 1, errorcode + 1)) {
68-
// Found raw data error
69-
if (result != Quality::Bad) {
70-
result = Quality::Bad;
71-
}
72-
result.addReason(FlagReasonFactory::Unknown(), "Raw error " + std::string(errorhist->GetYaxis()->GetBinLabel(errorcode + 1)) + " found in DDL " + std::to_string(linkID));
200+
for (int errorcode = 0; errorcode < errorhist->GetYaxis()->GetNbins(); errorcode++) {
201+
// try to find a threshold
202+
int threshold = 0;
203+
auto thresholdHandler = thresholdConfigErrorHists.find(mo->getName());
204+
if (thresholdHandler != thresholdConfigErrorHists.end()) {
205+
auto thresholdFound = thresholdHandler->second->find(errorcode);
206+
if (thresholdFound != thresholdHandler->second->end()) {
207+
threshold = thresholdFound->second;
208+
}
209+
}
210+
int numErrors = 0;
211+
for (int linkID = 0; linkID < errorhist->GetXaxis()->GetNbins(); linkID++) {
212+
numErrors += errorhist->GetBinContent(linkID + 1, errorcode + 1);
213+
}
214+
if (numErrors > threshold) {
215+
// Found number of raw data errors is above threshold for bin
216+
if (result != Quality::Bad) {
217+
result = Quality::Bad;
73218
}
219+
result.addReason(FlagReasonFactory::Unknown(), "Raw error " + std::string(errorhist->GetYaxis()->GetBinLabel(errorcode + 1)) + " above threshold " + std::to_string(threshold));
74220
}
75221
}
76222
} else if (std::find(gainhists.begin(), gainhists.end(), mo->GetName()) != gainhists.end()) {
@@ -150,7 +296,7 @@ void RawErrorCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkRes
150296
}
151297
}
152298
}
153-
//SM grid
299+
// SM grid
154300
if (mo->getName().find("Channel") != std::string::npos) {
155301
auto* h2D = dynamic_cast<TH2*>(mo->getObject());
156302
// orizontal
@@ -170,7 +316,7 @@ void RawErrorCheck::beautify(std::shared_ptr<MonitorObject> mo, Quality checkRes
170316
TLine* l11 = new TLine(-0.5, 200, 95.5, 200);
171317
TLine* l12 = new TLine(47.5, 200, 47.5, 207.5);
172318

173-
//vertical
319+
// vertical
174320
TLine* l13 = new TLine(47.5, -0.5, 47.5, 128);
175321
TLine* l14 = new TLine(31.5, 128, 31.5, 200);
176322
TLine* l15 = new TLine(63.5, 128, 63.5, 200);
@@ -221,4 +367,88 @@ bool RawErrorCheck::decodeBool(std::string value) const
221367
throw std::runtime_error(fmt::format("Value {} not a boolean", value.data()).data());
222368
}
223369

370+
int RawErrorCheck::findErrorCodeRDE(const std::string_view errorname) const
371+
{
372+
int result = -1;
373+
for (int error = 0; error < o2::emcal::ErrorTypeFEE::getNumberOfErrorTypes(); error++) {
374+
if (std::string_view(o2::emcal::ErrorTypeFEE::getErrorTypeName(error)) == errorname) {
375+
result = error;
376+
break;
377+
}
378+
}
379+
return result;
380+
}
381+
382+
int RawErrorCheck::findErrorCodePE(const std::string_view errorname) const
383+
{
384+
int result = -1;
385+
for (int error = 0; error < o2::emcal::RawDecodingError::getNumberOfErrorTypes(); error++) {
386+
if (std::string_view(o2::emcal::RawDecodingError::getErrorCodeNames(error)) == errorname) {
387+
result = error;
388+
break;
389+
}
390+
}
391+
return result;
392+
}
393+
394+
int RawErrorCheck::findErrorCodeMAAE(const std::string_view errorname) const
395+
{
396+
int result = -1;
397+
for (int error = 0; error < o2::emcal::AltroDecoderError::getNumberOfErrorTypes(); error++) {
398+
if (std::string_view(o2::emcal::AltroDecoderError::getErrorTypeName(error)) == errorname) {
399+
result = error;
400+
break;
401+
}
402+
}
403+
return result;
404+
}
405+
406+
int RawErrorCheck::findErrorCodeMIAE(const std::string_view errorname) const
407+
{
408+
int result = -1;
409+
for (int error = 0; error < o2::emcal::MinorAltroDecodingError::getNumberOfErrorTypes(); error++) {
410+
if (std::string_view(o2::emcal::MinorAltroDecodingError::getErrorTypeName(error)) == errorname) {
411+
result = error;
412+
break;
413+
}
414+
}
415+
return result;
416+
}
417+
418+
int RawErrorCheck::findErrorCodeRFE(const std::string_view errorname) const
419+
{
420+
int result = -1;
421+
for (int error = 0; error < o2::emcal::CaloRawFitter::getNumberOfErrorTypes(); error++) {
422+
if (std::string_view(o2::emcal::CaloRawFitter::getErrorTypeName(error)) == errorname) {
423+
result = error;
424+
break;
425+
}
426+
}
427+
return result;
428+
}
429+
430+
int RawErrorCheck::findErrorCodeGEE(const std::string_view errorname) const
431+
{
432+
int result = -1;
433+
for (int error = 0; error < o2::emcal::reconstructionerrors::getNumberOfGeometryErrorCodes(); error++) {
434+
if (std::string_view(o2::emcal::reconstructionerrors::getGeometryErrorName(error)) == errorname) {
435+
result = error;
436+
break;
437+
}
438+
}
439+
return result;
440+
}
441+
442+
int RawErrorCheck::findErrorCodeGTE(const std::string_view errorname) const
443+
{
444+
int result = -1;
445+
for (int error = 0; error < o2::emcal::reconstructionerrors::getNumberOfGainErrorCodes(); error++) {
446+
if (std::string_view(o2::emcal::reconstructionerrors::getGainErrorName(error)) == errorname) {
447+
result = error;
448+
break;
449+
}
450+
}
451+
return result;
452+
}
453+
224454
} // namespace o2::quality_control_modules::emcal

0 commit comments

Comments
 (0)