New Fit Panel

Hi,
I have compiled version 5.15_06.

My fit function is listed on the Fit Panel, after fitting some data. But, I do not get any parameter values when I press “set parameters” on the New Fit Panel for my fit functions.
Please help?

dube

Hi Dube,

Can you mail me a script that will help for reproducing that case?

Thank you, Ilka

Hi Ilka,
Here is a script I made up. It is a simple straight line y=m*x + c and the data to be fitted is “lindata.dat” also on this mail at the bottom

#include <TApplication.h>
#include <TGraph.h>
#include <TLegend.h>
#include <Riostream.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TAxis.h>
#include <TF1.h>

using namespace std;

class Linear {
public:
Linear (Double_t m, Double_t c);
~Linear();
Double_t Evaluate(Double_t x) const;

   private:
   Double_t fA;
   Double_t fB;

};

Linear::Linear(Double_t m, Double_t c) {
fA = m;
fB = c;
}

Linear::~Linear() {
cout <<"deleting object with coeffts: "<< fA << “,” << fB << endl;
}

Double_t Linear::Evaluate(Double_t x) const {
return fA*x + fB;
}

Double_t fitFunc(Double_t *x, Double_t *par){
Linear *t=new Linear(par[0],par[1]);
return t->Evaluate(x[0]);
}

int main(int argc, char **argv){
TApplication theApp(“App”, &argc, argv);

TCanvas *c1 =new TCanvas(“c1”,“Linearratic function fit”,850, 750);
c1->SetFillColor(40);
c1->SetGrid();

 TGraph *gr1=new TGraph("lindata.dat");
 gr1->SetMarkerColor(kRed);
 gr1->SetMarkerStyle(24);
 gr1->GetXaxis()->SetTitle("x");
 gr1->GetYaxis()->SetTitle("y");
 gr1->GetXaxis()->CenterTitle();
 gr1->GetYaxis()->CenterTitle();
 gr1->Draw("AP");

TF1 *fit=new TF1(“fit”,fitFunc,-20,20,2);

Double_t sv[2],pllo[2],plhi[2];

sv[0]=1.3;sv[1]=3.3;//set values of the parameters
pllo[0]=0.5;pllo[1]=2;//lower limits of parameters
plhi[0]=1.5;plhi[1]=3.5;//higher limits of parameters

fit->SetRange(-20,20);
fit->SetParameters(sv);
for (Int_t j=0; j<1; j++) {
fit->SetParLimits(j, pllo[j], plhi[j]);
}

fit->SetParNames(“m”,“c”);
printf(“Fitting…\n”);
gr1->Fit(fit,“R”);
//fit->SetNpx(200);

gStyle->SetOptStat(1111);
gStyle->SetOptFit();
gStyle->SetLabelSize(0.03,“x”);
gStyle->SetLabelSize(0.03,“y”);
fit->SetLineWidth(2);
fit->SetLineColor(kBlue);
fit->Draw(“Lsame”);
//c1->Modified();
c1->Update();

theApp.Run();
c1->Connect(“Closed()”, “TApplication”, &theApp, “Terminate()”);
c1->WaitPrimitive();

return 0;
}

lindata.dat

