Understanding a user defined fit function

Hi,

I have defined some user defined function which can be expressed as :
fitfun=h1/par(0) + par(1) * (1 - exp(-h2/par(2)))^par(3)

In code the format is like this :

Double_t ftotal(Double_t *x, Double_t *par) {
Double_t xx = x[0];
Int_t bin = h1->GetXaxis()->FindBin(xx);
Float_t br = h1->GetBinContent(bin);
cout <<"xx = “<<xx<<” "<<“bin = “<<bin<<”” << "bin content = " <<br<<endl;
if(par[0]!= 0) Double_t br1= br/par[0];
if(par[2] != 0) Double_t bk = par[1]*TMath::Power((1-TMath::Exp(-(x[0])/par[2])),par[3]);
Double_t tot = br1 + bk;
return tot;
}

Here h1 is histogram_A
while at line … if(par[2]!=0) Double_t bk =… -> here I am getting the contents of histogram_B
Now, I have some doubts:

  1. Is my approach correct while creating a fit fn using two histograms?
  2. While I am displaying the bin contents of first histogram(h1), some values are getting repeated, I doubt whether they are also being added up in the total fit fn?

Please find my code attached with this message.

Thanks,
Shikshit

forgot to attach the code in the last message.

Shikshit
fit_sample.C (1.31 KB)