Skip to content

Commit 41445c2

Browse files
committed
Feat: update gpu error task
1 parent 7e9c43b commit 41445c2

File tree

2 files changed

+17
-25
lines changed

2 files changed

+17
-25
lines changed

Detectors/TPC/qc/include/TPCQC/GPUErrorQA.h

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,20 @@
1818
#define AliceO2_TPC_QC_GPUERRORQA_H
1919

2020
#include <memory>
21+
#include <string>
22+
#include <vector>
2123
#include <unordered_map>
22-
#include <gsl/span>
2324

2425
// root includes
25-
#include "TH1.h"
2626

2727
// o2 includes
2828
// #include "DataFormatsTPC/Defs.h"
2929

30-
namespace o2
31-
{
32-
namespace tpc
33-
{
34-
namespace qc
30+
class TH1;
31+
namespace o2::tpc::qc
3532
{
3633

37-
/// @brief TPC QC task for errors from GPU reconstruction
34+
/// @brief TPC QC task for errors from GPU reconstruction
3835
///
3936
/// This class is used to retrieve and visualize GPU errors
4037
/// according to corresponding error code and location.
@@ -48,7 +45,7 @@ class GPUErrorQA
4845
GPUErrorQA() = default;
4946

5047
/// process gpu error reported by the reconstruction workflow
51-
void processErrors(gsl::span<const std::array<uint32_t, 4>> errors);
48+
void processErrors(std::vector<std::array<uint32_t, 4>> errors);
5249

5350
/// Initialize all histograms
5451
void initializeHistograms();
@@ -57,17 +54,16 @@ class GPUErrorQA
5754
void resetHistograms();
5855

5956
/// return histograms
60-
std::unordered_map<std::string, std::unique_ptr<TH1>>& getMapHist() { return mMapHist; };
57+
const std::unordered_map<std::string, std::unique_ptr<TH1>>& getMapHist() const { return mMapHist; };
6158

6259
/// Dump results to a file
6360
void dumpToFile(std::string filename);
6461

6562
private:
6663
std::unordered_map<std::string, std::unique_ptr<TH1>> mMapHist;
67-
ClassDefNV(GPUErrorQA, 1)
64+
65+
ClassDefNV(GPUErrorQA, 1);
6866
};
69-
} // namespace qc
70-
} // namespace tpc
71-
} // namespace o2
67+
} // namespace o2::tpc::qc
7268

7369
#endif // AliceO2_TPC_QC_GPUERRORQA_H

Detectors/TPC/qc/src/GPUErrorQA.cxx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,9 @@
1111

1212
#define _USE_MATH_DEFINES
1313

14-
#include <cmath>
15-
#include <memory>
16-
#include <unordered_map>
17-
1814
// root includes
1915
#include "TFile.h"
20-
#include <TH1.h>
16+
#include "TH1I.h"
2117

2218
// o2 includes
2319
#include "TPCQC/GPUErrorQA.h"
@@ -41,7 +37,7 @@ void GPUErrorQA::initializeHistograms()
4137
};
4238

4339
// 1D histogram counting all reported errors
44-
mMapHist["ErrorCounter"] = std::make_unique<TH1F>("ErrorCounter", "ErrorCounter", errorNames.size(), 0, errorNames.size());
40+
mMapHist["ErrorCounter"] = std::make_unique<TH1I>("ErrorCounter", "ErrorCounter", errorNames.size(), -0.5, errorNames.size() - 0.5);
4541
mMapHist["ErrorCounter"]->GetXaxis()->SetTitle("Error Codes");
4642
mMapHist["ErrorCounter"]->GetYaxis()->SetTitle("Entries");
4743
// for convienence, label each bin with the error name
@@ -58,22 +54,22 @@ void GPUErrorQA::resetHistograms()
5854
}
5955
}
6056
//______________________________________________________________________________
61-
void GPUErrorQA::processErrors(gsl::span<const std::array<uint32_t, 4>> errors)
57+
void GPUErrorQA::processErrors(std::vector<std::array<uint32_t, 4>> errors)
6258
{
6359
for (const auto& error : errors) {
6460
uint32_t errorCode = error[0];
65-
mMapHist["ErrorCounter"]->Fill(static_cast<float>(errorCode));
61+
mMapHist["ErrorCounter"]->AddBinContent(errorCode);
6662
}
6763
}
6864

6965
//______________________________________________________________________________
7066
void GPUErrorQA::dumpToFile(const std::string filename)
7167
{
7268
auto f = std::unique_ptr<TFile>(TFile::Open(filename.data(), "recreate"));
69+
TObjArray arr;
70+
arr.SetName("GPUErrorQA_Hists");
7371
for (const auto& [name, hist] : mMapHist) {
74-
TObjArray arr;
75-
arr.SetName(name.data());
7672
arr.Add(hist.get());
77-
arr.Write(arr.GetName(), TObject::kSingleKey);
7873
}
74+
arr.Write(arr.GetName(), TObject::kSingleKey);
7975
}

0 commit comments

Comments
 (0)