@ PREAMBLE
  This text will help you in installation of PamVMC simulator. This document will be
  updated after next release of tools.
  Installation was done on Debian machine, kernel 2.6.26-2-686,
  gcc version 3.4.6 (Debian 3.4.6-5)
  Everything was compiled under ROOT v. 5.23. PAMELA software (8th reduction) was corrected 
  to be compiled (see list of changes below). PAMELA libraries was compiled, but  executables, 
  like chewbacca still doesn't work (need to be corrected). Anyway, PamVMC needs only libraries
  for getting information about real magnetic field. To proceess data, I prefer now to have 
  also standard (second) PAMELA SW installaton under previous version of ROOT (5.20). @

  This is a list of tools to do simulation:
  CLHEP 2.0.4.2
  GEANT 4.9.2.p01
  ROOT v. 5.23.04
  VGM v.3.02
  PAMELA 8th reduction (should be corrected by yourself if any problems)

  In /scripts directory you will find examples of scripts that does an export of
  ALL enviroment variables for this installation. Please check them with yours.

1) @installed packages mesa-libGLU mesa-libGLU-devel gcc-g77 libXi libXi-devel@
2) @set gcc and g++ and f77 @
3) @install CLHEP 2.0.4.2@
   mkdir /cern
   cd /cern
   wget <source> 
   tar zxf clhep-2.0.4.2.tgz
   ln -s /cern/2.0.4.2 CLHEP
   cd CLHEP
   ./configure --prefix=/cern/CLHEP
   make
   make test
   make install
