Using TobjString in TTree


with TObjString it is possible to store strings in root trees. Is it also possible work with the string in TTree :: Draw commandos. I am trying something like this:

tree.Draw(“data”, “mystring.String()==”“The String”"");

This however returns an error:
*ERROR 30 :
Bad numerical expression : “TheString”
(long long)-1

Thank you for your help

Felix Rauscher

Hi Felix,
assuming mystring is a TObjString, the following should work:
tree.Draw(“data”, “mystring.fString.fData==“The String””);

Hi Axel,

thanks for the hint. Backslashjing the quotes eliminates the error message. However I still did not find a way to make it work properly.
I found two valid expressions. The one you gave me always returns false (no entries are drawn). Anotherone

tree.Draw(“data”, “mystring.String()==TString(“The Stgring”)”)

always returns true, so all entries of the tree are Drawn.



Now I think I found out the Answer. The Correct Syntax is

tree.Draw(“data”, “mystring.String().CompareTo(“The_String”)”);

I had to exchange the space with an ‘_’ in the tree, because the interpreter deletes all whitespaces. Does anyone know how to protect whitespaces from the interpreter?


Never use Tree/branch/leaf names with spaces. THis will be a source
of problems in many places.



Indeed the parser in TTreeFormula seems to remove the spaces embedded in the strings. This will be fixed shortly.