External function in tree "Draw"

Hi all,

I’m trying to do something like (in MyMacro.C):

double f (double x)
{
return x*x; // example
}

void MyMacro ()
{
[…]
MyTree -> Draw (“x:y”, “y > f->Eval (x)”);
}

Where f(x) is an external function. I tried to this in different ways but I get always
an error saying: “bad numerical expression”. It seems that Draw() doesn’t like external
functions. On the contrary, if I put e.g.

MyTree -> Draw (“x:y”, “y > TMath::Sin(x)”);

it works! Why?

Thanks,
best,

NNNNN

MyTree -> Draw (“x:y”, “y > f(x)”);

Hello,

I also have a same problem.

My code is as follows:

T1->Draw("S0:Time", TMath::Nint(S0), "same");     //Here S0 values should be get round-off and then plot rouned S0 values vs Time
TGraph *gr5 = new TGraph(T1->GetSelectedRows(),T1->GetV2(), T1->GetV1()); 
 gr5->SetLineColor(kBlack);

But it’s not working. How to do this? Please guide.

Thank you.

T1->Draw(“TMath::Nint(S0):Time”); // 2D scatter-plot
TGraph gr5 = ((TGraph)((gPad->GetPrimitive(“Graph”))->Clone())); // clone the result of Draw
gr5->SetLineColor(kBlack);