Adding variables (not inside tree) to cut selection when drawing


I often have to add various variables to the selection cut when drawing a tree. So let’s assume I have a tree with x and y variables. I can easily draw using selection cuts:

tree->Draw(“x”,“2.*y > 1.”)

but what happens if I have to add an external variable:

Float_t z = 10.;

tree->Draw(“x”,“z*y > 1”)

as doing this returns the “unknown z” error message.

I would be very grateful if you could please suggest a way of doing this.

Thank you,


Of course a local C++ variable is not known by the TTree::Draw method. A trick could be:

Float_t z = 10.;
tree->Draw("x",Form("%f*y > 1",z))

Thank you, this worked.