Re: [ROOT] Problem with TF1

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Aug 13 2002 - 08:29:43 MEST


Hi,

TTree::Fit returns the number of Tree entries used by the fit.
To access the result of teh fit, you have two possibilities

option 1: you are interested by the result histogram and the fit function
=========================================================================
tree->Fit("gaus","leaf");
TH1F *htemp = (TH1F*)gDirectory->Get("htemp");
TF1 *f1 = (TF1*)htemp->GetFunction("gaus");
f1->GetParameter(0);

option 2: you are interested only by the fit function
=====================================================
tree->Fit("gaus","leaf");
TF1 *f1 = (TF1*)gROOT->GetFunction("gaus");
f1->GetParameter(0);

Rene Brun


On Tue, 13 Aug 2002, Takefumi SORA wrote:

> Hi,Rooters
> 
> I want to fit "Leaf" and get its parameter.
> This is my program.
> 
>   TFile *f = new TFile("381run.root");
>   TTree *tree = (TTree*)f.Get("tree");
>   tree->Fit("gaus","leaf");
>   TF1 *fit0 = tree->Fit("gaus","leaf");
>   Double_t pedestal0 = fit0->GetParameter(1);
>   cout << pedestal0 << endl;
> 
> Executing it, returned the error message.
> Error: Incorrect assignment to fit0, wrong type 'Int_t'
> 
> How can I avoid the trouble ?
> 
> -- 
> Takefumi SORA <tak-sora@bg7.so-net.ne.jp>
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:04 MET