Problem about function

Dear Sir/Miss;
I defined a function in my code to make my fitting convenient because i use GAUS fit so many times and want to get the fitted results. But there was some problems that I could not find out and it puzzled me for a whole day. So I’m here looking for help.
For my code easy to read, I omitted some code which have no influence to the happenned error.

The message for the error: Error: Function gfpara(zsq11,0.,0.,pk,sig) is not defined in current scope zacali.C:155:

Here is my code:

[code]Double_t gfpara(char* hnm,Float_t vdn,Float_t vup,Double_t pk,Double_t sig)
{
Double_t gpara[3];
gf=new TF1(“gf”,“gaus”);
gf->SetLineColor(2);

if(vdn==0.&&vup==0.)
{
hnm->Fit(“gf”);
gf->GetParameters(&gpara[0]);
pk=gpara[2];
sig=gpara[3];
}
else
{
hnm->Fit(“gf”,"","",vdn,vup);
gf->GetParameters(&gpara[0]);
pk=gpara[2];
sig=gpara[3];
}
return fit;
}

//_______________________________________________________

void zacali(){ //main begin
TCanvas *myC = new TCanvas(“myC”,“Z_Calibration”,1);
gStyle->SetPalette(1);
Double_t nuczfitpk[4],nuczfitsig[4];
Double_t nucde1fitpk[4],nucde1fitsig[4];
Double_t nucde2fitpk[4],nucde2fitsig[4];
Double_t pk=0.0;
Double_t sig=0.0;
TFile f("/mnt/LDATA/caliZ031.root");
TH2F *zzsi2=new TH2F(“zzsi2”,“zsq vs t1si2”,200,0,4096,200,6000,14500);
ana_data->Project(“zzsi2”,“zsq:t1si2e”);
char nmh1fz[50],nmh1fde1[50],nmh1fde2[50];
for(Int_t i=11;i<16;i++)
{ //for loops

  sprintf(nmh1fz,"zsq Z=%d",i);
  sprintf(nmh1fde1,"t1si2 Z=%d",i);
  sprintf(nmh1fde2,"t2si1 Z=%d",i);

  else if(i==12)
{	cout<<"here z=12"<<endl;
TH1F *zsq12= new TH1F("zsq12",nmh1fz,1000,8270,9030);
ana_data->Project("zsq12",zsq);
TH1F *de112= new TH1F("de112",nmh1fde1,2000,100,4096);
ana_data->Project("de112","t1si2e","zsq>8270&&zsq<9030");
TH1F *de212= new TH1F("de212",nmh1fde2,2000,100,4096);
ana_data->Project("de212","t2si1e","zsq>8270&&zsq<9030");
myC->cd(1);
zsq12->Draw();
gfpara(zsq12,0.,0.,pk,sig);
nuczfitpk[1]=pk;nuczfitsig[1]=sig;
myC->cd(2);
de112->Draw();
gfpara(de112,0.,0.,pk,sig);
nucde1fitpk[1]=pk;nucde1fitsig[1]=sig;
myC->cd(3);
de212->Draw();
gfpara(de212,0.,0.,pk,sig);
nucde2fitpk[1]=pk;nucde2fitsig[1]=sig;

}
  else if(i==11)
{	cout<<"here z=11"<<endl;
TH1F *zsq11= new TH1F("zsq11",nmh1fz,1000,7050,7660);
ana_data->Project("zsq11","zsq");
TH1F *de111= new TH1F("de111",nmh1fde1,2000,100,4096);
ana_data->Project("de111","t1si2e","zsq>7050&&zsq<7660");
TH1F *de211= new TH1F("de211",nmh1fde2,2000,100,4096);
ana_data->Project("de211","t2si1e","zsq>7050&&zsq<7660");
myC->cd(1);
zsq11->Draw();
gfpara(zsq11,0.,0.,pk,sig);        //This line the error happenned.
nuczfitpk[0]=pk;nuczfitsig[0]=sig;
myC->cd(2);
de111->Draw();
gfpara(de111,0.,0.,pk,sig);
nucde1fitpk[0]=pk;nucde1fitsig[0]=sig;
myC->cd(3);
de211->Draw();
gfpara(de211,0.,0.,pk,sig);
nucde2fitpk[0]=pk;nucde2fitsig[0]=sig;

}
  myC->SaveAs(fpic);
}	//for loops

f.Close();
} //main end
[/code]

The signature for your function gfpara looks wrong.
Instead of;

Double_t gfpara(char* hnm,Float_t *vdn,Float_t *vup,Double_t* pk,Double_t* sig) it should be

Rene

The question is solved by the help of one of my friend.
the define of the function should be:

[code]gfpara(TH1F* hnm,Float_t vdn,Float_t vup,Double_t &pk,Double_t &sig)

[/code]since hnm is name of a histogram.

[quote=“brun”]The signature for your function gfpara looks wrong.
Instead of;

Double_t gfpara(char* hnm,Float_t *vdn,Float_t *vup,Double_t* pk,Double_t* sig) it should be

Rene[/quote]

Thanks for your quick responce.
i have correctted the mistake in the defination line.