Hi
I am fitting a graph with several fits in subranges. All of them work except the last one “gss5”. I set the parameters in the script but it graphs it wrong while if i set the same parameters graphically it draws it right . Am i doing sth wrong ?
FILE *fa = fopen(“tt”,“w”);
int i;
for (i=0;i<1152;i++) fprintf(fa,"%i %f %d\n",i,angl[i],cnt[i]);
fclose(fa);
TGraph *gr = new TGraph ( 1152,angl, cnt );
gr->Draw(“AP”);
double par1[3],parb[3],parc[5];
TF1 *gss1= new TF1(“gss1”,“pol2”,-0.719,-0.194);
gss1->SetLineColor(1);
gr->Fit(“gss1”,“r”);
//-------
double x,p[3];
TF1 *gss2a= new TF1(“gss2a”,"[0]+[1]*exp(x/[2])",-0.19562,-0.113);
gss2a->SetParameters(2337,18345,0.06655);
gss2a->SetLineColor(5);
gr->Fit(“gss2a”,“ru”);
//---------
TF1 gss2= new TF1(“gss2”,"exp([0]+x[1])",-0.1122,-0.052);
gss2->SetParameters(9.85,11.0);
gss2->SetLineColor(2);
gr->Fit(“gss2”,“ru”);
//---------
TF1 *gss3= new TF1(“gss3”,"[0]+[1]*exp(-(x-[2])/[3])+[4]*exp(-(x-[5])/[6])",0.052,0.35);
gss3->SetParameters(1522,92902.5,-0.0063,0.01934,12787,-0.0063,0.1169);
gss3->SetLineColor(3);
gr->Fit(“gss3”,“r”);
//--------
TF1 *gss5 = new TF1(“gss5”,"[0]*exp(-x/[1])+[2]",0.35,0.714);
gss5->SetParameters(4873.1,0.32,502);
//gss5->SetParameters(502.1,5873.1,0.32);
gss5->SetLineColor(4);
gr->Fit(“gss5”,“r”);
gr->Draw(“AP”);
gss1->Draw(“same”);
gss2->Draw(“same”);
gss3->Draw(“same”);
gss2a->Draw(“same”);
gss5->Draw(“same”);
FILE fp = fopen(“samy”,“w”);
int i ;
double r1,r2,r3,r4,r5;
for (i=0;i<525;i++) { r1 = -0.719+i0.001 ; fprintf(fp," %i %f %f\n",i,r1,gss1->Eval(r1));}
for (i=525;i<(82+525);i++) { r2 = -0.194+(i-525)*0.001; fprintf(fp," %i %f %f\n",i,r2,gss2a->Eval(r2) );}
for (i=607;i<668;i++) { r3 = -0.112+(i-607)*0.001; fprintf(fp," %i %f %f\n",i,r3,gss2->Eval(r3) );}
for (i=668;i<976;i++) { r4 = 0.052+(i-668)*0.001; fprintf(fp," %i %f %f\n",i,r4,gss3->Eval(r4) );}
for (i=976;i<1334;i++) { r5 = 0.360+(i-976)*0.001; fprintf(fp," %i %f %f\n",i,r5,gss5->Eval(r5) );}
fclose(fp);