Hi ROOTers, Does anyone have a working example of TTree::UnbinnedFit in ROOT 3.00-06. I have gotten TTree::UnbinnedFit to work in 2.25-03, but not yet in 3.00-06. I get a seg fault at the call to the UnbinnedFit method. Below are the 2 macros I use - one to generate a ntuple of random numbers, and one to try and fit it. If this works for others, perhaps there is something the matter with my setup? Chris // for ntuple generation void example() { gROOT->Reset(); TFile *hfile = gROOT->FindObject("hsimple.root"); if (hfile) hfile->Close(); hfile = new TFile("hsimple.root","RECREATE","Random Root File"); ntuple = new TNtuple("ntuple","Random ntuple","px:i"); gRandom->SetSeed(); Float_t px,py; for ( Int_t i=0; i<25000; i++) { gRandom->Rannor(px,py); ntuple->Fill(px,i); } hfile->Write(); } // for fitting void example2() { TFile *f = gROOT->FindObject("hsimple.root"); if (!f) f= new TFile("hsimple.root"); TTree *tree= (TTree*)f.Get("ntuple"); TF1* f1 = new TF1("f1", "gaus(0)/sqrt(2*3.14159)/[2]", 0, 5); f1->SetParameters(1.0, 0.2, 0.3); f1->SetParLimits(0, 1, 1); // for correct normalization tree->Draw("px"); tree->UnbinnedFit("f1", "px" ); }
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:43 MET