4) @install GEANT 4.9.2.p01@
   cd /cern
   mkdir G4
   cd G4
   mkdir data
   @copy all cross-section data files in /cern/G4/data and untar them@
   cd /cern
   @copy geant4 sorce tar file in /cern and untar@
   cd /cern/geant4.9.2.p01
   ./Configure -build
   @ Would you like to see the instructions? [n] @
   @ [Press [Enter] for default settings] @
   @ Do you expect to run these scripts and binaries on multiple machines? [n] @
   @ Where is Geant4 source installed?  [/cern/geant4.9.2.p01]  @		
   @ Specify the path where Geant4 libraries and source files should be installed. [/cern/G4] @
   @ Do you want to copy all Geant4 headers in one directory? [y] @
   @ Specify the path where are the Geant4 data libraries
    PhotonEvaporation2.0 RadioactiveDecay3.2 G4EMLOW6.2 G4NDL3.13 G4ABLA3.0 
    are installed. For now, a flat directory structure is assumed, and this can 
    be customized at the next step if needed. [/cern/G4/data] @
  @ Please, specify where CLHEP is installed. [/cern/CLHEP]  @ 
  @ You can customize paths and library name of you CLHEP installation:
    1) CLHEP_INCLUDE_DIR:		/cern/CLHEP/include	
    2) CLHEP_LIB_DIR:		/cern/CLHEP/lib
    3) CLHEP_LIB:			CLHEP
    To modify default settings, select number above (e.g. 2)
    [Press [Enter] for default settings] @
  @ By default 'static' (.a) libraries are built.
    Do you want to build 'shared' (.so) libraries? [y] @
  @ You selected to build 'shared' (.so) libraries. 
    Do you want to build 'static' (.a) libraries too? [n] @
  @ Do you want to build 'global' compound libraries? [n] @
  @ Do you want to compile libraries in DEBUG mode (-g)? [n] @
  @ G4UI_NONE
    If this variable is set, no UI sessions nor any UI libraries are built. 
    This can be useful when running a pure batch job or in a user framework 
    having its own UI system.
    Do you want to set this variable ? [n]  @
  @ G4UI_BUILD_XAW_SESSION
    G4UI_USE_XAW
    Specifies to include and use the XAW interfaces in the
    application to be built.
    The XAW (X11 Athena Widget set) extensions are required to activate 
    and build this driver. [n] @
  @ G4UI_BUILD_XM_SESSION
    G4UI_USE_XM
    Specifies to include and use the XM Motif based user interfaces.
    The XM Motif extensions are required to activate and build this
    driver. [n] @ 
  @ G4UI_BUILD_QT_SESSION
    G4UI_USE_QT
    Setting these variables will enable the building of the G4 Qt based 
    user interface module and the use of this module in your applications
    respectively.
    The Qt3 or Qt4 headers, libraries and moc application are required to enable
    the building of this module.
    Do you want to enable build and use of this module? [n] @ 
  @ G4VIS_NONE
    If this variable is set, no visualization drivers will be built or used.
    Do you want to set this variable ? [n] @ 
  @ G4VIS_BUILD_OPENGLX_DRIVER
    G4VIS_USE_OPENGLX
    It is an interface to the de facto standard 3D graphics library,
    OpenGL. It is well suited for real-time fast visualization
    and prototyping. The X11 version of the OpenGL libraries is required. [y] @ 
  @ G4VIS_BUILD_OPENGLXM_DRIVER
    G4VIS_USE_OPENGLXM
    It is an interface to the de facto standard 3D graphics library,
    OpenGL. It is well suited for real-time fast visualization
    and prototyping. The X11 version of the OpenGL libraries and 
    the Motif Xm extension is required. [n] @
  @ G4VIS_BUILD_DAWN_DRIVER
    G4VIS_USE_DAWN
    DAWN drivers are interfaces to the Fukui Renderer DAWN. DAWN is
    a vectorized 3D PostScript processor suited to prepare technical
    high quality outputs for presentation and/or documentation. [n] @
  @ G4VIS_BUILD_OIX_DRIVER
    G4VIS_USE_OIX
    The OpenInventor driver is based on OpenInventor technology 
    for scientific visualization.
    The X11 version of OpenInventor is required. [n] @ 
  @ G4VIS_BUILD_RAYTRACERX_DRIVER
    G4VIS_USE_RAYTRACERX
    Allows for interactive ray-tracing graphics through X11.
    The X11 package is required. [n] @
  @ G4VIS_BUILD_VRML_DRIVER
    G4VIS_USE_VRML
    These driver generate VRML files, which describe 3D scenes to be 
    visualized with a proper VRML viewer. [n] @ 
  @ OGLHOME/include
    OGLHOME/lib
    You have selected to use OpenGL driver.
    Specify the correct path (OGLHOME) where OpenGL is installed in your system.
    It was found in /usr. Press [Enter] to set this path or type the correct one.
    You can set '-' (without quotation) to CANCEL the OpenGL flag at all: [/usr] 
    "here you need to specify path to your OpenGL headers and libraries. 
     Please note, that you have to install development version of OpenGL to have headers" @
  @ G4UI_BUILD_OPENGLQT_DRIVER
    G4UI_USE_OPENGLQT
    Setting these variables will enable the building of the G4 OpenGL Qt based 
    visualisation driver and the use of this driver in your applications
    respectively.
    The Qt3 or Qt4 headers, libraries and moc application are required to enable
    the building of this module.
    Do you want to enable build and use of this module? [n] @ 
  @ G4LIB_BUILD_GDML
    Setting this variable will enable building of the GDML plugin module embedded
    in Geant4 for detector description persistency.
    It requires your system to have the XercesC library and headers installed.
    Do you want to set this variable? [n] @
  @ G4LIB_BUILD_G3TOG4  
    The utility module 'g3tog4' will be built by setting this
    variable. NOTE: it requires a valid FORTRAN compiler to be
    installed on your system and the 'cernlib' command in the
    path, in order to build the ancillary tools!
    Do you want to build 'g3tog4' ? [y] @ 
  @ G4LIB_BUILD_ZLIB  
    Do you want to activate compression for output files
    generated by the HepRep visualization driver? [y] @
  @ G4ANALYSIS_USE
    Activates the configuration setup for allowing plugins to
    analysis tools based on AIDA (Astract Interfaces for Data
    Analysis). In order to use AIDA features and compliant analysis
    tools, the proper environment for these tools will have to be
    set (see documentation for the specific analysis tools). [n] @
  @ end of configuration phase.
    Creating configuration setup file...
    WARNING: the generated configuration file
    can be edited if necessary!
    You can introduce any change to the configuration file
    /cern/geant4.9.2.p01/.config/bin/Linux-g++/config.sh before the final installation. 
    To do so, use a shell escape now (e.g. !vi /cern/geant4.9.2.p01/.config/bin/Linux-g++/config.sh).
    Press [Enter] to start installation or use a shell escape to edit config.sh: @

 @ Finally,@
    ./Configure - install
 @script to setup enviroment: /cern//geant4.9.2.p01/.config/bin/Linux-g++/env.sh @

