
1) The ToF software uses the Tracking software V2.00
It is assumed that you have created all the directories and the compiling
of the three executables "level0.exe", "level1.exe" and "level2.exe"
was succesful.

2) Copy the file toftrack.tar to the "utilities/template" directory (where
the program template.f is located), untar the file toftrack.tar.

The following files will be extracted:
Makefile (the old Makefile will be overwritten)
run-test.sh       
tofcalib.rz   
toftrack.f
common_tof.f       
tofroutine.f  
trk_level2.f (the old trk_level2.f was not correct)
common_tofroutine.f 

3)Create the executable toftrack.exe doing
# make toftrack  

4) The "level*.exe" programs in your working directory were run by doing

#./run-test.sh some_filename.txt level0/1/2 &

Copy the new "run-test.sh" from the template directory to the working 
directory. Copy toftrack.exe to the working directory
After you have done step 5 (see below) you can run the toftrack software 
analogue to the command for the level0/1/2 software:

#./run-test.sh some_filename.txt toftrack &

In the file good_files.tar.gz there is a list of good files from the Roma 
tests.

5) Untar the file tofcalib.tar in your rz-data directory (where the level2 
and tof rz-files are located). This will create a standard "tofcalib.rz" 
file plus the calibration files for the Roma data 
"DW_******_***_tofcalib.rz"


---------------------------------------------------------------------------

