SANCtable.cxx

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 //-Static part-----------------------------------------------------------------
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 //-The main computation module-------------------------------------------------
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 *                            // to pbarn
00207                   nc/fc*1e0/2.0/s *
00208                   1e0/4 *                            // spin sum
00209                   (sig[i][j][1] - sig[i][j][0]) *    // |Amp|^2 - linearized
00210                   betaf/16/pi;                       // phase_space/dcos{theta}
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++)    // rotations  for tau+  see tau+  KW and SANC frames
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++)    // rotations  for tau-  see tau-  KW and SANC frames
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++)    // rotations  for tau+/tau- see reaction  KW and SANC frames
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++)    // rotations  for tau+/tau- see reaction KW and SANC frames
00241         {
00242                 R[1][j]  = -R[1][j];
00243                 R[2][j]  = -R[2][j];
00244         }
00245         /*                      
00246           printf("\n");
00247           printf("d_sigma/d_cos{theta} = %.9f \n",divv);
00248           printf("s    = %.9f \n" ,s);
00249           printf("cosf = %.9f \n",cosf);
00250           printf("\n");
00251           printf("R(i,j)= \n");
00252           printf("\n");
00253           for(int i=0;i<4;i++)
00254           {
00255             for(int j=0;j<4;j++)
00256               printf("%.5f ",R[i][j]);
00257             printf("\n");
00258           }
00259           double sinf;
00260           double MM;
00261           double xnorm;
00262           double Bench[4][4]={0.};               
00263           sinf=sqrt(1-cosf*cosf);
00264           MM=sqrt(4e0*mta*mta/s);
00265           xnorm=1+cosf*cosf + MM*MM*sinf*sinf;
00266           Bench[0][0]=(1+cosf*cosf + MM*MM*sinf*sinf)/xnorm;
00267           Bench[1][1]=(-(1- MM*MM)*sinf*sinf)/xnorm;
00268           Bench[2][2]=( (1+ MM*MM)*sinf*sinf)/xnorm;
00269           Bench[3][3]=(1+cosf*cosf - MM*MM*sinf*sinf)/xnorm;
00270           Bench[2][3]=(2*MM*sinf*cosf)/xnorm;
00271           Bench[3][2]=(2*MM*sinf*cosf)/xnorm;
00272           printf("\n");
00273           printf("Bench(i,j)= \n");
00274           printf("\n");
00275 
00276           for(int i=0;i<4;i++)
00277           {
00278             for(int j=0;j<4;j++)
00279               printf("%.5f ",Bench[i][j]);
00280             printf("\n");
00281           }
00282 
00283           printf("\n");
00284           printf("   \n");
00285           printf("Bench(i,j)=R(i,j) at low energies, where ew corr and Z contribute little \n");
00286           printf("\n");
00287                   
00288         */
00289 
00290         return divv;
00291 }
Generated on Sun Oct 20 20:24:10 2013 for C++InterfacetoTauola by  doxygen 1.6.3