TTree::Draw not correctly running over free indices?


I have an ntuple from event-generation (combined ntuple), containing branches like:

NPar/I … number of particles in event
Type[NPar]/I … PDG of each particle
KFDauNt[NPar]/I … index to first daughter of a given particle

Now, I would like to see PDG codes of the first daughter of Z0 (PDG=23). So what I did was:

(The empty brackets are not neccessary, but better for understandability). But this draw command does not work correctly. Although I have only Z0->mumu decays in all the events, it draws somewhat arbitrary PDG codes. If I modify the draw condition by adding always-true condition like that:

then it works as expected - I see only abs(PDG)=13.

In both cases, the number of entries in the resulting histograms is equal to number of entries in the ntuple. So the first draw command scans through the correct number of items, but somewhat using wrong indices (haven’t figured out through what it scans finally). According to the description in TTree::Draw reference, I would expect that draw command would scan through the items like:

draw Type[KFDauNt[0]] only if Type[0]==23 draw Type[KFDauNt[1]] only if Type[1]==23 draw Type[KFDauNt[2]] only if Type[2]==23 ... draw Type[KFDauNt[NPar-1]] only if Type[NPar-1]==23
I.e. scanning synchronously through the free index. But obviously, this is true only if I use the KFDauNt[] in the condition of the Draw command (using it “standalone” in the Draw-argument does not help).

Does anyone has an idea, why the two draw commands work differently ? (And what ROOT really does in the first “wrong” case ?).

thanks for help,

I just forget to add one, may be important, aspect: using the Type[KFDauNt[]] in the condition part of the Draw command: e.g. like:

t3333->Draw(“1”,“Type[]==23 && abs(Type[KFDauNt[]]==13)”)

this seem to work correctly (telling me that the condition is true for all events). So it look like the indexing is somehow broken only when used in the Draw-argument, but not in the Draw-condition.


Hi Pavel,

I can not reproduce this problem in my simple test. Could you send me your data file? By the way which version of ROOT are you using?


Hello Philippe,

root versions I have tried: 5.17.05 (local), 5.10.00e (lxplus), 5.19.02 (lxplus). In the attachment, there is a data file with 100 events and two figures representing the “wrong” and “correct behaviour” as described in the first e-mail.


evtgen.CBNT.root (477 KB)


This has been fixed today in the SVN trunk (5.19/03)

Thanks for reporting the issue.


PS. The work around you found is the correct work around for older version of ROOT.