ROOT logo
ROOT » HIST » HIST » THn

class THn: public THnBase



    Multidimensional histogram.

 Use a THn if you really, really have to store more than three dimensions,
 and if a large fraction of all bins are filled.
 Better alternatives are
   * THnSparse if a fraction of all bins are filled
   * TTree
 The major problem of THn is the memory use caused by n-dimensional
 histogramming: a THnD with 8 dimensions and 100 bins per dimension needs
 more than 2.5GB of RAM!

 To construct a THn object you must use one of its templated, derived
 classes:
 THnD (typedef for THnT<Double_t>): bin content held by a Double_t,
 THnF (typedef for THnT<Float_t>): bin content held by a Float_t,
 THnL (typedef for THnT<Long_t>): bin content held by a Long_t,
 THnI (typedef for THnT<Int_t>): bin content held by an Int_t,
 THnS (typedef for THnT<Short_t>): bin content held by a Short_t,
 THnC (typedef for THnT<Char_t>): bin content held by a Char_t,

 They take name and title, the number of dimensions, and for each dimension
 the number of bins, the minimal, and the maximal value on the dimension's
 axis. A TH2F h("h","h",10, 0., 10., 20, -5., 5.) would correspond to
   Int_t bins[2] = {10, 20};
   Double_t xmin[2] = {0., -5.};
   Double_t xmax[2] = {10., 5.};
   THnF hn("hn", "hn", 2, bins, min, max);

 * Filling
 A THn is filled just like a regular histogram, using
 THn::Fill(x, weight), where x is a n-dimensional Double_t value.
 To take errors into account, Sumw2() must be called before filling the
 histogram.
 Storage is allocated when the first bin content is stored.

 * Projections
 The dimensionality of a THn can be reduced by projecting it to
 1, 2, 3, or n dimensions, which can be represented by a TH1, TH2, TH3, or
 a THn. See the Projection() members. To only project parts of the
 histogram, call
   hn->GetAxis(12)->SetRange(from_bin, to_bin);

 * Conversion from other histogram classes
 The static factory function THn::CreateHn() can be used to create a THn
 from a TH1, TH2, TH3, THnSparse and (for copying) even from a THn. The
 created THn will have compatble storage type, i.e. calling CreateHn() on
 a TH2F will create a THnF.

Function Members (Methods)

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

