Symbol not defined in TTree::Draw selection

hello all,

i am having problems with undefined symbols in the selection string of a TTree::Draw command. i have a TTree which contains entries of class (myClass) which has a variable array member and length(myClass->i[arrayLength], myClass->arrayLength).

the following commands draw correctly:

but the following returns an error:

Error: Symbol i is not defined in current scope FILE:(tmpfile) LINE:1

as well as this:

Error: Symbol i[0] is not defined in current scope FILE:(tmpfile) LINE:1

or even:
myTree->Draw(“i”,“i[0]>0 && multiplet->myfunc(i[0])>0”,"");

Error: Symbol i[0] is not defined in current scope FILE:(tmpfile) LINE:1

why is root incapable of recognizing the variable within the class function call? it works for math calls such as abs() or sqrt().

any advice would be greatly appreciated.

dan dwyer


Currently TTree::Draw can call member functions only when fixed arguments. This is because we have not (yet?) understood the semantic of doing such (in term of the impiied loops). I.e. for myTree->Draw("i","multiplet->myfunc(i)>0",""); Do we mean for (k=0;k<n;k++) multiplet[k]->myfunc(i[k])>0orfor (k=0;k<n;k++) for (j=0;j<n;j++) multiplet[k]->myfunc(i[j])>0


hi philippe,

is it possible to use a non-member function to do the same? I tried wrapping the member function in a simple macro, but the function is not recognized:

*ERROR 30 : Bad numerical expression : "myFuncTestMacro(...)" (Int_t)(-1)

I cannot make a simple tree entry based cut, since i need to select only certain elements within the myClass->i[] array.

The only other way I can think to do this is to manually modify and write each entry into a new tree, but this is very cumbersome in this situation.



The call to external function is currently limited (for similar reasons) to taking and return numerical arguments :frowning:.

So your best bet is to actually use TTree::MakeSelector which will generate a C++ file that you can modify to do any calculation you