How to see the code snippets of selection when using TTree::Draw

Hi All,

I find the TTree::Draw() is a very useful method for my analysis but it is a bit confusing sometime, especially when a complex expression is used. I see the Draw() still draws something but I am not sure it is what I want.
For the purpose of debugging, if I provide TTree::Draw() the “varexp” and “selection”, can I see the translations of those to an equivalent C/C++ code snippet? By that, I can see how TTree::Draw() loops and fill the histograms.

Thank you,


TTree::Draw() does not translate the expression to C++. Instead it interprets it itself.

I.e. we don’t have the means of converting the expression to C++ code.

Cheers, Axel.

Hi Axel,
I see so it means there is no way to check rather than trying to make sense of the output histograms.
Thank you,

When you call TTree::Draw, a TTreeFormula is being generated. You can trace back the C++ expressions behind the scenes in the TTreePlayer.cxx and TTreeFormula.cxx files:

See some bug of TTree::Draw:
An alternative:
A newer more robust method: Selecting subset of entries in TTree and plot them in Histogram

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