Summing energies from two branches under certain conditions

Dear @DBoni ,

Thanks for reaching out. I understand your problem and I think it potentially can be solved with TTreeIndex and RDataFrame (see a somewhat related post at Modification of a RDataFrame with an extracted column).

Although the application is not trivial so I need to spend some time trying to frame your problem. Meanwhile let me know if the material above helps you in finding some possible solution.

Cheers,
Vincenzo