Пример #1
0
static void f8_key_prog(int x)
{  
  static char FUNC[75]="2*2  % Press ESC to finish, F1 for help, ENTER to calculate";  
  int npos=1;
  void * pscr;
  get_text(1,20,80,21,&pscr);
  scrcolor(Red,White);   
  goto_xy(1,20); print("CALC : ");
  goto_xy(1,21); print("result=");
  scrcolor(Black,White);
  for(;;)
  { double res;
    int err; 
    int key;
    goto_xy(9,20); key=str_redact(FUNC,npos,70); 
    if(key==KB_ESC) break;
    else if(key==KB_F1)  show_help("n_calc");
    else if(key==KB_ENTER)
    {  goto_xy(8,21); 
       err=calcExpression(FUNC,rd_num,&res);
       goto_xy(9,21);
       if(err) {print("Erorr: %s",errmesstxt(err)); npos=rderrpos;}
       else  print("%E                     ",res); 
    }
  }
  put_text(&pscr);
}
Пример #2
0
void  sq_diagramsinfo(void)
{
   int n_sub, n_del, n_calc, n_rest;


   diag_stat(2,&n_sub,&n_del,&n_calc,&n_rest);
   if(!n_sub) return;

   goto_xy(15,9);
   scrcolor(Red,BGmain);
   print(" Squared diagrams \n");
   scrcolor(FGmain,BGmain);
   print("      diagrams in      subprocesses  are constructed.\n");
   print("      diagrams  are deleted.\n");
   print("      diagrams  are calculated.");
   scrcolor(Blue,BGmain);
   goto_xy(1,10);
   print("%d",n_del+n_calc+n_rest);
   goto_xy(20,10);
   print("%d",n_sub);
   goto_xy(1,11);
   print("%d",n_del);
   while (where_x() < 7) print(" ");
   goto_xy(1,12);
   print("%d",n_calc);
   goto_xy(1,13);
   
}
Пример #3
0
static int input(int y0, char*hlp, char*directive, char*text, int cur, int lim)
{
   if(errTxt)
   {
      goto_xy(1,y0+1); 
      scrcolor(FGmain,BGmain);
      clr_eol();
      print("%s","Error: ");
      scrcolor(Red,BGmain);
      print("%s",errTxt);
      scrcolor(FGmain,BGmain);
      if(blind) { printf("%s\n",errTxt); sortie(110);}
      be_be();
      errTxt=NULL;
   }
   for(;;) 
   { int rc;
     goto_xy(1,y0);  
     scrcolor(FGmain,BGmain);
     print("%s",directive);
     rc=str_redact(text,cur, lim);
     switch(rc)
     { case  KB_UP:
       case  KB_DOWN: 
       case  KB_PAGED:
       case  KB_PAGEU:  prtcllist(rc); continue;
       case  KB_F1:     show_help(hlp); continue; 
     }
     return rc;                            
   }
}
Пример #4
0
void         processinfo(void)
{
   goto_xy(5,3);
   scrcolor(Red,BGmain); print(" Process:  ");
   scrcolor(FGmain,BGmain);
   print("%s",processch);
}
Пример #5
0
void modelinfo(void)
{ 
  goto_xy(5,1);
  scrcolor(Red,BGmain); print("   Model:  ");
  scrcolor(FGmain,BGmain);
  print(currentModelName());
  if(forceUG) print("/Unitary Gauge/");
  else        print("                  ");
}
Пример #6
0
static void  infotext(void)
{
	goto_xy(1,4); 
   scrcolor(Red,BGmain);
	print(" %-53s\n","P(c.m.s.)    :");
	
	print(" Cos(p1,p3): min=                   max=            \n");
	print(" %-53s","Cross Section: ");
   scrcolor(FGmain,BGmain);
}
Пример #7
0
void  messanykey(int x1,int y1,char* txtstr)
{  
 int  fcolor_tmp=fColor;
 int  bcolor_tmp=bColor;
 char  newtext[STRSIZ];     
   scrcolor(White,Blue);
   sprintf(newtext,"%s\nPress any key ",txtstr);       
   message(x1,y1,newtext);
   scrcolor(fcolor_tmp,bcolor_tmp);
}
Пример #8
0
void modelinfo(void)
{ char buff[30];
  int size=modelmenu[0]; 
  goto_xy(5,1);
  scrcolor(Red,BGmain); print("   Model:  ");
  scrcolor(FGmain,BGmain);
  sprintf(buff,"%*.*s",size,size,modelmenu+(n_model*size-size+1));
  trim(buff); print(buff);
  if(forceUG) print("/Unitary Gauge/");
  else        print("                  ");
}
Пример #9
0
void         menuhelp(void)
{
  scrcolor(Red,BGmain);
  goto_xy(23,4);print("Abstract");
  scrcolor(FGmain,BGmain);
  goto_xy(1,6);
  print("     CalcHEP package is created for calculation of \n"); 
  print("  decay and high energy collision processes of     \n"); 
  print("  elementary particles in the lowest order (tree)  \n");
  print("  approximation. The main idea put into the CalcHEP\n");
  print("  was to make available passing from the lagrangian\n"); 
  print("  to the final distributions effectively with the  \n");
  print("  high level of automatization.\n");
  print("     Use F2 key to get information about interface \n");   
  print("  facilities and F1 - as online help.              \n");
  scrcolor(Yellow,BGmain);print("  Questions:"); scrcolor(Black,BGmain);
  print("https://answers.launchpad.net/calchep\n");
  scrcolor(Yellow,BGmain);print("       Bugs:");   
  scrcolor(Black,BGmain);
  print("https://bugs.launchpad.net/calchep\n");
           
  scrcolor(Black,BGmain);
  chepbox(1,5,53,17);
  scrcolor(FGmain,BGmain);
}
Пример #10
0
static void infor(void)
{ static int first=1;
  scrcolor(FGmain,BGmain);  
  clrbox(1,1,53,4);
  goto_xy(4,3); scrcolor(Red,BGmain);    print("(sub)Process: ");
  scrcolor(FGmain,BGmain); print("%s",Process);
  goto_xy(4,4); scrcolor(Red,BGmain);    print("Monte Carlo session: ");
  scrcolor(Black,BGmain);  print("%d",nSess);
  if(first) 
  {
     goto_xy(1,7); scrcolor(Blue, BGmain);
     print(" #IT %s Error[%%]  nCall    Eff.  chi^2", nin_int == 2? "Cross section[pb]":"   Width[GeV]    ");
  }
  if(integral.old) 
  { print("(continue)");     
    if(integral.n_it>0 && first)
    {
      goto_xy(1,8);scrcolor(FGmain, BGmain);
      integral.In=integral.s1/integral.n_it;               
      integral.dI=sqrt(integral.s0)/integral.n_it;                        
      if(integral.n_it<=1 || integral.s0==0 ) integral.khi2=0; else           
      integral.khi2=(integral.s2-integral.s1*integral.s1/integral.n_it)*integral.n_it/(integral.n_it-1)/fabs(integral.s0);
      print(" < >   %12.4E %10.2E %8d %7.7s %-7.1G" ,
      integral.In, fabs(integral.In)? 100*integral.dI/(double)fabs(integral.In):0., integral.nCallTot, effInfo(),integral.khi2);
    }      
  }  
  else 
  {   print("(begin)");
      scrcolor(FGmain,BGmain);                 
      clrbox(1,8,53,maxRow()-2);      
  }
  first=0;
}
Пример #11
0
static void  writeinformation(void)
{  double Pcm=va_int[0];
   scrcolor(FGmain,BGmain);
   goto_xy(18,4); print("%12f [GeV]    ",Pcm);   /*  Energy  */
   goto_xy(18,5); print("%8.6f",cos1);
   goto_xy(42,5); print("%8.6f",cos2);
}
Пример #12
0
static void writestatistic(void)
{
   scrcolor(Black ,BGmain);
   goto_xy(20,19); print("%4u",ndiagrtot);
   goto_xy(20,20);
   print("%2u (%%)",(((diagrcount - 1) * 100) / ndiagrtot));
   goto_xy(20,21); print("%4u",diagrcount);
}
Пример #13
0
int informline(long curent, long total)
{  int  xx;
   int res=0;
   static int Y;
   static int X;
   int xm=where_x(), ym=where_y(), fc=fColor,bc=bColor;
  
   if (curent == 0)
   {
      Y=maxRow();
      X=15;
/*      goto_xy(15,Y); scrcolor(Black,Red);
      memset(b,' ',50); b[50] = '\0';
*/
     goto_xy(15,Y); scrcolor(White,Red);
     print(" Calculation in progress. Calculation in progress.");                                                                     
/*            12345678901234567890123456789012345678901234567890 */
/*      print("%s",b); */
      goto_xy(15,Y);
      scrcolor(fc,bc);
      escpressed();
      goto exi;;
   }

   if(X>65 || X<15) X=15;
   
   xx = 15 + (50 * curent) / total;
   if (xx > 65) xx = 65;
   scrcolor(Black,Red);
   goto_xy(X,Y);
   while (where_x() < xx) print("%c",'X');
   if(xx !=X) { X=xx; res=escpressed();}
   if (curent >= total)
   {
      scrcolor(White,Black);
      goto_xy(1,Y); clr_eol();
      goto exi;
   }
   
   exi:
   
   scrcolor(fc,bc); goto_xy(xm,ym);   
   return res;
   
   
}
Пример #14
0
static int hbb_open(hbb_struct * hbb) {
  int x0=where_x(),
      y0=where_y();
  int i;
  if (hbb->status == 0 || hbb->onscreen) return 0;
  goto_xy(hbb->x,hbb->y);
  scrcolor(hbb->fgc,hbb->bgc);
  for (i=0;i<hbb->nb;i++) 
  {  if(where_x() + strlen(hbb->hbbar[i].name)+1 >= X2) { hbb->nb=i; break;} 
     print("%s",hbb->hbbar[i].name); 
     goto_xy(where_x()+1,hbb->y);
  }
                            
  scrcolor(hbb->fgc_off,hbb->bgc_off);
  goto_xy(x0,y0);
  hbb->onscreen=1;
  return 0;
}
Пример #15
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); 
} 
Пример #16
0
void         diagramsinfo(void)
{  int n_sub, n_del, n_calc, n_rest;

   diag_stat(1,&n_sub,&n_del,&n_calc,&n_rest);
   if(!n_sub) return;
   goto_xy(15,5);
   scrcolor(Red,BGmain);
   print(" Feynman diagrams \n");
   scrcolor(FGmain,BGmain);
   print("      diagrams in      subprocesses  are constructed.\n");
   print("      diagrams  are deleted.");
   scrcolor(Blue,BGmain);
   goto_xy(1,6);
   print("%d",n_del+n_calc+n_rest);
   goto_xy(20,6);
   print("%d",n_sub);
   goto_xy(1,7);
   print("%u",n_del);
   while (where_y() < 7) print(" ");
   
}
Пример #17
0
static int hbb_close(hbb_struct * hbb) {
  int x0=where_x(),
      y0=where_y();
  int i,j;
  if (hbb->status == 0 || !hbb->onscreen) return 0;
  goto_xy(hbb->x,hbb->y);
  scrcolor(hbb->fgc_off,hbb->bgc_off);
  for (i=0;i<hbb->nb;i++) for(j=0;j<=strlen(hbb->hbbar[i].name);j++)
      print("%c",hbb->bg);
  goto_xy(x0,y0);
  hbb->onscreen=0;
  return 0;
}
Пример #18
0
int     mess_y_n(int x1,int y1,char* txtstr)
{
  int      key;
  int      fcolor_tmp=fColor;
  int      bcolor_tmp=bColor;
  char  newtext[STRSIZ];

  scrcolor(White,Red);
  sprintf(newtext,"%s\n( Y / N ?) ",txtstr);       

  for(;;)
  {
    key = message(x1,y1,newtext);
/*    if(blind) printf(" %s   YES\n",newtext); */
    switch (key)
    {
      case 'N':
      case 'n': scrcolor(fcolor_tmp,bcolor_tmp);return 0;
      case 'Y':
      case 'y': scrcolor(fcolor_tmp,bcolor_tmp);return 1;
    }
  }
}
Пример #19
0
static void  total_cs(void)
{  double  totcs;

   goto_xy(18,6); 
   scrcolor(FGmain,BGmain);
   print("?                            "); 
   goto_xy(18,6);
   refresh_scr();
   calccoef(); 
   if (err_code ) print("incorrect"); else 
   {
      totcs= gauss345(cross_section, cos1,cos2,eps); 
      if (err_code<=0 ) { print("%-G [pb]",totcs);} 
      if(err_code==1)  print("?");
   }
}
Пример #20
0
static void printLn(FILE * iprt,int *line,char * format, ...)
{  
   va_list args;
   char dump[STRSIZ];
   va_start(args, format);
   vsprintf(dump,format,args);
   va_end(args);

   goto_xy(1,*line); print("%53s","");
   goto_xy(1,*line);
   print("%s\n",dump); 
   (*line)++;
   if (*line >= maxRow()-2 ) *line=8; else 
   {
     scrcolor(Blue, BGmain);
     print("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
   }   
   if(iprt) {fprintf(iprt,"%s\n",dump); fflush(iprt);}
}
Пример #21
0
static void init_stat(void)
{
   goto_xy(1,17);
   scrcolor(Yellow,Blue);
   print(" C Source Codes \n");
   scrcolor(Red,BGmain);
   print(" Process..........\n");
   print(" Total diagrams...\n");
   print(" Processed........\n");
   print(" Current..........\n");
   scrcolor(Yellow,Blue);
   print(" Press Esc to stop    ");
   scrcolor(Black,BGmain);
   goto_xy(20,18); print("%s",processch);
   goto_xy(20,19); print("%4u",ndiagrtot);
   goto_xy(20,20); print("   0");
   scrcolor(Yellow ,BGmain);
   goto_xy(20,21); print("   1");
   scrcolor(Yellow,BGmain);
}
Пример #22
0
int  str_redact(char* txt,int npos, int maxLen)
{  int    i, x, x0, y0;
   int key;
   int first;
   char    txttmp[STRSIZ];
   int t_color=Yellow;   
   int saveFcolor=fColor, saveBcolor=bColor;
   clearTypeAhead();

   strcpy(txttmp,txt);
   if(strlen(txt)>maxLen) txt[maxLen]=0;
   first = 1;
   
   scrcolor(t_color,Black);
   y0 = where_y();
   x0 = where_x();
   print("%-*s",maxLen,txt);
      if (npos<1) npos=1;
   if (npos>strlen(txt)) npos=strlen(txt)+1;
   x = x0 + npos - 1;
   scrcolor(Black,White); 
   goto_xy(x,y0);
   if(npos>strlen(txt)) print("%c",' ');else print("%c",txt[npos-1]);
   scrcolor(t_color,Black);
   goto_xy(x,y0);

   for(;;)
   {
      key = inkey();

      switch (key)
      {	
         case KB_MOUSE:
         if ( mouse_info.row == where_y() && mouse_info.but1 == 2 ) 
         {  npos=mouse_info.col-x0+1; }
         break;
         	
         case 9:      /*  Tab  */
            do
            {
               npos++;
               if (npos > strlen(txt)) npos = 0;
            }  while (!(npos==0 || txt[npos-1] == ','));
            x = x0 + i;
         break;

         case KB_END:
            npos=strlen(txt)+1;   /* End    */
         break;

         case KB_HOME:
            npos=1;   /*  Home  */
         break;


         case KB_RIGHT:
            npos++;
         break;

         case KB_LEFT:
            npos--;
         break;


         case KB_BACKSP:
	   if (npos > 1) npos--; else break;

         case KB_DC:
	   if (npos<=strlen(txt)) for(i=npos-1; txt[i]; i++) txt[i]=txt[i+1];
         break;


         case KB_ESC:
            strcpy(txt,txttmp);
            npos=1;

         case KB_ENTER:
         case KB_F1:
	 case KB_PAGEU:
	 case KB_PAGED:
	 case KB_UP:
	 case KB_DOWN:
            goto label_1; 

         default:
	    if (key > 31 && key <128 && npos<maxLen)                                         
            {                                                               
              if (first)                                                    
              {                                                             
                 sprintf(txt,"%c",key);                                     
                 npos = 2;                                                  
                 x = x0 + npos - 1;                                         
              }                                                             
              else                                                          
              {                                                             
                 if(strlen(txt)>=maxLen-1) txt[maxLen-2]=0; 
                 for (i=MIN(strlen(txt)+1,maxLen-1);i>= npos;i--) 
                                            txt[i] = txt[i-1]; 
                 txt[npos-1] = key; 
                 npos++;
              }                                                             

            }                                                               
      }

      goto_xy(x0,y0); print("%-*s",maxLen,txt);

      if(npos<=0) npos=1;
      if(npos>strlen(txt)) npos=strlen(txt)+1;  
      x=x0+npos-1;
      scrcolor(Black,White); 
      goto_xy(x,y0);        
      if(npos>strlen(txt)) print("%c",' ');else print("%c",txt[npos-1]);
      scrcolor(t_color,Black);
      goto_xy(x,y0);      
   
      first = 0;
   }

label_1: 
   goto_xy(x0,y0);
   if(key!=KB_ESC) print("%s",txt);
   scrcolor(saveFcolor,saveBcolor);
   return key;
}
Пример #23
0
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;   
} 
Пример #24
0
void  cheplabel(void)
{
 int  key; 
 char fname[STRSIZ];
 FILE *f;

 while(1)
 { 
   { int X=20,Y=1;
     scrcolor(FGmain,BGmain);
     goto_xy(X,Y);  print("Skobeltsyn Institute of Nuclear Physics,");
     goto_xy(X+8,Y+1);  print("Moscow State University.");
   }

   { int Y=5;
     scrcolor(Blue,LightGray);
     goto_xy(7,Y); print("CalcHEP - a package for Calculation in High Energy Physics");
     scrcolor(FGmain,BGmain);
     goto_xy(15,Y+1);  print("Version 2.4.4; Last correction August 23,2006");
   }

   { int Y=7;

     scrcolor(FGmain,BGmain); 
     goto_xy(3,Y+2);print("  Author of the package:");
     scrcolor(Blue,LightGray);
     print(" Alexander Pukhov");
     scrcolor(FGmain,BGmain);
     goto_xy(14,Y+3);print("For contacts:");
     scrcolor(Blue,LightGray);   
     goto_xy(28,Y+3);print("email: <*****@*****.**>");
     goto_xy(28,Y+4);print("http://theory.sinp.msu.ru/~pukhov/calchep.html");
     goto_xy(28,Y+5);print("http://www.ifh.de/~pukhov/calchep.html");
   }

   { int Y=14;
     scrcolor(FGmain,BGmain);
     goto_xy(5,Y);print("The package contains codes written by:");
     scrcolor(Blue,LightGray);
     goto_xy(10,Y+1); scrcolor(Blue,LightGray); 
     print("M.Donckt,V.Edneral,V.Ilyin,D.Kovalenko,A.Kryukov,G.Lepage,A.Semenov");
     
/*     print("G.Belanger,F.Boudjema,A.Djouadi,V.Edneral,V.Ilyin,J.-L.Kneur,");
     goto_xy(10,Y+2); 
     print("A.Kryukov,G.Lepage,G.Moultaka,A.Semenov");
*/     
   }
   
{ 
 int Y=17;
     scrcolor(FGmain,BGmain);
     goto_xy(5,Y);print("The BS models for CalcHEP were developed in collaboration with:");
     scrcolor(Blue,LightGray);
     goto_xy(10,Y+1); scrcolor(Blue,LightGray); 
     print("G.Belanger,A.Belyaev,F.Boudjema,A.Semenov");
}   

   { int X1=19, X2=61, Y1=21, Y2=Y1+2;
     scrcolor(FGmain,BGmain);
     goto_xy(X1+2,Y1-1); print("Press F9 or click the box below to get");

     scrcolor(Blue,LightGray);  
     chepbox(X1,Y1,X2,Y2);

     goto_xy(X1+3,Y1+1); print("References and Contributions ");
/*     goto_xy(X1+3,Y1+2); print("   and  relative information.      "); */
    
     scrcolor(FGmain,BGmain);
     goto_xy(3,Y2+1); print("This information is available during the session by means of the F9 key"); 
     clearTypeAhead();
     key= inkey();
     if(key==KB_F9 || ( key==KB_MOUSE  
                   && mouse_info.row>=Y1 && mouse_info.row<=Y2 
                   && mouse_info.col >=X1 &&  mouse_info.col<=X2 ) )
     { 
       sprintf(fname,"%s%cCITE",pathtocomphep,f_slash);
       f=fopen(fname,"r");
       showtext (1, 1, 80,1,"",f);
       fclose(f);
       break;
     }
     if(key !=KB_MOUSE) break;
   }
 }
 clr_scr(FGmain,BGmain);
}
Пример #25
0
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;
}
Пример #26
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);
}
Пример #27
0
void showtext(int x1, int y1, int x2, int y2, char* headline,
 FILE * fileptr )
{
   int   key;
   void *  pscr;
   int   i,l;
   linelist  currentline=NULL,lastline;
   int width=x2-x1-1;
   int fc=fColor,bc=bColor;	

   if (fileptr==NULL || !readnewline(fileptr,width,&currentline))
   {
      messanykey(10,10," File is empty");
      return;
   }
	       
   if(y2<=y1+1) 
      for (y2=y1+2;y2<maxRow()&&readnewline(fileptr,width,&currentline);y2++)
         currentline=currentline->next;	      
            
   get_text(x1,y1,x2,y2,&pscr);

   scrcolor(Black,White);
   chepbox(x1,y1,x2,y2);
   scrcolor(Red,White);	
   goto_xy(x1+1,y1); print("*");
   l=strlen(headline);
   if ( l < (x2-x1) )
   {
      goto_xy(x1+(x2-x1-l)/2,y1);
      scrcolor(White,Black);
      print(headline);
      scrcolor(Black,White);
   }

   key = KB_PAGEU;
   do
   {
      switch (key)
      {
	case KB_PAGEU:
	   for (i=y1+1;i<y2;i++)
	     if (currentline->pred !=NULL)  currentline=currentline->pred;
           break;

	case KB_UP:
	   for(i=1;i<(y2-y1)/2;i++)
              if (currentline->pred !=NULL)  currentline=currentline->pred;
	   break;

	case KB_PAGED: 
	   for (i=y1+1;i<y2;i++)
	   {
	      readnewline(fileptr,width,&currentline);
	      if (currentline->next !=NULL)  currentline=currentline->next;
	   }
	   break;

	case KB_DOWN:
	   for(i=1;i<(y2-y1)/2;i++)
           {
	      readnewline(fileptr ,width,&currentline);
	      if (currentline->next !=NULL)  currentline=currentline->next;
	   }
			break;

      }  /*  Case  */

/*    display */

      lastline=currentline;
      goto_xy(x2-4,y1); 
      if( lastline->pred == NULL) for (i=0;i<4;i++) print("%c",boxFrame[1]);
              else                print("PgUp");
      for (i =y1+1; i <y2; i++)
      {
	   goto_xy(x1+1,i);
	   readnewline(fileptr,width,&lastline);
	   if ( lastline !=NULL ) { print("%s",lastline->line);
	   lastline=lastline->next;}
	   print(buff+where_x()+80-x2);
      }
      goto_xy(x2-4,y2);
      if (lastline == NULL) for (i=0;i<4;i++) print("%c",boxFrame[5]);
              else                            print("PgDn");   
      key = inkey();
/* mouse filter */
       if ( (key == KB_MOUSE)&&(mouse_info.but1==2)
         &&(mouse_info.col >= x1)&&(mouse_info.col <= x2)  )
       { 
         if (x2 - mouse_info.col <4 ) 
         { if(mouse_info.row == y1) key=KB_PAGEU; else            
           if(mouse_info.row == y2) key=KB_PAGED;
         }   
         if ( (mouse_info.row == y1)&&(mouse_info.col - x1 <3)) key=KB_ESC;
         if ((mouse_info.row > y1)&&(mouse_info.row < y2))                        
         { if (mouse_info.row < (y1+y2)/2)  key=KB_UP; else key=KB_DOWN;}
       }                   
/* end of filter */                                        
   }  while ((key != KB_ESC)&&(key !=KB_BACKSP));
     
   scrcolor(fc,bc);
   put_text(&pscr);
   while (currentline->pred != NULL )  currentline=currentline->pred;
   dellinelist(currentline);

}
Пример #28
0
int runVegas(void)
{
    int i;
    double sd;
    double avgi;
    char mess[25];
    FILE * iprt = NULL;
    int mode=1;
    void * pscr=NULL;
    static int n_Line=0;
    
    if(blind) vegas_control=NULL; else  vegas_control=infoLine;
    i=imkmom(inP1,inP2);
    if(veg_Ptr&&veg_Ptr->dim!=i)clearGrid();
    if(!veg_Ptr) veg_Ptr=vegas_init(i,func_,50);     

    if(nin_int == 2) strcpy(mess, "Cross section[pb]");
      else           strcpy(mess, "   Width[Gev]    ");
    
/* ** save current session parameters */
     w_sess__(NULL);
/* ** open protocol and resulting files */
       
    {  char fname[50];
       sprintf(fname,"%sprt_%d",outputDir,nSess);
       iprt=fopen(fname,"a");
    }

/* **  initkinematics */

    while(correctHistList()) editHist();

    if(integral.old) { if(!n_Line)  n_Line=9;} else
    {
       w_sess__(iprt);
       n_Line=8;
    }
                           
/* *** Main cycle */

    for(;;)
    {
        int fz;
        char strmen[]="\030"
         " nSess  = N2_1          "
         " nCalls = N1_1          "
         " Set  Distributions     "
         "*Start integration      "
         " Display Distributions  "
         " Clear statistic        "
         " Freeze grid        OFF " 
	 " Clear  grid            "
	 " Event Cubes NCUBE      "
	 " Num. of events=NE      "
	 " Generate Events        ";
	 
        if(integral.freeze)
        {  fz=1;
           improveStr(strmen,"OFF","ON");
           improveStr(strmen,"NCUBE","%d",EventGrid);
        }  
        else
        {  fz=0;
           strmen[ 030*8+2]=0;
        }

        improveStr(strmen,"N1_1","%d",integral.ncall[fz]);
        improveStr(strmen,"N2_1","%d",integral.itmx[fz]);
        improveStr(strmen,"NE","%d",nEvents);
        menu1(54,7,"",strmen,"n_veg_*",&pscr,&mode);
        switch(mode)
        {     
        case 0:
           w_sess__(NULL);
          if(iprt) fclose(iprt);
          return 0;           
        case 1: correctInt(50,12,"Enter new value ", integral.itmx+fz,1);  break;
        case 2: correctLong(50,12,"Enter new value ",integral.ncall+fz,1);break;
        case 3:  editHist(); break;
        case 4:
          if(veg_Ptr->fMax && !integral.freeze) 
          {  free(veg_Ptr->fMax); veg_Ptr->fMax=NULL; veg_Ptr->evnCubes=0; }
          if(!veg_Ptr->fMax && integral.freeze)
          {  setEventCubes(veg_Ptr, EventGrid);
             EventGrid=veg_Ptr->evnCubes;
          }

          for (i = 1; i <= integral.itmx[fz]; ++i)                                       
          { char  errtxt[100]="";
            long nCall;
            if(integral.ncall[0]==0) break;                                                                  
            negPoints=0;                                                              
            badPoints=0; 
            hFill=1;   
            nCall=vegas_int(veg_Ptr, integral.ncall[fz],1.5*(!fz),nPROCSS,&avgi, &sd);
            if(nCall<0) { messanykey(10,10,"NaN in integrand"); break;}
            if(nCall==0) break;
            
            integral.old=1;                                              
            negPoints/=nCall;                                                         
            badPoints/=nCall;                                                         
            integral.nCallTot+=nCall;                                                          
            scrcolor(FGmain,BGmain);                                                 
            printLn(iprt,&n_Line,"%4d   %12.4E %10.2E %8d %s",                     
                 ++integral.n_it, avgi,avgi? 100*sd/(double)fabs(avgi):0.,nCall,effInfo());
                                                                   
            if(negPoints<0) sprintf(errtxt+strlen(errtxt)," Negative points %.1G%%;",                
                                      -100*negPoints/(avgi-2*negPoints));             
            if(badPoints)  sprintf(errtxt+strlen(errtxt),                             
                 "Bad Precision %.1G%%;",100*badPoints/(avgi-2*negPoints));           
                                                                                      
            if(errtxt[0])                                                             
            {                                                                         
               scrcolor(Red,BGmain);                                                  
               printLn(iprt,&n_Line,"%s",errtxt);                                     
            }
                                                                                                                                                
            integral.s0+=sd*sd;                                                                  
            integral.s1+=avgi;                                                             
            integral.s2+=avgi*avgi;                                    
          } 
          
          
          integral.In=integral.s1/integral.n_it; 
          integral.dI=sqrt(integral.s0)/integral.n_it;
          if(integral.n_it<=1 || integral.s0==0 ) integral.khi2=0; else 
          integral.khi2=(integral.s2-integral.s1*integral.s1/integral.n_it)*integral.n_it/(integral.n_it-1)/fabs(integral.s0);  
          
          scrcolor(FGmain,BGmain);

          printLn(iprt,&n_Line," < >   %12.4E %10.2E %8d %7.7s %-7.1G" ,
                      integral.In, fabs(integral.In)? 100*integral.dI/(double)fabs(integral.In):0., integral.nCallTot, 
                                                              effInfo(),  integral.khi2);
          if(histTab.strings)
          { char  fname[20];
            FILE * d;
            sprintf(fname,"distr_%d",nSess);
            d=fopen(fname,"w");  
            wrt_hist2(d,Process);
            fclose(d);
          }
                    messanykey(54,11,"Integration is over");
/*          integral.freeze=0; */
          break;

        case 5: showHist(54,10,Process); break;
        case 6: clearStatistics(-1);
                messanykey(54,13,"Old results for integral\n"
                "and distributions\nare deleted.");
                break;
        case 7: 
             if(veg_Ptr->fMax && integral.freeze) 
             {  if(mess_y_n(15,15,"You have event generator prepared.\n"
                " Setting the flag \"OFF\"  will destroy it."
                " Press 'Y' to confirm.")) integral.freeze=0; 
             } else  integral.freeze=!integral.freeze; 
             break; 
        case 8: if(!integral.freeze || mess_y_n(15,15,"The information for Event Generator will be lost\n OK?"))  
                { int ndim=veg_Ptr->dim;
                  vegas_finish(veg_Ptr);
                  veg_Ptr=vegas_init(ndim,func_,50);
                  messanykey(57,11,"OK");
                }   
                break;
        case 9: 
           if(correctLong(50,12,"Enter new value ",&EventGrid,1))
           { if(veg_Ptr->fMax) {free(veg_Ptr->fMax); veg_Ptr->fMax=NULL;}
             printf("EventGrid=%d\n",EventGrid);
             setEventCubes(veg_Ptr, EventGrid);
             EventGrid=veg_Ptr->evnCubes;  
           } break;
        case 10:  correctInt(50,15,"",&nEvents,1); break;
        case 11: 
           if( !veg_Ptr || !veg_Ptr->fMax)
           { char * mess="Before event generation one has to launch  Vegas session with freezed grid\n"
                                           "to prepare generator";
                if(blind) { printf("%s\n",mess); sortie(200);}  else messanykey(4,13,mess);
           } else  runEvents();
       }
    }    
}
Пример #29
0
void  mk_reduceprograms(void)
{
   int          ndel, ncalc, nrest, i;
   long         nrecord, naxu;
   csdiagram    csd;
   unsigned     ncalctot;
   shortstr     txt;
   hlpcsptr     gstlist, c;
   vcsect       vcs_copy;
   s_listptr    d_facts, df;
   rmptr        t_fact;

   goto_xy(1,21); scrcolor(Yellow,Blue);
   print("  REDUCE code generation \n");
   scrcolor(Red,BGmain);
   print(" Generated........\n");
   print(" current diagram :\n");
   scrcolor(Yellow,Blue);
   print(" Press Esc to halt REDUCE codes generation ");
   scrcolor(FGmain,BGmain);
   diagrq=fopen(DIAGRQ_NAME,"rb");
   ncalctot = 0;
   menuq=fopen(MENUQ_NAME,"rb");

   for(nsub=1;nsub<=subproc_sq;nsub++) 
   {
      rd_menu(2,nsub,txt,&ndel,&ncalc,&nrest,&nrecord);
      fseek(diagrq,nrecord*sizeof(csdiagram),SEEK_SET);
      naxu = ndel + ncalc + nrest;
      for (ndiagr = 1; ndiagr <= naxu; ndiagr++)
      {
	 goto_xy(20,22); print("%u",ncalctot);
	 goto_xy(20,23); print("%u",ndiagr); clr_eol();
         FREAD1(csd,diagrq);
         if (csd.status != -1)
         { 
            outFileOpen("%sresults%cp%d_%d.red",pathtouser,f_slash,nsub,ndiagr);
            writeLabel('%');
            writeF("%%\n");
            
            transfdiagr(&csd,&vcs);

            cwtarg(&vcs);
            if (vcs.clrnum == 0)
            {
               writeF(
                  "%%-------  Zero color factor --------\n");
               writeF("totFactor_:=0$\n");
               writeF("numerator_:=0$\n");
               writeF("denominator_:=1$\n");
            }
            else
            {
               generateghosts(&vcs,&gstlist);
               if (gstlist == NULL)
               {
                  writeF( "%%-------  non-existent diagram  --------\n");
                  writeF("totFactor_:=0$\n");
                  writeF("numerator_:=0$\n");
                  writeF("denominator_:=1$\n");
               }
               else
               {
		  goto_xy(40,23);
		  print("(%% %4d subdiagrams)",gstlist->maxnum);
		  writeF("%% The total number of diagrams %d\n",gstlist->maxnum);
                  preperdiagram();
                  head();
                  emitfactors();
                  diagramsrfactors(gstlist,&d_facts,&t_fact);
                  writeF("totFactor_:=%s$\n",rmonomtxt(*t_fact));

                 writeF("totFactor_:="
                       "totFactor_*SymmFact*AverFact*FermFact*ColorFact$\n");
                 
                  clrvm(t_fact->n.v);
                  clrvm(t_fact->d.v);
                  free(t_fact);

                  writesubst();
                  writeF("numerator_:=0$\n");

                  c = gstlist;
                  df = d_facts;
                  vcs_copy = vcs;
                  while (c != NULL)
                  {
                     coloringvcs(c);
                     writeF("%%  diagram  number =   %d\n", c->num);
                     DiagramToOutFile(&vcs,1,'%');

                     {int k; int sgn=c->sgn;
                      for(k=0;k<vcs.sizet;k++) sgn*=vertexes[k].lgrnptr->factor;
                      writeF("  GhostFact:=%d$\n",sgn);
                     }
                     
		     findReversVert();
                     attachvertexes();

                     emitreducecode();

                     writeF(" numerator_:=numerator_ +(%s)*GhostFact*Vrt_1 $\n",
                        smonomtxt(df->monom));
                     writeF(" Clear Vrt_1,GhostFact$\n");
                     writeF("%%\n");

                     vcs = vcs_copy;
                     c = c->next;
                     df = df->next;
                  }

                  eraseslist(d_facts);
                  eraseghosts(gstlist);

                  vcs = vcs_copy;
                  emitdenoms();
	          writeF(" Clear p%d",nin + nout + 1);
                  for (i = nin + nout + 2; i <= 12; i++)
	          writeF(",p%d",i);
                  writeF("$\n");
                  writeF("%%\n");

               }
            }
            writeF("End$\n");
            outFileClose();
            --(nrest);
            ++(ncalctot);
            if (escpressed()) goto exi;
         }
      }
   }

exi: 
   fclose(diagrq); fclose(menuq);
   clrbox(1,21,70,24);

}
Пример #30
0
int runVegas(void)
{
    int i;
    double sd;
    double avgi;
    char mess[25];
    FILE * iprt = NULL;
    int mode=1;
    void * pscr=NULL;
    static int n_Line=7;

    i=imkmom(inP1,inP2);
    if(veg_Ptr&&veg_Ptr->ndim!=i)clearGrid();
    if(!veg_Ptr) veg_Ptr=vegas_init(i,50);     

    if(nin_int == 2) strcpy(mess, "Cross section[pb]");
      else           strcpy(mess, "   Width[Gev]    ");
    
/* ** save current session parameters */
     w_sess__(NULL);
/* ** open protocol and resulting files */
       
    {  char fname[50];
       sprintf(fname,"%sprt_%d",outputDir,nSess);
       iprt=fopen(fname,"a");
       if(ftell(iprt)==0) 
       { fprintf(iprt,"    CalcHEP kinematics module \n The session parameters:\n");
         w_sess__(iprt);
         fprintf(iprt,"===================================\n");   
       }
    }

/* **  initkinematics */

    while(correctHistList()) editHist();
    
/* *** Main cycle */
    if(!integral.old || n_Line==7)
    { n_Line=7;
      scrcolor(Blue, BGmain);
//    printLn(iprt,&n_Line," #IT  %20s Error %%    nCall   chi**2",mess); 
      printLn(iprt,&n_Line," #IT %s Error[%%]  nCalls   Eff.  chi^2",mess);
    }

    for(;;)
    {
        static int worn=1;
        char strmen[]="\030"
         " nSess  = N2_1          "
         " nCalls = N1_1          "
         " Set  Distributions     "
         "*Start integration      "
         " Display Distributions  "
         " Clear statistic        "
         " Freeze grid        OFF " 
	 " Clear  grid            "
	 " Event Cubes NCUBE      "
	 " Generate Events        ";

        improveStr(strmen,"N1_1","%d",integral.ncall[0]);
        improveStr(strmen,"N2_1","%d",integral.itmx[0]);
        improveStr(strmen,"NCUBE","%d",EventGrid);

        if(integral.freeze) improveStr(strmen,"OFF","ON");

        menu1(54,7,"",strmen,"n_veg_*",&pscr,&mode);
        switch(mode)
        {     
        case 0:
          if(iprt) fclose(iprt);
          return 0;           
        case 1:  
          correctInt(50,12,"Enter new value ",&integral.itmx[0],1); break;
        case 2: 
          correctLong(50,12,"Enter new value ",&integral.ncall[0],1); break;
        case 3:  editHist(); break;
        case 4:
          if(veg_Ptr->fMax && !integral.freeze)
          {  if(!mess_y_n(15,15,"You have event generator prepared.\n"
             " The  answer 'Y'  will start Vegas session \nwhich destroys it."
             " To save the event generator answer 'N' \nand set "
             " ' Freeze grid' ON")) break;
             else { free(veg_Ptr->fMax); veg_Ptr->fMax=NULL; veg_Ptr->nCubes=0;}  
          }
          for (i = 1; i <= integral.itmx[0]; ++i)                                       
          { double sum;
            char  errtxt[100]="";
            int k;

            if(integral.ncall[0]==0) break;
            nCall=0;                                                                  
            negPoints=0;                                                              
            badPoints=0; 
            hFill=1;  
            if(vegas_int(veg_Ptr, integral.ncall[0],1.5*(!integral.freeze), 
                 func_, &avgi, &sd)        
              ) break;
            integral.old=1;                                              
            negPoints/=nCall;                                                         
            badPoints/=nCall;                                                         
            integral.nCallTot+=nCall;                                                          
            scrcolor(FGmain,BGmain);                                                 
            printLn(iprt,&n_Line,"%4d   %12.4E %10.2E %8d %s",                     
                 ++integral.n_it, avgi,avgi? 100*sd/(double)fabs(avgi):0.,nCall,effInfo());
                                                                   
            if(negPoints<0) sprintf(errtxt+strlen(errtxt)," Negative points %.1G%%;",                
                                      -100*negPoints/(avgi-2*negPoints));             
            if(badPoints)  sprintf(errtxt+strlen(errtxt),                             
                 "Bad Precision %.1G%%;",100*badPoints/(avgi-2*negPoints));           
                                                                                      
            if(errtxt[0])                                                             
            {                                                                         
               scrcolor(Red,BGmain);                                                  
               printLn(iprt,&n_Line,"%s",errtxt);                                     
            }
                                                                                                                                                
            integral.s0+=sd*sd;                                                                  
            integral.s1+=avgi;                                                             
            integral.s2+=avgi*avgi;                                    
          } 
          
          
          integral.In=integral.s1/integral.n_it; 
          integral.dI=sqrt(integral.s0)/integral.n_it;
          if(integral.n_it<=1 || integral.s0==0 ) integral.khi2=0; else 
          integral.khi2=(integral.s2-integral.s1*integral.s1/integral.n_it)*integral.n_it/(integral.n_it-1)/fabs(integral.s0);  
          
          scrcolor(FGmain,BGmain);

          printLn(iprt,&n_Line," < >   %12.4E %10.2E %8d %7.7s %-7.1G" ,
                      integral.In, fabs(integral.In)? 100*integral.dI/(double)fabs(integral.In):0., integral.nCallTot, 
                                                              effInfo(),  integral.khi2);
          if(histTab.strings)
          { char  fname[20];
            FILE * d;
            sprintf(fname,"distr_%d",nSess);
            d=fopen(fname,"w");  
            wrt_hist2(d,Process);
            fclose(d);
          }
                    messanykey(54,11,"Integration is over");
/*          integral.freeze=0; */
          break;

        case 5: showHist(54,10,Process); break;
        case 6: clearStatistics(-1);
                messanykey(54,13,"Old results for integral\n"
                "and distributions\nare deleted.");
                break;
        case 7: integral.freeze=!integral.freeze; break; 
        case 8: if(!integral.freeze || mess_y_n(15,15,"The information for Event Generator will be lost\n OK?"))  
                { int ndim=veg_Ptr->ndim;
                  vegas_finish(veg_Ptr);
                  veg_Ptr=vegas_init(ndim,50);
                  messanykey(57,11,"OK");
                }   
                break;
        case 9: 
           if(correctLong(50,12,"Enter new value ",&EventGrid,1))
           { if(veg_Ptr->fMax) {free(veg_Ptr->fMax); veg_Ptr->fMax=NULL;veg_Ptr->nCubes=0;}} break;
        case 10: 
           if( !veg_Ptr || !veg_Ptr->fMax)
           { char * mess="Before event generation one has to launch  Vegas session with freezed grid\n"
                                           "to prepare generator";
                if(blind) { printf("%s\n",mess); sortie(200);}  else messanykey(4,13,mess);
           }    else    runEvents(); 
       }
    }    
}