Passing an array as an argument to a custom function

Hello ROOTers,

Surely this is a FAQ, but I haven’t been able to find the answer anywhere. I have a TTree which contains, among other things, the following TBranches:

*Br 21 :Ntrack : Ntrack/I *and

I would like to pass Avv and Ntrack as arguments to a custom function in a call to TTree::Draw. Assume the prototype

Int_t myfunc(Int_t, Int_t*)I would like to run

t->Draw("myfunc(Ntrack,Avv)");However, this code produces

Is there any way I can pass a variable-size array as an argument to a custom function?


I have found this discussion:
which seems to indicate that what I would like to do is not possible (or at least it wasn’t on the 20th January 2011).


Yes, it is not possible in this form of TTree::Draw. Instead you would need to use the script form by creating a file// myfunction.C double myfunction() { return myfunc(Ntrack,Avv); }
and usemytree->Draw("myfunction.C+");