Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Detectors/TPC/qc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ o2_add_library(TPCQC
src/SACs.cxx
src/IDCsVsSACs.cxx
src/TrackClusters.cxx
src/GPUErrorQA.cxx
PUBLIC_LINK_LIBRARIES O2::TPCBase
O2::DataFormatsTPC
O2::GPUO2Interface
Expand All @@ -36,7 +37,8 @@ o2_target_root_dictionary(TPCQC
include/TPCQC/DCSPTemperature.h
include/TPCQC/SACs.h
include/TPCQC/IDCsVsSACs.h
include/TPCQC/TrackClusters.h)
include/TPCQC/TrackClusters.h
include/TPCQC/GPUErrorQA.h)

o2_add_test(PID
COMPONENT_NAME tpc
Expand Down
73 changes: 73 additions & 0 deletions Detectors/TPC/qc/include/TPCQC/GPUErrorQA.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

///
/// @file GPUErrorQA.h
/// @author Anton Riedel, anton.riedel@cern.ch
///

#ifndef AliceO2_TPC_QC_GPUERRORQA_H
#define AliceO2_TPC_QC_GPUERRORQA_H

#include <memory>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <memory>
#include <string>
#include <memory>

#include <unordered_map>
#include <gsl/span>

// root includes
#include "TH1.h"

// o2 includes
// #include "DataFormatsTPC/Defs.h"
Comment on lines +24 to +28
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use forward declaration for TH1

Suggested change
// root includes
#include "TH1.h"
// o2 includes
// #include "DataFormatsTPC/Defs.h"
class TH1;


namespace o2
{
namespace tpc
{
namespace qc
{
Comment on lines +30 to +35
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
namespace o2
{
namespace tpc
{
namespace qc
{
namespace o2::tpc::qc
{


/// @brief TPC QC task for errors from GPU reconstruction
///
/// This class is used to retrieve and visualize GPU errors
/// according to corresponding error code and location.
///
/// origin: TPC
/// @author Anton Riedel, anton.riedel@cern.ch
class GPUErrorQA
{
public:
/// \brief Constructor.
GPUErrorQA() = default;

/// process gpu error reported by the reconstruction workflow
void processErrors(gsl::span<const std::array<uint32_t, 4>> errors);

/// Initialize all histograms
void initializeHistograms();

/// Reset all histograms
void resetHistograms();

/// return histograms
std::unordered_map<std::string, std::unique_ptr<TH1>>& getMapHist() { return mMapHist; };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the histograms don't need to be filled outside, this can be const

Suggested change
std::unordered_map<std::string, std::unique_ptr<TH1>>& getMapHist() { return mMapHist; };
std::unordered_map<std::string, std::unique_ptr<TH1>>& getMapHist() const { return mMapHist; };


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

private:
std::unordered_map<std::string, std::unique_ptr<TH1>> mMapHist;
ClassDefNV(GPUErrorQA, 1)
};
} // namespace qc
} // namespace tpc
} // namespace o2
Comment on lines +69 to +71
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} // namespace qc
} // namespace tpc
} // namespace o2
} // namespace o2::tpc::qc


#endif // AliceO2_TPC_QC_GPUERRORQA_H
79 changes: 79 additions & 0 deletions Detectors/TPC/qc/src/GPUErrorQA.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Copyright 2019-2025 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

#define _USE_MATH_DEFINES

#include <cmath>
#include <memory>
#include <unordered_map>
Comment on lines +15 to +16
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's already defined in the header

Suggested change
#include <memory>
#include <unordered_map>


// root includes
#include "TFile.h"
#include <TH1.h>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include <TH1.h>
#include "TH1.h"


// o2 includes
#include "TPCQC/GPUErrorQA.h"
#include "GPUDefMacros.h"

ClassImp(o2::tpc::qc::GPUErrorQA);

using namespace o2::tpc::qc;

//______________________________________________________________________________
void GPUErrorQA::initializeHistograms()
{
TH1::AddDirectory(false);

// get gpu error names
// copied from GPUErrors.h
static std::unordered_map<uint32_t, const char*> errorNames = {
#define GPUCA_ERROR_CODE(num, name, ...) {num, GPUCA_M_STR(name)},
#include "GPUErrorCodes.h"
#undef GPUCA_ERROR_CODE
};

// 1D histogram counting all reported errors
mMapHist["ErrorCounter"] = std::make_unique<TH1F>("ErrorCounter", "ErrorCounter", errorNames.size(), 0, errorNames.size());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a histogram of floats? If it is a simple counter, it could also be TH1I, unless one would like to normalize at some point.

mMapHist["ErrorCounter"]->GetXaxis()->SetTitle("Error Codes");
mMapHist["ErrorCounter"]->GetYaxis()->SetTitle("Entries");
// for convienence, label each bin with the error name
for (size_t bin = 1; bin < mMapHist["ErrorCounter"]->GetNbinsX(); bin++) {
auto const& it = errorNames.find(bin);
mMapHist["ErrorCounter"]->GetXaxis()->SetBinLabel(bin, it->second);
}
}
//______________________________________________________________________________
void GPUErrorQA::resetHistograms()
{
for (const auto& pair : mMapHist) {
pair.second->Reset();
}
}
//______________________________________________________________________________
void GPUErrorQA::processErrors(gsl::span<const std::array<uint32_t, 4>> errors)
{
for (const auto& error : errors) {
uint32_t errorCode = error[0];
mMapHist["ErrorCounter"]->Fill(static_cast<float>(errorCode));
}
}

//______________________________________________________________________________
void GPUErrorQA::dumpToFile(const std::string filename)
{
auto f = std::unique_ptr<TFile>(TFile::Open(filename.data(), "recreate"));
for (const auto& [name, hist] : mMapHist) {
TObjArray arr;
arr.SetName(name.data());
arr.Add(hist.get());
arr.Write(arr.GetName(), TObject::kSingleKey);
}
Comment on lines +73 to +78
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it does not make sense to put each histogram in a separate array.

Suggested change
for (const auto& [name, hist] : mMapHist) {
TObjArray arr;
arr.SetName(name.data());
arr.Add(hist.get());
arr.Write(arr.GetName(), TObject::kSingleKey);
}
TObjArray arr;
arr.SetName("GPUError_Hists");
for (const auto& [name, hist] : mMapHist) {
arr.Add(hist.get());
}
arr.Write(arr.GetName(), TObject::kSingleKey);

}
1 change: 1 addition & 0 deletions Detectors/TPC/qc/src/TPCQCLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#pragma link C++ class o2::tpc::qc::SACs + ;
#pragma link C++ class o2::tpc::qc::IDCsVsSACs + ;
#pragma link C++ class o2::tpc::qc::TrackClusters + ;
#pragma link C++ class o2::tpc::qc::GPUErrorQA + ;
#pragma link C++ function o2::tpc::qc::helpers::makeLogBinning + ;
#pragma link C++ function o2::tpc::qc::helpers::setStyleHistogram1D + ;
#pragma link C++ function o2::tpc::qc::helpers::setStyleHistogram2D + ;
Expand Down