EvtGen
2.2.0
Monte Carlo generator of particle decays, in particular the weak decays of heavy flavour particles such as B mesons.
Toggle main menu visibility
Loading...
Searching...
No Matches
src
EvtGenModels
EvtItgSimpsonIntegrator.cpp
Go to the documentation of this file.
1
2
/***********************************************************************
3
* Copyright 1998-2020 CERN for the benefit of the EvtGen authors *
4
* *
5
* This file is part of EvtGen. *
6
* *
7
* EvtGen is free software: you can redistribute it and/or modify *
8
* it under the terms of the GNU General Public License as published by *
9
* the Free Software Foundation, either version 3 of the License, or *
10
* (at your option) any later version. *
11
* *
12
* EvtGen is distributed in the hope that it will be useful, *
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15
* GNU General Public License for more details. *
16
* *
17
* You should have received a copy of the GNU General Public License *
18
* along with EvtGen. If not, see <https://www.gnu.org/licenses/>. *
19
***********************************************************************/
20
21
#include "
EvtGenModels/EvtItgSimpsonIntegrator.hh
"
22
23
//-------------
24
// C Headers --
25
//-------------
26
extern
"C"
{
27
}
28
29
//---------------
30
// C++ Headers --
31
//---------------
32
33
#include <math.h>
34
35
//-------------------------------
36
// Collaborating Class Headers --
37
//-------------------------------
38
39
#include "
EvtGenBase/EvtReport.hh
"
40
41
#include "
EvtGenModels/EvtItgAbsFunction.hh
"
42
using
std::endl;
43
44
EvtItgSimpsonIntegrator::EvtItgSimpsonIntegrator
(
45
const
EvtItgAbsFunction
& theFunction,
double
precision,
int
maxLoop ) :
46
EvtItgAbsIntegrator
( theFunction ),
47
m_precision
( precision ),
48
m_maxLoop
( maxLoop )
49
{
50
}
51
52
double
EvtItgSimpsonIntegrator::evaluateIt
(
double
lower,
double
higher )
const
53
{
54
// EvtGenReport(EVTGEN_INFO,"EvtGen")<<"in evaluate"<<endl;
55
int
j;
56
double
result( 0.0 );
57
double
s, st, ost( 0.0 );
58
for
( j = 1; j < 4; j++ ) {
59
st =
trapezoid
( lower, higher, j, result );
60
s = ( 4.0 * st - ost ) / 3.0;
61
ost = st;
62
}
63
64
double
olds( s );
65
st =
trapezoid
( lower, higher, j, result );
66
s = ( 4.0 * st - ost ) / 3.0;
67
68
if
( fabs( s - olds ) <
m_precision
* fabs( olds ) ||
69
( s == 0.0 && olds == 0.0 ) )
70
return
s;
71
72
ost = st;
73
74
for
( j = 5; j <
m_maxLoop
; j++ ) {
75
st =
trapezoid
( lower, higher, j, result );
76
s = ( 4.0 * st - ost ) / 3.0;
77
78
if
( fabs( s - olds ) <
m_precision
* fabs( olds ) ||
79
( s == 0.0 && olds == 0.0 ) )
80
return
s;
81
olds = s;
82
ost = st;
83
}
84
85
EvtGenReport
(
EVTGEN_ERROR
,
"EvtGen"
)
86
<<
"Severe error in EvtItgSimpsonIntegrator. Failed to converge after loop with 2**"
87
<<
m_maxLoop
<<
" calls to the integrand in."
<< endl;
88
89
return
0.0;
90
}
EvtItgAbsFunction.hh
EvtItgSimpsonIntegrator.hh
EvtReport.hh
EvtGenReport
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=nullptr)
Definition
EvtReport.cpp:32
EVTGEN_ERROR
@ EVTGEN_ERROR
Definition
EvtReport.hh:49
EvtItgAbsFunction
Definition
EvtItgAbsFunction.hh:35
EvtItgAbsIntegrator::trapezoid
double trapezoid(double lower, double higher, int n, double &result) const
Definition
EvtItgAbsIntegrator.cpp:56
EvtItgAbsIntegrator::EvtItgAbsIntegrator
EvtItgAbsIntegrator(const EvtItgAbsFunction &)
Definition
EvtItgAbsIntegrator.cpp:37
EvtItgSimpsonIntegrator::evaluateIt
double evaluateIt(double, double) const override
Definition
EvtItgSimpsonIntegrator.cpp:52
EvtItgSimpsonIntegrator::m_maxLoop
double m_maxLoop
Definition
EvtItgSimpsonIntegrator.hh:46
EvtItgSimpsonIntegrator::m_precision
double m_precision
Definition
EvtItgSimpsonIntegrator.hh:45
EvtItgSimpsonIntegrator::EvtItgSimpsonIntegrator
EvtItgSimpsonIntegrator(const EvtItgAbsFunction &, double precision=1.0e-5, int maxLoop=20)
Definition
EvtItgSimpsonIntegrator.cpp:44
Generated by
1.17.0