Using Vectors in TTree::Draw

I am using TTrees that have vector<> and vector<vector<>> data members. I am having trouble using them in TTree::Draw().

For example, if I have “vector< vector > *ADC”, how would I use it in a TTree::Draw statement? It is especially confusing because it is a pointer.

I’ve tried the following:

tree->Draw(“ADC[0][2]”,“ADC[][] > 45”);
This seems to work

tree->Draw(“ADC[][2]”,“ADC[0][2] > 45”);
This yields a plot with many entries in the bin from 0 to 1, which doesn’t make sense since there shouldn’t be any none zero ADCs in the tree.

tree->Draw(“ADC[][]”,“ADC[0][2] > 45”);
This seems to work reasonably.

tree->Draw(“ADC[][]”,“ADC[][] > 45”);
This seems to work reasonably.

I’m just not sure what is the supported syntax. Is this discussed anywhere?

Thanks.

Hi,

Which version of ROOT are you using?
Can you provide an simple example reproducing this issue?

Cheers,
Philippe.

ROOT Version 5.18/00a (lxplus version)

I suppose my question was more of an informational question, not really a problem as of yet.

Can you just confirm the proper syntax for using vectors and vectors of vectors in the strings passed to the TTree::Draw() method? I can’t find any examples anywhere which specifies this.

Thanks.

[quote]I suppose my question was more of an informational question, not really a problem as of yet. [/quote]Humm … you did say:[quote]tree->Draw(“ADC[][2]”,“ADC[0][2] > 45”);
This yields a plot with many entries in the bin from 0 to 1, which doesn’t make sense since there shouldn’t be any none zero ADCs in the tree. [/quote]which may or may not be a problem depending on the data …

[quote]Can you just confirm the proper syntax for using vectors and vectors of vectors in the strings passed to the TTree::Draw() method? I can’t find any examples anywhere which specifies this. [/quote]You seem to have gotten the syntax right. The syntax is described in the documentation of TTree::Draw where the vector of vector is simply an instance of the case of a 2 dimensional array with 2 varying length dimensions.

Cheers,
Philippe.

After closer inspection, this seems to work in all of the previously discussed situations.

But it is good to hear that this is the correct syntax. Thank you.

Now I think I have encountered a problem.

Again, I am using a “vector<vector>* ADC” where the inner vector has 5 entries always.

TTree::Draw("(ADC[][0]",""); AND TTree::Draw("(ADC[][1]","");
These produce reasonable plots.

However, if I use any higher indices: ADC[][2], ADC[][3], ADC[][4] i get plots with all entries at x=0. Any idea why this might be.?

The most obvious thing is that these indices don’t exist, but if I do a MakeClass and then iterate over these indices I see the correct values.

Thanks.

Hi,

Can you try with a newer version of ROOT? (or alternatively can you send me you ROOT file?)?

Cheers,
Philippe.