6) @ install PYTHIA6 @
   @ get archive ftp://root.cern.ch/root/pythia6.tar.gz and put it in /cern @
   tar zxf pythia6.tar.gz
   cd pythia6
   makePythia6.linux
5) @ installation of ROOT v. 5.23.04 @
   @ put root_v5.23.04.source.tar.gz in /cern @
   cd /cern
   tar zxf root_v5.23.04.source.tar.gz
   mv root root_v5.23.04
   ln -s root_v5.23.04 ROOT
   cd ROOT/lib
   ln -s /cern/pythia6/libPythia6.so libPythia6.so
   cd /cern/ROOT
   source /cern//geant4.9.2.p01/.config/bin/Linux-g++/env.sh
   export ROOTSYS=/cern/ROOT
   ./configure linux --disable-afs --enable-cern --enable-mysql --disable-cintex 
                     --disable-globus --enable-roofit --enable-g4root 
                     --with-g4-incdir=$G4INCLUDE --with-g4-libdir=$G4LIB/Linux-g++ 
                     --with-clhep-incdir=$CLHEP_BASE_DIR/include 
                     --with-f77=g77 --enable-pythia6  --with-pythia6-libdir=/cern/pythia6
    make

6) @installation of VGM v.3.02@
   @Note: VGM is needed to convert ROOT-defined geomery in GEANT4. So, you need
    install VGM only if you plan to use in RunConfiguration of your application
    an option "geomRootToGeant4" - geometry defined in Root, but GEANT4 navigation.
    By default, in PamVMC option "geomRoot" was defined because GEANT4 has no
    option ONLY/MANY, so if I use "geomRootToGeant4" translation could be wrong (WARNING!).
    But if you wish to do some run-time visualization, like showers, you should use
    VGM libraries and option "geomRootToGeant4" in PamVMC Run configuration.@
  
    @ get archive from http://ivana.home.cern.ch/ivana/VGM.html and put in in /cern @
    cd /cern
    tar zxf v3-02.tar.gz
    ln -s /cern/v3-02 /cern/VGM
    emacs -nw VGM/config/geant4.gmk
    @ correct line 23: CPPFLAGS += -I$(G4INCLUDE) on some machines @
    cd /VGM/packages
    make
    @ after you should fin in /cern/VGM/lib/Linux-g++ libaries: 
     libBaseVGM.so  libClhepVGM.so  libGeant4GM.so  libRootGM.so  libXmlVGM.so @

7) Installation of PAMELA software

   @ create a symbolic link to cint includes: (needed for Darth Vader with ROOT 5.23)
     for ROOT 5.20 you don't need to do it@
     cd /cern/ROOT/include
     ln -s ../cint/cint/inc/ cint
   

8) Installation of geant4_vmc

  @  get source ftp://root.cern.ch/root/vmc/geant4_vmc.2.6.tar.gz and put in /cern @
     cd /cern
     tar zxf geant4_vmc.2.6.tar.gz
     ln -s /cern/geant4_vmc_2.6 /cern/geant4_vmc
     cd /geant4_vmc/source
     make

9) Installation of PamVMC

  @Before you start, do an export of PAM_VMC env.  variable to source directory
  In case if you wish to use PamVMC with GEANT4 you should go to $(PAM_VMC)/PamG4RunConfiguration @
  make clean
  make
  @ this will produce a libPamG4RunConfiguration.so library in $(PAM_VMC)/lib/tgt_$(PLATFORM) @
  cd $(PAM_VMC)
  make
  @ after this step an application library $(PAM_VMC)/lib/tgt_$(PLATFORM)/libPamVMC_fc.so will be compiled
    and some calibration files will be copied from $(PAM_VMC)/aux@

  @ in $(PAM_VMC)/examples you can find an example of usage @
  @ For more details please look inside $(PAM_VMC)/include PamVMCPrimaryGenerator.h and PamVMCDetectorHit.h @

