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#include <TCanvas.h>
12
13namespace Belle2 {
23 public:
24 std::string m_orghist_name;
25 std::string m_refhist_name;
26 std::unique_ptr <TCanvas> m_canvas;
27 std::unique_ptr <TH1> m_refHist;
28 std::unique_ptr <TH1> m_refCopy;
30 public:
31
34 RefHistObject(void) : m_orghist_name(""), m_refhist_name(""), m_canvas(nullptr), 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_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 }
50
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 }
69
72 void resetBeforeEvent(void);
73
77 TCanvas* getCanvas(void) { return m_canvas.get();};
78
82 TH1* getRefHist(void) { return m_refHist.get();};
83
87 TH1* getRefCopy(void) { return m_refCopy.get();};
88
92 void setCanvas(TCanvas* canvas)
93 {
94 m_canvas.reset(canvas); // Assumes ownership of canvas
95 }
96
100 void setRefHist(TH1* refHist)
101 {
102 m_refHist.reset(refHist); // Assumes ownership of refHist
103 }
104
108 void setRefCopy(TH1* refCopy)
109 {
110 m_refCopy.reset(refCopy); // Assumes ownership of refCopy
111 }
112
116 TH1* getReference(void);
117
118 private:
121 void makeReferenceCopy(void);
122 };
124}
Class to keep track of reference histograms with the original.
Definition: RefHistObject.h:22
std::string m_refhist_name
reference histogram name
Definition: RefHistObject.h:25
std::string m_orghist_name
online histogram name
Definition: RefHistObject.h:24
RefHistObject(void)
Constructor.
Definition: RefHistObject.h:34
TCanvas * getCanvas(void)
Get canvas pointer.
Definition: RefHistObject.h:77
void setRefCopy(TH1 *refCopy)
set scaled ref hist pointer
RefHistObject & operator=(RefHistObject &&other) noexcept
Move assignment operator.
Definition: RefHistObject.h:53
std::unique_ptr< TCanvas > m_canvas
canvas where we draw the histogram
Definition: RefHistObject.h:26
TH1 * getRefHist(void)
Get ref hist pointer.
Definition: RefHistObject.h:82
std::unique_ptr< TH1 > m_refCopy
Pointer to scaled reference histogram.
Definition: RefHistObject.h:28
void resetBeforeEvent(void)
Reset histogram and update flag, not the entries.
void setRefHist(TH1 *refHist)
set ref hist pointer
void setCanvas(TCanvas *canvas)
Set canvas pointer.
Definition: RefHistObject.h:92
std::unique_ptr< TH1 > m_refHist
Pointer to reference histogram.
Definition: RefHistObject.h:27
RefHistObject(RefHistObject &&other) noexcept
Move constructor.
Definition: RefHistObject.h:38
TH1 * getReference(void)
Get reference pointer for copy.
void makeReferenceCopy(void)
Make a reference copy.
TH1 * getRefCopy(void)
Get scaled ref hist pointer.
Definition: RefHistObject.h:87
Abstract base class for different kinds of events.