Update branch value


I’m trying to split a tree into two subtrees with the same structure and for one of the two I need to update the value a given branch for each entry. I’m splitting the tree by means of CopyTree(selection) and CopyTree(’!’+selection), whereas I have tried unsuccesfully several ways to update the value of the branch (among which, very naively, in a loop over the entries: my_tree.my_branch = new_value).
Is there a way to do that in pyroot?

Thanks in advance,


unless you give a code sample, all I can do is guess.

Assignment to a data member on a tree, will simply add that to its python dict, it will not send it back to any underlying structure. You will need to create variables that hold the values, use SetBranchAddress() to tell the tree about their existence, set their value, and then call Fill().

Theoretically this could be done in setattr for TTree (at least, I think it can), but I’ve never seen this use case before.