
 In the framework of  \CompHEP~ package  there are four ways to 
realize numerical calculations, namely using:
\begin{itemize}
\item[1)]  built-in interpreter  
\item[2)]  compiled \C~ output
\item[3)]  compiled  {\it double precision} (REAL*8)   \FORTRAN~ output
\item[4)]  compiled  {\it quadruple precision} (REAL*16) \FORTRAN~ output.   
\end{itemize}
For the  first two items  calculations are performed 
with a {\it double} precision.  The interpreter works 
slower  compared with the stand-alone compiled executables, but it
does not need such steps as the storage and  compilation of symbolic
output. So it is reasonable to use the interpreter either in the case of
simple process or if you have no compiler at all. 

The general  functionality scheme is the same for all four cases.
The main differences  are: 
\begin{itemize}
\item[-] for the first two items the user interface is more comfortable
because it is based on graphic terminal facilities; 
\item[-]  results of calculation produced by the interpreter are
displayed on the screen only, whereas in other cases they are  stored onto a 
disk either;
\item[-]  {\it batch} calculations (set of evaluations launched by one
job task) are not available for the interpreter; 
\item[-] for the current version only  \FORTRAN~ programs provide
the user with a possibility to generate an event flow.
 
\end{itemize}
 
The interpreter is launched  from within the symbolic
session.
Compiled  programs can be  created and  started under the  symbolic session 
(see {\it Menu~7} in Fig.\ref{s_chain})
or created by means of Section \ref{file-commands} commands and
launched as an independent process.



\subsubsection{Sketch of the menu system}


A general scheme of   \CompHEP~  numerical calculations 
is presented in Fig.\ref{n_chain}. 
The \CompHEP~ screen with  the   menu  number 1  is presented in
Figs. \ref{screen_menu} and \ref{screen_menu_f}.  
  Three functions
of this menu  launch   integration programs. One of them is 
 Monte Carlo program \VEGAS~   \cite{Lepage,NumRecFORT}.
  The other one is the ordinary {\it Simpson} 
integration routine which can operate only for the simplest 
2~\verb|->|~2 type of reactions.  The {\it Batch} menu function is used 
to organize a set of \VEGAS~ evaluations in the non-interactive mode (see
Section \ref{batch}).  
 Other menu items are needed to set  an environment for integration.
Below we  briefly   describe all of them. 
More  detailed explanation is given in the following sections.

By means of the {\it  Subprocess} function the user may  select 
one subprocess for a  further processing. This function is active 
only if  several subprocesses have been evaluated  symbolically before.
The name of  current subprocess
is displayed on the screen (Fig.\ref{screen_menu} and
Fig.\ref{screen_menu_f}).
 Subprocess summation is not implemented in the current 
version.

 
The {\it In\_state}  function gives the user an option
to choose  structure functions for incoming particles and
assign some values for their momenta. The  {\it GeV} units
are assumed for the momenta.
  This menu function is available for  collision processes 
only.

The {\it Model\_parameters}  function allows the user to assign a 
new value to any  independent parameter involved in the
evaluation.  After  an activation of this
function  the corresponding menu of parameters with information
about their  values is displayed.  As a result of  changing  
the  independent parameters 
some constrained parameter can  get non-evaluated as a 
result of a negative square root argument or division by zero in the
relevant  expressions. In this
case an error  message appears on the screen and the user
is required to choose an admissible set of parameter values. 

  Although the user may assign some value to the  QCD strong coupling
parameter {\it GG} it does not influence on results of calculation.
This parameter will be reset according to the rules defined by the 
{\it QCD~scale} menu function.   

  \CompHEP~ substitutes a Breit-Wigner exact propagator for the  s-channel
virtual particles.
 This trick is
needed to avoid  the integral divergence near the mass pole
and   is motivated by high order corrections.
The way of implementation of the  Breit-Wigner propagator  is driven by  
the {\it Breit-Wigner} menu function. See Section (\ref{Breit-Wigner}) 
for details.


