26Table::Table(std::string_view label,
int nRows,
int nCols, std::string_view title)
42 LOG(fatal) <<
"cbm::qa::report::Table::Set(): A nullptr QA-table is passed to the function. The table label is \""
53 bool bRowsHaveTitles =
false;
54 for (
int iRow = 0; iRow < nRowsQa; ++iRow) {
55 if (!std::string(pQaTable->GetXaxis()->GetBinLabel(nRowsQa - iRow)).empty()) {
56 bRowsHaveTitles =
true;
60 fNofCols = nColsQa +
static_cast<int>(bRowsHaveTitles);
65 bool bCommonRowFormat = cellFormat.find_first_of(
'|') == std::string::npos;
66 std::vector<std::string> vCellFormat(nColsQa, bCommonRowFormat ? cellFormat : std::string(
kDefaultFormat));
67 if (!bCommonRowFormat) {
68 std::stringstream stream(cellFormat);
70 while (iCol < nColsQa && std::getline(stream, vCellFormat[iCol],
'|')) {
71 if (vCellFormat.empty()) {
72 vCellFormat[iCol] =
"{}";
79 for (
auto& entry : vCellFormat) {
81 std::string sTest = fmt::format(entry, 0.);
83 catch (
const std::runtime_error& err) {
84 LOG(error) <<
"cbm::qa::report::Table(): Inacceptable format \"" << entry <<
"\" is passed, using default";
92 for (
int iCol =
static_cast<int>(bRowsHaveTitles); iCol <
fNofCols; ++iCol) {
93 this->
SetColumnTitle(iCol, std::string(pQaTable->GetXaxis()->GetBinLabel(iCol)));
95 for (
int iRow = 0; iRow <
fNofRows; ++iRow) {
97 if (bRowsHaveTitles) {
98 this->
SetCell(iRow, 0, pQaTable->GetYaxis()->GetBinLabel(
fNofRows - iRow));
100 for (
int iColQa = 0; iColQa < nColsQa; ++iColQa) {
101 double entry = pQaTable->
GetCell(iRow, iColQa);
102 int iCol = iColQa +
static_cast<int>(bRowsHaveTitles);
103 this->
SetCell(iRow, iCol, fmt::format(vCellFormat[iColQa], entry));
Base class for the report table (header)
Definition of CbmQaTable class.
TODO: SZh, 30.01.2023: Override THistPainter::PaintText() to add zeroes in tables.
Double_t GetCell(Int_t iRow, Int_t iCol) const
Gets cell content. Please mind, that the signature and result of this function is different to TH2D::...
Int_t GetNrows() const
Sets number of rows.
Int_t GetNcols() const
Sets number of columns.
Interface for the report element.
const std::string & GetLabel() const
Gets label.
Table element in the report.
Table(std::string_view label, std::string_view title="")
Constructor.
void SetCell(int iRow, int iCol, std::string_view cell)
Sets cell.
void Set(const CbmQaTable *pQaTable, const std::string &cellFormat=std::string(kDefaultFormat))
Sets a table from CbmQaTable.
std::vector< std::string > fvsTable
std::vector< std::string > fvsTableHeader
void SetColumnTitle(int iCol, std::string_view title)
Sets column title.
static constexpr std::string_view kDefaultFormat
Default format of double entries.