67 const std::vector<std::vector<double>> &xbins);
99 void Init(
const char*
name,
const char* title,
101 Int_t chunkSize = 1024 * 16);
120 Int_t chunkSize = 1024 * 16);
123 Int_t chunkSize = 1024 * 16);
166 template <
typename... MoreTypes>
169 const std::array<
double, 1 +
sizeof...(morevals)>
x{firstval,
static_cast<double>(morevals)...};
172 return Fill(
x.data());
175 return Fill(
x.data(),
x.back());
177 Error(
"Fill",
"Wrong number of arguments for number of histogram axes.");
193 void SetTitle(
const char *title)
override;
238 const Int_t dim[2] = {xDim, yDim};
251 const Int_t dim[3] = {xDim, yDim, zDim};
333 fIter(hist->CreateIter(respectAxisRange)) {}
#define ClassDefOverride(name, id)
Iterator over THnBase bins (internal implementation).
Bool_t RespectsAxisRange() const
Bool_t HaveSkippedBin() const
virtual Int_t GetCoord(Int_t dim) const =0
THnBaseBinIter(Bool_t respectAxisRange)
virtual ~THnBaseBinIter()
Destruct a bin iterator.
virtual Long64_t Next(Int_t *coord=nullptr)=0
TBrowser helper for THnBase.
~THnBaseBrowsable() override
Destruct a THnBaseBrowsable.
Bool_t IsFolder() const override
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
void Browse(TBrowser *b) override
Browse an axis of a THnBase, i.e. draw its projection.
Array of doubles (64 bits per element).
Class to manage histogram axis.
Using a TBrowser one can browse all ROOT objects.
Collection abstract base class.
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)}
TH1 is the base class of all histogram classes in ROOT.
2-D histogram with a double per channel (see TH1 documentation)}
3-D histogram with a double per channel (see TH1 documentation)}
Multidimensional histogram base.
virtual ROOT::Internal::THnBaseBinIter * CreateIter(Bool_t respectAxisRange) const =0
void SetEntries(Double_t entries)
virtual void SetFilledBins(Long64_t)
void Browse(TBrowser *b) override
Browse a THnSparse: create an entry (ROOT::THnSparseBrowsable) for each dimension.
const TObjArray * GetListOfAxes() const
Long64_t Fill(const Double_t *x, Double_t w=1.)
virtual void InitStorage(Int_t *nbins, Int_t chunkSize)=0
Double_t GetBinError(const Int_t *idx) const
void SetBinError(const Int_t *idx, Double_t e)
enum THnBase::@84 fIntegralStatus
! status of integral
Double_t fEntries
Number of entries, spread over chunks.
virtual void AddBinContent(Long64_t bin, Double_t v=1.)=0
Double_t GetSumw2() const
Bool_t IsInRange(Int_t *coord) const
Check whether bin coord is in range, as defined by TAxis::SetRange().
TList * GetListOfFunctions()
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.
void AddBinContent(const Int_t *x, Double_t v=1.)
void Scale(Double_t c)
Scale contents and errors of this histogram by c: this = this * c It does not modify the histogram's ...
virtual void SetBinError2(Long64_t bin, Double_t e2)=0
TObjArray * GetListOfAxes()
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.
Bool_t PrintBin(Long64_t idx, Int_t *coord, Option_t *options) const
Print one bin.
TH1D * Projection(Int_t xDim, Option_t *option="") const
Project all bins into a 1-dimensional histogram, keeping only axis "xDim".
Double_t GetSumwx(Int_t dim) const
Bool_t CheckConsistency(const THnBase *h, const char *tag) const
Consistency check on (some of) the parameters of two histograms (for operations).
Int_t GetNdimensions() const
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",...
~THnBase() override
Destruct a THnBase.
void PrintBin(Int_t *coord, Option_t *options) const
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.
virtual Long64_t GetBin(const char *name[], Bool_t=kTRUE)=0
TArrayD fTsumwx2
Total sum of weight*X*X for each dimension.
void ResetBase(Option_t *option="")
Clear the histogram.
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).
THnBase * RebinBase(Int_t group) const
Combine the content of "group" neighboring bins into a new bin and return the resulting THnBase.
THnBase * ProjectionND(Int_t ndim, const Int_t *dim, Option_t *option="") const
TObjArray fAxes
Axes of the histogram.
void SetBinEdges(Int_t idim, const Double_t *bins)
Set the axis # of bins and bin limits on dimension idim.
Bool_t GetCalculateErrors() const
void AddInternal(const THnBase *h, Double_t c, Bool_t rebinned)
Add() implementation for both rebinned histograms and those with identical binning.
void SetTitle(const char *title) override
Change (i.e.
void PrintEntries(Long64_t from=0, Long64_t howmany=-1, Option_t *options=nullptr) const
Print "howmany" entries starting at "from".
virtual void SetBinContent(Long64_t bin, Double_t v)=0
Double_t GetBinError(Long64_t linidx) const
Double_t GetBinContent(const Int_t *idx) const
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,...
Double_t fTsumw2
Total sum of weights squared; -1 if no errors are calculated.
virtual void Reserve(Long64_t)
Double_t GetEntries() const
Long64_t Fill(Double_t firstval, MoreTypes... morevals)
Fill with the provided variadic arguments.
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)
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.)
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,...
void Divide(const THnBase *h)
Divide this histogram by h this = this/(h) Note that if h has Sumw2 set, Sumw2 is automatically calle...
void Print(Option_t *option="") const override
Print a THnBase.
Long64_t Fill(const char *name[], Double_t w=1.)
Double_t GetSumwx2(Int_t dim) const
Double_t GetWeightSum() const
TObjArray fBrowsables
! Browser-helpers for each axis
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 !...
void GetRandom(Double_t *rand, Bool_t subBinRandom=kTRUE)
Generate an n-dimensional random tuple based on the histogrammed distribution.
TAxis * GetAxis(Int_t dim) const
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 ...
Long64_t Merge(TCollection *list)
Merge this with a list of THnBase's.
Double_t fTsumw
Total sum of weights.
virtual Long64_t GetBin(const Int_t *idx) const =0
Double_t ComputeIntegral()
Calculate the integral of the histogram.
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,...
void SetBinError(Long64_t bin, Double_t e)
void CalculateErrors(Bool_t calc=kTRUE)
Calculate errors (or not if "calc" == kFALSE)
Int_t fNdimensions
Number of dimensions.
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".
void Init(const char *name, const char *title, const TObjArray *axes, Bool_t keepTargetAxis, Int_t chunkSize=1024 *16)
Initialize axes and name.
void FillBinBase(Double_t w)
Increment the statistics due to filled weight "w",.
THnBase & operator=(const THnBase &other)
std::vector< Double_t > fIntegral
! vector with bin weight sums
TArrayD fTsumwx
Total sum of weight*X for each dimension.
Iterator over THnBase bins.
Bool_t HaveSkippedBin() const
THnIter(const THnBase *hist, Bool_t respectAxisRange=kFALSE)
Int_t GetCoord(Int_t dim) const
ROOT::Internal::THnBaseBinIter * fIter
Bool_t RespectsAxisRange() const
Long64_t Next(Int_t *coord=nullptr)
Return the next bin's index.
The TNamed class is the base class for all named ROOT classes.
Mother of all ROOT objects.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Double_t Sqrt(Double_t x)
Returns the square root of x.