Belle II Software development
MonitoringObject Class Reference

MonitoringObject is a basic object to hold data for the run-dependency monitoring Run summary TCanvases and monitoring variables. More...

#include <MonitoringObject.h>

Inheritance diagram for MonitoringObject:

Public Member Functions

 MonitoringObject ()
 Constructor.
 
 MonitoringObject (const std::string &name)
 Constructor with name (always use this)
 
void addCanvas (TCanvas *canv)
 Add Canvas to monitoring object.
 
const std::map< std::string, float > & getVariables ()
 Get map of all float variables.
 
const std::map< std::string, float > & getUpError ()
 Get map of all float variables upper errors.
 
const std::map< std::string, float > & getLowError ()
 Get map of all float variables lower errors.
 
const std::vector< std::pair< std::string, std::string > > & getStringVariables ()
 Get vector of all string variables.
 
TCanvas * getCanvas (const std::string &name)
 Get pointer to existing canvas with given name (NULL is returned if not existing)
 
const std::vector< TCanvas * > & getListOfCanvases ()
 Get list of all canvases.
 
void print () const
 Print content of MonitoringObject.
 
void setVariable (const std::string &var, float val, float upErr=-1., float dwErr=-1)
 set value to float variable (new variable is made if not yet existing)
 
void setVariable (const std::string &var, const std::string &val)
 set value to string variable (new variable is made if not yet existing)
 

Private Member Functions

 ClassDefOverride (MonitoringObject, 1)
 classdef
 

Private Attributes

std::vector< TCanvas * > m_Canvases
 vector of all TCanvases
 
std::map< std::string, float > m_vars
 map of all float variables
 
std::map< std::string, float > m_upErr
 map of upper errors of variables
 
std::map< std::string, float > m_dwErr
 map of lower errors of variables
 
std::vector< std::pair< std::string, std::string > > m_strVars
 map of all string variables
 

Detailed Description

MonitoringObject is a basic object to hold data for the run-dependency monitoring Run summary TCanvases and monitoring variables.

Definition at line 31 of file MonitoringObject.h.

Constructor & Destructor Documentation

◆ MonitoringObject() [1/2]

MonitoringObject ( )
inline

Constructor.

Definition at line 36 of file MonitoringObject.h.

36{};

◆ MonitoringObject() [2/2]

MonitoringObject ( const std::string &  name)
inlineexplicit

Constructor with name (always use this)

Definition at line 39 of file MonitoringObject.h.

40 {
41 fName = name;
42 }

Member Function Documentation

◆ addCanvas()

void addCanvas ( TCanvas *  canv)
inline

Add Canvas to monitoring object.

Parameters
canvpointer to canvas to add

Definition at line 48 of file MonitoringObject.h.

49 {
50 for (auto cc : m_Canvases) {
51 if (cc->GetName() == canv->GetName()) {
52 B2ERROR("Canvas with name " << canv->GetName() << " already in the " << fName <<
53 " MonitoringObject! Use different name (or call getCanvas(name) to access pointer to the existing TCanvas).");
54 return;
55 }
56 }
57 m_Canvases.push_back(canv);
58 };
std::vector< TCanvas * > m_Canvases
vector of all TCanvases

◆ getCanvas()

TCanvas * getCanvas ( const std::string &  name)
inline

Get pointer to existing canvas with given name (NULL is returned if not existing)

Definition at line 95 of file MonitoringObject.h.

96 {
97 for (auto cc : m_Canvases) {
98 if (cc->GetName() == name) return cc;
99 }
100 B2WARNING("TCanvas with name " << name << " not found in MonitoringObject " << fName);
101 return NULL;
102 };

◆ getListOfCanvases()

const std::vector< TCanvas * > & getListOfCanvases ( )
inline

Get list of all canvases.

Definition at line 107 of file MonitoringObject.h.

108 {
109 return m_Canvases;
110 }

◆ getLowError()

const std::map< std::string, float > & getLowError ( )
inline

Get map of all float variables lower errors.

Definition at line 79 of file MonitoringObject.h.

80 {
81 return m_dwErr;
82 }
std::map< std::string, float > m_dwErr
map of lower errors of variables

