I have a set of data pressx that is an array of doubles representing different pressures, and ratey, which is a 3-d array of rates which all correspond with those pressures.
This code works fine, it gives the expected output.
for(int i = 0; i < 80; i++)
for(int j = 0; j < 4; j++)
{
TGraph *gr = new TGraph(count, pressx, ratey[i][j]);
gr->Fit("pol1", "N");
TF1 *fit = gr->GetFunction("pol1"); // doesn't do anything yet
}
Which is something like
Fitting results:
Parameters:
NO. VALUE ERROR
0 1.394513 5.089739
1 -0.001425 0.007489
For each one of the 320 arrays.
This doesn’t work:
for(int i = 0; i < 80; i++)
for(int j = 0; j < 4; j++)
{
TGraph *gr = new TGraph(count, pressx, ratey[i][j]);
gr->Fit("pol1", "N");
TF1 *fit = gr->GetFunction("pol1");
cout << fit->GetParameter(0) << endl;
cout << fit->GetParameter(1) << endl;
}
I get output like [code]Fitting results:
Parameters:
NO. VALUE ERROR
0 1972353841828572710836978851435764041775644420634645785532212557621689350216983729690258820091815214520707018459778846229014730463689795283159686675440788434341446857549396297720976863864596521606573053437174786929002242367013541837766078679220224.000000 5.089739
1 20379705714213766341736252165763112630883593503138327473248784208480583523907746432706736109011669045963268457781549463239180946361389043090791873471552147397816692953832362689851848513703833775709707432007304360176606345363332255706174004920320.000000 0.007489
*** Break *** segmentation violation
Generating stack trace…
Aborted
[/code]
And if I use “QN” for the fit’s options, I just get no output other than the segfault.
I assume that I’m not doing it right, but what’s wrong about my method?