TF1 Integration

Hello ROOTers,
I have a trouble when integrating a TF1. Here is an example:
I define a Gaussian function;
TF1 *g=new TF1(“g”,“TMath::Gaus(x,0,0.1,1)”,-100,100)
To get the integral in various regions I do:
for(int i=1; i<100; i++){
cout<<"range = “<<-i<<” to “<<i<<” integral = "<Integral(-i,i)<<endl;
}
and here is the output:
range = -1 to 1 integral = 1
range = -2 to 2 integral = 1
range = -3 to 3 integral = 1
range = -4 to 4 integral = 1
range = -5 to 5 integral = 1
range = -6 to 6 integral = 1
range = -7 to 7 integral = 1
range = -8 to 8 integral = 1
range = -9 to 9 integral = 1.80091e-15
range = -10 to 10 integral = 3.77343e-19
range = -11 to 11 integral = 3.17367e-23
range = -12 to 12 integral = 1.07332e-27
range = -13 to 13 integral = 1.46156e-32
range = -14 to 14 integral = 8.0218e-38
range = -15 to 15 integral = 1.77604e-43
range = -16 to 16 integral = 1.58724e-49
range = -17 to 17 integral = 5.72903e-56
range = -18 to 18 integral = 8.35526e-63
range = -19 to 19 integral = 4.9254e-70
.
.
.
Is there any explanation for this output when the integration range is wide (beyond |9|)?
Thanks,
Arafat.

Hi,

the simple Gauss integration method implemented in TF1::Integral is not suited for a so peaked function. I recommend you use the adaptive integration method of MathMore, class GSLIntegrator.
See the attached macro as example and eventually also the online ref doc at

project-mathlibs.web.cern.ch/pro … rator.html

Best Regards

Lorenzo
testIntegralGaus.C (638 Bytes)

Hi Lorenzo,
Thanks for the reply.
I cannot make your example work. Did you try it before?
I tried both the interpreter and then the compiler.
Here is the compilation result:

rootcint: symbol lookup error: rootcint: undefined symbol: _ZN14G__ShadowMaker15NeedShadowClassER12G__ClassInfo
Error in : Dictionary generation failed!
Info in : Invoking compiler to check macro’s validity
filejXQTH4.check.cxx:2:32: Math/GSLIntegrator.h: No such file or directory
filejXQTH4.check.cxx:3:29: Math/WrappedTF1.h: No such file or directory
filejXQTH4.check.cxx: In function void testIntegralGaus()': filejXQTH4.check.cxx:16: error:ROOT::Math’ has not been declared
filejXQTH4.check.cxx:16: error: GSLIntegrator' was not declared in this scope filejXQTH4.check.cxx:16: error: expected;’ before "ig"
filejXQTH4.check.cxx:17: error: ROOT::Math' has not been declared filejXQTH4.check.cxx:17: error:WrappedTF1’ was not declared in this scope
filejXQTH4.check.cxx:17: error: expected ;' before "wf" filejXQTH4.check.cxx:18: error:ig’ was not declared in this scope
filejXQTH4.check.cxx:18: error: `wf’ was not declared in this scope
filejXQTH4.check.cxx:16: warning: unused variable 'GSLIntegrator’
filejXQTH4.check.cxx:17: warning: unused variable 'WrappedTF1’
filejXQTH4.check.cxx:18: warning: unused variable 'wf’
Error: Function testIntegralGaus() is not defined in current scope :0:
*** Interpreter error recovered ***

Arafat.

Hi,

which ROOT version are you using, 5.18 ?
You need in any case to have mathmore enabled and a version of the GSL library > 1.8 installed.
MathMore is built in ROOT whenever a GSL library is found in the system.
If it is not found, you need to download and install GSL first.
The GSL library and header file location can be specified in the ROOT configure script with the ROOT configure options --with-gsl-incdir=… --with-gsl-libdir=…

Lorenzo