00001 #include "SANCtable.h"
00002
00003 int SANCtable::ns1=0,SANCtable::ns2=0,SANCtable::ns3=0,SANCtable::ncos=0;
00004 double SANCtable::smin1=0,SANCtable::smax1=0;
00005 double SANCtable::smin2=0,SANCtable::smax2=0;
00006 double SANCtable::smin3=0,SANCtable::smax3=0;
00007 int SANCtable::iqed=0,SANCtable::iew=0,SANCtable::iborn=0;
00008 int SANCtable::gfscheme=0,SANCtable::ifgg=0;
00009 double SANCtable::nc=0,SANCtable::fc=0,SANCtable::tlmu2=0;
00010
00011
00012
00013
00014 void SANCtable::setDimensions(int n1, int n2, int n3, int nc)
00015 {
00016 ns1=n1;
00017 ns2=n2;
00018 ns3=n3;
00019 ncos=nc;
00020 }
00021 void SANCtable::setRanges(double sn1, double sx1, double sn2, double sx2, double sn3, double sx3)
00022 {
00023 smin1=sn1*sn1;
00024 smax1=sx1*sx1;
00025 smin2=sn2*sn2;
00026 smax2=sx2*sx2;
00027 smin3=sn3*sn3;
00028 smax3=sx3*sx3;
00029 }
00030 void SANCtable::setFlags()
00031 {
00032 iqed=0;iew=1;iborn=0;gfscheme=0;ifgg=1;
00033 nc=1.0;fc=3.0;tlmu2=1e-5;
00034 flagset_(&iqed,&iew,&iborn,&gfscheme,&ifgg,&nc,&fc,&tlmu2);
00035 int buf=0;
00036 printconsts_(&buf);
00037 }
00038
00039
00040
00041 void SANCtable::setFixedLength(int prc)
00042 {
00043 if(prc==0)
00044 {
00045 f.precision(6);
00046 f.unsetf(ios::fixed);
00047 }
00048 else
00049 {
00050 f.precision(prc);
00051 f.setf(ios::fixed);
00052 }
00053 }
00054
00055 bool SANCtable::addHeader()
00056 {
00057 char path[255],ftime[255];
00058 time_t utime;
00059 if(ns1==0 || smin1==0) return false;
00060 f<<"Dimensions: "<<ns1<<" "<<ns2<<" "<<ns3<<" "<<ncos<<endl;
00061 f<<"Ranges: "<<log(smin1)<<" "<<log(smax1)<<" "<<smin2<<" "<<smax2<<" "<<smin3<<" "<<smax3<<endl;
00062 getcwd(path,255);
00063 time(&utime);
00064 strftime(ftime,255,"%d %b %Y, %H:%M:%S, GMT%z",localtime(&utime));
00065 f<<"Timestamp: "<<ftime<<endl;
00066 f<<"Path: "<<path<<endl<<endl;
00067 return true;
00068 }
00069
00070 bool SANCtable::addFile(char *name)
00071 {
00072 ifstream d(name);
00073 unsigned char c;
00074 if(!d.is_open()) return false;
00075 while(!d.eof())
00076 {
00077 d>>noskipws>>c;
00078 f.put(c);
00079 }
00080 return true;
00081 }
00082
00083 void SANCtable::addRange(int rangeNo,bool isLog)
00084 {
00085 double min=0,max=0,steps=0;
00086 ofstream::fmtflags last = cout.setf(ios::fixed);
00087 f<<"\nBeginRange"<<rangeNo<<endl;
00088 cout<<"\nBeginRange"<<rangeNo<<endl;
00089 switch(rangeNo)
00090 {
00091 case 1: min=smin1; max=smax1; steps=ns1; break;
00092 case 2: min=smin2; max=smax2; steps=ns2; break;
00093 case 3: min=smin3; max=smax3; steps=ns3; break;
00094 }
00095 double step= (isLog) ? (log(max)-log(min))/(steps-1) : (max-min)/(steps-1);
00096 double sloop=0;
00097 for(int i=0;i<steps;i++)
00098 {
00099 sloop= (isLog) ? exp(log(min)+i*step) : min+i*step;
00100 cout<<sloop<<endl;
00101 for(int j=0;j<ncos;j++)
00102 {
00103 double costhetloop=-1.+1.0/ncos+j*2./ncos;
00104 iew=0;
00105 flagset_(&iqed,&iew,&iborn,&gfscheme,&ifgg,&nc,&fc,&tlmu2);
00106 double borndivv = Rcalc(flav,sloop,costhetloop);
00107
00108 iew = (born) ? 0 : 1;
00109 flagset_(&iqed,&iew,&iborn,&gfscheme,&ifgg,&nc,&fc,&tlmu2);
00110 double divv = Rcalc(flav,sloop,costhetloop);
00111
00112 for(int k=0;k<4;k++)
00113 for(int l=0;l<4;l++)
00114 f<<R[k][l]<<" ";
00115 f<<divv<<" "<<borndivv<<endl;
00116 }
00117 }
00118 cout.flags(last);
00119 }
00120
00121 void SANCtable::open(char *name)
00122 {
00123 f.open(name);
00124 isOpen = f.is_open();
00125 }
00126
00127 void SANCtable::close()
00128 {
00129 f<<"End"<<endl;
00130 f.close();
00131 isOpen=false;
00132 }
00133
00134
00135
00136 double SANCtable::Rcalc(int flav, double s,double cosf)
00137 {
00138 double sig[4][4][2],sum=0.,divv=0.;
00139 complex<double> amp[2][2][2][2][2]={0}, sigma[4][2][2]={0}, c;
00140
00141 sigma[0][0][0] = complex<double>(1,0);
00142 sigma[0][1][1] = complex<double>(1,0);
00143
00144 sigma[1][0][1] = complex<double>(1,0);
00145 sigma[1][1][0] = complex<double>(1,0);
00146
00147 sigma[2][0][1] = complex<double>(0,-1);
00148 sigma[2][1][0] = complex<double>(0,1);
00149
00150 sigma[3][0][0] = complex<double>(1,0);
00151 sigma[3][1][1] = complex<double>(-1,0);
00152
00153 double mta,conhc,pi;
00154 paraget_(&mta,&conhc,&pi);
00155
00156 double betaf = sqrt(1e0-4e0*mta*mta/s);
00157 double t = mta*mta - s/2*(1e0-betaf*cosf);
00158 double u = mta*mta - s/2*(1e0+betaf*cosf);
00159 for(int iz = 0;iz<2;iz++)
00160 {
00161 for(int L1=1;L1<=2;L1++)
00162 {
00163 for(int L2=1;L2<=2;L2++)
00164 {
00165 for(int L3=1;L3<=2;L3++)
00166 {
00167 for(int L4=1;L4<=2;L4++)
00168 {
00169 double har=0,hai=0;
00170 if(flav==1) downdown_(&L1,&L2,&L3,&L4,&s,&t,&u,&iz,&har,&hai);
00171 else upup_(&L1,&L2,&L3,&L4,&s,&t,&u,&iz,&har,&hai);
00172 amp[L1-1][L2-1][L3-1][L4-1][iz] = complex<double>(har,hai);
00173 }
00174 }
00175 }
00176 }
00177 }
00178
00179 for(int i=0;i<4;i++){
00180 for(int j=0;j<4;j++){
00181 for(int iz = 0;iz<2;iz++)
00182 {
00183 sum = 0.0;
00184 for(int L1=1;L1<=2;L1++)
00185 {
00186 for(int L2=1;L2<=2;L2++)
00187 {
00188 for(int L3=1;L3<=2;L3++)
00189 {
00190 for(int L4=1;L4<=2;L4++)
00191 for(int M3=1;M3<=2;M3++)
00192 for(int M4=1;M4<=2;M4++)
00193 {
00194 c = amp[L1-1][L2-1][L3-1][L4-1][iz] *
00195 conj(amp[L1-1][L2-1][M3-1][M4-1][iz]) *
00196 sigma[i][M3-1][L3-1] *
00197 sigma[j][M4-1][L4-1];
00198 sum+=real(c);
00199 }
00200 }
00201 }
00202 }
00203 sig[i][j][iz]=sum;
00204 }
00205
00206 R[i][j] = conhc *
00207 nc/fc*1e0/2.0/s *
00208 1e0/4 *
00209 (sig[i][j][1] - sig[i][j][0]) *
00210 betaf/16/pi;
00211
00212 if(i==0 && j==0) divv=R[0][0];
00213
00214 R[i][j]=R[i][j]/divv;
00215
00216 }
00217 }
00218
00219
00220 for(int i=0;i<4;i++)
00221 {
00222 double xx= R[i][1];
00223 R[i][1] = R[i][2];
00224 R[i][2] = -xx;
00225 }
00226
00227 for(int j=0;j<4;j++)
00228 {
00229 double xx= R[1][j];
00230 R[1][j] = -R[2][j];
00231 R[2][j] = -xx;
00232 R[3][j] = -R[3][j];
00233 }
00234 for(int i=0;i<4;i++)
00235 {
00236 R[i][1] = -R[i][1];
00237 R[i][2] = -R[i][2];
00238 }
00239
00240 for(int j=0;j<4;j++)
00241 {
00242 R[1][j] = -R[1][j];
00243 R[2][j] = -R[2][j];
00244 }
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290 return divv;
00291 }