I am trying to rename branches in a TTree to then copy them in another TTree with a new name.
The snippet goes like this:
for inputBranchName, outputBranchName in zip(inputBranches,outputBranches): inputBranch=tree.GetLeaf(inputBranchName) print inputBranch inputBranch.SetName(outputBranchName)
where input/outputBranches are the lists of branches I want to rename/new branch names. This works fine whenever I am dealing with simple (=int) branches, but doesn’t when I am working with std::vector branches.
If I print inputBranch before the renaming in the case of the simple branch, I get:
<ROOT.TLeafI object (“AntiKt6Truth_n”) at 0xad826b8>
and the renaming works ok. If I print inputBranch in the case of the std::vector branch I get
<ROOT.TLeafElement object (“AntiKt6Truth_E”) at 0xad82b28>
and my output is:
inputBranch.SetName(outputBranchName) ReferenceError: attempt to access a null-pointer
Does anyone know what I am doing wrong?
EDIT: I found what I was doing wrong, and it was a typo . Everything works fine, sorry for the noise…