Is there an efficient way to perform arithmetic with the branches of a TNtuple? By this, I mean adding and subtracting branches, multiplying a branch by a scalar, etc.
In my case, I’d like to multiply all entries in one branch by a number (e.g. multiply all elements by, say, 12), and then add this branch to another branch, element-wise (which branch the result is stored in doesn’t matter, afterwards I no longer need the original two branches). The branches in question have hundreds of millions of entries, so doing this entry-by-entry is painfully slow. Is there a better way?
where you would use TTree::Draw (e.g. tree->Draw("2*x+3*y"), save to a TGraph and then fill the new branch from the graph points (or perhaps directly fill the new branch from the GetV array/s, without going through TGraph). The arithmetics part is fast, but doesn’t directly save to a new or existing branch.
The link Rene Brun gave doesn’t seem to work anymore but it’s here (scroll down to the section he mentions): https://root.cern/doc/master/classTTree.html#a73450649dc6e54b5b94516c468523e45