#include
#include
#include
Double_t myfunction(Double_t *x, Double_t *par)
{
Float_t xx =x[0];
Double_t f = TMath::Sqrt(par[0]*xx) + par[1];
return f;
}
void myfun()
{
TF1 *f1 = new TF1("myfun",myfunction,0,150,2);
f1->SetParameters(2,1);
f1->SetParNames("coefficiente","costante");
f1->Draw();
}
void myfit()
{
TF1 *f1=gROOT->GetFunction("myfun");
f1->SetParameters(800,1);
c1 = new TCanvas("c1","Massa in Funzione del TOF",200,10,700,500);
c1->SetFillColor(42);
c1->SetGrid();
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderSize(12);
Int_t n = 13;
Double_t x[n] = {19.981,28.0135,31.9988,39.962,64.45,83.911,85.911,128.905,129.903,130.905,131.904,133.905,135.907};
Double_t ex[n] = {0.002,0.0004,0.0006,0.001,0.01,0.004,0.004,0.006,0.006,0.006,0.006,0.006,0.006};
Double_t ey[n] = {0.0016,0.0019,0.0017,0.0016,0.0015,0.0015,0.0014,0.0013,0.0013,0.0013,0.0014,0.0013,0.0013};
Double_t y[n] = {4.8678,5.7261,6.1083,6.8036,8.5918,9.7763,9.8904,12.0714,12.1189,12.1635,12.2089,12.3007,12.3909};
gr = new TGraphErrors(n,x,y,ex,ey);
//gr2 = new TGraphErrors(n,x,y2,ex,ey2);
gr->SetTitle("Massa in Funzione del TOF");
gr->SetMarkerColor(2);
gr->SetMarkerStyle(21);
//gr2->SetMarkerColor(4);
//gr2->SetMarkerStyle(23);
gr->Draw("AP");
gr->Fit("myfun");
//gr2->Draw("P");
c1->SaveAs("ptresVSpt.ps");
return c1;
}