Adding array branches

First, this looks suspicious to me: You create a new TTree (Tree_cal), and then you re-assign the pointer to another TTree, read from the input file. Is it really what you want?
What about cloning the old tree, like in tis example:

   TFile *oldfile = TFile::Open("oldfile.root");
   TTree *oldtree = (TTree *)oldfile->Get("T");

   //Create a new file + a clone of old tree in new file
   TFile *newfile = TFile::Open("newfile.root", "RECREATE");
   TTree *newtree = oldtree->CloneTree();
   [...]

See also This topic

2 Likes