Belle II Software development
HistObject Class Reference

Class to keep track of histograms. More...

#include <HistObject.h>

Public Member Functions

 HistObject (void)
 Constructor.
 
 ~HistObject (void)
 Destructor.
 
bool update (TH1 *hist)
 Check if update of histogram is necessary.
 
void resetBeforeEvent (void)
 Reset histogram and update flag, not the entries.
 
bool isUpdated (void)
 Check if histogram was updated.
 
TH1 * getHist (void)
 Get histogram pointer.
 

Public Attributes

std::unique_ptr< TH1 > m_hist
 Pointer to histogram.
 
bool m_updated = false
 flag if update since last event
 
double m_entries = -1
 entries in previous/current for update check
 

Detailed Description

Class to keep track of histograms.

The class owns the histogram and keeps track if the histogram has changed between analysis events by checking the number of entries.

Definition at line 23 of file HistObject.h.

Constructor & Destructor Documentation

◆ HistObject()

HistObject ( void )
inline

Constructor.

Definition at line 32 of file HistObject.h.

32: m_hist(nullptr), m_updated(false), m_entries(-1) {};

◆ ~HistObject()

~HistObject ( void )

Destructor.

Definition at line 12 of file HistObject.cc.

13{
14}

Member Function Documentation

◆ getHist()

TH1 * getHist ( void )
inline

Get histogram pointer.

Returns
histogram ptr

Definition at line 56 of file HistObject.h.

56{ return m_hist.get();};

◆ isUpdated()

bool isUpdated ( void )
inline

Check if histogram was updated.

Returns
it was updated

Definition at line 51 of file HistObject.h.

51{ return m_updated;};

◆ resetBeforeEvent()

void resetBeforeEvent ( void )

Reset histogram and update flag, not the entries.

Definition at line 27 of file HistObject.cc.

28{
29 m_hist = nullptr;
30 m_updated = false;
31}
bool m_updated
flag if update since last event
Definition HistObject.h:26
std::unique_ptr< TH1 > m_hist
Pointer to histogram.
Definition HistObject.h:25

◆ update()

bool update ( TH1 * hist)

Check if update of histogram is necessary.

Parameters
histpointer to histogram
Returns
histogram was updated flag (return m_updated)

Definition at line 16 of file HistObject.cc.

17{
18 if (hist) {
19 // if it is not nullptr, check if there was an update
20 m_updated |= hist->GetEntries() != m_entries;
21 m_entries = hist->GetEntries();
22 }
23 m_hist = std::unique_ptr<TH1>(hist); // even if it is nullptr
24 return m_updated;
25}
double m_entries
entries in previous/current for update check
Definition HistObject.h:27

Member Data Documentation

◆ m_entries

double m_entries = -1

entries in previous/current for update check

Definition at line 27 of file HistObject.h.

◆ m_hist

std::unique_ptr<TH1> m_hist

Pointer to histogram.

Definition at line 25 of file HistObject.h.

◆ m_updated

bool m_updated = false

flag if update since last event

Definition at line 26 of file HistObject.h.


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