示例#1
0
static void  decay12information(double totwidth,int Branchings)
{  
   clrbox(1,1,53,16);  
   clrbox(1,16, maxRow(), maxCol());
   
   goto_xy(5,3);scrcolor(Red,BGmain); print(" Decay ");
   scrcolor(Blue,BGmain);print("%s -> 2*x      ",inParticle);
   goto_xy(1,4);
   scrcolor(Red,BGmain); 
   print(" Total width : "); 
   scrcolor(FGmain,BGmain); 
   if(err_code) {print(" incorrect       "); return;}

   print("%.3E GeV     ",totwidth);
   if (totwidth > 0. ) 
   {  int i,xcount = 31, ycount = 15;
      int * sort= (int*) malloc(sizeof(int)*nprc_int);

      for(i=0;i<nprc_int;i++) sort[i]=i;  
      for(i=0;i<nprc_int-1;)
      {   
         if(widths[sort[i]] < widths[sort[i+1]])
         {  int buff=sort[i];
            sort[i]=sort[i+1];
            sort[i+1]=buff;
            if (i!=0) i--;
         } else i++;
      }   

      goto_xy(1,6);
      scrcolor(Red,BGmain);
      if(Branchings) print(" Modes and fractions :");
      else           print(" Partial widths [Gev] :"); 
      for(i=0,xcount=5,ycount=7;i<nprc_int;i++,ycount++) 
      if(widths[sort[i]]>0)
      {  if(ycount >= maxRow()) 
         { ycount =16; xcount += 25;
           if(xcount > maxCol()-20) break;
           if(xcount >30) ycount=16; else ycount=7;
         }
	 goto_xy(xcount,ycount);
         scrcolor(Blue,BGmain);
         print("%3s ",pinf_int(sort[i]+1,2,NULL,NULL));
         print("%3s - ", pinf_int(sort[i]+1,3,NULL,NULL));
         scrcolor(FGmain,BGmain);
         if(Branchings) print("%8.2E%%", 100*widths[sort[i]]/totwidth); 
         else           print("%9.3E", widths[sort[i]]); 
      }  
      free(sort);
   } 
   scrcolor(FGmain,BGmain); 
} 
示例#2
0
//------------------------------------------------------------------------
// Purpose  : Initialize particle
//------------------------------------------------------------------------
void	DiwaliPaus::InitParticle(Particle& out)
{
	// Randomize Color
	D3DXVECTOR3	minCol(0.0f, 0.0f, 0.0f);
	D3DXVECTOR3 maxCol(1.0f, 1.0f, 1.0f);
	D3DXVECTOR3 outCol;
	Helper::GetRandomVector(outCol, minCol, maxCol);
	out.initialColor		=	D3DXCOLOR(outCol.x, outCol.y, outCol.z, 1.0f);
	
	out.initialPos			=	D3DXVECTOR3(0.0f, 100.0f, 0.0f);
	out.initialSize			=	Helper::GetRandomFloat(10.0f, 20.0f);
	out.initialTime			=	m_fTime;

	// Randomize Velocity
	D3DXVECTOR3 minVec(-1.5f, 10.0f, -1.5f);
	D3DXVECTOR3 maxVec(1.5f, 20.0f, 1.5f);
	Helper::GetRandomVector(out.initialVelocity, minVec, maxVec);

	out.lifeTime			=	Helper::GetRandomFloat(5.0f, 7.0f);
	out.mass				=	Helper::GetRandomFloat(0.8f, 1.2f);
};
示例#3
0
void interpretator(void)
{
 marktp   heapbg;
 void * pscr;
 double sqrts_mem=sqrts;
   get_text(1,1,maxCol(),maxRow(),&pscr);   
   clr_scr(FGmain,BGmain);
   
   allcanal=(canal*)m_alloc(subproc_sq*sizeof(*allcanal));
   mark_(&heapbg);

   if(compileall()==0) { n_comphep(); free(calcCoef); calcCoef=NULL;} 


   release_(&heapbg);
   free(allcanal);

   clr_scr(FGmain,BGmain);
   put_text(&pscr);
   sqrts=sqrts_mem;
}
示例#4
0
文件: crt_util.c 项目: Omer80/wimps
static int  correctVar(char* txt,int x,int y, int  type, void * var,int clear)
{  int         npos,key,err;
   int xx;
   void *     pscr; 
   char * buff;
   int *  I;
   long * L;
   double * D;
   int maxLen;

   get_text(x,y,maxCol(),y,&pscr);   
   scrcolor(White,Black);
   goto_xy(x,y);
   print(txt);
   xx=where_x();
   

   if(type<0) {buff=var; maxLen=-type;} else 
   { buff=malloc(100); 
     switch (type)
     {
        case 'L':  L=var;  sprintf(buff,"%ld",*L); break;
        case 'D':  D=var;  sprintf(buff,"%lg",*D); break;
        case 'I':  I=var;  sprintf(buff,"%d" ,*I); break;
     }
     maxLen=MAX(15,strlen(buff));
   }    
   npos = 1;      

   do
   { 
      goto_xy(xx,y);
      key  = str_redact(buff,npos,maxLen);

      if (key == KB_ESC)
      {  
         put_text(&pscr);
         if(type>=0) free(buff);
         return 0;
      }
      err=0;
      if (key == KB_ENTER)
      {
/*         trim(buff); */
         if(type<0) err=1; else
         {
            switch (type)
            {   
              case 'L':   err=sscanf(buff,"%ld",L); break;
              case 'D':   err=sscanf(buff,"%lf",D); break;
              case 'I':   err=sscanf(buff,"%d" ,I); break;
            }
         }                                     
         if (err<=0)   messanykey(10,10," incorrect number"); 
      }
      
   }  while (err<=0);
   
   if(clear)put_text(&pscr); else free(pscr); 
   if(type>=0) free(buff);   
   return 1;   
} 
示例#5
0
文件: crt_util.c 项目: Omer80/wimps
void  menu0(int col,int row,char* label, char* menstr ,
	  void (**funcKey)(int) ,char** funcKeyMess, void ** hscr, int* kk)
{  int    i, j, k, col1, npage,lastrow;
   long	  lastpage;
   int    ink;
   int    ncol;
   void * pscr;
   int  fkPos[11];
   int  height;
   char fmt[20];
   int  lastLine;

/* colors */
   int label_fg  =Yellow;
   int label_bg  =Blue;
   int help_fg1  =White;
   int help_fg2  =Black;
   int help_bg   =DarkGray;
   int box_fg    =White;
   int box_bg    =DarkGray;
   int star_fg   =Red;
   int page_fg   =Black;
   int actFunc_fg=Black;
   int actFunc_bg=White;
   int pasFunc_fg=White;
   int pasFunc_bg=DarkGray;

/* save colors */
   int      fcolor_tmp=fColor;
   int      bcolor_tmp=bColor;
   void *hscr_=NULL;
   
   if(hscr==NULL) hscr=&hscr_;
   lastLine=maxRow();
   if (funcKey == NULL) for (i=0;i<11;i++) fkPos[i]=0; else
   {  int xx;
      scrcolor(FGmain,BGmain);
      goto_xy(1,lastLine); clr_eol();
      xx=0;
      for (j=0;j<10;j++) { if(funcKey[j] && funcKeyMess[j]) 
                                          xx=xx+4+strlen(funcKeyMess[j]);}
      xx= (80 - xx )/2 ;
      goto_xy(xx,lastLine);
      for (i=0;i<10;i++)
      { fkPos[i]=where_x();
        if (funcKey[i] && funcKeyMess[i])
        { scrcolor(help_fg1,help_bg); print(" F%i-",i+1);
          scrcolor(help_fg2,help_bg); print(funcKeyMess[i]);
        }
      }
      fkPos[10]=where_x();
   }

   clearTypeAhead();

   if (*kk < 0) *kk = -(*kk);
      ncol=menstr[0];
      sprintf(fmt,"%%%d.%ds",ncol,ncol);
      height=strlen(menstr)/ncol;
      if(height==0) { *kk=0; return; }
      if (row+height+1 >lastLine-2) height=lastLine-3-row;
      lastpage = 1+    (strlen(menstr)/ncol -1)/height ;
   if(label[0] ==0 || row == 1) 
   { if (*hscr == NULL)  get_text(col,row,col+ncol+1,row+2,hscr);} 
   else
   {  char label_[STRSIZ];
      int shft,sz;
      if (*hscr == NULL) get_text(col,row-1,col+ncol+1,row+2,hscr); 
      for(i=0;i<ncol+2;i++) label_[i]=' ';
      label_[ncol+2]=0;  
      sz=strlen(label);
      if(sz >ncol+2) {shft=0;sz=ncol+2;} else shft=(ncol+2 -sz)/2;  
      memcpy(label_+shft,label,sz); 
      scrcolor(label_fg,label_bg);
      goto_xy(col,row-1);
      print(label_);
   }

   get_text(col,row + 3,col + ncol + 1,row + height + 1,&pscr);

   if (*kk <= 0  || *kk > lastpage * height   )
   {  npage = 1;
      k = 1;
   }
   else {
      k = ((*kk) - 1) % height + 1;
      npage = ((*kk) - 1) / height + 1;
   }
   col1 = col + 1;

label_1:
      scrcolor(box_fg,box_bg);
      chepbox(col,row,col + ncol + 1,row + height + 1);
      scrcolor(star_fg,box_bg);
      goto_xy(col+1,row); print("<");
/*      goto_xy(col+1,row + height+1);  print("?"); */
      scrcolor(page_fg,box_bg);
      if (npage > 1)
      {
         goto_xy(col + ncol - 2,row);
         print("PgUp");
      }
      if (npage < lastpage)
      {
         goto_xy(col + ncol - 2,row + height + 1);
         print("PgDn");
      }

      if(npage<lastpage) lastrow=height;
		  else   lastrow = (strlen(menstr)/ncol)%height;

   lastrow=0;
   scrcolor(pasFunc_fg,pasFunc_bg);
   for (j = 1; j <= height; j++)
   {  int shift;
      goto_xy(col + 1,row + j);
      shift=1+(j-1 + (npage-1)*height)*ncol;
      if(shift<strlen(menstr)) {print(fmt,menstr+shift );lastrow++;}
		 else           print(fmt," ");

   }

   scrcolor(actFunc_fg,actFunc_bg);
   if (k > lastrow) k = lastrow;
   goto_xy(col + 1,row + k);
   if (lastrow) print(fmt,menstr+1+(k-1+(npage-1)*height)*ncol);
   while (1)
   {  int jump=1,mousePos;

      scrcolor(pasFunc_fg,pasFunc_bg); 

      ink = inkey();
/* mouse filter */
      if ((ink==KB_MOUSE)&&(mouse_info.but1 == 2))
      {
         if (mouse_info.row == lastLine )
         for(i=0; i<10;i++)
         if ((mouse_info.col > fkPos[i]) && (mouse_info.col < fkPos[i+1]))
         {  if (i==9)ink='0'; else ink='1'+i;}

         if ( (mouse_info.col >= col ) && (mouse_info.col <=col+ncol+1) )
         {  mousePos = mouse_info.row - row;

            if (col+ncol+1-mouse_info.col <4)
            {
               if (mousePos==0)        ink=KB_PAGEU;
               if (mousePos==height+1) ink=KB_PAGED;
            }

            if ((mousePos == 0 ) && ( mouse_info.col-col <4)) ink=KB_ESC;

            if ((mousePos < 0)&&(mousePos >= height))
            {
               if (mousePos > k)  {ink=KB_DOWN; jump=mousePos - k;}
               if (mousePos < k)  {ink=KB_UP;   jump=k - mousePos;}
               if (mousePos==k )   ink=KB_ENTER;
            }
         }
      }
/* end of filter */
      if (lastrow == 0) goto label_3;
label_4:
      switch (ink)
      {
        case KB_MOUSE:
        if (mouse_info.but1 != 2) break;
        if (mouse_info.row == lastLine )
        for(i=0; i<10;i++)
          if ((mouse_info.col > fkPos[i]) && (mouse_info.col < fkPos[i+1]))
          {  if (i==9)ink='0'; else ink='1'+i;
             goto label_4;
          }

        if ( (mouse_info.col < col ) || (mouse_info.col >col+ncol+1) ||
             (mouse_info.row < row ) || (mouse_info.row >row+height+1) ) break;

           mousePos = mouse_info.row - row;
           if ((mousePos == 0 ) && ( mouse_info.col-col <4)) ink=KB_ESC;
           if ((mousePos != 0)&&(mousePos != height+1))
           {
              if  (mousePos > k)  { ink=KB_DOWN; jump=mousePos - k;}
              if (mousePos < k      ) { ink=KB_UP;   jump=k - mousePos;}
           }
           if (col+ncol+1-mouse_info.col <4)
           {
              if (mousePos==0)        ink=KB_PAGEU;
              if (mousePos==height+1) ink=KB_PAGED;
           }
           if (mousePos==k       ) ink=KB_ENTER;
           if (ink!=KB_MOUSE) goto label_4;

          break;

		  case  KB_DOWN: 
           if(k==lastrow)
           { 
              if(npage < lastpage)
              {  k=1;
                 npage++;
                 goto label_1;
              } else { be_be(); break; }           
           }else {ink= KB_RIGHT; goto label_4;}

		  case  KB_UP: 
           if(k==1)
           {
              if (npage > 1)
	      {
                 k=height;
		 npage--;
		 goto label_1;
              }
              else{ be_be(); break; }           
           }
           else {ink= KB_LEFT; goto label_4;}

		  case KB_LEFT: 
            goto_xy(col1,row + k);
	    print(fmt,menstr+1+(k-1+(npage-1)*height)*ncol);
            k = k - jump;
            if (k == 0) k = lastrow;
            scrcolor(actFunc_fg,actFunc_bg);
            goto_xy(col1,row + k);
	    print(fmt,menstr+1+(k-1+(npage-1)*height)*ncol);
         break;

                  case KB_RIGHT:
	    goto_xy(col1,row + k);
	    print(fmt,menstr+1+(k-1+(npage-1)*height)*ncol);
            k = k + jump ;
            if(k > lastrow) k = 1;
            scrcolor(actFunc_fg,actFunc_bg);   
            goto_xy(col1,row + k);
	    print(fmt,menstr+1+(k-1+(npage-1)*height)*ncol);
         break;

                  case KB_ENTER:
            scrcolor(box_fg,box_bg);
            chepbox(col,row,col+ncol+1,row+2);
            put_text(&pscr);
            goto_xy(col1,row + 1);
            scrcolor(actFunc_fg,actFunc_bg);
	    print(fmt,menstr+1+(k-1+(npage-1)*height)*ncol);
            *kk = (npage - 1) * height + k;
            goto_xy(1,lastLine);scrcolor(FGmain,BGmain); clr_eol();
            if(hscr==&hscr_) put_text(hscr); 
            refresh_scr();
            escpressed();
            return;

			case  KB_BACKSP:
			case  KB_ESC:
            goto label_3;

			case KB_PAGEU:
            if (npage > 1)
            {
               npage--;
               goto label_1;
            }
            else
               be_be();
         break;

			case KB_PAGED:
            if (npage < lastpage)
            {
               npage++;
               goto label_1;
            }
            else
               be_be();
	    break;

	case  '1':  case'2':	   case  '3':	case  '4':	case  '5':
	case '6':   case '7':	case  '8':	case  '9':	case  '0':
	case KB_F1: case KB_F2: case KB_F3: case KB_F4: case KB_F5:
	case KB_F6: case KB_F7: case KB_F8: case KB_F9: case KB_F10:
	{  int fk;
           if (funcKey==NULL) break;
	   if ( ink>='0' && ink <='9') { fk=ink-'0';if (fk==0) fk=10;}
	      else fk=ink-KB_F1+1;
	   if ((funcKey[fk-1]) != NULL)
           {  void * saveHlp;
	      get_text(1,lastLine,maxCol(),lastLine,&saveHlp);
	      scrcolor(box_fg,box_bg);
	      goto_xy(col+1,row); print("%c",boxFrame[1]);
	      goto_xy(1,lastLine);scrcolor(FGmain,BGmain);clr_eol();
	      (*funcKey[fk-1])((npage-1)*height+k);	 
	      put_text(&saveHlp);
	      scrcolor(star_fg,box_bg);
	      goto_xy(col+1,row); print("<");
	   }
           break;
        }
        case 6:  /* ^F */
        case 'f':
        case 'F':
        {  char name[32]="";
           int key=correctStr(5,23,"Enter name(Esc for exit):",name,30,1);
           if(key)
           { char * x=strstr(menstr+1,name);
             if(x==NULL) 
             {
               if(blind) sortie(121); else messanykey(10,10, "Not detected"); 
               break;
             }
             k= ((x-menstr)-1)/menstr[0];
             npage = k/ height + 1;
             k = k% height + 1;
             goto label_1;
           }
        } break; 
     }
  }

label_3:
   put_text(hscr);
   put_text(&pscr);
   scrcolor(fcolor_tmp,bcolor_tmp);
   goto_xy(1,lastLine); clr_eol();
   *kk = 0;
}
示例#6
0
static void f7_prog(int mode)
{ int pos=1;
  void *pscr=NULL;
  f3_key[4]=NULL;

  for(;;)
  {  static double xMin=1E-5, xMax=1.0, q0 = 91.187,qMin=1.5,qMax=1.E4,x0=0.1;
     static int nPoints=100;
     static int both=1,LOG=1;  
     int on[2]={0,0};


     char strmen[]="\030"
                  " x-Min = XXX            "
                  " x-Max = YYY            "
                  " q-Min = QXX            "
                  " q-Max = QYY            " 
                  " Npoints = NNN          "
                  " q0      = QQQ          "
                  " x0      = xXX          "
                  " log scale argument LOG "  
                  " Display plot x*F(x)    "
                  " Display plot   F(x)    "
                  " Display plot   F(Q)    "
                  " both PDF1&PDF2    BOTH ";

               
     improveStr(strmen,"XXX","%.3E",xMin); 
     improveStr(strmen,"YYY","%.3E",xMax);
     improveStr(strmen,"QXX","%.3E",qMin);
     improveStr(strmen,"QYY","%.3E",qMax);
     improveStr(strmen,"NNN","%d",nPoints);
     improveStr(strmen,"QQQ","%.2fGeV",q0); 
     improveStr(strmen,"xXX","%.2E",x0);
     if(LOG) improveStr(strmen,"LOG","ON"); else improveStr(strmen,"LOG","OFF");
     
     if(mode>2) both=1;
     if(both){ on[0]=1,on[1]=1;} else  on[mode-1]=1;

     if(!sf_num[0]) on[0]=0;
     if(!sf_num[1]) on[1]=0;
     if(sf_num[0]==0 && sf_num[1]==0) return;
      
     if(both) improveStr(strmen,"BOTH","ON"); else improveStr(strmen,"BOTH","OFF");
     menu1(54,10,"PDF plots",strmen,"n_pdf_plots_*",&pscr,&pos);

     switch(pos)
     {  case 0: f3_key[4]=f7_prog; 
                return;
        case 1:
          correctDouble(55,18,"xMin = ",&xMin,1);                  
          break; 
        case 2:
          correctDouble(55,18,"xMax = ",&xMax,1);                  
          break; 
        case 3:
          correctDouble(55,18,"qMin = ",&qMin,1);
          break; 
        case 4:  
          correctDouble(55,18,"qMax = ",&qMax,1);
          break; 
        case 5:
          correctInt(50,18,"nPoints = ",&nPoints,1);
          break; 
        case 6: 
          correctDouble(50,18,"q0 = ",&q0,1);
          break;
        case 7:
          correctDouble(50,18,"x0 = ",&x0,1);
           break;
        case 8: LOG=!LOG; break;             
        case 9: case 10: case 11:
        { double z1,z2;
          if(pos==11) {z1=qMin;z2=qMax;} else {z1=xMin;z2=xMax;}

          if(z1>=0 && (!LOG||(z2/z1>10) ) && z2>z1 && nPoints>=3 && nPoints<=150 )
         { int l,i;
           double * df[2]={NULL,NULL};
           double f[2][250];
           char p_name[2][100], title[100];
           char*xName;
           void * screen;
           
           get_text(1,1,maxCol(),maxRow(),&screen);
//           if(LOG) {z1=log10(z1); z2=log10(z2);}
           for(l=0;l<2; l++) if(on[l])
           {  double be=sf_be[l];
              strFunName(l+1,p_name[l]);
              sprintf(p_name[l]+strlen(p_name[l]),"(%s)", pinf_int(Nsub,l+1,NULL,NULL));              
//              sprintf(p_name[l],"pdf%d(%s)", l+1,pinf_int(Nsub,l+1,NULL,NULL) ); 
              for(i=0;i<nPoints;i++)
              {  double x=x0,q=q0,z,al;
                 al=(i+0.5)/(double)nPoints;
                 if(LOG)  z=pow(z1,1-al)*pow(z2,al); 
                 else     z=z1+al*(z2-z1);
                 
                 if(pos==11) q=z; else x=z;
                 f[l][i]=strfun_(l+1,x,q);
                 if(pos==9) f[l][i]*=x;
//          if(pos==11) f[l][i]/=q*q;
                 if(be!=1.) f[l][i]*=be*pow(1.-x,be-1.);
              }
           }
//           strcpy(title,"Incoming particle distribution");
           title[0]=0;  
           
           switch(pos)
           { case  9: sprintf(title+strlen(title)," x*F(x,Q=%.2E)",q0);   break;
             case 10: sprintf(title+strlen(title)," F(x,Q= %.2E)",q0);     break;
             case 11: sprintf(title+strlen(title)," F(x=%.2E,Q)",x0);     break;
           }
           if(pos==11) xName="Q"; else xName="x";
           if(on[0]&&on[1]) plot_N(title,z1,z2, xName, LOG, 2, nPoints, f[0],NULL,p_name[0],nPoints,f[1],NULL,p_name[1]);
           else 
           { if(on[0]) l=0; else l=1;
              plot_N(title,z1,z2, xName, LOG,1, nPoints, f[l],NULL,p_name[l]);   
           }  
           put_text(&screen);
         } else messanykey(16,5," Correct input is \n"
                                "  0<=xMin<xMax<=1,\n"
                                " 3<=nPoints<=150");
        }                        
        break;                        
        case 12: both=!both;    
        break; 
      }
   }
}
示例#7
0
文件: screen.c 项目: Omer80/wimps
int  viewresults(void)
{  
   int  k,kmenu;
   void *  pscr  = NULL;
 
   shortstr  newname;
   int dirStat=checkDir("results");

   if(dirStat==0){messanykey(10,15,"directory RESULTS is empty"); return 1;}

   kmenu = 1;   
label_1:

   menu1(10,10,"","\010"
      " View   "
      " Delete "
      " Rename ","s_res",&pscr,&kmenu);
      
   switch (kmenu)
   {
     case 0:
       return 0;         
     case 1: 
      viewDir("results");    
      break;

     case 2:
      if(dirStat==2)
      { char mess[]="Can not clean dir 'results' because it contains the LOCK file";
        if(blind) { printf("%s\n",mess); sortie(102);} 
        else { messanykey(3,13,mess); break;}
      } 
      if ( mess_y_n( 6,13," Delete files ") ) 
      {  struct dirent **namelist;
         int n,i;
         n = scandir("./results", &namelist, NULL, NULL);
         for(i=0; i<n;i++)
         { 
           char buff[100];
           if(strcmp(namelist[i]->d_name,"aux") && strcmp(namelist[i]->d_name,"..") && strcmp(namelist[i]->d_name,".")  )
           { 
             sprintf(buff,"rm -rf results/%s",namelist[i]->d_name);  
             if(unlink(buff+7)) system(buff);
           }  
         }
         free(namelist);
      }
      put_text(&pscr);
      return 1;
     case 3:
      strcpy(newname," ");
      while(1)
      {  void * pscr3;
         get_text(1,maxRow(),maxCol(),maxRow(),&pscr3); 
         goto_xy(1,maxRow());
         print("Enter new name: ");
	 k = str_redact(newname,1,30);
	 if (k == KB_ESC)
	 {   goto_xy(1,24);
             clr_eol();
             goto label_1;
         }
	 if (k == KB_ENTER)
         {
            trim(newname);
            if(rename("results",newname)==0)
            {  char command[200];
               mkdir("results",0755);
               sprintf(command," cp -rp  %s/aux results",newname);
               system(command);
               
               put_text(&pscr);
               put_text(&pscr3);
               return 1;
            }
             else  messanykey(10,15," Can't rename the directory");
         }
         put_text(&pscr3);   
      }
   } 
   goto label_1;
}
示例#8
0
int qcdmen_(void)
{
   void * pscr=NULL;
   int mode;
   int returnCode=0;

   initStrFun(0);
L10:{  char strmen[]="\030"
      " parton dist. alpha OFF "
      " alpha(MZ)=  ZZZZ       "
      " nf =        NF         "
      " order=      NNLO       "
      " mb(mb)=     MbMb       "
      " Mtop(pole)= Mtp        "
      " Alpha(Q) plot          "
      " Qren = RRR             "
      " Qpdf1= FF1             "
      " Qpdf2= FF2             "
      " Qshow= FFS             ";

      if(alphaPDF)
      { int k=0;
//printf("alphaPDF=%d sf_alpha[0]=%p sf_alpha[1]=%p\n", alphaPDF,sf_alpha[0],sf_alpha[1]);      
        switch(alphaPDF)
        { case 1: if(sf_alpha[0]) k=1; else if(sf_alpha[1]) k=2; break;
          case 2: if(sf_alpha[1]) k=2; else if(sf_alpha[0]) k=1; break;
        }    
        if(k) improveStr(strmen,"OFF","pdf%d",k);
      }    
      improveStr(strmen,"ZZZZ","%.4f", alphaMZ);
      improveStr(strmen,"NF","%d",alphaNF);

           if(alphaOrder==1) improveStr(strmen,"NNLO","%-.4s","LO");
      else if(alphaOrder==2) improveStr(strmen,"NNLO","%-.4s","NLO");
      else alphaOrder=3;
      
      improveStr(strmen,"MbMb","%.3f", MbMb);
      improveStr(strmen,"Mtp","%.2f", Mtp);

      improveStr(strmen,"RRR","%-.16s", Rscale_str);
      
      improveStr(strmen,"FF1","%-.16s", F1scale_str);
      improveStr(strmen,"FF2","%-.16s", F2scale_str); 
      improveStr(strmen,"FFS","%-.16s", Sscale_str);
      menu1(54,8,"QCD alpha",strmen,"n_alpha",&pscr,&mode);
    }
    switch (mode)
    { case 0: if(returnCode) init_alpha(); return returnCode;
      case 1: 
         { char alphaMen[100]="\006"                                                                                    
           "  OFF "                                                                                                     
           " pdf1 "                                                                                                     
           " pdf2 ";                                                                                                    
           int k=0;                                                                                                     
           menu1(54,12,"alpha",alphaMen,"",NULL,&k);                                                                    
           if(k)alphaPDF=k-1;                                                                                           
           if(alphaPDF && !sf_alpha[alphaPDF-1]) messanykey(20,20,"WARNING! This pdf  does not define alphaQCD ");                                             
         }                                                                                                              
         break;
      case 2:
         { double alphaMZ_old=alphaMZ; 
           if(correctDouble(3,15,"Enter new value ",&alphaMZ,1)) returnCode=1;
           if(alphaMZ>0 && alphaMZ<0.3) returnCode=1; else  
           { alphaMZ=alphaMZ_old;
              messanykey(5,15,"Your input is out of alphaMZ range");
           }
         }
         break;
      case 3:
         { int NF_old=alphaNF;
           if(correctInt(3,15,"Enter new value ",&alphaNF,1))
           {
              if(alphaNF<=6 && alphaNF>=3) returnCode=1;
              else { messanykey(5,15,"NF out of range"); alphaNF=NF_old;}
           }   
         }
         break;
      case 4:
         {  char lomen[]="\010"
               " LO     "
               " NLO    "
               " NNLO   ";
            void *pscrlo=NULL;
            int k=0;
            menu1(52,12,"",lomen,"",&pscrlo,&k);
            if(k) { alphaOrder=k; returnCode=1; put_text(&pscrlo);}
         }
         break;
      case 5: correctDouble(3,15,"Enter new value ",&MbMb,1);  break;
      case 6: correctDouble(3,15,"Enter new value ",&Mtp,1);   break;   
      case 7:
	{ void * screen;
	  int i;

	  static double qMin=1, qMax=1000;
	  static int nPoints=100;
	  if(returnCode) init_alpha();
	  get_text(1,1,maxCol(),maxRow(),&screen);

          if(correctDouble(40 ,15 ,"Q_min=",&qMin,0)&& qMin>=0.5
          && correctDouble(40 ,16 ,"Q_max=",&qMax,0)&& qMax>qMin
          && correctInt(33,17,"number of points=" ,&nPoints,0)
          && nPoints>3&& nPoints<=150)
	  { double *f[3]={NULL,NULL,NULL};
	    double *ff[3]={NULL,NULL,NULL};
	    char buff[3][100]; 
	    char* Y[3]={buff[0],buff[1],buff[2]};
	    switch(alphaOrder)
	    { case 1: sprintf(Y[0],"MSbar LO");   break;
	      case 2: sprintf(Y[0],"MSbar NLO");  break;
	      case 3: sprintf(Y[0],"MSbar NNLO"); break;
	      default:sprintf(Y[0],"MSbar");
	    }  
	       
	    int N,k;
	    f[0]=(double*) malloc(nPoints*sizeof(double));
            int xLog= (qMin>0 && qMax/qMin >10)? 1 : 0; 

	    for(i=0;i<nPoints;i++)
	    { double z=(i+0.5)/(double)(nPoints),q;
	      if(xLog) q=pow(qMin,1-z)*pow(qMax,z); else q=qMin*(1-z)+qMax*z;
	      f[0][i]=alpha_0(q);
//	      printf("i=%d %E\n",i,f[0][i]);
	    }
	    
	    N=1;	    
	    for(k=0;k<2;k++) if(sf_alpha[k])
	    {  
	       char buff[300];  
               strFunName(k+1,Y[N]);
               char *p=strstr(Y[N],"(proton");
               if(p) p[0]=0; else
               { p=strstr(Y[N],"(anti-proton");
                 if(p) p[0]=0;
               }  
	       f[N]=(double*) malloc(nPoints*sizeof(double));
               for(i=0;i<nPoints;i++)
               { double z=(i+0.5)/(double)(nPoints),q;
                 if(xLog) q=pow(qMin,1-z)*pow(qMax,z);
                    else  q=qMin*(1-z)+qMax*z;   
                 f[N][i]=(*sf_alpha[k])(q);
	       } 
	       N++;                                                      
            }
//            printf("N=%d Y[0]=%s\n Y[1]=%s\n Y[2]=%s\n", N,Y[0],Y[1],Y[2]);                                                         
//            plot_Nar(NULL, "Alpha(Q)",  log10(qMin), log10(qMax),"log10(Q/GeV)", nPoints, N, f,ff,Y);
              plot_Nar(NULL, "Alpha(Q)",  qMin,qMax,"Q/GeV", nPoints, xLog, N, f,ff,Y);
            for(k=0;k<N;k++) free(f[k]);
	  } else  messanykey(40,18,
	          " Correct input is \n"
	          " 0.5<= Q_min <Q_max\n"
	          " number of points <=150 and >=4");
	  put_text(&screen);
	} break;	

      case 8:
         { int npos=1,rc;
           do
           { 
              char mess[200];
              goto_xy(2,12); print("Renorm. scale: ");
              if(str_redact(Rscale_str,npos,60)==KB_ENTER) returnCode=1;
              goto_xy(2,12); clr_eol();
              rc=initScales(Rscale_str,F1scale_str,F2scale_str,Sscale_str, mess);
              if(rc) messanykey(10,10,mess);
           }  while(rc);
         }
	 break;


      case 9:
         { int npos=1,rc;
           do
           { 
              char mess[200];
              goto_xy(2,12); print("Fct1.scale: ");
              if(str_redact(F1scale_str,npos,60)==KB_ENTER) returnCode=1;
              goto_xy(2,12); clr_eol();
              rc=initScales(Rscale_str,F1scale_str,F2scale_str,Sscale_str, mess);
              if(rc) messanykey(10,10,mess);
           }  while(rc);
         }
	 break;
      case 10:
         { int npos=1,rc;
           do
           { 
              char mess[200];
              goto_xy(2,12); print("Fct1.scale: ");
              if(str_redact(F2scale_str,npos,60)==KB_ENTER) returnCode=1;
              goto_xy(2,12); clr_eol();
              rc=initScales(Rscale_str,F1scale_str,F2scale_str,Sscale_str, mess);
              if(rc) messanykey(10,10,mess);
           }  while(rc);
         }
	 break;
      case 11:
         { int npos=1,rc;
           do
           { 
              char mess[200];
              goto_xy(2,12); print("Shworing scale: ");
              if(str_redact(Sscale_str,npos,60)==KB_ENTER) returnCode=1;
              goto_xy(2,12); clr_eol();
              rc=initScales(Rscale_str,F1scale_str,F2scale_str,Sscale_str,mess);
              if(rc) messanykey(10,10,mess);
           }  while(rc);
         }
	 break;
	 
    }
    goto L10;
}
示例#9
0
void  decay12(void)
{ 
   int  i, k,L;
   void * pscr=NULL; 
   char * mlist;
   static int Branch=1;

   widths=(double*)malloc(sizeof(double)*nprc_int);

   for(i=1;i<=nvar_int;i++)
   {   if(!strcmp(varName_int[i],"Q"))  Q=va_int+i;
       else if(!strcmp(varName_int[i],"GG")) GG=va_int+i;
   }
 
   if(GG)for(i=1;i<=nvar_int+nfunc_int;i++) 
      if(!strcmp(varName_int[i],"SC")){ SC=va_int+i; break;}
   
   inmenutxt(&mlist);
   L=mlist[0];
   sscanf(mlist+1,"%s",inParticle);   

   for(k=1;k;) 
   {  
      char strmen[]="\030"        
         " Incoming particle      "
         " Show Branchings        "
         " QCD Scale Q= Free      "
         " Model parameters       "
         " Constraints            "
         " Parameter dependence   "
         " Les Houches output     ";

      clrbox(1,13, maxCol(), maxRow());
      nsubSel=0;
      decay12information(calcwidth12(),Branch);

      if(EffQmass) improveStr(strmen,"Free ","M1");
      if(!Branch)  improveStr(strmen,"Branchings","Partial widths"); 
      menu1(54,4,"",strmen,"n_12_*",&pscr,&k);

      switch (k)
      { 
        case 1:
           {
             if(strlen(mlist)>L+2)
             { void * pscr2=NULL;
               int k=1;
                menu1(56,5,"",mlist,"",&pscr2,&k);
               if(k)  sscanf(mlist+(k-1)*L+1,"%s",inParticle);
               put_text(&pscr2);
             }
           }
           break;
        case 2: Branch=!Branch;     break;
        case 3: EffQmass=!EffQmass; break;
        case 4: change_parameter(54,8,0); break;
        case 5: show_depend(54,8); break;
        case 6:
           { char proc[20];
             char dimInfo[20]="Width  [GeV]";
             void * pscr=selectChan();
             if(!pscr) break;
             if(nsubSel==0) sprintf(proc,"%s -> 2*x",inParticle); else
             { sprintf(proc," BR(%s ->  %s %s)",inParticle, 
                pinf_int(nsubSel,2,NULL,NULL),  pinf_int(nsubSel,3,NULL,NULL));
                dimInfo[0]=0;
             }  
	     paramdependence( calcwidth12,proc,dimInfo);
	     put_text(&pscr);
	   } break;
        case 7: writeLesHdecays(); break; 
      } 
   }
   free(widths);
   free(mlist);   
   clrbox(1,1,53,16);
   clrbox(1,16,maxCol(),maxRow());
}
示例#10
0
int enter(void)
{   
   int  i, y0,scat;
   int  redres;

   char ** items=NULL;
   char * errpos=NULL;
   char * arrpos=NULL;

   int curh=0;


   prtcllist(0);
   scrcolor(Red,BGmain);
   y0 = ycons;
   errTxt=NULL;
label_1:
   if(y0<maxRow()) y0++;  
   for(;y0>ycons;y0--){goto_xy(1,y0); clr_eol();} 

   if(arrpos) strncpy(arrpos,"->",2);

   redres=input(y0,"s_ent_1", "Enter  process: ",processch,errpos?errpos-processch+1:1,SSTRLEN); 
   switch (redres)
   {
	case KB_F1:   /*  Help  */
	       show_help("s_ent_1");
	       goto label_1;
	case KB_ESC: 
	       clrbox(1,2,maxCol(),24);
               return 1;
   }   /*  Case  */

   
   arrpos=strstr(processch,"->");
   if(arrpos)  strncpy(arrpos,", ",2); 
   else { errTxt="'->' is absent "; goto label_1; }
   if( strchr(processch,',')<arrpos ) scat=1; else scat=0;
   
   if(items) free(items);
   items=stritems(" ,",processch);

   for(i=0,nin=0,nout=0,n_x=0,curh=0; items[i]; i++)   
   {  char name[100];

      sscanf(items[i],"%[^, ]", name); 
      if(strlen(name)>7) {errTxt="Too long name"; break;}
      if(strlen(name)==0){errTxt="Empty item"; break;}
      if(items[i]>arrpos && strlen(name) == 3 && name[1] == '*' &&
             (name[2] == 'X' || name[2] == 'x')  &&
             isdigit(name[0])) {n_x += name[0]-'0'; nout +=name[0]-'0';}   
      else
      {
        if(curh==MAXINOUT-1){errTxt="Too many particles"; break;}
        if(items[i]>arrpos) nout++; else nin++; 
        if(nin>2){errTxt="Too many incoming particles"; break;}                  
        if(enter_h(&y0,name,curh,scat)) break;  
        curh++;
      }
   }
   
   errpos=items[i]; 
   free(items); items=NULL;
   if(errpos && !errTxt) 
   { sprintf(err_Txt,"wrong definition of %d-th particle",i+1);
      errTxt=err_Txt;
   }   
   if(errTxt) goto label_1;    
   if(nout<2)
   {  errTxt="The number of outgoing particles should  exceed 1";
      goto label_1;
   }
   if(nin<1)
   {  errTxt="Incoming  particle(s) is not defined";
      goto label_1; 
   }

   if(errpos||nin+nout>MAXINOUT) 
   {if(!errTxt) errTxt=errtxt; goto label_1; }   
    
   y0++;
   if(y0>=maxRow()-1) {y0=maxRow()-1; goto_xy(1,y0); clr_eol();}

   if(restrict_p(y0,1, "Exclude diagrams with ","s_ent_4",limpch,liminsp)
     ) goto label_1;

   for(nilprtcl(LimQ), i=0;i<liminsp[i].who;i++) if(liminsp[i].how <0)
   {
     liminsp[i].how =-liminsp[i].how;
     addlim(LimQ,liminsp[i].who,liminsp[i].how,0);
   }

   y0++;
   if(y0>=maxRow()-1) {y0=maxRow()-1; goto_xy(1,y0); clr_eol();} 
   if(n_x && restrict_p(y0,0,"Exclude X-particles ","s_ent_5",deloutch,limout)
     ) goto label_1;   
          
   for(i=nin+nout;i<MAXINOUT;i++) hadrons[i].name[0]=0;
  
   strncpy(arrpos,"->",2);

   return 0;
}
示例#11
0
int  viewresults(void)
{  
   int  k,kmenu;
   void *  pscr  = NULL;
 
   shortstr  newname;
   int dirStat=checkDir("results");

   if(dirStat==0){messanykey(10,15,"directory RESULTS is empty"); return 1;}

   kmenu = 1;   
label_1:

   menu1(10,10,"","\010"
      " View   "
      " Delete "
      " Rename ","s_res",&pscr,&kmenu);
      
   switch (kmenu)
   {
     case 0:
       return 0;         
     case 1: 
      viewDir("results");    
      break;

     case 2:
      if(dirStat==2)
      { char mess[]="Can not clean dir 'results' because it contains the LOCK file";
        if(blind) { printf("%s\n",mess); sortie(102);} 
        else { messanykey(3,13,mess); break;}
      } 
      if ( mess_y_n( 6,13," Delete files ") ) system("rm -r results; mkdir results");
      put_text(&pscr);
      return 1;
     case 3:
      strcpy(newname," ");
      while(1)
      {  void * pscr3;
         get_text(1,maxRow(),maxCol(),maxRow(),&pscr3); 
         goto_xy(1,maxRow());
         print("Enter new name: ");
	 k = str_redact(newname,1,30);
	 if (k == KB_ESC)
	 {   goto_xy(1,24);
             clr_eol();
             goto label_1;
         }
	 if (k == KB_ENTER)
         {
            trim(newname);
            if(rename("results",newname)==0)
            {
               mkdir("results",-1);
               put_text(&pscr);
               put_text(&pscr3);
               return 1;
            }
             else  messanykey(10,15," Can't rename the directory");
         }
         put_text(&pscr3);   
      }
   } 
   goto label_1;
}
示例#12
0
文件: mc_menu.c 项目: Omer80/wimps
static void f7_prog(int mode)
{ int pos=1;
  void *pscr=NULL;
  if(mode>2) 
  { messanykey(10,15," Highlight the corresponding\n"
                     "structure function");
    return;
  }     

  if(!sf_num[mode-1]) return;
  
  f3_key[4]=NULL;

  for(;;)
  {  static double xMin=0.0, xMax=1.0, scale = 91.187;
     static int nPoints=100;
     double f[150];
     
     char strmen[]="\030 "
                  " x-Min = XXX            "
                  " x-Max = YYY            "
                  " Npoints = NNN          "
                  " QCD-scale= QQQ         "
                  " Display plot x*F(x)    "
                  " Display plot F(x)      ";
     
     improveStr(strmen,"XXX","%.3f",xMin);
     improveStr(strmen,"YYY","%.3f",xMax);
     improveStr(strmen,"NNN","%d",nPoints);
     improveStr(strmen,"QQQ","%.1fGeV",scale); 

     menu1(54,14,"",strmen,"n_alpha_view",&pscr,&pos);

     switch(pos)
     {  case 0: f3_key[4]=f7_prog; 
                return;
        case 1:
          correctDouble(55,18,"xMin = ",&xMin,1);                  
          break; 
        case 2:
          correctDouble(55,18,"xMax = ",&xMax,1);                  
          break; 
        case 3:
          correctInt(50,18,"nPoints = ",&nPoints,1);
          break; 
        case 4: 
          correctDouble(50,18,"QCD-scale = ",&scale,1);
          break;
        case 5: case 6:
         if(xMin>=0 && xMax>xMin && xMax<=1 
            && nPoints>=3 && nPoints<=150 && scale>0.5)
         {
           void * screen;
           double dx=(xMax-xMin)/(2*nPoints);
           double be=sf_be[mode-1];
           int i;
           get_text(1,1,maxCol(),maxRow(),&screen);
           for(i=0;i<nPoints;i++)
           {  double x=xMin+(i+0.5)*(xMax-xMin)/nPoints;
              f[i]=strfun_(mode,x,scale);
              if(pos==5) f[i]*=x;
              if(be!=1.) f[i]*=be*pow(1.-x,be-1.);
           }
           {
              char p_name[20], mess[STRSIZ];
              strcpy(p_name,pinf_int(Nsub,mode,NULL,NULL));
              if(pos==5) strcat(p_name,"(x)*x"); else strcat(p_name,"(x)");
              strFunName(mode,mess);
              trim(mess);
              sprintf(mess+strlen(mess)," [QCD-scale = %.1f GeV]",scale); 
              plot_1(xMin+dx,xMax-dx,nPoints,f,NULL,mess,"x",p_name);  
           }
           put_text(&screen);
         } else messanykey(16,5," Correct input is \n"
                                "  0<=xMin<xMax<=1,\n"
                                " QCD-scale > 0.5 GeV\n"
                                " 3<=nPoints<=150");    
         break;    
      }
   }
}