The {\it Cuts} menu function provides the user with a possibility  to 
cut a  phase space volume. A set of physical variables which 
could be used to construct a cut function is described in Section \ref{functions}.
Details of  the {\it Cuts} menu processing are given in Section \ref{cuts}.

  The {\it Kinematics} and {\it Regularization}  menu functions are used
to construct an appropriate mapping of phase space onto  the  \VEGAS~ integration 
volume. This is  important for successful Monte Carlo integration. 


\subsubsection{Numeration of Monte Carlo sessions}
\CompHEP~  numerical calculations are organized as
a sequence of Monte Carlo integration sessions. Each session has its ordinal
number. The current session number is
displayed. 

All results of calculations are written into the
{\it results} directory.  
To distinguish files produced in different
sessions we include a session number {\it N} in the output file names.
 To distinguish files produced by {\it n\_comphep\_f}
from those produced by {\it n\_comphep\_c} we use prefixes {\it 'c\_'} and {\it
'f\_'} as required.  
   The results  of integration and all settings   are stored in the protocol 
file {\it f\_prt\_}{\tt N} ({\it c\_prt\_}{\tt N}).  Events generated 
by {\it n\_comphep\_f}
are stacked in the file {\it events\_}{\tt N}.
 A current version of the  {\it n\_comphep\_c}
program does not save events.

  The latest settings are saved in the file {\it f\_session.dat
(c\_session.dat)}
when
{\it n\_comphep} is quitted.  On a next launch this file is scanned to restore
the
last settings.

\subsubsection  {QCD scale}

  \CompHEP~ substitutes the QCD strong coupling constant as a
function of the  ${\Lambda}^{(6)}$ parameter and the  $Q^2$ scale value.
It is calculated in the next-to-next-to-leading order (NLLO)
and  depends on a number of  quark flavors ({\it nf}) with masses less
than Q (see Eq.9.5a of \cite{ParticlesFields}). 
Relevant constants  $\Lambda^{(nf)}$ are recalculated
from  ${\Lambda}^{(6)}$  according to the  matching equation (9.7) 
of \cite{ParticlesFields}.
     
If the user is going to change  a numerical value of  $\Lambda^{(6)}$ 
or the $Q^2$ scale definition he  should  call the necessary function of
{\it Menu~4}. For the    $Q^2$ choice he will be prompted 
what  kind of scale he would like to implement, namely, the {\it constant}
scale or  the {\it running} one. In the first case  a subsequent input 
of number in {\it GeV} units is expected. In the second case \CompHEP~ 
provides the  user with  a possibility to define the  $Q^2$ scale as a
squared sum of particle momenta.  Digits on  input will be
transformed into  ordinal momentum numbers. For example: the input '13' will
be treated  as  $Q^2=|(p1-p3)^2|$.


   If $Q^2$  is defined as a constant, the corresponding value
of $\alpha = GG^2 / ( 4 \pi )$ is displayed on the screen.
 The  $\alpha(s)$ plot  for a user-defined region of {\it s}   is  available
also by means of the corresponding  function of {\it Menu~4}. 
 The same $Q^2$ scale is used as an argument
of parton distribution functions.

\subsubsection {Breit-Wigner propagator}
\label{Breit-Wigner}
The propagator of virtual particle
has a pole at $p^2 = m^2$:
$$\frac{1}{p^2 -m^2}\;\;.$$
If the pole is situated inside the phase space volume 
it leads to a non-integrable
singularity. The general solution of this 
problem is an account  of special set of  high order corrections
\cite{BD}. They  transform the propagator to the  Breit-Wigner form
 $$ \frac{1}{p^2 -m^2 -i \cdot \Gamma(p^2) \cdot m}\;\;,$$
where the value $\Gamma(m^2)$  is the particle width (reversed mean life
time).  

First  problem  which  appears in a way of implementation of this
expression is a choice of $\Gamma(p^2)$ dependence. 
The  $\Gamma$  value is 
essential near    the pole point $p^2 = m^2$. Thus, for the
first approximation we can put $\Gamma(p^2)=\Gamma(m^2)=const$.
It corresponds to the position {\it OFF} of {\it 'S~dependence'} switch.
In some papers it is declared that  $\Gamma(p^2)=\Gamma(m^2) \cdot
\sqrt{p^2}/m$  describes the pole shape better. This choice  corresponds to 
the position {\it ON} of  {\it 'S~dependence'} switch. 


