Dear all,
I am trying to copy a pre-existing tree from root file, add new branch to the tree, and save (only the new, modified, tree) to a new root file. What I observe is that in new root file are saved both the old and the new ttree. How can I avoid it?
This is the relevant part of the code that I am using:
f_in = TFile.Open('inputFile.root')
t_in = f_in.Get("mytree")
f_out = TFile('outFile.root', "recreate")
t_out = t_in.CloneTree()
modifyTree(t_out) #complicate function to add the new branch to t_out, looping on t_out and uses Fill().
f_out.cd()
t_out.Write()
The “backup cycle” is a snapshot of the meta data of the TTree (i.e. the list of branches and the location in the file of their data baskets) that is kept as a ‘precaution’ when writing the newest version of the meta data (the “current cycle”). So unless something went ‘wrong’ during the writing, you can safely ignore the “backup cycle”. (There is also ways to not keep the “backup cycle” when requesting the writing the TTree). To re-iterate this only means that the meta data is (partially) duplicated AND none of the actual data is duplicated.