Last update: V. Formato

@ 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 a SL5 machine, kernel 2.6.18-348.18.1.el5,
  gcc version 4.7.0 
  Everything was compiled under ROOT v. 5.34. PAMELA software (9th reduction) was corrected 
  to be compiled (see list of changes below). PAMELA libraries were compiled, but  executables, 
  like chewbacca still doesn't work (need to be corrected). Anyway, PamVMC needs only the libraries
  to get information about the magnetic field. To proceess data, you should have 
  a standard PAMELA SW installaton under previous version of ROOT (5.26). @

  This is a list of tools for the installation:
  GEANT 4.9.6.p01
  ROOT v. 5.34
  VGM v.3.06
  xerces-c-3.1.1
  PAMELA 9th reduction software (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) @install GEANT 4.9.6.p01@  (also includes CHLEP)
   mkdir cern
   cd /cern
   tar -xvf geant4.9.6.p01.tar.gz
   mkdir geant4.9.6.p01-build
   mkdir geant4.9.6.p01-install
   ln -s geant4.9.6.p01-install G4
   cd geant4.9.6.p01-build
   export CFLAGS=-m32
   export CXXFLAGS=-m32
   cmake -DCMAKE_INSTALL_PREFIX=$PWD/../geant4.9.6.p01-install/ -DGEANT4_INSTALL_DATA=ON ../geant4.9.6.p01
   ccmake ../geant4.9.6.p01           
         @@@ Enable the following flags:
             - GEANT4_USE_G3TOG4
             - GEANT4_USE_GDML
             - GEANT4_USE_OPENGL_X11
             - GEANT4_USE_SYSTEM_EXPAT
   make -j4
   make install
   cd geant4.9.6.p01-install
   ln -s bin/geant4.sh env.sh
   cd ..
1a)@source the geant4 environmental variables!
   source G4/env.sh

2) @ installation of ROOT v. 5.34 @
   @ put root_v5.34.04.source.tar.gz in /cern @
   cd /cern
   tar -zxvf root_v5.34.04.source.tar.gz
   mv root root_v5.34
   ln -s root_v5.34 root
   source G4/env.sh
   export ROOTSYS=$PWD/root
   ./configure linux --all --enable-builtin-pcre --disable-castor
    make

3) @installation of xerces v.3.1.1@
   tar -xvf xerces-c-3.1.1.tar.gz
   ./configure --build=i686 --prefix $PWD
   make
   make install

4) @installation of VGM v.3.06@
   @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-06.tar.gz
    mkdir vgm.3.06-build
    mkdir vgm.3.06-install
    ln -s vgm.3.06-install VGM
    emacs -nw VGM/config/geant4.gmk
    @ correct line 23: CPPFLAGS += -I$(G4INCLUDE) on some machines @
    cd VGM
    ./autoconf/configure --with-clhep-include=$PWD/../geant4.9.6.p01-install/include/Geant4/ --with-clhep-libdir=$PWD/../geant4.9.6.p01-install/lib/ --with-geant4=/$PWD/../geant4.9.6.p01-install/ --with-xerces=$PWD/../xerces-c-3.1.1/ --with-root=$PWD/../root/
    make

5) Installation of PAMELA software

   @ Follow the standard instructions for the installation of PAMELA software and source the enviroment @
   

6) Installation of geant4_vmc

  @get source ftp://root.cern.ch/root/vmc/geant4_vmc.2.14a.tar.gz and put in /cern @
   cd /cern
   tar -zxvf geant4_vmc.2.14a.tar.gz
   cd geant4_vmc
   @edit `root-config --etcdir`/vmc/Makefile.linux and add the -m32 flag to the OPT variable and empty the variable SHLIB@
   make

7) Installation of PamVMC

  @Before you start, do an export of PAM_VMC env.  variable to the 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@
  @ do an export
  export LD_LIBRARY_PATH=$(PAM_VMC)/lib/tgt_$(PLATFORM):$(LD_LIBRARY_PATH)

  @ 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 @


@From here on old instructions:

/////////////EXTERNAL DIGITIZER/////////////////
In aux/PamVMVDigitizer you can find a source code of stand-alone digitizer. Just do make. 
There are only 3 parameters: input root-file name, output raw-filename and integer random seed.
If you specify 0, then TRandom3(0) object will be created. All digitizers use this object.
Please note, that current version of digidaizer could be not compatible with root-files generated
with previous versions of PamVMC due to addtitonal variables in PamVMCDetectorHit class


/////////////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.
