How to use sampleana2

Global Infomation

The data analysis is normally done at ps.cc.kek.jp because all experimental data are stocked in ps.cc.kek.jp.

The data directory of the cosmic test during the CsI stacking is

/hpss/ps/klea/experiment/daqtest/csi_stacking

This is my setting in order to use e391 library at ps.cc.kek.jp.

#!
#! E391
#!
if ( ! $?E391_HOME )     setenv E391_HOME     /dfs/g/ps/klea/e391
if ( ! $?E391_LEVEL )    setenv E391_LEVEL    pro
source ${E391_HOME}/local/etc/cshrc_e391
setenv ROOTSYS     ${CERN}/root
setenv MN_FIT      ${CERN}/mn_fit
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${CERN}/${CERN_LEVEL}/lib/so:${CERN}/${CERN_LEVEL}/lib:${ROOTSYS}/lib


get sampleana2

Plese finish the preparation in order to use E391 library.

make work directory and set MY_TOP_DIR

li01i% mkdir -p /your_work/e391

li01i% setenv MY_TOP_DIR /your_work/e391 (for csh, tcsh)

li01i% source ${E391_HOME}/local/etc/cshrc_e391

li01i% cd $MY_TOP_DIR

li01i% make src

li01i% cd src

li01i% get_packages skeleton

li01i% get_packages sampleana2

li01i% ls -l

total 4.0K
-rw-r--r--    1 kensh    ps_klea       416 Aug 14 03:13 Makefile
-rw-rw-r--    1 kensh    ps_klea        11 Aug 14 03:13 PACKAGES
drwxrwxr-x    2 kensh    ps_klea       320 Aug 14 03:13 config
drwxr-xr-x    3 kensh    ps_klea       320 Aug 14 03:13 sampleana2
drwxr-xr-x    4 kensh    ps_klea       352 Aug 14 03:13 skeleton

Let's make sampleana2 for first check.

li01i% gmake

making ....

li01i% ls -l ../

total 5.0K
drwxrwxr-x    2 kensh    ps_klea       256 Aug 12 11:04 bin
drwxrwxr-x    2 kensh    ps_klea       256 Aug 12 11:04 include
drwxrwxr-x    3 kensh    ps_klea       288 Aug 12 11:04 lib
drwxrwxr-x    2 kensh    ps_klea       256 Aug 12 11:04 share
drwxrwxr-x    5 kensh    ps_klea       480 Aug 14 03:13 src

li01i% ls -l ../bin

total 18M
-rwxr-xr-x    1 kensh    ps_klea       17M Aug 14 04:33 myana


sampleana2

The sampleana2 package is a sample code to analyze the experimental data. This program read experimental data files (e.g. build00022.mid etc...) and call user routine, user_init(), user_begin_of_run(), user_process_event(), user_end_of_run() and user_term(). Each user routine is defined :

 user_init()                            --- called in the start point of the program
 user_begin_of_run( int runnum )        --- called in the begin of run
 user_process_event( int runnum, int spillrum, int eventnum )
                                        --- called in event by event
 user_end_of_run( int runnum )          --- called in the end of run
 user_term()                            --- called in the end point of the program
