Re: [ROOT] Problems with Fitting

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Aug 23 2001 - 19:41:39 MEST


Hi Stefan,

We modified the specs for the option "0" in TH1""Fit in version 3.00.
See Release notes at:

http://root.cern.ch/root/roottalk/roottalk01/0956.html

Change in Fitting option "0"
============================

The option "0" has been activated. When selecting this option, the
fitted function is added to the list of functions of the histogram,
but it is not drawn. You can undo what you disabled in the following way:
  h.Fit("myFunction","0"); // fit, store function but do not draw
  h.Draw(); function is not drawn
  const Int_t kNotDraw = 1<<9;
  h.GetFunction("myFunction")->ResetBit(kNotDraw);
  h.Draw();  // function is visible again


In your example, do:

  histo->Fit("land_1","b0");

  TCanvas *c1 = new TCanvas("c1","c1",800,600);
  c1->Divide(2,1);
  c1->cd(1);
  const Int_t kNotDraw = 1<<9;
  histo->GetFunction("land_1")->ResetBit(kNotDraw);
  histo->DrawCopy("");
  c1->cd(2);
  land_1->Draw("");

Note that in your last statement above, you draw the function prototype
with the original parameters. The function with the real parameters
is stored with the histogram data structure in the list of functions.

I have added the above information in the documentation of TH1::Fit

Rene Brun


Stefan Stonjek wrote:
> 
> Hello,
> 
> I have two problems with the attached script:
> 
> 1) In the 2.?? versions of root the fitted function is drawn together with
>    the histogram (for just the histogram you have to give "hist" as an
>    opton). But in the 3.?? versions the fitted function is not drawn. Is
>    this a bug or a new feature.
> 
> 2) If one tries to plot the function seperatly a function is ploted wich
>    seems to be completly different from the one which is plotted together
>    with the histogram for versions < 3.00.
> 
> I hope someone can help me with this problem.
> 
> Tschuess
>         Stefan
> 
> *********      Stefan  Stonjek     *********
> *****            DESY / ZEUS           *****
> *****      Stefan.Stonjek@desy.de      *****
> *********  Tel.: +49-40-8998-3159  *********
> 
>   --------------------------------------------------------------------------------
> 
>                    Name: histfit.C
>    histfit.C       Type: Plain Text (TEXT/PLAIN)
>                Encoding: BASE64



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:58 MET