The second  and even  more important problem is a gauge symmetry breaking.
Generally we  have  this symmetry in any order of perturbation theory
but  the intervention of a part of  higher order terms  to the lowest order
expression via the Breit-Wigner propagator can break it.  

The gauge symmetry
is responsible for some cancellation of  diagram contributions
(see Section \ref{cancellations}), and its  violation, in turn, 
prevents the cancellations 
and can lead to a completely wrong result. 
The user could  solve this problem by setting  the {\it Gauge~invariance}   
menu switch to the position {\sc ON}. 
In this case the contribution of a
diagram which does not contain the Breit-Wigner propagator is
multiplied by  factor \cite{BW-factor,BW-factor2}  
\begin{equation}
\frac{(p^2-m^2)^2}{(p^2 -m^2)^2 +  (width(p^2) \cdot m)^2}\;\;.
\label{width_factor}
\end{equation}
This trick corresponds to the symbolic summation of all diagram
contributions at a common denominator expression and to
a subsequent substitution of the width term  into the factored
denominator. The  trick
allows to keep all gauge-motivated cancellations. As a defect of the trick it
must be mentioned that the factor (\ref{width_factor}) kills a contribution
of non-resonant diagrams in the resonance point \cite{BadGIWdth}. 
If the  particle
width is very small such an approximation is reasonable, but in some
 cases it can also lead to an error.


\subsubsection{Phase space functions} \label{functions}

There is a special set of phase space functions
 which  may be used to construct cuts and  distributions in the framework of 
 \CompHEP.
  The general notation looks like \\
  \hspace*{2cm} {\it (Key~Character)(momentum~set)}.\\
A set of momenta  is represented as a set of digits. Any digit corresponds 
to a momentum number. For  example, {\it C13} means a cosine of the
angle between  momenta ${\bf p_1}$ and ${\bf p_3} $. 
The momenta are assigned to   particles according to their sequence in the
process name.

Below we list the available  key characters and explain the meaning of 
the corresponding  physical functions.

\begin{itemize}
\item [A] - angle  in degree units. 
\item[C]  - cosine of angle.   
\item[J]  - jet cone angle. The jet cone angle ${\it J_{ij}}$ is defined 
as $\sqrt{\Delta y^2+\Delta\varphi^2}$, where  
$\Delta y$ is the pseudo-rapidity difference and $\Delta \varphi$  is the azimuth angle
difference for momenta ${\bf p_i}$ and ${\bf p_j}$. 

\item[E]  - energy of  the particle set.
\item[M]  - mass of the  particle set. 
\item[P] - cosine in  the rest frame of pair.  ${\it Pij}$ is
defined as follows: we imply a boost in
the direction of ${\bf p_i + p_j}$ to  get the
rest frame of the pair. Then  {\it P} is a cosine of angle between 
the transformed ${\bf  p_i}$  and  the direction of boost.

\item[T]  - transverse momentum   of the  particle set.  
\item[S]  - squared invariant mass of the particle set.
\item[Y] -  rapidity of the particle set. 
\item[U] -  user's implemented  function. The character string following 
 {\it U}  is passed on to the user   \FORTRAN/\C~ function   {\it
usrfun(str)} which, as it is assumed,  calculates a corresponding  value. See
Section \ref{user-prg} for  further explanations.

\end{itemize}

Zero components of all  momenta  are positive, and the conservation law 
means that the sum of momenta of incoming particles is equal to that 
of outgoing particles. Relative momenta signs   for the {\it S}
 function are substituted automatically.

There  are some natural requirements on the momentum set, namely:
 a)~the momentum sets following    {\it A, C, J, P}   must consist 
of two elements; b)~the momenta following   {\it M, P, T}   must belong 
to  outgoing  particles only; c)~any momentum can appear only once
in  one set.


\subsubsection{Cuts} \label{cuts}

The {\it Cuts} menu function opens a table for cuts definition.
This table consists of three columns. 
The  phase space function  in notations of Section \ref{functions}  must be 
 written   in the first  column. 
