Re: "Unknown function" error message ...

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Jan 18 1999 - 09:47:32 MET


David d'Enterria wrote:
> 
> Hi everybody,
> 
> I am fitting with different functions an histogram:
> 
> h_en_cm_photon.Draw("e1")
> c1.SetLogy()
> h_en_cm_photon.Fit("expo","R","EI",60,120)
> TF1 *Au_fit_direct = new TF1(*(h_en_cm_photon.GetFunction("expo")))
> Au_fit_direct.SetName("Au_fit_direct")
> Au_fit_direct.SetRange(0,200);
> Au_fit_direct.Draw("e1same")
> TH1F *Au_direct = new TH1F(*(Au_fit_direct.GetHistogram()))
> 
> TH1F *Au_direct_subs = new
> TH1F("Au_direct_subs","Au_direct_subs",h_en_cm_photon.GetNbinsX(),0,200)
> 
> Au_direct_subs.Sumw2();
> Au_direct_subs.Add(h_en_cm_photon,Au_direct,1,-1);
> Au_direct_subs.Draw("e1")
> Au_direct_subs.Fit("expo","R","EI",30,50)
> TF1 *Au_fit_therm = new TF1(*(Au_direct_subs.GetFunction("expo")))
> Au_fit_therm.SetRange(0,200);
> Au_fit_therm.SetName("Au_fit_therm")
> Au_fit_therm.Draw("e1same")
> TH1F *Au_therm = new TH1F(*(Au_fit_therm.GetHistogram()))
> Au_therm.Draw("e1same")
> 
> h_en_cm_photon.Draw("e1")
> Au_direct.Draw("e1same")
> Au_therm.Draw("e1same")
> h_en_cm_photon.Fit("Au_fit_direct + Au_fit_therm","R","",10,25)
> 
> Everything works as expected but the last instruction gives:
> "Unknown function: Au_fit_direct + Au_fit_therm"
> 
> When, alternatively, trying to define a new function from the existent
> ones via :
> TF1 *Au_fit_total = new TF1("Au_fit_direct + Au_fit_therm")
> I get "Error: illegal pointer to class object Au_fit_total" when trying
> to draw it (Au_fit_total.Draw())....
> 
> Briefly, I don't get to know how to operate with  functions created via
> histo.GetFunction() to create new functions or to use them to fit
> histograms .... and the Class Description for TFormula and TF1 (as well
> as the different examples in the web) don't give me an answer (as far as
> I know) ....
> 
> So, where I'm wrong ?
> 

Hi David,
This syntax is currently not supported by TF1.
For fitting additions of multiple functions, see an example at URL:
  http://root.cern.ch/root/html/examples/backsig.C.html

Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:28 MET