Renaming leaf in branch

I have a TTree with a TBranch that was written like this:


Is there a way to rename that leaf, so that it has the same name as the branch, without copying the file?

I tried

TFile *_file0 = TFile::Open("file.root","update");

but that had no effect.


returns nullptr;

It is possible but delicate. What is the purpose of the rename?
It might be simpler to alias it:



I want to use a TTreeReader, but with the leaf’s name not matching that of the branch it throws an error.

If it’s possible, can you tell me how to do it?

Fortunately, it turns out I was mis-remembering or so it seems.

Your example as-is works for me. Note that most tools use the branch name rather than the leaf name so you need to change both.


Most likely it is failing simply that the file is not open for update.


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