Returning the result of an expression value from a Branch

Hello Rooters!

I am looking for a method, and think it exists, but cannot find it.

Here is my problem:
I would like to have access to a specific value from a Branch, as for example:

But here, my idea would be to have access to the value : TMath::Abs(track.Pt) for my second entry.

and so I would like to know if there is a method to get it.

Thank you for your help!

If I am interpreting correctly:

TTrees are set up on purpose as a sequence of independent events. If your calculation for event N+1 can depend on event N, then your events are not independent.

You can still analyze them using ROOT, but you can’t do it with the built-in TTree::Scan/Draw methods. You’ll have to set branch addresses and iterate over entry numbers and store the values from previous entries yourself.


Hi Jean-François,

thank you for your reply, but actually I found a class and method to access it.
Actually it turns out that I was looking for the TTreeFormula class and its EvalInstance() method:

TTreeFormula formula(“formula”,“TMath::Abs(track.Pt)”,Pair);


Thanks for your support, even if the description of my issue was not very clear,