Hi
I have a pyroot script wich renames a TTree. The part of it which does that I copied here:
for file in files:
f=TFile(path+file,'UPDATE')
for i,tree in enumerate(oldTrees):
t=f.Get(oldTrees[i])
if not t:
print 'Could not find tree '+oldTrees[i]+'. Skipping...'
continue
t.Write(newTrees[i])
gDirectory.Delete(oldTrees[i]+';*')
del t
f.Write()
f.Close()
del f
print 'Renamed trees for '+file+'.'
Everything seems to work fine, but when I subsequently use hadd to merge the root files, suddenly the old Trees appear again (together with the new trees). For example I am calling the useless command
I would expect x.root and y.root being exactly the same, but unfortunately this is not the case. I guess I am not properly deleting the trees in my root file but I don’t know what I am doing wrong.
Any help is much appreciated. Thanks.