I am trying too manipulate a RooRealVar, and I read somewhere in the forum that the only way to do that is to manipulate variables directly from the tree. So I’m trying to add a new branch with the log of a variable, but I’m struggling to do that.
I know in python I can just do (assuming tree has a branch named x)
@StephanH can a branch that has been just written be used by RooRealVar here?
Also, I have doubts if it is possible to both read and write the same TTree simultaneously, or if you need to read one tree and write in another, then close the file of the latter. @pcanal can perhaps comment.
When done carefully and in different branches, you should be able to read and write to the same TTree. The code snippet does not indicate how the RooRealVar is attached to the existing TTree. For example it might be opening a 2nd copy of the file in which case ordering of things might matter a lot; In this regard, in the above snippet the file should probably be opened in Update mode and the TFile and/or TTree written.