Using a function with multiple input to define a TF1

ROOT Version :6.16
Platform: Fedora 29
Compiler: BuiltIn Interpreter

I am trying to declare a TF1 using a function defined in my code. The function takes two inputs.

double my_func = (double t, double p)
return a+b;
TF1* f = new TF1("name", "my_func(t, 1.0)", min, max);

The result is:

Error in TF1::TF1: function: f/my_func(t,1.0) has dimension 4 instead of 1

Is there a way to declare a TF1 using a function of multiple variables?

The ultimate use of this is to fill a histogram, so if what I am trying to do is not possible, is there instead a way to use TF2s? I have tried

my_func(a,b){ return a+b; }
TF2* f = new TF2("name", "my_func(t,p)", tmin, tmax, pmin, pmax);
TH1D* h = new TH1D("name_h", "title_h", nbin, min, max);

but similarly had no success.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.