TTree Query on array

Hi,

I am using the Query function on TTree but unlike Scan or Draw Query does
not appear to return arrays unless one asks for the specific index. Example:

TTree t;
Float_t a[3];
t.Branch(“b”,a,“c[3]/F”);
t.Fill();
TTreeResult* res=t.Query(“c”);
Int_t count=res->GetFieldCount() ;
cout<<count<<endl;

count will be 1 instead of 3. Is this a bug or on purpose? Can one get
the whole array in a single query as with Scan or Draw?
The version of ROOT I’m using is 5.10/00.

Thank you,

Martin

Hi,

TTree::Query only looks at the first element of the array. To see the other elements you need to unroll them by handTTreeResult* res=t.Query("c[0]:c[1]:c[2]");

By the way, I was wondering why you would like to use this (slower) interface.

Cheers,
Philippe.

Hi Philippe,

Ok, I see.
The reason I use Query is that I want to extract numbers from a tree in a compiled executable but using query formulas and cuts defined as strings at run time.
Is there a more efficient way of doing this than using Query?

Thanks,

Martin

Use TTree::Draw

Rene