Evaluating TF1 outside histogram borders

dear rooters,

i am trying to evaluate a (fitted) TF1 beyond the borders of my histogram (which it has been fitted to).

can somebody tell me how to do that? (option in eval() maybe? something else?)

thanks in advance,

Get the pointer to the TF1 object and call myfunc->Eval(x)



that’s what i’m doing, but outside the boundaries of my histogram myfunc->eval(x) returns “inf”, which is not possible cause the function convergerges to a finite number.

here’s the function:

[code]static Double_t FermiFunction (Double_t* x, Double_t* par)
Double_t funtionValue;


return funtionValue;


the parameters after the fit are:

p[0] = 1.2
p[1] = 9.4
p[2] = 1.6

in the attachment you can see the histogram with the function. at a value of x~62, which is quite close to the upper boundary of the histogram, eval(x) returns inf.

any ideas why that might be?

c1.ps (10.8 KB)

Could you post teh shortest possible RUNNING script reproducing the problem?
Alternatively could you print the values of x[0] and par[…] in your function?


hi rene,

sorry for being a bit imprecise in my description.

so what i did is:

  1. fitted a TH1F with a TF1
  2. wrote the TH1F to a root file

when i then access the TF1 from the TH1F, all values outside the histogram boundaries are 0 (not inf, my mistake).

i attached a root file and a script which accesses the TF1 in the TH1F from the file and prints out the outcome of eval(x) at two values, one inside the histograms boundaries, one outside (the histogram ranges from 0 to 60).

i guess when writing a TH1 to a file its TF1 data member is only defined inside the histograms boundaries, right?

of course i can just get the fit parameters and define a TF1 with those parameters and a different range. i just wonder if there’s another method for getting the TF1 from the histogram in the file and access its values outside the histogram’s range.

cheers, and thanks for your help,
test.root (6.14 KB)
test.C (221 Bytes)

You are reading a histogram having an associated function, but the code of the function is not available. In this case ROOT uses a table of tabulated function values within the histogram range for drawing purposes only. This table cannot be extrapolated outside the tabulated range.


hi rene,

yes, after some thinking i expected something like that. thanks for the clarification.