How to divide a ROOT file into smaller files using TCut


I have a series of ROOT files which contain event data from our experiments at the ANU (typical experiments in the current series use 5 particle detectors, four gamma detectors and 4 TDCs).

I have experience of producing subset files from the main ROOT file using TCut on the basis of various attributes of the data (e.g. for data lying between certain limits).

  TCut p1 = Form("X.PE1>%g && X.PE1<%g",P1_min,P1_max);

I need to divide the event data so that the first 1 Mb of event data goes into one file, the next 1Mb of event data into the next file and so on. I want to do this without losing the relationships between the data (e.g. coincidences between gamma and particle data).

An example ROOT file with the same structure as the files I want to cut up is attached.

I have no idea where to start on this. I have tried using circular buffers but I can’t seem to get the syntax correct.

Any guidance you can give on an appropriate method will be greatly appreciated.
pd1060309_r12.root (1.75 MB)


would TFile::SetMaxTreeSize() do? See … axTreeSize

Cheers, Axel.

Hi Axel,

I tried using TFile::SetMaxTreeSize() in one of my attempt as it does seems perfect (I also tried SetCircular) - I must be using it incorrectly because I did not get the expected effect.

Is there an example of this command being used in a script that I could look at to see where I might be going wrong?

I will post a short script (that runs) later today to illustrate my problem. It could simply be that I am misinterpreting how the command is meant to work.


Hi Russell,

yikes, I meant TTree::SetMaxTreeSize() (for which I also sent the link)! An example is in test/MainEvent.cxx.

Cheers, Axel.

Dear Axel,

It is all working now - the problem was that I was miscounting the zeros in my TTree::SetMaxTreeSize command. This meant that I was telling ROOT to split a 50Mb into 50Mb chunks and nothing was happening.

{ // TString fname01="ru1020509_r03.root"; TString tree01_name="TREE"; // TFile* f01=TFile::Open( fname01.Data(), "READ" ); TTree *T = (TTree*)f01.Get("tree01_name"); TChain chain("TREE"); // TREE->SetMaxTreeSize(5000000); // chain.Add("ru1020509_r03.root"); // chain->Merge("ru1020509_r03_split.root"); // }

Thank you for your help.