I thought I reasonably understood how TTree::Draw works, but I ran into a weird issue. Could someone explain why it works the way I observe?

I have a branch “cell_chi2” that is a 28-element array of doubles. I fill with -1 values for “no value” since negative chi-square is not meaningful, and where a value is recorded it will be 0 or greater. I also have a branch “Track_chi2” that is supposed to be the sum of these elements as calculated by the code that produces my TTree (i.e. it should be redundant).

I expected this draw command to draw a 1D histogram of all zero entries:

`mytree->Draw("Sum$(cell_chi2) - Track_chi2","cell_chi2 > 0 && Track_chi2 > 0");`

instead I see a histogram of negative-integer values from 0 to 28, which are clearly the -1 values being added up in the Sum$. So if I instead do:

`mytree->Draw("Sum$(cell_chi2 > 0 ? cell_chi2 : 0) - Track_chi2"," Track_chi2 > 0");`

then I see the expected all-zero result.

From my understanding of how TTree::Draw works, I thought the first would draw the same thing as the second. Can someone explain what is being looped over, and what “cell_chi2 > 0” is actually selecting? Is it just checking if the first element of cell_chi2 is > 0, or is it doing some pointer arithmetic, comparing the address of the first element to be > 0?

Thanks,

Jean-François