Multiple loop indices in TTree::Draw()?


ROOT Version: 6.40.04
Platform: linuxx8664gcc
Compiler: gcc


Hi,

Would it be possible to expose multiple independent loop indices in TTree::Draw(), to plot coincidences between hits in variable-length arrays from the command-line?
I find myself wanting to do this very often. :slight_smile:

For example, with gamma detector hit arrays GAe[GAn], GAt[GAn] and charged-particle detector hit arrays CDe[CDn], CDt[CDn]:

Gamma-gamma coincidences with a timing cut:

t->Draw("GAe[i0$]:GAe[i1$]",
        "(i0$ != i1$) && (fabs(GAt[i0$] - GAt[i1$]) < 10)");

Particle-gated gamma-gamma coincidences (with a graphical cut mycut on the CD arrays) (effectively a triple-loop):

t->Draw("GAe[i1$]:GAe[i2$]",
        "mycut && (i1$ != i2$) && "
        "(fabs(GAt[i1$] - CDt[i0$]) < 100) && "
        "(fabs(GAt[i2$] - CDt[i0$]) < 100) && "
        "(fabs(GAt[i1$] - GAt[i2$]) < 10)");

(here mycut would implicitly references the CD arrays via i0$ as the first dimension, or an explicitly notation might be useful too).

Since TTreeFormula / TTreeFormulaManager already handles multi-index nested loops when matrices are involved, it seems the underlying machinery is there and the missing link is exposing explicit dimension indices (like i0$, i1$, i2$, analogous to Iteration$) in the parser?

Best regards,
Håkan

Maybe @pcanal knows if there’s a solution