Belle II Software development
RefHistObject Class Reference

Class to keep track of reference histograms with the original. More...

#include <RefHistObject.h>

Public Member Functions

 RefHistObject (void)
 Constructor.
 
 RefHistObject (RefHistObject &&other) noexcept
 Move constructor.
 
RefHistObjectoperator= (RefHistObject &&other) noexcept
 Move assignment operator.
 
void resetBeforeEvent (void)
 Reset histogram and update flag, not the entries.
 
TCanvas * getCanvas (void)
 Get canvas pointer.
 
TH1 * getRefHist (void)
 Get ref hist pointer.
 
TH1 * getRefCopy (void)
 Get scaled ref hist pointer.
 
void setCanvas (TCanvas *canvas)
 Set canvas pointer.
 
void setRefHist (TH1 *refHist)
 set ref hist pointer
 
void setRefCopy (TH1 *refCopy)
 set scaled ref hist pointer
 
TH1 * getReference (void)
 Get reference pointer for copy.
 

Public Attributes

std::string m_orghist_name
 online histogram name
 
std::string m_refhist_name
 reference histogram name
 
std::unique_ptr< TCanvas > m_canvas
 canvas where we draw the histogram
 
std::unique_ptr< TH1 > m_refHist
 Pointer to reference histogram.
 
std::unique_ptr< TH1 > m_refCopy
 Pointer to scaled reference histogram.
 

Private Member Functions

void makeReferenceCopy (void)
 Make a reference copy.
 

Detailed Description

Class to keep track of reference histograms with the original.

Definition at line 22 of file RefHistObject.h.

Constructor & Destructor Documentation

◆ RefHistObject() [1/2]

RefHistObject ( void  )
inline

Constructor.

Definition at line 34 of file RefHistObject.h.

34: m_orghist_name(""), m_refhist_name(""), m_canvas(nullptr), m_refHist(nullptr), m_refCopy(nullptr) {};
std::string m_refhist_name
reference histogram name
Definition: RefHistObject.h:25
std::string m_orghist_name
online histogram name
Definition: RefHistObject.h:24
std::unique_ptr< TCanvas > m_canvas
canvas where we draw the histogram
Definition: RefHistObject.h:26
std::unique_ptr< TH1 > m_refCopy
Pointer to scaled reference histogram.
Definition: RefHistObject.h:28
std::unique_ptr< TH1 > m_refHist
Pointer to reference histogram.
Definition: RefHistObject.h:27

◆ RefHistObject() [2/2]

RefHistObject ( RefHistObject &&  other)
inlinenoexcept

Move constructor.

Definition at line 38 of file RefHistObject.h.

39 : m_orghist_name(std::move(other.m_orghist_name)),
40 m_refhist_name(std::move(other.m_refhist_name)),
41 m_canvas(std::move(other.m_canvas)),
42 m_refHist(std::move(other.m_refHist)),
43 m_refCopy(std::move(other.m_refCopy))
44 {
45 // Reset the moved-from object
46 other.m_canvas = nullptr;
47 other.m_refHist = nullptr;
48 other.m_refCopy = nullptr;
49 }

Member Function Documentation

◆ getCanvas()

TCanvas * getCanvas ( void  )
inline

Get canvas pointer.

Returns
canvas ptr

Definition at line 77 of file RefHistObject.h.

77{ return m_canvas.get();};

◆ getRefCopy()

TH1 * getRefCopy ( void  )
inline

Get scaled ref hist pointer.

Returns
scaled ref hist ptr

Definition at line 87 of file RefHistObject.h.

87{ return m_refCopy.get();};

◆ getReference()

TH1 * getReference ( void  )

Get reference pointer for copy.

Returns
reference histogram pointer

Definition at line 40 of file RefHistObject.cc.

41{
43 return m_refCopy.get();
44}
void makeReferenceCopy(void)
Make a reference copy.

◆ getRefHist()

TH1 * getRefHist ( void  )
inline

