SANCinterface.c

00001 #include <math.h>
00002 #include <stdio.h>
00003 #include <time.h>
00004 
00005 extern void upup_(int *L1,int *L2, int *L3,int *L4,double *s,double *t,double *u,int *iz,double *har,double *hai);
00006 extern void downdown_(int *L1,int *L2, int *L3,int *L4,double *s,double *t,double *u,int *iz,double *har,double *hai);
00007 extern void flagset_(int *iqedx,int *iewx,int *ibornx,int *gfschemex,int *ifggx,double *ncx,double *fcx,double *tlmu2x);
00008 extern void paraget_(double  *mtax, double  *conhcx, double *pix);
00009 extern void printconsts_(int *pmg);
00010 
00011 
00012 int iqed=0,iew=1,iborn=0,gfscheme=0,ifgg=1;
00013 double nc=1.0,fc=3.0,tlmu2=1e-5;
00014 int buf=0;
00015 double R[4][4];
00016 double divv;
00017 double borndivv=123.456;
00018 
00019 struct compl {double im,re;};
00020 
00021 struct compl mul(struct compl x, struct compl y)
00022 {
00023   struct compl c ;
00024   c.re=x.re*y.re-x.im*y.im;
00025   c.im=x.re*y.im+x.im*y.re;
00026   return c;
00027 }
00028 
00029 struct compl conju(struct compl x)
00030 {
00031   struct compl c ;
00032   c.re=x.re;
00033   c.im=-x.im;
00034   return c;
00035 }
00036 
00037 double abso(struct compl x)
00038 {
00039   return sqrt(x.re*x.re+x.im*x.im);
00040 }
00041 
00042 
00043 void Rcalc(int flav, double sloop,double costhetloop)
00044 {
00045         int L1,L2,L3,L4,iz,i,j,M3,M4;
00046         double s,t,u;
00047         double cosf,betaf,har,hai,MM,sinf,xnorm,xx;
00048 
00049         double mta,conhc,pi;
00050 
00051         double sum,sig[4][4][2], Bench[4][4]={0};
00052         double ha[2];
00053         struct compl amp[2][2][2][2][2]={0}, sigma[4][2][2]={0}, c;
00054         sigma[0][0][0].re=1;
00055         sigma[0][1][1].re=1;
00056 
00057         sigma[1][0][1].re=1;
00058         sigma[1][1][0].re=1;
00059 
00060         sigma[2][0][1].im=-1;
00061         sigma[2][1][0].im= 1;
00062 
00063         sigma[3][0][0].re=1;
00064         sigma[3][1][1].re=-1;
00065 
00066         s=sloop;
00067         cosf=costhetloop;
00068 // --------------------------
00069         paraget_(&mta,&conhc,&pi);
00070         betaf = sqrt(1e0-4e0*mta*mta/s);
00071         t = mta*mta - s/2*(1e0-betaf*cosf);
00072         u = mta*mta - s/2*(1e0+betaf*cosf);
00073         for(iz = 0;iz<2;iz++)
00074         {
00075                 for(L1=1;L1<=2;L1++)
00076                 {
00077                         for(L2=1;L2<=2;L2++)
00078                         {
00079                                 for(L3=1;L3<=2;L3++)
00080                                 {
00081                                         for(L4=1;L4<=2;L4++)
00082                                         {
00083                                           if(flav==1)   downdown_(&L1,&L2,&L3,&L4,&s,&t,&u,&iz,&har,&hai);
00084                                           else          upup_(&L1,&L2,&L3,&L4,&s,&t,&u,&iz,&har,&hai);
00085                                                 amp[L1-1][L2-1][L3-1][L4-1][iz].im=hai;
00086                                                 amp[L1-1][L2-1][L3-1][L4-1][iz].re=har;
00087                                         }
00088                                 }
00089                         }
00090                 }
00091         }
00092         for(i=0;i<4;i++){
00093         for(j=0;j<4;j++){
00094         for(iz = 0;iz<2;iz++)
00095         {
00096                 sum = 0e0;
00097                 for(L1=1;L1<=2;L1++)
00098                 {
00099                         for(L2=1;L2<=2;L2++)
00100                         {
00101                                 for(L3=1;L3<=2;L3++)
00102                                 {
00103                                         for(L4=1;L4<=2;L4++)
00104                                         for(M3=1;M3<=2;M3++)
00105                                         for(M4=1;M4<=2;M4++)
00106                                         {       
00107                                           c=mul(mul(mul(amp[L1-1][L2-1][L3-1][L4-1][iz],conju(amp[L1-1][L2-1][M3-1][M4-1][iz])),
00108                                                     sigma[i][L3-1][M3-1]),(sigma[j][M4-1][L4-1])); 
00109                                           sum=sum+ c.re;
00110                                         }
00111                                 }
00112                         }
00113                 }
00114                 sig[i][j][iz]=sum;
00115         }
00116         R[i][j] = conhc *                            // to pbarn
00117                   nc/fc*1e0/2.0/s *
00118                   1e0/4 *                            // spin sum
00119                   (sig[i][j][1] - sig[i][j][0]) *    // |Amp|^2 - linearized
00120                   betaf/16/pi;                       // phase_space/dcos{theta}
00121         if(i==0 && j==0)
00122             divv=R[0][0];
00123 
00124         R[i][j]=R[i][j]/divv;  
00125                 if(i!=0) R[i][j] =-  R[i][j]; // necessary for tau- but further investigation needed
00126 
00127         }
00128         }
00129 
00130         /*      // there should be rotation like this one, however we do not need that. 
00131                 // Wrong definition of Pauli matrix for antiparticle, missing conjugation?
00132         for(j=0;j<4;j++)
00133           {
00134             xx=       R[1][j];
00135            R[3][j] =-  R[3][j];
00136            R[1][j] =  -xx;
00137           }
00138         
00139         */
00140         
00141                                                 
00142         for(i=0;i<4;i++)      // rotations  around z axis  must be checked
00143         {
00144           xx=       R[i][1];
00145           R[i][1] =-  R[i][2];
00146           R[i][2] =  xx;
00147         }
00148         
00149         
00150         for(j=0;j<4;j++)    // rotations  around z axis  must be checked
00151         {
00152           xx=       R[1][j];
00153           R[1][j] =  R[2][j];
00154           R[2][j] =-  xx;
00155         }
00156                 
00157                                 
00158         /*              
00159           printf("\n");
00160           printf("d_sigma/d_cos{theta} = %.9f \n",divv);
00161           printf("\n");
00162           printf("R(i,j)= \n");
00163           printf("\n");
00164           for(i=0;i<4;i++)
00165           {
00166             for(j=0;j<4;j++)
00167               printf("%.5f ",R[i][j]);
00168             printf("\n");
00169           }
00170          
00171           sinf=sqrt(1-cosf*cosf);
00172           MM=sqrt(4e0*mta*mta/s);
00173           xnorm=1+cosf*cosf + MM*MM*sinf*sinf;
00174           Bench[0][0]=(1+cosf*cosf + MM*MM*sinf*sinf)/xnorm;
00175           Bench[1][1]=(-(1- MM*MM)*sinf*sinf)/xnorm;
00176           Bench[2][2]=( (1+ MM*MM)*sinf*sinf)/xnorm;
00177           Bench[3][3]=(1+cosf*cosf - MM*MM*sinf*sinf)/xnorm;
00178           Bench[2][3]=(2*MM*sinf*cosf)/xnorm;
00179           Bench[3][2]=(2*MM*sinf*cosf)/xnorm;
00180           printf("\n");
00181           printf("Bench(i,j)= \n");
00182           printf("\n");
00183 
00184           for(i=0;i<4;i++)
00185           {
00186             for(j=0;j<4;j++)
00187               printf("%.5f ",Bench[i][j]);
00188             printf("\n");
00189           }
00190 
00191           printf("\n");
00192           printf("   \n");
00193           printf("Bench(i,j)=R(i,j) at low energies, where ew corr and Z contribute little \n");
00194           printf("\n");
00195         */        
00196 
00197 }
00198 
00199 int main(int argc, char **argv){
00200   double sloop=100;
00201   double costhetloop=0.0;
00202   int i,j,k,l;
00203   int NS1=100, NS2=100, NS3=100, NCOS=21;
00204   double smin1=log(6*6);
00205   double smax1=log(17000*17000);
00206 
00207   double smin2=85*85;
00208   double smax2=110*110;
00209 
00210   double smin3=160*160;
00211   double smax3=220*220;
00212   int    flav;
00213   double step;
00214   FILE *f=NULL,*d=NULL,*dd=NULL;
00215   unsigned char c;
00216   char   ftime[255],path[255];
00217   time_t utime;
00218   if (argc > 1) flav=atoi(argv[1]);
00219   else flav=1;
00220   if (flav==1) f=fopen("table1-1.txt","w");
00221   else         f=fopen("table2-2.txt","w");
00222 
00223   flagset_(&iqed,&iew,&iborn,&gfscheme,&ifgg,&nc,&fc,&tlmu2);
00224   printconsts_(&buf);
00225   dd=fopen("SancLib_v1_02/lib.txt","r");
00226   if(!dd) { printf("No info file  on electrowek library SANC (file SancLib_v1_02/lib.txt missing), we better stop \n"); return -1; }
00227   d=fopen("var.dump","r");
00228   if(!d) { printf("No initialization variables of SANC (file var.dump missing), we better stop \n"); return -1; }
00229 
00230   fprintf(f,"Dimensions: %i %i %i %i\n",NS1,NS2,NS3,NCOS);
00231   fprintf(f,"Ranges: %.5f %.5f %.5f %.5f %.5f %.5f \n",smin1,smax1,smin2,smax2,smin3,smax3);
00232   getcwd(path,255);
00233   time(&utime);
00234   strftime(ftime,255,"%d %b %Y, %H:%M:%S, GMT%z",localtime(&utime));
00235   fprintf(f,"Timestamp: %s\n",ftime);
00236   fprintf(f,"Path: %s\n\n",path);
00237 
00238   while(1)
00239   {
00240     c=0;
00241     fscanf(dd,"%c",&c);
00242     if(c==0) break;
00243     fprintf(f,"%c",c);
00244     }
00245 
00246   while(1)
00247   {
00248     c=0;
00249     fscanf(d,"%c",&c);
00250     if(c==0) break;
00251     fprintf(f,"%c",c);
00252     }
00253   fprintf(f,"\nBeginRange1\n");  
00254   printf("\nBeginRange1\n");  
00255 
00256   step=(smax1-smin1)/(NS1-1);
00257   for(i=0;i<NS1;i++)
00258   {
00259     sloop=exp(smin1+i*step);
00260     printf("%.5f \n",sloop);
00261     for(j=0;j<NCOS;j++)
00262     {
00263       costhetloop=-1.+1.0/NCOS+j*2./(NCOS);
00264 
00265       iew=0;
00266       flagset_(&iqed,&iew,&iborn,&gfscheme,&ifgg,&nc,&fc,&tlmu2);
00267       Rcalc(flav,sloop,costhetloop);
00268       borndivv=divv;
00269 
00270       iew=1;
00271       flagset_(&iqed,&iew,&iborn,&gfscheme,&ifgg,&nc,&fc,&tlmu2);
00272       Rcalc(flav,sloop,costhetloop);
00273 
00274       for(k=0;k<4;k++)
00275         for(l=0;l<4;l++)
00276           fprintf(f,"%.5f ",R[k][l]);
00277       fprintf(f,"%.8f ",divv);
00278       fprintf(f,"%.8f\n",borndivv);
00279       // fprintf(f,"%.5f \n",sloop);
00280     }
00281   }
00282 
00283 
00284   fprintf(f,"\nBeginRange2\n");  
00285   printf("\nBeginRange2\n");  
00286 
00287   step=(smax2-smin2)/(NS2-1);
00288   for(i=0;i<NS2;i++)
00289   {
00290     sloop=(smin2+i*step);
00291     printf("%.5f \n",sloop);
00292     for(j=0;j<NCOS;j++)
00293     {
00294       costhetloop=-1.+1.0/NCOS+j*2./(NCOS);
00295  
00296       iew=0;
00297       flagset_(&iqed,&iew,&iborn,&gfscheme,&ifgg,&nc,&fc,&tlmu2);
00298       Rcalc(flav,sloop,costhetloop);
00299       borndivv=divv;
00300 
00301       iew=1;
00302       flagset_(&iqed,&iew,&iborn,&gfscheme,&ifgg,&nc,&fc,&tlmu2);
00303       Rcalc(flav,sloop,costhetloop);
00304 
00305       for(k=0;k<4;k++)
00306         for(l=0;l<4;l++)
00307           fprintf(f,"%.5f ",R[k][l]);
00308       fprintf(f,"%.5f ",divv);
00309       fprintf(f,"%.5f \n",borndivv);
00310     }
00311   }
00312 
00313 
00314   fprintf(f,"\nBeginRange3\n");  
00315   printf("\nBeginRange3\n");  
00316 
00317   step=(smax3-smin3)/(NS3-1);
00318   for(i=0;i<NS3;i++)
00319   {
00320     sloop=(smin3+i*step);
00321     printf("%.5f \n",sloop);
00322     for(j=0;j<NCOS;j++)
00323     {
00324       costhetloop=-1.+1.0/NCOS+j*2./(NCOS);
00325 
00326       iew=0;
00327       flagset_(&iqed,&iew,&iborn,&gfscheme,&ifgg,&nc,&fc,&tlmu2);
00328       Rcalc(flav,sloop,costhetloop);
00329       borndivv=divv;
00330 
00331       iew=1;
00332       flagset_(&iqed,&iew,&iborn,&gfscheme,&ifgg,&nc,&fc,&tlmu2);
00333       Rcalc(flav,sloop,costhetloop);
00334 
00335       for(k=0;k<4;k++)
00336         for(l=0;l<4;l++)
00337           fprintf(f,"%.5f ",R[k][l]);
00338       fprintf(f,"%.5f ",divv);
00339       fprintf(f,"%.5f \n",borndivv);
00340     }
00341   }
00342   fprintf(f,"End\n");
00343   fclose(f);
00344   return 0;
00345 }
Generated on Sun Oct 20 20:24:10 2013 for C++InterfacetoTauola by  doxygen 1.6.3