Very large TH1 array

Hi everyone,

I’m having troubles while declaring a very large TH1F array. I tried to use TNtuple or TTree but it’s too slow for my application. So the thing is I want to create an array of TH1F such as ADC[x][y][z] but it gives me a segmentation fault when the size is bigger than ADC[5][125][100]. I don’t want to use TH3 as I’ve already seen the answer, because I need a 1D histo for each x,y,z point.

So I would like to know if this is sort of normal due to the implementation of TH1 and if I can declare it as the declaration of arrays in C++ as for example: float ***Maps; Maps = new float **[x]; for(int i=0; i<x; i++ ){ Maps[i]= new float *[y]; for(int j=0; j<y; j++){ Maps[i][j]= new float [z]; } }
I already tried this but I should have done something wrong because I’m getting errors during the compilation.

Cheers,

Sam

Hi,

What is the size of your TH1? How do you create it? When you say ‘ADC[5][125][100]’ what is the type? Did you try THnSparse?

Philippe.

Hi Philippe,

My TH1 is of float type (if this is what you meant), the total end size is [55][500][400] and I declare it as TH1F ADC[x][y][z]. I didn’t try the THnSparse but I don’t think this is gonna work because I need an 1D histo for each x, y, z value and not a xy*z dimensional histo. I am not sure that I make myself clear!

Sam

Hi Sam,

If you use TH1D of just 100 bins this already means that you need 810055500400 bytes … i.e. 8Gb (That is without any of the overhead) … This means that in order to do this, you would have to use run with a 64 bits and have a machine with at 8Gb of RAM possibly 16GB. So it looks like you would need to find an alternative implementation.

[quote] I tried to use TNtuple or TTree but it’s too slow for my application.[/quote]What is your use case? Can you segment it? Do you really need all 11 millions histograms in memory at the same time?

Philippe.

Hi Philippe,

Normally I’m running under 64bits openSUSE and I don’t have that much of memory but the problem occurs before I declare the size of the histos! It stops when it reads the declaration of the array only. And as you said, I’ve already segmented it in multiple parts with loops to overpass this problem, it would just be faster and easier to make it in one time.

But thanks anyway!

Sam