45double exactIntegral(
double a,
double b) {
49double func(
double x){
55double func2(
const double *
x,
const double * = 0){
63void testIntegPerf(
double x1,
double x2,
int n = 100000){
66 std::cout <<
"\n\n***************************************************************\n";
67 std::cout <<
"Test integration performances in interval [ " <<
x1 <<
" , " <<
x2 <<
" ]\n\n";
71 double dx = (
x2-
x1)/
double(
n);
80 for (
int i = 0; i <
n; ++i) {
82 s1+= ig.Integral(
x1,
x);
85 std::cout <<
"Time using ROOT::Math::Integrator :\t" << timer.
RealTime() << std::endl;
86 std::cout <<
"Number of function calls = " << nc/
n << std::endl;
87 int pr = std::cout.precision(18); std::cout <<
s1 << std::endl; std::cout.precision(pr);
97 for (
int i = 0; i <
n; ++i) {
102 std::cout <<
"Time using TF1::Integral :\t\t\t" << timer.
RealTime() << std::endl;
103 std::cout <<
"Number of function calls = " << nc/
n << std::endl;
104 pr = std::cout.precision(18); std::cout <<
s1 << std::endl; std::cout.precision(pr);
109void DrawCumulative(
double x1,
double x2,
int n = 100){
111 std::cout <<
"\n\n***************************************************************\n";
112 std::cout <<
"Drawing cumulatives of BreitWigner in interval [ " <<
x1 <<
" , " <<
x2 <<
" ]\n\n";
115 double dx = (
x2-
x1)/
double(
n);
118 for (
int i = 1; i <=
n; ++i) {
119 double x =
x1 + dx*i;
131 for (
int i = 1; i <=
n; ++i) {
132 double x =
x1 + dx*i;
137 TF1 *fBW =
new TF1(
"fBW",
"TMath::BreitWigner(x, 0, 1)",
x1,
x2);
141 for (
int i = 1; i <=
n; ++i) {
142 double x =
x1 + dx*i;
148 for (
int i = 1; i <=
n; ++i) {
163 cum0->
SetTitle(
"BreitWigner - the cumulative");
181 cum20->
Draw(
"hsame");
184 l->AddEntry(cum10,
"GSL integration - analytical ");
185 l->AddEntry(cum20,
"TF1::Integral - analytical ");
190 std::cout <<
"\n***************************************************************\n";
197void mathmoreIntegration(
double a = -2,
double b = 2)
199 DrawCumulative(
a,
b);
static const double x2[5]
static const double x1[5]
Functor1D class for one-dimensional functions.
User Class for performing numerical integration of a function in one dimension.
Template class to wrap any C++ callable object which takes one argument i.e.
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual Double_t Integral(Double_t a, Double_t b, Double_t epsrel=1.e-12)
IntegralOneDim or analytical integral.
1-D histogram with a double per channel (see TH1 documentation)}
virtual void SetTitle(const char *title)
See GetStatOverflows for more information.
virtual void SetBinError(Int_t bin, Double_t error)
Set the bin Error Note that this resets the bin eror option to be of Normal Type and for the non-empt...
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
virtual TH1 * DrawCopy(Option_t *option="", const char *name_postfix="_copy") const
Copy this histogram and Draw in the current pad.
virtual void Draw(Option_t *option="")
Draw this histogram with options.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
This class displays a legend box (TPaveText) containing several legend entries.
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void Stop()
Stop the stopwatch.
Double_t BreitWigner(Double_t x, Double_t mean=0, Double_t gamma=1)
Calculate a Breit Wigner function with mean and gamma.