BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtCubicSpline.cc
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3// Environment:
4// This software is part of the EvtGen package developed jointly
5// for the BaBar and CLEO collaborations. If you use all or part
6// of it, please give an appropriate acknowledgement.
7//
8// Copyright Information: See EvtGen/COPYRIGHT
9// Copyright (C) 1998 Caltech, UCSB
10//
11// Module: EvtCubicSpline.cc
12//
13// Description: resonance-defining class
14//
15// Modification history:
16//
17// ponyisi 18 Feb 2008 created
18//
19//------------------------------------------------------------------------
20//
21#include "EvtCubicSpline.hh"
22#include "EvtComplex.hh"
23#include "EvtConst.hh"
24#include "EvtKine.hh"
25#include "EvtPatches.hh"
26#include "EvtReport.hh"
27#include "EvtVector4R.hh"
28#include <fstream>
29#include <iostream>
30#include <math.h>
31#include <stdlib.h>
32
34vector<double> EvtCubicSpline::_mHHLimits;
35vector<ControlPoint> EvtCubicSpline::_yvalues;
36vector<ControlPoint> EvtCubicSpline::_y2values;
37
39
40// operator
41
43 if ( &n == this ) return *this;
44 _p4_p = n._p4_p;
45 _p4_d1 = n._p4_d1;
46 _p4_d2 = n._p4_d2;
47 _ampl = n._ampl;
48 _theta = n._theta;
49 /* _nPoints = n._nPoints;
50 for (int i=0;i<_nPoints;i++){
51 _mHHLimits.push_back(n._mHHLimits[i]);
52 _yvalues.push_back(n._yvalues[i]);
53 _y2values.push_back(n._y2values[i]);
54 }*/
55 return *this;
56}
57
58// constructor
59
61 const EvtVector4R& p4_d2 )
62 : _p4_p( p4_p )
63 , _p4_d1( p4_d1 )
64 , _p4_d2( p4_d2 )
65// _m1a(m1a), _m1b(m1b), _g1(g1),
66// _m2a(m2a), _m2b(m2b), _g2(g2)
67{
68 // _nPoints = 0;
69}
70
71void EvtCubicSpline::setParams( const vector<double> x, const vector<double> ym,
72 const vector<double> yp ) {
73 if ( _nPoints ) return;
74 double e1, e2, e3;
75 for ( int i = 0; i < x.size(); i++ )
76 {
77 e1 = x[i];
78 e2 = ym[i];
79 e3 = yp[i];
80 _mHHLimits.push_back( e1 );
81 _yvalues.push_back( ControlPoint( e2 * cos( e3 ), e2 * sin( e3 ) ) );
82 _y2values.push_back( ControlPoint( 0, 0 ) );
83 _nPoints++;
84 }
86}
87
88void EvtCubicSpline::setParams( const int n, const double* x, const double* ym,
89 const double* yp ) {
90 vector<double> vx, vym, vyp;
91 for ( int i = 0; i < n; i++ )
92 {
93 vx.push_back( x[i] );
94 vym.push_back( ym[i] );
95 vyp.push_back( yp[i] );
96 }
97 setParams( vx, vym, vyp );
98}
99
100/*
101void EvtCubicSpline::setParamsFromFile(const string swaveparfile, const double scale){
102 if (_nPoints) return;
103 string location = getenv("BESEVTGENROOT");
104 location += "/share/"; location += swaveparfile;
105 std::ifstream file(location.c_str());
106 std::cout<<"Reading swave parameters from file "<<location<<std::endl;
107 if(file==0){std::cout<<" EvtCubicSpline::EvtCubicSpline: swave parameter file not
108available"<<std::endl;abort();} double e1, e2, e3; while(!file.eof()){ file>>e1>>e2>>e3; if
109(e1<0) break; _mHHLimits.push_back(e1); e2 *= scale;
110 _yvalues.push_back(ControlPoint(e2*cos(e3),e2*sin(e3)));
111 _y2values.push_back(ControlPoint(0,0));
112 _nPoints ++;
113 e1 = -1;
114 }
115 file.close();
116 Complex_Derivative(_mHHLimits, _yvalues, _nPoints, _y2values);
117}*/
118
119bool EvtCubicSpline::Complex_Derivative( const vector<double>& x,
120 const vector<ControlPoint>& y, const int n,
121 vector<ControlPoint>& y2 ) {
122 int i, k;
123 ControlPoint* u = new ControlPoint[n];
124 double sig, p, qn, un;
125 ControlPoint yp1, ypn;
126 /* yp1.real = 2.*(y[1].real - y[0].real) / (x[1] - x[0]);
127 yp1.imag = 2.*(y[1].imag - y[0].imag) / (x[1] - x[0]);
128 ypn.real = 2.*(y[n-1].real - y[n-2].real) / (x[n-1] - x[n-2]);
129 ypn.imag = 2.*(y[n-1].imag - y[n-2].imag) / (x[n-1] - x[n-2]);*/
130 fprime( x, y, yp1 );
131 fprime( x, y, n, ypn );
132
133 /* The lower boundary condition is set either to be "natural" or else to have specified first
134 * derivative*/
135 if ( yp1.real > 0.99e30 )
136 {
137 y2[0].real = 0.;
138 u[0].real = 0.;
139 }
140 else
141 {
142 y2[0].real = -0.5;
143 u[0].real =
144 ( 3.0 / ( x[1] - x[0] ) ) * ( ( y[1].real - y[0].real ) / ( x[1] - x[0] ) - yp1.real );
145 }
146 if ( yp1.imag > 0.99e30 )
147 {
148 y2[0].imag = 0.;
149 u[0].imag = 0.;
150 }
151 else
152 {
153 y2[0].imag = -0.5;
154 u[0].imag =
155 ( 3.0 / ( x[1] - x[0] ) ) * ( ( y[1].imag - y[0].imag ) / ( x[1] - x[0] ) - yp1.imag );
156 }
157
158 /* This is the decomposition loop of the tridiagonal algorithm. y2 and u are used for
159 * temporary storage of the decomposed factors*/
160
161 for ( i = 1; i < n - 1; i++ )
162 {
163 sig = ( x[i] - x[i - 1] ) / ( x[i + 1] - x[i - 1] );
164 p = sig * y2[i - 1].real + 2.0;
165 y2[i].real = ( sig - 1.0 ) / p;
166 u[i].real = ( y[i + 1].real - y[i].real ) / ( x[i + 1] - x[i] ) -
167 ( y[i].real - y[i - 1].real ) / ( x[i] - x[i - 1] );
168 u[i].real = ( 6.0 * u[i].real / ( x[i + 1] - x[i - 1] ) - sig * u[i - 1].real ) / p;
169 p = sig * y2[i - 1].imag + 2.0;
170 y2[i].imag = ( sig - 1.0 ) / p;
171 u[i].imag = ( y[i + 1].imag - y[i].imag ) / ( x[i + 1] - x[i] ) -
172 ( y[i].imag - y[i - 1].imag ) / ( x[i] - x[i - 1] );
173 u[i].imag = ( 6.0 * u[i].imag / ( x[i + 1] - x[i - 1] ) - sig * u[i - 1].imag ) / p;
174 }
175
176 /* The upper boundary condition is set either to be "natural" or else to have specified first
177 * derivative*/
178
179 if ( ypn.real > 0.99e30 )
180 {
181 qn = 0.;
182 un = 0.;
183 }
184 else
185 {
186 qn = 0.5;
187 un = ( 3.0 / ( x[n - 1] - x[n - 2] ) ) *
188 ( ypn.real - ( y[n - 1].real - y[n - 2].real ) / ( x[n - 1] - x[n - 2] ) );
189 }
190 y2[n - 1].real = ( un - qn * u[n - 2].real ) / ( qn * y2[n - 2].real + 1.0 );
191 if ( ypn.imag > 0.99e30 )
192 {
193 qn = 0.;
194 un = 0.;
195 }
196 else
197 {
198 qn = 0.5;
199 un = ( 3.0 / ( x[n - 1] - x[n - 2] ) ) *
200 ( ypn.imag - ( y[n - 1].imag - y[n - 2].imag ) / ( x[n - 1] - x[n - 2] ) );
201 }
202 y2[n - 1].imag = ( un - qn * u[n - 2].imag ) / ( qn * y2[n - 2].imag + 1.0 );
203
204 /* This is the backsubstitution loop of the tridiagonal algorithm */
205
206 for ( k = n - 2; k >= 0; k-- )
207 {
208 y2[k].real = y2[k].real * y2[k + 1].real + u[k].real;
209 y2[k].imag = y2[k].imag * y2[k + 1].imag + u[k].imag;
210 }
211 delete[] u;
212 return true;
213}
214
215// amplitude function
216
218
219 // EvtComplex ampl(cos(_theta*pi180inv), sin(_theta*pi180inv));
220 // ampl *= _ampl;
221 if ( _nPoints == 0 ) return EvtComplex( 0, 0 );
222
223 // SCALARS ONLY
224 double mAB = ( _p4_d1 + _p4_d2 ).mass();
225 int khiAB = find_bin( mAB, _mHHLimits, _nPoints );
226 int kloAB = khiAB - 1;
227 double dmHH, aa, bb, aa3, bb3;
228 double pwa_coefs_real_kloAB = _yvalues[kloAB].real;
229 double pwa_coefs_imag_kloAB = _yvalues[kloAB].imag;
230 double pwa_coefs_real_khiAB = _yvalues[khiAB].real;
231 double pwa_coefs_imag_khiAB = _yvalues[khiAB].imag;
232 double pwa_coefs_prime_real_kloAB = _y2values[kloAB].real;
233 double pwa_coefs_prime_imag_kloAB = _y2values[kloAB].imag;
234 double pwa_coefs_prime_real_khiAB = _y2values[khiAB].real;
235 double pwa_coefs_prime_imag_khiAB = _y2values[khiAB].imag;
236 dmHH = _mHHLimits[khiAB] - _mHHLimits[kloAB];
237 aa = ( _mHHLimits[khiAB] - mAB ) / dmHH;
238 bb = 1 - aa;
239 aa3 = aa * aa * aa;
240 bb3 = bb * bb * bb;
241 double ret_real = aa * pwa_coefs_real_kloAB + bb * pwa_coefs_real_khiAB +
242 ( ( aa3 - aa ) * pwa_coefs_prime_real_kloAB +
243 ( bb3 - bb ) * pwa_coefs_prime_real_khiAB ) *
244 ( dmHH * dmHH ) / 6.0;
245 double ret_imag = aa * pwa_coefs_imag_kloAB + bb * pwa_coefs_imag_khiAB +
246 ( ( aa3 - aa ) * pwa_coefs_prime_imag_kloAB +
247 ( bb3 - bb ) * pwa_coefs_prime_imag_khiAB ) *
248 ( dmHH * dmHH ) / 6.0;
249 return EvtComplex( ret_real, ret_imag );
250}
double mass
const Int_t n
Double_t e1
Double_t e2
double imag(const EvtComplex &c)
static vector< ControlPoint > _yvalues
static vector< double > _mHHLimits
static int find_bin(double mass1, const vector< double > &x, const int n)
EvtCubicSpline(const EvtVector4R &p4_p, const EvtVector4R &p4_d1, const EvtVector4R &p4_d2)
virtual ~EvtCubicSpline()
EvtCubicSpline & operator=(const EvtCubicSpline &)
EvtComplex resAmpl()
const EvtVector4R & p4_p()
static vector< ControlPoint > _y2values
static void setParams(const vector< double > x, const vector< double > ym, const vector< double > yp)
static int _nPoints
const EvtVector4R & p4_d2()
static bool Complex_Derivative(const vector< double > &x, const vector< ControlPoint > &y, const int n, vector< ControlPoint > &y2)
static void fprime(const vector< double > &x, const vector< ControlPoint > &y, const int n, ControlPoint &yp2)
const EvtVector4R & p4_d1()