CbmRoot
Loading...
Searching...
No Matches
CbmQaTable.h
Go to the documentation of this file.
1/* Copyright (C) 2022-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergey Gorbunov, Sergei Zharko [committer] */
4
12
13#pragma once
14
15#include "TH2D.h"
16#include "TROOT.h"
17
18#include <fstream>
19#include <string>
20
21
23
24class CbmQaTable : public TH2D {
25 public:
27 CbmQaTable() : TH2D() {}
28
30 CbmQaTable(const char* name, const char* title, Int_t nRows, Int_t nCols);
31
33 virtual ~CbmQaTable();
34
38 std::string ToString(int prec, bool useErr = false) const;
39
42 void ToTextFile(const std::string& fileName, std::ios_base::openmode mode = std::ios_base::out) const;
43
45 Double_t GetCell(Int_t iRow, Int_t iCol) const;
46
48 Double_t GetCellError(Int_t iRow, Int_t iCol) const;
49
51 Int_t GetNrows() const { return fNrows; }
52
54 Int_t GetNcols() const { return fNcols; }
55
58 void SetCell(Int_t iRow, Int_t iCol, Double_t content, Double_t error = 0.);
59
61 void SetNamesOfCols(const std::vector<std::string>& names);
62
64 void SetNamesOfRows(const std::vector<std::string>& names);
65
67 void SetRowName(Int_t iRow, const char* name);
68
70 void SetTextSize(Float_t size = 0.03);
71
74 void SetColWidth(Int_t width) { fColWidth = width; }
75
76
78 friend std::ostream& operator<<(std::ostream& out, const CbmQaTable& aTable);
79
80 private:
81 // Forbid methods for direct access to the bins
82 using TH2D::GetBinContent;
83 using TH2D::GetBinError;
84 using TH2D::SetBinContent;
85 using TH2D::SetBinError;
86
87
88 // Structural fields
89 Int_t fNcols{0};
90 Int_t fNrows{0};
91
92 Int_t fColWidth{12};
93
94 // Some hard-coded constants
95 static constexpr Float_t kDefaultTextSize{0.03};
96 static constexpr Style_t kDefaultFontStyle{62};
97
98 static constexpr Int_t kDefaultSetwPar{20};
99 static constexpr Int_t kRowTitlesSetwPar{30};
100 static constexpr Int_t kValuesPrecision{3};
101 // TODO: Apply this precision and other options to graphical verion of the table
102
104};
static constexpr size_t size()
Definition KfSimdPseudo.h:2
TODO: SZh, 30.01.2023: Override THistPainter::PaintText() to add zeroes in tables.
Definition CbmQaTable.h:24
void ToTextFile(const std::string &fileName, std::ios_base::openmode mode=std::ios_base::out) const
static constexpr Int_t kValuesPrecision
precision of output parameters
Definition CbmQaTable.h:100
static constexpr Float_t kDefaultTextSize
default size of text
Definition CbmQaTable.h:95
Int_t fNcols
number of columns in a table
Definition CbmQaTable.h:89
static constexpr Int_t kRowTitlesSetwPar
size of entry in std::setw() for row titles
Definition CbmQaTable.h:99
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::...
void SetNamesOfCols(const std::vector< std::string > &names)
Sets the names of table columns.
Double_t GetCellError(Int_t iRow, Int_t iCol) const
Gets cell error. Please mind, that the signature and result of this function is different to TH2D::Ge...
Int_t GetNrows() const
Sets number of rows.
Definition CbmQaTable.h:51
void SetNamesOfRows(const std::vector< std::string > &names)
Sets the names of table rows.
Int_t GetNcols() const
Sets number of columns.
Definition CbmQaTable.h:54
virtual ~CbmQaTable()
Destructor.
static constexpr Style_t kDefaultFontStyle
default text style
Definition CbmQaTable.h:96
static constexpr Int_t kDefaultSetwPar
default size of entry in std::setw() for columns
Definition CbmQaTable.h:98
void SetCell(Int_t iRow, Int_t iCol, Double_t content, Double_t error=0.)
ClassDef(CbmQaTable, 1)
CbmQaTable()
Default constructor.
Definition CbmQaTable.h:27
Int_t fColWidth
Width of column in number of symbols.
Definition CbmQaTable.h:92
Int_t fNrows
number of rows in a table
Definition CbmQaTable.h:90
friend std::ostream & operator<<(std::ostream &out, const CbmQaTable &aTable)
Dumps table content into a stream.
void SetRowName(Int_t iRow, const char *name)
Set name of a row.
void SetTextSize(Float_t size=0.03)
Sets size of the text.
void SetColWidth(Int_t width)
Definition CbmQaTable.h:74
std::string ToString(int prec, bool useErr=false) const