Re: [ROOT] Problem with TF1

From: Pietro Govoni (Pietro.Govoni@cern.ch)
Date: Tue Aug 13 2002 - 09:24:41 MEST


Dear Takefumi SORA,
I'm a ROOT user too, so I hope I will be able to give you some hints; as
far as I understood you would like to get the parameters of the fit of the
variable "leaf".
Looking at the prototype of the TTree::Fit method:

Int_t Fit(const char *funcname ,const char *varexp, const char
*selection,Option_t *option ,Option_t *goption,Int_t nentries, Int_t
firstentry)

it seems to me that its output is not a pointer to a TF1 object; this
means that it is not possible to use the line:

TF1 *fit0 = tree->Fit("gaus","leaf");

What I would do to reach your aim is first to try:

Double_t pedestal0 = gaus->GetParameter(1);

after the fit.
In case it didn't work, I'd try first to get the histogram to fit:

TH1F *hnew = new TH1F("hnew","hnew",#,#,#);
tree->Draw("leaf >> hnew");

and then fit it:

hnew->Fit("gaus");

After that, again:

Double_t pedestal0 = gaus->GetParameter(1);


Best regards


pietro


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