High value of Chi Square

Goodevening everybody,
I’ve some problems with chi-square. I wrote a macro that fit some experimental data with a sin function. The result is that the fitting function is perfect for the data, but in a way that i cannot undersantd Root returns me a very high value of Chi-Square. This is the macro:


#include "TCanvas.h"
#include "TStyle.h"
#include "TMath.h"

Double_t myfunction (Double_t *x, Double_t *par)
{
   Double_t Arg=x[0]+par[2];
   Double_t f = par[0]*TMath::Sin(par[1]*Arg);
   return f;

}

void myfunc(){
TF1 *woof= new TF1("woofer", myfunction,0,0.002,3);
woof->SetParameter(0,4.57);
woof->SetParameter(1, 6283.185);
woof->SetParameter(2,-0.0929);
woof->Draw();

TF1 *tweet= new TF1("tweeter", myfunction,0,0.002,3);
tweet->SetParameter(0,2.11);
tweet->SetParameter(1, 6283.185);
tweet->SetParameter(2,+1.0915);
tweet->Draw();

TF1 *sign= new TF1("signal", myfunction,0,0.002,3);
sign->SetParameter(0,4.59);
sign->SetParameter(1, 6283.185);
sign->SetParameter(2,-0.00001);
sign->Draw();
}

void fit(){
  TCanvas *c1 = new TCanvas("c1", "c1",346,57,700,500);
  TF1 *f1=(TF1*)gROOT->GetFunction("woofer");
  TF1 *f2=(TF1*)gROOT->GetFunction("tweeter");
  TF1 *f3=(TF1*)gROOT->GetFunction("signal");



  


TGraphErrors *woofer= new TGraphErrors("./Turno3bassaerrori.txt", "%lg%lg%lg");
TGraphErrors *tweeter= new TGraphErrors("./Turno3bassaerrori.txt", "%lg%*lg%*lg%lg%lg");
TGraphErrors *signal= new TGraphErrors("./Turno3bassaerrori.txt", "%lg%*lg%*lg%*lg%*lg%lg%lg");
woofer->GetXaxis()->SetLimits(0,0.002);
woofer->SetLineColor(12);
tweeter->SetLineColor(6);
signal->SetLineColor(1);
woofer->SetLineWidth(2);
tweeter->SetLineWidth(2);
signal->SetLineWidth(2);
woofer->Fit("woofer", "R", "QWEMR");
tweeter->Fit("tweeter", "R","QWEMR");
signal->Fit("signal", "R","QWEMR");
c1->cd();
woofer->SetTitle("Segnali a frequenza 1kHz");
woofer->Draw();
tweeter->Draw("SAME");
signal->Draw("SAME");
cout <<endl <<endl <<endl <<f1->GetChisquare()/f1->GetNDF() <<" " <<f2->GetChisquare()/f2->GetNDF() <<" " <<f3->GetChisquare()/f3->GetNDF() <<endl;

}

Here is the canvas with the function and the experimental data.

I’ll be very grateful if some of you will explain me the reason for this high Chi square value.
[EDIT] I tried to insert the same data in gnuplot and I’ve obtained Reduced Chi square in the order of the unit, so is this a ROOT problem in calculating it?

I assume you want:

woofer->Fit("woofer", "QWEMR");
tweeter->Fit("tweeter", "QWEMR");
signal->Fit("signal", "QWEMR");