GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
GHSym.h
Go to the documentation of this file.
1#ifndef GHSYM_H
2#define GHSYM_H
3
4#include "TH1.h"
5#include "TH2.h"
6#include "TArrayF.h"
7#include "TArrayD.h"
8#include "TProfile.h"
9#include "TF1.h"
10#include "TRandom.h"
11
12class GHSym : public TH1 {
13public:
14 GHSym();
15 GHSym(const char* name, const char* title, Int_t nbins, Double_t low, Double_t up);
16 GHSym(const char* name, const char* title, Int_t nbins, const Double_t* bins);
17 GHSym(const char* name, const char* title, Int_t nbins, const Float_t* bins);
18 GHSym(const GHSym&);
19 GHSym(GHSym&&) noexcept;
21 GHSym& operator=(GHSym&&) noexcept;
22
23 ~GHSym() = default;
24
25 Int_t BufferEmpty(Int_t action = 0) override;
26 Int_t BufferFill(Double_t, Double_t) override { return -2; } // MayNotUse
27 virtual Int_t BufferFill(Double_t x, Double_t y, Double_t w);
28 void Copy(TObject& obj) const override;
29 Int_t Fill(Double_t) override; // MayNotUse
30 Int_t Fill(const char*, Double_t) override { return Fill(0); } // MayNotUse
31 Int_t Fill(Double_t x, Double_t y) override;
32 virtual Int_t Fill(Double_t x, Double_t y, Double_t w);
33 virtual Int_t Fill(const char* namex, const char* namey, Double_t w);
34 void FillN(Int_t, const Double_t*, const Double_t*, Int_t) override { ; } // MayNotUse
35 void FillN(Int_t ntimes, const Double_t* x, const Double_t* y, const Double_t* w, Int_t stride = 1) override;
36#if ROOT_VERSION_CODE < ROOT_VERSION(6, 24, 0)
37 void FillRandom(const char* fname, Int_t ntimes = 5000) override
38 {
39 FillRandom(fname, ntimes, nullptr);
40 }
41 void FillRandom(TH1* h, Int_t ntimes = 5000) override { FillRandom(h, ntimes, nullptr); }
42 void FillRandom(const char* fname, Int_t ntimes = 5000, TRandom* rng = nullptr);
43 void FillRandom(TH1* h, Int_t ntimes = 5000, TRandom* rng = nullptr);
44#else
45 void FillRandom(const char* fname, Int_t ntimes = 5000, TRandom* rng = nullptr) override;
46 void FillRandom(TH1* h, Int_t ntimes = 5000, TRandom* rng = nullptr) override;
47#endif
48#if ROOT_VERSION_CODE < ROOT_VERSION(6, 18, 0)
49 Int_t FindFirstBinAbove(Double_t threshold = 0, Int_t axis = 1) const override
50 {
51 return FindFirstBinAbove(threshold, axis, 1, -1);
52 }
53 Int_t FindLastBinAbove(Double_t threshold = 0, Int_t axis = 1) const override { return FindLastBinAbove(threshold, axis, 1, -1); }
54 Int_t FindFirstBinAbove(Double_t threshold = 0, Int_t axis = 1, Int_t firstBin = 1, Int_t lastBin = -1) const;
55 Int_t FindLastBinAbove(Double_t threshold = 0, Int_t axis = 1, Int_t firstBin = 1, Int_t lastBin = -1) const;
56#else
57 Int_t FindFirstBinAbove(Double_t threshold = 0, Int_t axis = 1, Int_t firstBin = 1, Int_t lastBin = -1) const override;
58 Int_t FindLastBinAbove(Double_t threshold = 0, Int_t axis = 1, Int_t firstBin = 1, Int_t lastBin = -1) const override;
59#endif
60 virtual void FitSlices(TF1* f1 = nullptr, Int_t firstbin = 0, Int_t lastbin = -1, Int_t cut = 0,
61 Option_t* option = "QNR", TObjArray* arr = nullptr);
62 Int_t GetBin(Int_t binx, Int_t biny = 0, Int_t binz = 0) const override;
63 virtual Double_t GetBinWithContent2(Double_t c, Int_t& binx, Int_t& biny, Int_t firstxbin = 1, Int_t lastxbin = -1,
64 Int_t firstybin = 1, Int_t lastybin = -1, Double_t maxdiff = 0) const;
65 Double_t GetCellContent(Int_t binx, Int_t biny) const override;
66 Double_t GetCellError(Int_t binx, Int_t biny) const override;
67 virtual Double_t GetCorrelationFactor(Int_t axis1 = 1, Int_t axis2 = 2) const;
68 virtual Double_t GetCovariance(Int_t axis1 = 1, Int_t axis2 = 2) const;
69 virtual void GetRandom2(Double_t& x, Double_t& y);
70 void GetStats(Double_t* stats) const override;
71 Double_t Integral(Option_t* option = "") const override;
72 using TH1::Integral;
73 virtual Double_t Integral(Int_t firstxbin, Int_t lastxbin, Int_t firstybin, Int_t lastybin,
74 Option_t* option = "") const;
75 virtual Double_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Option_t* = "") const { return 0; }
76 using TH1::IntegralAndError;
77 virtual Double_t IntegralAndError(Int_t firstxbin, Int_t lastxbin, Int_t firstybin, Int_t lastybin, Double_t& error,
78 Option_t* option = "") const;
79#if ROOT_VERSION_CODE < ROOT_VERSION(6, 20, 0)
80 Double_t Interpolate(Double_t) override;
81 Double_t Interpolate(Double_t, Double_t) override;
82 Double_t Interpolate(Double_t, Double_t, Double_t) override;
83#else
84 Double_t Interpolate(Double_t) const override;
85 Double_t Interpolate(Double_t, Double_t) const override;
86 Double_t Interpolate(Double_t, Double_t, Double_t) const override;
87#endif
88 Double_t KolmogorovTest(const TH1* h2, Option_t* option = "") const override;
89 Long64_t Merge(TCollection* list) override;
90 virtual TProfile* Profile(const char* name = "_pf", Int_t firstbin = 1, Int_t lastbin = -1,
91 Option_t* option = "") const;
92 virtual TH1D* Projection(const char* name = "_pr", Int_t firstBin = 0, Int_t lastBin = -1,
93 Option_t* option = "") const;
94 void PutStats(Double_t* stats) override;
95 virtual GHSym* Rebin2D(Int_t ngroup = 2, const char* newname = "");
96 void Reset(Option_t* option = "") override;
97 void SetCellContent(Int_t binx, Int_t biny, Double_t content) override;
98 void SetCellError(Int_t binx, Int_t biny, Double_t content) override;
99 virtual void SetShowProjectionX(Int_t nbins = 1); // *MENU*
100 virtual void SetShowProjectionY(Int_t nbins = 1); // *MENU*
101 TH1* ShowBackground(Int_t niter = 20, Option_t* option = "same") override;
102 Int_t ShowPeaks(Double_t sigma = 2, Option_t* option = "", Double_t threshold = 0.05) override; // *MENU*
103 void Smooth(Int_t ntimes = 1, Option_t* option = "") override; // *MENU*
104
105protected:
106 using TH1::DoIntegral;
107 virtual Double_t DoIntegral(Int_t binx1, Int_t binx2, Int_t biny1, Int_t biny2, Double_t& error, Option_t* option,
108 Bool_t doError = kFALSE) const;
109
110 TH2* Matrix() { return fMatrix; }
111 void Matrix(TH2* val) { fMatrix = val; }
112
113private:
114 Double_t fTsumwy{0.}; ///< Total Sum of weight*Y
115 Double_t fTsumwy2{0.}; ///< Total Sum of weight*Y*Y
116 Double_t fTsumwxy{0.}; ///< Total Sum of weight*X*Y
117 TH2* fMatrix{nullptr}; //!<! Transient pointer to the 2D-Matrix used in Draw() or GetMatrix()
118
119 /// /cond CLASSIMP
120 ClassDefOverride(GHSym, 1) // NOLINT(readability-else-after-return)
121 /// /endcond
122};
123
124class GHSymF : public GHSym, public TArrayF {
125public:
126 GHSymF();
127 GHSymF(const char* name, const char* title, Int_t nbins, Double_t low, Double_t up);
128 GHSymF(const char* name, const char* title, Int_t nbins, const Double_t* bins);
129 GHSymF(const char* name, const char* title, Int_t nbins, const Float_t* bins);
130 GHSymF(const GHSymF&);
131 GHSymF(GHSymF&&) noexcept;
133
134 TH2F* GetMatrix(bool force = false);
135
136 void AddBinContent(Int_t bin) override { ++fArray[bin]; }
137 void AddBinContent(Int_t bin, Double_t w) override { fArray[bin] += static_cast<Float_t>(w); }
138 void Copy(TObject& rh) const override;
139 void Draw(Option_t* option = "") override { GetMatrix()->Draw(option); }
140 TH1* DrawCopy(Option_t* option = "", const char* name_postfix = "_copy") const override;
141 Double_t GetBinContent(Int_t bin) const override;
142 Double_t GetBinContent(Int_t binx, Int_t biny) const override { return GetBinContent(GetBin(binx, biny)); }
143 Double_t GetBinContent(Int_t binx, Int_t biny, Int_t) const override { return GetBinContent(GetBin(binx, biny)); }
144 void Reset(Option_t* option = "") override;
145 Double_t RetrieveBinContent(Int_t bin) const override { return static_cast<Double_t>(fArray[bin]); }
146 void SetBinContent(Int_t bin, Double_t content) override;
147 void SetBinContent(Int_t binx, Int_t biny, Double_t content) override { SetBinContent(GetBin(binx, biny), content); }
148 void SetBinContent(Int_t binx, Int_t biny, Int_t, Double_t content) override
149 {
150 SetBinContent(GetBin(binx, biny), content);
151 }
152 void SetBinsLength(Int_t n = -1) override;
153 void UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = static_cast<Float_t>(content); }
154 GHSymF& operator=(const GHSymF& h1);
155 GHSymF& operator=(GHSymF&&) noexcept;
156 friend GHSymF operator*(Float_t c1, GHSymF& h1);
157 friend GHSymF operator*(GHSymF& h1, Float_t c1) { return operator*(c1, h1); }
158 friend GHSymF operator+(GHSymF& h1, GHSymF& h2);
159 friend GHSymF operator-(GHSymF& h1, GHSymF& h2);
160 friend GHSymF operator*(GHSymF& h1, GHSymF& h2);
161 friend GHSymF operator/(GHSymF& h1, GHSymF& h2);
162
163 /// /cond CLASSIMP
164 ClassDefOverride(GHSymF, 1) // NOLINT(readability-else-after-return)
165 /// /endcond
166};
167
168class GHSymD : public GHSym, public TArrayD {
169public:
170 GHSymD();
171 GHSymD(const char* name, const char* title, Int_t nbins, Double_t low, Double_t up);
172 GHSymD(const char* name, const char* title, Int_t nbins, const Double_t* bins);
173 GHSymD(const char* name, const char* title, Int_t nbins, const Float_t* bins);
174 GHSymD(const GHSymD&);
175 GHSymD(GHSymD&&) noexcept;
177
178 TH2D* GetMatrix(bool force = false);
179
180 void AddBinContent(Int_t bin) override { ++fArray[bin]; }
181 void AddBinContent(Int_t bin, Double_t w) override { fArray[bin] += w; }
182 void Copy(TObject& rh) const override;
183 TH1* DrawCopy(Option_t* option = "", const char* name_postfix = "_copy") const override;
184 void Draw(Option_t* option = "") override { GetMatrix()->Draw(option); }
185 Double_t GetBinContent(Int_t bin) const override;
186 Double_t GetBinContent(Int_t binx, Int_t biny) const override { return GetBinContent(GetBin(binx, biny)); }
187 Double_t GetBinContent(Int_t binx, Int_t biny, Int_t) const override { return GetBinContent(GetBin(binx, biny)); }
188 void Reset(Option_t* option = "") override;
189 Double_t RetrieveBinContent(Int_t bin) const override { return static_cast<Double_t>(fArray[bin]); }
190 void SetBinContent(Int_t bin, Double_t content) override;
191 void SetBinContent(Int_t binx, Int_t biny, Double_t content) override { SetBinContent(GetBin(binx, biny), content); }
192 void SetBinContent(Int_t binx, Int_t biny, Int_t, Double_t content) override
193 {
194 SetBinContent(GetBin(binx, biny), content);
195 }
196 void SetBinsLength(Int_t n = -1) override;
197 void UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = content; }
198 GHSymD& operator=(const GHSymD& h1);
199 GHSymD& operator=(GHSymD&&) noexcept;
200 friend GHSymD operator*(Float_t c1, GHSymD& h1);
201 friend GHSymD operator*(GHSymD& h1, Float_t c1) { return operator*(c1, h1); }
202 friend GHSymD operator+(GHSymD& h1, GHSymD& h2);
203 friend GHSymD operator-(GHSymD& h1, GHSymD& h2);
204 friend GHSymD operator*(GHSymD& h1, GHSymD& h2);
205 friend GHSymD operator/(GHSymD& h1, GHSymD& h2);
206
207 /// /cond CLASSIMP
208 ClassDefOverride(GHSymD, 1) // NOLINT(readability-else-after-return)
209 /// /endcond
210};
211#endif
Double_t GetBinContent(Int_t bin) const override
Definition GHSym.cxx:3036
TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const override
Definition GHSym.cxx:3019
GHSymD()
Definition GHSym.cxx:2942
friend GHSymD operator+(GHSymD &h1, GHSymD &h2)
Definition GHSym.cxx:3119
void AddBinContent(Int_t bin) override
Definition GHSym.h:180
void SetBinContent(Int_t binx, Int_t biny, Int_t, Double_t content) override
Definition GHSym.h:192
TH2D * GetMatrix(bool force=false)
Definition GHSym.cxx:2993
void Reset(Option_t *option="") override
Definition GHSym.cxx:3054
void AddBinContent(Int_t bin, Double_t w) override
Definition GHSym.h:181
Double_t RetrieveBinContent(Int_t bin) const override
Definition GHSym.h:189
void Copy(TObject &rh) const override
Definition GHSym.cxx:3014
void UpdateBinContent(Int_t bin, Double_t content) override
Definition GHSym.h:197
void Draw(Option_t *option="") override
Definition GHSym.h:184
void SetBinContent(Int_t binx, Int_t biny, Double_t content) override
Definition GHSym.h:191
void SetBinsLength(Int_t n=-1) override
Definition GHSym.cxx:3077
GHSymD & operator=(const GHSymD &h1)
Definition GHSym.cxx:3089
friend GHSymD operator/(GHSymD &h1, GHSymD &h2)
Definition GHSym.cxx:3149
friend GHSymD operator*(GHSymD &h1, Float_t c1)
Definition GHSym.h:201
friend GHSymD operator*(Float_t c1, GHSymD &h1)
Definition GHSym.cxx:3109
Double_t GetBinContent(Int_t binx, Int_t biny, Int_t) const override
Definition GHSym.h:187
Double_t GetBinContent(Int_t binx, Int_t biny) const override
Definition GHSym.h:186
friend GHSymD operator-(GHSymD &h1, GHSymD &h2)
Definition GHSym.cxx:3129
void SetBinContent(Int_t bin, Double_t content) override
Definition GHSym.cxx:3063
Double_t GetBinContent(Int_t bin) const override
Definition GHSym.cxx:2814
void SetBinsLength(Int_t n=-1) override
Definition GHSym.cxx:2856
GHSymF & operator=(const GHSymF &h1)
Definition GHSym.cxx:2868
void AddBinContent(Int_t bin, Double_t w) override
Definition GHSym.h:137
void Draw(Option_t *option="") override
Definition GHSym.h:139
Double_t GetBinContent(Int_t binx, Int_t biny, Int_t) const override
Definition GHSym.h:143
Double_t GetBinContent(Int_t binx, Int_t biny) const override
Definition GHSym.h:142
void SetBinContent(Int_t binx, Int_t biny, Double_t content) override
Definition GHSym.h:147
friend GHSymF operator/(GHSymF &h1, GHSymF &h2)
Definition GHSym.cxx:2928
void Reset(Option_t *option="") override
Definition GHSym.cxx:2833
friend GHSymF operator+(GHSymF &h1, GHSymF &h2)
Definition GHSym.cxx:2898
friend GHSymF operator*(GHSymF &h1, Float_t c1)
Definition GHSym.h:157
void SetBinContent(Int_t bin, Double_t content) override
Definition GHSym.cxx:2842
void AddBinContent(Int_t bin) override
Definition GHSym.h:136
TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const override
Definition GHSym.cxx:2797
TH2F * GetMatrix(bool force=false)
Definition GHSym.cxx:2772
Double_t RetrieveBinContent(Int_t bin) const override
Definition GHSym.h:145
void Copy(TObject &rh) const override
Definition GHSym.cxx:2792
void SetBinContent(Int_t binx, Int_t biny, Int_t, Double_t content) override
Definition GHSym.h:148
GHSymF()
Definition GHSym.cxx:2721
friend GHSymF operator-(GHSymF &h1, GHSymF &h2)
Definition GHSym.cxx:2908
void UpdateBinContent(Int_t bin, Double_t content) override
Definition GHSym.h:153
friend GHSymF operator*(Float_t c1, GHSymF &h1)
Definition GHSym.cxx:2888
Definition GHSym.h:12
virtual Double_t DoIntegral(Int_t binx1, Int_t binx2, Int_t biny1, Int_t biny2, Double_t &error, Option_t *option, Bool_t doError=kFALSE) const
Definition GHSym.cxx:214
Double_t Integral(Option_t *option="") const override
Definition GHSym.cxx:1079
Long64_t Merge(TCollection *list) override
Definition GHSym.cxx:1448
virtual Double_t GetCovariance(Int_t axis1=1, Int_t axis2=2) const
Definition GHSym.cxx:922
Double_t fTsumwy
Total Sum of weight*Y.
Definition GHSym.h:114
void Copy(TObject &obj) const override
Definition GHSym.cxx:203
virtual Double_t GetBinWithContent2(Double_t c, Int_t &binx, Int_t &biny, Int_t firstxbin=1, Int_t lastxbin=-1, Int_t firstybin=1, Int_t lastybin=-1, Double_t maxdiff=0) const
Definition GHSym.cxx:834
virtual TProfile * Profile(const char *name="_pf", Int_t firstbin=1, Int_t lastbin=-1, Option_t *option="") const
Definition GHSym.cxx:1720
Double_t KolmogorovTest(const TH1 *h2, Option_t *option="") const override
Definition GHSym.cxx:1232
void SetCellError(Int_t binx, Int_t biny, Double_t content) override
Definition GHSym.cxx:2546
void FillRandom(const char *fname, Int_t ntimes=5000, TRandom *rng=nullptr) override
Definition GHSym.cxx:459
void GetStats(Double_t *stats) const override
Definition GHSym.cxx:996
void Matrix(TH2 *val)
Definition GHSym.h:111
void PutStats(Double_t *stats) override
Definition GHSym.cxx:2198
TH2 * fMatrix
! Transient pointer to the 2D-Matrix used in Draw() or GetMatrix()
Definition GHSym.h:117
Int_t BufferFill(Double_t, Double_t) override
Definition GHSym.h:26
void Reset(Option_t *option="") override
Definition GHSym.cxx:2516
void Smooth(Int_t ntimes=1, Option_t *option="") override
Definition GHSym.cxx:2602
TH1 * ShowBackground(Int_t niter=20, Option_t *option="same") override
Definition GHSym.cxx:2579
virtual Double_t IntegralAndError(Int_t firstxbin, Int_t lastxbin, Int_t firstybin, Int_t lastybin, Double_t &error, Option_t *option="") const
Definition GHSym.cxx:1100
virtual Double_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Option_t *="") const
Definition GHSym.h:75
TH2 * Matrix()
Definition GHSym.h:110
virtual Double_t GetCorrelationFactor(Int_t axis1=1, Int_t axis2=2) const
Definition GHSym.cxx:900
virtual void SetShowProjectionY(Int_t nbins=1)
Definition GHSym.cxx:2565
Double_t fTsumwy2
Total Sum of weight*Y*Y.
Definition GHSym.h:115
Int_t Fill(Double_t) override
Definition GHSym.cxx:281
Int_t BufferEmpty(Int_t action=0) override
Definition GHSym.cxx:77
Int_t Fill(const char *, Double_t) override
Definition GHSym.h:30
Double_t Interpolate(Double_t) const override
Definition GHSym.cxx:1116
virtual TH1D * Projection(const char *name="_pr", Int_t firstBin=0, Int_t lastBin=-1, Option_t *option="") const
Definition GHSym.cxx:1957
Int_t ShowPeaks(Double_t sigma=2, Option_t *option="", Double_t threshold=0.05) override
Definition GHSym.cxx:2589
void FillN(Int_t, const Double_t *, const Double_t *, Int_t) override
Definition GHSym.h:34
Double_t GetCellError(Int_t binx, Int_t biny) const override
Definition GHSym.cxx:895
Int_t GetBin(Int_t binx, Int_t biny=0, Int_t binz=0) const override
Definition GHSym.cxx:813
GHSym & operator=(const GHSym &)
virtual GHSym * Rebin2D(Int_t ngroup=2, const char *newname="")
Definition GHSym.cxx:2207
GHSym & operator=(GHSym &&) noexcept
virtual void FitSlices(TF1 *f1=nullptr, Int_t firstbin=0, Int_t lastbin=-1, Int_t cut=0, Option_t *option="QNR", TObjArray *arr=nullptr)
Definition GHSym.cxx:640
Int_t FindFirstBinAbove(Double_t threshold=0, Int_t axis=1, Int_t firstBin=1, Int_t lastBin=-1) const override
Definition GHSym.cxx:574
Int_t FindLastBinAbove(Double_t threshold=0, Int_t axis=1, Int_t firstBin=1, Int_t lastBin=-1) const override
Definition GHSym.cxx:607
void SetCellContent(Int_t binx, Int_t biny, Double_t content) override
Definition GHSym.cxx:2541
Double_t GetCellContent(Int_t binx, Int_t biny) const override
Definition GHSym.cxx:890
virtual void GetRandom2(Double_t &x, Double_t &y)
Definition GHSym.cxx:953
virtual void SetShowProjectionX(Int_t nbins=1)
Definition GHSym.cxx:2551
GHSym()
Definition GHSym.cxx:30
Double_t fTsumwxy
Total Sum of weight*X*Y.
Definition GHSym.h:116