The second and the third columns  define the  minimal  and maximal
limits  for this function.  If one of them  is empty   the corresponding
limit is not applied.

   Input   formats for limits  are  different 
for the \FORTRAN~ and \C~  realizations.
  In the case of  
{\it n\_comphep\_c} and  {\it interpreter} sessions the user may type
in the corresponding fields any algebraic formula
which contains numbers and identifiers enumerated in the {\it 
Model~parameters} menu. Parentheses "()" and operations $ "+,-,/,*,**,sqrt()"$
also are permitted.

In the case of {\it n\_comphep\_f } session only numbers are expected 
in the  corresponding columns. To escape an input in $GeV^2$ units 
in the case of squared  momenta function
\begin{center} $ V_{min} <  S(momenta~set) < V_{max} $, \end{center} 
the  {\it n\_comphep\_f } program
 asks the user to put  $V_{min}/\sqrt{|V_{min}|}$ and 
  $V_{max}/\sqrt{|V_{max}|}$   in the relevant cells.

  It is very important to note that only the cuts on masses and squared
momenta 
(the {\it S} and {\it M} cases)  are realized via a reduction of the phase space.
Other ones are realized by  multiplication of squared
matrix element by a step function. 


\subsubsection{Kinematics} \label{Kinematics}

The {\it Kinematics} function  allows to  display and change  a general 
scheme of the phase space parameterization.
  A kinematics scheme in  \CompHEP~ is
defined by a set of subsequent   1~\verb|->|~2 decays
of the incoming state into the  outgoing particle sets. 

  After activation of this menu function the current 
decay scheme will be displayed and a dialogue message 
will propose the user to accept it or put in another one.

 During the input \CompHEP~  consequently  asks the user  to define
a  first outgoing cluster of  virtual decay. The user input must be 
a sequence of particle (momentum) numbers without any separating symbols.
It is  assumed that 
particles are numerated in the same order as they are written down in 
 the (sub)process name.

  An example of  kinematics 
definition for 2~\verb|->|~4 process is given by the following lines: \\
\hspace*{2cm} 12~~\verb|->|~{\bf 3},456\\
\hspace*{2cm}456~\verb|->|~{\bf 56},3\\
\hspace*{2cm}56~~ \verb|->|~5,6\\
Here the user input is indicated in bold characters. 

In the framework of such a decay scheme the multi-particle phase space
is parameterized by masses of sub-clusters and  by two-dimensional  spherical
angles of  1~\verb|->|~2 decays  \cite{B4,kinematics}.
 A choice of kinematics influences on the phase space mapping
 and by this way it influences  
on convergence of  Monte Carlo integration. See Section \ref{kinematics}. 



\subsubsection {Regularization} \label{regul_menu}

  In   general case a squared matrix element is
too singular for direct Monte Carlo integration.
  Singularities of the matrix element are caused
by poles of virtual particle propagators
and can have one of the following forms
\begin{eqnarray}
\label{pole_1}
1/(p^2 - m^2)\\
\label{pole_2}
1/(p^2 - m^2)^2\\
\label{pole_w}
1/( (p^2-m^2)^2 + (m\cdot\Gamma)^2)
\end{eqnarray}
where $m$, $\Gamma$, and $p$  are the  mass, 
 width, and  momentum of virtual particle.

The {\it Regularization} menu function allows the user to
 point out  dangerous denominators for automatic 
smoothing  the  sharp peaks of the squared matrix
element.
The regularization  table contains  four fields: {\it momenta, mass, width
} and {\it power}.

 Momentum of virtual particle is a sum of momenta of incoming and
outgoing particles. Just type the ordering numbers of these
momenta  in the {\it Momentum} field. The sign is substituted automatically.  
For example, for a collision process 
{\bf 12}  is treated as  $(p1+p2)$ and
{\bf 134} is treated as  $(p1-p3-p4)$.


  {\it Mass} and {\it Width} describe a position of the pole.
In the case of \FORTRAN~ program the corresponding  numerical
values must be written down in these fields. In the case of {\it C} program
 the user can write down some algebraic expressions which contain the identifiers
