TBranch as function of other TBranch in TTree possible?

Dear ROOT experts,

This might be an unusual question, but is there a way to have a TBranch in a TTree that is the function of a second TBranch in a TTree?

E.g. let’s say I have a TBranches of integers in my TTree that is like

myInt = [1,2,3,4,5] 

and I want to store a second TBranch whose entries are the squares of the entries of myInt. I could just calculate the squares of myInt when I analyze the TTree or save a 2nd TBranch like

myIntSq = [1,4,9,16,25]

But let’s say I do not want to store this extra information and also don’t want to have to calculate myIntSq explicitly when analyzing the TTree.
Instead I want each entry of myIntSq to be a function of the corresponding entry of myInt.
Is that possible?

Best,
Christian

Welcome to the ROOT Forum!
I don’t think this is possible, but I’m sure @pcanal or @Axel knows better

It the RDataFrame, you can use its built-in Define method.

In the “conventional” way of analysis, you can use: TTree::SetAlias

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.