Home | News | Documentation | Download

Fitting vector of TGraphs result in "Warning in <Fit>: Fit data is empty"

Dear Root experts

I am trying to automatize a couple of fits, therefore I have put both the TGraphErrors* and TF1* in 2-dimensional vectors:

std::vector< std::vector< TGraphErrors* > > tgraphs;
std::vector< std::vector< TF1* > > fit_tf1s;

However when inside a loop I execute:


I unfortunately get the error message: “Warning in : Fit data is empty”. However when I iterate over the elements of my tgraphs[i][j] i see it is not empty ( i can print all elements to screen) and also when I draw my tgraphs[i][j] I am able to see my points (and not the fitted curves, since the fit failed earlier …). Does somebody have an idea what is going on and why ROOT is not able to extract the values of tgraphs[i][j] to give it to the fitter?

I have attached my root macro and an input txt file. Executing
root -l TownsendCoefficient_doublefit_PScan_Automatic.C+ should show you the error message. The line I think is not working is line 181.

Thanks a lot
Kind regards
Piet Verwilligen
ArCO2_70_30_94000Pa_Townsend.txt (385 Bytes)
TownsendCoefficient_doublefit_PScan_Automatic.C (16.5 KB)

Try with “RW”.

Thanks a lot for your quick reply Pepe

I read first your suggestions here:

and I tried with “W” and “WW” as well before mailing, but without success. Below is a summary for each option I tried:

[li]“R” --> “Warning in : Fit data is empty”[/li]
[li]“RW” --> “Warning in : Fit data is empty”[/li]
[li]“RWW” --> “Warning in : Fit data is empty”[/li]
[li]“RL” --> “Info in : L (Log Likelihood fit) is an invalid option when fitting a graph. It is ignored Warning in : Fit data is empty”[/li]
[li]“W” --> fitting is executed, but chi^2 is 10^11, p0 nearly 0 and p1 remained the initial value i gave it to start with, both with huge uncertainties. So i am not getting a meaningful fit here.[/li]
[li]“WW” --> same result as with “W” option[/li][/ul]

Any idea what is going on?
Thanks a lot

Well, “R” uses the range defined by your fit function.
So, it seems that your “tgraphs[i][j]” graph has no data points between “fit_tf1s[i][j]->GetXmin()” and “fit_tf1s[i][j]->GetXmax()”.
Right before “Fit”, try to add something like: std::cout << fit_tf1s[i][j]->GetXmin() << " " << fit_tf1s[i][j]->GetXmax() << std::endl; tgraphs[i][j]->Print(); // see all x[...]=...
BTW. Note that “WW” and “L” are not valid for graphs.

Hi Pepe

Indeed, the range was set wrongly … Previously i was working with units of [V/m] now I read in data from a txt file that was in units of [V/cm], my range was a factor 100 to large. Thanks. my mistake. :frowning:

The result I got entering your lines:

Fit tgraphs[0][0] with TF1 named korff_garfield_tot_94000
TF1* Fit Xmin = 1.5e+06 TF1* Fit Xmax = 1.65e+07
x[0]=20000, y[0]=3731.1, ex[0]=0, ey[0]=16.7899
x[1]=25000, y[1]=8852.26, ex[1]=0, ey[1]=26.5568

x[19]=160000, y[19]=311533, ex[19]=0, ey[19]=118.383
helped a lot to trace back the problem.Thanks!