Paw


Jeff Wilkes' Paw Tutorial.
Paw Manual

Paw Basics
to run a paw kumac in the UNIX background: paw -b background.kumac
abbreviations: PAW completes commands fragments for you when possible, e.g.:
nt/pl = ntuple/plot
h/fil = histogram/file
It's useful to know what an abbreviation stands for in case you need to look it up on the PAW website.
To read a vector from file: vec/read x,y,z... file.dat
To set the value of a vector inside a kumac: vec/cre x(4) r -3 3 2
To read the contents of a vector you've already defined: vec/write x
To plot a vector you've defined: vec/pl x
To override the nt/plot (or vec/plot) automatic window size:
graph/hplot/null 0 1 0 1 *empty canvas on x:(0,1) and y:(0,1)
set dmod 1 *normal line style
nt/plot 1.am%at am<1 ! ! ! S *superimpose ntuple plot
The exclamation marks mean "use the default value for the 2nd, 3rd, and 4th arguments of ntuple/plot."
vec/pl res%zen ! S *superimpose vector plot
To plot two vectors with error bars: hplot/aerrors x y xerr xerr yerr yerr 100 ! ! 1W
to add a line to your plot: line 0 0 1 1 from (0,0) to (1,1)
To fill a histo with a vector: vec/hfill x 50
To make an ntuple out of vectors:
nt/cre 100 'Eric Ntuple' 5(varbs) ! ! evtnumb theta conenumb KSnumb KSProb
nt/read 100 cone.dat
To divide the screen into several plots: zone 2 2
Save canvas as a postscript: type "opt zfl1", replot it, then "picture/print filename.ps"
To compare MC (bars) with data (points with error bars): an example example.kumac.
Draw error bars without symbols clipping: use the "E0" option instead of just "E".

Cosmetics:
To change the size of a marker: set ksiz .25
Graphics Definitions
A visual description
PAW Font Information (e.g., how to use Greek letters, subscript, superscript, etc.)
For publication quality plots: modify your .pawlogon.kumac
For publication quality plots with zone 2 2: zone22.kumac
To add a global title: title 'title'
To get rid of the global title:
opt utit
title '' U
to relabel the x,y axes: graph/hplot/atit '[a]?t!' '[a]?m!'
To create a symbol key:
set mscf 2
set mtyp 20
h/pl 50
set mtyp 21
h/pl 51 s
KEY -70 5.5 20 'SK1'  *the first number is the placement according to x-axis
KEY -70 6.0 21 'SK2'  *the second number is placement according to the y-axis
to create a line key:
KEY 17 .35 2 'dec=-90, ra=164' ! L *2 is a dashed line
KEY 17 .40 1 'dec=54, ra=292' ! L *1 is a solid line

To write in greek characters: enclose letters in brackets (e.g., alpha=[a])
To write a degree symbol: [\260]
To write special characters like ">" use 'special symbols' mode: "G# (see font information)

Histograms
Create a histogram: 1d (then follow the prompts)
or type: histo/create/1dhisto ID# 'Title' NBins LowerBound UpperBound
Note: Paw rounds off data to seven significant digits. If you create bins that require precision greater than seven significant digits, this may cause errors.
Fill the histogram with a vector: vector/hfill x 50 (where 50 is the histogram ID in this case)
Plot your histogram: histo/plot 50
Include Stats: opt stat
turn off stats: opt nstat
turn on or off some stats: set stat 0111110 (my personal choice)
Make an axis log/lin: opt logx, opt liny
Shaded (or filled) histograms: set htyp 1
To set the value of each histogram bin with a vector: h/put_vect/contents 50 y
This is useful when you have already reduced your data or you are dealing with a theoretical prediction!
To dump the the value of each histogram bin:
1d 70 'histogram' 80 0 22.2
vec/cre x(80) (where 80 is the number of histogram bins)
h/get/contents 70 x
vec/write x x.histo (to write a vector to a file)
To subtract two histograms: hist/op/diff 50 60 70 ! ! E
(puts H50-H60 into H70)
By including the "E", PAW will automatically propagate the errors."
(You can also add, multiply and divide.)
To normalize a histogram (without changing its contents): norm 50 1
To assign your own error bars to a histogram: h/put_vect/errors 50 vec
To KS test two histograms: hi/op/diff 50 60
To set the range of a histogram:
min 50 0
max 50 8
Sets the range of ID=50 to (0,8)