0.000000 4.200590
0.100000 4.650219
0.200000 5.227779
0.300000 4.620303
0.400000 4.651821
0.500000 4.720150
0.600000 5.608736
0.700000 4.982805
0.800000 5.920594
0.900000 5.679198
1.000000 5.637391
1.100000 6.262547
1.200000 5.698689
1.300000 6.591844
1.400000 6.410959
1.500000 5.557841
1.600000 6.705182
1.700000 6.207403
1.800000 5.837462
1.900000 5.970522
2.000000 7.110844
2.100000 6.776068
2.200000 7.116675
2.300000 6.735188
2.400000 7.606098
2.500000 6.812428
2.600000 6.794317
2.700000 6.731828
2.800000 6.959407
2.900000 8.115814
3.000000 8.011347
3.100000 7.366234
3.200000 7.962963
3.300000 8.406861
3.400000 7.720267
3.500000 7.952556
3.600000 8.212557
3.700000 8.789655
3.800000 8.690285
3.900000 8.182382
4.000000 8.018508
4.100000 8.698837
4.200000 8.973216
4.300000 9.514715
4.400000 8.594515
4.500000 9.741047
4.600000 9.252012
4.700000 9.271225
4.800000 9.421316
4.900000 10.190080
5.000000 10.243771
5.100000 9.171150
5.200000 10.432029
5.300000 10.245123
5.400000 10.679122
5.500000 9.990217
5.600000 9.716047
5.700000 9.811455
5.800000 10.529850
5.900000 10.177965
6.000000 10.188360
6.100000 11.112989
6.200000 10.506635
6.300000 11.317843
6.400000 11.621181
6.500000 11.796011
6.600000 11.198791
6.700000 11.864447
6.800000 11.884761
6.900000 11.233522
7.000000 11.977862
7.100000 11.542295
7.200000 11.994245
7.300000 11.789527
7.400000 11.736967
7.500000 11.740485
7.600000 12.409469
7.700000 11.752668
7.800000 12.887760
7.900000 12.187639
8.000000 12.084553
8.100000 13.298563
8.200000 12.486886
8.300000 12.641491
8.400000 13.314182
8.500000 13.590237
8.600000 13.113796
8.700000 13.377492
8.800000 13.973436
8.900000 14.076005
9.000000 13.971811
9.100000 14.110827
9.200000 13.598049
9.300000 13.494201
9.400000 13.534301
9.500000 14.236190
9.600000 13.601980
9.700000 14.444109
9.800000 14.107859
9.900000 14.019721
10.000000 14.679152
10.100000 14.232489
10.200000 15.434334
10.300000 14.427460
10.400000 15.086258
10.500000 15.055054
10.600000 15.003617
10.700000 15.224694
10.800000 15.453488
10.900000 15.122288
11.000000 15.199038
11.100000 15.530594
11.200000 15.620065
11.300000 15.788981
11.400000 15.947251
11.500000 16.462478
11.600000 15.641458
11.700000 16.696835
11.800000 16.394501
11.900000 17.054120
12.000000 16.865153
12.100000 17.089548
12.200000 17.281113
12.300000 17.382438
12.400000 17.021850
12.500000 17.409718
12.600000 17.636117
12.700000 17.486973
12.800000 17.328966
12.900000 17.236971
13.000000 18.263851
13.100000 18.216498
13.200000 17.353321
13.300000 17.976669
13.400000 17.844442
13.500000 17.787169
13.600000 18.229872
13.700000 18.558575
13.800000 18.020019
13.900000 17.986558
14.000000 19.083383
14.100000 19.054864
14.200000 19.388554
14.300000 19.507974
14.400000 19.449897
14.500000 19.176835
14.600000 19.577186
14.700000 19.049419
14.800000 19.044888
14.900000 20.059718
15.000000 20.016916
15.100000 20.161578
15.200000 19.874965
15.300000 20.194931
15.400000 20.090546
15.500000 19.779202
15.600000 20.740011
15.700000 20.419184
15.800000 20.875730
15.900000 20.120265
16.000000 20.822625
16.100000 21.019788
16.200000 21.055026
16.300000 21.387273
16.400000 21.111737
16.500000 20.665548
16.600000 20.714802
16.700000 21.555089
16.800000 20.857290
16.900000 21.022625
17.000000 22.104897
17.100000 21.579665
17.200000 21.202841
17.300000 22.064725
17.400000 22.280895
17.500000 22.012041
17.600000 22.792971
17.700000 22.337005
17.800000 21.800884
17.900000 22.351996
18.000000 23.002376
18.100000 22.183060
18.200000 22.298594
18.300000 23.425721
18.400000 22.983509
18.500000 23.394376
18.600000 22.804770
18.700000 23.321893
18.800000 22.879656
18.900000 23.291618
19.000000 24.038663
19.100000 24.070516
19.200000 23.200313
19.300000 23.997124
19.400000 24.541514
19.500000 23.998917
19.600000 23.705742
19.700000 23.707989
19.800000 24.373905
19.900000 24.649263

Hi Dube,

I can reproduce the reported case and will see what happens.

Thank you, Ilka

Hi Dube,

Just to let you know: I did not forget this post. I was busy last two weeks but now I am back to the case reported by you.

Cheers, Ilka

Just for record - that was fixed last week and the fix is available in the ROOT development version v5.15/08.

Cheers, Ilka