Hello together,

I already searched and found a solution for a linear fit in log scale in this forum and build a makro, which I thought it would work.

[code]{

c1 = new TCanvas(“c1”,“Title”,200,10,700,500);

c1->GetFrame()->SetBorderSize(12);

TF1 * f1 = new TF1(“f1”,"[0]*x^[1]", 1200, 1340);

f1->SetParameter(0,2);

f1->SetParameter(1,0.5);

Int_t n = 8;

Double_t x[n] = {1200, 1220, 1240, 1260, 1280, 1300, 1320, 1340};

Double_t y[n] = {102.33, 114.26, 128.76, 144.56, 164.64, 188.05, 209.57, 229.65};

Double_t ex[n] = {1,1,1,1,1,1,1,1};

Double_t ey[n] = {0.5, 0.5, 0.75, 0.61, 0.73, 0.71, 0.42, 0.55};

gr = new TGraphErrors(n,x,y,ex,ey);

gr->SetTitle(“Title”);

gr->SetMarkerColor(4);

gr->SetMarkerStyle(1);

gr->Draw(“AP”);

gr->Fit(“f1”);

f1->Draw(“SAME”);

gStyle->SetOptFit(1111);

return c1;

}[/code]

The problem is, that the TMath::Power function gives non-sense values. I tried to set one one each parameters to a fixed value, but the power function will not work. Is there something wrong with my code? Am I missing something?

I hope you can help me