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#elif ROOT_VERSION_CODE < ROOT_VERSION(6, 36, 0)
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#else
48 void FillRandom(const char* fname, Int_t ntimes = 5000, TRandom* rng = nullptr);
49 void FillRandom(TH1* h, Int_t ntimes = 5000, TRandom* rng = nullptr) override;
50#endif
51#if ROOT_VERSION_CODE < ROOT_VERSION(6, 18, 0)
52 Int_t FindFirstBinAbove(Double_t threshold = 0, Int_t axis = 1) const override
53 {
54 return FindFirstBinAbove(threshold, axis, 1, -1);
55 }
56 Int_t FindLastBinAbove(Double_t threshold = 0, Int_t axis = 1) const override { return FindLastBinAbove(threshold, axis, 1, -1); }
57 Int_t FindFirstBinAbove(Double_t threshold = 0, Int_t axis = 1, Int_t firstBin = 1, Int_t lastBin = -1) const;
58 Int_t FindLastBinAbove(Double_t threshold = 0, Int_t axis = 1, Int_t firstBin = 1, Int_t lastBin = -1) const;
59#else
60 Int_t FindFirstBinAbove(Double_t threshold = 0, Int_t axis = 1, Int_t firstBin = 1, Int_t lastBin = -1) const override;
61 Int_t FindLastBinAbove(Double_t threshold = 0, Int_t axis = 1, Int_t firstBin = 1, Int_t lastBin = -1) const override;
62#endif
63 virtual void FitSlices(TF1* f1 = nullptr, Int_t firstbin = 0, Int_t lastbin = -1, Int_t cut = 0,
64 Option_t* option = "QNR", TObjArray* arr = nullptr);
65 Int_t GetBin(Int_t binx, Int_t biny = 0, Int_t binz = 0) const override;
66 virtual Double_t GetBinWithContent2(Double_t c, Int_t& binx, Int_t& biny, Int_t firstxbin = 1, Int_t lastxbin = -1,
67 Int_t firstybin = 1, Int_t lastybin = -1, Double_t maxdiff = 0) const;
68 Double_t GetCellContent(Int_t binx, Int_t biny) const override;
69 Double_t GetCellError(Int_t binx, Int_t biny) const override;
70 virtual Double_t GetCorrelationFactor(Int_t axis1 = 1, Int_t axis2 = 2) const;
71 virtual Double_t GetCovariance(Int_t axis1 = 1, Int_t axis2 = 2) const;
72 virtual void GetRandom2(Double_t& x, Double_t& y);
73 void GetStats(Double_t* stats) const override;
74 Double_t Integral(Option_t* option = "") const override;
75 using TH1::Integral;
76 virtual Double_t Integral(Int_t firstxbin, Int_t lastxbin, Int_t firstybin, Int_t lastybin,
77 Option_t* option = "") const;
78 virtual Double_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Option_t* = "") const { return 0; }
79 using TH1::IntegralAndError;
80 virtual Double_t IntegralAndError(Int_t firstxbin, Int_t lastxbin, Int_t firstybin, Int_t lastybin, Double_t& error,
81 Option_t* option = "") const;
82#if ROOT_VERSION_CODE < ROOT_VERSION(6, 20, 0)
83 Double_t Interpolate(Double_t) override;
84 Double_t Interpolate(Double_t, Double_t) override;
85 Double_t Interpolate(Double_t, Double_t, Double_t) override;
86#else
87 Double_t Interpolate(Double_t) const override;
88 Double_t Interpolate(Double_t, Double_t) const override;
89 Double_t Interpolate(Double_t, Double_t, Double_t) const override;
90#endif
91 Double_t KolmogorovTest(const TH1* h2, Option_t* option = "") const override;
92 Long64_t Merge(TCollection* list) override;
93 virtual TProfile* Profile(const char* name = "_pf", Int_t firstbin = 1, Int_t lastbin = -1,
94 Option_t* option = "") const;
95 virtual TH1D* Projection(const char* name = "_pr", Int_t firstBin = 0, Int_t lastBin = -1,
96 Option_t* option = "") const;
97 void PutStats(Double_t* stats) override;
98 virtual GHSym* Rebin2D(Int_t ngroup = 2, const char* newname = "");
99 void Reset(Option_t* option = "") override;
100 void SetCellContent(Int_t binx, Int_t biny, Double_t content) override;
101 void SetCellError(Int_t binx, Int_t biny, Double_t content) override;
102 virtual void SetShowProjectionX(Int_t nbins = 1); // *MENU*
103 virtual void SetShowProjectionY(Int_t nbins = 1); // *MENU*
104 TH1* ShowBackground(Int_t niter = 20, Option_t* option = "same") override;
105 Int_t ShowPeaks(Double_t sigma = 2, Option_t* option = "", Double_t threshold = 0.05) override; // *MENU*
106 void Smooth(Int_t ntimes = 1, Option_t* option = "") override; // *MENU*
107
108protected:
109 using TH1::DoIntegral;
110 virtual Double_t DoIntegral(Int_t binx1, Int_t binx2, Int_t biny1, Int_t biny2, Double_t& error, Option_t* option,
111 Bool_t doError = kFALSE) const;
112
113 TH2* Matrix() { return fMatrix; }
114 void Matrix(TH2* val) { fMatrix = val; }
115
116private:
117 Double_t fTsumwy{0.}; ///< Total Sum of weight*Y
118 Double_t fTsumwy2{0.}; ///< Total Sum of weight*Y*Y
119 Double_t fTsumwxy{0.}; ///< Total Sum of weight*X*Y
120 TH2* fMatrix{nullptr}; //!<! Transient pointer to the 2D-Matrix used in Draw() or GetMatrix()
121
122 /// /cond CLASSIMP
123 ClassDefOverride(GHSym, 1) // NOLINT(readability-else-after-return)
124 /// /endcond
125};
126
127class GHSymF : public GHSym, public TArrayF {
128public:
129 GHSymF();
130 GHSymF(const char* name, const char* title, Int_t nbins, Double_t low, Double_t up);
131 GHSymF(const char* name, const char* title, Int_t nbins, const Double_t* bins);
132 GHSymF(const char* name, const char* title, Int_t nbins, const Float_t* bins);
133 GHSymF(const GHSymF&);
134 GHSymF(GHSymF&&) noexcept;
136
137 TH2F* GetMatrix(bool force = false);
138
139 void AddBinContent(Int_t bin) override { ++fArray[bin]; }
140 void AddBinContent(Int_t bin, Double_t w) override { fArray[bin] += static_cast<Float_t>(w); }
141 void Copy(TObject& rh) const override;
142 void Draw(Option_t* option = "") override { GetMatrix()->Draw(option); }
143 TH1* DrawCopy(Option_t* option = "", const char* name_postfix = "_copy") const override;
144 Double_t GetBinContent(Int_t bin) const override;
145 Double_t GetBinContent(Int_t binx, Int_t biny) const override { return GetBinContent(GetBin(binx, biny)); }
146 Double_t GetBinContent(Int_t binx, Int_t biny, Int_t) const override { return GetBinContent(GetBin(binx, biny)); }
147 void Reset(Option_t* option = "") override;
148 Double_t RetrieveBinContent(Int_t bin) const override { return static_cast<Double_t>(fArray[bin]); }
149 void SetBinContent(Int_t bin, Double_t content) override;
150 void SetBinContent(Int_t binx, Int_t biny, Double_t content) override { SetBinContent(GetBin(binx, biny), content); }
151 void SetBinContent(Int_t binx, Int_t biny, Int_t, Double_t content) override
152 {
153 SetBinContent(GetBin(binx, biny), content);
154 }
155 void SetBinsLength(Int_t n = -1) override;
156 void UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = static_cast<Float_t>(content); }
157 GHSymF& operator=(const GHSymF& h1);
158 GHSymF& operator=(GHSymF&&) noexcept;
159 friend GHSymF operator*(Float_t c1, GHSymF& h1);
160 friend GHSymF operator*(GHSymF& h1, Float_t c1) { return operator*(c1, h1); }
161 friend GHSymF operator+(GHSymF& h1, GHSymF& h2);
162 friend GHSymF operator-(GHSymF& h1, GHSymF& h2);
163 friend GHSymF operator*(GHSymF& h1, GHSymF& h2);
164 friend GHSymF operator/(GHSymF& h1, GHSymF& h2);
165
166 /// /cond CLASSIMP
167 ClassDefOverride(GHSymF, 1) // NOLINT(readability-else-after-return)
168 /// /endcond
169};
170
171class GHSymD : public GHSym, public TArrayD {
172public:
173 GHSymD();
174 GHSymD(const char* name, const char* title, Int_t nbins, Double_t low, Double_t up);
175 GHSymD(const char* name, const char* title, Int_t nbins, const Double_t* bins);
176 GHSymD(const char* name, const char* title, Int_t nbins, const Float_t* bins);
177 GHSymD(const GHSymD&);
178 GHSymD(GHSymD&&) noexcept;
180
181 TH2D* GetMatrix(bool force = false);
182
183 void AddBinContent(Int_t bin) override { ++fArray[bin]; }
184 void AddBinContent(Int_t bin, Double_t w) override { fArray[bin] += w; }
185 void Copy(TObject& rh) const override;
186 TH1* DrawCopy(Option_t* option = "", const char* name_postfix = "_copy") const override;
187 void Draw(Option_t* option = "") override { GetMatrix()->Draw(option); }
188 Double_t GetBinContent(Int_t bin) const override;
189 Double_t GetBinContent(Int_t binx, Int_t biny) const override { return GetBinContent(GetBin(binx, biny)); }
190 Double_t GetBinContent(Int_t binx, Int_t biny, Int_t) const override { return GetBinContent(GetBin(binx, biny)); }
191 void Reset(Option_t* option = "") override;
192 Double_t RetrieveBinContent(Int_t bin) const override { return static_cast<Double_t>(fArray[bin]); }
193 void SetBinContent(Int_t bin, Double_t content) override;
194 void SetBinContent(Int_t binx, Int_t biny, Double_t content) override { SetBinContent(GetBin(binx, biny), content); }
195 void SetBinContent(Int_t binx, Int_t biny, Int_t, Double_t content) override
196 {
197 SetBinContent(GetBin(binx, biny), content);
198 }
199 void SetBinsLength(Int_t n = -1) override;
200 void UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = content; }
201 GHSymD& operator=(const GHSymD& h1);
202 GHSymD& operator=(GHSymD&&) noexcept;
203 friend GHSymD operator*(Float_t c1, GHSymD& h1);
204 friend GHSymD operator*(GHSymD& h1, Float_t c1) { return operator*(c1, h1); }
205 friend GHSymD operator+(GHSymD& h1, GHSymD& h2);
206 friend GHSymD operator-(GHSymD& h1, GHSymD& h2);
207 friend GHSymD operator*(GHSymD& h1, GHSymD& h2);
208 friend GHSymD operator/(GHSymD& h1, GHSymD& h2);
209
210 /// /cond CLASSIMP
211 ClassDefOverride(GHSymD, 1) // NOLINT(readability-else-after-return)
212 /// /endcond
213};
214#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:183
void SetBinContent(Int_t binx, Int_t biny, Int_t, Double_t content) override
Definition GHSym.h:195
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:184
Double_t RetrieveBinContent(Int_t bin) const override
Definition GHSym.h:192
void Copy(TObject &rh) const override
Definition GHSym.cxx:3014
void UpdateBinContent(Int_t bin, Double_t content) override
Definition GHSym.h:200
void Draw(Option_t *option="") override
Definition GHSym.h:187
void SetBinContent(Int_t binx, Int_t biny, Double_t content) override
Definition GHSym.h:194
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:204
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:190
Double_t GetBinContent(Int_t binx, Int_t biny) const override
Definition GHSym.h:189
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:140
void Draw(Option_t *option="") override
Definition GHSym.h:142
Double_t GetBinContent(Int_t binx, Int_t biny, Int_t) const override
Definition GHSym.h:146
Double_t GetBinContent(Int_t binx, Int_t biny) const override
Definition GHSym.h:145
void SetBinContent(Int_t binx, Int_t biny, Double_t content) override
Definition GHSym.h:150
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:160
void SetBinContent(Int_t bin, Double_t content) override
Definition GHSym.cxx:2842
void AddBinContent(Int_t bin) override
Definition GHSym.h:139
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:148
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:151
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:156
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:117
void Copy(TObject &obj) const override
Definition GHSym.cxx:203
void FillRandom(const char *fname, Int_t ntimes=5000, TRandom *rng=nullptr)
Definition GHSym.cxx:459
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 GetStats(Double_t *stats) const override
Definition GHSym.cxx:996
void Matrix(TH2 *val)
Definition GHSym.h:114
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:120
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:78
TH2 * Matrix()
Definition GHSym.h:113
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:118
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:119