public:
virtual~THn()
voidTObject::AbstractMethod(const char* method) const
voidTHnBase::Add(const THnBase* h, Double_t c = 1.)
voidTHnBase::Add(const TH1* hist, Double_t c = 1.)
voidAddBinContent(const Int_t* idx, 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 voidTHnBase::Browse(TBrowser* b)
voidTHnBase::CalculateErrors(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_tTHnBase::ComputeIntegral()
virtual voidTNamed::Copy(TObject& named) const
static THn*CreateHn(const char* name, const char* title, const TH1* h1)
static THn*CreateHn(const char* name, const char* title, const THnBase* hn)
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)
voidTHnBase::Divide(const THnBase* h)
voidTHnBase::Divide(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_tTHnBase::Fill(const Double_t* x, Double_t w = 1.)
Long64_tTHnBase::Fill(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
TFitResultPtrTHnBase::Fit(TF1* f1, Option_t* option = "", Option_t* goption = "")
virtual const TNDArray&GetArray() const
virtual TNDArray&GetArray()
TAxis*THnBase::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_tTHnBase::GetBinError(const Int_t* idx) const
Double_tTHnBase::GetBinError(Long64_t linidx) const
virtual Double_tGetBinError2(Long64_t linidx) const
Bool_tTHnBase::GetCalculateErrors() const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
Double_tTHnBase::GetEntries() const
virtual const char*TObject::GetIconName() const
TObjArray*THnBase::GetListOfAxes()
const TObjArray*THnBase::GetListOfAxes() const
TList*THnBase::GetListOfFunctions()
virtual const char*TNamed::GetName() const
virtual Long64_tGetNbins() const
Int_tTHnBase::GetNdimensions() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
voidTHnBase::GetRandom(Double_t* rand, Bool_t subBinRandom = kTRUE)
Double_tTHnBase::GetSumw() const
Double_tTHnBase::GetSumw2() const
Double_tTHnBase::GetSumwx(Int_t dim) const
Double_tTHnBase::GetSumwx2(Int_t dim) const
virtual const char*TNamed::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
Double_tTHnBase::GetWeightSum() 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_tTHnBase::IsFolder() const
Bool_tTHnBase::IsInRange(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_tTHnBase::Merge(TCollection* list)
voidTHnBase::Multiply(const THnBase* h)
voidTHnBase::Multiply(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 voidTHnBase::Print(Option_t* option = "") const
voidTHnBase::PrintBin(Int_t* coord, Option_t* options) const
voidTHnBase::PrintBin(Long64_t idx, Option_t* options) const
voidTHnBase::PrintEntries(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
THn*Projection(Int_t ndim, const Int_t* dim, Option_t* option = "") const
TH3D*Projection(Int_t xDim, Int_t yDim, Int_t zDim, Option_t* option = "") const
THnBase*THnBase::ProjectionND(Int_t ndim, const Int_t* dim, Option_t* option = "") const
virtual Int_tTObject::Read(const char* name)
THn*Rebin(Int_t group) const
THn*Rebin(const Int_t* group) const
voidTHnBase::RebinnedAdd(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 = "")
voidTHnBase::Scale(Double_t c)
voidSetBinContent(const Int_t* idx, Double_t v)
virtual voidSetBinContent(Long64_t bin, Double_t v)
voidTHnBase::SetBinEdges(Int_t idim, const Double_t* bins)
voidTHnBase::SetBinError(const Int_t* idx, Double_t e)
voidTHnBase::SetBinError(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)
voidTHnBase::SetEntries(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 voidTHnBase::SetTitle(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:
voidTHnBase::AddInternal(const THnBase* h, Double_t c, Bool_t rebinned)
voidAllocCoordBuf() const
Bool_tTHnBase::CheckConsistency(const THnBase* h, const char* tag) const
THnBase*THnBase::CloneEmpty(const char* name, const char* title, const TObjArray* axes, Bool_t keepTargetAxis) const
TH1*THnBase::CreateHist(const char* name, const char* title, const TObjArray* axes, Bool_t keepTargetAxis) const
static THnBase*THnBase::CreateHnAny(const char* name, const char* title, const TH1* h1, Bool_t sparse, Int_t chunkSize = 1024*16)
static THnBase*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)
voidTHnBase::FillBinBase(Double_t w)
voidTHnBase::Init(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_tTHnBase::PrintBin(Long64_t idx, Int_t* coord, Option_t* options) const
TObject*THnBase::ProjectionAny(Int_t ndim, const Int_t* dim, Bool_t wantNDim, Option_t* option = "") const
THnBase*THnBase::RebinBase(Int_t group) const
THnBase*THnBase::RebinBase(const Int_t* group) const
virtual voidTHnBase::Reserve(Long64_t)
voidTHnBase::ResetBase(Option_t* option = "")
virtual voidTHnBase::SetFilledBins(Long64_t)
voidTHnBase::UpdateXStat(const Double_t* x, Double_t w = 1.)
private:
THn&operator=(const THn&)

Data Members

protected:
TObjArrayTHnBase::fAxesaxes of the histogram
TObjArrayTHnBase::fBrowsables! browser-helpers for each axis
Int_t*fCoordBuf! Temporary buffer
Double_tTHnBase::fEntriesnumber of entries, spread over chunks
Double_t*THnBase::fIntegral! array with bin weight sums
enum THnBase::THnBase::fIntegralStatus! status of integral
TStringTNamed::fNameobject identifier
Int_tTHnBase::fNdimensionsnumber of dimensions
TNDArrayT<Double_t>fSumw2bin error, lazy allocation happens in TNDArrayT
TStringTNamed::fTitleobject title
Double_tTHnBase::fTsumwtotal sum of weights
Double_tTHnBase::fTsumw2total sum of weights squared; -1 if no errors are calculated
TArrayDTHnBase::fTsumwxtotal sum of weight*X for each dimension
TArrayDTHnBase::fTsumwx2total sum of weight*X*X for each dimension

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

~THn()
 Destruct a THn
ROOT::THnBaseBinIter* CreateIter(Bool_t respectAxisRange) const
 Create an iterator over all bins. Public interface is THnIter.
void Sumw2()
 Enable calculation of errors
void AllocCoordBuf() const
 Create the coordinate buffer. Outlined to hide allocation
 from inlined functions.
void InitStorage(Int_t* nbins, Int_t chunkSize)
 Initialize the storage of a histogram created via Init()
void Reset(Option_t* option = "")
 Reset the contents of a THn.
THn& operator=(const THn& )
void FillBin(Long64_t bin, Double_t w)
 Increment the bin content of "bin" by "w",
 return the bin index.
GetArray()
THn* CreateHn(const char* name, const char* title, const TH1* h1)
THn* CreateHn(const char* name, const char* title, const THnBase* hn)
Long64_t GetNbins() const
{ return GetArray().GetNbins(); }
Long64_t GetBin(const Int_t* idx) const
return GetArray()
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)
 Forwards to THnBase::SetBinContent().
 Non-virtual, CINT-compatible replacement of a using declaration.
SetBinContent(Long64_t bin, Double_t v)
void SetBinError2(Long64_t bin, Double_t e2)
void AddBinContent(const Int_t* idx, Double_t v = 1.)
 Forwards to THnBase::SetBinContent().
 Non-virtual, CINT-compatible replacement of a using declaration.
AddBinContent(Long64_t bin, Double_t v = 1.)
void AddBinError2(Long64_t bin, Double_t e2)
Double_t GetBinContent(const Int_t* idx) const
 Forwards to THnBase::GetBinContent() overload.
 Non-virtual, CINT-compatible replacement of a using declaration.
return GetBinContent(idx)
Double_t GetBinError2(Long64_t linidx) const
TH1D* Projection(Int_t xDim, Option_t* option = "") const
 Forwards to THnBase::Projection().
 Non-virtual, as a CINT-compatible replacement of a using
 declaration.
return Projection(xDim, option)
TH2D* Projection(Int_t yDim, Int_t xDim, Option_t* option = "") const
 Forwards to THnBase::Projection().
 Non-virtual, as a CINT-compatible replacement of a using
 declaration.
TH3D* Projection(Int_t xDim, Int_t yDim, Int_t zDim, Option_t* option = "") const
 Forwards to THnBase::Projection().
 Non-virtual, as a CINT-compatible replacement of a using
 declaration.
THn* Rebin(Int_t group) const
THn* Rebin(const Int_t* group) const