"tracktof" will read the appropriate level2, tof, and tofcalib file. If 
there is no tofcalib file for this data run, the standard calibration is 
used (There will be a message saying "Could not find.... Will use the 
standard calibration")


"tracktof" will create a new rz file DW_******_**_toftrack.rz" combining 
the level2 data, the (raw) tof data, plus the variables calculated in the 
tofroutine. 

The structure looks like this:


 ******************************************************************
 * Ntuple ID = 2      Entries = 1185      TOF
 ******************************************************************
 * Var numb * Type * Packing *    Range     *  Block   *  Name    *
 ******************************************************************
 *      1   * L*4  *    1    *              * EVENT    * GOOD
 *      2   * I*4  *         *              * EVENT    * NEV_TRK
 *      1   * I*4  *         *              * CPU      * PKT_TYPE
 *      2   * I*4  *         *              * CPU      * PKT_NUM
 *      3   * I*4  *         *              * CPU      * OBT
 *      4   * I*4  *         *              * CPU      * WHICH_CALIB
 *      1   * I*4  *         *              * TOF      * TDCID(12)
 *      2   * I*4  *         *              * TOF      * EVCOUNT(12)
 *      3   * I*4  *         *              * TOF      * TDCMASK(12)
 *      4   * I*4  *         *              * TOF      * ADC(4,12)
 *      5   * I*4  *         *              * TOF      * TDC(4,12)
 *      6   * I*4  *         *              * TOF      * TEMP1(12)
 *      7   * I*4  *         *              * TOF      * TEMP2(12)
 *      8   * R*4  *         *              * TOF      * BETA(5)
 *      9   * R*4  *         *              * TOF      * XTOF(3)
 *     10   * R*4  *         *              * TOF      * YTOF(3)
 *     11   * R*4  *         *              * TOF      * ADC_C(4,12)
 *     12   * I*4  *         *              * TOF      * IFLAG(6)
 *     13   * I*4  *         *              * TOF      * JFLAG(6)
 *     14   * R*4  *         *              * TOF      * XOUT(3)
 *     15   * R*4  *         *              * TOF      * YOUT(3)
 *      1   * I*4  *         *              * TRIGGER  * TRIG_EVCOUNT
 *      2   * I*4  *         *              * TRIGGER  * PMTPL(3)
 *      3   * I*4  *         *              * TRIGGER  * TRIGRATE(6)
 *      4   * I*4  *         *              * TRIGGER  * DLTIME(2)
 *      5   * I*4  *         *              * TRIGGER  * S4CALCOUNT(2)
 *      6   * I*4  *         *              * TRIGGER  * PMTCOUNT1(24)
 *      7   * I*4  *         *              * TRIGGER  * PMTCOUNT2(24)
 *      8   * I*4  *         *              * TRIGGER  * PATTERNBUSY(3)
 *      9   * I*4  *         *              * TRIGGER  * PATTERNTRIG(6)
 *     10   * I*4  *         *              * TRIGGER  * TRIGCONF
 *      1   * I*4  *         * [0,50]       * TRACKS   * NTRK
 *      2   * U*4  *    6    * [0,50]       * TRACKS   * IMAGE(NTRK)
 *      3   * R*4  *         *              * TRACKS   * XM(6,NTRK)
 *      4   * R*4  *         *              * TRACKS   * YM(6,NTRK)
 *      5   * R*4  *         *              * TRACKS   * ZM(6,NTRK)
 *      6   * R*4  *         *              * TRACKS   * RESX(6,NTRK)
 *      7   * R*4  *         *              * TRACKS   * RESY(6,NTRK)
 *      8   * R*4  *         *              * TRACKS   * AL(5,NTRK)
 *      9   * R*4  *         *              * TRACKS   * COVAL(5,5,NTRK)
 *     10   * R*4  *         *              * TRACKS   * CHI2(NTRK)
 *     11   * U*4  *    1    * [0,1]        * TRACKS   * XGOOD(6,NTRK)
 *     12   * U*4  *    1    * [0,1]        * TRACKS   * YGOOD(6,NTRK)
 *     13   * R*4  *         *              * TRACKS   * XV(6,NTRK)
 *     14   * R*4  *         *              * TRACKS   * YV(6,NTRK)
 *     15   * R*4  *         *              * TRACKS   * ZV(6,NTRK)
 *     16   * R*4  *         *              * TRACKS   * AXV(6,NTRK)
 *     17   * R*4  *         *              * TRACKS   * AYV(6,NTRK)
 *     18   * R*4  *         *              * TRACKS   * DEDXP(6,NTRK)
 *      1   * I*4  *         *              * SINGLETS * NCLSX(6)
 *      2   * I*4  *         *              * SINGLETS * NCLSY(6)
 ******************************************************************
 *  Block   *  Entries  * Unpacked * Packed *   Packing Factor    *
 ******************************************************************
 * EVENT    *  1185     * 8        * 5      *       1.600         *
 * CPU      *  1185     * 16       * 16     *       1.000         *
 * TOF      *  1185     * 932      * 932    *       1.000         *
 * TRIGGER  *  1185     * 288      * 288    *       1.000         *
 * TRACKS   *  1185     * 22004    * Var.   *    Variable         *
 * SINGLETS *  1185     * 48       * 48     *       1.000         *
 * Total    *    ---    * 23296    * Var.   *    Variable         *
 ******************************************************************
 * Blocks = 6            Variables = 51      Max. Columns = 5824  *
 ******************************************************************



The variables calculated in "TOFROUTINE" are the last ones in the block 
"TOF":


BETA(5):	four values (1-4) for beta from S11-S31, S12-S32, S21-S31 
		and S22-S32.
		if there is no valid signal beta is set to "100".
        	if there are four values for beta, the weighted mean is 
		calculated and put into beta(5). So it is possible for 
		the user to calculate his own mean value by using the 
		single values.

XTOF(3):	The x-position in the 3 different layers using the ToF 
		timing (So, for the x-coordinate we use S12, S21,S32).
 		If we cannot find a valid timing the value is set to "1000"

YTOF(3):  	The same for y-position using S11, S22,S31

ADC_C(4,12):	normalized ADC values, the value in the middle of the 
		paddle is set to "1", using the (sometimes poor) attenuation 
		fit curves. The ADC_C matrix is analog to the ADC matrix 
		for the raw data, so one can use the same channel map.

IFLAG(6):	6 values for the six layers: 	
		"0" if no hit in this layer 
		"-1" if more than one hit
		otherwise the number of the hitted paddle ("hit" = good 
		TDC values on both sides)

JFLAG(6): 	6 values for the six layers: coded value to see which 
		strips have valid hits:
		for i=1 to (number of strips) do
		if (paddle "i" = hit) then jflag = jflag + 2**(i-1)