/////////////SPGECTRA GENERATOR/////////////////
@ spectra_generator is a tool which allow you to generate tracks above the apparatus 
  isotropically and save initial kinematic parameters (X0,Y0,Z0=110., P, Theta, Phi) 
  "good" tracks in output root-file. After this, file could be used to do simulations.
  The condition to accept tracks is satisfaction to 14 acceptance planes, defined by
  TrkParams in Level2. This tool is based on DoTrack method of Level2.
  To save data in root-file PrimaryInfo class was developed and compiled in library. 
  If later you wish to develop your own script to work with data stored threre, 
  you need just load libPrimaryInfo.so shared library @

1) @ To compile library you need change your .rootlogon.C file. One example is provided
     in directory /aux/spectra_generator. Please check your enviroment variables. All pathes
     in this file completetly dependent on your enviroment @
2) cd /aux/spectra_generator
    make clean
    make
@ After this you should find a library: libPrimaryInfo.so,  and executable: sp_gen @

@+++SPECTRA GENERATOR HOWTO +++@
@ There are 3 different regimes in which sp_gen could work, and application recognize in 
 which way you wish it work by number and type of parameters which you specify to launch it:

  1) Fixed rigidity mode: Shooting isotropically with fixed rigitity tracks
     PARAMETERS: 
            (INTEGER) Number of "good" track that you wish to have finally
            (INTEGER) Charge of particle in (e+ units)
            (INTEGER) PDG of particle, see NOTE below
            (DOUBLE)  Fiducial value (cm) that you wish to cut each side from all of
                      14 acceptance planes. (0. -  nominal acceptance)
            (DOUBLE)  Rigidity (GV) of tracks.
            (STRING)  Name of output file (ex. out.root) where you wish to store your
                      "good" tracks.

       exampale: ./sp_gen 10000 1 2212 0.15 2.0 out.root
       Generates 10000 monoenergetic protons with rigidity 2 GV in fiducial acceptance
       cutting 0.15 cm on each side. Result will be put into out.root file.

    2) Flat spectra mode: Shooting isotropically with uniform distributed [Rmin, Rmax] 
       rigitity tracks
       PARAMETERS: 
            (INTEGER) Number of "good" track that you wish to have finally
            (INTEGER) Charge of particle in (e+ units)
            (INTEGER) PDG of particle, see NOTE below
            (DOUBLE)  Fiducial value (cm) that you wish to cut each side from all of
                      14 acceptance planes. (0. -  nominal acceptance)
            (DOUBLE)  Minimal Rigidity (GV) of tracks.
            (DOUBLE)  Maximal Rigidity (GV) of tracks.
            (STRING)  Name of output file (ex. out.root) where you wish to store your
                      "good" tracks.

       example: /sp_gen 10000 1 2212 0.15 2.0  3.0 out.root
       Generates 10000 protons with flat spectra and with rigidity 2-3
       GV in fiducial acceptance cutting 0.15 cm on each side. Result will be put into out.root file

  3)   Full spectra mode: Shooting isotropically with all spectra which differrential
       profile defined in input file.
       PARAMETERS: 
            (INTEGER) Number of "good" track that you wish to have finally
            (INTEGER) Charge of particle in (e+ units)
            (INTEGER) PDG of particle, see NOTE below
            (DOUBLE)  Fiducial value (cm) that you wish to cut each side from all of
                      14 acceptance planes. (0. -  nominal acceptance)
            (STRING)  Name of INPUT file (ex. input.root) where you stored your
                      TGraphAsymmErrors object with diffrerntial spectra profile.
                      Please note, that application suppose that name of graph is
                      "gflux". Of course, you can define your own. See sp_gen.C, line 170. 
            (STRING)  Name of output file (ex. out.root) where you wish to store your
                      "good" tracks.

       example: /sp_gen 10000 1 2212 0.15 input_flux.root out.root
       Generates 10000 protons with rigidity distributed accroding TGrapAsymmErorrs 
       in input_flux.root in fiducial acceptance cutting 0.15 cm on each side. 
       Result will be putt into out.root file

  !!!NOTE:    Use http://pdg.lbl.gov/2007/reviews/montecarlorpp.pdf document to define your
              particle according PDG numeration scheme.
