Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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 THnBase(const THnBase &other);
70
71 THnBase &operator=(const THnBase &other);
72
73 THnBase(THnBase &&other);
74
75 THnBase &operator=(THnBase &&other);
76
77 void UpdateXStat(const Double_t *x, Double_t w = 1.)
78 {
79 if (GetCalculateErrors()) {
80 for (Int_t d = 0; d < fNdimensions; ++d) {
81 const Double_t xd = x[d];
82 fTsumwx[d] += w * xd;
83 fTsumwx2[d] += w * xd * xd;
84 }
85 }
86 }
87
88 /// Increment the statistics due to filled weight "w",
90 fEntries += 1;
91 if (GetCalculateErrors()) {
92 fTsumw += w;
93 fTsumw2 += w*w;
94 }
96 }
97
98 virtual void InitStorage(Int_t* nbins, Int_t chunkSize) = 0;
99 void Init(const char* name, const char* title,
100 const TObjArray* axes, Bool_t keepTargetAxis,
101 Int_t chunkSize = 1024 * 16);
102 THnBase* CloneEmpty(const char* name, const char* title,
103 const TObjArray* axes, Bool_t keepTargetAxis) const;
104 virtual void Reserve(Long64_t /*nbins*/) {}
105 virtual void SetFilledBins(Long64_t /*nbins*/) {};
106
107 Bool_t CheckConsistency(const THnBase *h, const char *tag) const;
108 TH1* CreateHist(const char* name, const char* title,
109 const TObjArray* axes, Bool_t keepTargetAxis) const;
110 TObject* ProjectionAny(Int_t ndim, const Int_t* dim,
111 Bool_t wantNDim, Option_t* option = "") const;
112 Bool_t PrintBin(Long64_t idx, Int_t* coord, Option_t* options) const;
113 void AddInternal(const THnBase* h, Double_t c, Bool_t rebinned);
115 THnBase* RebinBase(const Int_t* group) const;
116 void ResetBase(Option_t *option= "");
117
118 static THnBase* CreateHnAny(const char* name, const char* title,
119 const TH1* h1, Bool_t sparse,
120 Int_t chunkSize = 1024 * 16);
121 static THnBase* CreateHnAny(const char* name, const char* title,
122 const THnBase* hn, Bool_t sparse,
123 Int_t chunkSize = 1024 * 16);
124
125 public:
126 ~THnBase() override;
127
129 const TObjArray* GetListOfAxes() const { return &fAxes; }
130 TAxis* GetAxis(Int_t dim) const { return (TAxis*)fAxes[dim]; }
131
132 TFitResultPtr Fit(TF1 *f1 ,Option_t *option = "", Option_t *goption = "");
133 TList* GetListOfFunctions() { return nullptr; }
134
135 virtual ROOT::Internal::THnBaseBinIter* CreateIter(Bool_t respectAxisRange) const = 0;
136
137 virtual Long64_t GetNbins() const = 0;
138 Double_t GetEntries() const { return fEntries; }
139 Double_t GetWeightSum() const { return fTsumw; }
141 Bool_t GetCalculateErrors() const { return fTsumw2 >= 0.; }
142
143 /// Calculate errors (or not if "calc" == kFALSE)
145 if (calc) Sumw2();
146 else fTsumw2 = -1.;
147 }
148
150 UpdateXStat(x, w);
151 Long64_t bin = GetBin(x, kTRUE /*alloc*/);
152 FillBin(bin, w);
153 return bin;
154 }
155 Long64_t Fill(const char* name[], Double_t w = 1.) {
156 Long64_t bin = GetBin(name, kTRUE /*alloc*/);
157 FillBin(bin, w);
158 return bin;
159 }
160
161 /// Fill with the provided variadic arguments.
162 /// The number of arguments must be equal to the number of histogram dimensions or, for weighted fills, to the
163 /// number of dimensions + 1; in the latter case, the last function argument is used as weight.
164 /// A separate `firstval` argument is needed so the compiler does not pick this overload instead of the non-templated
165 /// Fill overloads
166 template <typename... MoreTypes>
167 Long64_t Fill(Double_t firstval, MoreTypes... morevals)
168 {
169 const std::array<double, 1 + sizeof...(morevals)> x{firstval, static_cast<double>(morevals)...};
170 if (Int_t(x.size()) == GetNdimensions()) {
171 // without weight
172 return Fill(x.data());
173 } else if (Int_t(x.size()) == (GetNdimensions() + 1)) {
174 // with weight
175 return Fill(x.data(), x.back());
176 } else {
177 Error("Fill", "Wrong number of arguments for number of histogram axes.");
178 }
179
180 return -1;
181 }
182
183 virtual void FillBin(Long64_t bin, Double_t w) = 0;
184
185 void SetBinEdges(Int_t idim, const Double_t* bins);
186 Bool_t IsInRange(Int_t *coord) const;
187 Double_t GetBinError(const Int_t *idx) const { return GetBinError(GetBin(idx)); }
188 Double_t GetBinError(Long64_t linidx) const { return TMath::Sqrt(GetBinError2(linidx)); }
189 void SetBinError(const Int_t* idx, Double_t e) { SetBinError(GetBin(idx), e); }
191 void AddBinContent(const Int_t* x, Double_t v = 1.) { AddBinContent(GetBin(x), v); }
192 void SetEntries(Double_t entries) { fEntries = entries; }
193 void SetTitle(const char *title) override;
194
195 std::vector<Double_t> GetBinCenter(const std::vector<Int_t> &idx) const;
196
197 Double_t GetBinContent(const Int_t *idx) const { return GetBinContent(GetBin(idx)); } // intentionally non-virtual
198 virtual Double_t GetBinContent(Long64_t bin, Int_t* idx = nullptr) const = 0;
199 virtual Double_t GetBinError2(Long64_t linidx) const = 0;
200 virtual Long64_t GetBin(const Int_t* idx) const = 0;
201 virtual Long64_t GetBin(const Double_t* x) const = 0;
202 virtual Long64_t GetBin(const char* name[]) const = 0;
203 virtual Long64_t GetBin(const Int_t* idx, Bool_t /*allocate*/ = kTRUE) = 0;
204 virtual Long64_t GetBin(const Double_t* x, Bool_t /*allocate*/ = kTRUE) = 0;
205 virtual Long64_t GetBin(const char* name[], Bool_t /*allocate*/ = kTRUE) = 0;
206
207 void SetBinContent(const Int_t* idx, Double_t v) { SetBinContent(GetBin(idx), v); } // intentionally non-virtual
208 virtual void SetBinContent(Long64_t bin, Double_t v) = 0;
209 virtual void SetBinError2(Long64_t bin, Double_t e2) = 0;
210 virtual void AddBinError2(Long64_t bin, Double_t e2) = 0;
211 virtual void AddBinContent(Long64_t bin, Double_t v = 1.) = 0;
212
213 Double_t GetSumw() const { return fTsumw; }
214 Double_t GetSumw2() const { return fTsumw2; }
215 Double_t GetSumwx(Int_t dim) const { return fTsumwx[dim]; }
216 Double_t GetSumwx2(Int_t dim) const { return fTsumwx2[dim]; }
217
218 /// Project all bins into a 1-dimensional histogram,
219 /// keeping only axis "xDim".
220 /// If "option" contains:
221 /// - "E" errors will be calculated.
222 /// - "A" ranges of the taget axes will be ignored.
223 /// - "O" original axis range of the taget axes will be
224 /// kept, but only bins inside the selected range
225 /// will be filled.
226 TH1D* Projection(Int_t xDim, Option_t* option = "") const {
227 return (TH1D*) ProjectionAny(1, &xDim, false, option);
228 }
229
230 /// Project all bins into a 2-dimensional histogram,
231 /// keeping only axes "xDim" and "yDim".
232 ///
233 /// WARNING: just like TH3::Project3D("yx") and TTree::Draw("y:x"),
234 /// Projection(y,x) uses the first argument to define the y-axis and the
235 /// second for the x-axis!
236 ///
237 /// If "option" contains "E" errors will be calculated.
238 /// "A" ranges of the taget axes will be ignored.
239 TH2D* Projection(Int_t yDim, Int_t xDim, Option_t* option = "") const {
240 const Int_t dim[2] = {xDim, yDim};
241 return (TH2D*) ProjectionAny(2, dim, false, option);
242 }
243
244 /// Project all bins into a 3-dimensional histogram,
245 /// keeping only axes "xDim", "yDim", and "zDim".
246 /// If "option" contains:
247 /// - "E" errors will be calculated.
248 /// - "A" ranges of the taget axes will be ignored.
249 /// - "O" original axis range of the taget axes will be
250 /// kept, but only bins inside the selected range
251 /// will be filled.
252 TH3D* Projection(Int_t xDim, Int_t yDim, Int_t zDim, Option_t* option = "") const {
253 const Int_t dim[3] = {xDim, yDim, zDim};
254 return (TH3D*) ProjectionAny(3, dim, false, option);
255 }
256
257 THnBase* ProjectionND(Int_t ndim, const Int_t* dim,
258 Option_t* option = "") const {
259 return (THnBase*)ProjectionAny(ndim, dim, kTRUE /*wantNDim*/, option);
260 }
261
263
264 void Scale(Double_t c);
265 void Add(const THnBase* h, Double_t c=1.);
266 void Add(const TH1* hist, Double_t c=1.);
267 void Multiply(const THnBase* h);
268 void Multiply(TF1* f, Double_t c = 1.);
269 void Divide(const THnBase* h);
270 void Divide(const THnBase* h1, const THnBase* h2, Double_t c1 = 1., Double_t c2 = 1., Option_t* option="");
271 void RebinnedAdd(const THnBase* h, Double_t c=1.);
272
273 virtual void Reset(Option_t* option = "") = 0;
274 virtual void Sumw2() = 0;
275
277 void GetRandom(Double_t *rand, Bool_t subBinRandom = kTRUE);
278 Double_t Integral(Bool_t respectAxisRange) const;
279
280 void Print(Option_t* option = "") const override;
281 void PrintEntries(Long64_t from = 0, Long64_t howmany = -1, Option_t* options = nullptr) const;
282 void PrintBin(Int_t* coord, Option_t* options) const {
283 PrintBin(-1, coord, options);
284 }
285 void PrintBin(Long64_t idx, Option_t* options) const;
286
287 void Browse(TBrowser *b) override;
288 Bool_t IsFolder() const override { return kTRUE; }
289
290 //void Draw(Option_t* option = "");
291
292 ClassDefOverride(THnBase, 1); // Common base for n-dimensional histogram
293
294 friend class THnIter;
295};
296
297namespace ROOT {
298namespace Internal {
299 // Helper class for browsing THnBase objects
300 class THnBaseBrowsable: public TNamed {
301 public:
302 THnBaseBrowsable(THnBase* hist, Int_t axis);
303 ~THnBaseBrowsable() override;
304 void Browse(TBrowser *b) override;
305 Bool_t IsFolder() const override { return kFALSE; }
306
307 private:
308 THnBase* fHist; // Original histogram
309 Int_t fAxis; // Axis to visualize
310 TH1* fProj; // Projection result
311 ClassDefOverride(THnBaseBrowsable, 0); // Browser-helper for THnBase
312 };
313
314 // Base class for iterating over THnBase bins
316 public:
317 THnBaseBinIter(Bool_t respectAxisRange):
318 fRespectAxisRange(respectAxisRange), fHaveSkippedBin(kFALSE) {}
319 virtual ~THnBaseBinIter();
322
323 virtual Int_t GetCoord(Int_t dim) const = 0;
324 virtual Long64_t Next(Int_t* coord = nullptr) = 0;
325
326 protected:
329 };
330}
331}
332
333class THnIter: public TObject {
334public:
335 THnIter(const THnBase* hist, Bool_t respectAxisRange = kFALSE):
336 fIter(hist->CreateIter(respectAxisRange)) {}
337 ~THnIter() override;
338
339 /// Return the next bin's index.
340 /// If provided, set coord to that bin's coordinates (bin indexes).
341 /// I.e. coord must point to Int_t[hist->GetNdimensions()]
342 /// Returns -1 when all bins have been visited.
343 Long64_t Next(Int_t* coord = nullptr) {
344 return fIter->Next(coord);
345 }
346
347 Int_t GetCoord(Int_t dim) const { return fIter->GetCoord(dim); }
350
351private:
353 ClassDefOverride(THnIter, 0); //Iterator over bins of a THnBase.
354};
355
356#endif // ROOT_THnBase
#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
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
double Double_t
Definition RtypesCore.h:59
long long Long64_t
Definition RtypesCore.h:69
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
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
float xmin
float xmax
Iterator over THnBase bins (internal implementation).
Definition THnBase.h:315
Bool_t RespectsAxisRange() const
Definition THnBase.h:321
Bool_t HaveSkippedBin() const
Definition THnBase.h:320
virtual Int_t GetCoord(Int_t dim) const =0
THnBaseBinIter(Bool_t respectAxisRange)
Definition THnBase.h:317
virtual ~THnBaseBinIter()
Destruct a bin iterator.
Definition THnBase.cxx:1605
virtual Long64_t Next(Int_t *coord=nullptr)=0
TBrowser helper for THnBase.
Definition THnBase.h:300
~THnBaseBrowsable() override
Destruct a THnBaseBrowsable.
Definition THnBase.cxx:1649
Bool_t IsFolder() const override
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition THnBase.h:305
void Browse(TBrowser *b) override
Browse an axis of a THnBase, i.e. draw its projection.
Definition THnBase.cxx:1657
Array of doubles (64 bits per element).
Definition TArrayD.h:27
Class to manage histogram axis.
Definition TAxis.h:31
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:233
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
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
2-D histogram with a double per channel (see TH1 documentation)
Definition TH2.h:358
3-D histogram with a double per channel (see TH1 documentation)
Definition TH3.h:364
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:192
virtual void SetFilledBins(Long64_t)
Definition THnBase.h:105
void Browse(TBrowser *b) override
Browse a THnSparse: create an entry (ROOT::THnSparseBrowsable) for each dimension.
Definition THnBase.cxx:1582
const TObjArray * GetListOfAxes() const
Definition THnBase.h:129
Long64_t Fill(const Double_t *x, Double_t w=1.)
Definition THnBase.h:149
virtual void InitStorage(Int_t *nbins, Int_t chunkSize)=0
Double_t GetBinError(const Int_t *idx) const
Definition THnBase.h:187
void SetBinError(const Int_t *idx, Double_t e)
Definition THnBase.h:189
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:214
Bool_t IsInRange(Int_t *coord) const
Check whether bin coord is in range, as defined by TAxis::SetRange().
Definition THnBase.cxx:592
TList * GetListOfFunctions()
Definition THnBase.h:133
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:505
void AddBinContent(const Int_t *x, Double_t v=1.)
Definition THnBase.h:191
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:774
virtual void SetBinError2(Long64_t bin, Double_t e2)=0
TObjArray * GetListOfAxes()
Definition THnBase.h:128
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:252
Bool_t PrintBin(Long64_t idx, Int_t *coord, Option_t *options) const
Print one bin.
Definition THnBase.cxx:1440
TH1D * Projection(Int_t xDim, Option_t *option="") const
Project all bins into a 1-dimensional histogram, keeping only axis "xDim".
Definition THnBase.h:226
Double_t GetSumwx(Int_t dim) const
Definition THnBase.h:215
@ 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:1162
Int_t GetNdimensions() const
Definition THnBase.h:140
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:252
~THnBase() override
Destruct a THnBase.
Definition THnBase.cxx:167
void PrintBin(Int_t *coord, Option_t *options) const
Definition THnBase.h:282
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:323
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:1327
virtual Long64_t GetNbins() const =0
Bool_t IsFolder() const override
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition THnBase.h:288
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:1232
THnBase * ProjectionND(Int_t ndim, const Int_t *dim, Option_t *option="") const
Definition THnBase.h:257
TObjArray fAxes
Axes of the histogram.
Definition THnBase.h:46
void SetBinEdges(Int_t idim, const Double_t *bins)
Set the axis # of bins and bin limits on dimension idim.
Definition THnBase.cxx:1180
Bool_t GetCalculateErrors() const
Definition THnBase.h:141
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:798
void SetTitle(const char *title) override
Change (i.e.
Definition THnBase.cxx:1196
void PrintEntries(Long64_t from=0, Long64_t howmany=-1, Option_t *options=nullptr) const
Print "howmany" entries starting at "from".
Definition THnBase.cxx:1484
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:188
Double_t GetBinContent(const Int_t *idx) const
Definition THnBase.h:197
virtual Long64_t GetBin(const Double_t *x, Bool_t=kTRUE)=0
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:871
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:104
THnBase()
Definition THnBase.h:61
Double_t GetEntries() const
Definition THnBase.h:138
Long64_t Fill(Double_t firstval, MoreTypes... morevals)
Fill with the provided variadic arguments.
Definition THnBase.h:167
std::vector< Double_t > GetBinCenter(const std::vector< Int_t > &idx) const
THnBase::GetBinCenter.
Definition THnBase.cxx:534
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
void SetBinContent(const Int_t *idx, Double_t v)
Definition THnBase.h:207
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:77
virtual Double_t GetBinContent(Long64_t bin, Int_t *idx=nullptr) const =0
void Multiply(const THnBase *h)
Multiply this histogram by histogram h this = this * h Note that if h has Sumw2 set,...
Definition THnBase.cxx:932
Double_t Integral(Bool_t respectAxisRange) const
Compute integral (sum of counts) of histogram in all dimensions.
Definition THnBase.cxx:1345
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:1023
void Print(Option_t *option="") const override
Print a THnBase.
Definition THnBase.cxx:1535
Long64_t Fill(const char *name[], Double_t w=1.)
Definition THnBase.h:155
Double_t GetSumwx2(Int_t dim) const
Definition THnBase.h:216
Double_t GetWeightSum() const
Definition THnBase.h:139
TObjArray fBrowsables
! Browser-helpers for each axis
Definition THnBase.h:47
Double_t GetSumw() const
Definition THnBase.h:213
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:618
void GetRandom(Double_t *rand, Bool_t subBinRandom=kTRUE)
Generate an n-dimensional random tuple based on the histogrammed distribution.
Definition THnBase.cxx:557
TAxis * GetAxis(Int_t dim) const
Definition THnBase.h:130
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:179
Long64_t Merge(TCollection *list)
Merge this with a list of THnBase's.
Definition THnBase.cxx:897
Double_t fTsumw
Total sum of weights.
Definition THnBase.h:49
virtual Long64_t GetBin(const Int_t *idx) const =0
Double_t ComputeIntegral()
Compute integral (normalized cumulative sum of bins) w/o under/overflows The result is stored in fInt...
Definition THnBase.cxx:1365
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:887
void SetBinError(Long64_t bin, Double_t e)
Definition THnBase.h:190
void CalculateErrors(Bool_t calc=kTRUE)
Calculate errors (or not if "calc" == kFALSE)
Definition THnBase.h:144
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:239
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:195
void FillBinBase(Double_t w)
Increment the statistics due to filled weight "w",.
Definition THnBase.h:89
THnBase & operator=(const THnBase &other)
Definition THnBase.cxx:101
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:333
Bool_t HaveSkippedBin() const
Definition THnBase.h:348
THnIter(const THnBase *hist, Bool_t respectAxisRange=kFALSE)
Definition THnBase.h:335
Int_t GetCoord(Int_t dim) const
Definition THnBase.h:347
ROOT::Internal::THnBaseBinIter * fIter
Definition THnBase.h:352
~THnIter() override
Definition THnBase.cxx:1617
Bool_t RespectsAxisRange() const
Definition THnBase.h:349
Long64_t Next(Int_t *coord=nullptr)
Return the next bin's index.
Definition THnBase.h:343
A doubly linked list.
Definition TList.h:38
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
An array of TObjects.
Definition TObjArray.h:31
Mother of all ROOT objects.
Definition TObject.h:41
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1005
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
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:666