BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtBtoXsgammaRootFinder Class Reference

#include <EvtBtoXsgammaRootFinder.hh>

Public Member Functions

 EvtBtoXsgammaRootFinder ()
virtual ~EvtBtoXsgammaRootFinder ()
double GetRootSingleFunc (const EvtItgAbsFunction *theFunc, double functionValue, double lowerValue, double upperValue, double precision)
double GetGaussIntegFcnRoot (EvtItgAbsFunction *theFunc1, EvtItgAbsFunction *theFunc2, double integ1Precision, double integ2Precision, int maxLoop1, int maxLoop2, double integLower, double integUpper, double lowerValue, double upperValue, double precision)

Detailed Description

Definition at line 35 of file EvtBtoXsgammaRootFinder.hh.

Constructor & Destructor Documentation

◆ EvtBtoXsgammaRootFinder()

EvtBtoXsgammaRootFinder::EvtBtoXsgammaRootFinder ( )

Definition at line 41 of file EvtBtoXsgammaRootFinder.cc.

41{}

◆ ~EvtBtoXsgammaRootFinder()

EvtBtoXsgammaRootFinder::~EvtBtoXsgammaRootFinder ( )
virtual

Definition at line 43 of file EvtBtoXsgammaRootFinder.cc.

43{}

Member Function Documentation

◆ GetGaussIntegFcnRoot()

double EvtBtoXsgammaRootFinder::GetGaussIntegFcnRoot ( EvtItgAbsFunction * theFunc1,
EvtItgAbsFunction * theFunc2,
double integ1Precision,
double integ2Precision,
int maxLoop1,
int maxLoop2,
double integLower,
double integUpper,
double lowerValue,
double upperValue,
double precision )

Definition at line 121 of file EvtBtoXsgammaRootFinder.cc.

124 {
125
126 // Use the bisection to find the root.
127 // Iterates until find root to the accuracy of precision
128
129 // Need to work with integrators
130 EvtItgAbsIntegrator* func1Integ =
131 new EvtItgSimpsonIntegrator( *theFunc1, integ1Precision, maxLoop1 );
132 EvtItgAbsIntegrator* func2Integ =
133 new EvtItgSimpsonIntegrator( *theFunc2, integ2Precision, maxLoop2 );
134
135 // coefficient 1 of the integrators is the root to be found
136 // need to set this to lower value to start off with
137 theFunc1->setCoeff( 1, 0, lowerValue );
138 theFunc2->setCoeff( 1, 0, lowerValue );
139
140 double f1 = func1Integ->evaluate( integLower, integUpper ) -
141 theFunc2->getCoeff( 1, 2 ) * func2Integ->evaluate( integLower, integUpper );
142 theFunc1->setCoeff( 1, 0, upperValue );
143 theFunc2->setCoeff( 1, 0, upperValue );
144 double f2 = func1Integ->evaluate( integLower, integUpper ) -
145 theFunc2->getCoeff( 1, 2 ) * func2Integ->evaluate( integLower, integUpper );
146
147 double xLower = 0.0, xUpper = 0.0;
148 double root = 0;
149
150 if ( f1 * f2 > 0.0 )
151 {
152 report( WARNING, "EvtGen" ) << "EvtBtoXsgammaRootFinder: No root in specified range !"
153 << endl;
154 return false;
155 }
156
157 // Already have root
158 if ( fabs( f1 ) < precision )
159 {
160 root = lowerValue;
161 return root;
162 }
163 if ( fabs( f2 ) < precision )
164 {
165 root = upperValue;
166 return root;
167 }
168
169 // Orient search so that f(xLower) < 0
170 if ( f1 < 0.0 )
171 {
172 xLower = lowerValue;
173 xUpper = upperValue;
174 }
175 else
176 {
177 xLower = upperValue;
178 xUpper = lowerValue;
179 }
180
181 double rootGuess = 0.5 * ( lowerValue + upperValue );
182 double dxold = fabs( upperValue - lowerValue );
183 double dx = dxold;
184
185 theFunc1->setCoeff( 1, 0, rootGuess );
186 theFunc2->setCoeff( 1, 0, rootGuess );
187 double f = func1Integ->evaluate( integLower, integUpper ) -
188 theFunc2->getCoeff( 1, 2 ) * func2Integ->evaluate( integLower, integUpper );
189
190 for ( int j = 0; j < EVTITGROOTFINDER_MAXIT; j++ )
191 {
192
193 dxold = dx;
194 dx = 0.5 * ( xUpper - xLower );
195 rootGuess = xLower + dx;
196
197 // If change in root is negligible, take it as solution.
198 if ( fabs( xLower - rootGuess ) < precision )
199 {
200 root = rootGuess;
201 return root;
202 }
203
204 theFunc1->setCoeff( 1, 0, rootGuess );
205 theFunc2->setCoeff( 1, 0, rootGuess );
206 f = func1Integ->evaluate( integLower, integUpper ) -
207 theFunc2->getCoeff( 1, 2 ) * func2Integ->evaluate( integLower, integUpper );
208
209 if ( f < 0.0 ) { xLower = rootGuess; }
210 else { xUpper = rootGuess; }
211 }
212
213 report( WARNING, "EvtGen" ) << "EvtBtoXsgammaRootFinder: Maximum number of iterations "
214 << "in EvtBtoXsgammaRootFinder::foundRoot exceeded!"
215 << " Returning false." << endl;
216 return 0;
217}
std::string root
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
TFile * f1
#define EVTITGROOTFINDER_MAXIT
ostream & report(Severity severity, const char *facility)
Definition EvtReport.cc:34
@ WARNING
Definition EvtReport.hh:50
virtual double getCoeff(int, int)=0
virtual void setCoeff(int, int, double)=0
double evaluate(double lower, double upper) const

