Ejemplo n.º 1
0
int m_epp__ (int i,int*pString)
{
  void *pscr = NULL;
  i--;
  for (;;)
    {
      char strmen[] = "\050"
      " Incoming particle mass = XXX           "
      " Incoming particle charge = YYY         "
      " |Q^2|max = ZZZ                         "
      " Pt cut of outgoing proton = VVV        ";
      int mode;
      improveStr (strmen, "XXX", "%.10G GeV", xin[i]);
      improveStr (strmen, "YYY", "%d e", charge[i]);
      improveStr (strmen, "ZZZ", "%.8G GeV^2", q2_max[i]);
      improveStr (strmen, "VVV", "%.9G GeV", pt_min[i]);
      menu1 (38, 10, "", strmen, "n_sf_epp", &pscr, &mode);
      switch (mode)
	{
	case 0: return 1;
	case 1: correctDouble (40, 16, "Enter new value ", xin + i, 1);break;
	case 2:	charge[i]*=-1;break;
	case 3: correctDouble (40, 16, "Enter new value ", q2_max +i,1);break;
	case 4: 
	  do {correctDouble (40, 16, "Enter new value ", pt_min +i,1);}
          while((pt_min[0]>sqrt(q2_max[0])&& pt_min[0]>Maxpt_min) ||
                (pt_min[1]>sqrt(q2_max[1])&& pt_min[1]>Maxpt_min));
                           
	  /* kinematic and q2 approximation limitation */
	}
    }
    return 1;
}
Ejemplo n.º 2
0
static void f5_key_prog(int x)
{
  int kmenu=1;
  void * pscr=NULL;

  while(kmenu) 
  {  
    char strmen[]="\040"
                  " Virtual W/Z decays          OF5"
                  " Parallelization          nCORES"
                  " Allow weighted events      OF_ ";   
 
    if(VWdecay)  improveStr(strmen,"OF5","ON ");
        else     improveStr(strmen,"OF5","OFF");    
    improveStr(strmen,"nCORES","%d",nPROCSS); 
    if(regenEvents) improveStr(strmen,"OF_","OFF"); else improveStr(strmen,"OF_","ON");   
                                          
    menu1(20,18,"Switches",strmen,"n_switch_*",&pscr,&kmenu);
    if(kmenu==1) 
    {  VWdecay=!VWdecay;
       if(checkParam()>0){VWdecay=!VWdecay;checkParam();};
    } else if(kmenu==2) 
    { char mess[40];
      sprintf(mess,"There are %d processors. To use ", (int) sysconf(_SC_NPROCESSORS_ONLN));
      correctInt(20,22,mess,&nPROCSS,1);
    } else if(kmenu==3) regenEvents=!regenEvents;   
  }
  VZdecay=VWdecay;                     
}
Ejemplo n.º 3
0
static  int w_men__(void)
{
    int key =1;
    void * pscr=NULL;     
L1:
   {
      char strmen[] ="\030"
                      " BreitWigner range XXX  "
                      " T-channel widths   YYY "
                      " GI in t-channel    ZZZ "
                      " GI in s-channel    WWW ";   

      improveStr(strmen,"XXX","%.1f",*BWrange_int);
      improveStr(strmen,"YYY", (*twidth_int)? "ON" : "OFF");
      improveStr(strmen,"ZZZ",(*gtwidth_int)? "ON" : "OFF");
      improveStr(strmen,"WWW",(*gswidth_int)? "ON" : "OFF");

      menu1(54,6,"",strmen,"n_width_*",&pscr ,&key);
   }

   switch(key)
   { case 0:  return 0;
     case 1:  correctDouble(40,18,"Breit-Wigner range = ",BWrange_int ,1);
              if(*BWrange_int<0) *BWrange_int=-*BWrange_int;
              if(*BWrange_int>999.9) *BWrange_int=999.9;
              break;
     case 2:  *twidth_int = ! *twidth_int; break;
     case 3:  *gtwidth_int =! *gtwidth_int; break; 
     case 4:  *gswidth_int =! *gswidth_int; break;
   }    
    goto L1;
} /* w_men__ */
Ejemplo n.º 4
0
void f5_key_prog(int x)
{
  int kmenu=1;
  void * pscr=NULL;

  int nfun;
  for(nfun=0; nfun<8 && f5_key_prog != f3_key[nfun] ; nfun++);
  if(nfun<8) f3_key[nfun]=NULL;
       
 
  
  while(kmenu) 
  {  
    char strmen[]="\040"
/*                  " Symbolic conservation low   OF1"   */
                  " Number of QCD colors =      Nc "
                  " Diagrams in C-output        OF3"
                  " Widths in t-channels        OF4"
                  " Virtual W  decays           OF5"
                  " Virtual Z  decays           OF6";
/*                   
    if(consLow) improveStr(strmen,"OF1","ON ");
       else     improveStr(strmen,"OF1","OFF");
*/
    if(NcInfLimit) improveStr(strmen,"Nc","Inf");
       else        improveStr(strmen,"Nc","3");
/*
    if(noCChain) improveStr(strmen,"OF2","OFF");
       else      improveStr(strmen,"OF2","ON ");
*/
    if(noPict) improveStr(strmen,"OF3","OFF");
        else      improveStr(strmen,"OF3","ON ");
    if(tWidths) improveStr(strmen,"OF4","ON ");
        else      improveStr(strmen,"OF4","OFF"); 
        
    if(VWdecay)  improveStr(strmen,"OF5","ON ");
        else     improveStr(strmen,"OF5","OFF");    
    if(VZdecay)  improveStr(strmen,"OF6","ON ");
        else     improveStr(strmen,"OF6","OFF");
            
                                          
                  
    menu1(20,18,"Switches",strmen,"s_switch_*",&pscr,&kmenu);
    switch (kmenu)
    {
    
//      case 1: consLow=!consLow;       break;
      case 1: NcInfLimit=!NcInfLimit; break;
      case 2: noPict=!noPict;         break;
      case 3: tWidths=!tWidths;       break; 
      case 4: VWdecay=!VWdecay;cleanDecayTable();       break; 
      case 5: VZdecay=!VZdecay;cleanDecayTable();       break;   
/*      case 5: noCChain=!noCChain;     break; */
    }
    
  }
  if(nfun<8) f3_key[nfun]=f5_key_prog;
                     
}
Ejemplo n.º 5
0
int m_epa__(int i, int * pString)
{   
    void * pscr = NULL;
    i--;
    for(;;)
    { char mstr[]="\007"
                  "mu^-   "
                  "e^-    "
                  "e^+    "
                  "mu^+   ";


      char strmen[]="\050"
      " Incoming particle XXX                  "
      " |Q|max = ZZZ                           ";
      int mode=1;
      int n;
      if(pc[i]<0) n=3+pc[i]; else n=2+pc[i];
   
      improveStr(strmen,"XXX","%4.4s",mstr+1+(n-1)*mstr[0]);
      improveStr(strmen,"ZZZ","%s GeV",q_max_txt[i]);
      menu1(38,10,"",strmen, "n_sf_epa",&pscr,&mode);
    
      switch(mode)
      {
      case 0: { double v;
                if(1==sscanf(q_max_txt[i],"%lf",&v))
                {  
                   q_max_val[i]=v;
                   q_max_ptr[i]=q_max_val+i;
                   return 1;
                } else 
                { trim(q_max_txt[i]);
                  q_max_ptr[i]=varAddress(q_max_txt[i]);
                  if(!q_max_ptr[i]) 
                  { char buff[50];
                    sprintf(buff,"Can not find parameter '%s'",q_max_txt[i]);
                    continue;   
                  }
                }
                return 1;
              }      
      
      case 1: menu1(38,13,"",mstr,"",NULL,&n);
              if(n<3) pc[i]=n-3; else pc[i]=n-2; 
              break;
      case 2: correctStr (40,16,"Enter new value ",q_max_txt[i],19,1);
 break;
      }
    }
    return 1;     
}
Ejemplo n.º 6
0
static void improveEvents(vegasGrid * vegPtr,double (*func)(double *,double,double*))
{ int mode;
   void * pscr_=NULL;
   double eff0;

  for(mode=1;mode!=4; )
  {
      char strmen[]="\030"
                    " sub-cubes = N1         "
                    " random search = N2     "
                    " simplex search= N3     "
                    " Start search of maxima "; 
      improveStr(strmen,"N1","%d",n_cube);
      improveStr(strmen,"N2","%d",nRandom);
      improveStr(strmen,"N3","%d",nSimplex1);
      menu1(54,14,"Preparing of generator",strmen,"n_prep_gen_*",&pscr_,&mode);
      switch(mode)
      {
        case 0: return;
        case 1: if(correctLong(50,15,"Number of sub-cubes:",&n_cube,1))
                {
                    free(vegPtr->fMax); 
                    vegPtr->fMax=NULL;
                    vegPtr->nCubes=0;
                }  break;
        case 2: correctLong(50,15,"Random search:",&nRandom,1);break;
        case 3: correctLong(50,15,"Simplex steps :",&nSimplex1,1); break; 

/*                    " milk      = N3         "  
      improveStr(strmen,"N3","%.1f",milk);
        case 4: correctDouble(50,15,"Content of milk:",&milk,1); break;
*/
        case 4: if(n_cube < 1 ) n_cube=1; 
        { 
            int mCheck=vegas_max(vegPtr,n_cube, nRandom,nSimplex1, milk, func,&eff0);
            if(mCheck==0)
            { char mess[50];
              sprintf(mess,"Expected efficiency %f",eff0/max);
              messanykey(25,15,mess);
              put_text(&pscr_);
            } else
            {  mode=1;
               if(mCheck==2) messanykey(25,15,"Not enough memory.\n"
                                    "Decrease the number of sub-cubes");
            }                                                                                                         
        }                                                                             
      }
  }
}
Ejemplo n.º 7
0
void f5_key_prog(int x)
{
  int kmenu=1;
  void * pscr=NULL;

  int nfun;
  for(nfun=0; nfun<8 && f5_key_prog != f3_key[nfun] ; nfun++);
  if(nfun<8) f3_key[nfun]=NULL;
       
 
  
  while(kmenu) 
  {  
    char strmen[]="\040"
/*                  " Symbolic conservation low   OF1"*/
                  " High precision              OF5"
                  " Number of QCD colors =      Nc "
                  " Diagrams in C-output        OF3"
                  " Widths in t-channels        OF4"
                  ;
/*
    if(consLow) improveStr(strmen,"OF1","ON ");
       else     improveStr(strmen,"OF1","OFF");
*/
    if(NcInfLimit) improveStr(strmen,"Nc","Inf");
       else        improveStr(strmen,"Nc","3");
/*
    if(noCChain) improveStr(strmen,"OF2","OFF");
       else      improveStr(strmen,"OF2","ON ");
*/
    if(noPict) improveStr(strmen,"OF3","OFF");
        else      improveStr(strmen,"OF3","ON ");
    if(tWidths) improveStr(strmen,"OF4","ON ");
        else      improveStr(strmen,"OF4","OFF");  
    if(hPrec)   improveStr(strmen,"OF5","ON ");
        else      improveStr(strmen,"OF5","OFF");  

                  
    menu1(20,17,"Switches",strmen,"s_switch_*",&pscr,&kmenu);
    switch (kmenu)
    { case 1: hPrec=!hPrec; 
#ifdef __CYGWIN__
              hPrec=0;
#endif  
         break;
      case 2: NcInfLimit=!NcInfLimit; break;
      case 3: noPict=!noPict;         break;
      case 4: tWidths=!tWidths;       break;
/*
      case 5: hPrec=!hPrec;   break;     
      case 5: noCChain=!noCChain;   break; 
*/
    }
    
  }
  if(nfun<8) f3_key[nfun]=f5_key_prog;
                     
}
Ejemplo n.º 8
0
int  m_isr__(int i, int*pString)
{
  void * pscr=NULL;
  int mode =1;

  for(;;)
  {  char strmen[]="\40" 
     " ISR scale           = XXX      "
     " Beamstralung          ON       "
     " Bunch x+y sizes (nm)= YYY      "
     " Bunch lenght (mm)   = ZZZ      "
     " Number of particles = NNN      "
     "          *     N_cl = NCL      "
     "          *  Upsilon = UPS      ";

     if(scale<=1) improveStr(strmen,"XXX","%.2fS^.5",scale);
     else improveStr(strmen,"XXX","%.0fGeV",scale);

     calc_params(); 
     if(bOn) 
     {    
        improveStr(strmen,"YYY","%.1f",xy_nm);
        improveStr(strmen,"ZZZ","%.3f",z_mm);
        improveStr(strmen,"NNN","%.1e",qTot);
        improveStr(strmen,"NCL","%.2f",b_ncl);
        improveStr(strmen,"UPS","%.2f",b_ips);
     } else
     {
        improveStr(strmen,"ON","%3.3s","OFF");
        strmen[2*strmen[0]+1]=0;  
     }
     menu1(46,10,"",strmen,"n_sf_isr",&pscr,&mode);
    
     switch(mode)
     { 
       case 0: return 1;

       case 1: messanykey(45,16,"Value >1  is scale in GeV;\n"
                                "Value <=1 is fraction of sqrt(S)");
               correctDouble(45,16,"Enter value: ",&scale,1);break;


       case 2: bOn=!bOn; break;
       case 3: correctDouble(52,16,"Enter new value ",&xy_nm,1);break;
       case 4: correctDouble(52,16,"Enter new value ",&z_mm,1);break; 
       case 5: correctDouble(52,16,"Enter new value ",&qTot,1);break;    
       case 6:
       case 7: messanykey(10,10, "This parameter is a function of\n"
                                 "above ones and Sqrt(S)"); 
     }
  }
  return 1;
}
Ejemplo n.º 9
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;
}
Ejemplo n.º 10
0
static int  in_setting(void)
{
  int mode=1;
  void * pscr=NULL;    
  double Pcm; 
  void (*f7_tmp)(int)=f3_key[4];
  char * f7_mess_tmp= f3_mess[4];
  char sf_txt[STRSIZ];
  REAL mass[2];
  int i;
  int returnCode=0;

  if(nin_int == 1) return returnCode;

  for(i=0;i<2;i++) 
  if(sf_num[i])mass[i]=sf_mass[i];else pinf_int(Nsub,i+1,mass+i,NULL);
   
/* **   menu loop */

  for(;;)
  {    
    char strmen[] = "*"
    " S.F.1: First_structure_function                     "
    " S.F.2: Second_structure_function                    "
    " First  particle momentum[GeV] = PPP1                "
    " Second particle momentum[GeV] = PPP2                "
    " FirstPol                                            "
    " SecondPol                                           ";

    Pcm=va_int[0];

    strmen[0]=strlen(strmen)/6;         
    if(is_polarized(1,Nsub))
    improveStr(strmen,"FirstPol", "Helicity of  first particle   %.3G",(double)Helicity[0]); 
    else improveStr(strmen,"FirstPol", "First  particle unpolarized");
    if(is_polarized(2,Nsub))
    improveStr(strmen,"SecondPol","Helicity of second particle   %.3G",(double)Helicity[1]); 
    else improveStr(strmen,"SecondPol", "Second particle unpolarized");

    strFunName(1,sf_txt); improveStr(strmen,"First","%-45.45s", sf_txt);
    strFunName(2,sf_txt); improveStr(strmen,"Second","%-45.45s",sf_txt);
    improveStr(strmen,"PPP1","%-10.4G",inP1);
    improveStr(strmen,"PPP2","%-10.4G",inP2);

    f3_key[4]=f7_prog;   f3_mess[4]="Plot";
    menu1(25,7,"",strmen,"n_in_*",&pscr,&mode);
    f3_key[4]= f7_tmp;  f3_mess[4]=f7_mess_tmp;

    switch(mode)
    { case 0:
         for(i=0;i<2;i++) 
         if(sf_num[i])mass[i]=sf_mass[i];
         else pinf_int(Nsub,i+1,mass+i,NULL);         

         if((mass[0]==0 && inP1<=0)|| (mass[1]==0 && inP2<=0)) 
           messanykey(10,10,"For massless particle\nmomentum should be positive\n");
         else 
         {
           initStrFun(0);                                                                                                    
           return returnCode;
         } break;
      case 1:
      case 2: if(sf_menu(mode))
              { initStrFun(mode);            
                returnCode=returnCode|3;
              } 
              break;
      case 3: correctDouble(50,12,"Enter new value ",&inP1,1);
              returnCode=returnCode|1; break;
      case 4: correctDouble(50,12,"Enter new value ",&inP2,1); 
              returnCode=returnCode|1; break;
      case 5: if(is_polarized(1,Nsub))
              {  double buf=Helicity[0]; 
                 int spin2; 
                 char txt[60];
                  (*pinfAux_int)(Nsub,1, &spin2,NULL,NULL,NULL);
                  sprintf(txt, "Enter new value [%.1f,%.1f] :", -(spin2/2.),(spin2/2.));
                  correctDouble(40,12,txt,&buf,1);
                  if(fabs(2*buf)>spin2) 
                  { messanykey( 10,10,"Helicity out of limits");
                    if(blind) exit(111);
                  }else 
                  { Helicity[0]=buf;
                    returnCode=returnCode|1;
                  }   
              }   break;
      case 6: if(is_polarized(2,Nsub))
              {  double buf=Helicity[1];
                 int spin2; 
                 char txt[60];
                  (*pinfAux_int)(Nsub,2, &spin2,NULL,NULL,NULL);
                  sprintf(txt, "Enter new value [%.1f,%.1f] :", -(spin2/2.),(spin2/2.));
                  correctDouble(40,12,txt,&buf,1);
                  if(fabs(2*buf)>spin2) 
                  { messanykey( 10,10,"Helicity out of limits");
                    if(blind) exit(111);
                  }else 
                  { Helicity[1]=buf;
                    returnCode=returnCode|1;
                  }   
              }   break;                            
    }
  }
} /* in_setting */
Ejemplo n.º 11
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(); 
       }
    }    
}
Ejemplo n.º 12
0
static void  generateEvents( vegasGrid * vegPtr,  
                   double (*func)(double *,double,double*),  char *fname,  FILE * iprt)
{                                                   
   int mode=1;
   void * pscr=NULL;
   static int regen=1; 
//   if(!vegPtr->fMax)improveEvents(vegPtr,func);
    
   for(mode=1;;)
   {
     char strmen[]="\032"
                   " Number of events=N1      "
                   " Launch generator         "
		   " Allow weighted events OFF";
		   
     if(!regen) improveStr(strmen,"OFF","%s","ON");		   
     improveStr(strmen,"N1","%d",nEvents);
     menu1(53,10,"",strmen,"n_gen_*",&pscr,&mode);
     switch(mode)
     { case 0: return; 
       case 1: correctLong(50,15,"",&nEvents,1); break;
       case 2: 
       { long  nGenerated=0; 
         double eff;
         int nmax,mult,neg;   
         char mess[200];
         long cEvent;
         long fileEnd;
         
         if(!vegPtr->fMax) { messanykey(15,15,"Generator is not ready."); break;}
         events_= fopen(fname,"a");       
         if(ftell(events_)==0) write_event_cap();
         fileEnd=ftell(events_); 
         build_cb_int(Nsub);
         cEvent= vegas_events(vegPtr,nEvents,max,func,writeEvent,regen,&eff,&nmax,&mult,&neg);
         fclose(events_);

         if(cEvent>0)
         {  int l;
            sprintf(mess,"Statistic\n Events generated: %ld\n  efficiency: %.1E\nMax event multiplicity: %d\n"
                      "Multiple events(total): %d \nNegative weight  events: %d \n", cEvent, eff,nmax,mult, neg);

            l=strlen(mess);
            strcat(mess,"---------------\n Accept events? ");    
            if(mess_y_n(25,15,mess)) 
            {  
               long  nEvPos=0;
               integral.old=1;
               mess[l]=0;
               events_=fopen(fname,"r+");
               while(nEvPos==0)
               { char ch;
                 char word[100];
                 do fscanf(events_,"%c",&ch); while(ch !='#');
                 fscanf(events_,"%s",word);
                 if(strcmp(word,"Number_of_events")==0) nEvPos=ftell(events_);
               }
               fscanf(events_,"%ld",&nGenerated);
               nGenerated+=cEvent;
               fseek(events_,nEvPos,SEEK_SET);
               fprintf(events_," %10ld",nGenerated);
               fclose(events_);
               fprintf(iprt," %ld events are stored in '%s'\n",nGenerated,fname);
               fprintf(iprt,"%s\n",mess);
               fflush(iprt);
            } else  truncate(fname,fileEnd);
         }
         destroy_cb_int();
       } 
       break;

//       case 3: improveEvents(vegPtr,func); put_text(&pscr); break;
       case 3: regen=!regen; 
       
//       goto ret;

     }
   }
}                                                                     
Ejemplo n.º 13
0
static void show_dependence(int X, int Y)
{ void *pscr1=NULL;
  int i,mPos=1; 
  REAL mem;
  int nc,ni,pos1,pos2;
  char txt[50];
  for(pos1=1;;)
  { nc=findParam(X-1,Y,0,nModelVars,nModelFunc,"Constraint",&pos1);
    if(!pos1) return;
    for(pos2=1;;)
    { double xMin,xMax;
      int nPoints=100;
      sprintf(txt,"check \"%s\" depends on",varNames[nc]); 
      ni=findParam(X-1,Y,0,0,nModelVars,txt,&pos2);
      mem=varValues[ni];
      if(ni<0) break; 
      
      xMin=varValues[ni] - fabs(varValues[ni] )/10;
      xMax=varValues[ni] + fabs(varValues[ni] )/10;
      
      for(;;)
      {  int k3=0; 
         char strmen[]="\026 "
            " x-Min = XXX          "
            " x-Max = YYY          "
            " Npoints = NNN        "
            " Display              ";

         improveStr(strmen,"XXX","%G",xMin);
         improveStr(strmen,"YYY","%G",xMax);
         improveStr(strmen,"NNN","%d",nPoints);
         sprintf(txt,"check %s(%s)",varNames[nc],varNames[ni]);        
         menu1(X,Y+2,txt,strmen,"",NULL,&k3);
         if(!k3) break;
         switch(k3)
         {  case 1: correctDouble(X,Y+12,"xMin = ",&xMin,1); break;
            case 2: correctDouble(X,Y+12,"xMax = ",&xMax,1); break;
            case 3: correctInt(X,Y+12,"nPoints = ",&nPoints,1); break;
            case 4:
            if( xMax>xMin && nPoints>=3 && nPoints<=150)
            {  double dx=(xMax-xMin)/(nPoints-1);
               double f[150];
               int i, NaN=0,Esc=0;
         
               informline(0,nPoints);               
               for(i=0;i<nPoints;i++)
               {  double x=xMin+i*dx;
                  varValues[ni]=x;
                  NaN=calcMainFunc();
                  if(NaN) 
                  {  char mess[100];
                     sprintf(mess,"Can not evaluate constraints for %s=%G",varNames[ni], x);
                     messanykey(16,5,mess);        
                     break;
                  }
                  f[i]=varValues[nc];
                  Esc=informline(i,nPoints);
                  if(Esc) break;  
               }
                  
               varValues[ni]=mem;
               calcMainFunc();

               if(!(NaN||Esc)) plot_1(xMin,xMax,nPoints,f,NULL,"Plot",
                              varNames[ni], varNames[nc]);
                               
            } else messanykey(16,5," Correct input is \n"
                                   "  xMin<xMax,\n"
                                   " 3<=nPoints<=150");
            break;
         }
       }
     }
  }
}
Ejemplo n.º 14
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();
       }
    }    
}
Ejemplo n.º 15
0
int monte_carlo_menu(void)
{
   static int r=0;
   int mode=1;
   void * pscr=NULL;
   void (*quit)(int)=f3_key[7];
   char menutxt[]="\030"
                  " Subprocess             "
                  " IN state               "
                  " Model parameters       "
                  " Constraints            "
                  " QCD  alpha & scales    "
                  " Breit-Wigner           "
	          " Aliases                "
	          " Cuts                   "
	          " Phase space mapping    "
                  " Monte Carlo simulation "
                  " Easy                   ";
                  
   if(nout_int!=2  ) menutxt[menutxt[0]*10+1]=0;
   if(nin_int==1)  improveStr(menutxt,"Easy", "Total width"); 
           else    improveStr(menutxt,"Easy", "1D integration");
 
   wrtprc_();
   for(;;)
   {  
      infor();
      f3_key[7]=quit;
      menu1(54,4,"",menutxt,"n_mc_*",&pscr, &mode);
      if(mode==1||mode==2||mode==3||mode==5||mode==7)f3_key[7]=NULL;

      switch (mode)
      { 
        case  0: return 0;
        case  1: r=r|3*sub_men__(); break;
        case  2: r=r|in_setting(); break;
        case  3: r=r|change_parameter(54,7,0);  break;
        case  4: { int modeC=1;
                   for(;;)
                   { char menuC[]="\030"
                     " All Constraints        " 
                     " Masses,Widths,Branching"; 
                     void * pscrC=NULL;
                     menu1(54,6,"",menuC,"n_constr_*",&pscrC, &modeC);
                     switch(modeC)
                     { case 0: break;
                       case 1: show_depend(54,7); break;
                       case 2: show_spectrum(54,9); break;
                     } 
                     if(!modeC) break;
                   } break;
                 }     
        case  5: r=r|qcdmen_();  break;
        case  6: r=r|w_men__();  break;
        case  7: do r=r|(3*edittable(1,4,&compTab,1,"n_comp",0)); while (fillCompositeArray());
	         break;     
        case  8: do r=r|(3*edittable(1,4,&cutTab,1,"n_cut",0)); while (fillCutArray()); 
                 break;             
        case  9: r=r|mappingMenu(); break;                      
        case  10: 
                 if(nout_int==1 && !sf_num[0] && !sf_num[1]  ) 
                 { if(blind)  return 1;                     
                   messanykey(15,15,"Phase space integration for 2->1 processes\n needs distribution functions.");
                   break;
                 }
                                                                        
                 
                 if(checkEnergy())   
                 { 
                    if(blind==1)
                    { char fname[50];
                     int i,j;
                     sprintf(fname,"events_%d.txt", nSess);
                     FILE * f=fopen(fname,"w");
                     fprintf(f,"#%s\n", VERSION_);
                     fprintf(f,"#Type %d -> %d\n", nin_int,nout_int);
                     fprintf(f,"#Initial_state ");
                     if(nin_int==1) fprintf(f," P1=0\n");
                     else
                     { fprintf(f," P1_3=0  P2_3=0\n");
                       wrt_sf__(f);
                     }  
                     fprintf(f,"#PROCESS  ");
                     for(i=1;i<=nin_int+nout_int; i++)
                     { int pcode;
                       char * pname=pinf_int(Nsub,i,NULL,&pcode);
                       fprintf(f," %d(%s)", pcode, pname);
                       if(i==nin_int)  fprintf(f," ->");
                     } 
                     fprintf(f,"\n");    
                     fprintf(f,"#MASSES ");
                     for(i=0;i<nin_int+nout_int;i++)
                     {  REAL m;
                        pinf_int(Nsub,i+1,&m,NULL); 
                        fprintf(f," %.10E", (double)m);
                     }   
                     fprintf(f,"\n");
  
                     fprintf(f,"#Cross_section(Width) %E\n",0.);
                    
                     fprintf(f,"#Number_of_events %10d\n",0);
                     fprintf(f,"#Sum_of_weights %12.4E %12.4E \n",0.,0.);
                     fprintf(f,"#Events  "); 
                     if(nin_int==2) fprintf(f,"     P1_3 [Gev]        P2_3 [Gev]   ");
                     for(i=1;i<=nout_int; i++) for(j=1;j<=3;j++) 
                          fprintf(f,"     P%d_%d [Gev]   ",i+nin_int,j);
                     integral.old=1;
                     fclose(f); 
                     return 1;
                   }
                            
                   messanykey(15,15,"Energy is too small!");                   
                   break;
                 }

                 if(fillCutArray()) 
                 { if(blind) return 2;
                   messanykey(15,15,"Can not evaluate cut limits"); 
                   break;
                 }  
        case 11:
                if(mode==11) 
                {  void (*f10_tmp)(int);
                   w_sess__(NULL);
                   f10_tmp=f3_key[7];
                   f3_key[7]=f10_key_prog_for22;
                   if(nin_int==1) decay12(); else
                   { REAL m1,m2, Pcm;
                     pinf_int(Nsub,1,&m1,NULL); 
                     pinf_int(Nsub,2,&m2,NULL);  
                     if(sf_num[0] && sf_mass[0]>m1) m1= sf_mass[0];
                     if(sf_num[1] && sf_mass[1]>m2) m2= sf_mass[1];
                     incomkin(m1,m2,inP1,inP2,NULL,&Pcm,NULL); 
                     if(sf_num[0]||sf_num[1]||nCuts)
                      messanykey(10,10,"Structure functions and cuts are ignored\n");                                       
                     cs_numcalc(Pcm);
                   }
                   f3_key[7]= f10_tmp;
                   r_sess__(NULL); 
                   break;
                } else if(fillRegArray()) 
                {  
                  if(blind) return 3;                
                   messanykey(15,15,
                       "Can not evaluate regularization paremeters");
                   break;    
                }
   
                if(mode==10)  runVegas(); 
                r=0;  
                break;
                 
      }
//printf("r=%d\n",r);      
      if(r) clearEventMax();
      if(r&2) clearGrid();
      if(r&1)newSession();
   }
}
Ejemplo n.º 16
0
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;    
      }
   }
}
Ejemplo n.º 17
0
int m_lha(int i,int*pString)
{ 
  int size=2+8*500;
  int size_=1;
  void *pscr=NULL;
  void *pscr0=NULL;
  static int n1=0;
  char * strmen=lhaMenu(); 
  int i1=i-1;

  if(!strmen) return 0;
  

  int n0=1,k,l;

  if(n1==0 && strlen(fname[i1]))
  { char *ch=strstr(strmen,fname[i1]);
    if(ch) n1= 1+(ch-strmen)/strmen[0];
  }
  menu1(5,7,"LHAlib menu",strmen,"",&pscr,&n1);
  if(n1)
  { char buff[50];
    sscanf(strmen+1+strmen[0]*(n1-1),"%s",buff);
    if(strcmp(buff,fname[i1]))
    { strcpy(fname[i1],buff);
      setNum[i1]=0;
      initpdfsetbynamem(&i,buff,strlen(buff));
      lastLHA=i;
      initpdfm(&i,setNum+i1,xMin+i1,xMax+i1,qMin+i1,qMax+i1);
    }
  }  
  else 
  { fname[i1][0]=0;
    setNum[i1]=0;
    sgn[i1]=0;
    return 0;
  } 


  for(;n0!=0 && n0!=3;)
  {  char buff[50];
     int nMax;
     char strmen0[]="\030"
                    " Set = 0                "   
                    " Proton                 "
                    " OK                     ";

     numberpdfm(&i,&nMax);
     if(nMax>1) improveStr(strmen0,"Set = 0","Set = %d [0,%d]",setNum[i1],nMax);
     else       improveStr(strmen0,"Set = 0","Set = 0 (only)");
     
     if(sgn[i1]<0) improveStr(strmen0,"Proton","%s","antiProton");
     
     menu1(5,10,"",strmen0,"",&pscr0,&n0);
     switch(n0) 
     { 
       case 1: if(nMax>1) 
               { correctInt(50,12,"Enter new value ",setNum+i1,1);
                 if(setNum[i1]<0) setNum[i1]=0;
                 if(setNum[i1]>nMax) setNum[i1]=nMax;
                 initpdfm(&i,setNum+i1,xMin+i1,xMax+i1,qMin+i1,qMax+i1);
               }   
               break;
       case 2: sgn[i1]=-sgn[i1]; break;
       case 3: put_text(&pscr0); break;
     }
  }
  
  put_text(&pscr); 
  free(strmen);
  return 1;
}
Ejemplo n.º 18
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());
}
Ejemplo n.º 19
0
int main(int argc,char** argv)
{   

/*===================================
0 - First start.
1 - Model menu.
2 - Enter process menu.
3 - Feynman diagrams menu; squaring.
4 - Squared diagram menu; symbolic calculation.                        
5 - Write results; new process.
10 -Restart symbolic calculations
==========================================================*/

/* 0-Start; 1-Restart; 2-Heap Error,3-Edit Model,4-UserBreak */

  void *pscr1=NULL,*pscr2=NULL,*pscr3=NULL,*pscr4=NULL,*pscr5=NULL;
  int   k1=1,k2=1,k3=1,k4=1,k5=1;

  int n;
  int pid=0;
  char LOCKtxt[]="Directory 'results/' contains the .lock file created by n_calchep.\n"
                 "To continue you may a)Close the n_calchep session, or b)Rename 'results/',\n";
  blind=0;
  strcpy(pathtocomphep,argv[0]);
  for(n=strlen(pathtocomphep)-1; n && pathtocomphep[n]!=f_slash; n--);
  pathtocomphep[n-3]=0;                                         
     
   for ( n=1;n<argc;n++) 
   { if (strcmp(argv[n],"-blind")==0 && n<argc-1 )
     {  blind=1;
        inkeyString=argv[++n];
     }
     if (strcmp(argv[n],"+blind")==0 )  blind=2;                                     
   }    

   if(!writeLockFile(".lock")) 
   { fprintf(stderr,"locked by other s_calchep. See .lock file\n");
      exit(100);
   }
   strcpy(pathtouser,"");  
   sprintf(pathtohelp,"%shelp%c",pathtocomphep,f_slash);
   outputDir="results/";        
   { char * icon=(char *) malloc(strlen(pathtocomphep)+10);
     int err;
     sprintf(icon,"%sicon",pathtocomphep);
     err=start1("CalcHEP/symb",icon,"calchep.ini",&xw_error);
     if(err && blind==0)
     { printf("Error:You have launched interactive session for version compiled  without X11 library.\n");
       printf("Options: a) Use blind session; b) Recompile CalcHEP with X11\n");
       exit(66);
     }      
     free(icon);
   }
   fillModelMenu();
   
   f3_key[0]=f3_key_prog;   f3_mess[0]="Model"; 
   f3_key[1]=f4_key_prog;   f3_mess[1]="Diagrams"; 
   f3_key[2]=f5_key_prog;   f3_mess[2]="Switches";
   f3_key[3]=f6_key_prog;   f3_mess[3]="Results"; 
                            f3_mess[4]="Del"; 
                            f3_mess[5]="UnDel";
   f3_key[6]=f9_key_prog;   f3_mess[6]="Ref";    
   f3_key[7]=f10_key_prog;  f3_mess[7]="Quit";

   restoreent(&menulevel);

   if(!blind && menulevel<2) cheplabel(); 

   switch (menulevel)
   {
      case 10: 
      case 6:
      case 5: 
      case 4:
      case 3: readModelFiles("./models",n_model); 
              modelinfo();
              loadModel(0,forceUG);
              processinfo();
              diagramsinfo();
      case 2: k1=n_model;

      case 1: break;
   }

   switch (menulevel)
   {
      case 2:  menuhelp();
               goto label_20;
      case 3:  goto label_31;
      case 4:  goto label_40;
      case 5:  goto label_50;
      case 6:  
      case 10: goto restart2;
   }
        
label_10:   /*   Menu2(ModelMenu): */
   f3_key[0]=NULL; /*models*/ 
   f3_key[1]=NULL; /*diagrams*/
   menulevel = 1;
   forceUG=0;
   menuhelp();
   for(;;)
   { 
      showheap();
      k1=n_model;
      menu1(56,4,"",modelmenu,"s_1",&pscr1,&k1);
      n_model=k1;
      if(n_model == 0)
      {
	if( mess_y_n(56,4,"Quit session")) {  saveent(menulevel); goto exi; }         
      }
      else  if(n_model == maxmodel+1)
      {
         clrbox(1,4,55,18);
         makenewmodel();
         menuhelp();
      }
      else if (n_model > 0)
      { 
	put_text(&pscr1);
	goto label_20;
      }
   }

label_20:   /*  Menu3:Enter Process  */
   f3_key[0]=NULL; 
   f3_key[1]=NULL; 

   menulevel = 2;
   saveent(menulevel);
   readModelFiles("./models",n_model);
   modelinfo();
   k2 = 1;
   do
   {  char strmen[]="\026"
        " Enter Process        "
        " Force Unit.Gauge OFF "
        " Edit model           "
        " Delete model         ";

      if(forceUG)improveStr(strmen,"OFF","ON");
      menu1(56,4,"",strmen,"s_2_*",&pscr2,&k2);
      switch (k2)
      {
         case 0:  goto_xy(1,1); clr_eol(); goto label_10;
         case 2:  forceUG=!forceUG;   modelinfo(); break;
	 case 3:  editModel(1); break;
         case 4: 
	    if ( deletemodel(n_model) )
            {
               goto_xy(1,1);
               clr_eol();
               n_model=1;
               fillModelMenu();
               goto label_10;
            }
            else   readModelFiles("./models",n_model);
      }
   }  while (k2 != 1);

   loadModel(0,forceUG);
label_21:

   f3_key[0]=NULL; 
   f3_key[1]=NULL; 

   menulevel=2;
   errorcode=enter();   /*  Enter a process  */
   newCodes=0;
   showheap();
   if (errorcode)   /*  'Esc' pressed  */ { menuhelp(); goto label_20;}
   errorcode=construct();          /*  unSquared diagrams  */
   if (errorcode) 
   {  if(blind)
      {  printf("Processes of this type are absent\n"); sortie(111); } 
      else 
      { messanykey(5,22,"Processes of this type are absent");  
        clrbox(1,19,80,24); 
        goto label_21;
      }
   }
   else if(!blind)
   { int dirStat=checkDir("results"); 
     if(dirStat!=0)
     {  messanykey( 10,10,"There are files in directory 'results/'.\n"  
                          "To continue you has to clean or rename this directory.");
        viewresults();
        if(checkDir("results")!=0)  goto label_21;                   
     }
     clr_scr(FGmain,BGmain);
     modelinfo();
     processinfo();
     diagramsinfo();
     goto label_31;	
   }
   
label_30: /*  Menu4: Squaring,...*/
   clr_scr(FGmain,BGmain);
   modelinfo();
   processinfo();
   diagramsinfo();
label_31: 

   f3_key[0]=f3_key_prog; 
   f3_key[1]=NULL; 

   menulevel=3;  
   k3 = 1;
   do
   {
      menu1(56,4,"","\026"
         " View diagrams        "
/*         " Amplitude calculation" */
         " Squaring technique   "
         " Write down processes ","s_squa_*",&pscr3,&k3);
      switch (k3)
      {
         case 0: clrbox(1,2,55,11); menuhelp(); goto label_20;
         case 1: viewfeyndiag(1);   break;
         case 3: { FILE*f=fopen("results/list_prc.txt","w");
                   int k,ndel,ncalc,nrest;
                   char process[100];
                   long recpos; 
                   menup=fopen(MENUP_NAME,"r");
                   for(k=1;;k++) 
                   { int err=rd_menu(1,k,process,&ndel,&ncalc,&nrest,&recpos);
                     if(!err) break;
                     trim(process);
                     fprintf(f,"%s\n",process);
                   } 
                   fclose(f);
                   fclose(menup);
                    messanykey(20,14,"See file 'results/list_prc.txt'");
 
                 } break; 

/*       case 2: messanykey(10,10,"Not implemented yet"); Amplitudes(); */
      }
   }  while (k3 != 2);      

   if (!squaring()) goto label_30;  /*  process is absent  */

   clear_tmp();

   saveent(menulevel);
   restoreent(&menulevel);  

label_40:   /*  Menu5: View squared diagrams.....   */

   f3_key[0]=f3_key_prog; 
   f3_key[1]=f4_key_prog; 

   menulevel=4;
   clr_scr(FGmain,BGmain);
   modelinfo();
   processinfo();
   diagramsinfo();
   sq_diagramsinfo(); /*   ????????   */

   k4=1;
   saveent(menulevel);
   pscr4=NULL;
   for(;;)   
   {  int res;
      menu1(56,4,"","\026"
         " View squared diagrams"
         " Symbolic calculations"
         " Make&Launch n_calchep"        
         " Make n_calchep       "
         " REDUCE program       "
         ,"s_calc_*",&pscr4,&k4);

      res=checkDir("results");
      if(res==1)
      {
        int  n_calchep_id=setLockFile("results/.lock");
        if(n_calchep_id) unLockFile(n_calchep_id); else res=2;                          
      }
      switch (k4)
      {  case 0:
            if (mess_y_n(50,3,"Return to previous menu?"))goto label_30;
         break;

         case 1:
            viewsqdiagr();  break;

         case 2:     /*  Compute all diagrams   */
restart2:
            f3_key[0]=f3_key_prog; 
            f3_key[1]=f4_key_prog; 

            menulevel=4;
            calcallproc();
            sq_diagramsinfo();

            if(!continuetest()) break; 
            showheap();  
            put_text(&pscr4);
         break;
         case 3:
            { static char keystr[12]="]{{[{";
              if(res==2) messanykey(3,10,LOCKtxt); else inkeyString=keystr;
            }
            break;
         case 4:
            if(res==2) messanykey(3,10,LOCKtxt); else
            { char command[100];
              FILE *f=fopen("results/EXTLIB","w");
              fprintf(f,"EXTLIB=\"%s\"\nexport EXTLIB\n",EXTLIB);
              fclose(f); 
              saveent(menulevel);
{ char command[100];
  sprintf(command,"cd results; $CALCHEP/bin/make_VandP  ../models  %d",n_model);
  system(command);
}                 
              finish();
              sortie(22);
            }
         case 5:  mk_reduceprograms();  break;
      }
      if(k4==2 && continuetest()) { put_text(&pscr4); break; }
   }

label_50:
   k5=1;
   pscr5=NULL;
   menulevel=5;
   saveent(menulevel);
   
   for(;;)  
   {  int n_calchep_id;   
      menu1(56,4,"","\026"
         " C code               "
         "     C-compiler       "
         "     Edit Linker      "
         " REDUCE code          "
         " MATHEMATICA code     "
         " FORM code            "
         " Enter new process    " ,"s_out_*",&pscr5,&k5);
         
      if((k5==1||k5==2)&&pid) 
      { int epid=waitpid(pid,NULL,WNOHANG);
        if(epid) pid=0; else
        { 
          messanykey(3,10,"This option is frozen while n_calchep runs or is compiled");
          continue;
        }
      }  

      switch (k5)
      {  case 0: goto label_40;  break;
         case 1:
           c_prog(); newCodes=0; saveent(menulevel);
           break;
         case 2:
           if(newCodes) { c_prog(); newCodes=0; saveent(menulevel);} 
           pid=fork();
           if(pid==0)
           { 
             char * command;
             n_calchep_id=setLockFile("results/.lock"); 
             if(n_calchep_id)
             {  
               command=(char*)malloc(strlen(pathtocomphep)+strlen(EXTLIB)+100);
               sprintf(command,"EXTLIB=\"%s\"\n"
                               "export EXTLIB\n"
                               "cd results\n"
                               "xterm -e %s/make__n_calchep %d",
                               EXTLIB,pathtocomphep,n_model);                                 
               system(command);
               sprintf(command,"cd results; ./n_calchep"); 
               unLockFile(n_calchep_id);
               system(command); 
               free(command);
             }
             exit(0);
           }
           break;
         case 3: if(edittable(1,1,&modelTab[4],1," ",0))
                 {  char fName[STRSIZ];
                    readEXTLIB();
                    sprintf(fName,"%smodels%c%s%d.mdl",pathtouser,f_slash,mdFls[4],n_model);
                    writetable( &modelTab[4],fName); 
                 }
                 break;
         case 4: makeReduceOutput(); break;
         case 5: makeMathOutput();   break; 
	 case 6: makeFormOutput();   break;
   
         case 7:
            put_text(&pscr5);
            clrbox(1,2,55,11);
            menuhelp();
            goto label_20;
      }
   }

exi:
   finish();
   sortie(0);
   return 0;
}
Ejemplo n.º 20
0
int main(int argc,char** argv)
{   

/*===================================
0 - First start.
1 - Model menu.
2 - Enter process menu.
3 - Feynman diagrams menu; squaring.
4 - Squared diagram menu; symbolic calculation.                        
5 - Write results; new process.
10 -Restart symbolic calculations
==========================================================*/

/* 0-Start; 1-Restart; 2-Heap Error,3-Edit Model,4-UserBreak */

  void *pscr1=NULL,*pscr2=NULL,*pscr3=NULL,*pscr4=NULL,*pscr5=NULL;
  int   k1=1,k2=1,k3=1,k4=1,k5=1;

  int n;
  int pid=0;
  char LOCKtxt[]="Directory 'results/' contains the .lock file created by n_calchep.\n"
                 "To continue you may a)Close the n_calchep session, or b)Rename 'results/',\n";


  blind=0;
  strcpy(pathtocalchep,argv[0]);
  for(n=strlen(pathtocalchep)-1; n && pathtocalchep[n]!=f_slash; n--);
  pathtocalchep[n-3]=0;                                         
     
   for ( n=1;n<argc;n++) 
   { if (strcmp(argv[n],"-blind")==0 && n<argc-1 )
     {  blind=1;
        inkeyString=argv[++n];
     }
     if (strcmp(argv[n],"+blind")==0 )  blind=2;                                     
     if (strcmp(argv[n],"--version")==0 ) { printf("%s\n", VERSION_); exit(0);}
   }    

   if(!writeLockFile(".lock")) 
   { fprintf(stderr,"locked by other s_calchep. See .lock file\n");
      exit(100);
   }
   strcpy(pathtouser,"");  
   sprintf(pathtohelp,"%shelp%c",pathtocalchep,f_slash);
   outputDir="results/";        
   { char * icon=(char *) malloc(strlen(pathtocalchep)+20);
     char  title[30];
     int err;
     sprintf(icon,"%s/include/icon",pathtocalchep);
     sprintf(title,"CalcHEP_%s/symb", VERSION);
     err=start1(title,icon,"calchep.ini",&xw_error);
     if(err && blind==0)
     { printf("Error:You have launched interactive session for version compiled  without X11 library.\n");
       printf(" Presumably X11 development package is not installed in your computer.\n");
       printf(" In this case directory /usr/include/X11/ is empty.\n");       
       printf("Options: a) Use blind session; b) Update Linux and recompile CalcHEP \n");
       printf("Name of needed package\n");
       printf("     libX11-devel      Fedora/Scientific Linux/CYGWIN/Darwin(MAC)\n");
       printf("     libX11-dev        Ubuntu/Debian\n");
       printf("     xorg-x11-devel    SUSE\n");

       exit(66);
     }      
     free(icon);
   }
   fillModelMenu();
   
   f3_key[0]=f3_key_prog;   f3_mess[0]="Model"; 
   f3_key[1]=f4_key_prog;   f3_mess[1]="Diagrams"; 
   f3_key[2]=f5_key_prog;   f3_mess[2]="Switches";
   f3_key[3]=f6_key_prog;   f3_mess[3]="Results"; 
                            f3_mess[4]="Del"; 
                            f3_mess[5]="UnDel";
   f3_key[6]=f9_key_prog;   f3_mess[6]="Ref";    
   f3_key[7]=f10_key_prog;  f3_mess[7]="Quit";

   restoreent(&menulevel);

   if(!blind && menulevel<2) cheplabel(); 

   switch (menulevel)
   {
      case 10: 
      case 6:
      case 5: 
      case 4:
      case 3: readModelFiles("./models",n_model); 
              modelinfo();
              loadModel(0,forceUG);
              processinfo();
              diagramsinfo();
              k1=n_model;
              break;
      case 2: k1=n_model;
              readModelFiles("./models",n_model);
              break; 
   }

   switch (menulevel)
   {
      case 2:  menuhelp();
               goto label_20;
      case 3:  goto label_31;
      case 4:  goto label_40;
      case 5:  goto label_50;
      case 6:  
      case 10: goto restart2;
   }
        
label_10:   /*   Menu2(ModelMenu): */
   f3_key[0]=NULL; /*models*/ 
   f3_key[1]=NULL; /*diagrams*/
   menulevel = 1;
   forceUG=0;
   menuhelp();
   for(;;)
   { 
      showheap();
      k1=n_model;
      menu1(56,4,"",modelmenu,"s_1",&pscr1,&k1);
      if(k1 == 0)
      {  
	if( mess_y_n(56,4,"Quit session")) {n_model=0;   saveent(menulevel); goto exi; }         
      }
      else  if(k1 == maxmodel+1)
      {
         clrbox(1,4,55,18);
         makenewmodel();
         menuhelp();
      }
      else if (k1 > 0)
      { int err=0;
        put_text(&pscr1);
        if(k1!=n_model || ldModelStatus==0) { err=readModelFiles("./models",k1);}
        n_model=k1;
        if(err){ if(blind) sortie(133); else  goto label_10;} else goto label_20;
      }
   }

label_20:   /*  Menu3:Enter Process  */
   f3_key[0]=NULL; 
   f3_key[1]=NULL; 

   menulevel = 2;
   saveent(menulevel);
   
   modelinfo();
   k2 = 1;
   
   do
   {  char strmen[]="\026"
        " Enter Process        "
        " Force Unit.Gauge= OFF"
        " Edit model           "
        " Numerical Evaluation "
        "======================"
        " Delete model         ";

      if(forceUG)improveStr(strmen,"OFF","ON");
      menu1(56,4,"",strmen,"s_2_*",&pscr2,&k2);
      switch (k2)
      {
         case 0:  goto_xy(1,1); clr_eol(); goto label_10;
         case 2:  forceUG=!forceUG;   modelinfo(); break;
	 case 3:  editModel(1); break;
	 case 4:  numcheck();   
	 case 5:  break;
         case 6: 
	    if(deletemodel(n_model))
            {
               goto_xy(1,1);
               clr_eol();
               n_model=1;
               ldModelStatus=0;
               fillModelMenu();
               goto label_10;
            }
      }
   }  while (k2 != 1);

   if(!loadModel(0,forceUG)) goto  label_20;
   
label_21:

   f3_key[0]=NULL; 
   f3_key[1]=NULL; 
   
   menulevel=2;
   checkAuxDir(n_model);
   errorcode=enter();   /*  Enter a process  */
   newCodes=0;
   showheap();
   if (errorcode)   /*  'Esc' pressed  */ { menuhelp(); goto label_20;}
   errorcode=construct();          /*  unSquared diagrams  */
   if (errorcode) 
   {  if(blind)
      {  printf("Processes of this type are absent\n"); sortie(111); } 
      else 
      { messanykey(5,22,"Processes of this type are absent");  
        clrbox(1,19,80,24); 
        goto label_21;
      }
   }
   else if(!blind)
   { int dirStat=checkDir("results"); 
     if(dirStat!=0)
     {  messanykey( 10,10,"There are files in directory 'results/'.\n"  
                          "To continue you has to clean or rename this directory.");
        viewresults();
        if(checkDir("results")!=0)  goto label_21;                   
     }
     clr_scr(FGmain,BGmain);
     modelinfo();
     processinfo();
     diagramsinfo();
     goto label_31;	
   }
   
label_30: /*  Menu4: Squaring,...*/
   clr_scr(FGmain,BGmain);
   modelinfo();
   processinfo();
   diagramsinfo();
label_31: 

   f3_key[0]=f3_key_prog; 
   f3_key[1]=NULL; 

   menulevel=3;  
   k3 = 1;
   do
   {
      menu1(56,4,"","\026"
         " View diagrams        "
/*         " Amplitude calculation" */
         " Square diagrams      "
         " Write down processes ","s_squa_*",&pscr3,&k3);
      switch (k3)
      {
         case 0: clrbox(1,2,55,11); menuhelp(); goto label_20;
         case 1: viewfeyndiag(1);   break;
         case 3: { FILE*f=fopen("results/list_prc.txt","w");
                   int k,ndel,ncalc,nrest;
                   char process[100];
                   long recpos; 
                   menup=fopen(MENUP_NAME,"r");
                   for(k=1;;k++) 
                   { int err=rd_menu(1,k,process,&ndel,&ncalc,&nrest,&recpos);
                     if(!err) break;
                     trim(process);
                     fprintf(f,"%s\n",process);
                   } 
                   fclose(f);
                   fclose(menup);
                    messanykey(20,14,"See file 'results/list_prc.txt'");
 
                 } break; 

/*       case 2: messanykey(10,10,"Not implemented yet"); Amplitudes(); */
      }
   }  while (k3 != 2);      

   if (!squaring()) goto label_30;  /*  process is absent  */

   clear_tmp();

   saveent(menulevel);
   restoreent(&menulevel);  

label_40:   /*  Menu5: View squared diagrams.....   */

   f3_key[0]=f3_key_prog; 
   f3_key[1]=f4_key_prog; 

   menulevel=4;
   clr_scr(FGmain,BGmain);
   modelinfo();
   processinfo();
   diagramsinfo();
   sq_diagramsinfo(); /*   ????????   */

   k4=1;
   saveent(menulevel);
   pscr4=NULL;
   for(;;)   
   {  int res;
      menu1(56,4,"","\026"
         " View squared diagrams"
         " Symbolic calculations"
         " Make&Launch n_calchep"        
         " Make n_calchep       "
         " REDUCE program       "
         ,"s_calc_*",&pscr4,&k4);

      res=checkDir("results");
      if(res==1)
      {
        int  n_calchep_id=setLockFile("results/.lock");
        if(n_calchep_id) unLockFile(n_calchep_id); else res=2;                          
      }
      switch (k4)
      {  case 0:
            if (mess_y_n(50,3,"Return to previous menu?"))goto label_30;
         break;

         case 1:
            viewsqdiagr();  break;

         case 2:     /*  Compute all diagrams   */
restart2:
            f3_key[0]=f3_key_prog; 
            f3_key[1]=f4_key_prog; 

            menulevel=4;
                        
            if(!nPROCSS ) calcallproc(); else 
            { int *pids=malloc(sizeof(int)*nPROCSS);
              int *pipes=malloc(2*sizeof(int)*nPROCSS);
              int **qd=malloc(sizeof(int*)*nPROCSS);
              int totD=sqDiagList(qd, nPROCSS);
              int totC,nProc;
              int k;
              
              fflush(NULL);
              for(k=0;k<nPROCSS;k++) 
              { int* kpipe=pipes+2*k;
                pipe(kpipe);
                pids[k]=fork();
                if(pids[k]==0)
                { 
                  close(kpipe[0]);
                  calcWithFork(k,qd[k],kpipe[1]);
                  exit(0);
                }
              }
              for(k=0;k<nPROCSS;k++) close(pipes[2*k+1]);
              infoLine(0.);
              for(nProc=nPROCSS,totC=0;nProc;)
              { int one;
                int err;
                nProc=0;
                for(k=0;k<nPROCSS;k++) if(pids[k])
                { if(waitpid(pids[k],NULL,WNOHANG)==0)
                  {  nProc++; 
                     if(read(pipes[2*k],&one,sizeof(int)))totC+=one;
                  } else 
                  { for(;read(pipes[2*k],&one,sizeof(int))>0;) totC+=one;
                     pids[k]=0;
                  }
                }  
                if(infoLine((double)totC/(double)totD)) for(k=0;k<nPROCSS;k++) if(pids[k]) kill(pids[k],SIGUSR1);   
              }  
              infoLine(2);
              for(k=0;k<nPROCSS;k++)
              { char ctlgName[100];
                char command[200];
                sprintf(ctlgName,"%s_%d",CATALOG_NAME,k);
                if(access(ctlgName,R_OK)==0)
                { sprintf(command," cat %s >> %s", ctlgName,CATALOG_NAME);
                  system(command);
                  unlink(ctlgName);   
                }
              }
              if(totC)  newCodes=1;  
              updateMenuQ();
              
              for(k=0;k<nPROCSS;k++) close(pipes[2*k]);
              free(pids);   
              free(pipes);
              for(k=0;k<nPROCSS;k++) free(qd[k]);
              free(qd);   
            }
            
            sq_diagramsinfo();

            if(!continuetest()) break; 
            showheap();  
            put_text(&pscr4);
         break;
         case 3:
            { static char keystr[12]="]{{[{";
              if(res==2) messanykey(3,10,LOCKtxt); else inkeyString=keystr;
            }
            break;
         case 4:
            if(res==2) messanykey(3,10,LOCKtxt); else
            { char command[100];
              saveent(menulevel);
              chdir("results");
              makeVandP(0,"../models",n_model,2,pathtocalchep);
              finish();
              sortie(22);
            }
         case 5:  mk_reduceprograms();  break;
      }
      if(k4==2 && continuetest()) { put_text(&pscr4); break; }
   }

label_50:
   k5=1;
   pscr5=NULL;
   menulevel=5;
   saveent(menulevel);
   sq_diagramsinfo();
      
   for(;;)  
   {  int n_calchep_id;   
      menu1(56,4,"","\026"
         " C code               "
         "     C-compiler       "
         "     Edit Linker      "
         " REDUCE code          "
         " MATHEMATICA code     "
         " FORM code            "
         " Enter new process    " ,"s_out_*",&pscr5,&k5);
          
      if((k5==1||k5==2)&&pid) 
      { int epid=waitpid(pid,NULL,WNOHANG);
        if(epid) pid=0; else
        { 
          messanykey(3,10,"This option is frozen while n_calchep runs or is compiled");
          continue;
        }
      }  

      switch (k5)
      {  case 0: goto label_40;  break;
         case 1:
           c_prog(); newCodes=0; saveent(menulevel);
           break;
         case 2:
           if(newCodes) { c_prog(); newCodes=0; saveent(menulevel);}
          n_calchep_id=setLockFile("results/.lock"); 
           if(n_calchep_id)
           {
             if(nPROCSS)
             { chdir("results"); 
                makeVandP(0,"../models",n_model,2,pathtocalchep);
               pCompile();
               if(access("./n_calchep",X_OK)==0)
               { 
                  fflush(NULL); 
                  pid=fork();   
                  if(pid==0) 
                  {
                    system("./n_calchep");
                    exit(0);
                  }    
               } else messanykey(15,15,"n_calchep is not generated");
               chdir("../");
             } else                       
             { fflush(NULL); 
               pid=fork();
               if(pid==0)
               {  if(chdir("results")==0)
                  {   char*command=malloc(100+strlen(pathtocalchep));
                      makeVandP(0,"../models",n_model,2,pathtocalchep); 
                      sprintf(command,"xterm -e %s/sbin/make__n_calchep %d", pathtocalchep,n_model);                                 
                      system(command);
                      free(command);
                      system("./n_calchep");                     
                   }
                   exit(0);    
               }
             }
             unLockFile(n_calchep_id); 
           } 
           break;
         case 3: if(edittable(1,1,&modelTab[4],1," ",0))
                 {  char fName[STRSIZ];
                    sprintf(fName,"%smodels%c%s%d.mdl",pathtouser,f_slash,mdFls[4],n_model);
                    writetable( &modelTab[4],fName); 
                 }
                 break;
         case 4: makeReduceOutput(); break;
         case 5: makeMathOutput();   break; 
	 case 6: makeFormOutput();   break;
   
         case 7:
            put_text(&pscr5);
            clrbox(1,2,55,11);
            menuhelp();
            goto label_20;
      }
   }

exi:
   finish();
   sortie(0);
   return 0;
}
Ejemplo n.º 21
0
int  cs_numcalc(double Pcm)
{
   int  k,l;
   void * pscr0=NULL;
   void * pscr = NULL;
    
   get_text(1,3,60,11,&pscr0); 
   k=proces_1.nsub;   
   sprintf(procname,"%s,%s ->%s,%s",pinf_int(k,1,NULL,NULL),
           pinf_int(k,2,NULL,NULL),pinf_int(k,3,NULL,NULL),pinf_int(k,4,NULL,NULL));              
   va_int[0]=Pcm;
   
    cos1=-0.999;
    cos2= 0.999;
      
   infotext();
   writeinformation();
   k = 1;
   l = 1;
   
   recalc = 1;
   do
   {  char menuTxt[]="\030"
         " Change parameter       "
         " Set precision          "
         " Cos13(min) = cosmin    "
         " Cos13(max) = cosmax    "
         " Angular dependence     "
         " Parameter dependence   "
         " sigma*v plots          ";
      if (recalc)
      {  
         total_cs();
         recalc = 0;
        if (err_code) errormessage();                  
      }

      improveStr(menuTxt,"cosmin","%.6f",cos1);
      improveStr(menuTxt,"cosmax","%.6f",cos2);
      
      menu1(54,4,"",menuTxt,"n_22_*",&pscr,&k);
         
      switch (k)
      {
         case 0:  break;
         case 1: if(change_parameter(54,5,1)) recalc=1; break;
         case 2: 
            do {   /* Precision */
               recalc = correctDouble(1,23," Enter precision : ",&eps,1);
               if (eps < 1.E-10 || eps > 0.0011)
                  messanykey(10,12,"Range check error");
            }  while (!(eps >= 1.E-10 && eps <= 0.03)); 
         break;
         case 3: recalc=correctDouble(15,10,"Min[cos(p1,p3)]=",&cos1,1); break;
         case 4: recalc=correctDouble(15,10,"Max[cos(p1,p3)]=",&cos2,1); break;
         case 5: if(err_code>1)  errormessage(); else drawgraph();    break;
         case 6: paramdependence(totcs,procname,"Cross Section [pb]"); break;
         case 7: paramdependence(vtotcs,procname,"v*sigma[pb]"); break;
      }  /*  switch  */
      if (k > 0) writeinformation();
   }  while (k != 0);
   put_text(&pscr0);
   return 0;
}
Ejemplo n.º 22
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; 
      }
   }
}
Ejemplo n.º 23
0
int monte_carlo_menu(void)
{
   static int r=0;
   int mode=1;
   void * pscr=NULL;
   void * pscr_mem=NULL;
   void (*quit)(int)=f3_key[7];
   char menutxt[]="\030"
                  " Subprocess             "
                  " IN state               "
                  " Model parameters       "
                  " Constraints            "
                  " QCD coupling           "
                  " Breit-Wigner           "
	          " Aliases                "
	          " Cuts                   "
	          " Phase space mapping    "
                  " Monte Carlo simulation "
                  " Easy                   ";
                  
   if(nout_int!=2  ) menutxt[menutxt[0]*10+1]=0;
   if(nin_int==1)  improveStr(menutxt,"Easy", "Total width"); 
           else    improveStr(menutxt,"Easy", "1D intergration");
 
   get_text(1,10,80,24,&pscr_mem);
   wrtprc_();
   for(;;)
   {  
      infor();
      f3_key[7]=quit;
      menu1(54,4,"",menutxt,"n_mc_*",&pscr, &mode);
      if(mode==1||mode==2||mode==3||mode==5||mode==7)f3_key[7]=NULL;

      switch (mode)
      { 
        case  0: put_text(&pscr_mem); return 0;
        case  1: r=r|3*sub_men__(); break;
        case  2: r=r|in_setting(); break;
        case  3: r=r|change_parameter(54,7,0);  break;
        case  4: { int modeC=1;
                   for(;;)
                   { char menuC[]="\030"
                     " All Constraints        " 
                     " Masses,Widths,Branching"; 
                     void * pscrC=NULL;
                     menu1(54,6,"",menuC,"n_constr_*",&pscrC, &modeC);
                     switch(modeC)
                     { case 0: put_text(&pscr_mem); break;
                       case 1: show_depend(54,7); break;
                       case 2: show_spectrum(54,9); break;
                     } 
                     if(!modeC) break;
                   } break;
                 }     
        case  5: r=r|qcdmen_();  break;
        case  6: r=r|w_men__();  break;
        case  7: do r=r|(3*edittable(1,4,&compTab,1,"n_comp",0)); while (fillCompositeArray());
	         break;     
        case  8: do r=r|(3*edittable(1,4,&cutTab,1,"n_cut",0)); while (fillCutArray()); 
                 break;             
        case  9: r=r|mappingMenu(); break;                      
        case  10: 
                 if(nout_int==1 && !sf_num[0] && !sf_num[1]  ) 
                 { if(blind)  return 1;                     
                   messanykey(15,15,"Phase space integration for 2->1 processes\n needs distribution functions.");
                   break;
                 }
                                                                        
                 
                 if(checkEnergy())   
                 { if(blind)  return 1;                  
                   messanykey(15,15,"Energy is too small!");                   
                   break;
                 }

                 if(fillCutArray()) 
                 { if(blind) return 2;
                   messanykey(15,15,"Can not evaluate cuts limlts"); 
                   break;
                 }  
        case 11:
                if(mode==11) 
                {  void (*f10_tmp)(int);
                   w_sess__(NULL);
                   f10_tmp=f3_key[7];
                   f3_key[7]=f10_key_prog_for22;
                   if(nin_int==1) decay12(); else
                   { REAL m1,m2, Pcm;
                     pinf_int(Nsub,1,&m1,NULL); 
                     pinf_int(Nsub,2,&m2,NULL);  
                     incomkin(m1,m2,inP1,inP2,NULL,&Pcm,NULL); 
                     if(sf_num[0]||sf_num[1]||nCuts)
                      messanykey(10,10,"Structure functions and cuts are ignored\n");                                       
                     cs_numcalc(Pcm);
                   }
                   f3_key[7]= f10_tmp;
                   r_sess__(NULL); 
                   break;
                } else if(fillRegArray()) 
                {  
                  if(blind) return 3;                
                   messanykey(15,15,
                       "Can not evaluate regularization paremeters");
                   break;    
                }
   
                if(mode==10)  runVegas(); 
                r=0;  
                break;
                 
      }
      if(r) clearEventMax();
      if(r&2) clearGrid();
      if(r&1)newSession();
   }
}