2D Histograms
to create: 2d id title NBinsX xmin xmax NBinsY ymin ymax
to fill: vec/hfill y%x 50
to plot lego style: lego 50
to view from another angle: lego 50 40 250 (theta=40deg, phi=250deg)
to see how many hits are in a bin: hi/dump 50 To set the value of each histogram bin with a vector: h/put/cont 50 v
If 50 is a histogram with 5 bins in x and 4 bins in y, then v will have to be 20 elements long.   When writing out v, you fill the first row of y, then the second, followed by the third and forth.   E.g.: if v=
0 1 2 3 4
4 3 2 1 0
-1 -2 -3 -4 -5
-6 -7 -8 -9 -10

then your histogram will look like this--(read the plot up and to the right):

To make this pretty colored plot (e.g., a celestial map): h/pl 50 colz
to make a sky map: use something like this.

NTuples
To list ntuples: nt/list
To navigate (change directories) within ntuples: cdir //upmu32R
To print the contents of an ntuple: nt/print 1
To plot an ntuple varb: nt/pl 1.fit_dir(3)
To fill a histogram with ntuple data: nt/project 100 1.fit_dir(3)
To define a cut: nt/cuts $1 fit_dir(3)>0
Fill a histo with cuts: nt/proj 100 1.evis $1.and.$2
To dump the contents of an ntuple: nt/dump 1.nrun%nev ! ! ! ntdump.dat ! ' '
To dump the contents of an ntuple with a cut: nt/dump 1.nrun $1 ! ! ntdump.dat ! ' '
To dump (scan) a quantity to the screen: scan 1 nev=9 varlis=fit_dir(3) fit_len
This prints the fit_dir(3) and fit_len for events that have nev=9.
dump format: If the contents of your ntuple dump are in some funny format, (e.g., you get numbers that look like this: z'1d') then "nt/dump 1.x*1.0" in order to force the output into conventional format.
A kumac for reading in an ntuple: NTReader.kumac
To make a scatter-plot: nt/plot 1.y%x
To superimpose your plot on top of the existing picture:
nt/plot 1.y%x 50 (where 50 is the histo ID)
nt/plot 1.a%b 50 S
To change the symbol on your scatter-plot: set mtyp 7 (8 is another good one.)
To create an ntuple of your very own:
nt/cre 100 'ntuple_name' 8 ! ! dec ra hits alpha sigmag sigmab n ll
There are 8 entries in this ntuple.
nt/read 100 cone.dat
cone.dat is organized into eight columns.
to weight the contents of an ntuple: nt/pl 100.x w
Here w is a variable in 100 that acts as a weight
The weight works like a cut.
To plot the product (or some function) of two variables: nt/pl 100.Hits*ul
To plot use an ntuple variable as an error bar: you'll need to write a short kumac.

HBooks (saved histogram files)
To open an .hbk file: hi/file 1 file.hbk
To open two .hbk files at once:
hi/file 1 file1.hbk
hi/file 2 file2.hbk
nt/pl 1.ra ! (from file 2)
cdir //lun1
nt/pl 1.ra ! (from file 1)
To chain together many .hbk files: write a kumac to chain them together: chain.csh
To see the contents of an hbk file: hi/list 1
To plot something from the latest opened hbk: hi/pl 10

Kumacs (Macros) (paw scripts)
To run a .kumac: exec example
To comment out a line: *this is commented out
!So is this one.
To continue a line that is too long end the first fragment with " _"
To define a variable: global/create lb -3
To refer to that variable: 2d 81 'alpha_m vs alpha_t 99% cl' 200 [lb] .4 200 0 1
to assign a new value to a variable: j=[j]+1
to assign a new value to a variable involving fortran functions: norm=$SIGMA(sqrt([green]))
To refer to command line arguments: nt/read 100 [1] ! ! ! !
To print a message to the screen: message 'hi'
to use a for loop (or a "do loop"):
do i=1,10 (includes the values 1 and 10)
  message 'hi'
enddo
if statement:
        if [k] = 1 then
                nt/cuts $11 $3&&$1
        elseif [k] = 2 then
                nt/cuts $11 $3&&$2&&!$4
        endif
To fit a histogram: fit.kumac
To fit a histogram (on only bins 1-15) with a user-defined function: h/fit 300(1:15) ../fitfunc/chisq.f

Assorted tricks:

vector operations:
vec/cre thru(10) r 2156 2337 595 226 144 83 78 58 33 25
vec/cre terr(10)
sigma terr=sqrt(thru) ! takes the square root of each vector element

Back to Resources