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 
29 class TAxis;
30 class TH1;
31 class TH1D;
32 class TH2D;
33 class TH3D;
34 class TF1;
35 class THnIter;
36 
37 namespace ROOT {
38 namespace Internal {
39  class THnBaseBinIter;
40 }
41 }
42 
43 class THnBase: public TNamed {
44 protected:
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  Double_t *fIntegral; //! array with bin weight sums
54  enum {
58  } fIntegralStatus; //! status of integral
59 
60 private:
61  THnBase(const THnBase&); // Not implemented
62  THnBase& operator=(const THnBase&); // Not implemented
63 
64  protected:
66  fNdimensions(0), fEntries(0),
68  {}
69 
70  THnBase(const char* name, const char* title, Int_t dim,
71  const Int_t* nbins, const Double_t* xmin, const Double_t* xmax);
72 
73  void UpdateXStat(const Double_t *x, Double_t w = 1.) {
74  if (GetCalculateErrors()) {
75  for (Int_t d = 0; d < fNdimensions; ++d) {
76  const Double_t xd = x[d];
77  fTsumwx[d] += w * xd;
78  fTsumwx2[d] += w * xd * xd;
79  }
80  }
81  }
82 
83  /// Increment the statistics due to filled weight "w",
85  fEntries += 1;
86  if (GetCalculateErrors()) {
87  fTsumw += w;
88  fTsumw2 += w*w;
89  }
91  }
92 
93  virtual void InitStorage(Int_t* nbins, Int_t chunkSize) = 0;
94  void Init(const char* name, const char* title,
95  const TObjArray* axes, Bool_t keepTargetAxis,
96  Int_t chunkSize = 1024 * 16);
97  THnBase* CloneEmpty(const char* name, const char* title,
98  const TObjArray* axes, Bool_t keepTargetAxis) const;
99  virtual void Reserve(Long64_t /*nbins*/) {}
100  virtual void SetFilledBins(Long64_t /*nbins*/) {};
101 
102  Bool_t CheckConsistency(const THnBase *h, const char *tag) const;
103  TH1* CreateHist(const char* name, const char* title,
104  const TObjArray* axes, Bool_t keepTargetAxis) const;
105  TObject* ProjectionAny(Int_t ndim, const Int_t* dim,
106  Bool_t wantNDim, Option_t* option = "") const;
107  Bool_t PrintBin(Long64_t idx, Int_t* coord, Option_t* options) const;
108  void AddInternal(const THnBase* h, Double_t c, Bool_t rebinned);
109  THnBase* RebinBase(Int_t group) const;
110  THnBase* RebinBase(const Int_t* group) const;
111  void ResetBase(Option_t *option= "");
112 
113  static THnBase* CreateHnAny(const char* name, const char* title,
114  const TH1* h1, Bool_t sparse,
115  Int_t chunkSize = 1024 * 16);
116  static THnBase* CreateHnAny(const char* name, const char* title,
117  const THnBase* hn, Bool_t sparse,
118  Int_t chunkSize = 1024 * 16);
119 
120  public:
121  virtual ~THnBase();
122 
123  TObjArray* GetListOfAxes() { return &fAxes; }
124  const TObjArray* GetListOfAxes() const { return &fAxes; }
125  TAxis* GetAxis(Int_t dim) const { return (TAxis*)fAxes[dim]; }
126 
127  TFitResultPtr Fit(TF1 *f1 ,Option_t *option = "", Option_t *goption = "");
128  TList* GetListOfFunctions() { return 0; }
129 
130  virtual ROOT::Internal::THnBaseBinIter* CreateIter(Bool_t respectAxisRange) const = 0;
131 
132  virtual Long64_t GetNbins() const = 0;
133  Double_t GetEntries() const { return fEntries; }
134  Double_t GetWeightSum() const { return fTsumw; }
135  Int_t GetNdimensions() const { return fNdimensions; }
136  Bool_t GetCalculateErrors() const { return fTsumw2 >= 0.; }
137 
138  /// Calculate errors (or not if "calc" == kFALSE)
139  void CalculateErrors(Bool_t calc = kTRUE) {
140  if (calc) Sumw2();
141  else fTsumw2 = -1.;
142  }
143 
144  Long64_t Fill(const Double_t *x, Double_t w = 1.) {
145  UpdateXStat(x, w);
146  Long64_t bin = GetBin(x, kTRUE /*alloc*/);
147  FillBin(bin, w);
148  return bin;
149  }
150  Long64_t Fill(const char* name[], Double_t w = 1.) {
151  Long64_t bin = GetBin(name, kTRUE /*alloc*/);
152  FillBin(bin, w);
153  return bin;
154  }
155 
156  virtual void FillBin(Long64_t bin, Double_t w) = 0;
157 
158  void SetBinEdges(Int_t idim, const Double_t* bins);
159  Bool_t IsInRange(Int_t *coord) const;
160  Double_t GetBinError(const Int_t *idx) const { return GetBinError(GetBin(idx)); }
161  Double_t GetBinError(Long64_t linidx) const { return TMath::Sqrt(GetBinError2(linidx)); }
162  void SetBinError(const Int_t* idx, Double_t e) { SetBinError(GetBin(idx), e); }
163  void SetBinError(Long64_t bin, Double_t e) { SetBinError2(bin, e*e); }
164  void AddBinContent(const Int_t* x, Double_t v = 1.) { AddBinContent(GetBin(x), v); }
165  void SetEntries(Double_t entries) { fEntries = entries; }
166  void SetTitle(const char *title);
167 
168  Double_t GetBinContent(const Int_t *idx) const { return GetBinContent(GetBin(idx)); } // intentionally non-virtual
169  virtual Double_t GetBinContent(Long64_t bin, Int_t* idx = 0) const = 0;
170  virtual Double_t GetBinError2(Long64_t linidx) const = 0;
171  virtual Long64_t GetBin(const Int_t* idx) const = 0;
172  virtual Long64_t GetBin(const Double_t* x) const = 0;
173  virtual Long64_t GetBin(const char* name[]) const = 0;
174  virtual Long64_t GetBin(const Int_t* idx, Bool_t /*allocate*/ = kTRUE) = 0;
175  virtual Long64_t GetBin(const Double_t* x, Bool_t /*allocate*/ = kTRUE) = 0;
176  virtual Long64_t GetBin(const char* name[], Bool_t /*allocate*/ = kTRUE) = 0;
177 
178  void SetBinContent(const Int_t* idx, Double_t v) { SetBinContent(GetBin(idx), v); } // intentionally non-virtual
179  virtual void SetBinContent(Long64_t bin, Double_t v) = 0;
180  virtual void SetBinError2(Long64_t bin, Double_t e2) = 0;
181  virtual void AddBinError2(Long64_t bin, Double_t e2) = 0;
182  virtual void AddBinContent(Long64_t bin, Double_t v = 1.) = 0;
183 
184  Double_t GetSumw() const { return fTsumw; }
185  Double_t GetSumw2() const { return fTsumw2; }
186  Double_t GetSumwx(Int_t dim) const { return fTsumwx[dim]; }
187  Double_t GetSumwx2(Int_t dim) const { return fTsumwx2[dim]; }
188 
189  /// Project all bins into a 1-dimensional histogram,
190  /// keeping only axis "xDim".
191  /// If "option" contains:
192  /// - "E" errors will be calculated.
193  /// - "A" ranges of the taget axes will be ignored.
194  /// - "O" original axis range of the taget axes will be
195  /// kept, but only bins inside the selected range
196  /// will be filled.
197  TH1D* Projection(Int_t xDim, Option_t* option = "") const {
198  return (TH1D*) ProjectionAny(1, &xDim, false, option);
199  }
200 
201  /// Project all bins into a 2-dimensional histogram,
202  /// keeping only axes "xDim" and "yDim".
203  ///
204  /// WARNING: just like TH3::Project3D("yx") and TTree::Draw("y:x"),
205  /// Projection(y,x) uses the first argument to define the y-axis and the
206  /// second for the x-axis!
207  ///
208  /// If "option" contains "E" errors will be calculated.
209  /// "A" ranges of the taget axes will be ignored.
210  TH2D* Projection(Int_t yDim, Int_t xDim, Option_t* option = "") const {
211  const Int_t dim[2] = {xDim, yDim};
212  return (TH2D*) ProjectionAny(2, dim, false, option);
213  }
214 
215  /// Project all bins into a 3-dimensional histogram,
216  /// keeping only axes "xDim", "yDim", and "zDim".
217  /// If "option" contains:
218  /// - "E" errors will be calculated.
219  /// - "A" ranges of the taget axes will be ignored.
220  /// - "O" original axis range of the taget axes will be
221  /// kept, but only bins inside the selected range
222  /// will be filled.
223  TH3D* Projection(Int_t xDim, Int_t yDim, Int_t zDim, Option_t* option = "") const {
224  const Int_t dim[3] = {xDim, yDim, zDim};
225  return (TH3D*) ProjectionAny(3, dim, false, option);
226  }
227 
228  THnBase* ProjectionND(Int_t ndim, const Int_t* dim,
229  Option_t* option = "") const {
230  return (THnBase*)ProjectionAny(ndim, dim, kTRUE /*wantNDim*/, option);
231  }
232 
233  Long64_t Merge(TCollection* list);
234 
235  void Scale(Double_t c);
236  void Add(const THnBase* h, Double_t c=1.);
237  void Add(const TH1* hist, Double_t c=1.);
238  void Multiply(const THnBase* h);
239  void Multiply(TF1* f, Double_t c = 1.);
240  void Divide(const THnBase* h);
241  void Divide(const THnBase* h1, const THnBase* h2, Double_t c1 = 1., Double_t c2 = 1., Option_t* option="");
242  void RebinnedAdd(const THnBase* h, Double_t c=1.);
243 
244  virtual void Reset(Option_t* option = "") = 0;
245  virtual void Sumw2() = 0;
246 
248  void GetRandom(Double_t *rand, Bool_t subBinRandom = kTRUE);
249 
250  void Print(Option_t* option = "") const;
251  void PrintEntries(Long64_t from = 0, Long64_t howmany = -1, Option_t* options = 0) const;
252  void PrintBin(Int_t* coord, Option_t* options) const {
253  PrintBin(-1, coord, options);
254  }
255  void PrintBin(Long64_t idx, Option_t* options) const;
256 
257  void Browse(TBrowser *b);
258  Bool_t IsFolder() const { return kTRUE; }
259 
260  //void Draw(Option_t* option = "");
261 
262  ClassDef(THnBase, 1); // Common base for n-dimensional histogram
263 
264  friend class THnIter;
265 };
266 
267 namespace ROOT {
268 namespace Internal {
269  // Helper class for browsing THnBase objects
270  class THnBaseBrowsable: public TNamed {
271  public:
272  THnBaseBrowsable(THnBase* hist, Int_t axis);
274  void Browse(TBrowser *b);
275  Bool_t IsFolder() const { return kFALSE; }
276 
277  private:
278  THnBase* fHist; // Original histogram
279  Int_t fAxis; // Axis to visualize
280  TH1* fProj; // Projection result
281  ClassDef(THnBaseBrowsable, 0); // Browser-helper for THnBase
282  };
283 
284  // Base class for iterating over THnBase bins
286  public:
287  THnBaseBinIter(Bool_t respectAxisRange):
288  fRespectAxisRange(respectAxisRange), fHaveSkippedBin(kFALSE) {}
289  virtual ~THnBaseBinIter();
292 
293  virtual Int_t GetCoord(Int_t dim) const = 0;
294  virtual Long64_t Next(Int_t* coord = 0) = 0;
295 
296  protected:
299  };
300 }
301 }
302 
303 class THnIter: public TObject {
304 public:
305  THnIter(const THnBase* hist, Bool_t respectAxisRange = kFALSE):
306  fIter(hist->CreateIter(respectAxisRange)) {}
307  virtual ~THnIter();
308 
309  /// Return the next bin's index.
310  /// If provided, set coord to that bin's coordinates (bin indexes).
311  /// I.e. coord must point to Int_t[hist->GetNdimensions()]
312  /// Returns -1 when all bins have been visited.
313  Long64_t Next(Int_t* coord = 0) {
314  return fIter->Next(coord);
315  }
316 
317  Int_t GetCoord(Int_t dim) const { return fIter->GetCoord(dim); }
318  Bool_t HaveSkippedBin() const { return fIter->HaveSkippedBin(); }
320 
321 private:
323  ClassDef(THnIter, 0); //Iterator over bins of a THnBase.
324 };
325 
326 #endif // ROOT_THnBase
c
#define c(i)
Definition: RSha256.hxx:101
THnBase::UpdateXStat
void UpdateXStat(const Double_t *x, Double_t w=1.)
Definition: THnBase.h:73
THnBase::ProjectionND
THnBase * ProjectionND(Int_t ndim, const Int_t *dim, Option_t *option="") const
Definition: THnBase.h:228
ROOT::Internal::THnBaseBrowsable::THnBaseBrowsable
THnBaseBrowsable(THnBase *hist, Int_t axis)
Construct a THnBaseBrowsable.
Definition: THnBase.cxx:1432
ROOT::Internal::THnBaseBrowsable
TBrowser helper for THnBase.
Definition: THnBase.h:270
TAxis
Class to manage histogram axis.
Definition: TAxis.h:30
THnBase::fEntries
Double_t fEntries
browser-helpers for each axis
Definition: THnBase.h:48
THnBase::SetTitle
void SetTitle(const char *title)
Change (i.e.
Definition: THnBase.cxx:1020
THnIter::Next
Long64_t Next(Int_t *coord=0)
Return the next bin's index.
Definition: THnBase.h:313
THnBase::Multiply
void Multiply(const THnBase *h)
Multiply this histogram by histogram h this = this * h Note that if h has Sumw2 set,...
Definition: THnBase.cxx:756
TBrowser
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
THnBase::GetBinContent
Double_t GetBinContent(const Int_t *idx) const
Definition: THnBase.h:168
THnBase::GetListOfFunctions
TList * GetListOfFunctions()
Definition: THnBase.h:128
THnBase::Reserve
virtual void Reserve(Long64_t)
Definition: THnBase.h:99
ROOT::Internal::THnBaseBinIter::~THnBaseBinIter
virtual ~THnBaseBinIter()
Destruct a bin iterator.
Definition: THnBase.cxx:1404
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
e
#define e(i)
Definition: RSha256.hxx:103
THnBase::kValidInt
@ kValidInt
Definition: THnBase.h:56
THnBase::Scale
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:610
THnBase::SetBinError
void SetBinError(Long64_t bin, Double_t e)
Definition: THnBase.h:163
TObjArray
An array of TObjects.
Definition: TObjArray.h:37
f
#define f(i)
Definition: RSha256.hxx:104
Option_t
const char Option_t
Definition: RtypesCore.h:66
ROOT::Internal::THnBaseBrowsable::IsFolder
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition: THnBase.h:275
TH3D
3-D histogram with a double per channel (see TH1 documentation)}
Definition: TH3.h:305
THnBase::Divide
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:847
THnBase::PrintBin
Bool_t PrintBin(Long64_t idx, Int_t *coord, Option_t *options) const
Print one bin.
Definition: THnBase.cxx:1240
xmax
float xmax
Definition: THbookFile.cxx:95
THnBase::Fill
Long64_t Fill(const Double_t *x, Double_t w=1.)
Definition: THnBase.h:144
TNamed.h
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
THnBase::fIntegral
Double_t * fIntegral
Definition: THnBase.h:53
THnBase::CalculateErrors
void CalculateErrors(Bool_t calc=kTRUE)
Calculate errors (or not if "calc" == kFALSE)
Definition: THnBase.h:139
THnBase::GetBinContent
virtual Double_t GetBinContent(Long64_t bin, Int_t *idx=0) const =0
TMath::Sqrt
Double_t Sqrt(Double_t x)
Definition: TMath.h:691
THnBase::SetFilledBins
virtual void SetFilledBins(Long64_t)
Definition: THnBase.h:100
THnBase::GetBinError
Double_t GetBinError(Long64_t linidx) const
Definition: THnBase.h:161
TH1D
1-D histogram with a double per channel (see TH1 documentation)}
Definition: TH1.h:616
ROOT::Internal::THnBaseBinIter::GetCoord
virtual Int_t GetCoord(Int_t dim) const =0
THnBase::Add
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:695
ROOT::Internal::THnBaseBinIter::RespectsAxisRange
Bool_t RespectsAxisRange() const
Definition: THnBase.h:291
THnBase::SetBinError2
virtual void SetBinError2(Long64_t bin, Double_t e2)=0
ROOT::Internal::THnBaseBinIter::Next
virtual Long64_t Next(Int_t *coord=0)=0
Int_t
int Int_t
Definition: RtypesCore.h:45
THnBase::~THnBase
virtual ~THnBase()
Destruct a THnBase.
Definition: THnBase.cxx:68
THnBase::Fill
Long64_t Fill(const char *name[], Double_t w=1.)
Definition: THnBase.h:150
x
Double_t x[n]
Definition: legend1.C:17
THnBase::Init
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:95
THnBase::Browse
void Browse(TBrowser *b)
Browse a THnSparse: create an entry (ROOT::THnSparseBrowsable) for each dimension.
Definition: THnBase.cxx:1381
THnBase::AddBinError2
virtual void AddBinError2(Long64_t bin, Double_t e2)=0
THnIter::~THnIter
virtual ~THnIter()
Definition: THnBase.cxx:1416
THnBase::Sumw2
virtual void Sumw2()=0
THnBase::CheckConsistency
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:986
THnBase::THnBase
THnBase(const THnBase &)
status of integral
THnBase::GetBinError
Double_t GetBinError(const Int_t *idx) const
Definition: THnBase.h:160
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
v
@ v
Definition: rootcling_impl.cxx:3635
b
#define b(i)
Definition: RSha256.hxx:100
THnBase::CreateIter
virtual ROOT::Internal::THnBaseBinIter * CreateIter(Bool_t respectAxisRange) const =0
h1
TH1F * h1
Definition: legend1.C:5
THnBase::GetBin
virtual Long64_t GetBin(const Double_t *x, Bool_t=kTRUE)=0
THnBase::fTsumwx2
TArrayD fTsumwx2
Definition: THnBase.h:52
bool
THnBase::GetSumwx
Double_t GetSumwx(Int_t dim) const
Definition: THnBase.h:186
THnBase::AddInternal
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:634
THnBase::SetBinError
void SetBinError(const Int_t *idx, Double_t e)
Definition: THnBase.h:162
THnBase::InitStorage
virtual void InitStorage(Int_t *nbins, Int_t chunkSize)=0
THnBase::Fit
TFitResultPtr Fit(TF1 *f1, Option_t *option="", Option_t *goption="")
Fit a THnSparse with function f.
Definition: THnBase.cxx:364
ROOT::Internal::THnBaseBinIter::fRespectAxisRange
Bool_t fRespectAxisRange
Definition: THnBase.h:297
ROOT::Internal::THnBaseBinIter::fHaveSkippedBin
Bool_t fHaveSkippedBin
Definition: THnBase.h:298
THnBase::FillBin
virtual void FillBin(Long64_t bin, Double_t w)=0
THnBase::RebinBase
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:1056
THnBase::GetNbins
virtual Long64_t GetNbins() const =0
THnBase::GetAxis
TAxis * GetAxis(Int_t dim) const
Definition: THnBase.h:125
ROOT::Internal::THnBaseBinIter::HaveSkippedBin
Bool_t HaveSkippedBin() const
Definition: THnBase.h:290
group
Definition: TWinNTSystem.h:59
THnBase::Merge
Long64_t Merge(TCollection *list)
Merge this with a list of THnBase's.
Definition: THnBase.cxx:721
THnBase::CreateHist
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:143
THnBase::GetNdimensions
Int_t GetNdimensions() const
Definition: THnBase.h:135
TArrayD.h
THnBase::fBrowsables
TObjArray fBrowsables
Definition: THnBase.h:47
ROOT::Internal::THnBaseBrowsable::Browse
void Browse(TBrowser *b)
Browse an axis of a THnBase, i.e. draw its projection.
Definition: THnBase.cxx:1456
THnBase::kInvalidInt
@ kInvalidInt
Definition: THnBase.h:57
THnBase::SetBinContent
virtual void SetBinContent(Long64_t bin, Double_t v)=0
TFitResultPtr
Provides an indirection to the TFitResult class and with a semantics identical to a TFitResult pointe...
Definition: TFitResultPtr.h:32
THnBase::SetBinEdges
void SetBinEdges(Int_t idim, const Double_t *bins)
Set the axis # of bins and bin limits on dimension idim.
Definition: THnBase.cxx:1004
xmin
float xmin
Definition: THbookFile.cxx:95
THnIter::RespectsAxisRange
Bool_t RespectsAxisRange() const
Definition: THnBase.h:319
ROOT::Internal::THnBaseBinIter::THnBaseBinIter
THnBaseBinIter(Bool_t respectAxisRange)
Definition: THnBase.h:287
h
#define h(i)
Definition: RSha256.hxx:106
THnBase::GetSumw
Double_t GetSumw() const
Definition: THnBase.h:184
THnBase::GetSumw2
Double_t GetSumw2() const
Definition: THnBase.h:185
THnBase::fNdimensions
Int_t fNdimensions
Definition: THnBase.h:45
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
THnBase::SetEntries
void SetEntries(Double_t entries)
Definition: THnBase.h:165
THnBase::FillBinBase
void FillBinBase(Double_t w)
Increment the statistics due to filled weight "w",.
Definition: THnBase.h:84
THnBase::Projection
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:223
TH2D
2-D histogram with a double per channel (see TH1 documentation)}
Definition: TH2.h:292
THnBase::Reset
virtual void Reset(Option_t *option="")=0
THnBase::fAxes
TObjArray fAxes
Definition: THnBase.h:46
THnBase::AddBinContent
virtual void AddBinContent(Long64_t bin, Double_t v=1.)=0
THnIter::fIter
ROOT::Internal::THnBaseBinIter * fIter
Definition: THnBase.h:322
THnBase::IsFolder
Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition: THnBase.h:258
THnBase::RebinnedAdd
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:711
THnBase::fTsumw
Double_t fTsumw
Definition: THnBase.h:49
THnBase::GetBin
virtual Long64_t GetBin(const Int_t *idx) const =0
THnBase::operator=
THnBase & operator=(const THnBase &)
THnBase::Print
void Print(Option_t *option="") const
Print a THnBase.
Definition: THnBase.cxx:1334
THnBase::CloneEmpty
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:79
ROOT::Internal::THnBaseBinIter
Iterator over THnBase bins (internal implementation).
Definition: THnBase.h:285
THnBase::GetListOfAxes
const TObjArray * GetListOfAxes() const
Definition: THnBase.h:124
THnBase::PrintEntries
void PrintEntries(Long64_t from=0, Long64_t howmany=-1, Option_t *options=0) const
Print "howmany" entries starting at "from".
Definition: THnBase.cxx:1284
THnBase::GetRandom
void GetRandom(Double_t *rand, Bool_t subBinRandom=kTRUE)
Generate an n-dimensional random tuple based on the histogrammed distribution.
Definition: THnBase.cxx:393
ROOT::Internal::THnBaseBrowsable::fHist
THnBase * fHist
Definition: THnBase.h:278
THnBase::ProjectionAny
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:454
ROOT::Internal::THnBaseBrowsable::fAxis
Int_t fAxis
Definition: THnBase.h:279
THnBase::GetBin
virtual Long64_t GetBin(const Double_t *x) const =0
f1
TF1 * f1
Definition: legend1.C:11
Double_t
double Double_t
Definition: RtypesCore.h:59
THnBase::Projection
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:210
TObjArray.h
TFitResultPtr.h
THnBase::GetBin
virtual Long64_t GetBin(const char *name[]) const =0
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TH1
TH1 is the base class of all histogramm classes in ROOT.
Definition: TH1.h:58
ROOT::Internal::THnBaseBrowsable::fProj
TH1 * fProj
Definition: THnBase.h:280
ROOT::Internal::THnBaseBrowsable::~THnBaseBrowsable
~THnBaseBrowsable()
Destruct a THnBaseBrowsable.
Definition: THnBase.cxx:1448
name
char name[80]
Definition: TGX11.cxx:110
THnIter::THnIter
THnIter(const THnBase *hist, Bool_t respectAxisRange=kFALSE)
Definition: THnBase.h:305
d
#define d(i)
Definition: RSha256.hxx:102
c2
return c2
Definition: legend2.C:14
THnBase::fTsumwx
TArrayD fTsumwx
Definition: THnBase.h:51
THnBase::Projection
TH1D * Projection(Int_t xDim, Option_t *option="") const
Project all bins into a 1-dimensional histogram, keeping only axis "xDim".
Definition: THnBase.h:197
THnBase::IsInRange
Bool_t IsInRange(Int_t *coord) const
Check whether bin coord is in range, as defined by TAxis::SetRange().
Definition: THnBase.cxx:428
THnBase::PrintBin
void PrintBin(Int_t *coord, Option_t *options) const
Definition: THnBase.h:252
THnBase::THnBase
THnBase()
Definition: THnBase.h:65
TCollection
Collection abstract base class.
Definition: TCollection.h:63
THnBase::GetWeightSum
Double_t GetWeightSum() const
Definition: THnBase.h:134
THnIter::GetCoord
Int_t GetCoord(Int_t dim) const
Definition: THnBase.h:317
THnBase::CreateHnAny
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:196
THnBase::SetBinContent
void SetBinContent(const Int_t *idx, Double_t v)
Definition: THnBase.h:178
THnBase::ComputeIntegral
Double_t ComputeIntegral()
Calculate the integral of the histogram.
Definition: THnBase.cxx:1165
TF1
1-Dim function class
Definition: TF1.h:213
TArrayD
Array of doubles (64 bits per element).
Definition: TArrayD.h:27
THnBase::GetSumwx2
Double_t GetSumwx2(Int_t dim) const
Definition: THnBase.h:187
THnBase::ResetBase
void ResetBase(Option_t *option="")
Clear the histogram.
Definition: THnBase.cxx:1151
THnBase::GetBin
virtual Long64_t GetBin(const char *name[], Bool_t=kTRUE)=0
THnBase::fIntegralStatus
enum THnBase::@75 fIntegralStatus
array with bin weight sums
THnBase::GetListOfAxes
TObjArray * GetListOfAxes()
Definition: THnBase.h:123
THnBase::kNoInt
@ kNoInt
Definition: THnBase.h:55
ROOT
VSD Structures.
Definition: StringConv.hxx:21
THnBase::GetBin
virtual Long64_t GetBin(const Int_t *idx, Bool_t=kTRUE)=0
THnBase::AddBinContent
void AddBinContent(const Int_t *x, Double_t v=1.)
Definition: THnBase.h:164
THnBase::GetEntries
Double_t GetEntries() const
Definition: THnBase.h:133
THnBase::fTsumw2
Double_t fTsumw2
Definition: THnBase.h:50
THnBase
Multidimensional histogram base.
Definition: THnBase.h:43
THnIter
Iterator over THnBase bins.
Definition: THnBase.h:303
TList
A doubly linked list.
Definition: TList.h:44
THnIter::HaveSkippedBin
Bool_t HaveSkippedBin() const
Definition: THnBase.h:318
THnBase::GetBinError2
virtual Double_t GetBinError2(Long64_t linidx) const =0
TMath.h
THnBase::GetCalculateErrors
Bool_t GetCalculateErrors() const
Definition: THnBase.h:136
int
c1
return c1
Definition: legend1.C:41