Referenced by EvtBtoXsgammaFermiUtil::FermiGaussFuncRoot().

◆ GetRootSingleFunc()

double EvtBtoXsgammaRootFinder::GetRootSingleFunc ( const EvtItgAbsFunction * theFunc,
double functionValue,
double lowerValue,
double upperValue,
double precision )

Definition at line 45 of file EvtBtoXsgammaRootFinder.cc.

47 {
48
49 // Use the bisection to find the root.
50 // Iterates until find root to the accuracy of precision
51
52 double xLower = 0.0, xUpper = 0.0;
53 double root = 0;
54
55 double f1 = theFunc->value( lowerValue ) - functionValue;
56 double f2 = theFunc->value( upperValue ) - functionValue;
57
58 if ( f1 * f2 > 0.0 )
59 {
60 report( WARNING, "EvtGen" ) << "EvtBtoXsgammaRootFinder: No root in specified range !"
61 << endl;
62 return 0;
63 }
64
65 // Already have root
66 if ( fabs( f1 ) < precision )
67 {
68 root = lowerValue;
69 return root;
70 }
71 if ( fabs( f2 ) < precision )
72 {
73 root = upperValue;
74 return root;
75 }
76
77 // Orient search so that f(xLower) < 0
78 if ( f1 < 0.0 )
79 {
80 xLower = lowerValue;
81 xUpper = upperValue;
82 }
83 else
84 {
85 xLower = upperValue;
86 xUpper = lowerValue;
87 }
88
89 double rootGuess = 0.5 * ( lowerValue + upperValue );
90 double dxold = fabs( upperValue - lowerValue );
91 double dx = dxold;
92
93 double f = theFunc->value( rootGuess ) - functionValue;
94
95 for ( int j = 0; j < EVTITGROOTFINDER_MAXIT; j++ )
96 {
97
98 dxold = dx;
99 dx = 0.5 * ( xUpper - xLower );
100 rootGuess = xLower + dx;
101
102 // If change in root is negligible, take it as solution.
103 if ( fabs( xLower - rootGuess ) < precision )
104 {
105 root = rootGuess;
106 return root;
107 }
108
109 f = theFunc->value( rootGuess ) - functionValue;
110
111 if ( f < 0.0 ) { xLower = rootGuess; }
112 else { xUpper = rootGuess; }
113 }
114
115 report( WARNING, "EvtGen" ) << "EvtBtoXsgammaRootFinder: Maximum number of iterations "
116 << "in EvtBtoXsgammaRootFinder::foundRoot exceeded!"
117 << " Returning false." << endl;
118 return 0;
119}
virtual double value(double x) const

Referenced by EvtBtoXsgammaFermiUtil::FermiRomanFuncRoot().


The documentation for this class was generated from the following files: