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,
Duong

Hi,

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,
Duong

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:
https://root.cern.ch/doc/master/TTreePlayer_8cxx_source.html#l00333
https://root.cern.ch/doc/master/TTreeFormula_8cxx_source.html#l02674
https://root.cern.ch/doc/master/TTreeFormula_8cxx_source.html#l03925

See some bug of TTree::Draw: https://sft.its.cern.ch/jira/browse/ROOT-8009
An alternative: https://root.cern.ch/doc/v608/classTTreeReader.html
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.