ROOT logo
ROOT » HIST » HIST » THnBase

class THnBase: public TNamed


    Multidimensional histogram base.

  Defines common functionality and interfaces for THn, THnSparse.

Function Members (Methods)

 
    This is an abstract class, constructors will not be documented.
    Look at the header to check for available constructors.

public:
virtual~THnBase()
voidTObject::AbstractMethod(const char* method) const
voidAdd(const THnBase* h, Double_t c = 1.)
voidAdd(const TH1* hist, Double_t c = 1.)
voidAddBinContent(const Int_t* x, Double_t v = 1.)
virtual voidAddBinContent(Long64_t bin, Double_t v = 1.)
virtual voidAddBinError2(Long64_t bin, Double_t e2)
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidBrowse(TBrowser* b)
voidCalculateErrors(Bool_t calc = kTRUE)
static TClass*Class()
virtual const char*TObject::ClassName() const
virtual voidTNamed::Clear(Option_t* option = "")
virtual TObject*TNamed::Clone(const char* newname = "") const
virtual Int_tTNamed::Compare(const TObject* obj) const
Double_tComputeIntegral()
virtual voidTNamed::Copy(TObject& named) const
virtual ROOT::THnBaseBinIter*CreateIter(Bool_t respectAxisRange) const
virtual voidTObject::Delete(Option_t* option = "")MENU
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
voidDivide(const THnBase* h)
voidDivide(const THnBase* h1, const THnBase* h2, Double_t c1 = 1., Double_t c2 = 1., Option_t* option = "")
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
Long64_tFill(const Double_t* x, Double_t w = 1.)
Long64_tFill(const char** name, Double_t w = 1.)
virtual voidTNamed::FillBuffer(char*& buffer)
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
TFitResultPtrFit(TF1* f1, Option_t* option = "", Option_t* goption = "")
TAxis*GetAxis(Int_t dim) const
virtual Long64_tGetBin(const Int_t* idx) const
virtual Long64_tGetBin(const Double_t* x) const
virtual Long64_tGetBin(const char** name) const
virtual Long64_tGetBin(const Int_t* idx, Bool_t = kTRUE)
virtual Long64_tGetBin(const Double_t* x, Bool_t = kTRUE)
virtual Long64_tGetBin(const char** name, Bool_t = kTRUE)
Double_tGetBinContent(const Int_t* idx) const
virtual Double_tGetBinContent(Long64_t bin, Int_t* idx = 0) const
Double_tGetBinError(const Int_t* idx) const
Double_tGetBinError(Long64_t linidx) const
virtual Double_tGetBinError2(Long64_t linidx) const
Bool_tGetCalculateErrors() const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
Double_tGetEntries() const
virtual const char*TObject::GetIconName() const
TObjArray*GetListOfAxes()
const TObjArray*GetListOfAxes() const
TList*GetListOfFunctions()
virtual const char*TNamed::GetName() const
virtual Long64_tGetNbins() const
Int_tGetNdimensions() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
voidGetRandom(Double_t* rand, Bool_t subBinRandom = kTRUE)
Double_tGetSumw() const
Double_tGetSumw2() const
Double_tGetSumwx(Int_t dim) const
Double_tGetSumwx2(Int_t dim) const
virtual const char*TNamed::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
Double_tGetWeightSum() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTNamed::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tIsFolder() const
Bool_tIsInRange(Int_t* coord) const
Bool_tTObject::IsOnHeap() const
virtual Bool_tTNamed::IsSortable() const
Bool_tTObject::IsZombie() const
virtual voidTNamed::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
Long64_tMerge(TCollection* list)
voidMultiply(const THnBase* h)
voidMultiply(TF1* f, Double_t c = 1.)
virtual Bool_tTObject::Notify()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
static voidTObject::operator delete(void* ptr)
static voidTObject::operator delete(void* ptr, void* vp)
static voidTObject::operator delete[](void* ptr)
static voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidPrint(Option_t* option = "") const
voidPrintBin(Int_t* coord, Option_t* options) const
voidPrintBin(Long64_t idx, Option_t* options) const
voidPrintEntries(Long64_t from = 0, Long64_t howmany = -1, Option_t* options = 0) const
TH1D*Projection(Int_t xDim, Option_t* option = "") const
TH2D*Projection(Int_t yDim, Int_t xDim, Option_t* option = "") const
TH3D*Projection(Int_t xDim, Int_t yDim, Int_t zDim, Option_t* option = "") const
THnBase*ProjectionND(Int_t ndim, const Int_t* dim, Option_t* option = "") const
virtual Int_tTObject::Read(const char* name)
voidRebinnedAdd(const THnBase* h, Double_t c = 1.)
virtual voidTObject::RecursiveRemove(TObject* obj)
virtual voidReset(Option_t* option = "")
voidTObject::ResetBit(UInt_t f)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(ostream& out, Option_t* option = "")
voidScale(Double_t c)
voidSetBinContent(const Int_t* idx, Double_t v)
virtual voidSetBinContent(Long64_t bin, Double_t v)
voidSetBinEdges(Int_t idim, const Double_t* bins)
voidSetBinError(const Int_t* idx, Double_t e)
voidSetBinError(Long64_t bin, Double_t e)
virtual voidSetBinError2(Long64_t bin, Double_t e2)
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
voidSetEntries(Double_t entries)
virtual voidTNamed::SetName(const char* name)MENU
virtual voidTNamed::SetNameTitle(const char* name, const char* title)
static voidTObject::SetObjectStat(Bool_t stat)
virtual voidSetTitle(const char* title)
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector&)
virtual Int_tTNamed::Sizeof() const
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
virtual voidSumw2()
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
protected:
voidAddInternal(const THnBase* h, Double_t c, Bool_t rebinned)
Bool_tCheckConsistency(const THnBase* h, const char* tag) const
THnBase*CloneEmpty(const char* name, const char* title, const TObjArray* axes, Bool_t keepTargetAxis) const
TH1*CreateHist(const char* name, const char* title, const TObjArray* axes, Bool_t keepTargetAxis) const
static THnBase*CreateHnAny(const char* name, const char* title, const TH1* h1, Bool_t sparse, Int_t chunkSize = 1024*16)
static THnBase*CreateHnAny(const char* name, const char* title, const THnBase* hn, Bool_t sparse, Int_t chunkSize = 1024*16)
virtual voidTObject::DoError(int level, const char* location, const char* fmt, va_list va) const
virtual voidFillBin(Long64_t bin, Double_t w)
voidFillBinBase(Double_t w)
voidInit(const char* name, const char* title, const TObjArray* axes, Bool_t keepTargetAxis, Int_t chunkSize = 1024*16)
virtual voidInitStorage(Int_t* nbins, Int_t chunkSize)
voidTObject::MakeZombie()
Bool_tPrintBin(Long64_t idx, Int_t* coord, Option_t* options) const
TObject*ProjectionAny(Int_t ndim, const Int_t* dim, Bool_t wantNDim, Option_t* option = "") const
THnBase*RebinBase(Int_t group) const
THnBase*RebinBase(const Int_t* group) const
virtual voidReserve(Long64_t)
voidResetBase(Option_t* option = "")
virtual voidSetFilledBins(Long64_t)
voidUpdateXStat(const Double_t* x, Double_t w = 1.)
private:
THnBase&operator=(const THnBase&)

