Zero chisquare

Hi. So I make a tree the normal way:

void triggers() { struct triggers_t { Int_t runnumber; Int_t ppmb; Int_t bht2; Int_t bjp2; }; triggers_t triggers; FILE *fp = fopen("triggers.dat","r"); char line[80]; TFile *f = new TFile("triggers.root","RECREATE"); TTree *tree = new TTree("tree","triggers data from ascii file"); tree->Branch("triggers",&triggers.runnumber,"runnumber/I:ppmb:bht2:bjp2"); while (fgets(&line,80,fp)) { sscanf(&line[0],"%d %d %d %d",&triggers.runnumber,&triggers.ppmb,&triggers.bht2,&triggers.bjp2); tree->Fill(); } tree->Print(); tree->Write(); fclose(fp); delete tree; delete f; }
Then, I do this:

TFile f("triggers.root") TH1F * h1 = new TH1F("h1","",100,6105000,6155000); tree->Draw("runnumber>>h1","bht2","E")
And I fit it to a 0th degree polynomial (or any other polynomial for that matter). Then I ask for chisquare, and it gives 0. In addition, the fit doesn’t even look right – most of the points are above the line: http://www.its.caltech.edu/~kuznetso/SURF/bht2_flat.gif
Any thoughts?
Thanks.

Could you send a ROOT file containing your histogram "h1"
and the command you use for the fit?

I cannot reproduce your problem with the Chisquare.
It could be that you have a bad fit because you have bad errors.
I see that in TTree::Draw you use teh option “e”. However the errors
are not shown in your picture.
Could you check this by calling
h1->Fit(“pol0”,“w”);
that will force equal weights for all your bins.

Which version are you using?

Rene

This is the file I used. I tried forcing equal weights as well, but it didn’t change the chisquare.
triggers.root (14.8 KB)

You did not indicate which version.

If you do:

TFile f("triggers.root"); TH1F * h1 = new TH1F("h1","",100,6105000,6155000); h1->Sumw2(); tree->Draw("runnumber>>h1","bht2","E"); h1->Fit("pol0");
You should obtain this result:

Root [18] h1.Fit("pol0","f") FCN=355.179 FROM MIGRAD STATUS=CONVERGED 12 CALLS 13 TOTAL EDM=1.20262e-17 STRATEGY= 1 ERROR MATRIX ACCURATE EXT PARAMETER STEP FIRST NO. NAME VALUE ERROR SIZE DERIVATIVE 1 p0 3.39982e+04 1.84467e+03 1.61958e+01 -2.65864e-12