enumerated in the {\it Model parameters} menu.  For  t-channel propagators
(both incoming and outgoing momenta contribute to  $P$)   only a zero  value 
in the {\it Width} field is permitted
because \CompHEP~ ignores particle width term for such propagators. 

 
  The {\it Power} field  defines an exponent of the propagator.
 Acceptable values are 1 and 2. Of course, in a squared
matrix element any propagator appears to the power of 2. But
sometimes as a result of gauge cancellations the exponent can be
efficiently  decreased to 1. If the {\it Width} field is not
equal to 0 such a cancellation is not expected and \CompHEP~
will use value 2 for the exponent ignoring the user input.


The work of regularization program is sensitive to the
{\it S} and {\it M} types of cuts (see Section \ref{cuts}) and 
is not  sensitive to other ones. Consequently, if you would like to 
smooth some singularity due to the pole  inside the phase space, you should 
apply the {\it S}  or {\it M}  cut to exclude the pole point 
from the consideration.

The algorithm of regularization is explained in Section 
\ref{kinematics}.

      
\subsubsection{VEGAS menu}

 See Section \ref{vegas} or \cite{Lepage,NumRecFORT} for  explanation
of the \VEGAS~ algorithm. The work of \VEGAS~ program is driven by {\it
Menu~6} of Fig.\ref{n_chain}.

The first position of this menu starts the process of  Monte Carlo
integration. It consists of {\it Itmx} runs with subsequent
adaptation of the  Monte Carlo weight function to the integrand. 
For each run \VEGAS~ calls the integrand about  {\it Ncall} times.
The user may set the {\it Itmx} and {\it Ncall} parameters applying  the next 
two items of the menu. 
The results of calculations are displayed  on the screen and
 written to the protocol file.

 If the required  precision of calculation 
is not reached the user may call the {\it Start integration} menu 
function once more to increase the Monte Carlo statistic.  
But if the {\it Clear~statistic} menu function 
is called, then the next  Monte Carlo session
will be started from the beginning.    
The  Monte Carlo weight function is saved between runs anyway.
   
 
In the case of \FORTRAN~ {\it n\_comphep} program the user can  write
weighted events generated by \VEGAS~ into a file. The maximum
and average values of event weights are displayed on the screen and written 
into the protocol file.  
The user must take into account that 
any new call of the {\it Start integration} menu function will 
rewrite this file.     

In the case of \C~ version of the  {\it n\_comphep} program the user   
has a possibility to fill in some histograms during  the Monte Carlo
integration. In this case he needs to activate the {\it Set Distribution}
function. This menu function opens a table of distributions 
which can be filled in by the user. The first column defines a phase
space  function  which the user would like to scan. The set of available 
functions and the input format are  defined in Section \ref{functions}.
The next two  columns define a region of variation of the corresponding 
phase space function. There could be either a number or an algebraic
expression containing the identifiers listed in the  {\it Model~parameters} 
menu.

  The user can browse the distributions using the {\it
Display~distributions}
menu function. This menu function asks the user to choose one  
distribution and a number of bins. After that the distribution appears. 
 A call for {\it Clear~statistic} menu function  clears  the stored
distributions.  


\subsubsection{Batch calculations} \label{batch}


   \CompHEP~ was created as a program for calculation in an interactive
