Passing non-POD branches to custom functions in TTree::Draw

I am trying to pass STL-based branches to a custom user function in TTree::Draw, and am not sure of the correct method signature for doing this. The setup is basically the following:

TTree “Events”
-> Branch float search_value
-> Branch vector values_to_search

I have a function in MyFile.C

float match_value(float search_value, vector values_to_search)
/* Loop over values_to_search, find search_value, do a calculation based on the result index */

I would like to do the following

Events->Draw(‘match_value(search_value, values_to_search)’, …)

The LoadMacro step compiles fine.

However, I am not sure of the correct method signature for the vector type. Should it be a vector? vector*? The former crashes, the latter gives a “Bad numerical expression” message in TTreeFormula::Compile.

Can anyone tell me the correct way to pass that branch?


The usual TTree::Draw syntax only supports calling function takes numerical arguments.
To call more complex function you can use the TTree::Draw syntax takes a script as input (and use TTree::MakeProxy under the cover) or you need to use TTree::MakeProxy or TTree::MakeSelector directly.