◆ getStringVariables()

const std::vector< std::pair< std::string, std::string > > & getStringVariables ( )
inline

Get vector of all string variables.

Definition at line 87 of file MonitoringObject.h.

88 {
89 return m_strVars;
90 }
std::vector< std::pair< std::string, std::string > > m_strVars
map of all string variables

◆ getUpError()

const std::map< std::string, float > & getUpError ( )
inline

Get map of all float variables upper errors.

Definition at line 71 of file MonitoringObject.h.

72 {
73 return m_upErr;
74 }
std::map< std::string, float > m_upErr
map of upper errors of variables

◆ getVariables()

const std::map< std::string, float > & getVariables ( )
inline

Get map of all float variables.

Definition at line 63 of file MonitoringObject.h.

64 {
65 return m_vars;
66 }
std::map< std::string, float > m_vars
map of all float variables

◆ print()

void print ( ) const

Print content of MonitoringObject.

Definition at line 19 of file MonitoringObject.cc.

20{
21
22 KeyValuePrinter printVar(false);
23 printVar.put("Name", GetName());
24 for (const auto& var : m_vars) {
25 printVar.put(var.first, var.second);
26 }
27 for (const auto& var : m_strVars) {
28 printVar.put(var.first, var.second);
29 }
30
31 KeyValuePrinter printCanv(false);
32 for (const auto& canv : m_Canvases) {
33 printCanv.put(canv->GetName(), canv->GetTitle());
34 }
35
36 std::cout << "=== MonitoringObject ===\n";
37 std::cout << printVar.string();
38 std::cout << "\n List of canvases: \n";
39 std::cout << printCanv.string();
40 std::cout << "========================\n";
41}
create human-readable or JSON output for key value pairs.

◆ setVariable() [1/2]

void setVariable ( const std::string &  var,
const std::string &  val 
)
inline

set value to string variable (new variable is made if not yet existing)

Parameters
varvariable name
valvariable value

Definition at line 150 of file MonitoringObject.h.

151 {
152
153 for (auto& pair : m_strVars) {
154 if (pair.first == var) {
155 pair.second = val;
156 return;
157 }
158 }
159 m_strVars.push_back(std::pair<std::string, std::string>(var, val));
160 }

◆ setVariable() [2/2]

void setVariable ( const std::string &  var,
float  val,
float  upErr = -1.,
float  dwErr = -1 
)
inline

set value to float variable (new variable is made if not yet existing)

Parameters
varvariable name
valvariable value
upErrvariable size of positive error
dwErrvariable size of negative error (if not set, symmetric error with size upErr is used)

Definition at line 124 of file MonitoringObject.h.

125 {
126
127 auto vv = m_vars.find(var);
128 if (vv != m_vars.end()) vv->second = val;
129 else m_vars.insert({var, val});
130
131 if (upErr > 0) {
132 auto vvE = m_upErr.find(var);
133 if (vvE != m_upErr.end()) vvE->second = upErr;
134 else m_upErr.insert({var, upErr});
135 }
136
137 if (dwErr > 0) {
138 auto vvE = m_dwErr.find(var);
139 if (vvE != m_dwErr.end()) vvE->second = dwErr;
140 else m_dwErr.insert({var, dwErr});
141 }
142
143 }

Member Data Documentation

◆ m_Canvases

std::vector<TCanvas*> m_Canvases
private

vector of all TCanvases

Definition at line 165 of file MonitoringObject.h.

◆ m_dwErr

std::map<std::string, float> m_dwErr
private

map of lower errors of variables

Definition at line 169 of file MonitoringObject.h.

◆ m_strVars

std::vector<std::pair<std::string, std::string> > m_strVars
private

map of all string variables

Definition at line 171 of file MonitoringObject.h.

◆ m_upErr

std::map<std::string, float> m_upErr
private

map of upper errors of variables

Definition at line 168 of file MonitoringObject.h.

◆ m_vars

std::map<std::string, float> m_vars
private

map of all float variables

Definition at line 167 of file MonitoringObject.h.


The documentation for this class was generated from the following files: