Logo ROOT  
Reference Guide
THnBase.h
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: Axel Naumann (2011-12-20)
3
4/*************************************************************************
5 * Copyright (C) 1995-2012, 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_THnBase
13#define ROOT_THnBase
14
15/*************************************************************************
16
17 THnBase: Common base class for n-dimensional histogramming.
18 Defines interfaces and algorithms.
19
20*************************************************************************/
21
22
23#include "TNamed.h"
24#include "TMath.h"
25#include "TFitResultPtr.h"
26#include "TObjArray.h"
27#include "TArrayD.h"
28
29class TAxis;
30class TH1;
31class TH1D;
32class TH2D;
33class TH3D;
34class TF1;
35class THnIter;
36
37namespace ROOT {
38namespace Internal {
39 class THnBaseBinIter;
40}
41}
42
43class THnBase: public TNamed {
44protected:
45 Int_t fNdimensions; ///< Number of dimensions
46 TObjArray fAxes; ///< Axes of the histogram
47 TObjArray fBrowsables; ///<! Browser-helpers for each axis
48 Double_t fEntries; ///< Number of entries, spread over chunks
49 Double_t fTsumw; ///< Total sum of weights
50 Double_t fTsumw2; ///< Total sum of weights squared; -1 if no errors are calculated
51 TArrayD fTsumwx; ///< Total sum of weight*X for each dimension
52 TArrayD fTsumwx2; ///< Total sum of weight*X*X for each dimension
53 std::vector<Double_t> fIntegral; ///<! vector with bin weight sums
54 enum {
58 } fIntegralStatus; ///<! status of integral
59
60 protected:
62
63 THnBase(const char *name, const char *title, Int_t dim, const Int_t *nbins, const Double_t *xmin,
64 const Double_t *xmax);
65
66 THnBase(const char *name, const char *title, Int_t dim, const Int_t *nbins,
67 const std::vector<std::vector<double>> &xbins);
68
69 void UpdateXStat(const Double_t *x, Double_t w = 1.)
70 {
71 if (GetCalculateErrors()) {
72 for (Int_t d = 0; d < fNdimensions; ++d) {
73 const Double_t xd = x[d];
74 fTsumwx[d] += w * xd;
75 fTsumwx2[d] += w * xd * xd;
76 }
77 }
78 }
79
80 /// Increment the statistics due to filled weight "w",
82 fEntries += 1;
83 if (GetCalculateErrors()) {
84 fTsumw += w;
85 fTsumw2 += w*w;
86 }
88 }
89
90 virtual void InitStorage(Int_t* nbins, Int_t chunkSize) = 0;
91 void Init(const char* name, const char* title,
92 const TObjArray* axes, Bool_t keepTargetAxis,
93 Int_t chunkSize = 1024 * 16);
94 THnBase* CloneEmpty(const char* name, const char* title,
95 const TObjArray* axes, Bool_t keepTargetAxis) const;
96 virtual void Reserve(Long64_t /*nbins*/) {}
97 virtual void SetFilledBins(Long64_t /*nbins*/) {};
98
99 Bool_t CheckConsistency(const THnBase *h, const char *tag) const;
100 TH1* CreateHist(const char* name, const char* title,
101 const TObjArray* axes, Bool_t keepTargetAxis) const;
102 TObject* ProjectionAny(Int_t ndim, const Int_t* dim,
103 Bool_t wantNDim, Option_t* option = "") const;
104 Bool_t PrintBin(Long64_t idx, Int_t* coord, Option_t* options) const;
105 void AddInternal(const THnBase* h, Double_t c, Bool_t rebinned);
107 THnBase* RebinBase(const Int_t* group) const;
108 void ResetBase(Option_t *option= "");
109
110 static THnBase* CreateHnAny(const char* name, const char* title,
111 const TH1* h1, Bool_t sparse,
112 Int_t chunkSize = 1024 * 16);
113 static THnBase* CreateHnAny(const char* name, const char* title,
114 const THnBase* hn, Bool_t sparse,
115 Int_t chunkSize = 1024 * 16);
116
117 public:
118 virtual ~THnBase();
119
121 const TObjArray* GetListOfAxes() const { return &fAxes; }
122 TAxis* GetAxis(Int_t dim) const { return (TAxis*)fAxes[dim]; }
123
124 TFitResultPtr Fit(TF1 *f1 ,Option_t *option = "", Option_t *goption = "");
125 TList* GetListOfFunctions() { return 0; }
126
127 virtual ROOT::Internal::THnBaseBinIter* CreateIter(Bool_t respectAxisRange) const = 0;
128
129 virtual Long64_t GetNbins() const = 0;
130 Double_t GetEntries() const { return fEntries; }
131 Double_t GetWeightSum() const { return fTsumw; }
133 Bool_t GetCalculateErrors() const { return fTsumw2 >= 0.; }
134
135 /// Calculate errors (or not if "calc" == kFALSE)
137 if (calc) Sumw2();
138 else fTsumw2 = -1.;
139 }
140
141 Long64_t Fill(const Double_t *x, Double_t w = 1.) {
142 UpdateXStat(x, w);
143 Long64_t bin = GetBin(x, kTRUE /*alloc*/);
144 FillBin(bin, w);
145 return bin;
146 }
147 Long64_t Fill(const char* name[], Double_t w = 1.) {
148 Long64_t bin = GetBin(name, kTRUE /*alloc*/);
149 FillBin(bin, w);
150 return bin;
151 }
152
153 /// Fill with the provided variadic arguments.
154 /// The number of arguments must be equal to the number of histogram dimensions or, for weighted fills, to the
155 /// number of dimensions + 1; in the latter case, the last function argument is used as weight.
156 /// A separate `firstval` argument is needed so the compiler does not pick this overload instead of the non-templated
157 /// Fill overloads
158 template <typename... MoreTypes>
159 Long64_t Fill(Double_t firstval, MoreTypes... morevals)
160 {
161 const std::array<double, 1 + sizeof...(morevals)> x{firstval, static_cast<double>(morevals)...};
162 if (Int_t(x.size()) == GetNdimensions()) {
163 // without weight
164 return Fill(x.data());
165 } else if (Int_t(x.size()) == (GetNdimensions() + 1)) {
166 // with weight
167 return Fill(x.data(), x.back());
168 } else {
169 Error("Fill", "Wrong number of arguments for number of histogram axes.");
170 }
171
172 return -1;
173 }
174
175 virtual void FillBin(Long64_t bin, Double_t w) = 0;
176
177 void SetBinEdges(Int_t idim, const Double_t* bins);
178 Bool_t IsInRange(Int_t *coord) const;
179 Double_t GetBinError(const Int_t *idx) const { return GetBinError(GetBin(idx)); }
180 Double_t GetBinError(Long64_t linidx) const { return TMath::Sqrt(GetBinError2(linidx)); }
181 void SetBinError(const Int_t* idx, Double_t e) { SetBinError(GetBin(idx), e); }
183 void AddBinContent(const Int_t* x, Double_t v = 1.) { AddBinContent(GetBin(x), v); }
184 void SetEntries(Double_t entries) { fEntries = entries; }
185 void SetTitle(const char *title);
186
187 Double_t GetBinContent(const Int_t *idx) const { return GetBinContent(GetBin(idx)); } // intentionally non-virtual
188 virtual Double_t GetBinContent(Long64_t bin, Int_t* idx = 0) const = 0;
189 virtual Double_t GetBinError2(Long64_t linidx) const = 0;
190 virtual Long64_t GetBin(const Int_t* idx) const = 0;
191 virtual Long64_t GetBin(const Double_t* x) const = 0;
192 virtual Long64_t GetBin(const char* name[]) const = 0;
193 virtual Long64_t GetBin(const Int_t* idx, Bool_t /*allocate*/ = kTRUE) = 0;
194 virtual Long64_t GetBin(const Double_t* x, Bool_t /*allocate*/ = kTRUE) = 0;
195 virtual Long64_t GetBin(const char* name[], Bool_t /*allocate*/ = kTRUE) = 0;
196
197 void SetBinContent(const Int_t* idx, Double_t v) { SetBinContent(GetBin(idx), v); } // intentionally non-virtual
198 virtual void SetBinContent(Long64_t bin, Double_t v) = 0;
199 virtual void SetBinError2(Long64_t bin, Double_t e2) = 0;
200 virtual void AddBinError2(Long64_t bin, Double_t e2) = 0;
201 virtual void AddBinContent(Long64_t bin, Double_t v = 1.) = 0;
202
203 Double_t GetSumw() const { return fTsumw; }
204 Double_t GetSumw2() const { return fTsumw2; }
205 Double_t GetSumwx(Int_t dim) const { return fTsumwx[dim]; }
206 Double_t GetSumwx2(Int_t dim) const { return fTsumwx2[dim]; }
207
208 /// Project all bins into a 1-dimensional histogram,
209 /// keeping only axis "xDim".
210 /// If "option" contains:
211 /// - "E" errors will be calculated.
212 /// - "A" ranges of the taget axes will be ignored.
213 /// - "O" original axis range of the taget axes will be
214 /// kept, but only bins inside the selected range
215 /// will be filled.
216 TH1D* Projection(Int_t xDim, Option_t* option = "") const {
217 return (TH1D*) ProjectionAny(1, &xDim, false, option);
218 }
219
220 /// Project all bins into a 2-dimensional histogram,
221 /// keeping only axes "xDim" and "yDim".
222 ///
223 /// WARNING: just like TH3::Project3D("yx") and TTree::Draw("y:x"),
224 /// Projection(y,x) uses the first argument to define the y-axis and the
225 /// second for the x-axis!
226 ///
227 /// If "option" contains "E" errors will be calculated.
228 /// "A" ranges of the taget axes will be ignored.
229 TH2D* Projection(Int_t yDim, Int_t xDim, Option_t* option = "") const {
230 const Int_t dim[2] = {xDim, yDim};
231 return (TH2D*) ProjectionAny(2, dim, false, option);
232 }
233
234 /// Project all bins into a 3-dimensional histogram,
235 /// keeping only axes "xDim", "yDim", and "zDim".
236 /// If "option" contains:
237 /// - "E" errors will be calculated.
238 /// - "A" ranges of the taget axes will be ignored.
239 /// - "O" original axis range of the taget axes will be
240 /// kept, but only bins inside the selected range
241 /// will be filled.
242 TH3D* Projection(Int_t xDim, Int_t yDim, Int_t zDim, Option_t* option = "") const {
243 const Int_t dim[3] = {xDim, yDim, zDim};
244 return (TH3D*) ProjectionAny(3, dim, false, option);
245 }
246
247 THnBase* ProjectionND(Int_t ndim, const Int_t* dim,
248 Option_t* option = "") const {
249 return (THnBase*)ProjectionAny(ndim, dim, kTRUE /*wantNDim*/, option);
250 }
251
253
254 void Scale(Double_t c);
255 void Add(const THnBase* h, Double_t c=1.);
256 void Add(const TH1* hist, Double_t c=1.);
257 void Multiply(const THnBase* h);
258 void Multiply(TF1* f, Double_t c = 1.);
259 void Divide(const THnBase* h);
260 void Divide(const THnBase* h1, const THnBase* h2, Double_t c1 = 1., Double_t c2 = 1., Option_t* option="");
261 void RebinnedAdd(const THnBase* h, Double_t c=1.);
262
263 virtual void Reset(Option_t* option = "") = 0;
264 virtual void Sumw2() = 0;
265
267 void GetRandom(Double_t *rand, Bool_t subBinRandom = kTRUE);
268
269 void Print(Option_t* option = "") const;
270 void PrintEntries(Long64_t from = 0, Long64_t howmany = -1, Option_t* options = 0) const;
271 void PrintBin(Int_t* coord, Option_t* options) const {
272 PrintBin(-1, coord, options);
273 }
274 void PrintBin(Long64_t idx, Option_t* options) const;
275
276 void Browse(TBrowser *b);
277 Bool_t IsFolder() const { return kTRUE; }
278
279 //void Draw(Option_t* option = "");
280
281 ClassDef(THnBase, 1); // Common base for n-dimensional histogram
282
283 friend class THnIter;
284};
285
286namespace ROOT {
287namespace Internal {
288 // Helper class for browsing THnBase objects
289 class THnBaseBrowsable: public TNamed {
290 public:
291 THnBaseBrowsable(THnBase* hist, Int_t axis);
293 void Browse(TBrowser *b);
294 Bool_t IsFolder() const { return kFALSE; }
295
296 private:
297 THnBase* fHist; // Original histogram
298 Int_t fAxis; // Axis to visualize
299 TH1* fProj; // Projection result
300 ClassDef(THnBaseBrowsable, 0); // Browser-helper for THnBase
301 };
302
303 // Base class for iterating over THnBase bins
305 public:
306 THnBaseBinIter(Bool_t respectAxisRange):
307 fRespectAxisRange(respectAxisRange), fHaveSkippedBin(kFALSE) {}
308 virtual ~THnBaseBinIter();
311
312 virtual Int_t GetCoord(Int_t dim) const = 0;
313 virtual Long64_t Next(Int_t* coord = 0) = 0;
314
315 protected:
318 };
319}
320}
321
322class THnIter: public TObject {
323public:
324 THnIter(const THnBase* hist, Bool_t respectAxisRange = kFALSE):
325 fIter(hist->CreateIter(respectAxisRange)) {}
326 virtual ~THnIter();
327
328 /// Return the next bin's index.
329 /// If provided, set coord to that bin's coordinates (bin indexes).
330 /// I.e. coord must point to Int_t[hist->GetNdimensions()]
331 /// Returns -1 when all bins have been visited.
332 Long64_t Next(Int_t* coord = 0) {
333 return fIter->Next(coord);
334 }
335
336 Int_t GetCoord(Int_t dim) const { return fIter->GetCoord(dim); }
339
340private:
342 ClassDef(THnIter, 0); //Iterator over bins of a THnBase.
343};
344
345#endif // ROOT_THnBase
double
Definition: Converters.cxx:939
#define d(i)
Definition: RSha256.hxx:102
#define b(i)
Definition: RSha256.hxx:100
#define f(i)
Definition: RSha256.hxx:104
#define c(i)
Definition: RSha256.hxx:101
#define h(i)
Definition: RSha256.hxx:106
#define e(i)
Definition: RSha256.hxx:103
int Int_t
Definition: RtypesCore.h:45
const Bool_t kFALSE
Definition: RtypesCore.h:101
bool Bool_t
Definition: RtypesCore.h:63
double Double_t
Definition: RtypesCore.h:59
long long Long64_t
Definition: RtypesCore.h:80
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassDef(name, id)
Definition: Rtypes.h:325
char name[80]
Definition: TGX11.cxx:110
float xmin
Definition: THbookFile.cxx:95
float xmax
Definition: THbookFile.cxx:95
Iterator over THnBase bins (internal implementation).
Definition: THnBase.h:304
Bool_t RespectsAxisRange() const
Definition: THnBase.h:310
Bool_t HaveSkippedBin() const
Definition: THnBase.h:309
virtual Int_t GetCoord(Int_t dim) const =0
THnBaseBinIter(Bool_t respectAxisRange)
Definition: THnBase.h:306
virtual ~THnBaseBinIter()
Destruct a bin iterator.
Definition: THnBase.cxx:1426
virtual Long64_t Next(Int_t *coord=0)=0
TBrowser helper for THnBase.
Definition: THnBase.h:289
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition: THnBase.h:294
~THnBaseBrowsable()
Destruct a THnBaseBrowsable.
Definition: THnBase.cxx:1470
THnBaseBrowsable(THnBase *hist, Int_t axis)
Construct a THnBaseBrowsable.
Definition: THnBase.cxx:1454
void Browse(TBrowser *b)
Browse an axis of a THnBase, i.e. draw its projection.
Definition: THnBase.cxx:1478
Array of doubles (64 bits per element).
Definition: TArrayD.h:27
Class to manage histogram axis.
Definition: TAxis.h:30
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
Collection abstract base class.
Definition: TCollection.h:65
1-Dim function class
Definition: TF1.h:213
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
Definition: TFitResultPtr.h:32
1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:618
TH1 is the base class of all histogram classes in ROOT.
Definition: TH1.h:58
2-D histogram with a double per channel (see TH1 documentation)}
Definition: TH2.h:292
3-D histogram with a double per channel (see TH1 documentation)}
Definition: TH3.h:305
Multidimensional histogram base.
Definition: THnBase.h:43
virtual void Sumw2()=0
virtual ROOT::Internal::THnBaseBinIter * CreateIter(Bool_t respectAxisRange) const =0
void SetEntries(Double_t entries)
Definition: THnBase.h:184
virtual void SetFilledBins(Long64_t)
Definition: THnBase.h:97
const TObjArray * GetListOfAxes() const
Definition: THnBase.h:121
Long64_t Fill(const Double_t *x, Double_t w=1.)
Definition: THnBase.h:141
virtual void InitStorage(Int_t *nbins, Int_t chunkSize)=0
Double_t GetBinError(const Int_t *idx) const
Definition: THnBase.h:179
void SetBinError(const Int_t *idx, Double_t e)
Definition: THnBase.h:181
Double_t fEntries
Number of entries, spread over chunks.
Definition: THnBase.h:48
virtual void AddBinContent(Long64_t bin, Double_t v=1.)=0
Double_t GetSumw2() const
Definition: THnBase.h:204
Bool_t IsInRange(Int_t *coord) const
Check whether bin coord is in range, as defined by TAxis::SetRange().
Definition: THnBase.cxx:450
TList * GetListOfFunctions()
Definition: THnBase.h:125
virtual Long64_t GetBin(const Int_t *idx, Bool_t=kTRUE)=0
TFitResultPtr Fit(TF1 *f1, Option_t *option="", Option_t *goption="")
Fit a THnSparse with function f.
Definition: THnBase.cxx:386
void AddBinContent(const Int_t *x, Double_t v=1.)
Definition: THnBase.h:183
void Scale(Double_t c)
Scale contents and errors of this histogram by c: this = this * c It does not modify the histogram's ...
Definition: THnBase.cxx:632
virtual void SetBinError2(Long64_t bin, Double_t e2)=0
TObjArray * GetListOfAxes()
Definition: THnBase.h:120
TH1 * CreateHist(const char *name, const char *title, const TObjArray *axes, Bool_t keepTargetAxis) const
Create an empty histogram with name and title with a given set of axes.
Definition: THnBase.cxx:165
Bool_t PrintBin(Long64_t idx, Int_t *coord, Option_t *options) const
Print one bin.
Definition: THnBase.cxx:1262
TH1D * Projection(Int_t xDim, Option_t *option="") const
Project all bins into a 1-dimensional histogram, keeping only axis "xDim".
Definition: THnBase.h:216
Double_t GetSumwx(Int_t dim) const
Definition: THnBase.h:205
@ kInvalidInt
Definition: THnBase.h:57
@ kNoInt
Definition: THnBase.h:55
@ kValidInt
Definition: THnBase.h:56
Bool_t CheckConsistency(const THnBase *h, const char *tag) const
Consistency check on (some of) the parameters of two histograms (for operations).
Definition: THnBase.cxx:1008
Int_t GetNdimensions() const
Definition: THnBase.h:132
TH3D * Projection(Int_t xDim, Int_t yDim, Int_t zDim, Option_t *option="") const
Project all bins into a 3-dimensional histogram, keeping only axes "xDim", "yDim",...
Definition: THnBase.h:242
void PrintBin(Int_t *coord, Option_t *options) const
Definition: THnBase.h:271
static THnBase * CreateHnAny(const char *name, const char *title, const TH1 *h1, Bool_t sparse, Int_t chunkSize=1024 *16)
Create a THn / THnSparse object from a histogram deriving from TH1.
Definition: THnBase.cxx:218
virtual Long64_t GetBin(const char *name[], Bool_t=kTRUE)=0
TArrayD fTsumwx2
Total sum of weight*X*X for each dimension.
Definition: THnBase.h:52
void ResetBase(Option_t *option="")
Clear the histogram.
Definition: THnBase.cxx:1173
virtual Long64_t GetNbins() const =0
THnBase * RebinBase(Int_t group) const
Combine the content of "group" neighboring bins into a new bin and return the resulting THnBase.
Definition: THnBase.cxx:1078
THnBase * ProjectionND(Int_t ndim, const Int_t *dim, Option_t *option="") const
Definition: THnBase.h:247
virtual Double_t GetBinContent(Long64_t bin, Int_t *idx=0) const =0
TObjArray fAxes
Axes of the histogram.
Definition: THnBase.h:46
void Browse(TBrowser *b)
Browse a THnSparse: create an entry (ROOT::THnSparseBrowsable) for each dimension.
Definition: THnBase.cxx:1403
void SetBinEdges(Int_t idim, const Double_t *bins)
Set the axis # of bins and bin limits on dimension idim.
Definition: THnBase.cxx:1026
Bool_t GetCalculateErrors() const
Definition: THnBase.h:133
void AddInternal(const THnBase *h, Double_t c, Bool_t rebinned)
Add() implementation for both rebinned histograms and those with identical binning.
Definition: THnBase.cxx:656
virtual void SetBinContent(Long64_t bin, Double_t v)=0
enum THnBase::@83 fIntegralStatus
! status of integral
Double_t GetBinError(Long64_t linidx) const
Definition: THnBase.h:180
Double_t GetBinContent(const Int_t *idx) const
Definition: THnBase.h:187
virtual Long64_t GetBin(const Double_t *x, Bool_t=kTRUE)=0
void PrintEntries(Long64_t from=0, Long64_t howmany=-1, Option_t *options=0) const
Print "howmany" entries starting at "from".
Definition: THnBase.cxx:1306
void Add(const THnBase *h, Double_t c=1.)
Add contents of h scaled by c to this histogram: this = this + c * h Note that if h has Sumw2 set,...
Definition: THnBase.cxx:717
Double_t fTsumw2
Total sum of weights squared; -1 if no errors are calculated.
Definition: THnBase.h:50
virtual void Reserve(Long64_t)
Definition: THnBase.h:96
virtual ~THnBase()
Destruct a THnBase.
Definition: THnBase.cxx:89
THnBase()
Definition: THnBase.h:61
Double_t GetEntries() const
Definition: THnBase.h:130
Long64_t Fill(Double_t firstval, MoreTypes... morevals)
Fill with the provided variadic arguments.
Definition: THnBase.h:159
virtual Long64_t GetBin(const char *name[]) const =0
virtual Double_t GetBinError2(Long64_t linidx) const =0
virtual void Reset(Option_t *option="")=0
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition: THnBase.h:277
void SetBinContent(const Int_t *idx, Double_t v)
Definition: THnBase.h:197
virtual void FillBin(Long64_t bin, Double_t w)=0
virtual Long64_t GetBin(const Double_t *x) const =0
void UpdateXStat(const Double_t *x, Double_t w=1.)
Definition: THnBase.h:69
void Multiply(const THnBase *h)
Multiply this histogram by histogram h this = this * h Note that if h has Sumw2 set,...
Definition: THnBase.cxx:778
void Divide(const THnBase *h)
Divide this histogram by h this = this/(h) Note that if h has Sumw2 set, Sumw2 is automatically calle...
Definition: THnBase.cxx:869
Long64_t Fill(const char *name[], Double_t w=1.)
Definition: THnBase.h:147
Double_t GetSumwx2(Int_t dim) const
Definition: THnBase.h:206
Double_t GetWeightSum() const
Definition: THnBase.h:131
TObjArray fBrowsables
! Browser-helpers for each axis
Definition: THnBase.h:47
void Print(Option_t *option="") const
Print a THnBase.
Definition: THnBase.cxx:1356
Double_t GetSumw() const
Definition: THnBase.h:203
TObject * ProjectionAny(Int_t ndim, const Int_t *dim, Bool_t wantNDim, Option_t *option="") const
Project all bins into a ndim-dimensional THn / THnSparse (whatever *this is) or if (ndim < 4 and !...
Definition: THnBase.cxx:476
void GetRandom(Double_t *rand, Bool_t subBinRandom=kTRUE)
Generate an n-dimensional random tuple based on the histogrammed distribution.
Definition: THnBase.cxx:415
TAxis * GetAxis(Int_t dim) const
Definition: THnBase.h:122
THnBase * CloneEmpty(const char *name, const char *title, const TObjArray *axes, Bool_t keepTargetAxis) const
Create a new THnBase object that is of the same type as *this, but with dimensions and bins given by ...
Definition: THnBase.cxx:101
Long64_t Merge(TCollection *list)
Merge this with a list of THnBase's.
Definition: THnBase.cxx:743
Double_t fTsumw
Total sum of weights.
Definition: THnBase.h:49
virtual Long64_t GetBin(const Int_t *idx) const =0
Double_t ComputeIntegral()
Calculate the integral of the histogram.
Definition: THnBase.cxx:1187
virtual void AddBinError2(Long64_t bin, Double_t e2)=0
void RebinnedAdd(const THnBase *h, Double_t c=1.)
Add contents of h scaled by c to this histogram: this = this + c * h Note that if h has Sumw2 set,...
Definition: THnBase.cxx:733
void SetTitle(const char *title)
Change (i.e.
Definition: THnBase.cxx:1042
void SetBinError(Long64_t bin, Double_t e)
Definition: THnBase.h:182
void CalculateErrors(Bool_t calc=kTRUE)
Calculate errors (or not if "calc" == kFALSE)
Definition: THnBase.h:136
Int_t fNdimensions
Number of dimensions.
Definition: THnBase.h:45
TH2D * Projection(Int_t yDim, Int_t xDim, Option_t *option="") const
Project all bins into a 2-dimensional histogram, keeping only axes "xDim" and "yDim".
Definition: THnBase.h:229
void Init(const char *name, const char *title, const TObjArray *axes, Bool_t keepTargetAxis, Int_t chunkSize=1024 *16)
Initialize axes and name.
Definition: THnBase.cxx:117
void FillBinBase(Double_t w)
Increment the statistics due to filled weight "w",.
Definition: THnBase.h:81
std::vector< Double_t > fIntegral
! vector with bin weight sums
Definition: THnBase.h:53
TArrayD fTsumwx
Total sum of weight*X for each dimension.
Definition: THnBase.h:51
Iterator over THnBase bins.
Definition: THnBase.h:322
Long64_t Next(Int_t *coord=0)
Return the next bin's index.
Definition: THnBase.h:332
Bool_t HaveSkippedBin() const
Definition: THnBase.h:337
THnIter(const THnBase *hist, Bool_t respectAxisRange=kFALSE)
Definition: THnBase.h:324
Int_t GetCoord(Int_t dim) const
Definition: THnBase.h:336
virtual ~THnIter()
Definition: THnBase.cxx:1438
ROOT::Internal::THnBaseBinIter * fIter
Definition: THnBase.h:341
Bool_t RespectsAxisRange() const
Definition: THnBase.h:338
A doubly linked list.
Definition: TList.h:44
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
An array of TObjects.
Definition: TObjArray.h:37
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:893
return c1
Definition: legend1.C:41
Double_t x[n]
Definition: legend1.C:17
TH1F * h1
Definition: legend1.C:5
TF1 * f1
Definition: legend1.C:11
return c2
Definition: legend2.C:14
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Double_t Sqrt(Double_t x)
Definition: TMath.h:641
const double xbins[xbins_n]