Introduction to Ntuple Analysis for Beginners

A package introducing the analysis of the E949/E787 PASSX ntuples by PAW is available from

bnlku9:/e787d/e949/koma/nt_ana/template/ .
Take a look at the README file (also available from here).

Please remind, I do NOT pretend to presenting you the best-and-brightest analysis package (in particular the kumac files); you can develop your own smart scheme with your PAW experience. This is nothing but an introductory one ( but did really work in my E787 K+ -> pi+ gamma analysis ) and would be helpful for beginners to understand the basic structure of the ntuple-based analysis. I expect an official ntuple-analysis package, with more user-friendly functions, will be available soon.

Takeshi K. Komatsubara, KEK-IPNS, on 2002-June-04(Tue) 

The package at bnlku9:/e787d/e949/koma/nt_ana/template/ was updated.
Some examples of how to use the profile and 2d-scatter plots to check the runNo.-dependence of the Rejection of a cut or the fitted mean of a peak, using kumac files "inv_his.kumac" and "prj.kumac", are given.

Takeshi K. Komatsubara, KEK-IPNS, on 2002-July-23(Tue) 

1. How to chain a group of ntuples

         Very often we have to chain more than 100 ntuples together. There is a .kumac script to
help to make it easy (available from  here). You can run paw in your terminal

 Example 1: for chaining all the ntuples in the path
    PAW>exec chain_nt /data8/e787/pass2/km21_02 0 km21
 Example 2: for chaining some ntuples in the path
    PAW>exec chain_nt /data8/e787/pass2/km21_02 pass2_km21_541*  km21

11 jul 02 original from
fixed and modified by d.jaffe

2. Where are our pass2 ntuples

     During E949 data taking period, an online pass2 analysis job was automatically run thru our new data
with all the available calibration files at that time. The created pass2 ntuples were then scp to TRIUMF
linux disk. If anyone has an account in TRIUMF machine, (s)he should be able to get these pass2 ntuples
from /kdecay/data10/e949/pass2/ directory. Below are the list of sub directories for various monitor samples.
For people in BNL, they can also run their script there provided bnlku7 and bnlku9 are still in good shape.


/kdecay/data10/e949/pass2/km21_02                :   pass2 ntuples for 2002 km21 monitors
/kdecay/data10/e949/pass2/km21_02_eos        :   scaler record ntuples for 2002 km21 monitors
/kdecay/data10/e949/pass2/kbeam_02              :   pass2 ntuple for 2002 k-beam data
/kdecay/data10/e949/pass2/kp21_02                 :    pass2 ntuples for 2002 kp21 monitors
/kdecay/data10/e949/pass2/kp21_02_eos         :   scaler record ntuples for 2002 kp21 monitors
/kdecay/data10/e949/pass2/piscat_02               :   pass2 ntuple ntuples for 2002 piscat monitors
/kdecay/data10/e949/pass2/piscat_02_eos       :   scaler record ntuples for 2002 piscat monitors
/kdecay/data10/e949/pass2/pnn1or2_02          :   pass2 ntuples for 2002 pnn1or2 triggers
/kdecay/data10/e949/pass2/pnn1or2_02_eos  :   scaler record ntuples for 2002 pnn1or2 trigger

2) In BNL:


Known problems in these ntuples:
a) Proper Range Stack energy calibration files might not be included when data were processed
b) Few percent data were processed with wrong RSSC calibration files
c) Long path name  in BNL may give a strange result, to get around the problem, you have to either
     run your script in that directory or use a link to shorten the path name.

3. How to access to the ntuple (assuming the ntuples have already been chained)

0) Variable names and their meanings in the pass2 ntuple

     a)  UTC information
     b)  RSSC information
     c)  Target information
     d)  I-counter information
     e)  Range stack information
     f)  Beam counter information
     g)  TD information
     h)  Photon veto information
     i)  Kinematics measurable information

1) Direct access, for example the momentum distribution

     PAW>n/pl 1.ptot
     PAW>n/cut $1 abs(cos3d).lt.0.5.and.(tpi-tk).gt.2
     PAW>h/cr/1d 1000 ' Momentum (MeV/c)' 30 220 250
     PAW>n/proj 1000 1.ptot $1
     PAW>h/pl 1000
2) Indirect access the ntuple thru a fortran routine with a common block file

     a) Create a common block file called "" (or whatever you like to call)
           Step 1: Download the following codes ( huwfun.fhwdecl.fhwpdcl.f  and  uwfunc.f)to your area
           Step 2: Create an executable using
                          f77 -mips2 -L$CERNLIB -o uwfunc uwfunc.f huwfun.f hwpdcl.f hwdecl.f -lmathlib -lpacklib
           Step 3: Create the common block file by means of
                               Enter ntuple file name: /data8/e787/pass2/km21_02/pass2_km21_001.nt.001
                               Enter ntuple # [ 1]:1
                               Enter generated file name [uwfunc]: pass2nt
                          There will be two files 'pass2nt.B' and 'pass2nt.P' created in your area, change the name of
                          pass2nt.P to with 'mv  pass2nt.P'.
     b) Create a fortran routine (available from  here)

     PAW>h/cr/1d 1000 ' Momentum(MeV/c)' 30 220 250
     PAW>n/loop 1 fill_ptot.f
     PAW>h/pl 1000

     c) More complicated one (for example the analysis of foil efficiencies, download  foil_eff.kumac  and  foil_eff.f)

     PAW>exec foil_eff

4) How to create a pass2 ntuple

a)  setenv CVS_RSH ssh
b)  setenv CVSROOT e949@sitka:/e949/CVS
c)  cvs checkout pass2src  (This will create a ~/pass2src working directory and dump all the pass2
      source codes into this directory)
d) cd pass2src
e)  modify the code(s) 
f)  Make_pass2 2001  (makes pass2.exe using CERLIB v2001 in non-debug mode)
     Make_pass2 2001 debug (makes pass2.exe using CERLIB v2001 in debug mode)
g) create a working directory (for example mkdir ~/pass2run )
h) copy the run script and kcm file from $PASS2_RUN
      setup e949 ; setup pass2 01
      cp $PASS2_RUN/pass2_anal_simple.csh
      cp $PASS2_RUN/pass2_anal_pion.kcm
      cp $PASS2_RUN/pass2_anal_muon.kcm
i) edit pass2_anal_simple.csh
     choose jobname via "setenv JOBNAME" command
     choose ntuple directory via "setenv NTDIR" command
     choose either standard or custom pass2 executable "setenv ANAL_EXE  ~/pass2src/pass2.exe" statement
     choose the input raw file name  MTIN '/data9/e949/data02/km21/km21_ps1.50215'
j) run pass2 job "pass2_anal_simple.csh"

5) How have an event display from a pass2 ntuple (it will go thru CVS soon)

To make an event display, we can use kofia photo. However, we can also use a so-called
'photo' paw .kumac to have an event display.

a) Download a   photo.tar.gz   file to your area and gunzip it.
b) Use 'tar xvf photo.tar' to extract all the files.
c) Run paw in that area and
     PAW>h/fil 1 km21_50215.001 0
     PAW>exec photo#init
     PAW>exec photo#read 1            (x-y view)
     PAW>exec photo#plotz              (r-z view)

For more description, check README in that area.

If you still have some questions, feel free to dial 1-800-nobody or e-mail to