TTree::Draw with several vectors


I just encountered a problem when using vectors in the TTree::Draw function …
I only found this post ( … raw+vector) to give half the answer I am looking for …

Here we go …

Imagine we have a tree with two vectors in each entry …

runnumbers = (90123, 90125, 90145)
locations = (12, 13, 14, 21, 23, 100)

What I am trying to do is plot all locations in case a given runnumber is matched in ‘runnumbers’

tree->Draw(“locations”,“runnumbers==90125”) = 1

what I get is one entry (13) … the index of the ‘locations’ entry always matches the index of the entry in ‘runnumbers’ that was found …

I get all ‘locations’ elements when checking one specific ‘runnumbers’ element

tree->Draw(“locations”,“runnumbers[0]==90125”) = 0
tree->Draw(“locations”,“runnumbers[1]==90125”) = 6

how can I check for matches in all of ‘runnumbers’ and still get all of ‘locations’?

Thanks very much in advance


Try tree->Draw("locations","Sum$(runnumbers==90125)>=1");


Seems to work … thanks!

Just one follow up question … if I want to make a wide selection of the runnumbers (many possible matches … I tried

tree->Draw(“locations”,“Sum$(runnumbers==90125 || runnumbers==90126 || runnumbers==90127 || …)>=1”);

which (besides the fact that it is kinda slow) complains about a segmentation violation in case you ask for too many runnumbers matched … any idea when this happens or a suggestion for a better way to do the selection …



It might be that you have too many operators and hence the stack (number of recursive function calls) is too deep. To solve this problem, compact you expression, for example:tree->Draw("locations","Sum$((runnumber >=90125 && runnumbers<=90127) || ...)>=1"); You can also use more call to Sum$ (but the more call to Sum$ the slower it will be).