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#include <vector>
29
30
31class TAxis;
32class TH1;
33class TH1D;
34class TH2D;
35class TH3D;
36class TF1;
37class THnIter;
38
39namespace ROOT {
40namespace Internal {
41 class THnBaseBinIter;
42}
43}
44
45class THnBase: public TNamed {
46protected:
47 Int_t fNdimensions; ///< Number of dimensions
48 TObjArray fAxes; ///< Axes of the histogram
49 TObjArray fBrowsables; ///<! Browser-helpers for each axis
50 Double_t fEntries; ///< Number of entries, spread over chunks
51 Double_t fTsumw; ///< Total sum of weights
52 Double_t fTsumw2; ///< Total sum of weights squared; -1 if no errors are calculated
53 TArrayD fTsumwx; ///< Total sum of weight*X for each dimension
54 TArrayD fTsumwx2; ///< Total sum of weight*X*X for each dimension
55 std::vector<Double_t> fIntegral; ///<! vector with bin weight sums
56 enum {
60 } fIntegralStatus; ///<! status of integral
61
62 protected:
64
65 THnBase(const char *name, const char *title, Int_t dim, const Int_t *nbins, const Double_t *xmin,
66 const Double_t *xmax);
67
68 THnBase(const char* name, const char* title, const std::vector<TAxis>& axes);
69
70 THnBase(const char *name, const char *title, Int_t dim, const Int_t *nbins,
71 const std::vector<std::vector<double>> &xbins);
72
73 THnBase(const THnBase &other);
74
76
78
80
81 void UpdateXStat(const Double_t *x, Double_t w = 1.)
82 {
83 if (GetCalculateErrors()) {
84 for (Int_t d = 0; d < fNdimensions; ++d) {
85 const Double_t xd = x[d];
86 fTsumwx[d] += w * xd;
87 fTsumwx2[d] += w * xd * xd;
88 }
89 }
90 }
91
92 /// Increment the statistics due to filled weight "w",
94 fEntries += 1;
95 if (GetCalculateErrors()) {
96 fTsumw += w;
97 fTsumw2 += w*w;
98 }
100 }
101
102 virtual void InitStorage(Int_t* nbins, Int_t chunkSize) = 0;
103 void Init(const char* name, const char* title,
104 const TObjArray* axes, Bool_t keepTargetAxis,
105 Int_t chunkSize = 1024 * 16);
106 THnBase* CloneEmpty(const char* name, const char* title,
107 const TObjArray* axes, Bool_t keepTargetAxis) const;
108 virtual void Reserve(Long64_t /*nbins*/) {}
109 virtual void SetFilledBins(Long64_t /*nbins*/) {};
110
111 Bool_t CheckConsistency(const THnBase *h, const char *tag) const;
112 TH1* CreateHist(const char* name, const char* title,
113 const TObjArray* axes, Bool_t keepTargetAxis) const;
114 TObject* ProjectionAny(Int_t ndim, const Int_t* dim,
115 Bool_t wantNDim, Option_t* option = "") const;
116 Bool_t PrintBin(Long64_t idx, Int_t* coord, Option_t* options) const;
119 THnBase* RebinBase(const Int_t* group) const;
120 void ResetBase(Option_t *option= "");
121 void SetTitleImpl(const char *title, bool overrideAxesTitle);
122
123 static THnBase* CreateHnAny(const char* name, const char* title,
124 const TH1* h1, Bool_t sparse,
125 Int_t chunkSize = 1024 * 16);
126 static THnBase* CreateHnAny(const char* name, const char* title,
127 const THnBase* hn, Bool_t sparse,
128 Int_t chunkSize = 1024 * 16);
129
130 public:
131 ~THnBase() override;
132
134 const TObjArray* GetListOfAxes() const { return &fAxes; }
135 TAxis* GetAxis(Int_t dim) const { return (TAxis*)fAxes[dim]; }
136
138 TList* GetListOfFunctions() { return nullptr; }
139
141
142 virtual Long64_t GetNbins() const = 0;
143 Double_t GetEntries() const { return fEntries; }
144 Double_t GetWeightSum() const { return fTsumw; }
146 Bool_t GetCalculateErrors() const { return fTsumw2 >= 0.; }
147
148 /// Calculate errors (or not if "calc" == kFALSE)
150 if (calc) Sumw2();
151 else fTsumw2 = -1.;
152 }
153
155 UpdateXStat(x, w);
156 Long64_t bin = GetBin(x, kTRUE /*alloc*/);
157 FillBin(bin, w);
158 return bin;
159 }
160 Long64_t Fill(const char* name[], Double_t w = 1.) {
161 Long64_t bin = GetBin(name, kTRUE /*alloc*/);
162 FillBin(bin, w);
163 return bin;
164 }
165
166 /// Fill with the provided variadic arguments.
167 /// The number of arguments must be equal to the number of histogram dimensions or, for weighted fills, to the
168 /// number of dimensions + 1; in the latter case, the last function argument is used as weight.
169 /// A separate `firstval` argument is needed so the compiler does not pick this overload instead of the non-templated
170 /// Fill overloads
171 template <typename... MoreTypes>
173 {
174 const std::array<double, 1 + sizeof...(morevals)> x{firstval, static_cast<double>(morevals)...};
175 if (Int_t(x.size()) == GetNdimensions()) {
176 // without weight
177 return Fill(x.data());
178 } else if (Int_t(x.size()) == (GetNdimensions() + 1)) {
179 // with weight
180 return Fill(x.data(), x.back());
181 } else {
182 Error("Fill", "Wrong number of arguments for number of histogram axes.");
183 }
184
185 return -1;
186 }
187
188 virtual void FillBin(Long64_t bin, Double_t w) = 0;
189
190 void SetBinEdges(Int_t idim, const Double_t* bins);
191 Bool_t IsInRange(Int_t *coord) const;
192 Double_t GetBinError(const Int_t *idx) const { return GetBinError(GetBin(idx)); }
194 void SetBinError(const Int_t* idx, Double_t e) { SetBinError(GetBin(idx), e); }
196 void AddBinContent(const Int_t* x, Double_t v = 1.) { AddBinContent(GetBin(x), v); }
197 void SetEntries(Double_t entries) { fEntries = entries; }
198 void SetTitle(const char *title) override;
199
200 std::vector<Double_t> GetBinCenter(const std::vector<Int_t> &idx) const;
201
202 Double_t GetBinContent(const Int_t *idx) const { return GetBinContent(GetBin(idx)); } // intentionally non-virtual
203 virtual Double_t GetBinContent(Long64_t bin, Int_t* idx = nullptr) const = 0;
205 virtual Long64_t GetBin(const Int_t* idx) const = 0;
206 virtual Long64_t GetBin(const Double_t* x) const = 0;
207 virtual Long64_t GetBin(const char* name[]) const = 0;
208 virtual Long64_t GetBin(const Int_t* idx, Bool_t /*allocate*/ = kTRUE) = 0;
209 virtual Long64_t GetBin(const Double_t* x, Bool_t /*allocate*/ = kTRUE) = 0;
210 virtual Long64_t GetBin(const char* name[], Bool_t /*allocate*/ = kTRUE) = 0;
211
212 void SetBinContent(const Int_t* idx, Double_t v) { SetBinContent(GetBin(idx), v); } // intentionally non-virtual
213 virtual void SetBinContent(Long64_t bin, Double_t v) = 0;
214 virtual void SetBinError2(Long64_t bin, Double_t e2) = 0;
215 virtual void AddBinError2(Long64_t bin, Double_t e2) = 0;
216 virtual void AddBinContent(Long64_t bin, Double_t v = 1.) = 0;
217
218 Double_t GetSumw() const { return fTsumw; }
219 Double_t GetSumw2() const { return fTsumw2; }
220 Double_t GetSumwx(Int_t dim) const { return fTsumwx[dim]; }
221 Double_t GetSumwx2(Int_t dim) const { return fTsumwx2[dim]; }
222
223 /// Project all bins into a 1-dimensional histogram,
224 /// keeping only axis "xDim".
225 /// If "option" contains:
226 /// - "E" errors will be calculated.
227 /// - "A" ranges of the taget axes will be ignored.
228 /// - "O" original axis range of the taget axes will be
229 /// kept, but only bins inside the selected range
230 /// will be filled.
232 return (TH1D*) ProjectionAny(1, &xDim, false, option);
233 }
234
235 /// Project all bins into a 2-dimensional histogram,
236 /// keeping only axes "xDim" and "yDim".
237 ///
238 /// WARNING: just like TH3::Project3D("yx") and TTree::Draw("y:x"),
239 /// Projection(y,x) uses the first argument to define the y-axis and the
240 /// second for the x-axis!
241 ///
242 /// If "option" contains "E" errors will be calculated.
243 /// "A" ranges of the taget axes will be ignored.
245 const Int_t dim[2] = {xDim, yDim};
246 return (TH2D*) ProjectionAny(2, dim, false, option);
247 }
248
249 /// Project all bins into a 3-dimensional histogram,
250 /// keeping only axes "xDim", "yDim", and "zDim".
251 /// If "option" contains:
252 /// - "E" errors will be calculated.
253 /// - "A" ranges of the taget axes will be ignored.
254 /// - "O" original axis range of the taget axes will be
255 /// kept, but only bins inside the selected range
256 /// will be filled.
258 const Int_t dim[3] = {xDim, yDim, zDim};
259 return (TH3D*) ProjectionAny(3, dim, false, option);
260 }
261
262 /// @brief Project histogram onto the axes specified in dim.
263 /// @param ndim Size of the dim array.
264 /// @param dim Indices of the axes to project on.
265 /// @param option - "E" errors will be calculated.
266 /// - "A" ranges of the target axes will be ignored.
267 /// - "O" original axis range of the target axes will be kept, but only bins inside the selected range
268 /// will be filled.
269 /// @return A new THnBase derived class, such as THN or THNSparse.
270 THnBase* ProjectionND(Int_t ndim, const Int_t* dim,
271 Option_t* option = "") const {
272 return (THnBase*)ProjectionAny(ndim, dim, kTRUE /*wantNDim*/, option);
273 }
274
276
277 void Scale(Double_t c);
278 void Add(const THnBase* h, Double_t c=1.);
279 void Add(const TH1* hist, Double_t c=1.);
280 void Multiply(const THnBase* h);
281 void Multiply(TF1* f, Double_t c = 1.);
282 void Divide(const THnBase* h);
283 void Divide(const THnBase* h1, const THnBase* h2, Double_t c1 = 1., Double_t c2 = 1., Option_t* option="");
284 void RebinnedAdd(const THnBase* h, Double_t c=1.);
285
286 virtual void Reset(Option_t* option = "") = 0;
287 virtual void Sumw2() = 0;
288
292
293 void Print(Option_t* option = "") const override;
294 void PrintEntries(Long64_t from = 0, Long64_t howmany = -1, Option_t* options = nullptr) const;
295 void PrintBin(Int_t* coord, Option_t* options) const {
296 PrintBin(-1, coord, options);
297 }
298 void PrintBin(Long64_t idx, Option_t* options) const;
299
300 void Browse(TBrowser *b) override;
301 Bool_t IsFolder() const override { return kTRUE; }
302
303 //void Draw(Option_t* option = "");
304
305 ClassDefOverride(THnBase, 1); // Common base for n-dimensional histogram
306
307 friend class THnIter;
308};
309
310namespace ROOT {
311namespace Internal {
312 // Helper class for browsing THnBase objects
313 class THnBaseBrowsable: public TNamed {
314 public:
315 THnBaseBrowsable(THnBase* hist, Int_t axis);
316 ~THnBaseBrowsable() override;
317 void Browse(TBrowser *b) override;
318 Bool_t IsFolder() const override { return kFALSE; }
319
320 private:
321 THnBase* fHist; // Original histogram
322 Int_t fAxis; // Axis to visualize
323 TH1* fProj; // Projection result
324 ClassDefOverride(THnBaseBrowsable, 0); // Browser-helper for THnBase
325 };
326
327 // Base class for iterating over THnBase bins
343}
344}
345
346class THnIter: public TObject {
347public:
349 fIter(hist->CreateIter(respectAxisRange)) {}
350 ~THnIter() override;
351
352 /// Return the next bin's index.
353 /// If provided, set coord to that bin's coordinates (bin indexes).
354 /// I.e. coord must point to Int_t[hist->GetNdimensions()]
355 /// Returns -1 when all bins have been visited.
356 Long64_t Next(Int_t* coord = nullptr) {
357 return fIter->Next(coord);
358 }
359
360 Int_t GetCoord(Int_t dim) const { return fIter->GetCoord(dim); }
363
364private:
366 ClassDefOverride(THnIter, 0); //Iterator over bins of a THnBase.
367};
368
369#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
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
double Double_t
Double 8 bytes.
Definition RtypesCore.h:73
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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:328
Bool_t RespectsAxisRange() const
Definition THnBase.h:334
Bool_t HaveSkippedBin() const
Definition THnBase.h:333
virtual Int_t GetCoord(Int_t dim) const =0
THnBaseBinIter(Bool_t respectAxisRange)
Definition THnBase.h:330
virtual ~THnBaseBinIter()
Destruct a bin iterator.
Definition THnBase.cxx:1621
virtual Long64_t Next(Int_t *coord=nullptr)=0
TBrowser helper for THnBase.
Definition THnBase.h:313
~THnBaseBrowsable() override
Destruct a THnBaseBrowsable.
Definition THnBase.cxx:1663
THnBaseBrowsable(THnBase *hist, Int_t axis)
Construct a THnBaseBrowsable.
Definition THnBase.cxx:1647
Bool_t IsFolder() const override
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition THnBase.h:318
void Browse(TBrowser *b) override
Browse an axis of a THnBase, i.e. draw its projection.
Definition THnBase.cxx:1671
Array of doubles (64 bits per element).
Definition TArrayD.h:27
Class to manage histogram axis.
Definition TAxis.h:32
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:182
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:926
TH1 is the base class of all histogram classes in ROOT.
Definition TH1.h:109
2-D histogram with a double per channel (see TH1 documentation)
Definition TH2.h:400
3-D histogram with a double per channel (see TH1 documentation)
Definition TH3.h:424
Multidimensional histogram base.
Definition THnBase.h:45
virtual void Sumw2()=0
virtual ROOT::Internal::THnBaseBinIter * CreateIter(Bool_t respectAxisRange) const =0
void SetEntries(Double_t entries)
Definition THnBase.h:197
virtual void SetFilledBins(Long64_t)
Definition THnBase.h:109
void Browse(TBrowser *b) override
Browse a THnSparse: create an entry (ROOT::THnSparseBrowsable) for each dimension.
Definition THnBase.cxx:1598
const TObjArray * GetListOfAxes() const
Definition THnBase.h:134
Long64_t Fill(const Double_t *x, Double_t w=1.)
Definition THnBase.h:154
virtual void InitStorage(Int_t *nbins, Int_t chunkSize)=0
Double_t GetBinError(const Int_t *idx) const
Definition THnBase.h:192
void SetBinError(const Int_t *idx, Double_t e)
Definition THnBase.h:194
Double_t fEntries
Number of entries, spread over chunks.
Definition THnBase.h:50
virtual void AddBinContent(Long64_t bin, Double_t v=1.)=0
Double_t GetSumw2() const
Definition THnBase.h:219
Bool_t IsInRange(Int_t *coord) const
Check whether bin coord is in range, as defined by TAxis::SetRange().
Definition THnBase.cxx:604
TList * GetListOfFunctions()
Definition THnBase.h:138
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:517
void AddBinContent(const Int_t *x, Double_t v=1.)
Definition THnBase.h:196
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:789
virtual void SetBinError2(Long64_t bin, Double_t e2)=0
TObjArray * GetListOfAxes()
Definition THnBase.h:133
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:264
Bool_t PrintBin(Long64_t idx, Int_t *coord, Option_t *options) const
Print one bin.
Definition THnBase.cxx:1456
TH1D * Projection(Int_t xDim, Option_t *option="") const
Project all bins into a 1-dimensional histogram, keeping only axis "xDim".
Definition THnBase.h:231
Double_t GetSumwx(Int_t dim) const
Definition THnBase.h:220
@ kInvalidInt
Definition THnBase.h:59
@ kNoInt
Definition THnBase.h:57
@ kValidInt
Definition THnBase.h:58
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:1180
Int_t GetNdimensions() const
Definition THnBase.h:145
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:257
~THnBase() override
Destruct a THnBase.
Definition THnBase.cxx:179
void PrintBin(Int_t *coord, Option_t *options) const
Definition THnBase.h:295
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:335
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:54
void ResetBase(Option_t *option="")
Clear the histogram.
Definition THnBase.cxx:1343
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:301
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:1248
THnBase * ProjectionND(Int_t ndim, const Int_t *dim, Option_t *option="") const
Project histogram onto the axes specified in dim.
Definition THnBase.h:270
TObjArray fAxes
Axes of the histogram.
Definition THnBase.h:48
void SetBinEdges(Int_t idim, const Double_t *bins)
Set the axis # of bins and bin limits on dimension idim.
Definition THnBase.cxx:1198
Bool_t GetCalculateErrors() const
Definition THnBase.h:146
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:813
void SetTitle(const char *title) override
Change (i.e.
Definition THnBase.cxx:1237
void PrintEntries(Long64_t from=0, Long64_t howmany=-1, Option_t *options=nullptr) const
Print "howmany" entries starting at "from".
Definition THnBase.cxx:1500
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:193
Double_t GetBinContent(const Int_t *idx) const
Definition THnBase.h:202
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:889
Double_t fTsumw2
Total sum of weights squared; -1 if no errors are calculated.
Definition THnBase.h:52
virtual void Reserve(Long64_t)
Definition THnBase.h:108
THnBase()
Definition THnBase.h:63
Double_t GetEntries() const
Definition THnBase.h:143
Long64_t Fill(Double_t firstval, MoreTypes... morevals)
Fill with the provided variadic arguments.
Definition THnBase.h:172
std::vector< Double_t > GetBinCenter(const std::vector< Int_t > &idx) const
THnBase::GetBinCenter.
Definition THnBase.cxx:546
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:212
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:81
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:950
Double_t Integral(Bool_t respectAxisRange) const
Compute integral (sum of counts) of histogram in all dimensions.
Definition THnBase.cxx:1361
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:1041
void Print(Option_t *option="") const override
Print a THnBase.
Definition THnBase.cxx:1551
Long64_t Fill(const char *name[], Double_t w=1.)
Definition THnBase.h:160
Double_t GetSumwx2(Int_t dim) const
Definition THnBase.h:221
Double_t GetWeightSum() const
Definition THnBase.h:144
TObjArray fBrowsables
! Browser-helpers for each axis
Definition THnBase.h:49
Double_t GetSumw() const
Definition THnBase.h:218
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:630
void GetRandom(Double_t *rand, Bool_t subBinRandom=kTRUE)
Generate an n-dimensional random tuple based on the histogrammed distribution.
Definition THnBase.cxx:569
TAxis * GetAxis(Int_t dim) const
Definition THnBase.h:135
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:191
Long64_t Merge(TCollection *list)
Merge this with a list of THnBase's.
Definition THnBase.cxx:915
Double_t fTsumw
Total sum of weights.
Definition THnBase.h:51
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:1381
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:905
void SetBinError(Long64_t bin, Double_t e)
Definition THnBase.h:195
void SetTitleImpl(const char *title, bool overrideAxesTitle)
Definition THnBase.cxx:1205
void CalculateErrors(Bool_t calc=kTRUE)
Calculate errors (or not if "calc" == kFALSE)
Definition THnBase.h:149
Int_t fNdimensions
Number of dimensions.
Definition THnBase.h:47
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:244
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:207
void FillBinBase(Double_t w)
Increment the statistics due to filled weight "w",.
Definition THnBase.h:93
THnBase & operator=(const THnBase &other)
Definition THnBase.cxx:113
std::vector< Double_t > fIntegral
! vector with bin weight sums
Definition THnBase.h:55
TArrayD fTsumwx
Total sum of weight*X for each dimension.
Definition THnBase.h:53
Iterator over THnBase bins.
Definition THnBase.h:346
Bool_t HaveSkippedBin() const
Definition THnBase.h:361
THnIter(const THnBase *hist, Bool_t respectAxisRange=kFALSE)
Definition THnBase.h:348
Int_t GetCoord(Int_t dim) const
Definition THnBase.h:360
ROOT::Internal::THnBaseBinIter * fIter
Definition THnBase.h:365
~THnIter() override
Definition THnBase.cxx:1632
Bool_t RespectsAxisRange() const
Definition THnBase.h:362
Long64_t Next(Int_t *coord=nullptr)
Return the next bin's index.
Definition THnBase.h:356
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:1071
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
Double_t Sqrt(Double_t x)
Returns the square root of x.
Definition TMath.h:673