T(Tree)Formula and variables

Hi,

I use a small dictionnary containing the contents of a namespace Utils::, in expressions like
mytree->Draw(“some_var”,“Utils::some_function()>cut”)

The sad thing is, if I have a variable
TLorentzVector Utils::jet;
I cannot use
mytree->Draw(“some_var”,“Utils::jet.Pt()>cut”);
I get:
Error in TTreeFormula::Compile: Bad numerical expression : “Utils::jet.Pt()”
(The variable Utils::jet is correctly exported in the dictionnary ; I can use Utils::jet.Pt() from CINT for instance).

So I have to write a wrapper
Utils::getPt() { return Utils::jet.Pt(); }
and then
mytree->Draw(“some_var”,“Utils::getPt()>cut”);
works like a charm.

Why is this ?

That’s all the more disturbing that if I have a variable
TLorentzVector tlv; in my TTree, it can compile expressions like
mytree->Draw(“tlv.Eta()”,“tlv.Pt()>cut”);

Can I do something to be able to use directly the variable, without needing a wrapper ?

Nicolas

[quote]Why is this ? [/quote]Access to global variable (even when they have a dictionary) has not been added to TTreeFormula. To use such syntax you may want to explore passing a script to TTreeFormula (see the documentation for TTree::Draw and TTree::MakeProxy) for some details).

Cheers,
Philippe.

Thanks for the answer Philippe.

Passing a script does not seem a good solution for my use-case, so I guess I will continue writing a collection of wrappers until the support of global variables is added (is that planned ?)

Cheers,
Nicolas

Hi Nicolas,

We are not planning any upgrade to TTreeFormula until we have a solid replacement for CINT (and are able to leverage this replacement for a reimplementation of TTreeFormula).

Cheers,
Philippe.