Creating a large histogram with tree splitting


I’m trying to create a large histogram by using splitting.
However, when I change the splitting value of the branch with the below code, it doesn’t seem to allow me to use more bins.
I’m wondering if I’m doing the splitting correctly or whether it is actually possible?


  int noBins3Dx = 2000;
  int noBins3Dy = 2000;
  int noBins3Dz = 2000;
  double min3Dx = -1.;	double max3Dx = 1.;
  double min3Dy = -1;	double max3Dy = 1.;
  double min3Dz = -1.;	double max3Dz = 1.;
  Int_t split = 99;
  Int_t bsize = 64000;
  TFile *MyFile1 = new TFile("File1.root","RECREATE");
  TTree*mytree= new TTree("mytree","TestTree");
  TH3D*h1= new TH3D("h1","test",noBins3Dx, min3Dx, max3Dx, noBins3Dy, min3Dy,max3Dy, noBins3Dz, min3Dz, max3Dz);
  TBranch*branch= mytree->Branch("hBranch","TH3D",&h1, bsize, split);
  for (int i = 0; i < 100; i++)
    h1->Fill( double(rand())/RAND_MAX , double(rand())/RAND_MAX, double(rand())/RAND_MAX);


I think splitting in this case is something very different. It is about how the tree is written to disc, but not about histograms. See e.g. here:

Instead, I suggest to look into the histogram tutorials:

Thanks for the reply.

So from looking at all those examples I guess there is no way to make a histogram larger than the standard size limit?

I’m sure there is, but I don’t know what you mean by standard size limits.

If it’s about bins, you can have as many bins as you want (and as you memory supports).
If it’s about axis ranges, you can set any range supported by double numbers.

So what do you need?

I was talking about the 1073741822 byte limit.

But I just came across the following post.
So hopefully THnSparse is the answer.


Definitely try THnSparse if your histogram is more than 1Gb in Ram, and most of the bis are empty.