Re: [ROOT] Bug with fitted functions attached to histograms ?

From: Patois Yannick (patois@ganil.fr)
Date: Mon Jun 11 2001 - 22:52:36 MEST


Hi,

I finally simplified my script enought to post it here. It's still not
that much clean, sorry, anyway, seems seems to arise on a TH1::Clone
when a function is attached to it.

Here the script:

<<<< File bug104.C
void bug104() {
  TH1 *tp;
  TF1 fa("fa","gaus",-1,1);
  fa.SetParameter(0,1);
  fa.SetParameter(1,0);
  
  for (int nb=0;nb<2;nb++) {
    TH1 *h1;
    fa.SetParameter(2,nb/10.);  
    if (nb==0)      {h1=new
                      TH1F("h1","h1",100,-1.1,1.1);h1->FillRandom("fa");}
    if (nb==1)      {h1=new
                      TH1F("h2","h2",100,-1.1,1.1);h1->FillRandom("fa");}
    TF1 f1("f1","gaus");
    h1->Fit("f1","Q");
    if (nb==0)tp=(TH1*)h1->Clone();
    TF1 *fb=tp->GetFunction("f1");
    cout << fb->GetParameter(2)<<endl;
  }
}
>>>>

The output from ROOT version 3.00.06 (i386-linux):

  *   Version   3.00/06     12 March 2001   *
.root [0] .x bug104.C
<TCanvas::MakeDefCanvas>: created default TCanvas with name c1
7.88193e-09
7.88193e-09

The two values printed out are the same. This is expected.

But on latest ROOT:

  *   Version   3.01/05       7 June 2001   *
root [0] .x bug104.C
<TCanvas::MakeDefCanvas>: created default TCanvas with name c1
7.88193e-09
0.0995868

The second value is in fact the fit result for h2! Not h1!

What do you think of it ?

	Yannick
 



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