Change value of TBranch

Ah, I have it. Not sure if that’s the canonical way, but it is working:

arr_br = array('f', [0]) roottree_out.SetBranchAddress(branch, arr_br) for event in roottree_in: arr_br[0] = 2.71828 roottree_out.Fill() roottree_out.Write()

It’s important to have the type of the array the same as the branch. While this sounds obvious, it took me a few hours to realize why my code wasn’t producing the expected output.

A helpful thread: Cloning tree and changing contents in the new tree