# Get the integral of a function of a total function

Hi! I’m having some problems to get a integral of a function that is inside in a total function. I fit this function with 3 functions: 2 gaussian and a constant. Now, I need to get the Integral (and his error) of one of this gaussians.

This is the code of the fitting functions: pastebin[dot]com/etaHYUpW
This is the code of the fit: pastebin[dot]com/xj8UPEEC

`cout << "AREA: " << funcFit->Integral(1230, 1260) << " +/- " << funcFit->IntegralError(1230, 1260) << endl;`

With this last code funcFit->Integral I get the fit of the totalFit.

In this case I need the integral of the gaussian without the noise and the little pile-up on the right (2nd gaussian).

I don’t know how to do this, has anybody an idea?

See this old post (in the old “TH1F variable bin width” thread).

Try:

``````// ...
TF1 *funcFit = new TF1("funcFit", "gausn(0) + pol0(3) + gausn(4)", limInf, limSup);
funcFit->SetParName(0, "Area");
// ...
funcFit->SetParName(4, "Area_PileUp");
// ...
``````

Mmh… Isn’t it the parameter 0 the amplitude of the first gaussian and parameter 4 the amplitude of the second gaussian? When he writes

`"gaus peak integral = " << f1->GetParameter(0)`

He gets the amplitude of the peak, not the complex area of the gaussian.

I need this orange gauss area: