Calling TTree::Draw() with user functions

Hello,

In my TTree I have two branches (formed from a two different classes, derived from TObject). In each branch I have a TLorentzVector objects: ‘lv1’ -in the first branch and ‘lv2’ in the second. Now I want to call TTree::Draw() with a function which accepts
the two vectors, something like this:
tree->Draw(“f(lv1,lv2)”)
Where the function ‘f’ is defined in one of my classes (I failed to use the TFormula-derived ‘f’ object).

The error message is:
Error: Failed to evaluate lv1
*** Interpreter error recovered ***
Error: class,struct,union or type (unknown) not defined (tmpfile):1:

What do I miss? After reading the documentation about TTree:Draw() function I thought that this is possible.

Please, give me an advice!

Alexander.

Hi,

Currently TTree::Draw can only call functions for which it has a dictionary and that are either free standing function or class static functions AND whose argument are all numerical (i.e. it can not pass any object).

Cheers,
Philippe.

PS. Alternatively you can write a small script and header file

// mycut.h #include "myheader.h"

// mycut.C double mycut() { return f(lv1,lv2); }
and use tree->Draw("mycut.C+");