TTreeFormula::Compile Error

Hello All!

I am making some cuts based on variables stored in a NTuple.

I pass the TNtuple to a function which takes it as TNtuple * in.

In the function:

_input = (TNtuple *) in->CloneTree();
formula = tmp.c_str();

where tmp is passed in from a script

TSQLResult * q = _input->Query(formula, _1dselection);

in _1dselection are several requirements of the branches of the NTuple, no problem there. IN formula I have

max(fabs(lep1eta),fabs(lep2eta))

and I get the error

Error in TTreeFormula::Compile: Bad numerical expression : “fabs(lep1eta)”

what is wrong. I have TMath.h header!

There is a lot of passing and pointing going on here so I have no idea if that is the problem and I have not been too explicit about that, but I thought the solution might be obvious to some; my questions usually have simple solutions.

Thanks,
gabe

Hi,

The string being passed to Query is analyzed using TTreeFormula which derives from TFormula and is not a complete C++ compiler (and is not using information from the surronding C++ code (i.e. your TMath.h include does not help). See the TFormula documentation for the list of built-in operation (see root.cern.ch/root/html/TFormula. … la:Analyze in particular). In addition you can access free standing and static C++ function by using their fully qualified name (for this to work you need to make sure you have a dictionary for it).

You can try the cut:max(abs(lep1eta),abs(lep2eta))

Cheers,
Philippe