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 30 of file MonitoringObject.h.

Constructor & Destructor Documentation

◆ MonitoringObject() [1/2]

MonitoringObject ( )
inline

Constructor.

Definition at line 35 of file MonitoringObject.h.

35{};

◆ MonitoringObject() [2/2]

MonitoringObject ( const std::string &  name)
inlineexplicit

Constructor with name (always use this)

Definition at line 38 of file MonitoringObject.h.

39 {
40 fName = name;
41 }

Member Function Documentation

◆ addCanvas()

void addCanvas ( TCanvas *  canv)
inline

Add Canvas to monitoring object.

Parameters
canvpointer to canvas to add

Definition at line 47 of file MonitoringObject.h.

48 {
49 for (auto cc : m_Canvases) {
50 if (cc->GetName() == canv->GetName()) {
51 B2ERROR("Canvas with name " << canv->GetName() << " already in the " << fName <<
52 " MonitoringObject! Use different name (or call getCanvas(name) to access pointer to the existing TCanvas).");
53 return;
54 }
55 }
56 m_Canvases.push_back(canv);
57 };
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 94 of file MonitoringObject.h.

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

◆ getListOfCanvases()

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

Get list of all canvases.

Definition at line 106 of file MonitoringObject.h.

107 {
108 return m_Canvases;
109 }

◆ getLowError()

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

Get map of all float variables lower errors.

Definition at line 78 of file MonitoringObject.h.

79 {
80 return m_dwErr;
81 }
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 86 of file MonitoringObject.h.

87 {
88 return m_strVars;
89 }
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 70 of file MonitoringObject.h.

71 {
72 return m_upErr;
73 }
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 62 of file MonitoringObject.h.

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

◆ print()

void print ( ) const

Print content of MonitoringObject.

Definition at line 18 of file MonitoringObject.cc.

19{
20
21 KeyValuePrinter printVar(false);
22 printVar.put("Name", GetName());
23 for (const auto& var : m_vars) {
24 printVar.put(var.first, var.second);
25 }
26 for (const auto& var : m_strVars) {
27 printVar.put(var.first, var.second);
28 }
29
30 KeyValuePrinter printCanv(false);
31 for (const auto& canv : m_Canvases) {
32 printCanv.put(canv->GetName(), canv->GetTitle());
33 }
34
35 std::cout << "=== MonitoringObject ===\n";
36 std::cout << printVar.string();
37 std::cout << "\n List of canvases: \n";
38 std::cout << printCanv.string();
39 std::cout << "========================\n";
40}
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 149 of file MonitoringObject.h.

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

◆ 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 123 of file MonitoringObject.h.

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

Member Data Documentation

◆ m_Canvases

std::vector<TCanvas*> m_Canvases
private

vector of all TCanvases

Definition at line 164 of file MonitoringObject.h.

◆ m_dwErr

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

map of lower errors of variables

Definition at line 168 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 170 of file MonitoringObject.h.

◆ m_upErr

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

map of upper errors of variables

Definition at line 167 of file MonitoringObject.h.

◆ m_vars

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

map of all float variables

Definition at line 166 of file MonitoringObject.h.


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