- HOW-TO-DIGIT, or "how to learn the PAMELA Digitizer in 5 minutes"
- Creation:          October 2007
- main contribution: S. Bottai
- author:            S. Orsi

1) Install a database dedicated to simulation (if not already installed) :
Set the PAMELA enviroment variable. Then set variable for the dedicated
database :
unset PAM_DBHOST
unset PAM_DBUSER
unset PAM_DBPSW

export PAM_DBHOST=mysql://nameofmachine/namedatabase
(example : PAM_DBHOST=mysql://srv-g2-01.ts.infn.it/pameladigit)
export PAM_DBUSER=root
export PAM_DBPSW=pameladb

2) Create the database for simulation with the script install_GPAMELADB.sh, which is in Profiler 
directory under docs (you must run it in the dierectory itself or copy in the directory where the sql 
files are present ). The script will create the database and fill it with the approprate reference to 
the calibrations files for the simulation.
(This is possible only for CVS version after 9/10/2007 , when the calibration files and their link have 
been put on the repository.)

3) Fill the GL_TLE table with "YodaProfiler -tle tle.txt" where the tle.txt file can be found in the 
Profiler directory under docs

4) Run the digitizer :

./Pamelagp2Digits namegpamelafile.his

It creates the files :
namegpamelafile.pam (input for Yoda)
namegpamelafile.gp.root (root conversion of namegpamelafile.his)

5) Run yoda :
yoda namegpamelafile.pam

this will produce the file namegpamelafile.root

6) Run the Profiler with the option -gpamela
YodaProfiler -gpamela -yodaFile namegpamelafile.root
It determines automatically the timesync and boot number and fills the database

7) You can check the entry in the database with the
R2-D2 -filename nomegpamelafile.root
which tells you the idRun automatically associated

8) Run DarthVader. 
Some examples of usage:

DarthVader -zerofill -idRun 1 -ALL +RUN +CAL [ --no-crosstalk ] +TRK +TOF +AC +TRG +ND
DarthVader -zerofill -idRun 1 +CAL [ --no-crosstalk ] -S4

The previous 2 commands have the same output, i.e. all detectors are included except S4 (the default 
behaviour includes the option "+ALL").
If the TRK is not present the option --no-tracker must be specified:
c) DarthVader -zerofill -idRun 1 -ALL +RUN +CAL [ --no-crosstalk --no-tracker] +AC

It is recommended to run DarthVader specifying as output the file namegpamelafile.gp.root (file created 
by the digitizer, containing the gpamela data in root [see above]).
The option "--no-crosstalk" (and "--no-tracker") can be omitted in this case

DarthVader -zerofill -idRun 1 -ALL +RUN +CAL +TRK ... -processFile namegpamelafile.gp.root

In this way all gpamela info and Level2 info are contained in the same file (namegpamelafile.gp.root). 

With the latest DarthVader you can also include S4 and ORB without errors (but S4 data will be empty 
until fully implemented in the Digitizer code). 

9) Default parameters for simulation are included in DarthVader since 9/10/2007.
In case is not possible to use the CVS version after 9/10/2007 you must force DarthVader to use 
alignment and eta parameters needed by the tracker.
This is also possible if for some reason you want to test other sets of parameters.
To do this simply write :

DarthVader -zerofill -idRun 1 -ALL +RUN +TRK [ -4 /path-to-eta-parameter-for-simulation/ -5 /path-to-] 
...

To load different parameter types you have to use different numbers, according to the same notation of 
the DB:

1 field map
2 adc-to-mip
3 charge correlation
4 position-finding
5 alignment
6 VA1 mask

The default parameters for the simulation are now in the CVS repository under the directory:

DarthVader/param/trk-param/align_param_GP-0/
DarthVader/param/trk-param/eta_param_GP-0/ 


	********* NB: **********
On the machines pamelatov in Roma2 the flags "-lmathlib -lpacklib -lkernlib" must be present in the 
Make file:
LDFLAGS = -g -lmathlib -lpacklib -lkernlib -llapack -lg2c -lm -lnsl -lcrypt -L/cern/2005/lib
On other machines (for example pamelaws02 in Naples) the digitizer does not compile if the same flags 
are speficied, so they should be removed.
