Hi, I attach a simple code here to test user-defined function. I define g1 as a gaussian function and define g2 based on g1. Thus, if I define g2=g1*1.0, I cannot get the right fitting plot, however, if I define g2=g1 I can. Anybody could tell my problem?
Thanks,
Zhiyi.
fitErf(){
TH1F *h = new TH1F(“h”,“gauss”, 100, -3, 3);
Int_t i;
for ( i=0; i<1000; i++)
h->Fill(gRandom->Gaus(0,1));
h->Draw();
TF1 *g1 = new TF1(“g1”,“gaus”,-3,3);
TF1 *g2 = new TF1(“g2”," g1 * 1.0 “,-3,3); // fitting plot is a straight line
//TF1 *g2 = new TF1(“g2”,” g1 ",-3,3); // fitting plot is right
h->Fit( “g2” );
}