Project
Loading...
Searching...
No Matches
GPUErrorQA.cxx
Go to the documentation of this file.
1// Copyright 2019-2025 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#define _USE_MATH_DEFINES
13
14// root includes
15#include "TFile.h"
16#include "TH1I.h"
17
18// o2 includes
19#include "TPCQC/GPUErrorQA.h"
20#include "GPUErrors.h"
21
23
24using namespace o2::tpc::qc;
25
26//______________________________________________________________________________
28{
29 TH1::AddDirectory(false);
30
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
40 // 1D histogram counting all reported errors
41 mMapHist["ErrorCounter"] = std::make_unique<TH1I>("ErrorCounter", "ErrorCounter", maxErrorCode, -0.5, maxErrorCode - 0.5);
42 mMapHist["ErrorCounter"]->GetXaxis()->SetTitle("Error Codes");
43 mMapHist["ErrorCounter"]->GetYaxis()->SetTitle("Entries");
44 // for convienence, label each bin with the error name
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 }
52 }
53}
54//______________________________________________________________________________
56{
57 for (const auto& pair : mMapHist) {
58 pair.second->Reset();
59 }
60}
61//______________________________________________________________________________
62void GPUErrorQA::processErrors(std::vector<std::array<uint32_t, 4>> errors)
63{
64 for (const auto& error : errors) {
65 uint32_t errorCode = error[0];
66 mMapHist["ErrorCounter"]->AddBinContent(errorCode);
67 }
68}
69
70//______________________________________________________________________________
71void GPUErrorQA::dumpToFile(const std::string filename)
72{
73 auto f = std::unique_ptr<TFile>(TFile::Open(filename.data(), "recreate"));
74 TObjArray arr;
75 arr.SetName("GPUErrorQA_Hists");
76 for ([[maybe_unused]] const auto& [name, hist] : mMapHist) {
77 arr.Add(hist.get());
78 }
79 arr.Write(arr.GetName(), TObject::kSingleKey);
80}
ClassImp(o2::tpc::qc::GPUErrorQA)
StringRef key
static const std::unordered_map< uint32_t, const char * > & getErrorNames()
Definition GPUErrors.cxx:51
TPC QC task for errors from GPU reconstruction.
Definition GPUErrorQA.h:42
void processErrors(std::vector< std::array< uint32_t, 4 > > errors)
process gpu error reported by the reconstruction workflow
void dumpToFile(std::string filename)
Dump results to a file.
void initializeHistograms()
Initialize all histograms.
void resetHistograms()
Reset all histograms.
GLuint const GLchar * name
Definition glcorearb.h:781
GLdouble f
Definition glcorearb.h:310
std::string filename()