Multidimensional (>3) Histograms?

What would be the easiest way to go, if I need histogram functionality over more than three dimensions (in this special case 4)?

What I need is good performance on saving data to a “grid” and retrieving via GetBinContent(FindBin(x1,x2,x3,x4,…)) later. What I of course don’t need is plotting :slight_smile:. I wanted to use ROOT, because I know the TH* class is written for very good performance.

Is anything like this planned, or would it be easy to implement it myself in my own root copy (if there is no general interest)? Or is there another ROOT structure that might be suitable for this?

Thanks a lot,
Frank

One could implement a TH4 class or more generally a THN class.
We never implemented this class because it would be of limited
use for obvious memory consumption problems.
A TH4F with 100 bins on each axis will occupy about 434 Mbytes!
Because most bins are empty, people prefer to use the more
flexible ntuple (TTree, TNtuple) classes and make projections
using selections.

99% of the work to implement this class is the variety of Projection
functions (a la TH3::Project3D, but with many more combinations),
Merge, Fillrandom, Kolmogorov tests, etc

If you are courageous to implement TH4, I will include it in the source.
Let me know

Rene

You are right, the memory consumption is a drawback. But since this “grid” will be completely filled, I suppose, an Ntuple would not have an advantage over a TH*D?

What about the performance, with respect to accessing one element, in an Ntuple vs. Histogram?

Thanks for your help,
Frank

Frank,

Yes, it is clear that accessing an element in a 4-d array is much
faster than going through a TNtuple/TTree.

The point I was making in my previous post was that most of the work
for va TH4/THN is in the auxilliary functions, not in the constructors
or fill /get functions that are straightforward…

Rene

That’s right, and since I don’t need most of the auxiliary functions, I might adjust the necessary constructors/getters/setters for TH4.

If I decide to do it in a proper way I will send it here, so somebody else can use it, if one decides to.

Thanks for your thoughts,
Frank

EDIT: Posted before thinking. There is lots of 3D-specific stuff in TH1 (like getting bin of x,y,z…), so it might not be too easy to implement a 4D on top?