How to initialize multidimensional histograms using THn?

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


I want to create seven 5-Dim histograms which should contain double type value

I have a few arrays for names, bins, xmins and xmax for these histograms

const char * names[7] = {“a”, “b”,“c”,“d”,“e”,“f”,“g”}; // names of histograms
const int bins[7] = {100,100,10, 10,10,10,10};
const int xmins[7] = {0,0,0,0,0,0,0};
const int xmax[7] = {100,100,10, 10,10,10,10};

Each histogram should have 5 dimensions : dim1, dim2, dim3, dim4, dim5

Could you please say how can we do it with THn?

Thanks a lot :wink:


I have some difficulty in filling these Histograms
I am using

// Declaration
const Int_t Nhist = 4;
const char * names[Nhist] = {“distr”,“qPt”,“phi”,“tgl”};
const Int_t bins[Nhist] = {100,100,10, 10};
const Double_t xmin[Nhist] = {0,0,0,0};
const Double_t xmax[Nhist] = {100,100,10, 10};
THnD * nHis;
nHis = new THnD(“nHis”, “nHis”, Nhist, bins, xmin, xmax);

But How can we fill each for these for histograms.


It seems to me that you misunderstand what THn is.
You create a one (single) 4-dimensional histogram, NOT four 1-dimensional ones.

nHis is a 4-dim histogram which has four different axis - distr, qPt, phi, tgl
I did it like this. Is it not right?
I followed the THn example.

Well, THn and THnSparse are very similar so, you can try:

grep -r THn ${ROOTSYS}/t[eu]*

I am curious.
What it does? Where I can apply this?

A standard Linux / MacOS terminal / shell command which should return something like this:



This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.