[ROOT] function can not be compiled

From: Huaizhang Deng (deng@bnl.gov)
Date: Mon Jun 05 2000 - 21:55:32 MEST


I wrote the following program.

Double_t RatioFunc(Double_t *t, Double_t *par) {
  Double_t R;
  R=par[0]*cos(2*3.14159265*0.0002291*(1-par[1]*1.0e-6)*t[0]+par[2])+par[3];
  return R;
}

TF1* RatioFit(TH1F* h, Float_t t_start, Float_t t_end) {

  TF1 *RatioFit=new TF1("RatioFit", RatioFunc, 0, 700000, 4);

  RatioFit->SetParNames("A", "R", "'f#", "offset");
  RatioFit->SetRange(t_start, t_end);
  RatioFit->SetParameters(0.4, 120, 0, 0);

  h->Fit("RatioFit", "R");
  return RatioFit;
}

Then I tried to do

int i;
TF1* fit;
for(i=0; i<5; i++) fit=RatioFit(hist, t, 400000.);

After the first fit, which is o.k., it complain "Function:RatioFit cannot be
compiled".
However, the following program works well.

int i;
TF* fit;
fit=RatioFit(h, t, 40000);
for(i=1; i<5; i++) fit=RatioFit(hist, t, 40000);

I wonder why those two programs make difference.

Huaizhang Deng



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:27 MET