Unintended copies of TTrees being saved to TFile


I am a little confused as to why I am ending up with two versions of the same TTree in my resulting .root file in a processing script.

The basic structure of the processing script is as follows:

TFile* infile = new TFile("infile.root");

TTree* my_input_tree = (TTree*)infile->Get("input_tree");

TFile* outfile = new TFile("output.root","recreate");
TTree* tree = new TTree("output_tree","output_tree");

input event;  // Input event class
analysisevent event; // Output event class

// *Set addresses of input_tree branches to corresponding members of input event class*

// *Set up branches of output tree and set addresses to corresponding members of output event class*

for(int i = 0;i<my_input_tree->GetEntries();i++){

// *Do processing event-by-event*



I end up with two TTrees in the output file- with identical names but with a suffix “;1” and “;2”. What is even stranger is that they appear to have different numbers of entries!

Can anyone tell me why this is?

Many thanks


Search for “cycle” and/or “namecycle”.

Ok so I think I understand…

The latter ‘cycles’ are there as a kind of second repository for the same data.

I was slightly concerned that my data was being split somehow and I needed to make sure to account for the data that ends up in both trees.

When I call, e.g. ttree->Get(“treename”), this will return the first namecycle which should contain all of the data. If I otherwise look at the later namecycles this will contain some subset of the data in the earliest namecycle.

Is that correct?

Usually, the last cycle contains all the data and ttree->Get(“treename”) will retrieve the last one.

Thanks for your help. I wonder if there is some way for me to prevent this splitting from occuring in the first place, to avoid confusion for myself or others who may look at these files. I actually started looking into this since the number of events in the tree obtained through the TFile->Get(“treename”) method seem strange. I am slightly unsure if I should be adding together the counts in the different namecycles or not.

I did try the TTree::SetMaxTreeSize() method (to prevent the splitting to different namecycles) but this doesn’t seem to change anything. The trees I am dealing are far less than the default 100GB limit anyway.

Another question- if I am processing an input tree that already has several namecycles, will this ensure that the subsequent output tree will also have (at least) the same number of namecycles?

I also do not understand the ordering of the suffixes of the namecycles- sometimes I have ;38, ;39 but no others. What has happened to ;1-;37?


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