Home | News | Documentation | Download

Show fitted function works differently (?) than before


Please read tips for efficient and successful posting and posting code

ROOT Version: 5.34/36
Platform: cygwin
Compiler: 10.2.0


Hi, I have a funny problem, see this example:

TH1F* h1 = new TH1F("h1","h1",10,0.,1.);
h1->Fill(0.3)
h1->Fill(0.3)
h1->Fill(0.4)
h1->Fill(0.4)
h1->Fill(0.4)
h1->Fill(0.5)
h1->Fill(0.5)
h1->Fill(0.5)
h1->Fill(0.5) // etc.....
  TF1* gauss = new TF1("gFun","gaus");
  gauss->SetParNames("height","mean","sigma");
  gauss->SetLineColor(kRed);
  gauss->SetLineWidth(2);
 double gauPeak = h1->GetMaximum();
 gauss->SetParameters(10.,gauPeak,0.001);
TFitResultPtr res = h1->Fit("gFun","QS0"); // do NOT plot this just now
....... h1 is done, do other things, big code parts.....
h1->Draw();           //this does NOT plot the red gaussian!
h1->Draw("FUNC") //this does NOT plot anything. note there is a stat box

I thought (I am even 99% sure that I have used this behaviour before) that using option “0” to the fit means “do the fit, but do not mess with my pads & windows just_now” ; but it appears that it means instead “do not ever plot this curve” even if the associated curve exists.
Could you please clarify me this?
Thank you!

See “Warning when using the option "0"” in the TH1::Fit method description.

OK, thank you. Just 2 things, for my peace of spirit:

  1. has it always been like this?
  2. in the TH1::Fit doc (that today I have read and reread a dozen of times)
    the warning you mention should be really just below the place where the option “0” is mentioned, not 2 pages below, where nobody looks for it anymore.
    Bye, Sandro

This is like that at least since ROOT version 5.24 ie: June 2009