Skip to content
Snippets Groups Projects
Commit bcaadcde authored by Sergei Zharko's avatar Sergei Zharko
Browse files

CbmQaTable class introduction

parent 23535557
No related branches found
No related tags found
1 merge request!796L1Algo interface and tools: updates
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
#include "TAxis.h" #include "TAxis.h"
#include <fstream>
#include <iomanip> #include <iomanip>
#include <iostream> #include <iostream>
#include <fstream>
#include <sstream> #include <sstream>
// TODO: Insert class info, try __PRETTY_FUNCTION__ and inline function for its modification (S.Zharko) // TODO: Insert class info, try __PRETTY_FUNCTION__ and inline function for its modification (S.Zharko)
...@@ -48,24 +48,15 @@ CbmQaTable::CbmQaTable(const char* name, const char* title, Int_t nRows, Int_t n ...@@ -48,24 +48,15 @@ CbmQaTable::CbmQaTable(const char* name, const char* title, Int_t nRows, Int_t n
// //
//------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------
// //
CbmQaTable::~CbmQaTable() CbmQaTable::~CbmQaTable() {}
{
}
// //
//------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------
// //
Double_t CbmQaTable::GetCell(Int_t iRow, Int_t iCol) const Double_t CbmQaTable::GetCell(Int_t iRow, Int_t iCol) const { return TH2D::GetBinContent(iCol + 1, fNrows - iRow); }
{
return TH2D::GetBinContent(iCol + 1, fNrows - iRow);
}
// //
//------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------
// //
Double_t CbmQaTable::GetCellError(Int_t iRow, Int_t iCol) const Double_t CbmQaTable::GetCellError(Int_t iRow, Int_t iCol) const { return TH2D::GetBinError(iCol + 1, fNrows - iRow); }
{
return TH2D::GetBinError(iCol + 1, fNrows - iRow);
}
// //
//------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------
// //
...@@ -79,7 +70,7 @@ void CbmQaTable::SetCell(Int_t iRow, Int_t iCol, Double_t content, Double_t erro ...@@ -79,7 +70,7 @@ void CbmQaTable::SetCell(Int_t iRow, Int_t iCol, Double_t content, Double_t erro
// //
void CbmQaTable::SetNamesOfCols(const std::vector<std::string>& names) void CbmQaTable::SetNamesOfCols(const std::vector<std::string>& names)
{ {
Int_t nEntries = (fNcols > static_cast<Int_t>(names.size())) ? static_cast<Int_t>(names.size()) : fNcols; Int_t nEntries = (fNcols > static_cast<Int_t>(names.size())) ? static_cast<Int_t>(names.size()) : fNcols;
// TODO: Possibly, we need a restriction on the names size (S.Zharko) // TODO: Possibly, we need a restriction on the names size (S.Zharko)
for (Int_t iCol = 1; iCol <= nEntries; ++iCol) { for (Int_t iCol = 1; iCol <= nEntries; ++iCol) {
TH2D::GetXaxis()->SetBinLabel(iCol, names[iCol - 1].c_str()); TH2D::GetXaxis()->SetBinLabel(iCol, names[iCol - 1].c_str());
...@@ -90,7 +81,7 @@ void CbmQaTable::SetNamesOfCols(const std::vector<std::string>& names) ...@@ -90,7 +81,7 @@ void CbmQaTable::SetNamesOfCols(const std::vector<std::string>& names)
// //
void CbmQaTable::SetNamesOfRows(const std::vector<std::string>& names) void CbmQaTable::SetNamesOfRows(const std::vector<std::string>& names)
{ {
Int_t nEntries = (fNrows > static_cast<Int_t>(names.size())) ? static_cast<Int_t>(names.size()) : fNrows; Int_t nEntries = (fNrows > static_cast<Int_t>(names.size())) ? static_cast<Int_t>(names.size()) : fNrows;
// TODO: Possibly, we need a restriction on the names size (S.Zharko) // TODO: Possibly, we need a restriction on the names size (S.Zharko)
for (Int_t iRow = 1; iRow <= nEntries; ++iRow) { for (Int_t iRow = 1; iRow <= nEntries; ++iRow) {
TH2D::GetYaxis()->SetBinLabel(fNrows - iRow + 1, names[iRow - 1].c_str()); TH2D::GetYaxis()->SetBinLabel(fNrows - iRow + 1, names[iRow - 1].c_str());
...@@ -134,7 +125,7 @@ std::ostream& operator<<(std::ostream& out, const CbmQaTable& aTable) ...@@ -134,7 +125,7 @@ std::ostream& operator<<(std::ostream& out, const CbmQaTable& aTable)
out.precision(3); out.precision(3);
out.setf(std::ios::left); out.setf(std::ios::left);
// Print column titles // Print column titles
out << std::setw(CbmQaTable::kRowTitlesSetwPar) << std::setfill(' ') << ' ' << ' '; // top-left cell, always out << std::setw(CbmQaTable::kRowTitlesSetwPar) << std::setfill(' ') << ' ' << ' '; // top-left cell, always
for (Int_t iCol = 1; iCol <= aTable.fNcols; ++iCol) { for (Int_t iCol = 1; iCol <= aTable.fNcols; ++iCol) {
std::string entry = std::string(aTable.GetXaxis()->GetBinLabel(iCol)); std::string entry = std::string(aTable.GetXaxis()->GetBinLabel(iCol));
if (static_cast<Int_t>(entry.size()) > CbmQaTable::kDefaultSetwPar) { if (static_cast<Int_t>(entry.size()) > CbmQaTable::kDefaultSetwPar) {
...@@ -151,7 +142,7 @@ std::ostream& operator<<(std::ostream& out, const CbmQaTable& aTable) ...@@ -151,7 +142,7 @@ std::ostream& operator<<(std::ostream& out, const CbmQaTable& aTable)
entry = entry.substr(0, CbmQaTable::kDefaultSetwPar - 3) + "..."; entry = entry.substr(0, CbmQaTable::kDefaultSetwPar - 3) + "...";
} }
out << std::setw(CbmQaTable::kRowTitlesSetwPar) << std::setfill(' ') << entry << ' '; out << std::setw(CbmQaTable::kRowTitlesSetwPar) << std::setfill(' ') << entry << ' ';
for (Int_t iCol = 0; iCol < aTable.fNcols; ++iCol) { for (Int_t iCol = 0; iCol < aTable.fNcols; ++iCol) {
out << std::setw(CbmQaTable::kDefaultSetwPar) << std::setfill(' ') << aTable.GetCell(iRow, iCol) << ' '; out << std::setw(CbmQaTable::kDefaultSetwPar) << std::setfill(' ') << aTable.GetCell(iRow, iCol) << ' ';
} }
...@@ -162,8 +153,3 @@ std::ostream& operator<<(std::ostream& out, const CbmQaTable& aTable) ...@@ -162,8 +153,3 @@ std::ostream& operator<<(std::ostream& out, const CbmQaTable& aTable)
// //
//------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------
// //
...@@ -12,21 +12,21 @@ ...@@ -12,21 +12,21 @@
#ifndef CbmQaTable_h #ifndef CbmQaTable_h
#define CbmQaTable_h 1 #define CbmQaTable_h 1
#include "TROOT.h"
#include "TH2D.h" #include "TH2D.h"
#include "TROOT.h"
#include <fstream> #include <fstream>
#include <string> #include <string>
// TODO: We need a method, which sets and gets cell values! (S.Zharko) // TODO: We need a method, which sets and gets cell values! (S.Zharko)
class CbmQaTable: public TH2D { class CbmQaTable : public TH2D {
public: public:
// //
// CONSTRUCTORS AND DESTRUCTORS // CONSTRUCTORS AND DESTRUCTORS
// //
/// Default constructor /// Default constructor
CbmQaTable(): TH2D() {} CbmQaTable() : TH2D() {}
/// Constructor from number of rows and columns /// Constructor from number of rows and columns
CbmQaTable(const char* name, const char* title, Int_t nRows, Int_t nCols); CbmQaTable(const char* name, const char* title, Int_t nRows, Int_t nCols);
/// Destructor /// Destructor
...@@ -34,7 +34,7 @@ public: ...@@ -34,7 +34,7 @@ public:
/// Dumps table content into a string /// Dumps table content into a string
std::string ToString() const; std::string ToString() const;
/// Dumps table content into a text file. File open mode is also controllable, for example, use /// Dumps table content into a text file. File open mode is also controllable, for example, use
/// mode = std::ios_base::app to append the table into an existing file /// mode = std::ios_base::app to append the table into an existing file
void ToTextFile(const std::string& fileName, std::ios_base::openmode mode = std::ios_base::out) const; void ToTextFile(const std::string& fileName, std::ios_base::openmode mode = std::ios_base::out) const;
...@@ -74,17 +74,17 @@ private: ...@@ -74,17 +74,17 @@ private:
// Structural fields // Structural fields
Int_t fNcols {0}; ///< number of columns in a table Int_t fNcols {0}; ///< number of columns in a table
Int_t fNrows {0}; ///< number of rows in a table Int_t fNrows {0}; ///< number of rows in a table
// Some hard-coded constants // Some hard-coded constants
static constexpr Float_t kDefaultTextSize {0.03}; ///< default size of text static constexpr Float_t kDefaultTextSize {0.03}; ///< default size of text
static constexpr Style_t kDefaultFontStyle {62}; ///< default text style static constexpr Style_t kDefaultFontStyle {62}; ///< default text style
static constexpr Int_t kDefaultSetwPar {12}; ///< default size of entry in std::setw() for columns static constexpr Int_t kDefaultSetwPar {12}; ///< default size of entry in std::setw() for columns
static constexpr Int_t kRowTitlesSetwPar {30}; ///< size of entry in std::setw() for row titles static constexpr Int_t kRowTitlesSetwPar {30}; ///< size of entry in std::setw() for row titles
static constexpr Int_t kValuesPrecision {3}; ///< precision of output parameters static constexpr Int_t kValuesPrecision {3}; ///< precision of output parameters
// TODO: Apply this precision and other options to graphical verion of the table // TODO: Apply this precision and other options to graphical verion of the table
ClassDef(CbmQaTable, 1); ClassDef(CbmQaTable, 1);
}; };
#endif // CbmQaTable_h #endif // CbmQaTable_h
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment