
     This directory contains  source files  of  some auxiliary  routines.
==========================================================================
1. callPYTH.f   event2pyth.c
  callPYTH.f  is a main program which has to be linked with PYTHIA library.
It allows to created executable code which reads event files generated by 
CalcHEP and organize decays of resonances, generation of parton showers 
and  hadronization using facilities of PYTHIA and/or decay events generated 
by CalcHEP.
event2pyth.c is an auxiliary program which has to by compiler preliminary 
by C-compiler and the corresponding object file has to be linked with 
other Fortran codes. 
    cc -c event2pyth.c
    f77 -o pythLink  callPYTH.f event2pyth.o pythia####.o
  callPYTH.f  has to be modified by the user to specify destination of 
event files, usage of SLHA, and output format. The main user routines used
in callPYTH.f  are 
  a)  integer function SCANDIR(dirname)
   attaches all event_#.txt files stored in directory 'dirname' and returns 
the number of files attached. One can call it several times for different 
directories  to mix different subrocesses.  SCANDIR stops with error 
message if it meets two event files with identical processes. One can use 
subproc_cycle routines to generate event files for several subprocesses by 
one command (see bin/README for details). SCANDIR also can be applied to 
directories with decay events generated by CalcHEP. Then 
these decays will be recursively applied to products of event reaction 
before passing  the event to PYTHIA. 
 
  b)   subroutine EVENTSTAT(CS, MAXEVENTS)
   returns summary cross section for all attached files and maximum number of
   events which one can generate with right statistics. 

After initialization of Pythia 
    CALL PYINIT('USER',' ',' ',0d0)
one can 
    CALL PYEVNT 
in cycle as many times as he likes. The program  chooses  events from the 
attached files according to cross sections of subprocesses.  When   one 
of event_#.txt files  finishes, it rewinds.

==========================================================================
2. myPDFLIB.f 
This is a template of routine which allows user to implement 
new parton distributions in CalcHEP. It simulates CERN PDFLIB  and 
must be included in 'Libraries' model table instead of CERN PDFLIB.

In the simplest case of implementation of single structure function,
the user has to replace the toy realization of 
   SUBROUTINE STRUCTM(X,SCALE,UPV,DNV,USEA,DSEA,STR,CHM,BOT,TOP,GL)
on real one. 

The ALPHAS2(SCALE) function also presented in myPDFLIB.f in a toy version.
Indeed CalcHEP user has a possibility to ignore  this ALPHAS2 and to use 
the one built-in CalcHEP. Or you can realize here real  ALPHAS2 compatible 
with the implemented structure function.

The compiled object file  must be passed to linker by means of 
'Libraries' model menu. The special Fortran libraries have to be added to 
the linker. They should be stored in  $lFort variable. 
Read README(findFlib.c) in case of problem.

To implement several structure functions one has to  modify slightly 
 SUBROUTINE PDFSET
It contains commented by (*) code for including second parton distribution.
The sets of distributions are specified by the  NPTYPE, NGROUP, NSET
parameters which passed to STRUCTM and ALPHAS2 via internal COMMON.

Note  that CalcHEP works only with   NPTYPE=1 distributions.
But you still have a possibility to define 9 groups of sets with 100 
distributions in each set. Just define the maximum number of sets for each 
group:  
       NPGSMX(1,NGROUP)=
and text identifier for each set
       SFNAME(1,NGROUP,NSET)=   Up to 8 symbols.
=========================================================================
3. findFlib.c : Detection  of Fortran libraries that one has to pass to cc
to link Fortran object files. 

   Compile the code
   cc -o findFLib findFlib.c 

   call
findFlib <C-compiler> <C-verbose option> <Fort -compiler> <Fort-verbose option>    
   like  
findFlib  cc -v f77 -v 

It  result the list of default libraries that are passed to linker by f77 
and not  passed by cc should appear on the screen. For example, in case of 
Linux one gets

-lfrtbegin
-lg2c
-lm
 
This libraries have to be added to 'Libraries' model item if 
one uses external functions written in Fortran. Note that in the example 
above -lfrtbegin definitely is not needed because according to its name 
is serves  Fortran 'main'. Also -lm  in CalcHEP is already added automatically.
===========================================================================
3. lan2calchep.c  - program which transforms model files produced by Lanhep
for Comphep into format of CalcHEP. In can be compiled by 
       cc -o lan2calchep lan2calchep.c 
The generated executable file need 3 arguments 
 
1)path to destination of models in LanHEP format
2)Model number N (like varsN.mdl)
3)Target model number. The model files  will be created in the current 
directory. 
Note that lanhep must be launched  with option -c4. In this case power 
is designated by the ^ symbol instead **.  
==========================================================================
4. axodraw.sty  - axodraw style file for LaTeX output produced by CalcHEP
==========================================================================
5. cteq2pdt.c  - transforms CTEQ *.tbl tables in CalcHEP *.pdt format. 
It has to be compiled by 
    cc -o cteq2pdt cteq2pdt.c alpha.c -lm 
the alpha.h file is used at compilation.
The usage:
   ./cteq2pdt <cteq_file.tbl >calchep_file.pdt
Can be applied to CTEQ4,CTEQ5,CTEQ6 files.
==========================================================================
6. mrst2pdt.c -transforms MRST *.dat tables in CalcHEP *.pdt format.
It has to be compiled by 
    cc -o mrst2pdt mrst2pdt.c alpha.c -lm 
the alpha.h file is used at compilation.
The usage:
   ./mrts2pdt name [nf Odr alMZ] <mrst_file.dat >calchep_file.pdt
Can be applied to mrst2002 files. 
MRST '.dat' file doesn't contains information about running alpha. 
It can  be passed via addition parameters: nf,Odr,alMZ. See MRST documentation.
(Indeed nf=5, Ord has to  be 'lo', 'nlo','nnlo' is included in filename) 
========================================================================== 
7. checkpdt.c  is a simple program for testing *pdt files.
It can be compiled by 
 cc  -o checkpdt checkpdt.c pdt.c -lm
where pdt.c has to be copied from c_sources/num together with 
c_sources/num/include/pdt.h  
The usage:
   ./checkpdt file.pdt parton x q 
where parton has to be presented by PDG numerical code.  
It writes on the screen parton density  dN/dx and alpha(q)
==========================================================================
8. main_22.c - is an example of 'main' program that uses  CalcHEP 
c-code output. Suppose you have prepared codes for some 2-2 process.
Go to directory 'results' and call 
    ../bin/mkLibstat out 
Parameter 'out' means that all external functions will get suffix '_out'.
In particular all interface functions will be collected in one 
structure 'interface_out'. Now one can collect executable file by 
cc -o main22 main_22.c proclib_out.c sqme_aux.o -lm 
where sqme_aux.o is disposed in CalcHEP source directory. 
 
The created 'main_22' calculate differential and total cross sections. 
main_22.c contains instruction
code=&interface_out; 
It has to be improved if ../bin/mkLibstat was used with other parameter.
==========================================================================
9,10,11,12,13,14,15:  
sum_22.m sum_22.red sum_cd.m sum_cd.red sum_int.m sum_int.red sum_num.red -

Mathematica and Reduce programs to work with symbolic formulae for diagrams.
See manual.   
==========================================================================
16,17,18,19:  check.red cmp.red cycle_check cycle_cmp -
 Auxiliary programs which allow to check symbolic calculator of CalcHEP.
==========================================================================
sdecay.in