Data Members

public:
enum { kNoInt
kValidInt
kInvalidInt
};
enum TObject::EStatusBits { kCanDelete
kMustCleanup
kObjInCanvas
kIsReferenced
kHasUUID
kCannotPick
kNoContextMenu
kInvalidObject
};
enum TObject::[unnamed] { kIsOnHeap
kNotDeleted
kZombie
kBitMask
kSingleKey
kOverwrite
kWriteDelete
};
protected:
TObjArrayfAxesaxes of the histogram
TObjArrayfBrowsables! browser-helpers for each axis
Double_tfEntriesnumber of entries, spread over chunks
Double_t*fIntegral! array with bin weight sums
enum THnBase::fIntegralStatus! status of integral
TStringTNamed::fNameobject identifier
Int_tfNdimensionsnumber of dimensions
TStringTNamed::fTitleobject title
Double_tfTsumwtotal sum of weights
Double_tfTsumw2total sum of weights squared; -1 if no errors are calculated
TArrayDfTsumwxtotal sum of weight*X for each dimension
TArrayDfTsumwx2total sum of weight*X*X for each dimension

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

~THnBase()
 Destruct a THnBase
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 axes.
 If keepTargetAxis is true, the axes will keep their original xmin / xmax,
 else they will be restricted to the range selected (first / last).
