Belle II Software development
RefHistObject Class Reference

Class to keep track of reference histograms with the original histograms copy (run type dependent, loaded on run start) and possible scaled copies. More...

#include <RefHistObject.h>

Public Member Functions

 RefHistObject (void)
 Constructor.
 
 RefHistObject (RefHistObject &&other) noexcept
 Move constructor.
 
RefHistObject & operator= (RefHistObject &&other) noexcept
 Move assignment operator.
 
void setRefHist (TH1 *refHist)
 set reference histogram pointer, takes ownership
 
void setRefCopy (TH1 *refCopy)
 set scaled reference histogram pointer, takes ownership
 
TH1 * getReference (void)
 Get reference histogram pointer the pointer is to a freshly made copy, which can be modified by the caller (scaled) without changing the original stored reference histogram.
 

Public Attributes

std::string m_orghist_name
 online histogram name TODO this is not used
 
std::string m_refhist_name
 reference histogram name TODO this is not used
 
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 copy of the underlying reference histogram which can be used for scaling.
 

Detailed Description

Class to keep track of reference histograms with the original histograms copy (run type dependent, loaded on run start) and possible scaled copies.

Definition at line 23 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_refHist(nullptr), m_refCopy(nullptr) {};

◆ 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_refHist(std::move(other.m_refHist)),
42 m_refCopy(std::move(other.m_refCopy))
43 {
44 // Reset the moved-from object
45 other.m_refHist = nullptr;
46 other.m_refCopy = nullptr;
47 }

Member Function Documentation

◆ getReference()

TH1 * getReference ( void )

Get reference histogram pointer the pointer is to a freshly made copy, which can be modified by the caller (scaled) without changing the original stored reference histogram.

Ownership stays in this class.

Returns
reference histogram pointer

Definition at line 41 of file RefHistObject.cc.

42{
43 // make a new copy
45 // now the caller can modify (e.g. scale) the copy without interference
46 return m_refCopy.get();
47}
std::unique_ptr< TH1 > m_refCopy
Pointer to scaled reference histogram.
void makeReferenceCopy(void)
Make a copy of the underlying reference histogram which can be used for scaling.

◆ makeReferenceCopy()

void makeReferenceCopy ( void )
private

Make a copy of the underlying reference histogram which can be used for scaling.

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 (not existing yet), make a copy of the original histogram
23 // but, as we want to have scaling, we may need to change the type to the next larger float.
24 if (orgref && (orgref->InheritsFrom("TH1C") or orgref->InheritsFrom("TH1S"))) {
25 m_refCopy = std::make_unique<TH1F>(); // we want it a float for better scaling
26 orgref->Copy(*m_refCopy.get());
27 } else if (orgref && (orgref->InheritsFrom("TH1I") or orgref->InheritsFrom("TH1L"))) {
28 m_refCopy = std::make_unique<TH1D>(); // we want it a float for better scaling
29 orgref->Copy(*m_refCopy.get());
30 } else {
31 // keep TProfile, TH1F or TH1D
32 m_refCopy = std::unique_ptr<TH1> (static_cast<TH1*>(orgref->Clone()));
33 }
34 m_refCopy->SetLineStyle(2);
35 m_refCopy->SetLineColor(3);
36 m_refCopy->SetFillColor(0);
37 m_refCopy->SetStats(kFALSE);
38 }
39}
std::unique_ptr< TH1 > m_refHist
Pointer to reference histogram.

◆ operator=()

RefHistObject & operator= ( RefHistObject && other)
inlinenoexcept

Move assignment operator.

Definition at line 51 of file RefHistObject.h.

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

◆ setRefCopy()

void setRefCopy ( TH1 * refCopy)
inline

set scaled reference histogram pointer, takes ownership

Parameters
refCopyscaled reference histogram pointer

Definition at line 89 of file RefHistObject.h.

90 {
91 m_refCopy.reset(refCopy); // Assumes ownership of refCopy
92 }

◆ setRefHist()

void setRefHist ( TH1 * refHist)
inline

set reference histogram pointer, takes ownership

Parameters
refHistreference histogram pointer

Definition at line 81 of file RefHistObject.h.

82 {
83 m_refHist.reset(refHist); // Assumes ownership of refHist
84 }

Member Data Documentation

◆ m_orghist_name

std::string m_orghist_name

online histogram name TODO this is not used

Definition at line 25 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 TODO this is not used

Definition at line 26 of file RefHistObject.h.


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