Belle II Software development
RefHistObject.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#pragma once
9
10#include <TH1.h>
11
12namespace Belle2 {
17
24 public:
25 std::string m_orghist_name;
26 std::string m_refhist_name;
27 std::unique_ptr <TH1> m_refHist;
28 std::unique_ptr <TH1> m_refCopy;
29
30 public:
31
34 RefHistObject(void) : m_orghist_name(""), m_refhist_name(""), m_refHist(nullptr), m_refCopy(nullptr) {};
35
38 RefHistObject(RefHistObject&& other) noexcept
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 }
48
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 }
65
66#if 0 // Unused, keep in case we need an explicit public accessor (e.g. testing). Code should use getReference below.
70 TH1* getRefHist(void) { return m_refHist.get();};
71
75 TH1* getRefCopy(void) { return m_refCopy.get();};
76#endif
77
81 void setRefHist(TH1* refHist)
82 {
83 m_refHist.reset(refHist); // Assumes ownership of refHist
84 }
85
89 void setRefCopy(TH1* refCopy)
90 {
91 m_refCopy.reset(refCopy); // Assumes ownership of refCopy
92 }
93
99 TH1* getReference(void);
100
101 private:
104 void makeReferenceCopy(void);
105 };
106
107}
std::string m_refhist_name
reference histogram name TODO this is not used
std::string m_orghist_name
online histogram name TODO this is not used
RefHistObject(void)
Constructor.
void setRefCopy(TH1 *refCopy)
set scaled reference histogram pointer, takes ownership
RefHistObject & operator=(RefHistObject &&other) noexcept
Move assignment operator.
std::unique_ptr< TH1 > m_refCopy
Pointer to scaled reference histogram.
void setRefHist(TH1 *refHist)
set reference histogram pointer, takes ownership
std::unique_ptr< TH1 > m_refHist
Pointer to reference histogram.
RefHistObject(RefHistObject &&other) noexcept
Move constructor.
TH1 * getReference(void)
Get reference histogram pointer the pointer is to a freshly made copy, which can be modified by the c...
void makeReferenceCopy(void)
Make a copy of the underlying reference histogram which can be used for scaling.
Abstract base class for different kinds of events.