void Init(const char* name, const char* title, const TObjArray* axes, Bool_t keepTargetAxis, Int_t chunkSize = 1024*16)
 Initialize axes and name.
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. Create a TH1D/TH2D/TH3D, depending on the number
 of elements in axes.
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.
THnBase* CreateHnAny(const char* name, const char* title, const THnBase* hn, Bool_t sparse, Int_t chunkSize = 1024*16)
 Create a THnSparse (if "sparse") or THn  from "hn", possibly
 converting THn <-> THnSparse.
void Add(const TH1* hist, Double_t c = 1.)
 Fill the THnBase with the bins of hist that have content
 or error != 0.
TFitResultPtr Fit(TF1* f1, Option_t* option = "", Option_t* goption = "")
   Fit a THnSparse with function f

   since the data is sparse by default a likelihood fit is performed
   merging all the regions with empty bins for betetr performance efficiency

  Since the THnSparse is not drawn no graphics options are passed
  Here is the list of possible options

                = "I"  Use integral of function in bin instead of value at bin center
                = "X"  Use chi2 method (default is log-likelihood method)
                = "U"  Use a User specified fitting algorithm (via SetFCN)
                = "Q"  Quiet mode (minimum printing)
                = "V"  Verbose mode (default is between Q and V)
                = "E"  Perform better Errors estimation using Minos technique
                = "B"  Use this option when you want to fix one or more parameters
                       and the fitting function is like "gaus", "expo", "poln", "landau".
                = "M"  More. Improve fit results
                = "R"  Use the Range specified in the function range
void GetRandom(Double_t* rand, Bool_t subBinRandom = kTRUE)
 Generate an n-dimensional random tuple based on the histogrammed
 distribution. If subBinRandom, the returned tuple will be additionally
 randomly distributed within the randomized bin, using a flat
 distribution.
Bool_t IsInRange(Int_t* coord) const
 Check whether bin coord is in range, as defined by TAxis::SetRange().
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 !wantNDim) a TH1/2/3 histogram,
 keeping only axes in dim (specifying ndim dimensions).
 If "option" contains "E" errors will be calculated.
                      "A" ranges of the taget axes will be ignored.
                      "O" original axis range of the taget axes will be
                          kept, but only bins inside the selected range
                          will be filled.
void Scale(Double_t c)
 Scale contents and errors of this histogram by c:
 this = this * c
 It does not modify the histogram's number of entries.
void AddInternal(const THnBase* h, Double_t c, Bool_t rebinned)
 Add() implementation for both rebinned histograms and those with identical
 binning. See 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, Sumw2 is automatically called for this
 if not already set.
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, Sumw2 is automatically called for this
 if not already set.
 In contrast to Add(), RebinnedAdd() does not require consistent binning of
 this and h; instead, each bin's center is used to determine the target bin.
Long64_t Merge(TCollection* list)
 Merge this with a list of THnBase's. All THnBase's provided
 in the list must have the same bin layout!
void Multiply(const THnBase* h)
 Multiply this histogram by histogram h
 this = this * h
 Note that if h has Sumw2 set, Sumw2 is automatically called for this
 if not already set.