Get ref hist pointer.

Returns
ref hist ptr

Definition at line 82 of file RefHistObject.h.

82{ return m_refHist.get();};

◆ makeReferenceCopy()

void makeReferenceCopy ( void  )
private

Make a reference copy.

Definition at line 13 of file RefHistObject.cc.

14{
15 auto orgref = m_refHist.get();
16 if (m_refCopy != nullptr) {
17 // if it exists already (->second call), we clear it only.
18 // thus the pointer is not changed!
19 m_refCopy->Reset();
20 m_refCopy->Add(orgref);
21 } else {
22 // is orgref is nullptr, just make a copy
23 if (orgref && (orgref->InheritsFrom("TH1C") or orgref->InheritsFrom("TH1S"))) {
24 m_refCopy = std::unique_ptr<TH1> (new TH1F()); // we want it a float for better scaling
25 orgref->Copy(*m_refCopy.get());
26 } else if (orgref && (orgref->InheritsFrom("TH1I") or orgref->InheritsFrom("TH1L"))) {
27 m_refCopy = std::unique_ptr<TH1> (new TH1D()); // we want it a float for better scaling
28 orgref->Copy(*m_refCopy.get());
29 } else {
30 // keep TProfile, TH1F or TH1D
31 m_refCopy = std::unique_ptr<TH1> ((TH1*)orgref->Clone());
32 }
33 m_refCopy->SetLineStyle(2);
34 m_refCopy->SetLineColor(3);
35 m_refCopy->SetFillColor(0);
36 m_refCopy->SetStats(kFALSE);
37 }
38}

◆ operator=()

RefHistObject & operator= ( RefHistObject &&  other)
inlinenoexcept

Move assignment operator.

Definition at line 53 of file RefHistObject.h.

54 {
55 if (this != &other) {
56 m_orghist_name = std::move(other.m_orghist_name);
57 m_refhist_name = std::move(other.m_refhist_name);
58 m_canvas = std::move(other.m_canvas);
59 m_refHist = std::move(other.m_refHist);
60 m_refCopy = std::move(other.m_refCopy);
61
62 // Reset the moved-from object
63 other.m_canvas = nullptr;
64 other.m_refHist = nullptr;
65 other.m_refCopy = nullptr;
66 }
67 return *this;
68 }

◆ setCanvas()

void setCanvas ( TCanvas *  canvas)
inline

Set canvas pointer.

Parameters
canvasinput TCanvas pointer

Definition at line 92 of file RefHistObject.h.

93 {
94 m_canvas.reset(canvas); // Assumes ownership of canvas
95 }

◆ setRefCopy()

void setRefCopy ( TH1 *  refCopy)
inline

set scaled ref hist pointer

Parameters
refCopyscaled reference TH1 pointer

Definition at line 108 of file RefHistObject.h.

109 {
110 m_refCopy.reset(refCopy); // Assumes ownership of refCopy
111 }

◆ setRefHist()

void setRefHist ( TH1 *  refHist)
inline

set ref hist pointer

Parameters
refHistreference TH1 pointer

Definition at line 100 of file RefHistObject.h.

101 {
102 m_refHist.reset(refHist); // Assumes ownership of refHist
103 }

Member Data Documentation

◆ m_canvas

std::unique_ptr<TCanvas> m_canvas

canvas where we draw the histogram

Definition at line 26 of file RefHistObject.h.

◆ m_orghist_name

std::string m_orghist_name

online histogram name

Definition at line 24 of file RefHistObject.h.

◆ m_refCopy

std::unique_ptr<TH1> m_refCopy

Pointer to scaled reference histogram.

Definition at line 28 of file RefHistObject.h.

◆ m_refHist

std::unique_ptr<TH1> m_refHist

Pointer to reference histogram.

Definition at line 27 of file RefHistObject.h.

◆ m_refhist_name

std::string m_refhist_name

reference histogram name

Definition at line 25 of file RefHistObject.h.


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