Problem with Fitting data on root

I wrote a macro that should fit all my data (with their errors) but it doesnt fit it ? What did i wrote wrong ? Can somebody help me ?

void myMacro(){
//raccolta dati
Float_t x[12] = {100,140,160,200,220,240,260,280,300,320,360,400} ;
Float_t y[12] = {0.04,0.08,0.11,0.25,0.35,0.53,0.70,1.01,1.38,2.07,3.36,5.60} ;
Float_t ex[12] = {10,10,10,10,10,10,10,10,10,10,10,10};
Float_t ey[12] = {0,0,0,0,0,0,0,0,0,0,0,0};

TCanvas *c1 = new TCanvas();

TGraphErrors * gr = new TGraphErrors(12,x,y,ex,ey);
gr->SetTitle("Diodo al Ge");
gr->SetMarkerStyle(21);
gr->Draw("AP");

c1->SetLogy(); //scala logaritmica
c1->SetGrid();
gr->GetXaxis()->SetTitle("Voltage (mV)");
gr->GetYaxis()->SetTitle("Current (mA)");

//fit
TF1 *f1 = new TF1 ("f1", "[0]*(exp(x/[1])-1)", 100,300);

f1->SetParameter(0,1e-6);
f1->SetParameter(1,50);
f1->SetParName(0,"I0");
f1->SetParName(1,"eta*VT");

gr->Fit("f1","R");
gStyle->SetOptFit(1111);

}
gr->Fit(f1, "W EX0 R N Q"); // initial pre-fit
gr->Fit(f1, "R"); // final fit

ROOT Forum → Search → “initial pre-fit”

BTW. Note that ‘’’ != ```

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.