BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtItgSimpsonIntegrator.cc
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3//
4// Copyright Information: See EvtGen/COPYRIGHT
5//
6// Environment:
7// This software is part of the EvtGen package developed jointly
8// for the BaBar and CLEO collaborations. If you use all or part
9// of it, please give an appropriate acknowledgement.
10//
11// Module: EvtItgSimpsonIntegrator.hh
12//
13// Description:
14// Abstraction of a generic function for use in integration methods elsewhere
15// in this package. (Stolen and modified from
16// the BaBar IntegrationUtils package - author: Phil Strother).
17//
18// Modification history:
19//
20// Jane Tinslay March 21, 2001 Module adapted for use in
21// EvtGen
22//
23//------------------------------------------------------------------------
25
27
28//-------------
29// C Headers --
30//-------------
31extern "C" {}
32
33//---------------
34// C++ Headers --
35//---------------
36
37#include <math.h>
38
39//-------------------------------
40// Collaborating Class Headers --
41//-------------------------------
42
44#include "EvtItgAbsFunction.hh"
45using std::endl;
46
48 double precision, int maxLoop )
49 : EvtItgAbsIntegrator( theFunction ), _precision( precision ), _maxLoop( maxLoop ) {}
50
51//--------------
52// Destructor --
53//--------------
54
56
57double EvtItgSimpsonIntegrator::evaluateIt( double lower, double higher ) const {
58
59 // report(INFO,"EvtGen")<<"in evaluate"<<endl;
60 int j;
61 double result( 0.0 );
62 double s, st, ost( 0.0 );
63 for ( j = 1; j < 4; j++ )
64 {
65 st = trapezoid( lower, higher, j, result );
66 s = ( 4.0 * st - ost ) / 3.0;
67 ost = st;
68 }
69
70 double olds( s );
71 st = trapezoid( lower, higher, j, result );
72 s = ( 4.0 * st - ost ) / 3.0;
73
74 if ( fabs( s - olds ) < _precision * fabs( olds ) || ( s == 0.0 && olds == 0.0 ) ) return s;
75
76 ost = st;
77
78 for ( j = 5; j < _maxLoop; j++ )
79 {
80
81 st = trapezoid( lower, higher, j, result );
82 s = ( 4.0 * st - ost ) / 3.0;
83
84 if ( fabs( s - olds ) < _precision * fabs( olds ) || ( s == 0.0 && olds == 0.0 ) )
85 return s;
86 olds = s;
87 ost = st;
88 }
89
90 report( ERROR, "EvtGen" )
91 << "Severe error in EvtItgSimpsonIntegrator. Failed to converge after loop with 2**"
92 << _maxLoop << " calls to the integrand in." << endl;
93
94 return 0.0;
95}
ostream & report(Severity severity, const char *facility)
Definition EvtReport.cc:34
@ ERROR
Definition EvtReport.hh:49
XmlRpcServer s
double trapezoid(double lower, double higher, int n, double &result) const
EvtItgAbsIntegrator(const EvtItgAbsFunction &)
EvtItgSimpsonIntegrator(const EvtItgAbsFunction &, double precision=1.0e-5, int maxLoop=20)
virtual double evaluateIt(double, double) const