#include #include #include Double_t coseno(Double_t *x, Double_t *par) { Float_t xx =x[0]; Double_t f = par[0]*TMath::Power(TMath::Cos(xx),par[1]); return f; } void angolo() { TF1 *f1 = new TF1("angolo",coseno,0,2,2); f1->SetParameters(2,2); f1->SetParNames("ampiezza","esponente"); f1->Draw(); } void myfit() { TF1 *f1=gROOT->GetFunction("angolo"); f1->SetParameters(73,2); c1 = new TCanvas("c1","Distribuzione angolare raggi cosmici",200,10,700,500); static const Int_t n = 7; Double_t x[n] = {0,0.2268,0.5235,0.8028,1.0821,1.3089,1.5707}; Double_t ex[n] = {0,0,0,0,0,0,0}; Double_t ey[n] = {9,8,8,6,4,3,2}; Double_t y[n] = {85,63,63,37,14,12,4}; gr = new TGraphErrors(n,x,y,ex,ey); gr->SetTitle("Distribuzione angolare raggi cosmici"); gr->SetMarkerColor(2); gr->SetMarkerStyle(21); gr->SetDirectory(0); gr->Draw("AP"); gr->Fit("angolo"); Double_t Chisquare = f1->GetChisquare(); Double_t NDF = f1->GetNDF(); cout<<"Chi quadro ridotto"<<" = "<SaveAs("ptresVSpt.ps"); return c1; }