void Multiply(TF1* f, Double_t c = 1.)
 Performs the operation: this = this*c*f1
 if errors are defined, errors are also recalculated.

 Only bins inside the function range are recomputed.
 IMPORTANT NOTE: If you intend to use the errors of this histogram later
 you should call Sumw2 before making this operation.
 This is particularly important if you fit the histogram after
 calling Multiply()
void Divide(const THnBase* h)
 Divide this histogram by h
 this = this/(h)
 Note that if h has Sumw2 set, Sumw2 is automatically called for
 this if not already set.
 The resulting errors are calculated assuming uncorrelated content.
void Divide(const THnBase* h1, const THnBase* h2, Double_t c1 = 1., Double_t c2 = 1., Option_t* option = "")
 Replace contents of this histogram by multiplication of h1 by h2
 this = (c1*h1)/(c2*h2)
 Note that if h1 or h2 have Sumw2 set, Sumw2 is automatically called for
 this if not already set.
 The resulting errors are calculated assuming uncorrelated content.
 However, if option ="B" is specified, Binomial errors are computed.
 In this case c1 and c2 do not make real sense and they are ignored.
Bool_t CheckConsistency(const THnBase* h, const char* tag) const
 Consistency check on (some of) the parameters of two histograms (for operations).
void SetBinEdges(Int_t idim, const Double_t* bins)
 Set the axis # of bins and bin limits on dimension idim
void SetTitle(const char* title)
 Change (i.e. set) the title.

 If title is in the form "stringt;string0;string1;string2 ..."
 the histogram title is set to stringt, the title of axis0 to string0,
 of axis1 to string1, of axis2 to string2, etc, just like it is done
 for TH1/TH2/TH3.
 To insert the character ";" in one of the titles, one should use "#;"
 or "#semicolon".
THnBase* RebinBase(Int_t group) const
 Combine the content of "group" neighboring bins into
 a new bin and return the resulting THnBase.
 For group=2 and a 3 dimensional histogram, all "blocks"
 of 2*2*2 bins will be put into a bin.
THnBase* RebinBase(const Int_t* group) const
 Combine the content of "group" neighboring bins for each dimension
 into a new bin and return the resulting THnBase.
 For group={2,1,1} and a 3 dimensional histogram, pairs of x-bins
 will be grouped.
void ResetBase(Option_t* option = "")
 Clear the histogram
Double_t ComputeIntegral()
 Calculate the integral of the histogram
void PrintBin(Long64_t idx, Option_t* options) const
 Print bin with linex index "idx".
 For valid options see PrintBin(Long64_t idx, Int_t* bin, Option_t* options).
Bool_t PrintBin(Long64_t idx, Int_t* coord, Option_t* options) const
 Print one bin. If "idx" is != -1 use that to determine the bin,
 otherwise (if "idx" == -1) use the coordinate in "bin".
 If "options" contains:
   '0': only print bins with an error or content != 0
 Return whether the bin was printed (depends on options)
void PrintEntries(Long64_t from = 0, Long64_t howmany = -1, Option_t* options = 0) const
 Print "howmany" entries starting at "from". If "howmany" is -1, print all.
 If "options" contains:
   'x': print in the order of axis bins, i.e. (0,0,...,0), (0,0,...,1),...
   '0': only print bins with content != 0
void Print(Option_t* option = "") const
 Print a THnBase. If "option" contains:
   'a': print axis details
   'm': print memory usage
   's': print statistics
   'c': print its content, too (this can generate a LOT of output!)
 Other options are forwarded to PrintEntries().
void Browse(TBrowser* b)
 Browse a THnSparse: create an entry (ROOT::THnSparseBrowsable) for each
 dimension.
THnBase& operator=(const THnBase& )
void UpdateXStat(const Double_t* x, Double_t w = 1.)
void FillBin(Long64_t bin, Double_t w)
void FillBinBase(Double_t w)
 Increment the statistics due to filled weight "w",
