This appears too complex for TTreeFormula, I recommend you try looking at this data with RDataFrame
TTreeFormula
RDataFrame