mode. But in practice   long-time calculations are typical and it is 
reasonable to perform them in a batch queue regime. According
to this 
requirement we have implemented the batch (or, say, `blind') calculation 
mode in \CompHEP.

  During the work with the {\it n\_comphep\_f(c) } program  in the interactive 
mode you have a possibility to store all current settings and task
parameters 
in the  {\it f(c)\_batch.dat} file. The function {\it Batch} of the main menu 
is used 
to define such a task and save it in a file. It opens the  {\it  Menu~8} 
(see Fig.\ref{n_chain}). Its first function  appends  parameters of the  current 
session to the {\it f(c)\_batch.dat} file.  It is possible 
to join several tasks in one {\it f(c)\_batch.dat} file. 

   
  For the batch mode you are provided with a possibility to perform two
sessions
of \VEGAS~ calculation with automatic call for  the {\it Clear~statistic} 
function between the sessions. These sessions are driven by the 
{\it Itmx1, nCall1, Itmx2, nCall2} parameters which in their turn
may be defined by means of functions of {\it Menu~8}. The 
meanings of these parameters are similar to the same name parameters of 
the \VEGAS~ menu.  If you put one of these
parameters equal to zero then only one session will be launched.

If you set the  {\it Generate events} switch   {\tt ON}, then the 
squared matrix elements calculated 
during the last \VEGAS~ session  will be saved in 
a file for further processing (see Section \ref{events}).

There is a  possibility to organize  cycle calculation within one task.
The  {\it Table size}  function  defines a number of steps for
the cycle  calculation.  The user may choose a parameter to scan by means of 
the     {\it Table param}  function. The last two menu functions
allow to set the extreme values for the scanning parameter. 

   
  Every time when you  start {\it n\_comphep\_f}~ it checks a presence of 
the {\it f\_batch.dat} file.
If it exists you will be prompted:\\
\hspace*{2cm}{\tt Would you like to use the BATCH mode?} 

If you answer {\it 'y'}  then {\it n\_comphep} reads the tasks from the 
{\it f\_batch.dat } file and performs requested calculations. 

So, if the {\it f\_batch.dat} file exists the batch calculations can
be launched by
the pipe command:\\
\hspace*{2cm}{\tt echo y |n\_comphep\_f}

The batch calculation in the case of {\it n\_comphep\_c}
is started by \\
\hspace*{2cm} {\tt    n\_comphep\_c -batch}

   \CompHEP~ has an internal counter for Monte Carlo sessions
which accrues after each Monte Carlo session. All output files 
have this session number as a part of their names. Hence, 
outputs from different tasks are written down in  different files and 
all results are  safely remembered after the {\it n\_comphep} run.
In the case of cycle calculation the additional 
joint file {\it f(c)\_table\_{\tt N}\_{\tt M}} with results of calculation 
will be created. Here  {\tt N} and {\tt M} are the first and the last 
number of session for the current cycle.

\subsubsection{Integration by means of the Simpson method} \label{simpson}
In the case of 2\verb|->|2 type of process we provide the user with a possibility
to calculate the cross-section using the  adaptive Simpson  algorithm.
It allows to get the results instantly and with a high precision.

Note that some user's settings are ignored when you choose this 
option. Namely, the structure functions are switched off, the center-of-mass
rapidity  is assigned to zero, regularizations are also ignored   and 
only  angle and cosine cuts for incoming and outgoing particles
are taken into account.

When the {\it Simpson} menu function is activated  \CompHEP~ tries        
to evaluate the cross-section. Sometimes it is not possible, for example, 
if the corresponding value is  infinite, as we have in the case of
 $e^+,e^+ \to e^+,e^+$ reaction. When program 
detects a pole inside of the integration region it produces an error message like

\begin{center}
\begin{tabular}{|c|}
\hline
    Division by zero  \\ Press any key \\
\hline 
\end{tabular}
\end{center}
    
In the  above case  you should  remove the region of small angle 
scattering by applying the corresponding cuts and  after that activate 
the {\it Simpson}  function once more. 

If the cross-section is successfully integrated the result
is displayed on the screen. {\it Menu~6} which is also  displayed on the 
screen  (see Fig.\ref{n_chain}) has the following  options:

a) to set relative precision of integral evaluation. A default value is
$10^{-4}$;
 
b) to display dependence of the differential cross-section on the cosine 
of the scattering angle;

c) to calculate and display on the screen the  total cross-section
or the forward-backward asymmetry  as a function of 
any  parameter involved in the calculation.


\subsubsection{Process of two particle  decay} \label{2decay}

In the case of  1\verb|->|2  decay process the menu scheme described  above
is not used  because in this simple case the phase space integration 
is not needed. \CompHEP~ writes on the screen the calculated particle width.
If a multi-channel process like Z\verb|->|2*x  has been introduced then 
branchings for all decay modes are displayed (Fig.\ref{results_1-2}). 
The menu on the screen contains only one function which provides the user with 
a possibility  to calculate the total particle 
width as a function of one of the model parameters.
