TTree Draw selection partial evaluation

Dear ROOTers,

I’m using the TTree.Draw command to create histograms (so far, so common). However there is a problem when trying to use an array that might either be empty or have one entry in the selection such that events are either accepted when:
the vector is empty OR (it has one entry AND the value is below a threshold).

Looking at the results it seems that this is equivalent to just evaluating the second expression
(it has one entry AND the value is below a threshold)

My current understanding is that ROOT always evaluates the full expression and rejects it because the value cannot be accessed for comparison. Would there be a way to circumvent this (for example stopping the evaluation after the first ORed expression succeds)?

Building the combined expression out of seperate TCut objects or using a ternary operator failed as well.

Thank you &


Could you please provide the part of the code that is causing the problem?



sure - here is a minimal example (the attached root file contains two branches: mynum - a scalar that is either 0 or 1 and an array myval with length equal to mynum and filled with a random float (0,1) if mynum=1).

root [1] tree->Draw("1", "mynum==0")
(Long64_t) 24862
root [2] tree->Draw("1", "mynum==1")
(Long64_t) 25138
root [3] tree->Draw("1", "mynum==1 && myval > 0.3")
(Long64_t) 17628
root [4] tree->Draw("1", "(mynum==1) && (myval <= 0.3)")
(Long64_t) 7510
root [5] tree->Draw("1", "!(mynum==1 && myval > 0.3)")
(Long64_t) 7510
root [6] tree->Draw("1", "(mynum==0) || ( (mynum==1) && (myval <= 0.3))")
(Long64_t) 7510

Statement [1] and [2] are fine and add up to a total of 50k entries. Now we bi-sect the events where we have one entry: [3] and [4] add up to the result of [2] - as expected. However the complement set of [3], written using the “!” negation in [5] and more explictely in [6] fails to include the additional 24862 entries where the array is empty from [1].

Thank you,

test.root (173 KB)