5 #include "StSvtTable.hh"
9 StSvtTable::StSvtTable()
18 StSvtTable::~StSvtTable()
23 void StSvtTable::setFreq(
int i)
25 double num = 0.0, width = 0.0;
27 for(
int j = 0; j < 1000; j++)
29 num = j*0.001 + (double)i;
30 for(
int k = 0; k < 2000; k++)
36 mFreq[j][k] = prob1(num,width);
37 if(i == 1 && j == 33 && k == 132)
38 cout<<
"mFreq"<<
" ["<<j<<
"]"<<
" ["<<k<<
"] = "<<mFreq[j][k]<<
"\t";
44 double StSvtTable::getFreq(
int j,
int k)
46 double freq = mFreq[j][k];
51 double StSvtTable::prob1(
double num ,
double sigma)
53 num = num/(::sqrt(2)*sigma);
55 double fraction = 0.5*(1 + erf(num));
62 double StSvtTable::prob2(
double num ,
double sigma)
64 double mSum = 0, mErrf = 0;
65 double mFactorial = 0;
66 double mPowerTerm = 0;
67 double mPowerTermSquared = 0;
68 double mCountTerm = 0;
70 if(fabs(num) < 5*sigma)
72 for(
int j = 0; j<=120; j++)
78 mPowerTerm = fabs(num)/(::sqrt(2)*sigma);
79 mPowerTermSquared = mPowerTerm*mPowerTerm;
80 mCountTerm = mPowerTerm;
85 mFactorial = (double)j*mFactorial;
86 mPowerTerm = (mPowerTermSquared)*(
double)fabs(mPowerTerm);
89 mPowerTerm = (-1)*mPowerTerm;
91 mCountTerm =(mPowerTerm /( mFactorial*(double)(2*j + 1)));
99 mErrf = (2.0/::sqrt(acos(-1.)))*mSum;
102 mErrf = (-1.0)*mErrf;
105 else if(num > 5*sigma)
110 return 0.5*(1.0 + mErrf);