where "runnum" is the run number, "spillnum" is the spill number and "eventnum" is the event number. These user routine is written in the file, sampleana2/src/user_ana.cc . You can modify this file to your analysis. The main routine is written in the file , sampleana2/src/myana.cc, but it is not necessary to modify this file if there is no special reason.
modify user routines
  1. user_init()

    This routine called in the start point of the program. You can define HBOOK(ntuple and histgram) using the TupleManager which is one of the utility of the e391 library. For example, in order to define one ntuple (RWN) ...

      // Histogram definition
      ntEvent = otuple.ntupleR( 1,"Event Data",
                                "runno spill evtno trig "
                                "adc0 adc1 adc2 adc3 adc8 adc9 "
                                "tdc0 tdc1 tdc2 tdc3 tdc8 tdc9 "
                                );
    
    In this declaration, one ntuple where ID is 1, NAME is "Event Data" and CONTENTS are "runno spill evtno trig adc0 adc1 ... tdc0 tdc1 ... tdc9". This is a sample result made by this declaration.
     ********************************************************
     * NTUPLE ID=    1  ENTRIES=    939   Event Data  
     ********************************************************
     *  Var numb  *   Name    *    Lower     *    Upper     *
     ********************************************************
     *      1     * runno     * 0.670000E+02 * 0.670000E+02 *
     *      2     * spill     * 0.300000E+01 * 0.630000E+02 *
     *      3     * evtno     * 0.100000E+01 * 0.240000E+02 *
     *      4     * trig      * 0.200000E+01 * 0.500000E+01 *
     *      5     * adc0      * 0.247000E+03 * 0.289600E+04 *
     *      6     * adc1      * 0.236000E+03 * 0.666580E+05 *
     *      7     * adc2      * 0.253000E+03 * 0.665450E+05 *
     *      8     * adc3      * 0.199000E+03 * 0.670270E+05 *
     *      9     * adc8      * 0.374000E+03 * 0.990000E+03 *
     *     10     * adc9      * 0.350000E+03 * 0.665780E+05 *
     *     11     * tdc0      * -.100000E+01 * -.100000E+01 *
     *     12     * tdc1      * -.100000E+01 * -.100000E+01 *
     *     13     * tdc2      * -.100000E+01 * -.100000E+01 *
     *     14     * tdc3      * -.100000E+01 * -.100000E+01 *
     *     15     * tdc8      * -.100000E+01 * -.100000E+01 *
     *     16     * tdc9      * -.100000E+01 * -.100000E+01 *
     ********************************************************
    
  2. user_begin_of_run( int runnum )

    If you want to do something when a run begin, your code should be written here.

  3. user_process_event( int runnum, int spillnum, int eventnum )

    In the sampleana2, you can get the experimental data as a C++ class "e391det" which is type of class E391Detector. This class has many useful member functions which is described in the header file, ${E391_TOP_DIR}/src/util/E391Detector/E391Detector/E391Detector.h .

    For example, you can get the ADC value and TDC valueof the CsI #0 as like

      int adc = e391det.CsI(0).adc();
      int tdc = e391det.CsI(0).tdc();
    

    This routine called in event by event, so that you should write your analysis code for one event in here. For example, to fill data to ntuple.

          ntEvent->fill( "runno", run_number );
          ntEvent->fill( "spill", spill_number );
          ntEvent->fill( "evtno", event_number );
          ntEvent->fill( "trig",  trig );
          ntEvent->fill( "adc0",  e391det.CsI(0).adc() );
          ntEvent->fill( "adc1",  e391det.CsI(1).adc() );
          ntEvent->fill( "adc2",  e391det.CsI(2).adc() );
          ntEvent->fill( "adc3",  e391det.CsI(3).adc() );
          ntEvent->fill( "adc8",  e391det.CsI(8).adc() );
          ntEvent->fill( "adc9",  e391det.CsI(9).adc() );
          ntEvent->fill( "tdc0",  e391det.CsI(0).tdc() );
          ntEvent->fill( "tdc1",  e391det.CsI(1).tdc() );
          ntEvent->fill( "tdc2",  e391det.CsI(2).tdc() );
          ntEvent->fill( "tdc3",  e391det.CsI(3).tdc() );
          ntEvent->fill( "tdc8",  e391det.CsI(8).tdc() );
          ntEvent->fill( "tdc9",  e391det.CsI(9).tdc() );
          
          ntEvent->dump();
          ntEvent->clear();
    

  4. user_end_of_run( int runnum )

    If you want to do something when a run finish, your code should be written here.

  5. user_term()

    If you want to do something when program finish, your code should be written here.


K,Sakashita, Wed Aug 14 04:42:09 JST 2002