What is the return of TF1::GetX() when "Interval does not contain a root"

Dear Experts,

I want to get the root of a fit function in a specific interval. I want to ignore this event if the interval does not contain a root.
But I can’t know whether there is a root in the interval.

I tried the following code:

Double_t r = fun->GetX(0,1,9);
cout << r << endl;

The output is:

Info in <ROOT::Math::BrentMethods::MinimStep>: Grid search failed to find a root in the  interval
Info in <ROOT::Math::BrentMethods::MinimStep>: xmin = 1 xmax = 9 npts = 100
Error in <ROOT::Math::BrentRootFinder>: Interval does not contain a root
Error in <TF1::GetX>: [1.000000,9.000000] is not a valid interval
nan

It seems that TF1::GetX() returns a “nan”, but I can’t judge it by

if (r == nan)

Output:
ROOT_prompt_3:1:2: error: invalid operands to binary expression ('Double_t' (aka 'double') and 'double (const char *) throw()')
r==nan

I have also tried “try-catch method”, but TF1::GetX() doesn’t throw any exception.

Oh, I have figured it out.
TMath::IsNaN() works!

1 Like