Esempio n. 1
0
static int restrict_p(int y0, int anti, char * mess, char * hlp, 
char *  inputstr, whohow  liminsp)
{ 
   int m, j, k;
   int ntot;

   char ** items;   
   char *errpos=NULL;

   int r; 

do{
    for(r=1;r!=KB_ENTER;) 
    { 
       r=input(y0, hlp,  mess,inputstr, errpos? 1+errpos-inputstr:1,SSTRLEN);
       if(r==KB_ESC) return 1;
    }
    trim(inputstr);
    nilprtcl(liminsp);
    ntot=0;

    items=stritems(",",inputstr);
    for(m=0 ; items[m]; m++)
    {  char frgm[100];
       char *n;
      sscanf(items[m],"%[^,]",frgm);       

      if(n=strstr(frgm,"!="))
      { if(!anti) {errTxt="wrong restriction"; break;}
        if(sscanf(n+2,"%d",&k)!=1) {errTxt="wrong number"; break;}
        else {n[0]=0; k++;  k=-k;}
      }
      else if(n=strstr(frgm,">"))
      {
        if(sscanf(n+1,"%d",&k)!=1) {errTxt="wrong number"; break;}
        else {n[0]=0;k++;}
      }
      else k=1;
      trim(frgm);

      locateinbase(frgm,&j);
      if ((j == 0) || (!anti&&pseudop(j)))
      {  errTxt="wrong limit statement";
         break;
      }
      ntot++;
      if(ntot>=whohowMAX) { errTxt="Too many items"; break;}
      addlim(liminsp,j,k,anti);
    }
    errpos=items[m];
    free(items);
  }while(errpos);
   return 0;
}
Esempio n. 2
0
static void  make_infbasis(void)
{
   int    i,j;
   int pcolor[MAXINOUT];

   writeF("static void cStrings(int nsub,int *nC, int * power, int **  chains)\n{\n");
   writeF("   switch(nsub)\n   {\n");
   
   
   if(!noCChain)
   for (nsub = 1, inftmp = inf; nsub <= subproc_sq; nsub++)
   {  
      writeF("   case %d : ",nsub);

      for (i = 0; i < nin + nout; i++)
      {  int l;
         locateinbase(inftmp->p_name[i], &l);
         pcolor[i]=prtclbase[l-1].cdim;
         if(i<nin)
         { if(pcolor[i]==3) pcolor[i]=-3; else if(pcolor[i]==-3) pcolor[i]=3;} 
      }

      infCbases(nin+nout,pcolor,&nC,&cBasisPower,&cChains);
      if(cBasisPower)
      {   writeF("\n     { static int cc[%d]=\n       {\n",2*nC*cBasisPower);
          for(i=0;i<cBasisPower;i++)
          {  writeF("       ");
             for(j=0; j<nC; j++)  
             { writeF(" %d,%d",cChains[2*i*nC+2*j]+1,cChains[2*i*nC+2*j+1]+1);
               if(i==cBasisPower-1 && j==nC-1) writeF("\n       };");
               else  writeF(",");
             }
             writeF("\n");
          }  
              
          writeF("       *nC=%d; *power=%d; *chains=cc;\n     }\n     break;\n",
                      nC,cBasisPower);
          free(cChains); cChains=NULL;                  
      } else  writeF("   *nC=0; *power=0; *chains=NULL; break;\n"); 
          
      inftmp = inftmp->next;
      
   }
   writeF("   default: *nC=0; *power=0; *chains=NULL;\n");
   writeF("   }\n");

   writeF("}\n\n");    
}
Esempio n. 3
0
static void prepareprocinform(void)
{int ndel, ncalc, nrest;
 long recpos;
 char        txt[STRSIZ];
 int     i, k;
 csdiagram   csd;
 char * mass;
 int        nn;
 int nsubs;

   inf = NULL;
   fseek(menuq,0,SEEK_SET);
   for (nsubs=1;nsubs<=subproc_sq;nsubs++)
   {
      inftmp = inf;
      inf = (procinfptr)getmem_((unsigned)sizeof(procinfrec));
      inf->next = inftmp;
      rd_menu(2,nsubs,txt,&ndel,&ncalc,&nrest,&recpos);
      inf->firstdiagpos = recpos;
      getprtcls(txt,inf->p_name);
      for (i = 0; i < nin + nout; i++)
      {
         locateinbase(inf->p_name[i],&nn);
         mass=prtclbase[nn-1].massidnt; 
         if (strcmp(mass,"0")) {for(k=1; k<=nmodelvar; k++) if(strcmp(modelvars[k].varname,mass)==0) break;} 
         else k=0;
         if(k>nmodelvar){ printf("mass %s is not defined\n",mass); exit(125);} 
         inf->p_masspos[i] = k;
         inf->p_code[i]=prtclbase1[nn].N; 
      }
      for (i = nin + nout; i < MAXINOUT; i++)
      {
         strcpy(inf->p_name[i],"***");
         inf->p_masspos[i] = 0;
      }
      fseek(diagrq,recpos*sizeof(csdiagram),SEEK_SET);
      inf->tot = 0;
      for (i = 1; i <= ndel + ncalc + nrest; i++)
      {
         FREAD1(csd,diagrq);
         if (csd.status == 1) ++(inf->tot);
      }
      if(inf->tot==0) for (i = 0; i < nin + nout; i++) inf->p_masspos[i]=0;
   }
   nsubs--;
   revers((void **)&inf);
}
Esempio n. 4
0
static void  make_infbasis(void)
{
   int    i,j;
   int pcolor[MAXINOUT];
   int *cb_pow=malloc(subproc_sq*sizeof(int));
   int *cb_nc=malloc(subproc_sq*sizeof(int)); 
   
   for (nsub = 1, inftmp = inf; nsub <= subproc_sq; nsub++)
   {  

      for (i = 0; i < nin + nout; i++)
      {  int l;
         locateinbase(inftmp->p_name[i], &l);
         pcolor[i]=prtclbase[l-1].cdim;
         if(i<nin && pcolor[i]!=1 && pcolor[i]!=8) pcolor[i]*=-1; 
      }

      cBasisPower=infCbases(nin+nout,pcolor,&nC,&cChains);    
      cb_pow[nsub-1]=cBasisPower;
      cb_nc[nsub-1]=nC;
      if(nC*cBasisPower)
      {  writeF("\n static int cwb_%d[%d]=\n       {\n",nsub, 4*nC*cBasisPower);
         for(i=0;i<cBasisPower;i++)
         {  writeF("       ");
            for(j=0; j<nC; j++)   
            {
              writeF(" %d,%d,%d,%d ", cChains[4*(i*nC+j)],
              cChains[4*(i*nC+j)+1],cChains[4*(i*nC+j)+2],cChains[4*(i*nC+j)+3]);
              if(i==cBasisPower-1 && j==nC-1) writeF("\n       };"); else  writeF(",");
            }
            writeF("\n");
         }      
      }else  writeF("\n#define  cwb_%d NULL\n",nsub); 
          
      inftmp = inftmp->next;
      
   }
   
   writeF("colorBasis  cb_ext[%d]={\n",subproc_sq);
   for(i=0;i<subproc_sq;i++)
   { writeF(" { %d, %d,  cwb_%d}",cb_pow[i],cb_nc[i],i+1);
     if(i!=subproc_sq-1) writeF(",");
     writeF("\n");
   } 
   writeF("};\n");
   free(cb_pow), free(cb_nc);   
}
Esempio n. 5
0
static int c_prog_int(void)
{
   int breaker;
   int i;
   long dfirst;
      
   if(nin+nout<=4) sumDiag=1; else sumDiag=0;   

   memerror=zeroHeep;
   mark_(&heapbeg);

   initvararray(0,'c',3);
  /* ======= Initialisation parth ======= */

   firstVar=nmodelvar;
   if(!strcmp( modelvars[firstVar].varname,strongconst))  firstVar--;
   prepareprocinform();
   calc_nvars_nfunc();
  /* ======= End of Initialisation ====== */

   {  outFileOpen("%sresults%cservice.c",pathtouser,f_slash); 
      labl();
      writeF("#include<math.h>\n");
      writeF("#include<complex.h>\n");                 
      writeF("#include\"num_out.h\"\n");
      writeF("#include\"num_in.h\"\n");

      writeF("double BWrange_ext=2.7;\n");
      writeF("int twidth_ext=0;\n");
      writeF("int gtwidth_ext=0;\n");
      writeF("int gswidth_ext=0;\n");
      writeF(" REAL va_ext[%d]={0};\n",nvars+nfunc+1); 
   }
   geninf("nin_ext",nin);
   geninf("nout_ext",nout);
   geninf("nprc_ext",subproc_sq);
   make_pinf();
   geninf("nvar_ext",nvars);
   geninf("nfunc_ext",nfunc);
    
   make_vinf();
   
   { 
      make_den_info();
      fprintf(outFile,"\nCalcHEP_interface interface_ext={ %d,\n\"%s\"\n,%d, %d, varName_ext,va_ext,"
          "%d, %d, %d, &pinf_ext, &pinfAux_ext, polarized_ext, &calcFunc_ext, &BWrange_ext,&twidth_ext,"
          "&gtwidth_ext,&gswidth_ext, &aWidth_ext, &sqme_ext,&den_info_ext,&build_cb_ext, &cb_pow_ext,"
          "&cb_nc_ext, &cb_chains_ext, &cb_coeff_ext, &destroy_cb_ext};\n", 
      forceUG, pathtocalchep,nvars, nfunc, nin,nout,subproc_sq);

      writeF("\nCalcHEP_interface * PtrInterface_ext=&interface_ext;\n");

      outFileClose();
      outFileOpen("%sresults%csqme.c",pathtouser,f_slash); 
      labl();
      writeF("#include<stdio.h>\n");
      writeF("#include<math.h>\n");
      writeF("#include<complex.h>\n");
      writeF("#include\"num_out.h\"\n");
      writeF("#include\"num_in.h\"\n");
   }
   writeF("static int calcall[%d];\n",subproc_sq+1);

   {
   writeF("static int particles[%d]={0",1+nin+nout); 
   for(i=0;i<nin+nout;i++) writeF(",0");
   writeF("};\n");
   }
   writeF("extern DNN ");
   for(i=1;i<subproc_sq;i++)  writeF("S%d_ext,",i); 
   writeF("S%d_ext;\n",subproc_sq); 
   
   writeF("static  DNN * darr[%d]={",subproc_sq);
   for(i=1;i<subproc_sq;i++)  writeF("&S%d_ext,",i);
   writeF("&S%d_ext};\n",subproc_sq);
   fseek(catalog,0,SEEK_END);
   ndiagrtot = ftell(catalog)/sizeof(catrec);
   
   writesubroutineinit();
   
   {  make_infbasis();
      writeF("#include\"sqme.inc\"\n");
      outFileClose();
   }
   diagrcount = 0;
   inftmp = inf;
   init_stat();
   for (nsub = 1,dfirst=1; nsub <= subproc_sq; nsub++)
   {  int colors[MAXINOUT];

      if (inftmp->tot != 0)   /*  this subprocess IN archive  */
      {

         for(i=0;i<nin+nout;i++) 
         {  int l;
            locateinbase(inftmp->p_name[i], &l);
            colors[i]=prtclbase[l-1].cdim;
         }
         for(i=0;i<nin; i++) 
         if(colors[i]==3) colors[i]=-3; else if(colors[i]==-3) colors[i]=3;
         if(noCChain) for(i=0;i<nin+nout; i++) colors[i]=1; 
         infCbases(nin+nout,colors,&nC,&cBasisPower,&cChains);
         if(cBasisPower)
         { 
            cCoefN=malloc(cBasisPower*sizeof(long));
            cCoefD=malloc(cBasisPower*sizeof(long));
         }

         writesubprocess(nsub,dfirst,inftmp->tot, &breaker);
         dfirst+=inftmp->tot;
         if (breaker) goto exi;
      
         if(cBasisPower)
         {
            if(cChains){free(cChains); cChains=NULL;} 
            free(cCoefN); free(cCoefD);
         }

      } else writesubprocess(nsub,dfirst,0, NULL);
      inftmp = inftmp->next;
   }
   
exi:
   clearstatistic();
   release_(&heapbeg);
   return !breaker;
}
Esempio n. 6
0
static void  make_pinf(void)
{
   int    i;

   writeF("char * pinf_ext(int nsub,int nprtcl,REAL* pmass,int * num)\n{\n");
   writeF("int n;\n");

   writeF(" static char *names[%d][%d] ={\n",subproc_sq,nin + nout);
   inftmp = inf;
   for (nsub = 1; nsub <= subproc_sq; nsub++)
   {  writeF("{");
      for (i = 1; i <= nin + nout; i++)
      {  if(i!=1) writeF(",");
         writeF("\"%s\"",inftmp->p_name[i-1]);
      }
      if (nsub== subproc_sq) writeF("}};\n"); else  writeF("},\n");
      inftmp = inftmp->next;
   }
   
   writeF("int const nvalue[%d][%d]={\n",subproc_sq,nin + nout);
   inftmp = inf;
   for (nsub = 1; nsub <= subproc_sq; nsub++)
   {  writeF("{");
      for (i = 1; i <= nin + nout; i++)
      {  int k=inftmp->p_masspos[i-1];      
         if(k) 
         {
            if(vararr[k].used) sscanf(vararr[k].alias,"V[%d]",&k); else k=-1;
         }
         if(i!=1) writeF(","); 
	 writeF("%d",k);
      }
      if (nsub== subproc_sq) writeF("}};\n"); else  writeF("},\n"); 
      inftmp = inftmp->next;
   }

   writeF("int const pcode[%d][%d]={\n",subproc_sq,nin + nout);
   inftmp = inf;
   for (nsub = 1; nsub <= subproc_sq; nsub++)
   {  writeF("{");
      for (i = 0; i < nin + nout; i++)
      { 
         if(i) writeF(",");  
	 writeF("%d",inftmp->p_code[i]);
      }
      if (nsub== subproc_sq) writeF("}};\n"); else  writeF("},\n"); 
      inftmp = inftmp->next;
   }

   writeF("if  (nsub<0 ||nsub>%d||nprtcl<0||nprtcl>%d) return NULL;\n",
   subproc_sq,nin + nout);
   writeF("if(pmass)\n{\n");
   writeF("  n=nvalue[nsub-1][nprtcl-1];\n");
   writeF("  if (n==0) *pmass=0; else *pmass=va_ext[n];\n"); 
   writeF("  if (*pmass<0) (*pmass)=-(*pmass);\n");  
   writeF("}\n");  
   writeF("if(num)*num=pcode[nsub-1][nprtcl-1];\n");
   writeF("return names[nsub-1][nprtcl-1];\n}\n");

   if(nin==1) writeF("char * polarized_ext[3]={\"\",\"\",\"\"};\n");
   else 
   {  writeF("char * polarized_ext[3]={\"\",\",");       
      for (i = 1; i <= nparticles; i++)
      if(polarized(1,i)) writeF("%s,",prtclbase1[i].name);
      writeF("\",\",");
      for (i = 1; i <= nparticles; i++)
      if(polarized(2,i)) writeF("%s,",prtclbase1[i].name);
      writeF("\"};\n");
   }

   writeF("int pinfAux_ext(int nsub,int nprtcl,int*spin2,int*color,int*neutral)\n{\n");
/*   writeF("int n;\n"); */

   writeF("int const pcode[%d][%d]={\n",subproc_sq,nin + nout);

   inftmp = inf;
   for (nsub = 1; nsub <= subproc_sq; nsub++)
   {  writeF("{");
      for (i = 0; i < nin + nout; i++)
      { 
         if(i) writeF(",");  
	 writeF("%d",inftmp->p_code[i]);
      }
      if (nsub== subproc_sq) writeF("}};\n"); else  writeF("},\n"); 
      inftmp = inftmp->next;
   }

   writeF("int const Spin2[%d][%d]={\n",subproc_sq,nin + nout);

   inftmp = inf;
   for (nsub = 1; nsub <= subproc_sq; nsub++)
   {  writeF("{");
      for (i = 0; i < nin + nout; i++)
      { int pos;
        if(i) writeF(",");  
	locateinbase(inftmp->p_name[i], &pos);
         writeF("%d",prtclbase1[pos].spin);	
      }
      if (nsub== subproc_sq) writeF("}};\n"); else  writeF("},\n"); 
      inftmp = inftmp->next;
   }

   writeF("int const Color[%d][%d]={\n",subproc_sq,nin + nout);

   inftmp = inf;
   for (nsub = 1; nsub <= subproc_sq; nsub++)
   {  writeF("{");
      for (i = 0; i < nin + nout; i++)
      { int pos;
        if(i) writeF(",");  
	locateinbase(inftmp->p_name[i], &pos);
         writeF("%d",prtclbase1[pos].cdim);	
      }
      if (nsub== subproc_sq) writeF("}};\n"); else  writeF("},\n"); 
      inftmp = inftmp->next;
   }

 writeF("int const Neutral[%d][%d]={\n",subproc_sq,nin + nout);

   inftmp = inf;
   for (nsub = 1; nsub <= subproc_sq; nsub++)
   {  writeF("{");
      for (i = 0; i < nin + nout; i++)
      { int pos;
        if(i) writeF(",");  
	locateinbase(inftmp->p_name[i], &pos);
	if(pos==prtclbase1[pos].anti)
         writeF("1");	else  writeF("0"); 
      }
      if (nsub== subproc_sq) writeF("}};\n"); else  writeF("},\n"); 
      inftmp = inftmp->next;
   }
   
   writeF("if(nsub<0 ||nsub>%d||nprtcl<0||nprtcl>%d) return 0;\n",
   subproc_sq,nin + nout);
   writeF("if(spin2) *spin2=Spin2[nsub-1][nprtcl-1];\n");
   writeF("if(color) *color=Color[nsub-1][nprtcl-1];\n");
   writeF("if(neutral) *neutral=Neutral[nsub-1][nprtcl-1];\n");
   writeF("return pcode[nsub-1][nprtcl-1];\n}\n");   
}
Esempio n. 7
0
static void  make_perm(void)
{
   int  i,j,pos=0,cbPowMax;
   int * simMap=malloc(sizeof(int)*subproc_sq); 
   writeF("static int permMap[%d][2]={\n",subproc_sq);
   

   for (nsub = 1, inftmp = inf; nsub <= subproc_sq; nsub++,inftmp = inftmp->next)
   {  
      int nP=1;
      int k=1;
      for (i = nin+1; i < nin + nout; i++)
      {   
         if(strcmp(inftmp->p_name[i],inftmp->p_name[i-1])==0){k++;nP*=k;} else k=1;  
      }
      simMap[nsub-1]=nP-1;
      writeF(" {%d,%d}", pos,nP-1);
      if(nP>1) pos+=nP-1; 
      if(nsub == subproc_sq) writeF("\n};\n"); else writeF(",");      
   }
   
   writeF("static int permP[%d][%d]={\n",pos,nin+nout);
//   writeF("{ "); for(i=0;i<nout-1;i++) writeF("0,"); writeF("0}");   

   cPerm=malloc(sizeof(int*)*pos);
   ncPerm=0;
   
   for (nsub = 1, inftmp = inf; nsub <= subproc_sq; nsub++,inftmp = inftmp->next)
   {  
      if(simMap[nsub-1]);
      {  int used[MAXINOUT],buff[MAXINOUT],np[MAXINOUT];
         writeF("\n // "); for(i=0;i<nin;i++)        writeF("%s ", inftmp->p_name[i]);
         writeF("-> "); for(i=nin;i<nin+nout;i++) writeF("%s ", inftmp->p_name[i]);
              
         for(i=0;i<nin+nout;i++) locateinbase(inftmp->p_name[i],np+i);
         for(i=0;i<nin;i++) { used[i]=1;buff[i]=i;}  for(i=nin;i<nin+nout;i++)used[i]=0;
         permRec(nin+nout,np,nin,used,buff);  
      }
      if(nsub<subproc_sq) writeF(",");  
   }
   writeF("\n};\n");

   for(i=0,cbPowMax=0 ;i<ncPerm;i++) if(cbPowMax<cPerm[i][0])cbPowMax=cPerm[i][0];
   writeF("static int permC[%d][%d]={\n",pos,cbPowMax);

   for(i=0;i<ncPerm;i++)
   {
      writeF("{"); 
        for(j=1;j<cPerm[i][0];j++) writeF("%d,",cPerm[i][j]);
        if(j==cPerm[i][0])  writeF("%d",cPerm[i][j]);
        writeF("}");
      if(i<ncPerm-1) writeF(",");
      writeF("\n");
   }
   writeF("};\n");
   
//      printf("bp=%d :",cPerm[i][0]);
//    for(j=1;j<=cPerm[i][0];j++) printf(" %d",cPerm[i][j]);  
//      printf("\n");
   
   
   for(i=0;i<ncPerm;i++) free(cPerm[i]);
   free(cPerm);
    
   free(simMap);
}
Esempio n. 8
0
static int  readlagrangian(int check, int ugForce)
{ 
  algvertptr  lgrgn1,lgrgn2;
  int    i, j, mm;
  char * ss;
  char   pPtr[4][60];
  int  factorShift,lorentzShift;
  arr4byte  f_copy;
  int mLine,totcolor,color,spinorNumb;
  linelist ln;
  static char fName[4][5] = {"P1","P2","P3","P4"};
  polyvars var_testing={0,NULL}; 

  vardef=&(var_testing);


  clearlgrgn();
  factorShift=tabCharPos(lgrng_tab.format,4);
  lorentzShift=tabCharPos(lgrng_tab.format,5);
  tabName=lgrng_tab.headln;

  for(ln=lgrng_tab.strings, nLine=1; ln; ln=ln->next, nLine++)
  { 
    ss=ln->line;
    sscanf(ss,"%[^|]%*c%[^|]%*c%[^|]%*c%[^|]",pPtr[0],pPtr[1],pPtr[2],pPtr[3]);
    for(i=0;i<4;i++) trim(pPtr[i]);
    if(pPtr[0][0]=='%') continue;
    for(i=0;i<4;i++)
    { 
      if(pPtr[i][0]) 
      { locateinbase(pPtr[i],&j);
        if(check && j == 0) 
        { errorMessage( fName[i]," unknown particle %s" ,pPtr[i]);
                          return 0;
        } 
        f_copy[i]=j;
      }
      else if(i==3) f_copy[3]=0; 
      else { errorMessage( fName[i],"particle name is expected");return 0;}
    }                            

    if(ugForce)
    { for(i=0;i<4;i++)
      { j=f_copy[i];
         if(j && ghostp(j) &&(!zeromass(j))) i=10;
      } 
      if(i>=10) continue;
    }

    lgrgn1=(algvertptr)m_alloc( sizeof(*lgrgn1));
    lgrgn1->next = lgrgn;
    lgrgn = lgrgn1;
    lgrgn->comcoef=    ln->line+factorShift;
    lgrgn->description=ln->line+lorentzShift;
    for (i=0;i<4;i++) lgrgn->fields[i] = f_copy[i];

    if(check)
    {
      totcolor=1;
      for (mm=0;((mm<4)&&(lgrgn->fields[mm] !=0));mm++)
      {
        color=prtclbase[lgrgn->fields[mm] -1].cdim;
        if (color==-3) color=5;
        totcolor=totcolor*color;
      }
      if( (totcolor!=1)&&(totcolor!=15)&&(totcolor!=64)&&(totcolor!=120)&&(totcolor!=512) )
      {   errorMessage("Lorentz part","wrong color structure");
         return 0;
      }
      spinorNumb=0;
      for (mm=0;((mm<4)&&(lgrgn->fields[mm] !=0));mm++)
      {
        if( prtclbase1[lgrgn->fields[mm]].spin&1 )  spinorNumb++ ;
      }
      if( (spinorNumb!=0)&&(spinorNumb!=2) )
      {  errorMessage("Lorentz part","wrong spinor  structure");
        return 0;
       }
    }
    if (! testLgrgn(lgrgn) )  { clearVars(vardef); return 0;}
   }

   clearVars(vardef);
   clearpregarbage();

   lgrgn1 = lgrgn;   /*     Sorting    */
   do
   {  lgrgn1->factor=1;
      for(i=0;i<4 && lgrgn1->fields[i];i++)
      { int hlp=prtclbase[lgrgn1->fields[i]-1].hlp;
        if(hlp=='C') break; 
        else if(hlp=='c') {lgrgn1->factor=-1; break;}
      }    
      for (i = 1; i <= 4; i++) lgrgn1->perm[i-1] = i;
      i = 1;
      while (i < 4)
         if (lgrgn1->fields[i-1] >= lgrgn1->fields[i + 1-1]) ++(i);
         else
         {
            mm = lgrgn1->fields[i-1];
            lgrgn1->fields[i-1] = lgrgn1->fields[i + 1-1];
            lgrgn1->fields[i + 1-1] = mm;
            mm = lgrgn1->perm[i-1];
            lgrgn1->perm[i-1] = lgrgn1->perm[i + 1-1];
            lgrgn1->perm[i + 1-1] = mm;
            if (i == 1)
               ++(i);
            else
               --(i);
         }
      lgrgn1 = lgrgn1->next;
  }  while (lgrgn1 != NULL);

  if (check)
  {
    mLine=nLine;
    lgrgn1 = lgrgn;   /*    check1       */
    do
    {
      nLine--;
      lgrgn2=lgrgn1->next;
      while (lgrgn2 != NULL )
      { if( (lgrgn1->fields[0]==lgrgn2->fields[0]) &&
            (lgrgn1->fields[1]==lgrgn2->fields[1]) &&
            (lgrgn1->fields[2]==lgrgn2->fields[2]) &&
            (lgrgn1->fields[3]==lgrgn2->fields[3])
           )
        {  char sss[20]="";
           for(i=0;i<4;i++) if(lgrgn1->fields[i])
           { strcat(sss, prtclbase1[lgrgn1->fields[i]].name); strcat(sss," ");}                                            
           errorMessage("P1,P2,P3,P4","duplicate vertex {%s}",sss);
           return 0;
        }
        lgrgn2=lgrgn2->next;
      }
      lgrgn1= lgrgn1->next;
     }  while (lgrgn1 != NULL);


    nLine=mLine;
    lgrgn1 = lgrgn;   /*    check2       */
    do
    {
      nLine--;
      for (i=0;i<4;i++)
      {  f_copy[i]=lgrgn1->fields[i];
        if (f_copy[i] !=0)
        {
          mm=ghostmother(f_copy[i]);
          f_copy[i]=prtclbase[mm-1].anti  + f_copy[i]-mm   ;
         }
      }

      i = 1;
      while (i < 4)
        if (f_copy[i-1] >= f_copy[i ]) ++(i);
        else
        {
          mm = f_copy[i-1];
          f_copy[i-1] = f_copy[i ];
          f_copy[i ] = mm;
          if (i == 1)
            ++(i);
          else
            --(i);
        }

      lgrgn2=lgrgn;
      while ((lgrgn2 != NULL ) && (  (f_copy[0] !=lgrgn2->fields[0]) ||
                          (f_copy[1] !=lgrgn2->fields[1])  ||
                          (f_copy[2] !=lgrgn2->fields[2])  ||
                          (f_copy[3] !=lgrgn2->fields[3])
                         )
          )
         {
         lgrgn2=lgrgn2->next;
          }
      if (lgrgn2 == NULL)
      {  char sss[10];
        strcpy(sss,"");
        for (i=0;i<3;i++)
        { strcat (sss, prtclbase[lgrgn1->fields[i]-1].name);
          strcat(sss," ");
        }
        if (lgrgn1->fields[3] !=0   )
           strcat(sss,prtclbase[lgrgn1->fields[3]-1].name);

      errorMessage("P1,P2,P3,P4","conjugated vertex for %s not found",sss);
            return 0;
       }
      lgrgn1= lgrgn1->next;
     }  while (lgrgn1 != NULL);
   }
  return 1;
}
Esempio n. 9
0
static int  readparticles(int  check, int ugForce )
{  char      *ss,*endstr;
   char      fullname[60], massname[60], imassname[60], p1[60], p2[60],numtxt[20];
   char      latex[STRSIZ], latex_[STRSIZ], s[60],c[60], chlp[40];
   int       itmp,i,j, errcode,np1,np2,nparticleLimit =128;

   linelist  ln=prtcls_tab.strings;

   tabName=prtcls_tab.headln;

   if(prtclbase) { cleardecaylist(); clearLatexNames(); free(prtclbase);}
 
   prtclbase=(prtcl_base*) malloc(nparticleLimit*sizeof(prtcl_base));
   prtclbase1=prtclbase-1;	
   nparticles = 0;

   for(i=nparticles;i<nparticleLimit;i++)
           {prtclbase[i].top=NULL;prtclbase[i].latex=NULL;}
   
   nLine=1;
   while (ln != NULL)
   {  ss=ln->line;
      if (nparticles >= nparticleLimit-16)
      {  nparticleLimit+=128;
         prtclbase=re_alloc(prtclbase,nparticleLimit*sizeof(prtcl_base));
         if(!prtclbase) 
         { errorMessage(" P ","too many particles");
	   return 0;
	 }
	 prtclbase1=prtclbase-1;
         for(i=nparticles;i<nparticleLimit;i++)
               {prtclbase[i].top=NULL;prtclbase[i].latex=NULL;} 
      }

      sscanf(ss,"%[^|]%*c%[^|]%*c%[^|]%*c%[^|]%*c%[^|]%*c%[^|]%*c%[^|]%*c%[^|]%*c%[^|]%*c%[^|]%*c%[^|]",
	    fullname,p1,p2,numtxt,s,massname,imassname,c,chlp,latex,latex_);
      trim(p1); trim(p2); trim(latex); trim(latex_); 
      {
         static char fldName[2][5]={" P "," aP"};
         char * pName[2];
         pName[0]=p1;
         pName[1]=p2;

         for ( i=0;i<=1;i++)
         {
            if (check && (! isPrtclName(pName[i])))
            {  errorMessage(fldName[i],"incorrect particle name '%s'",pName[i]);
               return 0;
            }

            if (check )
            {
               locateinbase(pName[i],&j);
               if (j != 0)
               {
                  errorMessage(fldName[i],"duplicate particle name '%s'",pName[i]);
                  return 0;
               }
            }
         }
      }
      nparticles++;
      strcpy(prtclbase[nparticles-1].name,p1);

            
      itmp=strtol(trim(s),&endstr,10);
      if(check)
      {
         if (s+strlen(s) != endstr)
         {  errorMessage("2*spin","number expected");
            return 0 ;
         }
         if((itmp!=0)&&(itmp!=1)&&(itmp!=2)&&(itmp!=3)&&(itmp!=4))
         {  errorMessage("2*spin","value out of range");
            return 0;
         }
      }
      prtclbase[nparticles-1].spin=itmp;
      if( 1!=sscanf(numtxt,"%ld",&prtclbase[nparticles-1].N))
      {    errorMessage("number","can't read MC numeration parameter");
            return 0;
      }
      trim(massname);
      if(strcmp(massname,"0")==0)
      { if(prtclbase[nparticles-1].spin==3 || prtclbase[nparticles-1].spin==4)
         errorMessage("mass","spin 3/2 and spin 2 particles should be massive");
      }
      else 
      {  int pos;
         errcode=findvar(massname,NULL,&pos);
         if (check && (errcode != 0))
         {
            errorMessage("mass","unknown variable %s",massname);
            return 0;
         }else 
         {  if(pos>nCommonVars) nCommonVars=pos;

         } 
      }
      strcpy(prtclbase[nparticles-1].massidnt,massname);

      trim(imassname);
      
      if( check && strcmp(imassname,"0")&& !strcmp(massname,"0")) 
      {  errorMessage("width","non zero width for zero mass particle '%s'", 
            prtclbase[nparticles-1].name);
         return 0;
      }
                                       
      if(strcmp(imassname,"0") != 0)
      { 
         errcode=findvar(imassname,NULL,NULL);
         
         if(errcode)  
         {  if(imassname[0]=='!') 
            {  imassname[0]=' ';  
               trim(imassname);
               if(check && (!isVarName(imassname)) )
               {  errorMessage("width","incorrect name '%s'",imassname);
                  return 0;
               }
               if(check && (!isOriginName(imassname)) )                            
               { errorMessage("width","this identifier  '%s' already was used",imassname);
                 return 0;
               }
               { varlist mvars=modelvars+1+nmodelvar; 
                  nmodelvar++;
                  strcpy(mvars->varname,imassname);
                  mvars->func = NULL;
                  mvars->varvalue = 0.;
                  mvars->need=0;
                  mvars->hidden=0;
                  mvars->pwidth=nparticles;
               }                                                     
            }else 
            { 
               errorMessage("width","unknown variable %s",imassname);
               return 0;
            }
         }
      }
      strcpy(prtclbase[nparticles-1].imassidnt,imassname);

      itmp=strtol(trim(c),&endstr,10);
      if(check)
      {
         if (c+strlen(c) != endstr)
         {  errorMessage("color","number expected");
            return 0;
         }
         if (((itmp!=1)&&(itmp!=3)&&(itmp!=8))||((itmp==3)&&(strcmp(p1,p2)==0))  )
         {  errorMessage("color","value out of range");
            return 0;
         }
      }
      prtclbase[nparticles-1].cdim=itmp;
      trim(chlp);
      if (strcmp(chlp,"") == 0) strcpy(chlp," ");
      prtclbase[nparticles-1].hlp = toupper(chlp[0]);
      if(check)
      {  int ner;
         ner=1;
         switch(prtclbase[nparticles-1].hlp)
         {
            case ' ':if(prtclbase[nparticles-1].spin==2 &&
                        !strcmp(prtclbase[nparticles-1].massidnt,"0")
                       )
              {  errorMessage("aux","Massless vector boson must\n"
                                     " be a gauge particle");                  
                 return 0;
              }
              break;
            case 'L':
            case 'R':
              if ((prtclbase[nparticles-1].spin !=1)
               ||((prtclbase[nparticles-1].massidnt[0])!='0')
               ||(strcmp(p1,p2)==0))  ner=0;
              break;

            case '*':
              if(prtclbase[nparticles-1].massidnt[0]=='0')   ner=0;
              else if(prtclbase[nparticles-1].imassidnt[0]!='0')
              { errorMessage("aux","for aux='*' zero width is  expected"); return 0;}
              break;
            case 'G':
              if(prtclbase[nparticles-1].spin!=2)   ner=0;
              break;
            default: ner=0;
         }
         if(!ner){ errorMessage("aux","unexpeted character"); return 0;}
         if(prtclbase[nparticles-1].N==0 && prtclbase[nparticles-1].hlp!='*')
         { errorMessage("number","Zero PDG code."); return 0;}  
      }
      prtclbase[nparticles-1].latex=malloc(1+strlen(latex));
      strcpy(prtclbase[nparticles-1].latex,latex);
      
      np1 = ghostaddition();
      if (strcmp(p1,p2) == 0) prtclbase[np1-1].anti = np1;
      else
      {
        ++(nparticles);
        prtclbase[nparticles-1] = prtclbase[np1-1];
        prtclbase[nparticles-1].N *=(-1);
        strcpy(prtclbase[nparticles-1].name,p2);
        prtclbase[nparticles-1].latex=malloc(1+strlen(latex_));
        strcpy(prtclbase[nparticles-1].latex,latex_);
        if (prtclbase[np1-1].cdim == 3) prtclbase[nparticles-1].cdim = -3;
        np2=ghostaddition();
        prtclbase[np1-1].anti = np2;
        prtclbase[np2-1].anti = np1; 
      }
      ln=ln->next;
      nLine++;
   }

   for (i = 1; i <= nparticles; i++)
   {  prtcl_base *with1 = &prtclbase[i-1];
      with1->top = NULL;
      
      if (strchr("fcCtT",with1->hlp) != NULL)
      {  
         sprintf(with1->name+strlen(with1->name),".%c",with1->hlp); 
         switch (with1->hlp)
         {
            case 'c':                        
               with1->anti = prtclbase[i-1 - 1].anti +2;
               break;
            case 'C':
               with1->anti = prtclbase[i-1 - 2].anti +1;
               break;
            case 'f':
               with1->anti = prtclbase[i-1 - 3].anti +3;
               break;
            case 't':
               with1->anti = prtclbase[i-1 + 1].anti -1;
               break;               
            case 'T':
               with1->anti = prtclbase[i-1 + 2].anti -2;
               break;               
         }
      }
   }
   
   if(ugForce)for(i=1; i <= nparticles; i++) 
               if(gaugep(i) && (!zeromass(i))) prtclbase[i-1].hlp=' ';

  for(i=1;i<=nmodelvar;i++)
  if(modelvars[i].pwidth) modelvars[i].pwidth=ghostmother(modelvars[i].pwidth);
   
   return 1;
}
Esempio n. 10
0
static void  prtcllist(int  key)
{
 char         fullname[STRSIZ];
 char         hlp[60];
 char         p1[60], p2[60];
 int         i, j, pnum;
 linelist     ln;
 int  tabMax,tabSz;

 static int    nTot,nFirst;

	tabMax=ycons -7;
	if (key==0)
	{
		scrcolor(FGmain,BGmain);
		for (i = 2; i <= 24; i++)
		{  goto_xy(1,i);
			clr_eol();
		}
		goto_xy(14,3);
		scrcolor(Blue,BGmain);
		print("List of particles (antiparticles)");
		nTot=0;
		nFirst=1;
	}
	else
	{
		if (nTot <= 3 *tabMax )   return;
		switch (key)
		{
		  case KB_DOWN : nFirst+=3;         break;
		  case KB_UP   : nFirst-=3;         break;
		  case KB_PAGED: nFirst +=3*tabMax; break;
		  case KB_PAGEU: nFirst -=3*tabMax; break;
		}
		if (nFirst <1) nFirst=1;
		if (nTot-nFirst+3<3*tabMax )  nFirst=1+3*((nTot+2)/3) -3*tabMax;
		clrbox(1,4,79,5+tabMax);
	}
	goto_xy(3,5); scrcolor(FGmain,BGmain);
	for(i=0,ln=prtcls_tab.strings;  ln; ln=ln->next )
	{  sscanf(ln->line,"%[^|]%*c%[^|]%*c%[^|]%*c%*[^|]%*c%*[^|]%*c%*[^|]%*c%*[^|]%*c%*[^|]%*c%[^|]",
			 fullname,p1,p2,hlp);
		trim(p1);
		locateinbase(p1,&pnum);
		trim(hlp);
		if (prtclbase[pnum-1].top != NULL && strcmp(hlp,"*") != 0)
		{
			i++;
			if (i>=nFirst && (i-nFirst)/3 <tabMax )
			{
				print("%s",p1);
				if (strcmp(p1,p2) == 0) print("     "); else print("(%s)",p2);
				trim(fullname);
				print("- %s",fullname);
				j = i % 3;
				if (j == 0)	goto_xy(3,where_y() + 1);
						else	goto_xy(3 + 26 * j,where_y());
			}
		}
		
	}
	nTot=i;
	tabSz=MIN((nTot+2)/3,tabMax);
	chepbox(1,4,79,5+tabSz);

	if (nFirst >1 ) { goto_xy(72,4); print("PgUp");  }

	if (nFirst+3*tabSz <= nTot    ) { goto_xy(72,5+tabMax); print("PgDn");  }

	scrcolor(FGmain,BGmain);
}
Esempio n. 11
0
static int enter_h(int * y,char* name,int num,int scat)
{ int      i,m,j=0;
  int      redres;
  shortstr hadrch;  

  char ** items;
  char * errpos=NULL;

  locateinbase(name,&j);
  if(j)
  { 
    if(pseudop(j)) return -1;
    strcpy(hadrons[num].name,name);
    strcpy(hadrons[num].contents,name); 
    hadrons[num].parton[0] = j; 
    hadrons[num].pow = 1;
    if(!scat && num==0 && strcmp(prtclbase1[j].massidnt,"0")==0) 
    { errTxt="Decay of massless particle.";
      return -1;
    }   
    if(name[strlen(name)-1]=='%')
    { 
      if( !scat || nout||strcmp(prtclbase1[j].massidnt,"0") || 
          (prtclbase1[j].spin!=1 && prtclbase1[j].spin!=2) || 
          strchr("LR",prtclbase1[j].hlp)
        ) 
       { errTxt="This particle can not be polarized";   
         return -1;
       } else  hadrons[num].polarized[0]=1; 
    } else hadrons[num].polarized[0]=0;
    return 0;
  }

  for(i=0;i<num;i++) 
  if(!strcmp(hadrons[i].name,name))
  {  strcpy(hadrons[num].name,name);
     strcpy(hadrons[num].contents,hadrons[i].contents);
     hadrons[num].pow=hadrons[i].pow;
     for(j=0;j<hadrons[num].pow;j++)
     { hadrons[num].parton[j]=hadrons[i].parton[j];  
       if(nout) hadrons[num].polarized[j]=0;
       else hadrons[num].polarized[j]=hadrons[i].polarized[j];
     }  
     return 0;
  }

  hadrch[0]=0; 

  for(i=num;i<MAXINOUT;i++) if(!strcmp(hadrons[i].name,name))
  {  
     strcpy(hadrch,hadrons[i].contents);
     break;
  } 

  if(*y>=maxRow()-1) { goto_xy(1,*y); clr_eol();} else (*y)++;  

  do
  {
     m=errpos? errpos-hadrch+1: 0;
  
     do 
     {  char direction[100];
        sprintf(direction,"composit '%s'  consists of: ",name); 
        redres=input(*y, "s_ent_2", direction,  hadrch, m , SSTRLEN);
        if(redres==KB_ESC) return 1;               
     }  while (redres!=KB_ENTER && redres!=KB_ESC);

     if (redres == KB_ESC || strcmp(hadrch,"") == 0)  return 1;
  
      
     items=stritems(" ,",hadrch);
     for(m=0,hadrons[num].pow=0; items[m]; m++) 
     { char  name[100];
       if(hadrons[num].pow>=100) {errTxt="too many partons";break;}   
       sscanf(items[m],"%[^ ,]",name);
       locateinbase(name,&j);  
       if (j==0 || pseudop(j)) 
       { errTxt= "This particle is absent in the model"; break;}

       if(!scat && num==0 && strcmp(prtclbase1[j].massidnt,"0")==0)
       { errTxt="Decay of massless particle.";
         break;
       }
       if(name[strlen(name)-1]=='%')
       { 
         if( !scat || nout||strcmp(prtclbase1[j].massidnt,"0") || 
              (prtclbase1[j].spin!=1 && prtclbase1[j].spin!=2) ||
              strchr("LR",prtclbase1[j].hlp)
           ) 
         { errTxt="This particle can not be polarized";   
              break;
         } else  hadrons[num].polarized[hadrons[num].pow]=1; 
       } else hadrons[num].polarized[hadrons[num].pow]=0; 
       hadrons[num].parton[hadrons[num].pow++]=j;
     }

     errpos=items[m]; 
     if(!errpos)
     {  for(i=0;i<hadrons[num].pow;i++)
        for(j=i+1;j<hadrons[num].pow;j++)
        if(hadrons[num].parton[i]==hadrons[num].parton[j])
        {  errpos=items[j];
           errTxt="duplicate parton";
        }
     }
     strcpy(hadrons[num].name,name);
     strcpy(hadrons[num].contents,hadrch);
     free(items);
  }
  while(errpos);   
  return 0;
}