# Method Integral of ROOT

Hello!
I’m trying to use the method Integral by ROOT. The fit is drawn but the terminal says “Error in : Error 18 in qags.c at 547 : cannot reach tolerance because of roundoff error”.
How can I do? I tried to modify the tolerance but nothing changes.
My code is:

``````#include <iostream>
#include <fstream>
#include "TMath.h"
#include "TGraph.h"

Double_t gaussian1d(Double_t *x, Double_t *par)
{
Float_t xx =x[0];
Float_t yy = x[1];
Double_t f = par[2]*((exp(-0.5*((xx-par[0])/par[1])*((xx-par[0])/par[1]))));
return f;
}

Double_t gaussian1d_integral(Double_t *x, Double_t *par)
{
TF1 *mygaussian1d = new TF1("mygaussian1d",gaussian1d,-15,15,3); //gaussiana 1d dipende da 3 parametri
mygaussian1d->SetParameter(0,x[0]);
mygaussian1d->SetParameter(1,par[0]);
mygaussian1d->SetParameter(2,par[1]);
//  mygaussian2d->SetParameter(3,par[2]);
Double_t f_1 = mygaussian1d->Integral(-par[2],par[2]);
delete mygaussian1d;
return f_1;
}

void Gauss_random1D(){

TF1 *mygaussian1d_rnd = new TF1("mygaussian1d_rnd",gaussian1d,-15,15,3);
TF1 *mygaussian1d_int = new TF1("mygaussian1d_int",gaussian1d_integral,-15,15,3);
TF1 *mygaussian1d_fit = new TF1("mygaussian1d_fit",gaussian1d_integral,-15,15,3);

mygaussian1d_int->SetParameter(0,1);
mygaussian1d_int->SetParameter(1,1000);
mygaussian1d_int->SetParameter(2,10);

TH1F *h2=new TH1F("h2","test",400,-15,15);
h2->FillRandom("mygaussian1d_int",10000000);

TCanvas *can = new TCanvas();

mygaussian1d_int->Draw();

}
``````

Use “`Double_t`” instead of “`Float_t`” (and note that “`x[1]`” does NOT exist).

Thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.