Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TH2.h
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Rene Brun 26/12/94
3
4/*************************************************************************
5 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#ifndef ROOT_TH2
13#define ROOT_TH2
14
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TH2 //
19// //
20// 2-Dim histogram base class. //
21// //
22//////////////////////////////////////////////////////////////////////////
23
24#include "TH1.h"
25#include "TMatrixFBasefwd.h"
26#include "TMatrixDBasefwd.h"
27
28class TProfile;
29
30class TH2 : public TH1 {
31
32protected:
33 Double_t fScalefactor; ///< Scale factor
34 Double_t fTsumwy; ///< Total Sum of weight*Y
35 Double_t fTsumwy2; ///< Total Sum of weight*Y*Y
36 Double_t fTsumwxy; ///< Total Sum of weight*X*Y
37
38 TH2();
39 TH2(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
40 ,Int_t nbinsy,Double_t ylow,Double_t yup);
41 TH2(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
42 ,Int_t nbinsy,Double_t ylow,Double_t yup);
43 TH2(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
44 ,Int_t nbinsy,const Double_t *ybins);
45 TH2(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
46 ,Int_t nbinsy,const Double_t *ybins);
47 TH2(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins
48 ,Int_t nbinsy,const Float_t *ybins);
49
51 virtual TH1D *DoProjection(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const;
52 virtual TProfile *DoProfile(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const;
53 virtual TH1D *DoQuantiles(bool onX, const char *name, Double_t prob) const;
54 virtual void DoFitSlices(bool onX, TF1 *f1, Int_t firstbin, Int_t lastbin, Int_t cut, Option_t *option, TObjArray* arr);
55
56 Int_t BufferFill(Double_t, Double_t) override {return -2;} //may not use
57 Int_t Fill(Double_t) override; //MayNotUse
58 Int_t Fill(const char*, Double_t) override { return Fill(0);} //MayNotUse
59
60 Double_t Interpolate(Double_t x) const override; // may not use
61
62private:
63
64 TH2(const TH2&) = delete;
65 TH2& operator=(const TH2&) = delete;
66
67 // make private methods which have a TH1 signature and should not
68 using TH1::Integral;
70
71public:
72 ~TH2() override;
73 void AddBinContent(Int_t bin) override;
74 void AddBinContent(Int_t bin, Double_t w) override;
75 virtual void AddBinContent(Int_t binx, Int_t biny);
76 virtual void AddBinContent(Int_t binx, Int_t biny, Double_t w);
77 Int_t BufferEmpty(Int_t action=0) override;
78 void Copy(TObject &hnew) const override;
79 Int_t Fill(Double_t x, Double_t y) override;
81 virtual Int_t Fill(Double_t x, const char *namey, Double_t w);
82 virtual Int_t Fill(const char *namex, Double_t y, Double_t w);
83 virtual Int_t Fill(const char *namex, const char *namey, Double_t w);
84 void FillN(Int_t, const Double_t *, const Double_t *, Int_t) override {} //MayNotUse
85 void FillN(Int_t ntimes, const Double_t *x, const Double_t *y, const Double_t *w, Int_t stride=1) override;
86 using TH1::FillRandom;
87 void FillRandom(TF1 *f1, Int_t ntimes=5000, TRandom *rng = nullptr) override;
88 void FillRandom(TH1 *h, Int_t ntimes=5000, TRandom *rng = nullptr) override;
89 virtual void FitSlicesX(TF1 *f1 = nullptr, Int_t firstybin=0, Int_t lastybin=-1, Int_t cut=0, Option_t *option="QNR", TObjArray* arr = nullptr);
90 virtual void FitSlicesY(TF1 *f1 = nullptr, Int_t firstxbin=0, Int_t lastxbin=-1, Int_t cut=0, Option_t *option="QNR", TObjArray* arr = nullptr);
91 Int_t GetBin(Int_t binx, Int_t biny, Int_t binz = 0) const override;
92 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;
94 Double_t GetBinContent(Int_t binx, Int_t biny) const override { return TH1::GetBinContent( GetBin(binx, biny) ); }
95 Double_t GetBinContent(Int_t binx, Int_t biny, Int_t) const override { return TH1::GetBinContent( GetBin(binx, biny) ); }
98 virtual Double_t GetBinErrorLow(Int_t binx, Int_t biny) { return TH1::GetBinErrorLow( GetBin(binx, biny) ); }
99 virtual Double_t GetBinErrorUp(Int_t binx, Int_t biny) { return TH1::GetBinErrorUp( GetBin(binx, biny) ); }
100 virtual Double_t GetCorrelationFactor(Int_t axis1=1,Int_t axis2=2) const;
101 virtual Double_t GetCovariance(Int_t axis1=1,Int_t axis2=2) const;
102 virtual void GetRandom2(Double_t &x, Double_t &y, TRandom * rng = nullptr);
103 void GetStats(Double_t *stats) const override;
104 Double_t Integral(Option_t *option="") const override;
105 //virtual Double_t Integral(Int_t, Int_t, Option_t * ="") const {return 0;}
106 virtual Double_t Integral(Int_t binx1, Int_t binx2, Int_t biny1, Int_t biny2, Option_t *option="") const;
107 virtual Double_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Option_t * ="") const {return 0;}
108 virtual Double_t IntegralAndError(Int_t binx1, Int_t binx2, Int_t biny1, Int_t biny2, Double_t & err, Option_t *option="") const;
109 Double_t Interpolate(Double_t x, Double_t y) const override;
110 Double_t Interpolate(Double_t x, Double_t y, Double_t z) const override;
111 Double_t KolmogorovTest(const TH1 *h2, Option_t *option="") const override;
112 TH2 *RebinX(Int_t ngroup=2, const char *newname="") override; // *MENU*
113 virtual TH2 *RebinY(Int_t ngroup=2, const char *newname=""); // *MENU*
114 TH2 *Rebin(Int_t ngroup=2, const char*newname="", const Double_t *xbins = nullptr) override; // re-implementation of the TH1 function using RebinX
115 virtual TH2 *Rebin2D(Int_t nxgroup=2, Int_t nygroup=2, const char *newname=""); // *MENU*
116 TProfile *ProfileX(const char *name="_pfx", Int_t firstybin=1, Int_t lastybin=-1, Option_t *option="") const; // *MENU*
117 TProfile *ProfileY(const char *name="_pfy", Int_t firstxbin=1, Int_t lastxbin=-1, Option_t *option="") const; // *MENU*
118 TH1D *ProjectionX(const char *name="_px", Int_t firstybin=0, Int_t lastybin=-1, Option_t *option="") const; // *MENU*
119 TH1D *ProjectionY(const char *name="_py", Int_t firstxbin=0, Int_t lastxbin=-1, Option_t *option="") const; // *MENU*
120 void PutStats(Double_t *stats) override;
121 TH1D *QuantilesX(Double_t prob = 0.5, const char * name = "_qx" ) const;
122 TH1D *QuantilesY(Double_t prob = 0.5, const char * name = "_qy" ) const;
123 void Reset(Option_t *option="") override;
124 void SetBinContent(Int_t bin, Double_t content) override;
125 void SetBinContent(Int_t binx, Int_t biny, Double_t content) override { SetBinContent(GetBin(binx, biny), content); }
126 void SetBinContent(Int_t binx, Int_t biny, Int_t, Double_t content) override { SetBinContent(GetBin(binx, biny), content); }
127 virtual void SetShowProjectionX(Int_t nbins=1); // *MENU*
128 virtual void SetShowProjectionY(Int_t nbins=1); // *MENU*
129 virtual void SetShowProjectionXY(Int_t nbinsY=1, Int_t nbinsX=1); // *MENU*
130 TH1 *ShowBackground(Int_t niter=20, Option_t *option="same") override;
131 Int_t ShowPeaks(Double_t sigma=2, Option_t *option="", Double_t threshold=0.05) override; // *MENU*
132 void Smooth(Int_t ntimes=1, Option_t *option="") override; // *MENU*
133
134 ClassDefOverride(TH2,5) //2-Dim histogram base class
135};
136
137
138//______________________________________________________________________________
139
140class TH2C : public TH2, public TArrayC {
141
142public:
143 TH2C();
144 TH2C(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
145 ,Int_t nbinsy,Double_t ylow,Double_t yup);
146 TH2C(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
147 ,Int_t nbinsy,Double_t ylow,Double_t yup);
148 TH2C(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
149 ,Int_t nbinsy,const Double_t *ybins);
150 TH2C(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
151 ,Int_t nbinsy,const Double_t *ybins);
152 TH2C(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins
153 ,Int_t nbinsy,const Float_t *ybins);
154 TH2C(const TH2C &h2c);
155 ~TH2C() override;
156
157 void AddBinContent(Int_t bin) override;
158 void AddBinContent(Int_t bin, Double_t w) override;
159 void AddBinContent(Int_t binx, Int_t biny) override { AddBinContent(GetBin(binx, biny)); }
160 void AddBinContent(Int_t binx, Int_t biny, Double_t w) override { AddBinContent(GetBin(binx, biny), w); }
161 void Copy(TObject &hnew) const override;
162 void Reset(Option_t *option="") override;
163 void SetBinsLength(Int_t n=-1) override;
164
165 TH2C& operator=(const TH2C &h1);
166 friend TH2C operator*(Float_t c1, TH2C const &h1);
167 friend TH2C operator*(TH2C const &h1, Float_t c1) {return operator*(c1,h1);}
168 friend TH2C operator+(TH2C const &h1, TH2C const &h2);
169 friend TH2C operator-(TH2C const &h1, TH2C const &h2);
170 friend TH2C operator*(TH2C const &h1, TH2C const &h2);
171 friend TH2C operator/(TH2C const &h1, TH2C const &h2);
172
173protected:
174 Double_t RetrieveBinContent(Int_t bin) const override { return Double_t (fArray[bin]); }
175 void UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = Char_t (content); }
176
177 ClassDefOverride(TH2C,4) //2-Dim histograms (one char per channel)
178};
179
180
181//______________________________________________________________________________
182
183class TH2S : public TH2, public TArrayS {
184
185public:
186 TH2S();
187 TH2S(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
188 ,Int_t nbinsy,Double_t ylow,Double_t yup);
189 TH2S(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
190 ,Int_t nbinsy,Double_t ylow,Double_t yup);
191 TH2S(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
192 ,Int_t nbinsy,const Double_t *ybins);
193 TH2S(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
194 ,Int_t nbinsy,const Double_t *ybins);
195 TH2S(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins
196 ,Int_t nbinsy,const Float_t *ybins);
197 TH2S(const TH2S &h2s);
198 ~TH2S() override;
199
200 void AddBinContent(Int_t bin) override;
201 void AddBinContent(Int_t bin, Double_t w) override;
202 void AddBinContent(Int_t binx, Int_t biny) override { AddBinContent(GetBin(binx, biny)); }
203 void AddBinContent(Int_t binx, Int_t biny, Double_t w) override { AddBinContent(GetBin(binx, biny), w); }
204 void Copy(TObject &hnew) const override;
205 void Reset(Option_t *option="") override;
206 void SetBinsLength(Int_t n=-1) override;
207
208 TH2S& operator=(const TH2S &h1);
209 friend TH2S operator*(Float_t c1, TH2S const &h1);
210 friend TH2S operator*(TH2S const &h1, Float_t c1) {return operator*(c1,h1);}
211 friend TH2S operator+(TH2S const &h1, TH2S const &h2);
212 friend TH2S operator-(TH2S const &h1, TH2S const &h2);
213 friend TH2S operator*(TH2S const &h1, TH2S const &h2);
214 friend TH2S operator/(TH2S const &h1, TH2S const &h2);
215
216protected:
217 Double_t RetrieveBinContent(Int_t bin) const override { return Double_t (fArray[bin]); }
218 void UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = Short_t (content); }
219
220 ClassDefOverride(TH2S,4) //2-Dim histograms (one short per channel)
221};
222
223
224//______________________________________________________________________________
225
226class TH2I : public TH2, public TArrayI {
227
228public:
229 TH2I();
230 TH2I(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
231 ,Int_t nbinsy,Double_t ylow,Double_t yup);
232 TH2I(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
233 ,Int_t nbinsy,Double_t ylow,Double_t yup);
234 TH2I(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
235 ,Int_t nbinsy,const Double_t *ybins);
236 TH2I(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
237 ,Int_t nbinsy,const Double_t *ybins);
238 TH2I(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins
239 ,Int_t nbinsy,const Float_t *ybins);
240 TH2I(const TH2I &h2i);
241 ~TH2I() override;
242
243 void AddBinContent(Int_t bin) override;
244 void AddBinContent(Int_t bin, Double_t w) override;
245 void AddBinContent(Int_t binx, Int_t biny) override { AddBinContent(GetBin(binx, biny)); }
246 void AddBinContent(Int_t binx, Int_t biny, Double_t w) override { AddBinContent(GetBin(binx, biny), w); }
247 void Copy(TObject &hnew) const override;
248 void Reset(Option_t *option="") override;
249 void SetBinsLength(Int_t n=-1) override;
250
251 TH2I& operator=(const TH2I &h1);
252 friend TH2I operator*(Float_t c1, TH2I const &h1);
253 friend TH2I operator*(TH2I const &h1, Float_t c1) {return operator*(c1,h1);}
254 friend TH2I operator+(TH2I const &h1, TH2I const &h2);
255 friend TH2I operator-(TH2I const &h1, TH2I const &h2);
256 friend TH2I operator*(TH2I const &h1, TH2I const &h2);
257 friend TH2I operator/(TH2I const &h1, TH2I const &h2);
258
259protected:
260 Double_t RetrieveBinContent(Int_t bin) const override { return Double_t (fArray[bin]); }
261 void UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = Int_t (content); }
262
263 ClassDefOverride(TH2I,4) //2-Dim histograms (one 32 bit integer per channel)
264};
265
266//______________________________________________________________________________
267
268class TH2L : public TH2, public TArrayL64 {
269
270public:
271 TH2L();
272 TH2L(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
273 ,Int_t nbinsy,Double_t ylow,Double_t yup);
274 TH2L(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
275 ,Int_t nbinsy,Double_t ylow,Double_t yup);
276 TH2L(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
277 ,Int_t nbinsy,const Double_t *ybins);
278 TH2L(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
279 ,Int_t nbinsy,const Double_t *ybins);
280 TH2L(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins
281 ,Int_t nbinsy,const Float_t *ybins);
282 TH2L(const TH2L &h2l);
283 ~TH2L() override;
284 void AddBinContent(Int_t bin) override;
285 void AddBinContent(Int_t bin, Double_t w) override;
286 void AddBinContent(Int_t binx, Int_t biny) override { AddBinContent(GetBin(binx, biny)); }
287 void AddBinContent(Int_t binx, Int_t biny, Double_t w) override { AddBinContent(GetBin(binx, biny), w); }
288 void Copy(TObject &hnew) const override;
289 void Reset(Option_t *option="") override;
290 void SetBinsLength(Int_t n=-1) override;
291 TH2L& operator=(const TH2L &h1);
292 friend TH2L operator*(Float_t c1, TH2L const &h1);
293 friend TH2L operator*(TH2L const &h1, Float_t c1) {return operator*(c1,h1);}
294 friend TH2L operator+(TH2L const &h1, TH2L const &h2);
295 friend TH2L operator-(TH2L const &h1, TH2L const &h2);
296 friend TH2L operator*(TH2L const &h1, TH2L const &h2);
297 friend TH2L operator/(TH2L const &h1, TH2L const &h2);
298
299protected:
300 Double_t RetrieveBinContent(Int_t bin) const override { return Double_t (fArray[bin]); }
301 void UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = Int_t (content); }
302
303 ClassDefOverride(TH2L,0) //2-Dim histograms (one 64 bit integer per channel)
304};
305
306//______________________________________________________________________________
307
308class TH2F : public TH2, public TArrayF {
309
310public:
311 TH2F();
312 TH2F(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
313 ,Int_t nbinsy,Double_t ylow,Double_t yup);
314 TH2F(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
315 ,Int_t nbinsy,Double_t ylow,Double_t yup);
316 TH2F(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
317 ,Int_t nbinsy,const Double_t *ybins);
318 TH2F(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
319 ,Int_t nbinsy,const Double_t *ybins);
320 TH2F(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins
321 ,Int_t nbinsy,const Float_t *ybins);
322 TH2F(const TMatrixFBase &m);
323 TH2F(const TH2F &h2f);
324 ~TH2F() override;
325
326 /// Increment bin content by 1.
327 /// Passing an out-of-range bin leads to undefined behavior
328 void AddBinContent(Int_t bin) override {++fArray[bin];}
329 /// Increment bin content by a weight w.
330 /// \warning The value of w is cast to `Float_t` before being added.
331 /// Passing an out-of-range bin leads to undefined behavior
332 void AddBinContent(Int_t bin, Double_t w) override
333 {fArray[bin] += Float_t (w);}
334 void AddBinContent(Int_t binx, Int_t biny) override { AddBinContent(GetBin(binx, biny)); }
335 void AddBinContent(Int_t binx, Int_t biny, Double_t w) override { AddBinContent(GetBin(binx, biny), w); }
336 void Copy(TObject &hnew) const override;
337 void Reset(Option_t *option="") override;
338 void SetBinsLength(Int_t n=-1) override;
339
340 TH2F& operator=(const TH2F &h1);
341 friend TH2F operator*(Float_t c1, TH2F const &h1);
342 friend TH2F operator*(TH2F const &h1, Float_t c1);
343 friend TH2F operator+(TH2F const &h1, TH2F const &h2);
344 friend TH2F operator-(TH2F const &h1, TH2F const &h2);
345 friend TH2F operator*(TH2F const &h1, TH2F const &h2);
346 friend TH2F operator/(TH2F const &h1, TH2F const &h2);
347
348protected:
349 Double_t RetrieveBinContent(Int_t bin) const override { return Double_t (fArray[bin]); }
350 void UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = Float_t (content); }
351
352 ClassDefOverride(TH2F,4) //2-Dim histograms (one float per channel)
353};
354
355
356//______________________________________________________________________________
357
358class TH2D : public TH2, public TArrayD {
359
360public:
361 TH2D();
362 TH2D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
363 ,Int_t nbinsy,Double_t ylow,Double_t yup);
364 TH2D(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
365 ,Int_t nbinsy,Double_t ylow,Double_t yup);
366 TH2D(const char *name,const char *title,Int_t nbinsx,Double_t xlow,Double_t xup
367 ,Int_t nbinsy,const Double_t *ybins);
368 TH2D(const char *name,const char *title,Int_t nbinsx,const Double_t *xbins
369 ,Int_t nbinsy,const Double_t *ybins);
370 TH2D(const char *name,const char *title,Int_t nbinsx,const Float_t *xbins
371 ,Int_t nbinsy,const Float_t *ybins);
372 TH2D(const TMatrixDBase &m);
373 TH2D(const TH2D &h2d);
374 ~TH2D() override;
375
376 /// Increment bin content by 1.
377 /// Passing an out-of-range bin leads to undefined behavior
378 void AddBinContent(Int_t bin) override {++fArray[bin];}
379 /// Increment bin content by a weight w
380 /// Passing an out-of-range bin leads to undefined behavior
381 void AddBinContent(Int_t bin, Double_t w) override
382 {fArray[bin] += Double_t (w);}
383 void AddBinContent(Int_t binx, Int_t biny) override { AddBinContent(GetBin(binx, biny)); }
384 void AddBinContent(Int_t binx, Int_t biny, Double_t w) override { AddBinContent(GetBin(binx, biny), w); }
385 void Copy(TObject &hnew) const override;
386 void Reset(Option_t *option="") override;
387 void SetBinsLength(Int_t n=-1) override;
388
389 TH2D& operator=(const TH2D &h1);
390 friend TH2D operator*(Float_t c1, TH2D const &h1);
391 friend TH2D operator*(TH2D const &h1, Float_t c1) {return operator*(c1,h1);}
392 friend TH2D operator+(TH2D const &h1, TH2D const &h2);
393 friend TH2D operator-(TH2D const &h1, TH2D const &h2);
394 friend TH2D operator*(TH2D const &h1, TH2D const &h2);
395 friend TH2D operator/(TH2D const &h1, TH2D const &h2);
396
397protected:
398 Double_t RetrieveBinContent(Int_t bin) const override { return fArray[bin]; }
399 void UpdateBinContent(Int_t bin, Double_t content) override { fArray[bin] = content; }
400
401 ClassDefOverride(TH2D,4) //2-Dim histograms (one double per channel)
402};
403
404#endif
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
int Int_t
Definition RtypesCore.h:45
char Char_t
Definition RtypesCore.h:37
float Float_t
Definition RtypesCore.h:57
short Short_t
Definition RtypesCore.h:39
double Double_t
Definition RtypesCore.h:59
const char Option_t
Definition RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition Rtypes.h:346
Option_t Option_t option
char name[80]
Definition TGX11.cxx:110
Array of chars or bytes (8 bits per element).
Definition TArrayC.h:27
Char_t * fArray
Definition TArrayC.h:30
Array of doubles (64 bits per element).
Definition TArrayD.h:27
Double_t * fArray
Definition TArrayD.h:30
void Reset()
Definition TArrayD.h:47
Array of floats (32 bits per element).
Definition TArrayF.h:27
Float_t * fArray
Definition TArrayF.h:30
void Reset()
Definition TArrayF.h:47
Array of integers (32 bits per element).
Definition TArrayI.h:27
Int_t * fArray
Definition TArrayI.h:30
void Reset()
Definition TArrayI.h:47
Array of long64s (64 bits per element).
Definition TArrayL64.h:27
Long64_t * fArray
Definition TArrayL64.h:30
void Reset()
Definition TArrayL64.h:47
Array of shorts (16 bits per element).
Definition TArrayS.h:27
void Reset()
Definition TArrayS.h:47
Short_t * fArray
Definition TArrayS.h:30
1-Dim function class
Definition TF1.h:233
1-D histogram with a double per channel (see TH1 documentation)
Definition TH1.h:671
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:59
virtual void FillRandom(TF1 *f1, Int_t ntimes=5000, TRandom *rng=nullptr)
Definition TH1.cxx:3530
virtual Double_t IntegralAndError(Int_t binx1, Int_t binx2, Double_t &err, Option_t *option="") const
Return integral of bin contents in range [binx1,binx2] and its error.
Definition TH1.cxx:8001
virtual Double_t GetBinErrorLow(Int_t bin) const
Return lower error associated to bin number bin.
Definition TH1.cxx:9112
virtual Double_t Integral(Option_t *option="") const
Return integral of bin contents.
Definition TH1.cxx:7974
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
Definition TH1.cxx:5090
virtual Double_t GetBinErrorUp(Int_t bin) const
Return upper error associated to bin number bin.
Definition TH1.cxx:9143
2-D histogram with a byte per channel (see TH1 documentation)
Definition TH2.h:140
friend TH2C operator*(TH2C const &h1, Float_t c1)
Definition TH2.h:167
void Reset(Option_t *option="") override
Reset this histogram: contents, errors, etc.
Definition TH2.cxx:2987
void AddBinContent(Int_t binx, Int_t biny, Double_t w) override
Increment 2D bin content by a weight w.
Definition TH2.h:160
friend TH2C operator+(TH2C const &h1, TH2C const &h2)
Operator +.
Definition TH2.cxx:3067
Double_t RetrieveBinContent(Int_t bin) const override
Raw retrieval of bin content on internal data structure see convention for numbering bins in TH1::Get...
Definition TH2.h:174
friend TH2C operator*(Float_t c1, TH2C const &h1)
Operator *.
Definition TH2.cxx:3055
friend TH2C operator/(TH2C const &h1, TH2C const &h2)
Operator /.
Definition TH2.cxx:3103
void UpdateBinContent(Int_t bin, Double_t content) override
Raw update of bin content on internal data structure see convention for numbering bins in TH1::GetBin...
Definition TH2.h:175
void AddBinContent(Int_t binx, Int_t biny) override
Increment 2D bin content by 1.
Definition TH2.h:159
void AddBinContent(Int_t bin) override
Increment bin content by 1.
Definition TH2.cxx:2955
TH2C()
Constructor.
Definition TH2.cxx:2861
TH2C & operator=(const TH2C &h1)
Operator =.
Definition TH2.cxx:3044
~TH2C() override
Destructor.
Definition TH2.cxx:2871
void Copy(TObject &hnew) const override
Copy.
Definition TH2.cxx:2978
void SetBinsLength(Int_t n=-1) override
Set total number of bins including under/overflow Reallocate bin contents array.
Definition TH2.cxx:2998
friend TH2C operator-(TH2C const &h1, TH2C const &h2)
Operator -.
Definition TH2.cxx:3079
2-D histogram with a double per channel (see TH1 documentation)
Definition TH2.h:358
void UpdateBinContent(Int_t bin, Double_t content) override
Raw update of bin content on internal data structure see convention for numbering bins in TH1::GetBin...
Definition TH2.h:399
friend TH2D operator-(TH2D const &h1, TH2D const &h2)
Operator -.
Definition TH2.cxx:4337
friend TH2D operator+(TH2D const &h1, TH2D const &h2)
Operator +.
Definition TH2.cxx:4325
friend TH2D operator*(Float_t c1, TH2D const &h1)
Operator *.
Definition TH2.cxx:4313
void SetBinsLength(Int_t n=-1) override
Set total number of bins including under/overflow Reallocate bin contents array.
Definition TH2.cxx:4254
friend TH2D operator/(TH2D const &h1, TH2D const &h2)
Operator /.
Definition TH2.cxx:4361
void AddBinContent(Int_t binx, Int_t biny, Double_t w) override
Increment 2D bin content by a weight w.
Definition TH2.h:384
Double_t RetrieveBinContent(Int_t bin) const override
Raw retrieval of bin content on internal data structure see convention for numbering bins in TH1::Get...
Definition TH2.h:398
~TH2D() override
Destructor.
Definition TH2.cxx:4127
void AddBinContent(Int_t bin, Double_t w) override
Increment bin content by a weight w Passing an out-of-range bin leads to undefined behavior.
Definition TH2.h:381
void Copy(TObject &hnew) const override
Copy.
Definition TH2.cxx:4234
friend TH2D operator*(TH2D const &h1, Float_t c1)
Definition TH2.h:391
void AddBinContent(Int_t binx, Int_t biny) override
Increment 2D bin content by 1.
Definition TH2.h:383
TH2D()
Constructor.
Definition TH2.cxx:4117
TH2D & operator=(const TH2D &h1)
Operator =.
Definition TH2.cxx:4300
void AddBinContent(Int_t bin) override
Increment bin content by 1.
Definition TH2.h:378
2-D histogram with a float per channel (see TH1 documentation)
Definition TH2.h:308
TH2F()
Constructor.
Definition TH2.cxx:3845
void AddBinContent(Int_t bin) override
Increment bin content by 1.
Definition TH2.h:328
void AddBinContent(Int_t bin, Double_t w) override
Increment bin content by a weight w.
Definition TH2.h:332
TH2F & operator=(const TH2F &h1)
Operator =.
Definition TH2.cxx:4026
~TH2F() override
Destructor.
Definition TH2.cxx:3855
friend TH2F operator+(TH2F const &h1, TH2F const &h2)
Operator +.
Definition TH2.cxx:4061
void AddBinContent(Int_t binx, Int_t biny) override
Increment 2D bin content by 1.
Definition TH2.h:334
void Copy(TObject &hnew) const override
Copy.
Definition TH2.cxx:3960
void UpdateBinContent(Int_t bin, Double_t content) override
Raw update of bin content on internal data structure see convention for numbering bins in TH1::GetBin...
Definition TH2.h:350
Double_t RetrieveBinContent(Int_t bin) const override
Raw retrieval of bin content on internal data structure see convention for numbering bins in TH1::Get...
Definition TH2.h:349
friend TH2F operator-(TH2F const &h1, TH2F const &h2)
Operator -.
Definition TH2.cxx:4073
void AddBinContent(Int_t binx, Int_t biny, Double_t w) override
Increment 2D bin content by a weight w.
Definition TH2.h:335
friend TH2F operator*(Float_t c1, TH2F const &h1)
Operator *.
Definition TH2.cxx:4037
friend TH2F operator/(TH2F const &h1, TH2F const &h2)
Operator /.
Definition TH2.cxx:4097
void SetBinsLength(Int_t n=-1) override
Set total number of bins including under/overflow Reallocate bin contents array.
Definition TH2.cxx:3980
2-D histogram with an int per channel (see TH1 documentation)
Definition TH2.h:226
friend TH2I operator*(TH2I const &h1, Float_t c1)
Definition TH2.h:253
TH2I()
Constructor.
Definition TH2.cxx:3387
Double_t RetrieveBinContent(Int_t bin) const override
Raw retrieval of bin content on internal data structure see convention for numbering bins in TH1::Get...
Definition TH2.h:260
friend TH2I operator*(Float_t c1, TH2I const &h1)
Operator *.
Definition TH2.cxx:3548
friend TH2I operator-(TH2I const &h1, TH2I const &h2)
Operator -.
Definition TH2.cxx:3572
void Copy(TObject &hnew) const override
Copy.
Definition TH2.cxx:3506
void AddBinContent(Int_t binx, Int_t biny) override
Increment 2D bin content by 1.
Definition TH2.h:245
void UpdateBinContent(Int_t bin, Double_t content) override
Raw update of bin content on internal data structure see convention for numbering bins in TH1::GetBin...
Definition TH2.h:261
friend TH2I operator+(TH2I const &h1, TH2I const &h2)
Operator +.
Definition TH2.cxx:3560
void AddBinContent(Int_t bin) override
Increment bin content by 1.
Definition TH2.cxx:3483
void AddBinContent(Int_t binx, Int_t biny, Double_t w) override
Increment 2D bin content by a weight w.
Definition TH2.h:246
~TH2I() override
Destructor.
Definition TH2.cxx:3397
TH2I & operator=(const TH2I &h1)
Operator =.
Definition TH2.cxx:3537
friend TH2I operator/(TH2I const &h1, TH2I const &h2)
Operator /.
Definition TH2.cxx:3596
void SetBinsLength(Int_t n=-1) override
Set total number of bins including under/overflow Reallocate bin contents array.
Definition TH2.cxx:3526
2-D histogram with a long64 per channel (see TH1 documentation)
Definition TH2.h:268
void AddBinContent(Int_t binx, Int_t biny) override
Increment 2D bin content by 1.
Definition TH2.h:286
TH2L & operator=(const TH2L &h1)
Operator =.
Definition TH2.cxx:3766
friend TH2L operator-(TH2L const &h1, TH2L const &h2)
Operator -.
Definition TH2.cxx:3801
friend TH2L operator+(TH2L const &h1, TH2L const &h2)
Operator +.
Definition TH2.cxx:3789
void AddBinContent(Int_t binx, Int_t biny, Double_t w) override
Increment 2D bin content by a weight w.
Definition TH2.h:287
void SetBinsLength(Int_t n=-1) override
Set total number of bins including under/overflow Reallocate bin contents array.
Definition TH2.cxx:3755
friend TH2L operator*(TH2L const &h1, Float_t c1)
Definition TH2.h:293
~TH2L() override
Destructor.
Definition TH2.cxx:3626
void Copy(TObject &hnew) const override
Copy.
Definition TH2.cxx:3735
Double_t RetrieveBinContent(Int_t bin) const override
Raw retrieval of bin content on internal data structure see convention for numbering bins in TH1::Get...
Definition TH2.h:300
friend TH2L operator/(TH2L const &h1, TH2L const &h2)
Operator /.
Definition TH2.cxx:3825
void UpdateBinContent(Int_t bin, Double_t content) override
Raw update of bin content on internal data structure see convention for numbering bins in TH1::GetBin...
Definition TH2.h:301
TH2L()
Constructor.
Definition TH2.cxx:3616
friend TH2L operator*(Float_t c1, TH2L const &h1)
Operator *.
Definition TH2.cxx:3777
void AddBinContent(Int_t bin) override
Increment bin content by 1.
Definition TH2.cxx:3712
2-D histogram with a short per channel (see TH1 documentation)
Definition TH2.h:183
void AddBinContent(Int_t binx, Int_t biny, Double_t w) override
Increment 2D bin content by a weight w.
Definition TH2.h:203
void AddBinContent(Int_t bin) override
Increment bin content by 1.
Definition TH2.cxx:3219
~TH2S() override
Destructor.
Definition TH2.cxx:3133
friend TH2S operator-(TH2S const &h1, TH2S const &h2)
Operator -.
Definition TH2.cxx:3343
TH2S & operator=(const TH2S &h1)
Operator =.
Definition TH2.cxx:3308
void Copy(TObject &hnew) const override
Copy.
Definition TH2.cxx:3242
TH2S()
Constructor.
Definition TH2.cxx:3123
friend TH2S operator*(TH2S const &h1, Float_t c1)
Definition TH2.h:210
Double_t RetrieveBinContent(Int_t bin) const override
Raw retrieval of bin content on internal data structure see convention for numbering bins in TH1::Get...
Definition TH2.h:217
void AddBinContent(Int_t binx, Int_t biny) override
Increment 2D bin content by 1.
Definition TH2.h:202
void UpdateBinContent(Int_t bin, Double_t content) override
Raw update of bin content on internal data structure see convention for numbering bins in TH1::GetBin...
Definition TH2.h:218
friend TH2S operator*(Float_t c1, TH2S const &h1)
Operator *.
Definition TH2.cxx:3319
friend TH2S operator+(TH2S const &h1, TH2S const &h2)
Operator +.
Definition TH2.cxx:3331
void SetBinsLength(Int_t n=-1) override
Set total number of bins including under/overflow Reallocate bin contents array.
Definition TH2.cxx:3262
friend TH2S operator/(TH2S const &h1, TH2S const &h2)
Operator /.
Definition TH2.cxx:3367
Service class for 2-D histogram classes.
Definition TH2.h:30
TH1D * ProjectionY(const char *name="_py", Int_t firstxbin=0, Int_t lastxbin=-1, Option_t *option="") const
Project a 2-D histogram into a 1-D histogram along Y.
Definition TH2.cxx:2473
void GetStats(Double_t *stats) const override
Fill the array stats from the contents of this histogram The array stats must be correctly dimensione...
Definition TH2.cxx:1251
Int_t ShowPeaks(Double_t sigma=2, Option_t *option="", Double_t threshold=0.05) override
Interface to TSpectrum2::Search the function finds peaks in this histogram where the width is > sigma...
Definition TH2.cxx:2692
virtual Double_t GetCorrelationFactor(Int_t axis1=1, Int_t axis2=2) const
Return correlation factor between axis1 and axis2.
Definition TH2.cxx:1142
void FillRandom(TF1 *f1, Int_t ntimes=5000, TRandom *rng=nullptr) override
Fill histogram following distribution in function fname.
Definition TH2.cxx:714
virtual TProfile * DoProfile(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const
Definition TH2.cxx:1877
Double_t KolmogorovTest(const TH1 *h2, Option_t *option="") const override
Statistical test of compatibility in shape between THIS histogram and h2, using Kolmogorov test.
Definition TH2.cxx:1467
virtual void FitSlicesY(TF1 *f1=nullptr, Int_t firstxbin=0, Int_t lastxbin=-1, Int_t cut=0, Option_t *option="QNR", TObjArray *arr=nullptr)
Project slices along Y in case of a 2-D histogram, then fit each slice with function f1 and make a hi...
Definition TH2.cxx:1078
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
compute first cell (binx,biny) in the range [firstxbin,lastxbin][firstybin,lastybin] for which diff =...
Definition TH2.cxx:1114
TProfile * ProfileX(const char *name="_pfx", Int_t firstybin=1, Int_t lastybin=-1, Option_t *option="") const
Project a 2-D histogram into a profile histogram along X.
Definition TH2.cxx:2106
void AddBinContent(Int_t bin) override
Increment bin content by 1.
Definition TH2.cxx:238
TH2(const TH2 &)=delete
TH2 * Rebin(Int_t ngroup=2, const char *newname="", const Double_t *xbins=nullptr) override
Override TH1::Rebin as TH2::RebinX Rebinning in variable binning as for TH1 is not allowed If a non-n...
Definition TH2.cxx:1660
void FillN(Int_t, const Double_t *, const Double_t *, Int_t) override
Fill this histogram with an array x and weights w.
Definition TH2.h:84
Int_t BufferFill(Double_t, Double_t) override
accumulate arguments in buffer.
Definition TH2.h:56
TH1D * QuantilesY(Double_t prob=0.5, const char *name="_qy") const
Compute the Y distribution of quantiles in the other variable X name is the name of the returned hist...
Definition TH2.cxx:2515
TProfile * ProfileY(const char *name="_pfy", Int_t firstxbin=1, Int_t lastxbin=-1, Option_t *option="") const
Project a 2-D histogram into a profile histogram along Y.
Definition TH2.cxx:2156
void Copy(TObject &hnew) const override
Copy.
Definition TH2.cxx:380
virtual TH1D * DoQuantiles(bool onX, const char *name, Double_t prob) const
Implementation of quantiles for x or y.
Definition TH2.cxx:2524
Double_t fTsumwxy
Total Sum of weight*X*Y.
Definition TH2.h:36
void SetBinContent(Int_t bin, Double_t content) override
Set bin content.
Definition TH2.cxx:2613
Int_t Fill(const char *, Double_t) override
Increment bin with namex with a weight w.
Definition TH2.h:58
Int_t BufferEmpty(Int_t action=0) override
Fill histogram with all entries in the buffer.
Definition TH2.cxx:278
virtual Double_t Integral(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Option_t *="") const
Definition TH2.h:107
virtual void DoFitSlices(bool onX, TF1 *f1, Int_t firstbin, Int_t lastbin, Int_t cut, Option_t *option, TObjArray *arr)
Definition TH2.cxx:811
TH1D * QuantilesX(Double_t prob=0.5, const char *name="_qx") const
Compute the X distribution of quantiles in the other variable Y name is the name of the returned hist...
Definition TH2.cxx:2502
virtual void SetShowProjectionY(Int_t nbins=1)
When the mouse is moved in a pad containing a 2-d view of this histogram a second canvas shows the pr...
Definition TH2.cxx:2647
void SetBinContent(Int_t binx, Int_t biny, Int_t, Double_t content) override
Definition TH2.h:126
virtual Double_t GetBinErrorUp(Int_t binx, Int_t biny)
Definition TH2.h:99
void Reset(Option_t *option="") override
Reset this histogram: contents, errors, etc.
Definition TH2.cxx:2597
Double_t fScalefactor
Scale factor.
Definition TH2.h:33
virtual TH1D * DoProjection(bool onX, const char *name, Int_t firstbin, Int_t lastbin, Option_t *option) const
Internal (protected) method for performing projection on the X or Y axis called by ProjectionX or Pro...
Definition TH2.cxx:2166
TH2 * RebinX(Int_t ngroup=2, const char *newname="") override
Rebin only the X axis see Rebin2D.
Definition TH2.cxx:1639
Double_t fTsumwy2
Total Sum of weight*Y*Y.
Definition TH2.h:35
virtual void GetRandom2(Double_t &x, Double_t &y, TRandom *rng=nullptr)
Return 2 random numbers along axis x and y distributed according to the cell-contents of this 2-D his...
Definition TH2.cxx:1197
void SetBinContent(Int_t binx, Int_t biny, Double_t content) override
Definition TH2.h:125
virtual Double_t GetCovariance(Int_t axis1=1, Int_t axis2=2) const
Return covariance between axis1 and axis2.
Definition TH2.cxx:1160
Int_t GetBin(Int_t binx, Int_t biny, Int_t binz=0) const override
Return Global bin number corresponding to binx,y,z.
Definition TH2.cxx:1083
Double_t GetBinContent(Int_t binx, Int_t biny, Int_t) const override
Definition TH2.h:95
TH1D * ProjectionX(const char *name="_px", Int_t firstybin=0, Int_t lastybin=-1, Option_t *option="") const
Project a 2-D histogram into a 1-D histogram along X.
Definition TH2.cxx:2433
void Smooth(Int_t ntimes=1, Option_t *option="") override
Smooth bin contents of this 2-d histogram using kernel algorithms similar to the ones used in the ras...
Definition TH2.cxx:2724
~TH2() override
Destructor.
Definition TH2.cxx:230
Double_t GetBinContent(Int_t binx, Int_t biny) const override
Definition TH2.h:94
virtual Double_t IntegralAndError(Int_t binx1, Int_t binx2, Int_t biny1, Int_t biny2, Double_t &err, Option_t *option="") const
Return integral of bin contents in range [firstxbin,lastxbin],[firstybin,lastybin] for a 2-D histogra...
Definition TH2.cxx:1342
Double_t fTsumwy
Total Sum of weight*Y.
Definition TH2.h:34
TH2()
2-D histogram default constructor.
Definition TH2.cxx:73
TH2 & operator=(const TH2 &)=delete
TH1 * ShowBackground(Int_t niter=20, Option_t *option="same") override
This function calculates the background spectrum in this histogram.
Definition TH2.cxx:2676
virtual void SetShowProjectionX(Int_t nbins=1)
When the mouse is moved in a pad containing a 2-d view of this histogram a second canvas shows the pr...
Definition TH2.cxx:2631
Int_t Fill(Double_t) override
Invalid Fill method.
Definition TH2.cxx:393
virtual Double_t GetBinErrorLow(Int_t binx, Int_t biny)
Definition TH2.h:98
virtual TH2 * Rebin2D(Int_t nxgroup=2, Int_t nygroup=2, const char *newname="")
Rebin this histogram grouping nxgroup/nygroup bins along the xaxis/yaxis together.
Definition TH2.cxx:1695
virtual void FitSlicesX(TF1 *f1=nullptr, Int_t firstybin=0, Int_t lastybin=-1, Int_t cut=0, Option_t *option="QNR", TObjArray *arr=nullptr)
Project slices along X in case of a 2-D histogram, then fit each slice with function f1 and make a hi...
Definition TH2.cxx:1013
virtual Int_t BufferFill(Double_t x, Double_t y, Double_t w)
accumulate arguments in buffer.
Definition TH2.cxx:352
virtual void SetShowProjectionXY(Int_t nbinsY=1, Int_t nbinsX=1)
When the mouse is moved in a pad containing a 2-d view of this histogram two canvases show the projec...
Definition TH2.cxx:2664
Double_t Integral(Option_t *option="") const override
Return integral of bin contents.
Definition TH2.cxx:1314
void PutStats(Double_t *stats) override
Replace current statistics with the values in array stats.
Definition TH2.cxx:2482
virtual TH2 * RebinY(Int_t ngroup=2, const char *newname="")
Rebin only the Y axis see Rebin2D.
Definition TH2.cxx:1649
TMatrixTBase.
An array of TObjects.
Definition TObjArray.h:31
Mother of all ROOT objects.
Definition TObject.h:41
Profile Histogram.
Definition TProfile.h:32
This is the base class for the ROOT Random number generators.
Definition TRandom.h:27
#define Interpolate(a, x, b, y)
Definition geom.c:179
const Double_t sigma
Double_t y[n]
Definition legend1.C:17
return c1
Definition legend1.C:41
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
TH1F * h1
Definition legend1.C:5
TF1 * f1
Definition legend1.C:11
TMarker m
Definition textangle.C:8