Is there any documentation for TTree::Query?

Is there any user documentation for TTree::Query? The reference manual does not provide any information on the function arguments (varexp, selection, option), nor is there any explanation of TSQLResult, or the TTreeResult subclass.

What I’m looking for specifically is how can I get the row numbers that were found into the output? TSQLResult::GetRowCount() tells me how many rows matched, but not which ones.

Please read tips for efficient and successful posting and posting code

ROOT Version: 6.12-06
Platform: MacOS
Compiler: LLVM

For the description of the function’s arguments see (for “row numbers” see “Special functions and variables” therein): TTree::Draw

So it’s just the same arguments, but a different kind of output. Interesting! It’d be really cool if the documentation actually said that (see TTree::Query).

Is there any documentation for the contents of the output (TSQLResult or the TTreeResult subclass)? The documentation for those classes have no information about the member functions, let alone about how to interpret (or cast?) the returned values.

For instance, the Next() iterator function returns a TSQLRow* object, but provides no guidance on what that thing might contain, and especially with respect to how its contents relates to the varexp argument to Query().

The “documentation” for TSQLRow* is equally useless. It appears to have an indexing function (TSQLRow::operator[]()) which is equally undocumented. It returns a const char*; does that mean all of the floating point values get destroyed into few-digit strings? Is there a way to get the actual branch objects back with full precision?

I would have hoped all of this stuff would have been somewhere in the user’s guide, but that documentation appears to be unsearchable from the top level, or from the reference manual :frowning:

Hi @Michael_Kelsey ,
thank you very much for the feedback. I think @pcanal might have an idea of where Query and the TSQL* things are documented. If not, please feel free to open an issue at Issues · root-project/root · GitHub to report the lack of documentation.


Thank you, @equiraud! I can do that. For my original inquiry, I think what I would do is something like

TSQLResult* results = mytree->Query("Entry$","my-selection","");
TSQLRow* match = 0;
while ((match = results->Next())) {
  Int_t row = atoi(match[0]);
  // Do something here
  delete match;


Actual implementation and some docu can be found in TTreePlayer::Query() method. Yes, may be it could be good idea add some reference in TTree::Query() documentaion.


Looking at the “varexp” of your “Query” (just "Entry$"), it seems to me that you should have a look at “Saving the result of Draw to a TEventList, a TEntryList or a TEntryListArray” and “Using a TEventList, TEntryList or TEntryListArray as Input” in: TTree::Draw

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.