Skip to content

Commit 7b5af49

Browse files
ariedel-cerndavidrohr
authored andcommitted
Feat: account for missing error codes
1 parent 8aec6f6 commit 7b5af49

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

Detectors/TPC/qc/src/GPUErrorQA.cxx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,27 @@ void GPUErrorQA::initializeHistograms()
2828
{
2929
TH1::AddDirectory(false);
3030

31+
auto const& errorNames = o2::gpu::GPUErrors::getErrorNames();
32+
33+
int maxErrorCode = 1;
34+
for (const auto& [key, _] : errorNames) {
35+
if (static_cast<int>(key) > maxErrorCode) {
36+
maxErrorCode = key;
37+
}
38+
}
39+
3140
// 1D histogram counting all reported errors
32-
mMapHist["ErrorCounter"] = std::make_unique<TH1I>("ErrorCounter", "ErrorCounter", o2::gpu::errorNames.size(), -0.5, o2::gpu::errorNames.size() - 0.5);
41+
mMapHist["ErrorCounter"] = std::make_unique<TH1I>("ErrorCounter", "ErrorCounter", maxErrorCode, -0.5, maxErrorCode - 0.5);
3342
mMapHist["ErrorCounter"]->GetXaxis()->SetTitle("Error Codes");
3443
mMapHist["ErrorCounter"]->GetYaxis()->SetTitle("Entries");
3544
// for convienence, label each bin with the error name
36-
for (size_t bin = 1; bin < mMapHist["ErrorCounter"]->GetNbinsX(); bin++) {
37-
auto const& it = o2::gpu::errorNames.find(bin);
38-
mMapHist["ErrorCounter"]->GetXaxis()->SetBinLabel(bin, it->second);
45+
for (size_t bin = 1; bin <= maxErrorCode; bin++) {
46+
auto const& it = errorNames.find(bin);
47+
if (it != errorNames.end()) {
48+
mMapHist["ErrorCounter"]->GetXaxis()->SetBinLabel(bin, it->second);
49+
} else {
50+
mMapHist["ErrorCounter"]->GetXaxis()->SetBinLabel(bin, "NO_DEF");
51+
}
3952
}
4053
}
4154
//______________________________________________________________________________

0 commit comments

Comments
 (0)