1 //--------------------------------------------------------------------------
4 // Copyright Information: See EvtGen/COPYRIGHT
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.
11 // Module: EvtItgSimpsonIntegrator.hh
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).
18 // Modification history:
20 // Jane Tinslay March 21, 2001 Module adapted for use in
23 //------------------------------------------------------------------------
24 #include "EvtGenBase/EvtPatches.hh"
26 #include "EvtGenModels/EvtItgSimpsonIntegrator.hh"
40 //-------------------------------
41 // Collaborating Class Headers --
42 //-------------------------------
44 #include "EvtGenModels/EvtItgAbsFunction.hh"
45 #include "EvtGenBase/EvtReport.hh"
49 EvtItgSimpsonIntegrator::EvtItgSimpsonIntegrator(const EvtItgAbsFunction &theFunction, double precision, int maxLoop):
50 EvtItgAbsIntegrator(theFunction),
51 _precision(precision),
60 EvtItgSimpsonIntegrator::~EvtItgSimpsonIntegrator()
64 EvtItgSimpsonIntegrator::evaluateIt(double lower, double higher) const{
66 // report(INFO,"EvtGen")<<"in evaluate"<<endl;
69 double s, st, ost(0.0);
71 st = trapezoid(lower, higher, j, result);
72 s = (4.0 * st - ost)/3.0;
77 st = trapezoid(lower, higher, j, result);
78 s = (4.0 * st - ost)/3.0;
80 if (fabs(s - olds) < _precision*fabs(olds) || (s==0.0 && olds==0.0)) return s;
84 for (j=5;j<_maxLoop;j++){
86 st = trapezoid(lower, higher, j, result);
87 s = (4.0 * st - ost)/3.0;
89 if (fabs(s - olds) < _precision*fabs(olds) || (s==0.0 && olds==0.0)) return s;
94 report(ERROR,"EvtGen") << "Severe error in EvtItgSimpsonIntegrator. Failed to converge after loop with 2**"
95 << _maxLoop << " calls to the integrand in." << endl;