void InitStorage(Int_t* nbins, Int_t chunkSize)
void Reserve(Long64_t )
{}
void SetFilledBins(Long64_t )
{}
Bool_t PrintBin(Long64_t idx, Int_t* coord, Option_t* options) const
TObjArray* GetListOfAxes()
{ return &fAxes; }
const TObjArray* GetListOfAxes() const
{ return &fAxes; }
TAxis* GetAxis(Int_t dim) const
{ return (TAxis*)fAxes[dim]; }
TList* GetListOfFunctions()
{ return 0; }
ROOT::THnBaseBinIter* CreateIter(Bool_t respectAxisRange) const
Long64_t GetNbins() const
Double_t GetEntries() const
{ return fEntries; }
Double_t GetWeightSum() const
{ return fTsumw; }
Int_t GetNdimensions() const
{ return fNdimensions; }
Bool_t GetCalculateErrors() const
{ return fTsumw2 >= 0.; }
void CalculateErrors(Bool_t calc = kTRUE)
 Calculate errors (or not if "calc" == kFALSE)
Long64_t Fill(const Double_t* x, Double_t w = 1.)
Long64_t Fill(const char** name, Double_t w = 1.)
Double_t GetBinError(const Int_t* idx) const
{ return GetBinError(GetBin(idx)); }
Double_t GetBinError(Long64_t linidx) const
{ return TMath::Sqrt(GetBinError2(linidx)); }
void SetBinError(const Int_t* idx, Double_t e)
{ SetBinError(GetBin(idx), e); }
void SetBinError(Long64_t bin, Double_t e)
{ SetBinError2(bin, e*e); }
void AddBinContent(const Int_t* x, Double_t v = 1.)
{ AddBinContent(GetBin(x), v); }
void SetEntries(Double_t entries)
{ fEntries = entries; }
Double_t GetBinContent(const Int_t* idx) const
{ return GetBinContent(GetBin(idx)); }
Double_t GetBinContent(Long64_t bin, Int_t* idx = 0) const
Double_t GetBinError2(Long64_t linidx) const
Long64_t GetBin(const Int_t* idx) const
Long64_t GetBin(const Double_t* x) const
Long64_t GetBin(const char** name) const
Long64_t GetBin(const Int_t* idx, Bool_t = kTRUE)
Long64_t GetBin(const Double_t* x, Bool_t = kTRUE)
Long64_t GetBin(const char** name, Bool_t = kTRUE)
void SetBinContent(const Int_t* idx, Double_t v)
{ SetBinContent(GetBin(idx), v); }
void SetBinContent(Long64_t bin, Double_t v)
void SetBinError2(Long64_t bin, Double_t e2)
void AddBinError2(Long64_t bin, Double_t e2)
void AddBinContent(Long64_t bin, Double_t v = 1.)
Double_t GetSumw() const
{ return fTsumw; }
Double_t GetSumw2() const
{ return fTsumw2; }
Double_t GetSumwx(Int_t dim) const
{ return fTsumwx[dim]; }
Double_t GetSumwx2(Int_t dim) const
{ return fTsumwx2[dim]; }
TH1D* Projection(Int_t xDim, Option_t* option = "") const
 Project all bins into a 1-dimensional histogram,
 keeping only axis "xDim".
 If "option" contains "E" errors will be calculated.
                      "A" ranges of the taget axes will be ignored.
                      "O" original axis range of the taget axes will be
                          kept, but only bins inside the selected range
                          will be filled.
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".

 WARNING: just like TH3::Project3D("yx") and TTree::Draw("y:x"),
 Projection(y,x) uses the first argument to define the y-axis and the
 second for the x-axis!

 If "option" contains "E" errors will be calculated.
                      "A" ranges of the taget axes will be ignored.
{xDim, yDim}
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", and "zDim".
 If "option" contains "E" errors will be calculated.
                      "A" ranges of the taget axes will be ignored.
                      "O" original axis range of the taget axes will be
                          kept, but only bins inside the selected range
                          will be filled.
{xDim, yDim, zDim}
THnBase* ProjectionND(Int_t ndim, const Int_t* dim, Option_t* option = "") const
void Reset(Option_t* option = "")
void Sumw2()
Bool_t IsFolder() const
{ return kTRUE; }