Number of entries in fit

I have a simple task: fit a gaussian on a histogram and get out the number of entries in the fitted area, not depending on the binning of the histogram. I was trying to do that with:

void dgauss(TH1 * histo){

Double_t par[3]={50,2,1};
Double_t binwidth = histo->GetBinWidth(1);
	cout << "proba: " << proba.Data() << endl;
TF1 *FGauss = new TF1("FGauss","[0]*binwidth/(TMath::Sqrt(TMath::TwoPi())*[2])*TMath::Exp(-0.5*((x-[1])/[2])*(x-[1])/[2])))" , histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax());

TwoGauss->SetParameters(par);
histo->Fit("FGauss");

}

bit I always get

Error in TFormula::Compile: Bad numerical expression : binwidth

How can overcome this?

Cheers,
Ivan

Do:

char *formula = Form("[0]*%g/(TMath::Sqrt(TMath::TwoPi())*[2])*TMath::Exp(-0.5*((x-[1])/[2])*(x-[1])/[2])))",binwidth); TF1 *FGauss = new TF1("FGauss",formula, histo->GetXaxis()->GetXmin(),histo->GetXaxis()->GetXmax());
Rene

Thanks a lot Rene, that solved the problem. Btw, could you point me where the Form function is defined?

Thanks again,
Ivan

It is defined in TString.h

extern char *Form(const char *fmt, ...); // format in circular buffer
same functionality as sprintf. It uses an internal buffer to format the string
and returns a pointer to this string. Up to you to save a copy in your own managed area. In many cases (like in the example above) you can pass
directly Form to functions expecting a const char* argument.

Rene