BOSS 7.1.1
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//
22#include <math.h>
24#include "EvtGenBase/EvtKine.hh"
29#include <fstream>
30#include <iostream>
31#include <stdlib.h>
32
34vector<double> EvtCubicSpline::_mHHLimits;
35vector<ControlPoint> EvtCubicSpline::_yvalues;
36vector<ControlPoint> EvtCubicSpline::_y2values;
37
39
40//operator
41
43{
44 if ( &n == this ) return *this;
45 _p4_p = n._p4_p;
46 _p4_d1 = n._p4_d1;
47 _p4_d2 = n._p4_d2;
48 _ampl = n._ampl;
49 _theta = n._theta;
50/* _nPoints = n._nPoints;
51 for (int i=0;i<_nPoints;i++){
52 _mHHLimits.push_back(n._mHHLimits[i]);
53 _yvalues.push_back(n._yvalues[i]);
54 _y2values.push_back(n._y2values[i]);
55 }*/
56 return *this;
57}
58
59//constructor
60
62 const EvtVector4R& p4_d2
63 ):
64 _p4_p(p4_p),_p4_d1(p4_d1), _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, const vector<double> yp){
72 if (_nPoints) return;
73 double e1, e2, e3;
74 for (int i=0;i<x.size();i++){
75 e1 = x[i]; e2 = ym[i]; e3 = yp[i];
76 _mHHLimits.push_back(e1);
77 _yvalues.push_back(ControlPoint(e2*cos(e3),e2*sin(e3)));
78 _y2values.push_back(ControlPoint(0,0));
79 _nPoints ++;
80 }
82}
83
84void EvtCubicSpline::setParams(const int n, const double* x, const double* ym, const double* yp){
85 vector<double> vx, vym, vyp;
86 for (int i=0;i<n;i++){
87 vx.push_back(x[i]);
88 vym.push_back(ym[i]);
89 vyp.push_back(yp[i]);
90 }
91 setParams(vx, vym, vyp);
92}
93
94/*
95void EvtCubicSpline::setParamsFromFile(const string swaveparfile, const double scale){
96 if (_nPoints) return;
97 string location = getenv("BESEVTGENROOT");
98 location += "/share/"; location += swaveparfile;
99 std::ifstream file(location.c_str());
100 std::cout<<"Reading swave parameters from file "<<location<<std::endl;
101 if(file==0){std::cout<<" EvtCubicSpline::EvtCubicSpline: swave parameter file not available"<<std::endl;abort();}
102 double e1, e2, e3;
103 while(!file.eof()){
104 file>>e1>>e2>>e3;
105 if (e1<0) break;
106 _mHHLimits.push_back(e1);
107 e2 *= scale;
108 _yvalues.push_back(ControlPoint(e2*cos(e3),e2*sin(e3)));
109 _y2values.push_back(ControlPoint(0,0));
110 _nPoints ++;
111 e1 = -1;
112 }
113 file.close();
114 Complex_Derivative(_mHHLimits, _yvalues, _nPoints, _y2values);
115}*/
116
117bool EvtCubicSpline::Complex_Derivative(const vector<double>& x, const vector<ControlPoint>& y, const int n, vector<ControlPoint> &y2){
118 int i,k;
119 ControlPoint *u = new ControlPoint[n];
120 double sig,p,qn,un;
121 ControlPoint yp1, ypn;
122/* yp1.real = 2.*(y[1].real - y[0].real) / (x[1] - x[0]);
123 yp1.imag = 2.*(y[1].imag - y[0].imag) / (x[1] - x[0]);
124 ypn.real = 2.*(y[n-1].real - y[n-2].real) / (x[n-1] - x[n-2]);
125 ypn.imag = 2.*(y[n-1].imag - y[n-2].imag) / (x[n-1] - x[n-2]);*/
126 fprime( x, y,yp1);
127 fprime( x, y,n,ypn);
128
129 /* The lower boundary condition is set either to be "natural" or else to have specified first derivative*/
130 if(yp1.real > 0.99e30) {
131 y2[0].real = 0.;
132 u[0].real = 0.;
133 }
134 else{
135 y2[0].real=-0.5;
136 u[0].real=(3.0/(x[1]-x[0]))*((y[1].real-y[0].real)/(x[1]-x[0])-yp1.real);
137 }
138 if(yp1.imag > 0.99e30) {
139 y2[0].imag = 0.;
140 u[0].imag = 0.;
141 }
142 else{
143 y2[0].imag=-0.5;
144 u[0].imag=(3.0/(x[1]-x[0]))*((y[1].imag-y[0].imag)/(x[1]-x[0])-yp1.imag);
145 }
146
147
148/* This is the decomposition loop of the tridiagonal algorithm. y2 and u are used for temporary storage of the decomposed factors*/
149
150 for(i=1;i<n-1;i++){
151 sig=(x[i]-x[i-1])/(x[i+1]-x[i-1]);
152 p=sig*y2[i-1].real+2.0;
153 y2[i].real=(sig-1.0)/p;
154 u[i].real=(y[i+1].real-y[i].real)/(x[i+1]-x[i]) - (y[i].real-y[i-1].real)/(x[i]-x[i-1]);
155 u[i].real=(6.0*u[i].real/(x[i+1]-x[i-1])-sig*u[i-1].real)/p;
156 p=sig*y2[i-1].imag+2.0;
157 y2[i].imag=(sig-1.0)/p;
158 u[i].imag=(y[i+1].imag-y[i].imag)/(x[i+1]-x[i]) - (y[i].imag-y[i-1].imag)/(x[i]-x[i-1]);
159 u[i].imag=(6.0*u[i].imag/(x[i+1]-x[i-1])-sig*u[i-1].imag)/p;
160 }
161
162 /* The upper boundary condition is set either to be "natural" or else to have specified first derivative*/
163
164 if(ypn.real > 0.99e30) {
165 qn = 0.;
166 un = 0.;
167 }
168 else{
169 qn=0.5;
170 un=(3.0/(x[n-1]-x[n-2]))*(ypn.real-(y[n-1].real-y[n-2].real)/(x[n-1]-x[n-2]));
171 }
172 y2[n-1].real=(un-qn*u[n-2].real)/(qn*y2[n-2].real+1.0);
173 if(ypn.imag > 0.99e30) {
174 qn = 0.;
175 un = 0.;
176 }
177 else{
178 qn=0.5;
179 un=(3.0/(x[n-1]-x[n-2]))*(ypn.imag-(y[n-1].imag-y[n-2].imag)/(x[n-1]-x[n-2]));
180 }
181 y2[n-1].imag=(un-qn*u[n-2].imag)/(qn*y2[n-2].imag+1.0);
182
183 /* This is the backsubstitution loop of the tridiagonal algorithm */
184
185 for(k=n-2;k>=0;k--) {
186 y2[k].real=y2[k].real*y2[k+1].real+u[k].real;
187 y2[k].imag=y2[k].imag*y2[k+1].imag+u[k].imag;
188 }
189 delete [] u;
190 return true;
191}
192
193//amplitude function
194
196
197 // EvtComplex ampl(cos(_theta*pi180inv), sin(_theta*pi180inv));
198 // ampl *= _ampl;
199 if (_nPoints ==0) return EvtComplex(0,0);
200
201 // SCALARS ONLY
202 double mAB = (_p4_d1+_p4_d2).mass();
203 int khiAB = find_bin(mAB, _mHHLimits, _nPoints);
204 int kloAB = khiAB -1 ;
205 double dmHH, aa, bb, aa3, bb3;
206 double pwa_coefs_real_kloAB = _yvalues[kloAB].real;
207 double pwa_coefs_imag_kloAB = _yvalues[kloAB].imag;
208 double pwa_coefs_real_khiAB = _yvalues[khiAB].real;
209 double pwa_coefs_imag_khiAB = _yvalues[khiAB].imag;
210 double pwa_coefs_prime_real_kloAB = _y2values[kloAB].real;
211 double pwa_coefs_prime_imag_kloAB = _y2values[kloAB].imag;
212 double pwa_coefs_prime_real_khiAB = _y2values[khiAB].real;
213 double pwa_coefs_prime_imag_khiAB = _y2values[khiAB].imag;
214 dmHH = _mHHLimits[khiAB] - _mHHLimits[kloAB];
215 aa = ( _mHHLimits[khiAB] - mAB )/dmHH;
216 bb = 1 - aa;
217 aa3 = aa * aa * aa; bb3 = bb * bb * bb;
218 double ret_real = aa * pwa_coefs_real_kloAB + bb * pwa_coefs_real_khiAB + ((aa3 - aa)*pwa_coefs_prime_real_kloAB + (bb3 - bb) * pwa_coefs_prime_real_khiAB) * (dmHH*dmHH)/6.0;
219 double ret_imag = aa * pwa_coefs_imag_kloAB + bb * pwa_coefs_imag_khiAB + ((aa3 - aa)*pwa_coefs_prime_imag_kloAB + (bb3 - bb) * pwa_coefs_prime_imag_khiAB) * (dmHH*dmHH)/6.0;
220 return EvtComplex(ret_real,ret_imag);
221}
double sin(const BesAngle a)
Definition BesAngle.h:210
double cos(const BesAngle a)
Definition BesAngle.h:213
double mass
const Int_t n
Double_t x[10]
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()
static vector< ControlPoint > _y2values
static void setParams(const vector< double > x, const vector< double > ym, const vector< double > yp)
static int _nPoints
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)
double y[1000]