34 double f(
double * x,
double * p) {
36 return p[1]*TMath::Sin( p[0] * x[0] );
40 void ErrorIntegral() {
41 fitFunc =
new TF1(
"f",f,0,1,NPAR);
42 TH1D * h1 =
new TH1D(
"h1",
"h1",50,0,1);
44 double par[NPAR] = { 3.14, 1.};
45 fitFunc->SetParameters(par);
47 h1->FillRandom(
"f",1000);
48 fitFunc->SetParameter(0,3.);
54 double integral = fitFunc->Integral(0,1);
56 TVirtualFitter * fitter = TVirtualFitter::GetFitter();
58 double * covMatrix = fitter->GetCovarianceMatrix();
61 double sigma_integral = fitFunc->IntegralError(0,1);
63 std::cout <<
"Integral = " << integral <<
" +/- " << sigma_integral
68 double * p = fitFunc->GetParameters();
69 double ic = p[1]* (1-std::cos(p[0]) )/p[0];
70 double c0c = p[1] * (std::cos(p[0]) + p[0]*std::sin(p[0]) -1.)/p[0]/p[0];
71 double c1c = (1-std::cos(p[0]) )/p[0];
74 double sic = std::sqrt( c0c*c0c * covMatrix[0] + c1c*c1c * covMatrix[3]
75 + 2.* c0c*c1c * covMatrix[1]);
77 if ( std::fabs(sigma_integral-sic) > 1.E-6*sic )
78 std::cout <<
" ERROR: test failed : different analytical integral : "
79 << ic <<
" +/- " << sic << std::endl;