|
PAW > SET TFON ffp | Title FONT (ff) and PREC (p)
PAW > SET GFON ffp | Global title FONT (ff) and PREC (p)
PAW > SET VFON ffp | axis Values FONT (ff) and PREC (p)
PAW > SET LFON ffp | axis Labels FONT (ff) and PREC (p)
PAW > SET CFON ffp | Comment FONT (ff) and PREC (p)
PAW > SET *FON ffp | Set the same values for all
PAW > SET TXFP ffp | ITX FONT (ff) and PREC (p)
Example:
PAW > SET *FON -60 | the all the font to -6 (Helvetica-Bold) and all
| the precision to 0.
The possible PostScript fonts are:
Font 0 with the precision 2 is the Software HIGZ font:
The following table gives all the Postscript characters available in PAW. Note the Euro symbol is there (\360 in greek or special):
The possible precisions are:
|
Precision number |
Effect |
|
0 |
The font used on screen and on Postscript file are the same. On the screen the text is rotated and aligned but, for speed purpose, the size used is the available on the machine. The control characters special characters are not interpreted on the screen but are interpreted on the PostScript output. |
|
1 |
The font used on the screen is the HIGZ-Software and on PostScript the one selected. So, on the screen the text is rotated, aligned and scaled correctly, the control are interpreted but the font used doesn't look like the one used on the PostScript output. |
|
2 |
The font used on screen and on Postscript output are the same. On the screen the text is rotated, aligned and correctly scaled, the control characters are NOT interpreted but the font used looks like the one used on the PostScript output. |
In addition to the character font and precision, the text aspect can be modified via a set of control characters. These characters are embedded into the characters strings and are interpreted according to the rules defined in the HIGZ-software font table.
| List of escape characters and their meaning | |||
|---|---|---|---|
| < | go to lower case (optional) | > | go to upper case (optional) |
| [ | go to greek (Roman = default) | ] | end of greek |
| " | go to special symbols | # | end of special symbols |
| ~ | go to ZapfDingbats | # | end of ZapfDingbats |
| ^ | go to superscript | ? | go to subscript |
| ! | go to normal level of script | & | backspace one character |
| $ | termination character (optional) | @ | escape |
Example:
For/File 44 paw.ps
Meta 44 -111
Size 40 20
Next
Sel 1
Set CHHE 1
Set TXFP -11
Itx 0.2 1. 'L?em! = e J^[m]?&em! A?[m]! , J^[m]?&em!=l&^\261![ g?m]!l , M^j?&i! = [\345&?a]! A?[a! t^a]j?&i! '
Set TXFP -10
Itx 0.2 3.5 'L?em! = e J^[m]?&em! A?[m]! , J^[m]?&em!=l&^\261![ g?m]!l , M^j?&i! = [\345&?a]! A?[a! t^a]j?&i! '
Close 44
The output on the screen is the following. Note that the 'octal characters' like \261 or \345 are never translated whatever the precision is.
The output on the PostScript file is the same with precision 0 or 1.
Note: If the text output is produced with the command TEXT instead of ITX the font and precision used is always 0, 2.
Vector/Del *
Vector/Cre x(10) r 1 2 3 4 5 6 7 8 9 10
Vector/Cre y(10) r 0.9 2.1 2.9 4.1 4.9 6.1 6.9 8.1 8.9 10.1
Vector/Cre ey(10) r 10*0.3
Vector/Cre chi2(1) r
*
Vector/Fit x y ey p1 e
*
Application COMIS Quit
SUBROUTINE chiq
* NPFITS Number of points used in the fit
* NFPAR Number of free parameters
* FITCHI Chisquare
* FITPAR Values of parameters
* FITSIG Errors on parameters
COMMON/HCFITS/NCFITS,NPFITS,NFPAR,FITCHI,FITPAR(35),FITSIG(35)
+ ,FITDER(35)
vector chi2
chi2(1)=fitchi
END
Quit
*
Call chiq
Vector/Pri chi2
*
return
|
PAW > exe chi2
**********************************************
* *
* Function minimization by SUBROUTINE HFITV *
* Variable-metric method *
* ID = 0 CHOPT = E *
* *
**********************************************
Convergence when estimated distance to minimum (EDM) .LT. 0.10E+01
FCN= 1.077442 FROM MINOS STATUS=SUCCESSFUL 18 CALLS 58 TOTAL
EDM= 0.38E-11 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER PARABOLIC MINOS ERRORS
NO. NAME VALUE ERROR NEGATIVE POSITIVE
1 P1 -0.33333E-01 0.20507 -0.20494 0.20494
2 P2 1.0061 0.33054E-01 -0.33029E-01 0.33029E-01
CHISQUARE = 0.1347E+00 NPFIT = 10
CHI2(1) = 0.13468
PAW >
|
$HINFO(id,'ENTRIES') ........ Number of entries
$HINFO(id,'MEAN') ........... Mean value
$HINFO(id,'RMS') ............ Standard deviation
$HINFO(id,'EVENTS') ......... Number of equivalent events
$HINFO(id,'OVERFLOW') ....... Content of overflow channel
$HINFO(id,'UNDERFLOW') ...... Content of underflow channel
$HINFO(id,'MIN') ............ Minimum bin content
$HINFO(id,'MAX') ............ Maximum bin content
$HINFO(id,'SUM') ............ Total histogram content
$HINFO(id,'NSLIX') .......... Number of X slices
$HINFO(id,'NSLIY') .......... Number of Y slices
$HINFO(id,'NBANX') .......... Number of X bands
$HINFO(id,'NBANY') .......... Number of Y bands
$HINFO(id,'NPROX') .......... Projection X (0 or 1)
$HINFO(id,'NPROY') .......... Projection Y (0 or 1)
$HINFO(id,'XBINS') .......... Number of bins in X direction
$HINFO(id,'XMIN') ........... Lower histogram limit in X direction
$HINFO(id,'XMAX') ........... Upper histogram limit in X direction
$HINFO(id,'YBINS') .......... Number of bins in Y direction
$HINFO(id,'YMIN') ........... Lower histogram limit in Y direction
$HINFO(id,'YMAX') ........... Upper histogram limit in Y direction
Example:
PAW > MESSAGE $HINFO(10,'ENTRIES')Note that some other functions are available.
For low level drawing commands such as
PLINE,
PMARKER,
ITX,
FAREA,
the colours are set via commands like
PAW > SET PLCI 2,
PAW > SET FACI 4.
When a command like
HISTO/PLOT
is performed, the hatching and colour attributes
can be preset with the
SET command. It allows to change the colour (COL) and
the hatches type (TYP) of 4 main graphics object in the PAW plots:
Bxxx : Box around each histogram/function plot (zone).
Pxxx : Page. It may contain several zones.
Hxxx : Histogram
Fxxx : Function
xxx can be
TYP or
COL
Example:
PAW > SET HCOL 2
Changes the histogram colour to 2 (red).
The values given to the parameters PTYP, BTYP and HTYP are fill area interior style. The two following figures show the available fill area interior styles:


The parameters PCOL, BCOL, HCOL are equivalent to PTYP, BTYP, HTYP, respectively , but instead of changing the hatch style, they change the colour of the same areas.
If PCOL, BCOL, HCOL are between 1 and 99, then only the contour of the corresponding area is changed. If they are between 1001 and 1099, then the surface is filled with the corresponding fill area colour index.
It is possible to specify with one
SET command both the border and
the inside color for the Histogram, Box Page, and Function (
HCOL,
BCOL,
PCOL,
FCOL).
Example:
+---- 1 The Histogram is filled
| 0 Only the border is drawn
|+--- Border color (here 2) if the histogram is filled
||++- Inside color (here 3) if the histogram is filled
|||| Border color if the histogram is not filled
||||
VVVV
SET HCOL 1203.
The same mechanism is also available for
FCOL,
BCOL and
PCOL.
In addition, BCOL has two digits after the dot. The first one specifies the colour of the zone box shadowing and the second the colour of the statistic box shadowing.
See also the FAQ: How to define the colour map for the option COLZ of HISTO/PLOT ?
You can use the Histo/fit command with the predefined fitting functions on a profile histogram. See the macro below.
macro fit2l
h/del 0
application comis quit
subroutine make2d
call hbook2(2,'test',40,0.,10.,40,0.,10.,0.)
call hbprof(1,'test',40,0.,10.,0.,10.,'S')
do 10 i=1,10000
dev=0.5-rndm(i)
x=10.*rndm(i)
call hfill(1,x,x+dev,1.)
call hfill(2,x,x+dev,1.)
10 continue
end
quit
call make2d
zone 1 2
h/pl 2
hi/fit 1 p1
return
|
PAW > exe fit2l
**********************************************
* *
* Function minimization by SUBROUTINE HFITPO *
* Variable-metric method *
* ID = 1 CHOPT = TU *
* *
**********************************************
Convergence when estimated distance to minimum (EDM) .LT. 0.10E+01
FCN= 1.792382 FROM MIGRAD STATUS=CONVERGED 31 CALLS 32 TOTAL
EDM= 0.21E-24 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 A0 0.55398E-01 0.85177E-01 0.26538E-02 -0.96222E-11
2 A1 0.98826 0.14371E-01 0.25001E-02 -0.82064E-10
CHISQUARE = 0.4717E-01 NPFIT = 40
PAW >
|
RZOUT: current RZ file cannot support > 64K records
or individual directories > 64K
RZOUT: previous cycle(s) for this key ( 30) deleted
RZOUT: please consult ZEBRA manual for further details
or:
RZOUT: "Request exceeds quota"this indicates that some parameters must be tuned in order to bypass these limits:
Example:
COMMON/QUEST/IQUEST(100)
IQUEST(10)=64000
CALL HROPEN(lun,......,'NQ',4096,istat)
will create a file with a maximum of 64000 records of 4096 words. With this
technique the largest number of records you can have in an HBOOK file
will be 64000 (2**16).
Important note: It is very important to initialise IQUEST(10) just before the call to HROPEN. The QUEST common block is used a lot in the whole CERNLIB, and in particular in HBOOK, so if the value of IQUEST(10) is defined too far from the call to HROPEN, very likely it will not have the expected value when needed.
Program Quota
Parameter (Nwpawc=150000, Nvars=17)
Character*8 Chtags(Nvars)
Dimension Event(Nvars)
Common/Pawc/Paw(Nwpawc)
*
Equivalence (Event(1) ,X1) , (Event(2),Y1) , (Event(3) ,Z1)
Equivalence (Event(4) ,Enrgy1), (Event(5),Eloss1)
Equivalence (Event(6) ,X2) , (Event(7),Y2) , (Event(8) ,Z2)
Equivalence (Event(9) ,Enrgy2), (Event(10),Eloss2)
Equivalence (Event(11),X3) , (Event(12),Y3) , (Event(13),Z3)
Equivalence (Event(14),Enrgy3), (Event(15),Eloss3)
Equivalence (Event(16),X4) , (Event(17),Y4)
*
Common /QUEST/ Iquest(100)
Data Chtags/'X1','Y1','Z1','Energy1','Eloss1',
+ 'X2','Y2','Z2','Energy2','Eloss2',
+ 'X3','Y3','Z3','Energy3','Eloss3',
+ 'X4','Y4'/
*
Call Hlimit(Nwpawc)
*
Iquest(10) = 256000
Call Hropen (1,'QUOTA','quota.hbook','NQE',1024,ISTAT)
If (Istat.Ne.0) Stop
*
Call Hbookn (10,'A simple Ntuple',Nvars,'//QUOTA',10000,Chtags)
*
Do I=1, 5000000
Call Rannor(X1,Y1)
X1 = Float(I)
Z3 = Sqrt(X1*X1+Y1*Y1)
Enrgy1 = 50. + 10.*X1
Eloss1 = 10. * Abs(Y1)
Call Rannor (X2,Y2)
Z3 = Sqrt(X2*X2+Y2*Y2)
Enrgy2 = 50. + 10.*X2
Eloss2 = 10. * Abs(Y2)
Call Rannor(X3,Y3)
Z3 = SQRT(X3*X3+Y3*Y3)
Enrgy3 = 50. + 10.*X3
Eloss3 = 10. * Abs(Y3)
Call Rannor(X4,Y4)
Call Hfn(10,Event)
Enddo
Call Hrout(0,Icycle,' ')
Call Hrend('QUOTA')
End
When you run this example you get:
$ ./quota
RZMAKE. new RZ format selected.
This file will not be readable with versions of RZ prior to release 94B
$ ls -l quota.hbook
-rw-r--r-- 1 couet olivier 340918272 Dec 13 12:06 quota.hbook
$
the program xwpick, available on asis, should be used. It has all kind of options to produce GIF, PICT etc .. . In PAW just do:
shell xwpick ....
This will invoke xwpick in interactive mode.
To convert the current PAW window into a gif file, the following script (UNIX only) can be used (file xw1):
xwininfo -name 'HIGZ_01 @ hphigz' | grep xwininfo | sed -e 's/^..................../xwpick junk.gif -window/' -e 's/................. mv junk.gif $1
in PAW just do:
PAW > shell xw1 test.gif
and the current window will be converted in test.gif.
The command PICTURE/PRINT produces a gif file if the file name is file_name.gif.
Example:
PAW > pict/print test.gif
produce the file test.gif from the current graphics window.
This mechanism works only on X11 machines. On NT or Windows one should use the general procedure to capture any active windows:
CALL IGGIF(1,W,H,'name.gif','M')
Where W and
H are the width and heigh of the GIF
picture.
Note: The GIF file is created by converting the content of the X11 window. So, as we said before, the HIGZ graphics window is necessary. If the popping up of the HIGZ window on the computer screen is annoying, one can install the VNC server and redirect the HIGZ window to that screen like setenv DISPLAY :1.
Macro Legend
TYPE = [1] | Type of hatches
X1 = [2] | X bottom left corner of the box.
X2 = [3] | X top right corner of the box.
Y1 = [4] | Y bottom left corner of the box.
Y2 = [5] | Y top right corner of the box.
TEXT = [6] | Text to be printed
Set FAIS 3
Set FASI [TYPE]
Set BORD 1
Box [X1] [X2] [Y1] [Y2]
Set TXAL 03
XT = [X2]+$GRAFINFO('?CHHE')
YT = ([Y2]+[Y1])/2
Itx [XT] [YT] [TEXT]
Return
Note that this kind of macro is anyway useful to personalise an output.
And also ....
:0 local /usr/X11R6/bin/X +bsIf it is gdm the line starting the X server in the file /etc/X11/gdm/gdm.conf should contain the option +bs it could be something like:
0=/usr/bin/X11/X +bsWith some LINUX systems (for instance Suse Linux 7.2) the file .fvwm2rc should contains the line:
Style "*" BackingStore
Section "Screen"
.
.
.
Option "backingstore"
.
.
.
EndSection
#!/bin/sh
HOST=`hostname`
exec X +bs -bpp 32 -auth ${HOME}/.Xauthority
Note that once the necessary modifications have been done, the X server should be restart. Rebooting the machine may be necessary ...
Two possibilities:
Start --->
More Applications
---> Exceed X-terminal
---> Exceed Applications
---> Xconfig
---> Performance
In this window, titled "Performance":
"Save Unders" option (this eliminates the need
for the client to refresh the window when the menu is rolled back up).
Maximum Backing Store: Always (attempt to preserve the contents
of any window, whether it is mapped or not,
as long as it is displayed on the X server)
Default Backing Store: When Mapped
Minimum Backing Store: When Mapped
Tune... ---> Run All (this runs automatically some tests)
Then start again your X11-session
PAW > OUTPUT 60 FIT.DAT PAW > HI/FIT 10 GThe HI/FIT output is written in the file FIT.DAT.


SET NDVX i e.g. SET NDVX 512
or
SET NDVX i.jk e.g. SET NDVX 10.25
In the first case the number ``i'' contains 100 times the number of
secondary divisions plus the number of primary divisions. (e.g. 512 means
12 primary and 5 secondary division. By adding 10000 times N3 to ``i'' a
third level of divisions is available.
In the second case the number in front of the dot (i) indicates the total number of divisions, the first digit following the dot (j) the label identifier (LABNUM) (if this number is equal to 0 numeric labels are drawn). The second digit after the dot (k) indicates the position where the labels have to be drawn (i.e. the parameter, in this case 5, indicating horizontally written text centred on the interval). Study the next figures for details. These two figures show that the labels can be centred on the tick marks (1 to 4) or on the divisions (5 to 8). If the labels are centred on the tick marks, note that the number of items in the command LABELS must be equal to the number of tick marks (which is equal to the number of divisions plus one ), otherwise the last alphanumeric label on the axis will be undefined.
By default, the number of primary divisions given by SET NDVX n,
SET NDVY n or SET NDVZ n is optimised to have a reasonable labelling:
The number of divisions ( NDIV ) is calculated according to
the following convention:
(NDIV = N1 + 100*N2 + 10000*N3)
Where N1 is the number of primary divisions, N2 is the number of second order
divisions and N3 is the number of third order divisions. The sign of NDIV is
also used to control the labelling:
The number of primary divisions is also optimised according the number of zones (see command ZONE) i.e : along the X direction the number of primary divisions is divided by the_number_of_X_zones along the Y direction the number of primary divisions in divided by (the_number_of_Y_zones)/2.
If the number of divisions has to be exactly equal to the
number given by SET NDVX n, SET NDVY n or
SET NDVZ n, a negative value must be used i.e.:
SET NDVX -i e.g. SET NDVX -512
or
SET NDVX -i.jk e.g. SET NDVX -10.25
For example to label each subsequent X-axis with the names of the
months of the year centred in the middle of each bin you can use:
PAW > LABEL 1 12 JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC
PAW > SET NDVX -12.15
Limitation: Alpha numeric labels (defined with the command
LABEL) do not work on 3D plots
like Lego Plots and Surface Plots.
It is also possible to run PAW on a remote host and display the PAW graphics window on a MacIntosh. This can be achieve in two ways:
MACRO FIT2D
*
* Macro to test 2-D fits of functions F(x1,x2) = Y to data.
*
ZONE 2 2
OPT NSTA
H/DEL *
VECT/DEL *
NP= 3
VECT/CREA PAR([NP]) R 100.0 1.0 1.0
VECT/CREA STEP([NP]) R 1.0 1.0 1.0
VECT/CREA PMIN([NP]) R 1.0 0.0 1.0
VECT/CREA PMAX([NP]) R 1.0 1.0 1.0
*
* Define number of bins in X and Y, then book vectors:
*
NX= 6
NY= 8
MINX= 0.0
MAXX= 3.0
MINY= 0.0
MAXY= 4.0
N= [NX]*[NY]
VECT/CREA Y([N])
VECT/CREA EY([N])
VECT/CREA X([N],2)
*
* Make dummy data using random function HRNDM2. Observe that here the values to
* be expected from the fits are defined:
* | |
FUN2 20 EXP(-0.5*(((1.5-X)**2+(2.0-Y)**2)/(3.**2))) 20 [MINX] [MAXX] _
20 [MINY] [MAXY]
2D 30 'DATA' [NX] [MINX] [MAXX] [NY] [MINY] [MAXY]
APPLICATION COMIS QUIT
SUBROUTINE RNDM
DO 10 I=1,10000
CALL HRNDM2(20,RX,RY)
CALL HFILL(30,RX,RY,1.0)
10 CONTINUE
END
CALL RNDM
END
QUIT
H/PL 30 LEGO
GET/CON 30 Y
GET/ERR 30 EY
*
* Put coordinates x1 and x2 into vector X:
*
BINWX= ([MAXX]-[MINX])/[NX]
BINWY= ([MAXY]-[MINY])/[NY]
DO I=1,[NY]
DO J=1,[NX]
ZX= $SIGMA( [MINX]+[BINWX]*([J]-0.5) )
ZY= $SIGMA( [MINY]+[BINWY]*([I]-0.5) )
N= $SIGMA( ([I]-1)*[NX]+[J] )
VECT/INP X([N],1) [ZX]
VECT/INP X([N],2) [ZY]
ENDDO
ENDDO
*
* Do the fit:
*
V/IN PAR 100.0 1.0 1.0
V/FIT X Y EY FUNXY.FOR 0 [NP] PAR STEP PMIN PMAX
| Plot result:
P1= PAR(1)
P2= PAR(2)
P3= PAR(3)
ZONE 1 2 2 S
FUN2 50 [P1]*EXP(-0.5*((([P2]-X)**2+([P3]-Y)**2)/(3.**2))) [NX] [MINX] [MAXX] _
[NY] [MINY] [MAXY] ' '
H/PL 50 LEGO
RETURN
Where the COMIS function FUNXY.FOR is:
FUNCTION FUNXY(X)
DIMENSION X(2)
COMMON/PAWPAR/PAR(3)
FUNXY= PAR(1)
& *EXP( -0.5*(((PAR(2)-X(1))**2+(PAR(3)-X(2))**2)/(3.**2)) )
END
|
PAW > exe fit2d
**********************************************
* *
* Function minimization by SUBROUTINE HFITV *
* Variable-metric method *
* ID = 0 CHOPT = 0 *
* *
**********************************************
Convergence when estimated distance to minimum (EDM) .LT. 0.10E+01
FCN= 44.38704 FROM MIGRAD STATUS=CONVERGED 70 CALLS 71 TOTAL
EDM= 0.92E-04 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 P1 232.45 2.4176 0.58806 0.23439E-04
2 P2 1.7379 0.10665 0.24700E-01 0.10854
3 P3 2.0745 0.81073E-01 0.19395E-01 -0.86093E-01
CHISQUARE = 0.9864E+00 NPFIT = 48
PAW >
|
Subroutine Rescale(Id1,Id2,X1,X2)
Character*32 Chtitl
Logical Hexist
Call Hgive(Id1,Chtitl,Ncx,Xmin,Xmax,Ncy,Ymin,Ymax,Nwt,Loc)
Bw = (Xmax-Xmin)/Ncx
Nbin = (X2-X1)/Bw
Bw2 = Bw/2.
If (Hexist(Id2)) Call Hdelet(Id2)
Call Hbook1(Id2,Chtitl,NBin,X1,X2,0.)
Do I=1,Ncx
Call Hix(Id1,I,X)
XI = X+Bw2
W = Hx(Id1,XI)
Call Hfill(Id2,XI,0.,W)
Enddo
End
Example:
PAW > Call rescale.f(10,11,-3.,10.) PAW > h/pl 11
| on Unix |
paw -b macro_name |
| on VMS |
PAW/batch=macro_name |
Macro macro_name
For/File 1 filename.ps
Metafile -1 -111
.
.
here put your graphic commands
.
.
close 1
To know if a PAW session is running in batch
or interactive mode mode, it is enough to put the following
lines in the pawlogon.kumac
file:
if $INDEX($ARGS,'-b') = 0 then
a/cr batch 0
else
a/cr batch 1
endif
Then every where you need to know the running mode it is
enough to test the value of the alias
batch.
Arguments passing
It is NOT possible to pass directly arguments to a macro executed in batch. Nevertheless this problem can be bypass using environment variables.
| On Unix (csh) |
setenv arg1 hello paw -b macro_name |
| On Unix (ksh) |
export arg1=hello paw -b macro_name |
| On VMS |
arg1 :== hello PAW/batch=macro_name |
In all cases (UNIX, VMS ...) in the macro "macro_name" it
is enough to use $ENV(arg1)
to get the value of the global variable.
arg1
Example:
mess $ENV(arg1)
![]() |
Macro Colz
Set * ; Opt * ; H/Del *
*
Fun2 100 1000*(x**2+y**2) 100 -1 1 100 -1 1 ' '
*
Mess ' '
Mess 'The first 8 (0-7) basic colours are used'
Mess ' '
Hist/Plot 100 COLZ
Wait
*
Mess ' '
Mess 'SET NCOL allows to enlarge the colour map and defines'
Mess 'a grey scale ramp from color index 8 to NCOL'
Mess ' '
Set NCOL 20
Hist/Plot 100 COLZ
Wait
*
Mess ' '
Mess 'The command PALETTE defines (by default) a geographical'
Mess 'palette form 8 to NCOL'
Mess ' '
Palette 1
Hist/Plot 100 COLZ
Wait
*
Mess ' '
Mess 'The command COLOR allows to define individually the colours.'
Mess ' '
Color 20 1 0 0
Color 8 1 0 0
Color 15 1 0 0
Hist/Plot 100 COLZ
*
Return
|
![]() |
|
![]() |
|
![]() |
The following example is in fact a tool allowing to define a smooth colour map in a very simple way. This tool consist of 2 COMIS routines which should be saved in the files shade.f and setshd.f. The routine setshd allows to define a set (up to 20) of fixed colours which will be used to define the colour map. Once this set of colours is define, a single call to shade allows to define the colour map. An example is given below, with the macro shade.kumac.
File "shade.f":
subroutine shade()
parameter (nmx = 20)
common /shpt/ npt,idx(nmx),r(nmx),g(nmx),b(nmx)
if (npt.lt.2) then
print*, 'Error: at least two colours are needed'
return
endif
do i=2,npt
j = i-1
i1 = idx(j)
i2 = idx(i)
r1 = r(j)
g1 = g(j)
b1 = b(j)
r2 = r(i)
g2 = g(i)
b2 = b(i)
n = i2-i1+1
do ii=i1,i2
scale = float(ii-i1)/(n-1)
rs = (r2 - r1)*scale + r1
gs = (g2 - g1)*scale + g1
bs = (b2 - b1)*scale + b1
call iscr(1,ii,rs,gs,bs)
enddo
enddo
end
File "setshd.f":
subroutine setshd(idxi, ri, gi, bi)
parameter (nmx = 20)
common /shpt/ npt,idx(nmx),r(nmx),g(nmx),b(nmx)
if (idxi.lt.0) then
npt = 0
return
endif
npt = npt+1
if (npt.gt.nmx) then
print*, 'Error: too many colours'
return
endif
idx(npt) = idxi
r(npt) = ri
g(npt) = gi
b(npt) = bi
end
File "shade.kumac":
Macro shade
set ncol 255
fun2 100 exp(-.5*((x-75)/10)**2)*exp(-.5*((y-60)/10)**2) 100 45 105 100 30 90 ' '
call setshd.f( -1,0.0,0.0,0.0)
call setshd.f( 8,0.0,0.0,1.0)
call setshd.f(100,1.0,0.0,0.0)
call setshd.f(130,1.0,1.0,0.0)
call setshd.f(180,0.0,1.0,0.5)
call setshd.f(255,1.0,0.6,0.5)
call shade.f
h/pl 100 colz
h/del 100
return
Just do:
PAW > Exec shade
and you will get the following picture:
File "colz.kumac":
Macro Colz
Opt * ; h/del * ; v/del *
fun2 2 sin(x)/x*cos(y)*y 100 -6 6 100 -6 6 ' '
N = 6
V/create Z([N]) R -12 -4 -1 0 1 12
V/create R([N]) R 1.0 1.0 0.0 1.0 0.0 0.0
V/create G([N]) R 0.0 1.0 1.0 1.0 1.0 0.0
V/create B([N]) R 0.0 0.0 1.0 1.0 0.0 1.0
call colz.f(2,255,[N],Z,R,G,B)
Return
File "colz.f":
Subroutine Colz(Id,Ncol,N,Z,R,G,B)
*
* This procedure defines a mapping of a 2D histogram content to a palette
* of colours defines by R G B values. Ncol is the number of colours in the
* colour map.
* Z(i) is mapped to R(i), G(i), B(i).
* If Z(1) < Zmin, Zmin is used, is Z(N) > Zmax Z max is used
*
Dimension Z(N),R(N),G(N),B(N)
Character*32 Chtitl
*
Call Hgive(Id,Chtitl,Ncx,Xmin,Xmax,Ncy,Ymin,Ymax,Nwt,Loc)
*
Call Igset('NCOL',Float(Ncol))
*
Zmin = Hij(Id,1,1)
Zmax = Zmin
Do j=1,Ncy
Do I=1,Ncx
Zi = Hij(Id,i,j)
If (Zi.Gt.Zmax) Zmax = Zi
If (Zi.Lt.Zmin) Zmin = Zi
Enddo
Enddo
Dz = Zmax-Zmin
*
Call Setshd( -1,0.0,0.0,0.0)
Do I=1,N
Zi = Z(I)
If (Zi.Lt.Zmin) Zi = Zmin
If (Zi.Gt.Zmax) Zi = Zmax
Idz = Int(((Zi-Zmin)/Dz)*(Ncol-8)+8)
Call Setshd(Idz,R(I),G(I),B(I))
Enddo
Call Shade
Call Hplot(Id,'COLZ',' ',0)
End
*.__________________________________
*
Subroutine Shade()
Parameter (Nmx = 20)
Common /SHPT/ Npt,Idx(Nmx),R(Nmx),G(Nmx),B(Nmx)
If (Npt.Lt.2) Then
Print*, 'Error: at least two colours are needed'
Return
Endif
Do I=2,Npt
J = I-1
I1 = Idx(j)
I2 = Idx(i)
R1 = R(j)
G1 = G(j)
B1 = B(j)
R2 = R(i)
G2 = G(i)
B2 = B(i)
n = i2-i1+1
Do Ii=I1,i2
Scale = Float(Ii-I1)/(N-1)
Rs = (R2 - R1)*Scale + R1
Gs = (G2 - G1)*Scale + G1
Bs = (B2 - B1)*Scale + B1
Call Iscr(1,Ii,Rs,Gs,Bs)
Enddo
Enddo
End
*.__________________________________
*
Subroutine Setshd(Idxi, Ri, Gi, Bi)
Parameter (Nmx = 20)
Common /SHPT/ Npt,Idx(Nmx),R(Nmx),G(Nmx),B(Nmx)
If (Idxi.Lt.0) Then
Npt = 0
Return
Endif
Npt = Npt+1
If (Npt.Gt.Nmx) Then
Print*, 'Error: too many colours'
Return
Endif
Idx(Npt) = Idxi
R(Npt) = Ri
G(Npt) = Gi
B(Npt) = Bi
End
Just do:
PAW > Exec colz
and you will get the following picture:
Appl Comis Quit
Function Square(x)
Square = x*x
End
Quit
Do i=1,9
x = Square( $RSIGMA([i]) )
Mess Square of [i] is $CALL([x])
Enddo
The output of this macro is:
PAW > exe test Square of 1 is 1 Square of 2 is 4 Square of 3 is 9 Square of 4 is 16 Square of 5 is 25 Square of 6 is 36 Square of 7 is 49 Square of 8 is 64 Square of 9 is 81An other way to use $CALL with macro variable is:
Appl Comis Quit
Function Square(x)
Square = x*x
End
Quit
x = $Rsigma(16)
Mess Square of [x] is $CALL('square('//[x]//')')
Note also:
$CALL('fun(args)') ...... Call a Fortran REAL FUNCTION
$ICALL('ifun(args)') .... Call an INTEGER FUNCTION
$LCALL('lfun(args)') .... Call a LOGICAL FUNCTION and return 0 or 1
$DCALL('dfun(args)') .... Call a DOUBLE PRECISION FUNCTION
PROGRAM PAMAIN
*
* MAIN Program for basic PAW
*
PARAMETER (NWPAW=2000000)
*
COMMON/PAWC/PAWCOM(NWPAW)
*
ON REAL UNDERFLOW IGNORE <--- For HP only
*
CALL PAW(NWPAW,IWTYP)
*
CALL KUWHAG
*
CALL PAEXIT
*
STOP
END
SUBROUTINE QNEXT
END
SUBROUTINE CTL$GL_PCB \
ENTRY CTL$T_ACCOUNT | For VAX
ENTRY CTL$T_USERNAME | only
END /
To increase the size of the PAW memory the parameter
NWPAW should
be changed.
To rebuild paw++ instead of pawX11 be sure that:
PROGRAM PAMAIN
*
PARAMETER (NWPAW=2000000)
*
COMMON /PAWC/ PAWCOM(NWPAW)
*
CALL PAWPP(NWPAW,IWTYP)
*
IF (IWTYP .EQ. 999) THEN
CALL KUWHAM('Paw++')
ELSE
CALL KUWHAG
ENDIF
*
CALL PAEXIT
*
STOP
END
OPTION=-O <--- Machine dependent CERNLIB=/cern/pro/lib LIB=-lX11 -lm -lc <--- Machine dependent LIBMOTIF=-lXm -lXt <--- Machine dependent f77 -o pawX11 pamain.f $OPTION \ <--- replace pawX11 by paw++ to rebuild paw++ $CERNLIB/libpawlib.a \ $CERNLIB/libpacklib.a \ $CERNLIB/libgraflib.a \ $CERNLIB/libgrafX11.a \ $CERNLIB/libpacklib.a \ $CERNLIB/libmathlib.a \ $CERNLIB/libkernlib.a \ $CERNLIB/liblapack3.a \ $CERNLIB/libblas.a \ -L/usr/local/lib -lshift \ $LIBMOTIF \ <--- for paw++ only $LIBCopy/paste the previous script in an file named buildpaw and do:
$ chmod +x buildpaw $ ./buildpawThe machine dependent variables should be defined as follow:
OPTION=+ppu -Wl,-E LIB=-L/usr/lib/X11R5 -lX11 -lm -lc -lPW -ldld
OPTION=-O -Wl,-E LIB=-L/usr/X11R6/lib -lX11 -lcrypt -ldl -lnsl LIBMOTIF=-lXm -lXt -lXext -lXp
OPTION=-D 40000000 -T 20000000 -taso -v LIB=-lX11 -ldnet_stub LIBMOTIF=-lXm -lXt
OPTION=-Bdynamic LIB=-L/usr/openwin/lib -lX11 -lw -lgen -lsocket -lnsl -lintl -ldl LIBMOTIF=-lXm -lXt
df -Fepawbig.exe pamain.for pawlib.lib lapack3.lib blas.lib graflib.lib grafX11.lib ix_higz.lib packlib.lib mathlib.lib kernlib.lib user32.lib advapi32.lib wsock32.libTo run properly this script, the following steps must be done:
C:\cern buildpaw
program main
common/pawc/paw(100000)
call hlimit(100000)
call csinit(2000)
1 call cspaus('Test')
go to 1
end
This is the corresponding link procedure for a HP-UX system:
f77 -o ctest +ppu ctest.f \ /cern/pro/lib/libpawlib.a \ /cern/pro/lib/libpacklib.a \ /cern/pro/lib/libkernlib.a -ldld -Wl,-EYou run the program ctest. At the COMIS prompt, you can compile one or more COMIS files with the command
Cs > !file mytest.f Cs > call mytest#
MACRO ALABEL XLBL=' ' YLBL=' ' XDEL=0.05 YDEL=0.05
NT = $GRAFINFO('NT')
TSIZ = $GRAFINFO('?TSIZ')
TFON = $GRAFINFO('?TFON')
X1 = $GRAFINFO('VPXMIN') | Lower X limit of viewport in current NT
X2 = $GRAFINFO('VPXMAX') | Upper X limit of viewport in current NT
Y1 = $GRAFINFO('VPYMIN') | Lower Y limit of viewport in current NT
Y2 = $GRAFINFO('VPYMAX') | Upper Y limit of viewport in current NT
SEL 0
Xlx = ([X2]+[X1])/2
Xly = [Y1] - [YDEL]
Ylx = [X1] - [XDEL]
Yly = ([Y2]+[Y1])/2
SET TXFP [TFON] ; SET CHHE [TSIZ] ; SET TXAL 20
SET TANG 0 ; ITX [Xlx] [Xly] [XLBL]
SET TANG 90 ; ITX [Ylx] [Yly] [YLBL]
SEL [NT]
RETURN
Example:
|
PAW > zone 2 2
PAW > Nul
PAW > exe alabel XLBL=X-Title YLBL=Y-Title
|
The offset of the labels can be changed (in normalized coordinates) with the parameter XDEL and YDEL.
| Fortran version | C version |
|---|---|
Program hserver
*
Call Hlimap(10000,'TEST')
*
Call Hbook1(1,'test1',100,-3.,3.,0.)
*
Call Hcopy(1,2,'test2')
Call Hcopy(1,3,'test3')
*
Do i=1,100000000
call rannor(a,b)
call hf1(1,a,1.)
call hf1(2,b,1.)
call hf1(3,a**2+b**2,1.)
if(mod(i,100000).eq.0)print *,' hserver in loop index ',i
Enddo
*
End
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <cfortran.h>
#include <hbook.h>
#define PAWC_SIZE 10000
typedef struct { float PAW[PAWC_SIZE]; } PAWC_DEF;
#define PAWC COMMON_BLOCK(PAWC,pawc)
COMMON_BLOCK_DEF(PAWC_DEF,PAWC);
PAWC_DEF PAWC;
#define X11 1
int main(int argc, char **argv)
{
int i;
float a, b;
HLIMAP(PAWC_SIZE, "TEST");
HBOOK1(1,"test1",100,-3.,3.,0.);
HCOPY(1,2,"test2");
HCOPY(1,3,"test3");
for (i=0;;i++) {
a=6.*((float)random())/(float)RAND_MAX-3.;
a=log(a*a);
b=6.*((float)random())/(float)RAND_MAX-3.;
b=log(b*b);
HF1(1,a,1.);
HF1(2,b,1.);
HF1(3,a*a+b*b,1.0);
if (!(i % 100000)) printf("\nloop index i=%d", i);
}
return 0;
}
|
$ hserver
GLOBAL MEMORY CREATED, offset from LQ = 235337934
hserver in loop index 100000
hserver in loop index 200000
hserver in loop index 300000
hserver in loop index 400000
hserver in loop index 500000
hserver in loop index 600000
hserver in loop index 700000
.
.
.
While the histograms producer program is running, it is possible to access
the histograms in tow ways:
PAW > GLOBAL_SECT TEST PAW > H/PL 1 PAW > H/PL 1 U
| Fortran version | C version |
|---|---|
Program hreader
*
Character*80 name
Common /PAWC/ A(10000)
*
Call Hlimit(10000)
Call Hlimap(0,'TEST')
*
Call Hrin(1,9999,0)
Call Hgive(1,name,nx,xmi,xma,ny,ymi,yma,nwt,loc)
Print*, name,nx,xmi,xma
*
End
|
#include <stdio.h>
#include <stdlib.h>
#include <cfortran.h>
#include <hbook.h>
#define PAWC_SIZE 10000
typedef struct { float PAW[PAWC_SIZE]; } PAWC_DEF;
#define PAWC COMMON_BLOCK(PAWC,pawc)
COMMON_BLOCK_DEF(PAWC_DEF,PAWC);
PAWC_DEF PAWC;
#define X11 1
int main(int argc, char **argv) {
char fln[256];
int record_size=1024, success=0;
char name[80];
int nx,ny,nwt,loc;
float xmi, xma, ymi, yma, res;
HLIMIT(PAWC_SIZE);
HLIMAP(0,"TEST");
HRIN(1,9999,0);
HGIVE(histo,name,nx,xmi,xma,ny,ymi,yma,nwt,loc);
printf("\n>>%d: %s, %d", histo, name, nx);
return 0;
}
|
$ hreader test1 100 -3. 3. $With HBOOK version older than 4.27/01 be careful to put the shared memory name in a character variable.
PAW > call file.f | code is interpreted (default) PAW > call file.f77 | compilation of file.f with f77 and dynamic linking PAW > call file.c | same with the C compilerfile.c should have the following form:
#includeNote the _ added at the end of the procedure name. Then to call it from PAW it is enough to do:file_(int *i) { int j=*i*100; printf("this is a test %d\n",j); }
PAW > call file.c(123) this is a test 12300 PAW >
It is possible to load shared objects without executing the code. The following macro gives an example:
Macro comp
appl comis quit
!file filename.f77
quit
in this case the local compiler is invoked to process filename.f (note that the file extension remains .f even if the file is called with the extension .f77). Before invoking the compiler, COMIS perform preliminary operations:
then COMIS creates and executes a script file to invoke the native fortran compiler and linker to create a shared object and load the shared object.
C code can also be loaded as shared objects. The following macro gives an example:
Macro comp
appl comis quit
!file filename.c
quit
in this case COMIS creates and executes a script file to invoke the native C compiler and linker to create a shared object and load the shared object.
It is also possible to load an existing shared library. In that case the local compiler is not invoked. There is two types of shared libraries:
The following macro shows how to load a shared library produced from fortran code:
Macro load
appl comis quit
!file filename.sl
quit
in this case COMIS analyse the file filename.f to fill a list of used variables for ntuple watched common blocks, and then load the shared object filename.sl.
The following macro shows how to load a shared library produced from C code:
Macro load
appl comis quit
!file filename.csl
quit
in this case COMIS doesn't analyse the source file, it only load the shared object filename.sl . This can be a way to use fortran features not supported by COMIS such as DOUBLE COMPLEX.
Note that when a procedure has been is loaded with one of the methods described above, it can then be accessed by its name only i.e. the file extension is not needed anymore providing the procedure's code has not changed.
To produce and load the shared library, COMIS produced a temporary script file which looks like this:
#! /bin/sh
olddir=`pwd`
cd CHPATH
/bin/rm -f name.sl
# for C compiler
# cc -c .... name.c
CHCC name.c
#for f77 compiler
# f77 -c .... name.f
CHF77 name.f
errno=$?'
if [ $errno != 0 ]
then
exit $errno
fi
#for HPUX.
ld -b -o name.sl name.o
#for SUN.
# ld -G -o name.sl name.o for Solaris
ld -o name.sl name.o
#for SGI.
ld -shared -o name.sl name.o
#for LINUX.
ld -shared -o name.sl name.o
#
errno=$?
if [ $errno != 0 ]
then
exit $errno
fi
/bin/chmod 555 name.sl
/bin/rm -f name.o
cd $olddir
exit 0
This default script can be customised using COMIS directives.
The user can redefine CHPATH - The new directory where shared object and temporary files will be located (default is /tmp/),
Macro SetPath
appl comis quit
!setopt 'string' path
quit
The user can redefine CHF77 - fortran compiler directive:
Macro Setf77Options
appl comis quit
!setopt 'string' f77
quit
The user can redefine CHCC - C compiler directive:
Macro SetCOptions
appl comis quit
!setopt 'string' cc
quit
To have the current values of the !setopt parameters use:
Macro ShowOptions
appl comis quit
!setopt
quit
|
Default CHF77 value (fortran options) |
Default CHCC value (C options) |
|
| HPUX | f77 -c +z +ppu -K -O (before PAW
2.10) f77 -c +z +ppu |
cc -c +z -O (before PAW
2.10) cc -c +z |
| SGI | f77 -c -pic | cc -c -pic |
| SUN | f77 -c | cc -cckr -c |
| IBM/RT | xlf -qextname -qrndsngl -qcharlen=32767 -c | cc -c |
| LINUX | g77 -c | cc -c |
| ALPHA/OSF | f77 -c | cc -c |
ERROR: Undefined symbol: .f1_
To solve this problem you could add f1 routine into file with
f2 routine.
APPL COMIS QUIT
!FILE 0.csl
QUIT
$ nm /cern/pro/bin/pawX11 | grep -i routine_name
If nothing is returned it means that routine_name cannot
be accessed.
REAL FUNCTION select()
File main.f:
program main
common/pawc/paw(100000)
character*80 chfile
integer csaddr
call hlimit(100000)
call csinit(2000)
*-* file names are given like /xx/yy/file.f
*-* the subroutine name is assumed to be file
1 print *,' Give the name of the COMIS file to be executed'
read (5,'(A)')chfile
nch=lenocc(chfile)
islash=index(chfile,'/')
*-* search for / and .
if(nch.gt.0)then
idot=index(chfile,'.')
if(idot.eq.0)go to 1
ifirst=1
do 10 i=idot-1,1,-1
if(chfile(i:i).eq.'/')then
ifirst=i+1
go to 20
endif
10 continue
20 continue
call cltou(chfile)
*-* compile file
call csexec('!FILE '//chfile(1:nch),iret)
if(iret.ne.0)go to 1
*-* get subroutine address
iad=csaddr(chfile(ifirst:idot-1))
*-* execute routine
call csjcal(iad,0,p,p,p,p,p,p,p,p,p,p)
go to 1
endif
end
File test.f:
subroutine test
*-* stupid sum
sum=0
do i=1,1000
sum=sum+i
enddo
print *,' SUM=',sum
end
Macro Draw_Stat
*
Id = [1]
X1 = [2]
X2 = [3]
Y1 = [4]
Y2 = [5]
N = 6
Dy = $EVAL(([Y2]-[Y1])/([N]+1))
Xt = $EVAL([X1]+0.1)
Yt = $EVAL([Y2]-[Dy])
Selnt 1
Box [X1] [X2] [Y1] [Y2]
Set CHHE $EVAL(0.7*[Dy])
Set TXAL 03
Itx [Xt] [Yt] ID ; Yt = $EVAL([Yt]-[Dy])
Itx [Xt] [Yt] Entries ; Yt = $EVAL([Yt]-[Dy])
Itx [Xt] [Yt] Mean ; Yt = $EVAL([Yt]-[Dy])
Itx [Xt] [Yt] Rms ; Yt = $EVAL([Yt]-[Dy])
Itx [Xt] [Yt] Overflow ; Yt = $EVAL([Yt]-[Dy])
Itx [Xt] [Yt] Underflow
*
Yt = $EVAL([Y2]-[Dy])
Xt = $EVAL([X2]-0.1)
Set TXAL 33
Itx [Xt] [Yt] [Id] ; Yt = $EVAL([Yt]-[Dy])
Itx [Xt] [Yt] $HINFO([Id],'ENTRIES') ; Yt = $EVAL([Yt]-[Dy])
Itx [Xt] [Yt] $HINFO([Id],'MEAN') ; Yt = $EVAL([Yt]-[Dy])
Itx [Xt] [Yt] $HINFO([Id],'RMS') ; Yt = $EVAL([Yt]-[Dy])
Itx [Xt] [Yt] $HINFO([Id],'OVERFLOW') ; Yt = $EVAL([Yt]-[Dy])
Itx [Xt] [Yt] $HINFO([Id],'UNDERFLOW')
*
Return
This macro has five parameters:
|
PAW > H/Plot 10
PAW > Exec draw_stat 10 2 10 2 6 | the position is in cm
|
Example:
|
SET * ; OPT * | Reset the defaults
Nul 0 1 0 1 | draw an empty frame with axis
Set ndvy 5 | Change number of Y divisions
Nul 0 10 0 10 ABS | Redefine the scales
Ticks XR 5 ! | Axis in the new coordinates
|
PAW > VECTOR/DELETE *
PAW > VECTOR/READ X,Y snoopy.dat
PAW > GRAPH $VDIM(X,1) X Y
The output produced is:

10.45700 19.02800 9.867000 18.91000 9.308000 18.61600 8.630000 18.46800 8.012000 18.38000 7.393000 18.49800 6.834000 18.61600 5.862000 18.61600 4.860000 18.38000 3.829000 17.76100 3.240000 16.96600 2.710000 16.23000 2.769000 14.90400 2.209000 14.96300 1.826000 15.28700 1.708000 15.75800 1.767000 16.20000 2.150000 16.40600 2.504000 16.46500 2.828000 16.31800 2.739000 14.78600 3.063000 13.96200 3.535000 13.34300 3.976000 12.96000 4.801000 12.48900 5.596000 12.28300 6.274000 12.16500 6.863000 11.95900 7.305000 11.51700 7.806000 10.86900 8.012000 10.51500 7.894000 10.19100 7.688000 9.838000 7.246000 9.543000 7.010000 9.779000 7.452000 10.30900 6.745000 11.34000 5.803000 11.90000 5.037000 11.72300 5.214000 11.60500 5.420000 11.16300 5.125000 10.92800 4.772000 10.72200 4.242000 10.75100 3.711000 10.54500 3.358000 10.13300 3.152000 9.602000 3.417000 9.161000 4.300000 9.013000 4.624000 8.866000 4.948000 8.277000 4.890000 8.189000 4.683000 8.159000 4.536000 7.629000 5.007000 7.010000 4.566000 6.745000 5.155000 6.068000 4.477000 6.038000 4.271000 5.744000 4.477000 5.508000 4.801000 5.331000 5.214000 5.302000 5.685000 5.538000 5.655000 4.890000 6.097000 3.976000 6.627000 3.505000 6.480000 2.592000 5.891000 2.445000 4.860000 2.474000 4.389000 2.415000 3.800000 2.003000 3.594000 1.532000 3.711000 1.149000 4.035000 1.031000 4.536000 1.060000 4.683000 1.178000 5.331000 1.031000 6.598000 1.001000 9.219000 .9430000 10.45700 1.031000 10.75100 1.237000 10.75100 1.473000 10.39800 1.856000 9.985000 2.003000 9.367000 2.180000 8.984000 2.445000 8.807000 2.946000 8.748000 3.623000 8.984000 3.918000 9.602000 4.124000 10.36800 3.594000 11.34000 3.152000 11.95900 3.152000 11.48700 3.623000 10.45700 4.035000 9.750000 4.507000 9.750000 5.361000 9.396000 5.714000 9.190000 6.598000 9.161000 7.452000 8.954000 8.041000 8.895000 8.748000 8.954000 9.426000 8.984000 9.838000 9.485000 10.39800 9.956000 10.57400 10.66300 10.66300 11.10500 10.66300 11.57600 9.897000 12.10600 9.720000 12.54800 9.750000 13.13700 9.867000 13.90300 10.54500 14.34500 11.07500 14.69800 12.10600 14.72800 13.72600 14.22700 15.46400 14.02100 16.34800 13.25500 17.73200 12.01800 18.58600 10.48600 19.05700
Assuming that fitting is done to a straightforward one- dimensional histogram using essentially a minimization of chi2. Then the only complication is that the "error" in each bin, i.e. the error in the difference between the function curve and the bin contents, has an added component due to the fact that x is also not perfectly known. The usual technique is to calculate chi2 as the sum over bins of:
(n - f)2
-------------
dy2 + (f' dx)2
where n is the experimental bin content, f and f'
are respectively the
value of the function being fitted and its derivative, both taken at the
nominal value of x, and dx and dy are the errors
in x and y. (dy is
usually taken as the square root of n.) This clearly assumes that the
function being fitted is nearly a straight line inside a bin (or inside a
dx). If that is not true, the problem becomes highly non-linear and I
wouldn't believe the results of any fit.
The expression above is easy to calculate, since as you are looping over bins, you can remember the value of f from the previous bin and use that to estimate f'. Just watch out at both ends!
If the chi2 is calculated as indicated above and the approximations are valid, then all the other features of MINUIT (calculation of parameter errors, error matrix, contours, etc.) will automatically take account correctly of the errors in x and y.
Fred James
All the IGSET options are also available in SET. It is strongly recommended to use only SET to avoid mistakes.
Program CWN
*
Common /Pawc/ H(100000)
Parameter (Nmax = 100)
Common /CWN/ N,X(Nmax),Y(Nmax),Z(Nmax)
*.___________________________________________
*
Call Hlimit(100000)
*
Call Hropen(1,'CWN','cwn.hbook','N',1024,Istat)
If (Istat.Ne.0) Then
Print*, 'Error in opening file ...'
Stop
Endif
*
Call Hbnt(1,'CWN',' ')
Call Hbname(1,'Block1',N,'N[0,100], X(N), Y(N), Z(N)')
*
Do N=1,Nmax
Do I=1,N
X(N) = N*N
Y(N) = N*N*N
Z(N) = SIN(X(N))
EndDo
Call HFNT(1)
EndDo
*
Call Hrout(0,Icycle,' ')
Call Hrend('CWN')
*
end
sigma x=array(10,1#10)
v/li
application comis quit
Subroutine Square
VECTOR x,sqrx(10)
Do i = 1, 10
sqrx(i)=x(i)**2
Write (6,*) 'square of',x(i),sqrx(i)
Enddo
End
quit
call square
v/pri x
v/pri sqrx
In this example, the vector x is created via a PAW command
and is visible in the routine SQUARE. The vector SQRX doesn't
exists before SQUARE is called, so it is created with 10
entries.
(BSIZE+250)*N+20000 words
Where
BSIZE
is the Ntuple buffer size as can be set via the routine
HBSET
(default 1024 words).
The second part is taken by the RZ directory structure which contains the
keys that describe where the Ntuple extensions are stored (Ntuple extensions
are the column memory buffers which are flushed to disk, each extension has
a size of
BSIZE words).
For each key 6 words are needed. The number of keys
needed to store
M
events is dependent on the column packing factor (the
higher the packing factor is, the more events fit in a column buffer) and
on the
BSIZE
(the larger is
BSIZE
the fewer extensions need to be stored).
An upper limit is given by the key quota as specified in
HROPEN,
via
IQUEST(10)
(don't forget to include the
COMMON/QUEST/IQUEST(100)
in the routine where you call
HROPEN
). Assume you set
IQUEST(10)=65000
(the maximum) you will need at maximum:
65000*6 = 390000 words
Following from the above the maximum obtainable file size can easily be
determined:
IQUEST(10)*BSIZE*4 bytes
The number of events that can be stored in a file is approximately given by:
M = IQUEST(10)*BSIZE*packing/N
where packing is the average packing factor of all columns (all elements
of an array column are stored in the same buffer so they have a very small
packing factor).
PAW > call file.cwhere file.c is:
#include <stdio.h>
file_()
{
printf("this is a test\n");
}
Note that on some machine (HPUX, Linux ...) a "_" should
be added at the end of the procedure name. This is not necessary on all
machines just try both on your machine if you are unsure.
If you want to pass parameters, you should be careful to declare them as
pointers as FORTRAN passes parameters by address and C by value. Example:
#include <stdio.h>
file_(int *i)
{
int j=*i*100;
printf("this is a test %d\n",j);
}
this gives:
PAW > call file.c(123)
this is a test 12300
Note that if you want to call some CERNLIB Fortran subroutines
from a C program, your should use the
cfortran.h package.
Example:
Hi/fit 10 userf.f 0 6 parvalues
Application COMIS quit
Subroutine Set_names
Parameter (Npar=6)
Character*8 Names(Npar)
Names(1)='p1_name'
Names(2)=...
Call Hfinam(10,names,npar)
End
Quit
Call Set_names
Opt fit
Histo/Plot 10
Note the 0 option for CHOPT in Histo/Fit: the plot is not done by the fit
command.
If one of the names begins with "-", the parameters is not drawn when the option "FIT" is on.
The routine HGFIT (see HBOOK manual) return all the fit parameters including the parameter names. This routine takes the info from the HBOOK data structure.
SIGMA X=array(1000,1#10) SIGMA Y=sin(X)*X SIGMA Z=sin(X*X)*X call dvect.f(x,y,z)Where dvect.f is:
Subroutine Dvect(X,Y,Z)
Real X(1000)
Real Y(1000)
Real Z(1000)
Xmin = X(1)
Xmax = X(1)
Ymin = Y(1)
Ymax = Y(1)
Zmin = Z(1)
Zmax = Z(1)
Do i=2,1000
If (X(i).Lt.Xmin) Xmin=X(i)
If (X(i).Gt.Xmax) Xmax=X(i)
If (Y(i).Lt.Ymin) Ymin=Y(i)
If (Y(i).Gt.Ymax) Ymax=Y(i)
If (Z(i).Lt.Zmin) Zmin=Z(i)
If (Z(i).Gt.Zmax) Zmax=Z(i)
Enddo
Call Hplfr3(Xmin,Xmax,Ymin,Ymax,Zmin,Zmax,30.,30.,'FWB')
Call Ipm3(1000,X,Y,Z)
End
application comis quit
function func(x)
func=1.
end
subroutine funtest
external func
call hbfun1(10,'TEST hrndm1 ',100,0.,3.14,func)
End
quit
call funtest
To solve this problem, dynamic loading should be used i.e. put
funtest and func in the file funtest.f and do:
call funtest.f77
as describe
here
and in the PAW FAQ called "Dynamic linking".
Note that all the CERNLIB functions (for example HFITH, HFITV etc ...) using EXTERNAL will have the same problem when they are used via COMIS.
Macro Integral 1=0 2=0 3=0
*
* This Macro computes the Sum, Integral and the Mean Value of a given
* histogram between two channels. The input format should be:
* `inte ID CH_low CH_high', where `inte' is the alias to execute
* this kumac file, ID is the histogram id number, CH_low and
* CH_high are low and high channel numbers. All three numbers
* MUST be positive integers. - Yingchao Zhang
*
* Modified by : Olivier Couet (15th September 1994)
*
Trace off
If $VEXIST(Out)<>0 Then
V/Del Out
Endif
V/Create Out(3)
*
Application Comis Quit
Subroutine Integral(Id,Nl,Nh)
Character*80 Chtitl
Vector Out
Call Hgive(Id,Chtitl,Nx,Xmi,Xma,0,Ymi,Yma,Nwt,Loc)
If(Nl.Le.0) Nl=1
If(Nh.Ge.Nx) Nh=Nx
S = (Xma-Xmi)/Float(Nx)
W = 0.0
Y = 0.0
Z = 0.0
Do I = Nl,Nh
X = Xmi + (Float(I)-0.5)*S
Y = Y + Hx(Id,X)
W = W + Hx(Id,X)*X
EndDo
Z = Y*S
W = W/Y
Out(1) = Y
Out(2) = Z
Out(3) = W
End
Quit
*
* Check the input parameter
*
Id = [1]
Nl = [2]
Nh = [3]
If [Id] = 0 Then
Read Id 'Histogram identifier'
Endif
If [Nl] = 0 Then
Read Nl 'First channel'
Endif
If [Nh] = 0 Then
Read Nh 'Last channel'
Endif
*
* PLot the histogram and compute the integral
*
If $HEXIST([Id])=0 Then
Hrin [Id]
Endif
Histo/Plot [Id]([Nl]:[Nh])
Call Integral([Id],[Nl],[Nh])
Y = Out(1)
Z = Out(2)
W = Out(3)
Exec Rt 0.025 0.95 'Sum = '//[Y]
Exec Rt 0.025 0.90 'Integral = '//[Z]
Exec Rt 0.025 0.85 'Mean = '//[W]
V/Del Out
*
Return
Macro rt 1=0. 2=0. 3=' ' 4=.3
*
X1 = $GRAFINFO('WNXMIN')
X2 = $GRAFINFO('WNXMAX')
Y1 = $GRAFINFO('WNYMIN')
Y2 = $GRAFINFO('WNYMAX')
X = ([X2]-[X1])*[1]+[X1]
Y = ([Y2]-[Y1])*[2]+[Y1]
Set CHHE [4]
Set TXAL 3
Itx [X] [Y] [3]
*
Return
Macro DUPRWN
Close 0
Hi/File 1 hrztest.hbook
Hi/File 2 hrztest_new.hbook ! N
Nt/Dup //lun1/30 2
*
Application Comis Quit
Real Function Dup
Include ?
If (x.gt.0..and.y.gt.0.) call hfn(2,x)
dup=1.
end
Quit
*
nt/loop //lun1/30 dup
*
cd //lun2 |<------------------- For PAW version 2.07 only (see here)
*
hrout 2
*
* Verification: the 2 plots should be the same.
*
Option STAT
Zone 1 2
Nt/plot //lun1/30.x x.gt.0..and.y.gt.0.
Nt/plot //lun2/2.x
Macro DUPCWN1
*
Close 0 | Close all the currently opened file
H/file 1 hcwn.hbook | hcwn.hbook contains the ntuple to be duplicated
Hrin 1
Uwfunc //lun1/1 hcwn.inc | Copy the Ntuple structure into hcwn.inc
H/file 2 hcwn_new.hbook ! N | Create a new hbook file
Nt/Dup //lun1/1 11 | Duplicate the ntuple 1 in the ntuple 11
*
* Comis routine which Loop on all events of Id1 and select some events to be
* written in the new ntuple Id2.
*
Application COMIS quit
Subroutine ntdup(Id1,Id2)
Include 'hcwn.inc'
Call Hnoent(Id1,Noent)
Do Ievent=1,Noent
Call Hgnt(Id1,Ievent,Ierr)
If (Ierr.ne.0) Goto 20
If (Vx.Gt.0..Or.Vy.Gt.0.) Then
Call Hfnt(Id2)
Endif
Enddo
20 Continue
*
End
Quit
*
Call Ntdup(1,11) | Execute the routine Ntdup
Hrout 11 | Write Id2 on disk
*
* Verification: the 2 plots should be the same.
*
Option STAT
Zone 1 2
Nt/plot //lun1/1.vx vx.gt.0..or.vy.gt.0
Nt/plot //lun2/11.vx
*
Return
It is possible to do more in the fortran program:
Macro DUPCWN2
*
Close 0 | Close all the currently opened file
H/file 1 hcwn.hbook | hcwn.hbook contains the ntuple to be duplicated
Hrin 1 | Load the ntuple 1 in memory
Uwfunc //lun1/1 hcwn.inc | Copy the Ntuple structure into hcwn.inc
H/file 2 hcwn_new.hbook ! N | Create a new hbook file
*
Application COMIS quit
Subroutine ntdup(Id1,Id2)
include 'hcwn.inc'
*
* Duplicate structure of ntuple Id1 into Id2
*
Call Hntdup(Id1,Id2,-1,' ','A')
*
* Loop on all events of Id1. Select some events to be written
* in the new ntuple Id2.
*
Call Hnoent(Id1,Noent)
Do Ievent=1,Noent
Call Hgnt(Id1,Ievent,Ierr)
If (Ierr.Ne.0) Goto 20
If (Vx.Gt.0..Or.Vy.Gt.0.) Then
Call Hfnt(id2)
Endif
Enddo
20 Call Hrout(Id2,icycle,' ')
*
End
quit
*
Call Ntdup(1,11) | Execute the routine Ntdup
*
* Verification: the 2 plots should be the same.
*
Option STAT
Zone 1 2
Nt/plot //lun1/1.vx vx.gt.0..or.vy.gt.0
Nt/plot //lun2/11.vx
Note: Take care that the local variables used in the COMIS
routine are different from the field names in the Ntuple.
NT/LOOP 1 $1.AND.a.fwhere 1 is the ntuple identifier, $1 the graphical cut and a.f the LOGICAL fortran function (generated with the command UWFUNC) filling the new ntuple. The problem is that only the used ntuple variables in a.f will be loaded in the PAWCR4 common block. So you want all the variables in the new ntuple, you will have to use them all in a "dummy" way in a.f. For example you can do something like:
LOGICAL FUNCTION A
.
.
IF (IDNEVT.EQ.0) THEN
DUMMY = X1
DUMMY = X2
.
.
DUMMY = XI
..
ENDIF
.
.
END
where the XI are the all ntuple variables.
subroutine ac
character*16 filename
character*80 line
filename='data.hbook'
line = 'global/create filename '''//filename//''''
call kuexel(line)
end
Usage:
PAW > call ac.f
PAW > mess [filename]
data.hbook
macro quote
a = $quote('String test')
appl comis quit
subroutine test(c)
character*(*) c
print*, c
end
quit
call test([a])
Usage:
PAW > exe quote String test
HI/FIT 1 fff.f ! 1 par
the first thing this command do, is to set the pointer to the current
histogram to the histogram identified by
1 and it assumes this pointer
will not change during the command execution. This is usually the case with
"normal" fit functions.
The problem in different when HBOOK functions like
HCX,
HXI... are called
inside the fitting function because these functions (HCX, HXI...)
change the pointer to the current histogram and the fit command (which
assume this pointer doesn't change) point to the wrong histogram.
There is a way to fake the HI/FIT command. The following example shows
how to proceed:
macro f v/del *; h/del * zone 1 3 vector/create xx(10) r 1 2 3 4 5 5 4 3 2 1 vector/draw xx 1 sigma yy=3*xx vector/draw yy 2 vector/create par(1) r 1. histogram/fit 1 fff.f ! 1 parIn the following fitting function HFIND reset the current histogram before exiting the function.
function fff(x)
common /pawpar/ par(1)
y=hx(2,x)
call hfind(1,' ')
fff=y*par(1)
end
|
PAW > exe f
**********************************************
* *
* Function minimization by SUBROUTINE HFITH *
* Variable-metric method *
* ID = 1 CHOPT = *
* *
**********************************************
Convergence when estimated distance to minimum (EDM) .LT. 0.10E+01
FCN= 0.1500666E-11 FROM MIGRAD STATUS=CONVERGED 12 CALLS 13 TOTAL
EDM= 0.30E-11 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 P1 0.33333 0.60858E-01 0.23809E-02 -0.40413E-04
CHISQUARE = 0.1667E-12 NPFIT = 10
|
You must recreate your ntuple as a disk resident one (see the FAQ "How to create a disk resident Row Wise Ntuple").
appl data nt.dat
0 1 0.1
1 2 0.2
2 3 0.3
3 4 0.15
4 5 0.4
5 5 0.2
6 4 0.1
7 3 0.2
8 2 0.1
9 1 0.3
nt.dat
ntuple/create 1 'Test' 3 ! ! X Y EY
nt/read 1 nt.dat
appl comis quit
REAL FUNCTION A
REAL
+X ,Y ,EY
*
LOGICAL CHAIN
CHARACTER*128 CFILE
*
COMMON /PAWCHN/ CHAIN, NCHEVT, ICHEVT
COMMON /PAWCHC/ CFILE
*
COMMON/PAWIDN/IDNEVT,OBS(13),
+X ,Y ,EY
*
dimension xx(2),yy(2)
*
XX(1) = X
XX(2) = X
YY(1) = Y-EY
YY(2) = Y+EY
CALL IPL(2,XX,YY)
END
quit
set MTYP 20
nt/plot 1.y%x
nt/loop 1 A

Macro test
null 0 10 0 10 'ab'
igset txal 23
igset chhe 0.5
igset txfp -130
igset fais 1
igset fasi 0
igset faci 2
box 2 8 5 7
itx 5 6 'Example of text'
return
PAW > Exec test | with opt zfl1 in pawlogon.kumac
PAW > pi/print paw.ps
This problem can be avoid in 2 ways:
1)
PAW > for/file 66 paw.ps ; meta 66 -111
PAW > exec test
PAW > close 66
2)
PAW > exec test | with opt zfl1 in pawlogon.kumac
PAW > exe print
Where print is
macro print
for/file 66 paw.ps ; meta 66 -111
sel 1 ; izpict ' ' d
close 66
Note: IZPICT with option D draws the a picture without reordering the
normalisation transformations.
Example:
Fun2 2 x*y 40 0 1 40 0 1 ' '
V/Cr PAR(5) R .1 .11 .3 .31 .5
Set DMOD 1
set HCOL 1
Contour 2 1 2 PAR(1)
Do i=2,5
Set HCOl [i]
Contour 2 1 2S PAR([i])
Enddo
subroutine mess(lun,chmess)
character*(*) chmess
write (lun,'(a)') chmess
end
as follow:
PAW > output 22 a.dat
PAW > call mess.f(22,'hello')
If the character string is in a variable, the system function $QUOTE
should be used before calling the routine mess.f in order to enclose
the string with ' ':
a=$quote(hello)
output 22 a.dat
call mess.f(22,[a])
Macro Emat
Histo/fit 110(50:) G
Application COMIS Quit
Subroutine Get_Emat
Parameter (ndim=3)
Double Precision demat(ndim,ndim)
Vector Emat(ndim,ndim)
Call Mnemat(demat,ndim)
Do i=1,ndim
Do j=1,ndim
emat(j,i)=demat(j,i)
Enddo
Enddo
End
Quit
Call Get_Emat
Vector/Print Emat
Return
Note that the matrix is returned in a
DOUBLE Precision array.
It is copied into a single precision vector.
PROGRAM HTONEW
*
* Program to convert old format HBOOK files into new format
* New files are by default in RZ Exchange mode
* RWN are converted into CWN.
*
PARAMETER (MXBOOK=1000000)
COMMON/PAWC/ PAW(MXBOOK)
COMMON/QUEST/ IQUEST(100)
COMMON/HINFO/LRECL
*
CHARACTER*80 FILOUT,FILIN
*
EXTERNAL CONVERT
*
*===========================================================
*
print*, 'Input file ?'
read*, filin
print*, 'Output file ?'
read*, filout
lo = lenocc(filout)
li = lenocc(filin)
nsize = 0
*
CALL HLIMIT(MXBOOK)
CALL HBSET('BSIZE',100,IERR)
*
*
10 CONTINUE
*
*-* Create directory //PAWC/OLDF to store old ntuples
CALL HMDIR('OLDF',' ')
*-* Open old file and get record length
* LRECL=0 If LRECL=0 does not work,specify LRECL for your file
LRECL=NSIZE
CALL HROPEN(1,'OLDF',FILIN,' ',LRECL,ISTAT)
LRECL=IQUEST(10)
IF(ISTAT.NE.0) THEN
WRITE (6,'('' FILE : '',A80,'' CANNOT BE OPENED'')') FILIN(1:
+ LI)
GO TO 20
END IF
*
*-* Create new file
IQUEST(10) = 64000
if(lrecl.gt.4096)lrecl=4096
* lrecl=4096
print *,' Creating new file with LRECL=',lrecl,' words'
CALL HROPEN(2,'NEWF',FILOUT(1:LENOCC(FILOUT)),'QN',LRECL,ISTAT)
IF(ISTAT.NE.0) THEN
WRITE (6, '('' FILE : '',A80, '' CANNOT BE CREATED'')')
+ FILOUT(1:LO)
GOTO 20
END IF
*
*
*-* Convert
CALL HCDIR('//OLDF',' ')
CALL RZSCAN (' ', CONVERT)
CALL HREND ('NEWF')
CLOSE (2)
CALL HREND ('OLDF')
CLOSE (1)
*
WRITE (6,'('' Conversion completed'')')
*
* Abnormal end
20 CONTINUE
*
END
SUBROUTINE CONVERT (CDIR)
*
CHARACTER*(*) CDIR
*
INTEGER NWPAW,IXPAWC,IHDIV,IXHIGZ,IXKU, LMAIN
REAL FENC , HCV
COMMON/PAWC/NWPAW,IXPAWC,IHDIV,IXHIGZ,IXKU,FENC(5),LMAIN,HCV(9989)
INTEGER IQ ,LQ
REAL Q
DIMENSION IQ(2),Q(2),LQ(8000)
EQUIVALENCE (LQ(1),LMAIN),(IQ(1),LQ(9)),(Q(1),IQ(1))
INTEGER HVERSN,IHWORK,LHBOOK,LHPLOT,LGTIT,LHWORK,
+LCDIR,LSDIR,LIDS,LTAB,LCID,LCONT,LSCAT,LPROX,LPROY,LSLIX,
+LSLIY,LBANX,LBANY,LPRX,LPRY,LFIX,LLID,LR1,LR2,LNAME,LCHAR,LINT,
+LREAL,LBLOK,LLBLK,LBUFM,LBUF,LTMPM,LTMP,LTMP1,LHDUM ,LCIDN
COMMON/HCBOOK/HVERSN,IHWORK,LHBOOK,LHPLOT,LGTIT,LHWORK,
+LCDIR,LSDIR,LIDS,LTAB,LCID,LCONT,LSCAT,LPROX,LPROY,LSLIX,
+LSLIY,LBANX,LBANY,LPRX,LPRY,LFIX,LLID,LR1,LR2,LNAME,LCHAR,LINT,
+LREAL,LBLOK,LLBLK,LBUFM,LBUF,LTMPM,LTMP,LTMP1,LHDUM(10),LCIDN
*
INTEGER KNCX ,KXMIN ,KXMAX ,KBWIDX ,KMIN ,KMAX ,KNORM ,
+ KTIT1 ,KNCY ,KYMIN ,KYMAX ,KBWIDY ,KSCAL2 ,
+ KTIT2 ,KNBIT ,KNOENT ,KSTAT1 ,KNSDIR ,KNRH ,
+ KCON1 ,KCON2 ,KBITS ,KNTOT
PARAMETER(KNCX=3,KXMIN=4,KXMAX=5,KBWIDX=6,KMIN=7,KMAX=8,KNORM=9,
+ KTIT1=10,KNCY=7,KYMIN=8,KYMAX=9,KBWIDY=10,KSCAL2=11,
+ KTIT2=12,KNBIT=1,KNOENT=2,KSTAT1=3,KNSDIR=5,KNRH=6,
+ KCON1=9,KCON2=3,KBITS=1,KNTOT=2)
parameter (kip1=20)
*
COMMON/QUEST/ IQUEST(100)
*
COMMON/HINFO/LRECL
*
CHARACTER*80 TITLE, RDIR
*
parameter (nev=1000)
parameter (nmax=500)
parameter (nbvmax=40)
parameter (ntotmax=50000000)
dimension x(nmax,nev)
common/event/y(nmax)
dimension iy(nmax)
equivalence (y(1),iy(1))
character*8 tags(nmax),tag1,bname
character*1300 chform
character*1 type
dimension rlow(nmax),rhigh(nmax)
*
WRITE (6, '('' Processing directory: '',A)')
+ CDIR(1:LENOCC(CDIR))
*
RDIR = CDIR
RDIR(3:6) = 'NEWF'
JLS = ICFILA ('/', CDIR, 1, LENOCC(CDIR))
IF (JLS .GT. 2) THEN
CALL HMDIR (RDIR, ' ')
END IF
*
*-* Loop on all keys in file (order of creation)
NKEY = 50000
DO 80 M = 1, NKEY
CALL HCDIR (CDIR, ' ')
CALL RZINK (M, 0, 'S')
IF (IQUEST(1) .NE. 0) GO TO 999
IF (JBIT (IQUEST(14),4) .NE. 0) GO TO 80
IDN = IQUEST(21)
CALL HRIN(IDN,999,0)
IF(IQUEST(1).NE.0) THEN
WRITE (6,'('' NTUPLE OR HISTO '',I10,'' CANNOT BE READ'')')
+ IDN
GO TO 90
END IF
IF (JBIT (IQ(LCID+KBITS),4) .NE. 0) THEN
*-* ntuple
*-* First read the specs of old ntuple
NVAR = NMAX
CALL HGIVEN(IDN,TITLE,NVAR,TAGS,RLOW,RHIGH)
call hnoent(idn,noent)
ntotal=min(ntotmax,noent)
CALL HDELET(IDN)
*-* Change directory to new file. Create new ntuple
*-* Put a maximum of NBVMAX variable per block (hbname)
*-* Blocks are labelled Block1,Block2,etc.
*-* Buffer size per column is set to (nwpaw-100000)/nvar or lrecl-15 words
nwbuf1=(nwpaw-100000)/nvar
if(nwbuf1.gt.33000)nwbuf1=33000
if(nwbuf1.gt.noent)then
nwbuf=noent+1
else
nwmod=mod(nwbuf1,lrecl)
nwbuf=nwbuf1-nwmod-15
endif
** nwbuf=nwbuf1
** if(nwbuf1.gt.lrecl-15)nwbuf=lrecl-15
** if(nwbuf1.gt.2*lrecl-15)nwbuf=2*lrecl-15
if(nwbuf.lt.100)nwbuf=min(noent,nwbuf1)
call hbset('BSIZE',nwbuf,ierr)
print *,' Converting ntuple:',idn,' Bsize =',nwbuf,' words'
call hcdir(rdir,' ')
*-* We want to force new ntuple record to start at word 1 of a new record
lrzcdir=iquest(11)
iq(lrzcdir+kip1)=lrecl+1
call rzmods('CONVER',ierr)
call rzsave
CALL HBNT(IDN,TITLE,' ')
chform=' '
icold=1
nbn=0
type='R'
do 10 i=1,nvar
tag1=tags(i)
if(tag1.eq.' ')then
write(tag1,30000)i
30000 format('VAR',I3)
if(tag1(4:4).eq.' ')tag1(4:4)='0'
if(tag1(5:5).eq.' ')tag1(5:5)='0'
endif
nch=lenocc(tag1)
icnew=icold+nch+2
chform(icold:icnew)=tag1(1:nch)//':'//type//','
if(mod(i,nbvmax).eq.0.or.i.eq.nvar)then
nbn=nbn+1
if (nbn.ge. 1 .and. nbn.lt. 10) then
write(bname,10000)nbn
10000 format('Block',i1)
elseif (nbn.ge. 10 .and. nbn.lt. 100) then
write(bname,10001)nbn
10001 format('Block',i2)
elseif (nbn.ge.100 .and. nbn.lt.1000) then
write(bname,10002)nbn
10002 format('Block',i3)
else
print *, 'CONVERT: In trouble, NBN = ',nbn
bname = 'BlockXYZ'
endif
ibl=(nbn-1)*nbvmax +1
call hbname(idn,bname,y(ibl),chform(1:icnew-1))
icnew=0
chform=' '
endif
icold=icnew+1
10 continue
*
*
*-* Now loop to fill new ntuple.
*-* To avoid changing directory too frequently, buffer NEV events in memory
do 60 i=1,ntotal,nev
print *,' Number of events processed= ',i
call hcdir('//PAWC/OLDF',' ')
call hcdir(cdir,' ')
do 20 j=1,nev
k=i+j-1
if(k.gt.ntotal)go to 30
call hgn(idn,nidn,k,x(1,j),ierror)
20 continue
30 continue
call hcdir('//PAWC',' ')
call hcdir(rdir,' ')
do 50 j=1,nev
k=i+j-1
if(k.gt.ntotal)go to 70
do 40 l=1,nvar
y(l)=x(l,j)
40 continue
call hfnt(idn)
50 continue
60 continue
70 continue
*-* save new ntuple header onto file
call hrout(idn,icycle,' ')
call hdelet(idn)
call hcdir('//PAWC/OLDF',' ')
call hdelet(0)
call hcdir('//PAWC',' ')
ELSE
*-* Histogram
call hcdir(rdir,' ')
call hrout(idn,icycle,' ')
CALL HDELET(IDN)
END IF
80 CONTINUE
GO TO 999
*
* Abnormal end
90 CONTINUE
*
999 END
SELNT 1 | Select the centimetres
TEXT 1 1 'Hello' .3
| Resource name | type | default value | meaning |
|---|---|---|---|
| noKxterm | Boolean | False | if set to True no kxterm window is opened |
| noMBrowser | Boolean | False | if set to True no Main Browser is opened |
| higzMessGeometry | String | "0x0+0+0" | size and position of the HIGZ output window |
| kxtermGeometry | String | "650x450+0+0" | |
| kxtermTextFont | String | "*-courier-medium-r-normal*-120-*" | |
| kxtermFont | String | "*-helvetica-bold-r-normal*-120-*" | |
| centerCommand | int | 0 (False) | if True, command panels are centred in main browser |
| scrolledCmdPanel | String | "auto" | if set to "always" add a scroll bar in command panels. |
| panelInteractive | Boolean | True | if set to True "Close" button is set non sensitive in panels |
| doubleClickInterval | int | 250 | |
| helpFont | String | "*-courier-medium-r-normal*-120-*" | |
| doubleBuffer | Boolean | True | |
| gBell | int | 0 | bell volume when grabbing |
| mainCursor | int | -1 | |
| graphCursor | int | -1 | |
| inputCursor | int | -1 | |
| waitCursor | int | -1 | |
| helpCursor | int | -1 | |
| helpCursor | int | -1 | |
| busyCursor | int | -1 | |
| blckCursor | int | -1 | |
| selcCursor | int | -1 |
| Resource name | type | default value | meaning |
|---|---|---|---|
| dirlist*fontList | String | "*-courier-bold-r-normal*-120-*" | |
| kuipBrowser*fileScWindow.width | int | 80 | |
| kuipBrowser*fileScWindow.bottomOffset | int | 52 | |
| kuipBrowser*fileScWindow.topOffset | int | 59 | |
| kuipBrowser*dirScWindow.bottomOffset | int | 52 | |
| kuipBrowser*dirScWindow.topOffset | int | 59 | |
| kuipBrowser*separatorGadget1.topPosition | int | 50 | |
| kuipBrowser_shell.geometry | String | "-0+0" (no graphics) or "+0+485" (graphics) | |
| kuipGraphics_shell.geometry | String | "600x600-0+0" | graphics window geometry |
| Resource name | type | default value | meaning |
|---|---|---|---|
| iconBitmap | String | "default_icon" | |
| iconMask | String | "default_mask" | |
| iconSmallBitmap | String | "default_sicon" | |
| iconSmallMask | String | "default_smask" | |
| iconForeground | String | "black" "grey40" in Paw++ | |
| iconBackground | String | "white" | |
| iconLabelForeground | String | "black" | |
| iconLabelBackground | String | "white" | |
| iconWidth | Dimension | 40 | |
| iconHeight | Dimension | 40 | |
| iconSmallWidth | Dimension | 20 | |
| iconSmallHeight | Dimension | 20 | |
| iconHSpacing | int | 40 | |
| iconVSpacing | int | 10 | |
| iconSmallHSpacing | int | 20 | |
| iconSmallVSpacing | int | 10 | |
| iconNoHSpacing | int | 20 | |
| iconNoVSpacing | int | 10 | |
| iconType | int | IconBoxBIG_ICON | possible values: IconBoxSMALL_ICON, IconBoxNO_ICON |
| shadowOffset | int | 3 | |
| columns | int | 5 | |
| shadowColor | String | "gray50" | |
| fontList | String | "fixed" | |
| zoomEffect | Boolean | True | |
| zoomSpeed | int | 10 | |
| doubleClickInterval | int | 250 |
| Resource name | type | default value | meaning |
|---|---|---|---|
| autorefresh | Boolean | True | |
| echokuip | Boolean | False | |
| doublebuffer | Boolean | True | |
| samezone | Boolean | False | |
| hbookfile | String | hbook | default file extension for HBOOK files. |
| histoStyle_shell.geometry | String | "+670+635" | histogram style panel geometry. |
| dirlist*dir*iconForeground | String | "blue" | |
| dirlist*1d*iconForeground | String | "DarkGoldenrod3" | |
| dirlist*2d*iconForeground | String | "DeepPink3" | |
| dirlist*ntuple*iconForeground | String | "SteelBlue3" | |
| dirlist*pict*iconForeground | String | "green4" | |
| dirlist*chain*iconForeground | String | "blue" | |
| dirlist*entry*iconForeground | String | "OrangeRed" | |
| dirlist*Cmd*iconForeground | String | "cyan4" | |
| dirlist*Menu*iconForeground | String | "blue" | |
| dirlist*MacFile*iconForeground | String | "OliveDrab4" | |
| dirlist*hbook*iconForeground | String | "red" | |
| dirlist*piafhb*iconForeground | String | "red" | |
| dirlist*iconLabelForeground | String | "white" | |
| dirlist*iconLabelBackground | String | "black" | |
| dirlist*fontList | String | "*-courier-bold-r-normal-*-120-*" | |
| XmText*fontList | String | ||
| XmTextField*fontList | String | ||
| kxtermTextFont | String | ||
| helpFont | String | ||
| fontList | String | ||
| kxtermFont | String | ||
| keyboardFocusPolicy | String | "pointer" | other value: "explicit" |
| doubleClickInterval | int | 400 |
For setting all the Kxterm built-in resources for an application "Appl"
(e.g. "Paw++") one has to prefix the application class name with "Kx".
E.g.:
KxAppl*background: white
to set the background colour of Kxterm for application Appl.
KxPaw++*background: white
to set the background colour of Kxterm for application Paw++.
PAW > For/File 66 paw.ps PAW > Meta 66 -111 PAW > Exec My_macro PAW > Close 66To generate a PostScript with the picture currently on the screen do the following:
in your
pawlogon.kumac put:
OPTION ZFL1
and when you want to produce the PostScript file of what you have on the screen do:
PICTURE/PRINT PAW.PS
This will save the current picture on the screen in the file
PAW.PS
Note that the command OPTION * resets all the default options and will also cancel the OPTION ZFL1. So if you want to keep it you will have to do again OPTION ZFL1 each time you do OPTION *.
Example:
PAW > FUN/PLOT sin(x) -3 3
draws the sinus function between -3 and 3. Note that the command
FUN/PLOT creates and fills the
temporary histogram 12345.
It is also possible to fill an histogram with a function with the command
FUN1:
PAW > FUN1 10 sin(x) 100 -3 3
-[Format][Nx][Ny][Type]Where:
\begin{figure}
\includegraphics{example.eps}
\caption{Example of Encapsulated PostScript in LaTeX.}
\label{EXAMPLE}
\end{figure}
You may also want to clip the Encapsulated PostScript when you include it in
a Latex file using something like:
\begin{center}
\fbox{\includegraphics[bb=100 100 200 200, clip=]{example.eps}}
\end{center}
And you will not get what you expect ie. the image will not be clipped.
The problem comes from the fact that in order to always have a clean and
exact clipping in the PostScript file produced by HIGZ, the
clipping mechanism provided by PostScript itself is used. The HIGZ
"clipping" it is not only the clipping at the image boundary but the all
the clipping on the various zones (Normalisation transformation). This works
fine and that way one always get a very good clipping even on complicated
shapes, texts, polygons with patterns etc ... BUT, that doesn't
fit very well in Encapsulated PostScript files. In the PostScript description
manual it is even mentioned that using clipping operator is not recommended
in Encapsulated PostScript files. Most of the time it doesn't create
any problems because in most cases one want to see the whole plot produced.
Only a in few cases that can be a problem. To bypass that it is enough to
save the following line is a file (clipeps
for instance):
cat $1 | sed -e "s/systemdict begin initclip end//" > $2and do:
$ clipeps example.eps example2.epsthe file example2.eps will be properly clipped by the Latex directive given before.
To illustrate the PostScript metafile type usage we will use the following macro, converted into PostScript files with various PostScript metafile types.
Macro Test
set *fon -60
v/create x1(10) r 1 2 3 4 5 5 4 3 2 1
v/create x2(10) r 5 4 3 2 1 1 2 3 4 5
v/create x3(10) r 3 4 5 5 4 3 2 1 2 3
v/create x4(10) r 4 5 5 4 3 2 1 2 3 4
set htyp 354 ; v/draw x1
set htyp 345 ; v/draw x2
set htyp 390 ; v/draw x3
set htyp 344 ; v/draw x4
return
The conversion to PostScript is done via the following commands where
we will vary the metafile_type value.
PAW > FORTRAN/FILE 65 paw.ps
PAW > METAFILE 65 metafile_type
PAW > EXEC TEST
PAW > CLOSE 65
Some examples are given in the following list:
If you do H/PLOT id they are plotted randomly in each cell and the number of points is proportional to the cell content. If you use NT/PLOT id.v1.%v2 they are plotted at their real position.
Example:
SET * ; NULL 0 10 0 10 | Draw a frame
TEXT 5 1 'Left justified' .5 0. L
TEXT 5 2 'Centred' .5 0. C
TEXT 5 3 'Right justified' .5 0. R
SET TXAL 10*i+j
where
i
indicates the horizontal alignment (0,1: left; 2: center; 3:
right) and
j
the vertical alignment (0: bottom; 1 or 2: top;
3:center) as describe on the following picture.
H/PLOT 10(1:10) | Bin numbers (integer range)
H/PLOT 10(0.5:1.) | Axis value (floating point range)
H/PLOT 20(1:10,0.5:1.) | 2D histos
For vectors:
VECTOR/DRAW X(10:20)
For Ntuples:
NT/PLOT 1.X 10.le.X.ge.100
You can also do:
NULL X1 X2 Y1 Y2
And any
H/PLOT,
V/PLOT or
N/PLOT performed with
option
S will be in the range
X1 X2 Y1 Y2.
The command RANGE set the range for FUN/DRAW.
And the H/SET/MIN and H/SET/MAX commands set the range of the dependent variable (the bin height). For a 1D histogram, these set the Y range; for a 2D histogram, the same commands set the Z range.
Macro getxy
Hrin [1]
Nx=$hinfo([1],'xbins')
Ny=$hinfo([1],'ybins')
V/cre x([Nx])
V/cre y([Ny])
Application Comis Quit
subroutine getxy(id)
vector x,y
character*80 title
call hgive(id,title,nx,xmin,xmax,ny,ymin,ymax,nwt,iad)
dx=(xmax-xmin)/float(nx)
dy=(ymax-ymin)/float(ny)
do i=1,nx
x(i)=xmin+dx*float(i-1)
enddo
do i=1,ny
y(i)=ymin+dy*float(i-1)
enddo
end
Quit
Call getxy([1])
Return
Example of usage
PAW > exe getxy 4
PAW > v/pri x ; v/pri y
PAW > SET * ; OPT * ; ZONE 2 2 ; OPT GRID ; SET GRID 12 PAW > nul 0 1 PAW > set basl 0.001 PAW > nul 0 1 PAW > set dash 0.2 PAW > nul 0 1 PAW > set dash 0.5 PAW > nul 0 1
zone 2 2 V/cr x(10) r 1 2 3 4 5 5 4 3 2 1 V/dr x 1 V/cr par(3) r 1 2 3 Application HMINUIT exit Migrad Minos Show cov Show err Mnc 1 2 C Exit Hi/Fit 1 G M 3 parWhen the third parameter is used in the MNC command, PAW creates automatically two vectors (with 51 points) called XFIT and YFIT that can be used outside the Application HMINUIT with the command GRAPH for example. Note that the MINUIT directives between Application HMINUIT exit and exit should be in column 1 in the macro.
Normal PAW commands can be executed inside
Application HMINUIT
if they are prefixed with a
+ sign. For example to save the
vectors XFIT and
YFIT
for later use, you can include the two
following lines inside the
Application HMINUIT:
+v/copy xfit xfit1
+v/copy yfit yfit1
The graphic output of this macro is the following:
PAW > Set YVAL 999 | suppress the X labels PAW > Set XVAL 999 | suppress the Y labels
|
Nul 0 1 0 1 | Produce the first plot
Nul 0 1 0 10 AS | Refine the Y scale on the current plot
Tic XR 0.25 ! | Draw a vertical axis at the X position 0.25
Nul 0 1 0 100 AS
Tic XR 0.5 !
Nul 0 1 0 1000 AS
Tic XR 0.75 !
Nul 0 1 0 10000 AS
Tic XR 1.00 !
|
SET HCOL 1103 H/PLOT 10With the SET command it is possible to specify both the border and the inside color for the Histogram, Box Page, and Function (HCOL, BCOL, PCOL, FCOL).
Example:
+---- 1 The Histogram is filled
| 0 Only the border is drawn
|+--- Border color (here 1) if the histogram is filled
||++- Inside color (here 3) if the histogram is filled
|||| Border color if the histogram is not filled
||||
VVVV
SET HCOL 1103.
The same mechanism is also available for FCOL, BCOL and PCOL.
PAW> HISTO/FIT 1.PROX Gis NOT valid ... The way to proceed is the following:
PAW> HISTO/COPY 1.PROX 2 PAW> HISTO/FIT 2 G
More arguments seems to work but "by chance" only. Passing more arguments may have unpredictable effects.
For more details see the specifications of the new query processor
PAW > output_lp 66 scan.dat
PAW > nt/san 10
PAW > close 66
Note that the command
NTUPLE/DUMP is able do output in a file
FILECASE KEEPin your pawlogon.kumac file.
H/del *
Appl data nt.dat
0 1 0.1 1.8
1 2 1.1 2.2
2 3 2.1 3.8
3 4 3.1 4.8
4 5 4.1 5.2
5 5 5.1 5.8
6 4 6.1 4.2
7 3 7.1 8.8
8 2 8.1 2.2
9 1 9.1 1.2
nt.dat
Nt/Create 4 'Test' 4 ! ! X Y PX PY
Nt/Read 4 nt.dat
Null -1 10 -1 10
Appl comis Quit
REAL FUNCTION ntarr
REAL
+X ,Y ,PX ,PY
*
LOGICAL CHAIN
CHARACTER*128 CFILE
*
COMMON /PAWCHN/ CHAIN, NCHEVT, ICHEVT
COMMON /PAWCHC/ CFILE
*
COMMON/PAWIDN/IDNEVT,OBS(13),
+X ,Y ,PX ,PY
*
Dimension a(2),b(2),u(3),v(3)
*
a(1) = X
a(2) = PX
b(1) = Y
b(2) = PY
*
Arrow_size = 0.2
Arrow_width =0.3
fsin=0.
fcos=1.
xl=sqrt((a(2)-a(1))**2 + (b(2)-b(1))**2)
if(xl.gt.0.)then
fsin=(b(2)-b(1))/xl
fcos=(a(2)-a(1))/xl
endif
u(1)=a(1)+(xl-Arrow_size)*fcos-Arrow_size*Arrow_width *fsin
u(3)=a(1)+(xl-Arrow_size)*fcos+Arrow_size*Arrow_width *fsin
v(1)=b(1)+(xl-Arrow_size)*fsin+Arrow_size*Arrow_width *fcos
v(3)=b(1)+(xl-Arrow_size)*fsin-Arrow_size*Arrow_width *fcos
u(2)=a(2)
v(2)=b(2)
*
Call Igset('FAIS',1.)
Call Ipl(2,a,b)
Call Ifa(3,u,v)
*
ntarr=1.
*
END
Quit
nt/loop 4 ntarr

The following HBOOK batch program create a disk resident RWN. A direct access HBOOK file should be opened before the creation of the Ntuple. The name of the top directory created by HROPEN is given to HBOOKN. The file is used to flush the memory buffer on disk when necessary.
Program Ntuple
*
Parameter (Memory_Size = 50000)
Parameter (Number_of_Events = 100000)
Parameter (Number_of_Variables = 27)
*
Common /Pawc/ H(Memory_Size)
Dimension Event(Number_of_Variables)
Character*8 Chtags(Number_of_Variables)
Data Chtags /'A1','A2','A3','A4','A5','A6','A7','A8','A9',
+ 'B1','B2','B3','B4','B5','B6','B7','B8','B9',
+ 'C1','C2','C3','C4','C5','C6','C7','C8','C9'/
*.___________________________________________
*
Call Hlimit(Memory_Size)
*
Call Hropen(1,'EXAMPLE','example.hbook','N',1024,Istat)
If (Istat.Ne.0) Then
Print*, 'Error in opening file ...'
Stop
Endif
*
Call Hbookn(10,'Ntuple example',27,'EXAMPLE',9000,Chtags)
*
Do 10 I=1,Number_of_Events
Do 20 J=1,Number_of_Variables
Event(j) = Sqrt(Float(i))*Float(j)
20 Continue
Call Hfn(10,Event)
10 Continue
*
Call Hrout(0,Icycle,' ')
Call Hrend('EXAMPLE')
*
End
It is also possible to create a such Ntuple in PAW:
PAW > HI/FILE 1 example.hbook ! N
PAW > NT/CREATE 10 'Ntuple example' 1 //LUN1 ! A1 ...
PAW > NT/READ ...
H/del *
Appl data nt.dat
0 1 5 0.1 1.8 5.1
1 2 4 1.1 2.2 4.1
2 3 3 2.1 3.8 3.1
3 4 2 3.1 4.8 2.1
4 5 1 4.1 5.2 1.1
5 5 1 5.1 5.8 1.1
6 4 2 6.1 4.2 2.1
7 3 3 7.1 8.8 3.1
8 2 4 8.1 2.2 4.1
9 1 5 9.1 1.2 5.1
nt.dat
Nt/Create 4 'Test' 6 ! ! X Y Z PX PY PZ
Nt/Read 4 nt.dat
call hplfr3(0.,10.,0.,10.,0.,10.,30.,30.,'WBF')
Set MTYP 4
Set MSCF 0.7
Appl comis Quit
REAL FUNCTION ntarr
REAL
+X ,Y ,PX ,PY
*
LOGICAL CHAIN
CHARACTER*128 CFILE
*
COMMON /PAWCHN/ CHAIN, NCHEVT, ICHEVT
COMMON /PAWCHC/ CFILE
*
COMMON/PAWIDN/IDNEVT,OBS(13),
+X ,Y ,Z ,PX ,PY ,PZ
*
Dimension a(2),b(2),c(2),u(3),v(3)
*
a(1) = X
a(2) = PX
b(1) = Y
b(2) = PY
c(1) = Z
c(2) = PZ
*
Call Ipl3(2,a,b,c)
Call Ipm3(1,PX,PY,PZ)
*
ntarr=1.
*
END
Quit
nt/loop 4 ntarr

Note that the user's data do not have to be in double precision, but anything that is a function of the free parameters must be in double precision with respect to the parameters. The data can be in single precision because it doesn't change during the fit.
By default, the command
UWFUNC
generate function of type REAL. This
type is not always the right one. For example in an expression like
PAW > nt/loop select.f.and.$1
the left and right part of the .and.
should be
of type boolean.
The solutions are:
PAW > nt/loop bool(select.f).and.$1
PAW > nt/loop (select.f.ne.0).and.$1
PAW > nt/loop select.f.and.$1
/NTUPLE/LOOP: Warning: boolean '.AND.' converted to '*' for backward compatibilityEven if it is a warning, it is better to fix it to be sure to obtain the correct result.
More informations on the new ntuple query processor are available here.
*
* Create some vectors
*
v/del *
sigma x = array(100,-1#1)
sigma y = x*x+rndm(x)*0.1
sigma ey= array(100,0.1#0.1)
v/cr par(3) r 1 1 1
*
* Perform the fit
*
v/fit x y ey p2.f 0 3 par
*
* Delete the original vectors and create new
* vectors to get the fit result
*
v/del x,y,ey
v/cre p2x(100)
v/cre p2y(100)
*
* Function to get the fit result
*
appl comis quit
subroutine getfit
vector p2x,p2y
x = -1.
dx = 2./100.
do i=1,100
p2x(i) = x
p2y(i) = p2(x)
x = x + dx
enddo
end
quit
*
* Get the fit result and plot it
*
call getfit
graph 100 p2x p2y
The function used to do the fit (file p2.f) is:
FUNCTION P2(X)
COMMON/PAWPAR/PAR(3)
P2=PAR(1)*X*X+PAR(2)*X+PAR(3)
END
|
|
nt/plot 1.10to plot the variable number 10 in the ntuple 1. This was not a good feature because it generated a lot of ambiguities in the expressions parsing. So this feature has been removed in the query processor implemented in the PAW version after 2.07. To emulate this functionality with PAW version older than 2.07, the following macro can be used:
Macro plot_nt_nevt
Hrin [1]
Application COMIS quit
integer function ntnum(id,i)
parameter (maxvar=100)
character*80 chtitl,line
character*80 chtag(maxvar)
dimension rlow(maxvar),rhigh(maxvar)
nvar=maxvar
call hgiven(id,chtitl,nvar,chtag,rlow,rhigh)
if(i.gt.nvar)then
ntnum=1
print*, 'Variable number requested > NVAR (',nvar,')'
else
ntnum=0
line = 'global/create varname '//chtag(i)
call kuexel(line)
endif
end
quit
Ierr=$ICALL('ntnum('//[1]//','//[2]//')')
If [Ierr]=0 Then
nt/plot [1].[varname]
Endif
Return
The input parameters are the ntuple identifier and the variable numbers.
The following example plot the variable number 3 of the ntuple number 10.
PAW > exec plot_nt_nevt 10 3
More informations on the new ntuple query processor are available here.
SUBROUTINE HNTVAR(ID1,IVAR,CHTAG,BLOCK,NSUB,ITYPE,ISIZE,IELEM)This routine returns the tag, block, type, size and array length of the variable with index IVAR in N-tuple ID1. N-tuple must already be in memory.
Program add_block
*
Common /Pawc/ H(100000)
Parameter (Nmax = 300)
Common /CWN/ N,X,Y,Z
*.___________________________________________
*
Call Hlimit(100000)
*
Call Hropen(1,'CWN','cwn.hbook','N',1024,Istat)
If (Istat.Ne.0) Then
Print*, 'Error in opening file ...'
Stop
Endif
*
Call Hbnt(1,'CWN',' ')
Call Hbname(1,'BLOCK1',N,'N')
Call Hbname(1,'BLOCK2',X,'X')
*
Do N=1,Nmax
Do I=1,N
X = 10.*N
EndDo
Call HFNTB(1, 'BLOCK1')
Call HFNTB(1, 'BLOCK2')
EndDo
*
Call Hrout(0,Icycle,' ')
Call Hrend('CWN')
Close(1)
*
Call Hropen(1,'CWN','cwn.hbook','U',1024,Istat)
If (Istat.Ne.0) Then
Print*, 'Error in opening file ...'
Stop
Endif
Call Hrin (1,9999,0)
Call Hbname (1,' ',0,'$CLEAR')
Call Hbname (1,'BLOCK1',N,'$SET')
Call Hbname (1,'BLOCK2',X,'$SET')
*
Call Hbname(1,'BLOCK3',Y,'Y')
Call Hbname(1,'BLOCK4',Z,'Z')
*
Do N=1,Nmax
Do I=1,N
Y = 100.*N
Z = 1000.*N
EndDo
Call HFNTB(1, 'BLOCK3')
Call HFNTB(1, 'BLOCK4')
EndDo
*
Call Hrout(0,Icycle,' ')
Call Hrend('CWN')
Close(1)
*
End
When using HBOOK, I find that my jobs tend to crash with
ZEBRA dumps if I try to create a large ntuple.
All it does is to create and fill a large (80 MB) ntuple.
In this job, the buffer size given in the call to HBOOKN, is specified by the
parameter LBUF. If I run the job with:
When a Row-Wise-Ntuple is created, HBOOK keeps in memory a directory with a key and a pointer corresponding to each logical record (ntuple buffer) written to the disk file. If a buffer size of NPRIME words (parameter in HBOOKN) is declared, this buffer can accommodate up to NEBUF=NPRIME/Ncolumns entries. When the buffer is full after NEBUF events, it is written to the file and one entry is added to the directory in memory. Each entry requires 7 words.
Macro offset_example
*
Appl Sigma Quit
x =array(20,0#3)
y1=sin(x)
y2=sin(x*x)
y3=sin(x+0.2)
Quit
*
Option BAR
set BARW 0.33
set BARO 0
set HCOL 1102 ; v/draw y1
set BARO 0.33
set HCOL 1103 ; v/draw y2 chopt=s
set BARO 0.66
set HCOL 1104 ; v/draw y3 chopt=s
*
Return

The following setting are necessary:
To remove the axis:
Set XTIC 0.001
Set YTIC 0.001
Set XVAL 1000
Set YVAL 1000
To remove the histogram box:
color 9 1 1 1
Set BCOL 9
histo/create/proy 111 histo/project 111 histo/plot 111.proyThe above piece of code will plot the projection of 2D histogram 111 onto the y axis. If you want the projection onto the x axis just replace proy with prox in the above piece of code.
Important Remark:
When the projections are filled the filling routine for 1D histogram is called for each projected bin of the 2D i histogram. In case of PROX and PROY all the bins are used so the number of calls to the 1D histogram filling routine is equal to NX*NY (NX and Ny being the number of bin along X and Y axis). So to summarize, the number of entries you get for the projection is equal to the total number of bins of the 2D histogram. So it is meaningless.
Negative weights yield meaningless results.
When weights different from 1. are used, the errors are calculated properly only for bins with non-zero spread, and set to 0. for bins with zero spread.
Errors for the CHOPT='I' option are calculated in the same way (as those for the 'S' option.)
TEXT 10 10 'A^b&!?c!' 0.4 0. 'C'
and the
b
and
c
will come out vertically aligned.

PAW > HMERGE OUT1 IN1 IN2 PAW > HMERGE OUT2 IN3 IN4The first merge works as advertised, but the second merge includes IN1,IN2 as well as IN3,IN4. To avoid this problem perform the command H/DEL * between the two HMERGE commands.
Before PAW version 2.07
you can get the error message:
***** ERROR in PECRIT : OVERFLOW IN ICODE STACK :
The ICODE stack is the place where the ntuple query processor
keeps a translated version of your expressions and selection function.
It also has to store all the translated expressions which make up the
combination of cuts $1, which are quite a few.
With PAW version older than 2.07 you can try to reduce the size of the
selection expression by using masks.
Example:
*
* create a mask file named mymask.mask for ntuple up to 20000 events
* change the number if necessary
*
mask mymask n 20000
nt/cuts $1 -
nt/cuts $2 -
nt/cuts $3 -
nt/cuts $3 (x=1.).or.(x=2.).or.(x=3.).or.(x=4.).or.(x=5.)
nt/cuts $2 (x=1.).or.(x=2.).or.(x=7.).or.(x=8.)
n/loop 5000 $3>>mymask(1)
n/loop 5000 $2>>mymask(2)
nt/cuts $1 mymask(1).and.mymask(2)
n/loop 5000 $1>>mymask(3)
*
* The final cut should not give an overflow anymore.
*
nt/plot 1.x $1.and.$1.and.$1.and.$1.and.$1
Workstation type (?=HELP)
Just typing CR will set the default value.The default value depends on the PAW installation.
Typing ? will give a short help listing all the different possible workstation types.
Any other answer will be interpreted as a workstation type.
The X11 version of PAW (pawX11) accept also workstation types like: n or n.hostname where n (an integer between 1 and 10) is the line number in the file higz_windows.dat and hostname is the name of the machine on which the graphics will be displayed.
Remark: In the file higz_windows.dat, it is possible to specify the name of the window just after the hostname.
Example:0000 0000 0600 0600 hphigz.cern.ch PAW window 0600 0000 0300 0300 0000 0000 0600 0600 0000 0000 0600 0600 0000 0000 0600 0600 0000 0000 0600 0600 0000 0000 0600 0600 0000 0000 0600 0600 0000 0000 0600 0600 0000 0000 0600 0600
zone 1 1
For/file 66 paw.ps ; meta 66 -331
h/pl 1 colz
h/pl 2 colz
h/pl 3 colz
....
close 66
Since the version 2.07/22 of PAW this size follows the VSIZ attribute (SET command).
I'm writing out ntuples in a job and sometimes
get the error messages:
RZOUT: Directory too big: previous cycle(s) deleted, KEY(1)= 501
RZOUT: Directory too big: previous cycle(s) deleted, KEY(1)= 502
RZOUT: Directory too big: previous cycle(s) deleted, KEY(1)= 503
When nTuples are being created, the underlying memory manager Zebra must occasionally write a new directory record so that the nTuple can be accessed correctly after it is closed. For large nTuples it can happen that the space remaining in the direct access nTuple file is insufficient to create the new directory entry. In this case, the warning/error message you mention is received, and Zebra deletes a previous cycle of the directory to gain space. The new cycle is then written.
PAW > SET FAIS n
"n" may have the value 0, 1, or 3.
All the other values are
not valid.
n = 0 The polygon is drawn in hollow mode n = 1 The polygon is drawn in solid mode n = 3 Hatch mode.If n=3 it is possible to choose the type of hatches. This is done with the fill are style index attribute. It can be changed with the command:
PAW > SET FASI m
"m" may have several value describe in
the PAW manual.
Note that in hollow and hatch mode, the border of the box can be drawn if the attribute BORD is set to 1.
Example:
Nul 0 10 0 10
Set FAIS 0
Box 1 3 1 3
Set FAIS 1
Box 1 3 3 5
Set FAIS 3
Set FASI 245
Box 1 3 5 7
Set FASI 3
Box 3 5 5 7
Set BORD 1
Set FASI 4
Box 5 7 5 7

|
PAW > opt utit
PAW > title 'New title' U
PAW > h/pl 10
|
Try:
PAW > EXE MOVE ?
PAW > FUN2 101 SIN(X)*COS(Y) 40 -1.57 1.57 40 -1.57 1.57
PAW > EXEC MOVE 101 102 -3.24 3.24 -3.24 3.24
Where the macro move.kumac is:
MACRO MOVE
*
* This macro will take a 2-d histograms and move it into a bigger
* histogram. Movement will be done with vectors.
*
* This is provided as a starting basis and doesn't cover all cases.
*
* Robert C. Welsh Univ of Michigan Physics Dept.
* Feb 1995
*
IF [1] .EQ. '?' THEN
MESSAGE
MESSAGE This macro will move a 2d histogram with some limits into a new one
MESSAGE Usage:
MESSAGE MOVE [HIST#] [NEW HIST#] [XMinNew] [XMaxNew] [YMinNew] [YMaxNew]
MESSAGE
EXITM
ENDIF
HIST1 = [1]
HIST2 = [2]
XMNNEW = [3]
XMXNEW = [4]
YMNNEW = [5]
YMXNEW = [6]
XMIN = $HINFO([HIST1],'XMIN')
XMAX = $HINFO([HIST1],'XMAX')
YMIN = $HINFO([HIST1],'YMIN')
YMAX = $HINFO([HIST1],'YMAX')
NXOLD = $HINFO([HIST1],'XBINS')
NYOLD = $HINFO([HIST1],'YBINS')
DX = $RSIGMA(([XMAX]-[XMIN])/[NXOLD])
DY = $RSIGMA(([YMAX]-[YMIN])/[NYOLD])
NXNEW = $SIGMA(INT( ([XMXNEW] - [XMNNEW])/[DX]))
NYNEW = $SIGMA(INT( ([YMXNEW] - [YMNNEW])/[DY]))
V/CREATE TMP1([NXOLD],[NYOLD])
V/CREATE TMP2([NXNEW],[NYNEW])
TITLE = $HTITLE([HIST1])
IF $HEXIST([HIST2]).NE.0 THEN
MESSAGE You are overwriting a preexisting histogram!
H/DEL [HIST2]
ENDIF
2D [HIST2] [TITLE] [NXNEW] [XMNNEW] [XMXNEW] [NYNEW] [YMNNEW] [YMXNEW]
GET/CONT [HIST1] TMP1
I1 = $SIGMA(INT(([NXNEW]-[NXOLD])/2))-1
I2 = $SIGMA(INT(([NYNEW]-[NYOLD])/2))
IX = 0
IY = 1
DO IX=1,[NXOLD]
I1 = [I1] + 1
V/COPY TMP1(1:,[IX]) TMP2([I2]:,[I1])
ENDDO
PUT/CONT [HIST2] TMP2
V/DEL TMP1,TMP2
RETURN
>Name welcomedef >Menu /KUIP >Command welcome >Parameters + CHOPT 'Options' C D='E' -E English version -F French version >Guidance Print a "welcome" message. Message can be either in English (default) or in French. >Action welcomeCompile this CDF with the kuipc compiler:
> kuipc welcomedef.cdf welcomedef.cThis will generate a file welcomedef.c.
The following is the corresponding action routine "welcome" in a file
welcome.c:
#include <stdio.h>
#define R_OK 0
#define R_ERROR 1
void welcome_()
{
char mode, *s;
int r;
r = R_OK;
/* determine mode E (English) or F (French) */
switch( ku_npar() ) {
case 0:
mode = 'E';
break;
case 1: /* check */
s = ku_getc();
if ( *s == 'E' || *s == 'F' ) {
mode = *s;
} else {
printf( "welcome: Illegal option(s).\n" );
r = R_ERROR;
}
break;
default:
printf( "welcome: Illegal option(s).\n" );
r = R_ERROR;
break;
}
if ( r == R_ERROR ) return;
if ( mode == 'E' ) {
printf ("*** Welcome to Paw++ \n\n");
printf (" For any kind of help type: \n");
printf (" Paw++> help
N.B.: for COMIS the C routine name must be welcome_ (with an underscore).
We can group the commands you must execute (to make this new command available)
in a small KUIP macro (file welcome.kumac):
Macro welcome
App COMIS quit
!file welcome.c
quit
CALL welcomedef.c
Consequently you must just type on the command line (Paw or Paw++):
PAW > exec welcome
You can check that the command is known by typing:
PAW > help welcome
which will give you:
Command "/KUIP/welcome" :
* KUIP/welcome [ CHOPT ]
CHOPT C 'Options' D='E'
Possible CHOPT values are:
E English version
F French version
Print a "welcome" message. Message can be either in English (default) or
in French.
Note: in Paw++ if you want the command to be visible in the menu ``Commands''
in the ``Paw++ Main Browser'' you must not access this menu before
executing the macro welcome but only after (for efficiency reasons
the menu is built once for ever the first time it is accessed).
Paw++*XmText.translations: #override \n\
Ctrl b: backward-character()\n\
Alt b: backward-word()\n\
Meta b: backward-word()\n\
Shift Alt b: backward-word(extend)\n\
Shift Meta b: backward-word(extend)\n\
Alt [: backward-paragraph()\n\
Meta [: backward-paragraph()\n\
Shift Alt [: backward-paragraph(extend)\n\
Shift Meta [: backward-paragraph(extend)\n\
Alt <: beginning-of-file()\n\
Meta <: beginning-of-file()\n\
Ctrl a: beginning-of-line()\n\
Shift Ctrl a: beginning-of-line(extend)\n\
Ctrl osfInsert: copy-clipboard()\n\
Shift osfDelete: cut-clipboard()\n\
Shift osfInsert: paste-clipboard()\n\
Alt >: end-of-file()\n\
Meta >: end-of-file()\n\
Ctrl e: end-of-line()\n\
Shift Ctrl e: end-of-line(extend)\n\
Ctrl f: forward-character()\n\
Alt ]: forward-paragraph()\n\
Meta ]: forward-paragraph()\n\
Shift Alt ]: forward-paragraph(extend)\n\
Shift Meta ]: forward-paragraph(extend)\n\
Ctrl Alt f: forward-word()\n\
Ctrl Meta f: forward-word()\n\
Ctrl d: kill-next-character()\n\
Alt BackSpace: kill-previous-word()\n\
Meta BackSpace: kill-previous-word()\n\
Ctrl w: key-select() kill-selection()\n\
Ctrl y: unkill()\n\
Ctrl k: kill-to-end-of-line()\n\
Ctrl u: beginning-of-line() kill-to-end-of-line()\n\
Alt Delete: kill-to-start-of-line()\n\
Meta Delete: kill-to-start-of-line()\n\
Ctrl o: newline-and-backup()\n\
Ctrl j: newline-and-indent()\n\
Ctrl n: next-line() \n\
Ctrl osfLeft: page-left()\n\
Ctrl osfRight: page-right()\n\
Ctrl p: previous-line() \n\
Ctrl g: process-cancel()\n\
Ctrl l: redraw-display()\n\
Ctrl osfDown: next-page()\n\
Ctrl osfUp: previous-page()\n\
osfDown: next-line() \n\
osfUp: previous-line() \n\
Ctrl space: set-anchor()
Paw++*XmTextField.translations: #override \n\
Ctrl b: backward-character()\n\
Alt b: backward-word()\n\
Meta b: backward-word()\n\
Shift Alt b: backward-word(extend)\n\
Shift Meta b: backward-word(extend)\n\
Ctrl a: beginning-of-line()\n\
Shift Ctrl a: beginning-of-line(extend)\n\
Ctrl osfInsert: copy-clipboard()\n\
Shift osfDelete: cut-clipboard()\n\
Shift osfInsert: paste-clipboard()\n\
Ctrl e: end-of-line()\n\
Shift Ctrl e: end-of-line(extend)\n\
Ctrl f: forward-character()\n\
Ctrl Alt f: forward-word()\n\
Ctrl Meta f: forward-word()\n\
Ctrl u: beginning-of-line() delete-to-end-of-line()\n\
Ctrl osfLeft: page-left()\n\
Ctrl osfRight: page-right()\n\
Ctrl g: process-cancel()\n\
Ctrl space: set-anchor()
do i=1,10
fun1 [i] x*x 100 0 [i]
enddo
*
v/create mean(10)
do i=1,10
m = $hinfo([i],'MEAN')
v/input mean([i]) [m]
enddo
v/print mean
PAW > hi/fit 10 gis performed in PAW a screen output is given by PAW/Minuit:
**********************************************
* *
* Function minimization by SUBROUTINE HFITGA *
* Variable-metric method *
* ID = 10 CHOPT = TU *
* *
**********************************************
Convergence when estimated distance to minimum (EDM) .LT. 0.10E+01
FCN= 271.7804 FROM MIGRAD STATUS=CONVERGED 56 CALLS 57 TOTAL
EDM= 0.26E-04 STRATEGY= 1 ERROR MATRIX ACCURATE
EXT PARAMETER STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 Constant 151.91 2.1465 1.0634 -0.27620E-02
2 Mean -0.72353E-02 0.13767E-01 0.80668E-02 0.76994E-01
3 Sigma 1.1178 0.88523E-02 0.43773E-02 -0.93417
CHISQUARE = 0.2802E+01 NPFIT = 100
In this output several values are given.
The meaning of these various parameters is:
WARNING: The Chi2 value printed here is in fact not the real Chi2 but
is chi2/NDF
where NDF is:
(NBins - NPar) = [number of bins in histogram] - [number of free parameters in the fit]
The graphical display of a fit result with
OPTION FIT on, gives a correct label.
For backward compatibility reasons it is difficult to change the labelling
produced by the HI/FIT printout, because
it may break some applications reading this printout.
With one Zone you can do:
PAW > H/PL 10
PAW > H/PL 11 +
but with several zones one should do:
PAW > ZONE 2 2
PAW > H/PL 10 K
PAW > H/PL 11 +
As an example, the macro:
set * ; opt * ; h/del *
zone 2 2
v/create x(10) r 1 2 3 4 5 5 4 3 2 1
v/create y(10) r 5 4 3 2 1 1 2 3 4 5
v/draw x 1 ; v/draw y 2
set htyp 245
h/pl 1 k ; set htyp 254 ; h/pl 2 +
h/pl 2 k ; set htyp 245 ; h/pl 1 +
produce:

A given histogram can be kept only once per page. If
you keep the same histograms several time the first one is retain.
You can see this effect by keeping twice the histogram 1 in the
previous example:
set * ; opt * ; h/del *
zone 2 2
v/create x(10) r 1 2 3 4 5 5 4 3 2 1
v/create y(10) r 5 4 3 2 1 1 2 3 4 5
v/draw x 1 ; v/draw y 2
set htyp 245
h/pl 1 k ; set htyp 254 ; h/pl 2 +
h/pl 1 k ; set htyp 245 ; h/pl 1 +
The output is now:

In addition to these "Ntuple COMMON blocks" some other COMMON
block variables are also available. Namely:
COMMON /PAWIDN/ IDNEVT,OBS
COMMON /PAWCHN/ CHAIN, NCHEVT, ICHEVT
COMMON /PAWCHC/ CFILE
The meaning of these variables is the following:
shell 'ls *.hbook | sed -e ''s/^/h\/file 0 /'' > junk.kumac' exe junk shell rm junk.kumac
I used both HFITHN and HFITGA routines to fit a Gaussian,
for instance:
CALL HFITHN(1017,'G',' ',3,PAR,STEP,PMIN,PMAX,SIGPAR,CHI2)
CALL HFITGA(1017,C,AV,SD,CHI2,IC,SIG)
I didn't obtain the same result. Why, I guess these two calls
are equivalent, aren't they ?
To avoid the problem encountered here, the initial values of the
parameters should not be equal to zero. For example, do something like:
dimension par(3),step(3),pmin(3),pmax(3)
par(1) = 1.
par(2) = 1.
par(3) = 1.
CALL HFITHN(10,'G',' ',3,PAR,STEP,PMIN,PMAX,SIGPAR,CHI2)
and HFITHN
will give the same result as
HFITGA.
Program Group_Ntuple
*
Parameter (Nhmax = 100000)
Common /Pawc/ Hmemor(Nhmax)
Common /P/ A,B,C,D,E,F
*
Call Hlimit(Nhmax)
*--------------------------------------------------
* Create and fill the Ntuple 1
*
Call Hropen(10,'P1','p1.hbook','N',1024,Ista)
If (Ista.Ne.0) Stop
Call Hbnt(1,'Test','D')
Call Hbname(1,'P1',A,'A,B,C')
*
Do I=1,10
A = Float(I)
B = Float(10*I)
C = Float(100*I)
Call Hfnt(1)
EndDo
*
Call Hrout(0,IC,'')
Call Hrend('P1')
Close(10)
*--------------------------------------------------
* Create and fill the Ntuple 2
*
Call Hropen(10,'P2','p2.hbook','N',1024,Ista)
If (Ista.Ne.0) Stop
Call Hbnt(2,'Test','D')
Call Hbname(2,'P2',D,'D,E,F')
*
Do I=1,10
D = Float(1000*I)
E = Float(10000*I)
F = Float(100000*I)
Call Hfnt(2)
EndDo
*
Call Hrout(0,IC,'')
Call Hrend('P2')
Close(10)
*--------------------------------------------------
* Reset the common block
*
Do I=1,10
A = 0.
B = 0.
C = 0.
D = 0.
E = 0.
F = 0.
EndDo
*--------------------------------------------------
* Create and fill the Ntuple 3 from
* ntuples 1 and 2
*
Call Hropen(30,'P3','p3.hbook','N',1024,Ista)
If (Ista.Ne.0) Stop
Call Hbnt(3,'Test','D')
Call Hbname(3,'P3',A,'A,B,C,D,E,F')
*
Call Hropen(10,'P1','p1.hbook','U',1024,Ista)
If (Ista.Ne.0) Stop
Call Hrin (1,9999,0)
Call Hbname (1,' ',0,'$CLEAR')
Call Hbname (1,'P1',A,'$SET')
Call Hnoent (1,Noent1)
*
Call Hropen(20,'P2','p2.hbook','U',1024,Ista)
If (Ista.Ne.0) Stop
Call Hrin (2,9999,0)
Call Hbname (2,' ',0,'$CLEAR')
Call Hbname (2,'P2',D,'$SET')
Call Hnoent (2,Noent2)
*
Noent = Min(Noent1,Noent2)
*
Do I=1,Noent
Call Hcdir('//P1',' ')
Call Hgnt(1,I,Ierr)
Call Hcdir('//P2',' ')
Call Hgnt(2,I,Ierr)
Call Hcdir('//P3',' ')
Call Hfnt(3)
EndDo
*
Call Hrout(3,IC,'')
Call Hrend('P1')
Call Hrend('P2')
Call Hrend('P3')
Close(10)
Close(20)
Close(30)
*
End
The scanning of the ntuple 1 in PAW++ gives:

The scanning of the ntuple 2 in PAW++ gives:

The scanning of the ntuple 3 in PAW++ gives:

It is also possible to transfer it in alphanumeric mode from a machine A to a machine B as follow:
On machine A do:
PAW > hi/file 1 myfile.hbook
PAW > toa myfile.alf
transfer "myfile.alf" to machine B. And on machine B do:
PAW > hi/file 1 myfile.hbook ! N
PAW > fra myfile.alf
Macro CWN_Merge
*
* Close all the open files
*
Close 0
*
* Define the lists of file
*
Nb = ... | Number of files
name1 = ...
name2 = ...
name3 = ...
.
.
.
name[nb] = ...
*
* Define the selection function
*
IdN1 = ... | Ntuple identifier in the input file
IdN2 = ... | Ntuple identifier in the output file
H/file 1 [name1]
hrin [IdN1]
Uwfunc [IdN1] source.inc
Application COMIS quit
Subroutine ntdup(Id1,Id2)
Include 'source.inc'
Call Hnoent(Id1,Noent)
Noent = min(Noent,100)
Do Ievent=1,Noent
Call Hgnt(Id1,Ievent,Ierr)
If (Ierr.ne.0) Goto 20
If ( ... ) Call Hfnt(Id2)
Enddo
Return
20 write(*,*)'error ',ierr,'in ',ievent
End
Quit
close 1
*
* Create the files with selection
*
FilesChain = ' '
Do i=1,[Nb]
H/file 1 [name[i]]
hrin [IdN1]
NewFile = new[i].hbook
H/file 2 [NewFile] ! N
Nt/Dup //lun1/[IdN1] [IdN2]
Call Ntdup([IdN1],[IdN2])
Hrout [IdN2]
close 1
close 2
FilesChain = [FilesChain]//' '//[NewFile]
Enddo
*
* Merge all the new files in only one
*
Hmerge new.hbook $UNQUOTE([FilesChain])
Note: Take care that the local variables used in the COMIS
routine are different from the field names in the Ntuple.
Program Read_Two_Ntuples
*
Parameter (Nhmax = 100000)
Common /Pawc/ Hmemor(Nhmax)
Common /P1/ A,B,C
Common /P2/ D,E,F
*
Call Hlimit(Nhmax)
*--------------------------------------------------
* Create and fill the Ntuple 1
*
Call Hropen(10,'P1','p1.hbook','N',1024,Ista)
If (Ista.Ne.0) Stop
Call Hbnt(1,'Test','D')
Call Hbname(1,'P1',A,'A,B,C')
*
Do I=1,10
A = Float(I)
B = Float(10*I)
C = Float(100*I)
Call Hfnt(1)
EndDo
*
Call Hrout(0,IC,'')
Call Hrend('P1')
Close(10)
*--------------------------------------------------
* Create and fill the Ntuple 2
*
Call Hropen(10,'P2','p2.hbook','N',1024,Ista)
If (Ista.Ne.0) Stop
Call Hbnt(2,'Test','D')
Call Hbname(2,'P2',D,'D,E,F')
*
Do I=1,100
D = Float(1000*I)
E = Float(10000*I)
F = Float(100000*I)
Call Hfnt(2)
EndDo
*
Call Hrout(0,IC,'')
Call Hrend('P2')
Close(10)
*--------------------------------------------------
* Reset the common blocks
*
Do I=1,10
A = 0.
B = 0.
C = 0.
D = 0.
E = 0.
F = 0.
EndDo
*--------------------------------------------------
* Read the two Ntuples in two loops.
*
Call Hropen(10,'P1','p1.hbook','U',1024,Ista)
If (Ista.Ne.0) Stop
Call Hrin (1,9999,0)
Call Hbname (1,' ',0,'$CLEAR')
Call Hbname (1,'P1',A,'$SET')
Call Hnoent (1,Noent1)
*
Call Hropen(20,'P2','p2.hbook','U',1024,Ista)
If (Ista.Ne.0) Stop
Call Hrin (2,9999,0)
Call Hbname (2,' ',0,'$CLEAR')
Call Hbname (2,'P2',D,'$SET')
Call Hnoent (2,Noent2)
*
Do I=1,Noent1
Call Hcdir('//P1',' ')
Call Hgnt(1,I,Ierr)
print*, 'Ntuple 1: I = ',I,' A = ',A,' B = ',B,' C = ', C
JStart = (I-1)*10+1
JEnd = JStart+9
Do J=JStart,JEnd
Call Hcdir('//P2',' ')
Call Hgnt(2,I,Ierr)
print*, ' Ntuple 2: J = ',J,' D = ',D,' E = ',E,' F = ', F
EndDo
EndDo
*
Call Hrend('P1')
Call Hrend('P2')
Close(10)
Close(20)
*
End
It is also possible, and in fact even simpler, to perform the same thing on
ntuples sitting in the same HBOOK file. The program in that case looks
the following:
Program Read_Two_Ntuples
*
Parameter (Nhmax = 100000)
Common /Pawc/ Hmemor(Nhmax)
Common /P1/ A,B,C
Common /P2/ D,E,F
*
Call Hlimit(Nhmax)
*--------------------------------------------------
* Create and fill the Ntuple 1
*
Call Hropen(10,'NTUPLES','ntuples.hbook','N',1024,Ista)
If (Ista.Ne.0) Stop
Call Hbnt(1,'Test','D')
Call Hbname(1,'P1',A,'A,B,C')
*
Do I=1,10
A = Float(I)
B = Float(10*I)
C = Float(100*I)
Call Hfnt(1)
EndDo
*--------------------------------------------------
* Create and fill the Ntuple 2
*
Call Hbnt(2,'Test','D')
Call Hbname(2,'P2',D,'D,E,F')
*
Do I=1,100
D = Float(1000*I)
E = Float(10000*I)
F = Float(100000*I)
Call Hfnt(2)
EndDo
*
Call Hrout(0,IC,'')
Call Hrend('NTUPLES')
Close(10)
*--------------------------------------------------
* Reset the common blocks
*
Do I=1,10
A = 0.
B = 0.
C = 0.
D = 0.
E = 0.
F = 0.
EndDo
*--------------------------------------------------
* Read the two Ntuples in two loops.
*
Call Hropen(10,'NTUPLES','ntuples.hbook','U',1024,Ista)
If (Ista.Ne.0) Stop
Call Hrin (1,9999,0)
Call Hbname (1,' ',0,'$CLEAR')
Call Hbname (1,'P1',A,'$SET')
Call Hnoent (1,Noent1)
*
Call Hrin (2,9999,0)
Call Hbname (2,' ',0,'$CLEAR')
Call Hbname (2,'P2',D,'$SET')
Call Hnoent (2,Noent2)
*
Do I=1,Noent1
Call Hgnt(1,I,Ierr)
print*, 'Ntuple 1: I = ',I,' A = ',A,' B = ',B,' C = ', C
JStart = (I-1)*10+1
JEnd = JStart+9
Do J=JStart,JEnd
Call Hgnt(2,I,Ierr)
print*, ' Ntuple 2: J = ',J,' D = ',D,' E = ',E,' F = ', F
EndDo
EndDo
*
Call Hrend('NTUPLES')
Close(10)
*
End
To read two CW-Ntuples simultaneously in PAW the simplest is to do the
NT/LOOP
command on the first ntuple and to load, as in the batch program, the
other ntuple within the
UWFUNC
generated function. After having done:
PAW > hi/file 1 p1.hbook PAW > uwfunc 1 r1.f PAW > hi/file 2 p2.hbook PAW > uwfunc 2 r2.fYou should modify the function r1.f taking the common block declaration of the ntuple 2 in r2.f. The modified r1.f is (added code in red):
REAL FUNCTION r1()
*********************************************************
* *
* This file was generated by HUWFUN. *
* *
*********************************************************
*
* Ntuple Id: 1
* Ntuple Title: Test
* Creation: 26/07/1999 11.23.40
*
*********************************************************
*
LOGICAL CHAIN
CHARACTER*128 CFILE
INTEGER IDNEVT,NCHEVT,ICHEVT
REAL OBS(13)
*
COMMON /PAWIDN/ IDNEVT,OBS
COMMON /PAWCHN/ CHAIN, NCHEVT, ICHEVT
COMMON /PAWCHC/ CFILE
*
*-- Ntuple Variable Declarations
*
REAL A,B,C
*
COMMON /PAWCR4/ A,B,C
*
REAL D,E,F
*
COMMON /NT2/ D,E,F
*
if (idnevt.eq.1) then
Call Hbname (2,' ',0,'$CLEAR')
Call Hbname (2,'P2',D,'$SET')
Call Hnoent (2,Noent2)
Endif
*
print*, 'Ntuple 1: A = ',A,' B = ',B,' C = ', C
Call Hcdir('//LUN2',' ')
Call Hgnt(2,idnevt,Ierr)
print*, 'Ntuple 2: D = ',D,' E = ',E,' F = ', F
*
END
Having this function it is enough to do:
PAW > hrin 2 PAW > cd //lun1 PAW > nt/loop 1 r1.fwhich produces:
Ntuple 1: A = 1.000000 B = 10.00000 C = 100.0000 Ntuple 2: D = 1000.000 E = 10000.00 F = 100000.0 Ntuple 1: A = 2.000000 B = 20.00000 C = 200.0000 Ntuple 2: D = 2000.000 E = 20000.00 F = 200000.0 Ntuple 1: A = 3.000000 B = 30.00000 C = 300.0000 Ntuple 2: D = 3000.000 E = 30000.00 F = 300000.0 Ntuple 1: A = 4.000000 B = 40.00000 C = 400.0000 Ntuple 2: D = 4000.000 E = 40000.00 F = 400000.0 Ntuple 1: A = 5.000000 B = 50.00000 C = 500.0000 Ntuple 2: D = 5000.000 E = 50000.00 F = 500000.0 Ntuple 1: A = 6.000000 B = 60.00000 C = 600.0000 Ntuple 2: D = 6000.000 E = 60000.00 F = 600000.0 Ntuple 1: A = 7.000000 B = 70.00000 C = 700.0000 Ntuple 2: D = 7000.000 E = 70000.00 F = 700000.0 Ntuple 1: A = 8.000000 B = 80.00000 C = 800.0000 Ntuple 2: D = 8000.000 E = 80000.00 F = 800000.0 Ntuple 1: A = 9.000000 B = 90.00000 C = 900.0000 Ntuple 2: D = 9000.000 E = 90000.00 F = 900000.0 Ntuple 1: A = 10.00000 B = 100.0000 C = 1000.000 Ntuple 2: D = 10000.00 E = 100000.0 F = 1000000.
NTUPLE/PLOT 30.X SELECT.FOR
which worked fine with previous versions of PAW. Now gives the
error message:
/NTUPLE/PLOT: Wrong number of arguments for 'SELECT.FOR' (expect 1)
Since the version 2.07/22 of PAW, the ntuple query processor does more error checking. Here, SELECT.FOR is called without arguments but it requires one. There is two solutions:
NTUPLE/PLOT 30.X SELECT.FOR(1.)
Since PAW version 2.08/14 the command UWFUNC generates the functions without parameters. The PAW user should decides how many he wants (max 10).
More informations on the ntuple query processor are available here.
Macro hl
Output_lp 66 junk
H/Li s
Output_lp -66
Appl comis Quit
Subroutine hlist(Id1,Id2)
Character*80 Chline
Open(UNIT=66,FILE='junk',FORM='FORMATTED',STATUS='OLD')
20 Read (66,10,end=999) Chline
10 Format(A)
Read (Chline,'(I12)',Err=20) I
If (I.Ge.Id1.and.I.Le.Id2) Then
J = lenocc(Chline)
Print*, Chline(1:J)
Endif
Goto 20
999 Close(66)
End
Quit
call hlist([1],[2])
shell rm junk | Unix only
return
Just do:
Exec hl 10 20and only the histograms with IDs between 10 and 20 will be listed.
Example:
PAW > opt logy
PAW > nul 1 2 1 1000000
gives:
PAW > opt logy
PAW > set ndvy 3
PAW > nul 1 2 1 1000000
gives:
I draw a histogram as follows:
set hcol 4
set htyp -4
h/pl 100
On my terminal screen I can see a blue graph with blue hatching
as expected, but if I open a PostScript output file
the histogram is not hatched (I am looking at the PS file with
ghostview). Why?
The -4 hatching type is not supported on PS. Try instead:
set htyp 254
On a Sun running openwin with shared libraries, you may need to put the path for the library containing XKeysymDB *first* in the path list in LD_LIBRARY_PATH, or it may find the wrong XKeysymDB in the wrong directory.
N.B. XKeysymDB simply contains the registered keysym values for the OSF keysyms. The OSF values are server-independent. And, all registered keysyms will be included in an XKeysymDB file to be shipped with X11R5. In the meantime (till all systems are X11R5+), a list of the registered keysyms can be found in the X11R4 release in mit/doc/Registry/Xregistry.
Macro Redraw-Axis
X1 = $GRAFINFO('WNXMIN')
X2 = $GRAFINFO('WNXMAX')
Y1 = $GRAFINFO('WNYMIN')
Y2 = $GRAFINFO('WNYMAX')
IS = $GRAFINFO('?FAIS')
IC = $GRAFINFO('?FACI')
Set FAIS 0 ; Set FACI 1
Box [X1] [X2] [Y1] [Y2]
Set FAIS [IS] ; Set FACI [IC]
Tick XL [X1] !
Tick YB ! [Y1]
Return
just do:
PAW > Exe Redraw-Axis
and the axis of the current zone will be refreshed.
function maxbin(id)
character*80 chtitl
call hgive(id,chtitl,nx,xmin,xmax,ny,ymin,ymax,nwt,idb)
w = hi(id,1)
maxbin = 1
do i=2,nx
w2 = hi(id,i)
if (w2.gt.w) then
w = w2
maxbin = i
endif
enddo
end
One way to access it, is:
PAW > message $ICALL('maxbin.f(110)')
Macro Mnstat
Histo/fit 110(50:) G
Application COMIS Quit
Subroutine Get_Stat
Vector Stat(6)
Call Mnstat(Fmin,Fedm,Errdef,Npari,Nparx,Istat)
Stat(1) = Fmin
Stat(2) = Fedm
Stat(3) = Errdef
Stat(4) = Npari
Stat(5) = Nparx
Stat(6) = Istat
End
Quit
Call Get_Stat
Vector/Print Stat
Return
Example:
fun2 2 abs(sin(x)/x*cos(y)*y) 40 -12 12 40 -12 12 ' '
exec proxy 2
The macro proxy is:
Macro proxy
Id=[1]
opt grid
prox [Id]
proy [Id]
h/pro [Id]
*
set ywin 0.0001
set xwin 0.0001
set yval 999 ; set yhti 999
*
set grid 2003
zone 2 2
h/pl [Id].prox
*
set grid 3
zone 2 2 3 s
set yhti ; set yval
h/pl [Id] col
set yhti 999
*
set grid 1003
set xval 999
nb = $HINFO([Id],'YBINS')
v/create x([nb])
v/create y([nb])
h/copy [Id].proy 22
xmax = 1.1*$HINFO(22,'MAX')
ymin = $HINFO(22,'XMIN')
ymax = $HINFO(22,'XMAX')
null $HINFO(22,'MIN') [xmax] [ymin] [ymax]
get/cont 22 y
get/abs 22 x
nn = [nb]-2
v/inp x [ymin] [ymax] [nn]*0
his [nb] y x rh
*
set xwin ; set ywin; set xval
zone 2 2 2 s
h/pl [id] surf
return
The output produced is:
Example:
PAW > Exec reltext 25 75 'Hello'
Draw a text 75% from the bottom and 25% of the left of the current NT.
Macro Reltext 1=100 2=100 3=' '
X1 = $GRAFINFO('WNXMIN')
X2 = $GRAFINFO('WNXMAX')
Y1 = $GRAFINFO('WNYMIN')
Y2 = $GRAFINFO('WNYMAX')
DX = [X2]-[X1]
X = [1]/100.
X = [DX]*[X]
X = [X]+[X1]
DY = [Y2]-[Y1]
Y = [2]/100.
Y = [DY]*[Y]
Y = [Y]+[Y1]
Itx [X] [Y] [3]
*
Return
macro tdz
application comis quit
!file dzero.f
Subroutine TDZ
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
integer mxf
external DZF
a=0
b=3.
r=1.e-4
eps=1.e-7
mxf=10000
call dzero(a,b,x0,r,eps,mxf,dzf)
print *,' Zero of function at X0=',x0
end
double precision function dzf(x,i)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
integer i
a=2.
dzf=-3.+(x-a)**2
end
quit
call tdz
return
File dzero.f:
SUBROUTINE DZERO(A,B,X0,R,EPS,MXF,F)
IMPLICIT DOUBLE PRECISION (A-H,O-Z)
*KEEP, C205BODY.
LOGICAL MFLAG,RFLAG
EXTERNAL F
PARAMETER (ONE = 1, HALF = ONE/2)
XA=MIN(A,B)
XB=MAX(A,B)
FA=F(XA,1)
FB=F(XB,2)
IF(FA*FB .GT. 0) GO TO 5
MC=0
1 X0=HALF*(XA+XB)
R=X0-XA
EE=EPS*(ABS(X0)+1)
IF(R .LE. EE) GO TO 4
F1=FA
X1=XA
F2=FB
X2=XB
2 FX=F(X0,2)
MC=MC+1
IF(MC .GT. MXF) GO TO 6
IF(FX*FA .GT. 0) THEN
XA=X0
FA=FX
ELSE
XB=X0
FB=FX
END IF
3 U1=F1-F2
U2=X1-X2
U3=F2-FX
U4=X2-X0
IF(U2 .EQ. 0 .OR. U4 .EQ. 0) GO TO 1
F3=FX
X3=X0
U1=U1/U2
U2=U3/U4
CA=U1-U2
CB=(X1+X2)*U2-(X2+X0)*U1
CC=(X1-X0)*F1-X1*(CA*X1+CB)
IF(CA .EQ. 0) THEN
IF(CB .EQ. 0) GO TO 1
X0=-CC/CB
ELSE
U3=CB/(2*CA)
U4=U3*U3-CC/CA
IF(U4 .LT. 0) GO TO 1
X0=-U3+SIGN(SQRT(U4),X0+U3)
END IF
IF(X0 .LT. XA .OR. X0 .GT. XB) GO TO 1
R=MIN(ABS(X0-X3),ABS(X0-X2))
EE=EPS*(ABS(X0)+1)
IF(R .GT. EE) THEN
F1=F2
X1=X2
F2=F3
X2=X3
GO TO 2
END IF
FX=F(X0,2)
IF(FX .EQ. 0) GO TO 4
IF(FX*FA .LT. 0) THEN
XX=X0-EE
IF(XX .LE. XA) GO TO 4
FF=F(XX,2)
FB=FF
XB=XX
ELSE
XX=X0+EE
IF(XX .GE. XB) GO TO 4
FF=F(XX,2)
FA=FF
XA=XX
END IF
IF(FX*FF .GT. 0) THEN
MC=MC+2
IF(MC .GT. MXF) GO TO 6
F1=F3
X1=X3
F2=FX
X2=X0
X0=XX
FX=FF
GO TO 3
END IF
4 R=EE
FF=F(X0,3)
RETURN
5 Continue
* 5 CALL KERMTR('C205.1',LGFILE,MFLAG,RFLAG)
* IF(MFLAG) THEN
* IF(LGFILE .EQ. 0) WRITE(*,100)
* IF(LGFILE .NE. 0) WRITE(LGFILE,100)
* END IF
* IF(.NOT.RFLAG) CALL ABEND
R=-2*(XB-XA)
X0=0
RETURN
6 Continue
* 6 CALL KERMTR('C205.2',LGFILE,MFLAG,RFLAG)
* IF(MFLAG) THEN
* IF(LGFILE .EQ. 0) WRITE(*,101)
* IF(LGFILE .NE. 0) WRITE(LGFILE,101)
* END IF
* IF(.NOT.RFLAG) CALL ABEND
R=-HALF*ABS(XB-XA)
X0=0
RETURN
100 FORMAT(1X,'***** CERN C205 DZERO ... F(A) AND F(B)',
1 ' HAVE THE SAME SIGN')
101 FORMAT(1X,'***** CERN C205 DZERO ... TOO MANY FUNCTION CALLS')
END
Example:
PAW > option logy
PAW > exec decade 10 5
plot the histogram number 10 with 5 decades.
Macro decade 1=10 2=0
*
Id = [1]
Dec = [2]
If $HEXIST([Id]) = 0 Then
Hrin [Id]
If $HEXIST([Id]) = 0 Then
Mess Histogram [Id] not found
Exitm
Endif
Endif
Max = $HINFO([Id],'MAX')
Min = $HINFO([Id],'MIN')
If [Max] <= 0 Then
Mess The maximum value of the histogram is negative
Exitm
Endif
If [Min] <= 0 Then
Min = 0.00001*[Max]
Endif
If [Dec] = 0 Then
Dec = $SIGMA(LOG10([Max]/[Min]))
Endif
Min = $SIGMA([Max]/(10**[Dec]))
Min [Id] [Min]
H/pl [Id]
*
Return
Macro ex
exe hex 110
mess [@]
exe hex 111
mess [@]
return
Macro HEX
cdir = $hcdir()
If [cdir] <> '//PAWC' Then
Hrin [1]
Cd //PAWC
exist = $hexist([1])
If [exist] Then
H/Del [1]
Endif
Cd [cdir]
EXITM [exist]
Else
EXITM $hexist([1])
Endif
Return
In the macro EX the return code of the macro HEX is in [@]
Since version 2.09/18 of PAW the UNITS command is again able to display the list of HBOOK files.
The following example illustrate this fact. In this example the version 2.06/20 booked the default histogram 54 bins whereas the version 2.07/23 book the histogram with 100 bins. This make the difference when histogram are plotted as we can see on the following plots:
Plot obtain with version 2.07
Plot obtain with version 2.06
The binning is something the user should define according to his data, it is really part of the analysis process. For that the command nt/plot provides the parameter IDH (after the CHOPT parameter). With 2.07 one should do:
PAW > 1d 3 'e' 54 0 10 PAW > call hbarx(3) PAW > nt/pl 10.e wt ! ! ! E 3To obtain a plot similar to 2.06.
In addition, a call hbarx is necessary because when IDH is given NT/PLOT doesn't touch the histogram (except for a RESET of the content) and in particular doesn't call HBARX on it even if, like here, the option E is selected. The E option in that case means only: 'draw the histogram with error bars'.
More informations on the new ntuple query processor are available here.
A = Hello
creates the variable A which
contains the character string Hello.
To access the content of a variable, the operator
[] should be used. For example
in a macro the command:
MESSAGE [A]
gives the output:
Hello
Variables can be concatenate in the following way:
A = Hello
B = world
C = [A] [B]
MESSAGE [C]
C = [A]+[B]
MESSAGE [C]
This macro gives the output:
Hello world
Hello+world
If the expression on the right side can be evaluated as
an arithmetic expression PAW does it. Example:
A = 1
B = 2
C = [A] [B]
MESSAGE [C]
C = [A]+[B]
MESSAGE [C]
gives the output:
1 2
3
Note that the evaluation of an expression can be forced using the system
function $EVAL. In some cases this
ensure that the variable really contains a number. The following case
show a such example where using $EVAL
is safer than the automatic evaluation.
V/CREATE V2(2) R 10 20
L = 2
A = $EVAL(V[L](1))
MESSAGE [A]
gives the output:
10
Variables can be used in commands parameters. Example:
A = 1
FUN/PLOT X+[A] 0 1
plots the function X+1.
But be careful that A may
contains any character string and you may get any expression. For example
the following commands
A = -1
FUN/PLOT X+[A] 0 1
are equivalent to execute the command:
FUN/PLOT X+-1 0 1
which is not valid for the FORTRAN like expression evaluator of
FUN/PLOT and PAW will
give an error like:
CS-TR-ERR: routine _002, line 0
FUNCTION _002(X,Y,Z) _002=X+ ^ -1#
syntax error
A way to bypass this is to do:
A = -1
FUN/PLOT X+([A]) 1 0 1
which is equivalent to:
FUN/PLOT X+(-1) 0 1
The way it is implemented is simple: all (multi-dimensional) arrays can be handled as a single large one-dimensional array. In that way no extra information is needed to have direct access to a variable length array.
PAW > Hi/file 2 rwn_aptuple.hbook
PAW > Nt/Loop 10.age copy.f
The skeleton of the routine
COPY
has been generated with the command
UWFUNC.
REAL FUNCTION COPY(XDUMMY)
REAL
+CATEGORY,DIVISION,FLAG ,AGE ,SERVICE ,CHILDREN,
+GRADE ,STEP ,NATION ,HRWEEK ,COST
COMMON/PAWIDN/IDNEVT,VIDN1,VIDN2,VIDN3,VIDN(10),
+CATEGORY,DIVISION,FLAG ,AGE ,SERVICE ,CHILDREN,
+GRADE ,STEP ,NATION ,HRWEEK ,COST
*
VECTOR X(3354)
X(IDNEVT)=VIDN1
END
PAW > Hi/file 2 rwn_aptuple.hbook
PAW > Nt/Loop 10 copy.f(age)
The skeleton of the routine COPY
has been generated with the command
UWFUNC.
REAL FUNCTION COPY(V)
REAL
+CATEGORY,DIVISION,FLAG ,AGE ,SERVICE ,CHILDREN,
+GRADE ,STEP ,NATION ,HRWEEK ,COST
COMMON/PAWIDN/IDNEVT,OBS(13)
+CATEGORY,DIVISION,FLAG ,AGE ,SERVICE ,CHILDREN,
+GRADE ,STEP ,NATION ,HRWEEK ,COST
*
VECTOR X(3354)
X(IDNEVT)=V
END
PAW > SET MTYP 20 PAW > SET KSIZ 0.8 PAW > H/PL 10 EFirst change the marker type because the default marker type is a dot and the marker size has no effect on it. Then define the size with SET KSIZ. The marker size is in centimetres.
PAW > COLOR 2 0.4 0.6 0.1
PAW > COLOR 3 0.4 0.6 0.5
PAW > FUN/DRAW x*x*y*z
call hsetpr('FEPS',eps)
call hfith(id,...
I want to get the sum of the positive elements of an array
(busig).
I do
nt/plot 202.vadd(busig) busig>0
It shows also negative entries! Requiring the index to be >0 does not
help. If I do
nt/plot 202.busig busig>0
I see correctly only positive entries.
In fact the mechanism is slightly more involved then you maybe thought.
The basic structure is the tree that is defined by the
expression. E.g.
A + 3 * B
becomes
+
/ \
A *
/ \
3 B
or maybe it is easier by introducing brackets explicitly
( A + ( 3 * B ) )
so after this separation each operator is a mapping :
f( X, Y )-> Z
the number of ``arguments'' may be 1 or any number (with some limit)
now for each operator (or function) it is defined what the relation
is of the scalar / non scalar shape of the arguments and the shape
of the result.
most of the built-in functions and operators are defined as
sin( * ) -> *
meaning the shape is identical for the result and the argument or
for the sum
"+"( *, * ) -> *
meaning that if one of the arguments must be scalar or both arguments
must have the same shape and the result also has this shape.
The top level has a rule like n/plot ( sel, exp1, exp2, ... )
n/plot( *, *, *, ... ) -> *
The "v" function were added to be able to say things like
plot x[i] when y[i].gt.0 and all z[j].gt.10
n/pl 10.x y>0.and.vand(z>10)
the "v" functions have shape rules like
vadd( * ) -> 0
where 0 means scalar.
Now for the question:
n/plo 202.vadd(busig) busig>0
should become
n/pl 202.vadd(busig*(busig>0))
and all will be fine !
Paw++*background: white
KxPaw++*background: white
To effectively "load" this new resources you must issue afterwards
the command:
xrdb -merge .Xdefaults (or xrdb -merge .Xresources)
The command xrdb -query can be used to
see the resources which are
effectively set.
N.B. resources management is something quite complex in the X Window system. To have more information please refer to the Guide for the Usage of X Window at CERN, available at the UCO or at URL:
http://consult.cern.ch/writeups/xusage
and especially read carefully section 4.5 on Resources or User Preferences.
error in CFOPEN : Can't open configuration file
***** ERROR in HROPEN : Cannot open file :
The second parameter of HROPEN and the HRENDC are the same and should be a string in UPPERCASE. In the 98a version of cernlib this will not be necessary.
The following example shows how HROPEN and HRENDC should be called
Program Rfio
*
Parameter (Memory_Size=500000)
Common /Pawc/ H(Memory_Size)
*.___________________________________________
*
Call Hlimit(Memory_Size)
*
Do i=1,100
print*, 'Loop number', i
Call Hropen(1,'EXAMPLE','example.hbook','N',1024,Istat)
If (Istat.Ne.0) Then
Print*, 'Error in opening file ...'
Stop
Endif
Call Hrendc('EXAMPLE')
Enddo
*
End
NOTE: From HBOOK version 4.24/07 (PAW version 2.09/09), HREND can be called: C/IO is the default. To force fortran IO, HROPEN should be called with option F and the file should be closed with HRENDF.
If I pass an argument "40.0" to a macro on the PAW command line, and somewhere send this argument to a COMIS function expecting a real variable, I get garbage, whereas if I write "40.01" instead, then everything works.
By default PAW converts the numbers into integers if possible. You should
use $RSIGMA. Example:
appl comis quit
subroutine test(r)
print*, r
end
quit
r = 40.01
call test([r])
r = 40.0
call test([r])
r = $RSIGMA(40.0)
call test([r])
The output of this macro is:
PAW > exec test
40.01000
.5605194E-43
40.00000
PAW >
Program Read_RWNtuple
*
Parameter (Memory_Size = 50000)
Parameter (Number_of_Events = 1000)
Parameter (Number_of_Variables = 27)
*
Common /Pawc/ H(Memory_Size)
Dimension Event(Number_of_Variables)
Character*8 Chtags(Number_of_Variables)
Data Chtags /'A1','A2','A3','A4','A5','A6','A7','A8','A9',
+ 'B1','B2','B3','B4','B5','B6','B7','B8','B9',
+ 'C1','C2','C3','C4','C5','C6','C7','C8','C9'/
*.___________________________________________
*
Call Hlimit(Memory_Size)
*
Call Hropen(1,'EXAMPLE','example.hbook','N',1024,Istat)
If (Istat.Ne.0) Then
Print*, 'Error in opening file ...'
Stop
Endif
*
Call Hbookn(10,'Ntuple example',Number_of_Variables,
+ '//EXAMPLE',9000,Chtags)
*
Do 10 i=1,Number_of_Events
Do 20 j=1,Number_of_Variables
Event(j) = Float(i)*Float(j)
20 Continue
Call Hfn(10,Event)
10 Continue
*
Call Hrout(0,Icycle,' ')
Call Hrend('EXAMPLE')
Close(1)
*
* Read back the ntuple 10
*
Call Hropen(1,'EXAMPLE','example.hbook','U',1024,Istat)
Call Hrin (10,9999,0)
*
IDN=0
Do i=1,10
Call Hgn(10,IDN,i,Event,Ierr)
Print*, Event(1),Event(2),Event(3)
Enddo
*
Call Hrend('EXAMPLE')
Close(1)
*
End
It is possible to do the same in a C program using
cfortran.h.
The program looks the following:
#include <stdlib.h>
#include <cfortran.h>
#include <packlib.h>
#define Memory_Size 50000
#define Number_of_Variables 27
#define Number_of_Events 10
typedef struct { float PAW[Memory_Size]; } PAWC_DEF;
#define PAWC COMMON_BLOCK(PAWC,pawc)
COMMON_BLOCK_DEF(PAWC_DEF,PAWC);
PAWC_DEF PAWC;
main()
{
int istat = 0;
int icycle = 0;
int i,j,Ierr;
int IDN = 0;
int record_size = 1024;
float Event[Number_of_Variables];
char Chtags[Number_of_Variables][3] =
{"A1","A2","A3","A4","A5","A6","A7","A8","A9",
"B1","B2","B3","B4","B5","B6","B7","B8","B9",
"C1","C2","C3","C4","C5","C6","C7","C8","C9"};
HLIMIT(Memory_Size);
HROPEN(1,"EXAMPLE","example.hbook","N",record_size,istat);
if (istat != 0) {
printf("Error in opening file ...\n");
exit;
}
HBOOKN(10,"Ntuple example",Number_of_Variables,"//EXAMPLE",9000,Chtags);
for (i=1; i<=Number_of_Events; i++) {
for (j=0; j<Number_of_Variables; j++) {
Event[j] = (float)i*(float)(j+1);
}
HFN(10,Event);
}
HROUT(0,icycle," ");
HREND("EXAMPLE");
KUCLOS(1," ",1);
/*
* Read back the ntuple 10
*/
HROPEN(1,"EXAMPLE","example.hbook","U",record_size,istat);
HRIN(10,9999,0);
for (i=1; i<=10; i++) {
HGN(10,IDN,i,Event,Ierr);
printf("%f %f %f \n", Event[0],Event[1],Event[2]);
}
HREND("EXAMPLE");
KUCLOS(1," ",1);
}
Macro hlist Output_lp 66 Histogram_Listing H/Li s Output_lp -66 shell more Histogram_Listing shell rm Histogram_Listing return
Before PAW version 2.10 This is not possible. The size is computed automatically according to the bin size.
Since PAW version 2.10 This size in controlled by SET 2SIZ.
The icons which are used for particular files in Kuip/Motif ( *.kumac, *.ps, r, r/w, ...) and Paw++ ( *.hbook) corresponds to ``class definitions'' made in the CDF (Command Definition File) for specific objects handled by the application. E.g.:
>Class MacFile 'Kuip Macro' big_fm sm_fm
>Class hbook 'Hbook File' big_hbook sm_hbook
You must also define in the CDF the corresponding "browsables", i.e. the container for these objects (e.g. in Paw++ the browsable HBOOK is a container for HBOOK files which are identified as " *.hbook"). In your case you must define a new container for all the HBOOK files belonging to different projects.
Normally this is done when building the application but it is possible with COMIS to define new classes and new browsables and make them known by the application without recompiling and linking. The following is an example where I define a new class "hbnew" (HBOOK files identified as " *.hbnew"), and a new browsable "Hbnew" for these files.
>Name hbnew
>Browse Hbnew . hbnew_list_%C hbnew_dir_%C
List
>Class hbnew 'Hbnew File' big_hbnew sm_hbnew
!Open . 'Histo/File 0 [that] 0 -X'
!'Open Update Mode' . 'Histo/File 0 [that] 0 -XU'
>Icon_bitmaps
#define big_hbnew_width 28
#define big_hbnew_height 38
static char big_hbnew_bits[] = {
0xff, 0xff, 0xff, 0x0f, 0x1f, 0xfe, 0x87, 0x0f, 0x0f, 0xfc, 0x03, 0x0f,
0x07, 0xf8, 0x01, 0x0e, 0x03, 0xf0, 0x00, 0x0c, 0x01, 0x00, 0x00, 0x08,
0xf1, 0x03, 0xfc, 0x08, 0xe1, 0x01, 0x78, 0x08, 0xe1, 0x01, 0x78, 0x08,
0xe1, 0x01, 0x78, 0x08, 0xe1, 0x01, 0x78, 0x08, 0xe1, 0x01, 0x78, 0x08,
0xe1, 0x01, 0x78, 0x08, 0xe3, 0x01, 0x78, 0x0c, 0xe7, 0x01, 0x78, 0x0e,
0xe7, 0x01, 0x78, 0x0e, 0xe7, 0x03, 0x7c, 0x0e, 0xe7, 0xff, 0x7f, 0x0e,
0xe7, 0xff, 0x7f, 0x0e, 0xe7, 0xff, 0x7f, 0x0e, 0xe7, 0x03, 0x7c, 0x0e,
0xe7, 0x01, 0x78, 0x0e, 0xe7, 0x01, 0x78, 0x0e, 0xe7, 0x01, 0x78, 0x0e,
0xe7, 0x01, 0x78, 0x0e, 0xe3, 0x01, 0x78, 0x0c, 0xe1, 0x01, 0x78, 0x08,
0xe1, 0x01, 0x78, 0x08, 0xe1, 0x01, 0x78, 0x08, 0xe1, 0x01, 0x78, 0x08,
0xe1, 0x01, 0x78, 0x08, 0xe1, 0x01, 0x78, 0x08, 0xf1, 0x03, 0xfc, 0x08,
0x03, 0xf0, 0x00, 0x0c, 0x07, 0xf8, 0x01, 0x0e, 0x0f, 0xfc, 0x03, 0x0f,
0x1f, 0xfe, 0x87, 0x0f, 0xff, 0xff, 0xff, 0x0f};
#define sm_hbnew_width 18
#define sm_hbnew_height 22
static char sm_hbnew_bits[] = {
0xff, 0xff, 0x03, 0xe7, 0x9f, 0x03, 0xc3, 0x0f, 0x03, 0x01, 0x03, 0x02,
0x7d, 0xf8, 0x02, 0x39, 0x70, 0x02, 0x39, 0x70, 0x02, 0x39, 0x70, 0x02,
0x7b, 0x78, 0x03, 0xfb, 0x7f, 0x03, 0xfb, 0x7f, 0x03, 0x7b, 0x78, 0x03,
0x3b, 0x70, 0x03, 0x3b, 0x70, 0x03, 0x39, 0x70, 0x02, 0x39, 0x70, 0x02,
0x39, 0x70, 0x02, 0x7d, 0xf8, 0x02, 0x01, 0x03, 0x02, 0xc3, 0x0f, 0x03,
0xe7, 0x9f, 0x03, 0xff, 0xff, 0x03};
N.B. By compiling this CDF file with the KUIP compiler "
kuipc" you
automatically generate the C code:
> kuipc hbnew.cdf hbnew.c
In our example the first routine "hbnew_list_" must return one by one the " *.hbnew" files.
* file "
hbnew_list.c" which contains routine "
hbnew_list_":
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_PATH 256
#define MAX_STRING 80
extern char **km_scan_dir();
/***********************************************************************
* *
* Return one by one the *.hbnew files. This routine is called by *
* the Kuip Browser. *
* *
***********************************************************************/
char **hbnew_list_(brobj_name, brcls_name, bpath, n)
char *brobj_name, *brcls_name, *bpath;
int n;
{
static int init = 0;
char **scan;
if (!init) {
km_file_type(".hbnew", "hbnew", "(Hbook New File)", 0);
init = 1;
}
scan = km_scan_dir(bpath, "*.hbnew", n, 1);
return scan;
}
(N.B.
km_file_type and
km_scan_dir are KUIP callable
utilities).
The second routine " hbnew_dir_" returns the CWD for the " *.hbnew" files.
* file "
hbnew_dir.c" which contains routine "
hbnew_dir_":
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_PATH 256
#define MAX_STRING 80
extern char **km_scan_dir();
/***********************************************************************
* *
* Return the CWD for the *.hbnew files. This routine is called by *
* the Kuip Browser. *
* *
***********************************************************************/
char **hbnew_dir_(class_name, first)
char *class_name;
int first;
{
static char *path_desc[2];
static char root[MAX_PATH+6];
char path[MAX_PATH+1];
path_desc[0] = NULL;
path_desc[1] = NULL;
#ifdef NeXT
if (first && getwd(path)) {
#else
if (first && getcwd(path, MAX_PATH)) {
#endif
sprintf(root, "root=%s", path);
path_desc[0] = "Hbnew";
path_desc[1] = root;
}
return path_desc;
}
Macro hbnew
App COMIS quit
!file hbnew_list.c
!file hbnew_dir.c
quit
CALL hbnew.c

RZIODO. Error at record = xxxx LUN = x IOSTAT = xxxWhere:
Errors from RZIODO are passed back to calling routines and the higher level package should then handle them appropriately.
Possible causes include:
Program Hfitv_Example
*
Parameter (Npoints=100,Npar=3)
Dimension X(Npoints),Y(Npoints),E(Npoints)
Dimension Pmin(Npar),Pmax(Npar),Step(Npar),Sigpar(Npar)
Common/PAWPAR/PAR(Npar)
Common /PAWC/ H(100000)
External FitFun
*.___________________________________________
*
Call Igwkty(Kwtype)
Call Hlimit(100000)
Call Hplint(Kwtype)
*
* Vectors to br fitted
*
Do i=1,Npoints
R = 5.*rndm(i)
X(i) = Float(i)
Y(i) = X(i)*X(i)+i*R
E(i) = R
Enddo
*
* Parameters needed by Hfitv
*
Do i=1,Npar
PAR(i) = 1.
Pmin(i) = 0.
Pmax(i) = 0.
Step(i) = -1.
enddo
*
* Perform the fit
*
Call Hfitv(Npoints,Npoints,1,X,Y,E,FitFun,
+ ' ',Npar,PAR,Step,Pmin,Pmax,Sigpar,Chi2)
*
* Draw the curve
*
Call Hplfra(0.,101.,0.,10100.,' ')
Call Igraph(100,X,Y,'L')
*
* Draw the fit
*
Do i=1,Npoints
Y(i) = FitFun(X(i))
Enddo
Call Igset('PLCI',2.)
Call Igraph(100,X,Y,'L')
*
Call Igterm
Read(*,*)
Call Hplend
End
Function FitFun(X)
Parameter (Npar=3)
Common/PAWPAR/PAR(Npar)
FitFun = PAR(1)*X*X + PAR(2)*X + PAR(3)
End
|
pcitasd29> hfitv_example Workstation type (?=HELP) |
The code is a DOUBLE PRECISION fortran function which can be use later in PAW. The only limitation is that the code should be compiled because the COMIS interpreter doesn't handle properly the DOUBLE PRECISION functions.
The following example shows to proceed. It plots the function, result of
the smoothing, using the HQUADF.DAT file. Note the extensions ".f77" to use
compiled code.
v/create x(10) r 1 2 4 5 6 3 2 1 3 5
v/dr x 11
zone 1 2
smooth 11 F 3
shell mv hquadf.dat hquadf.f
appl comis quit
!file hquadf.f77
quit
appl data dy.f
real function dy(x)
DOUBLE PRECISION V,HQUADF
v = dble(x)
dy = float(HQUADF(v))
end
dy.f
fun/plot dy.f77 1 11
The output of this macro is:
Note that HQUADF.DAT may contains long DATA statements which sometimes can not be handle properly by the compiler. In that case you should edit them by hand in order to reduce the number of continuation lines.
Program Extend_Ntuple
*
Parameter (Nhmax = 100000)
Common /Pawc/ Hmemor(Nhmax)
Common /P/ A,B,C,D,E,F
*
Parameter (Nrvar=3)
Character*10 Chvar(Nrvar)
*
Data Chvar/'A','B','C'/
*
Call Hlimit(Nhmax)
*--------------------------------------------------
* Create and fill and save the Ntuple 1
*
Call Hropen(10,'P1','p1.hbook','N',1024,Ista)
If (Ista.Ne.0) Stop
Call Hbnt(1,'Test','D')
Call Hbname(1,'P1',A,'A,B,C')
*
Do I=1,10
A = Float(I)
B = Float(10*I)
C = Float(100*I)
Call Hfnt(1)
EndDo
*
Call Hrout(0,IC,'')
Call Hrend('P1')
Close(10)
*--------------------------------------------------
* Reset the common block
*
Do I=1,10
A = 0.
B = 0.
C = 0.
D = 0.
E = 0.
F = 0.
EndDo
*--------------------------------------------------
* Extend ntuple 1 with an extra block
* The extra variables are filled with
* functions of the exiting variables.
*
Call Hropen(10,'P1','p1.hbook','U',1024,Ista)
If (Ista.Ne.0) Stop
Call Hrin (1,9999,0)
Call Hbname (1,' ',0,'$CLEAR')
Call Hbname (1,'P1',A,'$SET')
Call Hbname (1,'P2',D,'D,E,F')
Call Hnoent (1,Noent)
Call Hgntv (1,Chvar,Nrvar,Noent,Ierr)
*
Do I=1,Noent
Call Hgntf(1,I,Ierr)
D = A+1
E = B+1
F = C+1
Call Hfntb(1,'P2')
EndDo
*
Call Hrout(1,IC,'')
Call Hrend('P1')
Close(10)
*
End
The scanning of the ntuple 1 in PAW++ gives:

subroutine a
call b('abcdef'//'ghijkl')
end
subroutine b(c)
character*(*) c
print*, c
end
gives:
PAW > call a.f
CS-TR-ERR: routine A, line 2
CALL B('abcdef' ^ //'ghijkl')
syntax error
To bypass this problem you should use an intermediate character variable:
subroutine a
character*80 s
s='abcdef'//'ghijkl'
call b(s)
end
subroutine b(c)
character*(*) c
print*, c
end
I am running PAW on an alpha machine
(DEC-UNIX 4.0) and compiling using the compiler (not COMIS) by
using the statement:
nt/loop ntuplenumber filename.f77
When more than 1 user is running PAW program in the same
manner the second user does not succeed in compiling and gets the message:
Cannot open file so_locations to update
With some PAW version, the file so_locations is created in
the
/tmp
directory and remains throughout the PAW session of the first user. When
the second PAW session try to create its own
so_locations file there
is a conflict. This problem can be avoid by redefining the temporary directory
where this file is created. Just put the following lines in your
pawlogon.kumac file.
appl comis quit
!setopt '/myhomedirectory/tmp' path
quit
***** ERROR in HBNAME : Too many variables in format (>50) : ID= 1
because the number of token in the CHFORM parameter of the HBNAME call is
limited to 50.
Program CWNLONG
*
Common /Pawc/ H(100000)
Parameter (Nmax = 300)
Common /CWN/ A00,A01,A02,A03,A04,A05,A06,A07,A08,A09,
+ A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,
+ A20,A21,A22,A23,A24,A25,A26,A27,A28,A29,
+ A30,A31,A32,A33,A34,A35,A36,A37,A38,A39,
+ A40,A41,A42,A43,A44,A45,A46,A47,A48,A49,
+ A50,A51,A52,A53,A54,A55,A56,A57,A58,A59,
+ A60,A61,A62,A63,A64,A65,A66,A67,A68,A69,
+ A70,A71,A72,A73,A74,A75,A76,A77,A78,A79,
+ A80,A81,A82,A83,A84,A85,A86,A87,A88,A89,
+ A90,A91,A92,A93,A94,A95,A96,A97,A98,A99
*.___________________________________________
*
Call Hlimit(100000)
*
Call Hropen(1,'CWN','cwn.hbook','N',1024,Istat)
If (Istat.Ne.0) Then
Print*, 'Error in opening file ...'
Stop
Endif
*
Call Hbnt(1,'CWN',' ')
Call Hbname(1,'BLOCK1',A00,
+ 'A00,A01,A02,A03,A04,A05,A06,A07,A08,A09,'//
+ 'A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,'//
+ 'A20,A21,A22,A23,A24,A25,A26,A27,A28,A29,'//
+ 'A30,A31,A32,A33,A34,A35,A36,A37,A38,A39,'//
+ 'A40,A41,A42,A43,A44,A45,A46,A47,A48,A49,'//
+ 'A50,A51,A52,A53,A54,A55,A56,A57,A58,A59,'//
+ 'A60,A61,A62,A63,A64,A65,A66,A67,A68,A69,'//
+ 'A70,A71,A72,A73,A74,A75,A76,A77,A78,A79,'//
+ 'A80,A81,A82,A83,A84,A85,A86,A87,A88,A89,'//
+ 'A90,A91,A92,A93,A94,A95,A96,A97,A98,A99'
+)
*
Call Hrout(0,Icycle,' ')
Call Hrend('CWN')
Close(1)
*
End
To avoid that it is enough to split the HBNAME call in two parts like in the
following example:
Program CWNLONG
*
Common /Pawc/ H(100000)
Parameter (Nmax = 300)
Common /CWN/ A00,A01,A02,A03,A04,A05,A06,A07,A08,A09,
+ A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,
+ A20,A21,A22,A23,A24,A25,A26,A27,A28,A29,
+ A30,A31,A32,A33,A34,A35,A36,A37,A38,A39,
+ A40,A41,A42,A43,A44,A45,A46,A47,A48,A49,
+ A50,A51,A52,A53,A54,A55,A56,A57,A58,A59,
+ A60,A61,A62,A63,A64,A65,A66,A67,A68,A69,
+ A70,A71,A72,A73,A74,A75,A76,A77,A78,A79,
+ A80,A81,A82,A83,A84,A85,A86,A87,A88,A89,
+ A90,A91,A92,A93,A94,A95,A96,A97,A98,A99
*.___________________________________________
*
Call Hlimit(100000)
*
Call Hropen(1,'CWN','cwn.hbook','N',1024,Istat)
If (Istat.Ne.0) Then
Print*, 'Error in opening file ...'
Stop
Endif
*
Call Hbnt(1,'CWN',' ')
Call Hbname(1,'BLOCK1',A00,
+ 'A00,A01,A02,A03,A04,A05,A06,A07,A08,A09,'//
+ 'A10,A11,A12,A13,A14,A15,A16,A17,A18,A19,'//
+ 'A20,A21,A22,A23,A24,A25,A26,A27,A28,A29,'//
+ 'A30,A31,A32,A33,A34,A35,A36,A37,A38,A39,'//
+ 'A40,A41,A42,A43,A44,A45,A46,A47,A48,A49'
+)
Call Hbname(1,'BLOCK1',A50,
+ 'A50,A51,A52,A53,A54,A55,A56,A57,A58,A59,'//
+ 'A60,A61,A62,A63,A64,A65,A66,A67,A68,A69,'//
+ 'A70,A71,A72,A73,A74,A75,A76,A77,A78,A79,'//
+ 'A80,A81,A82,A83,A84,A85,A86,A87,A88,A89,'//
+ 'A90,A91,A92,A93,A94,A95,A96,A97,A98,A99'
+)
*
Call Hrout(0,Icycle,' ')
Call Hrend('CWN')
Close(1)
*
End
run the following program with either HBOOK3 or HBOOK4.
*-- open old hbook3 hstore file
open(unit=lun,....
*-- Import all histograms from file to memory
call hfetch(0,lun)
*-- open a text file (recfm=f lrecl=80
open(unit=lun2,form='formatted',status='new')
*-- write histograms from memory to this file
call hwrite(o,lun2,0,0,-1)
*
Then run PAW and convert to a new HBOOK file:
PAW > hread 0 filename
PAW > Histo/file 1 newhbookfile 1024 N
PAW > Hrout 0
The
CHAIN
command open the chained files with the automatic record length detection (LRECL=0)
therefore it is not possible to chain files having a record length greater than 8192 unless
the chain is built with //lunxx. Example:
h/file 20 file_1 16384
h/file 21 file_2 16384
h/file 22 file_3 16394
chain chain_1 //lun20 //lun21 //lun22
cd //chain_1
Any change you make to the DECW$XDEFAULTS.DAT file does not take effect until you restart your DECwindows session.
Most applications have a system application resource file in the directory pointed to by the logical name DECW$SYSTEM_DEFAULTS (e.g. DECW$BOOKREADER.DAT, for the DEC supplied information system bookreader, or DECW$CLOCK.DAT, for xclock, ...).
You can also create a user application-specific resource file in the directory pointed to by the logical name DECW$USER_DEFAULTS:
e.g., for Paw++ on VMS, you can create a file DECW$PAWPP.DAT in your login directory and specify your user preferences for Paw++ in that file.
For more details can be found in the Guide for the Usage of X Window at CERN .
.
.
.
logical hntnew
.
.
.
id = 10
if (hntnew(id)) then
print*, id,' is a CWN'
else
print*, id,' is a RWN'
endif
.
.
.
PAW > H/DEL 12345
***** ERROR in HDELET : Unknown histogram : ID= 12345
PAW >
To avoid this you can use the following maro:
Macro HDEL
If $HEXIST([1]) Then
H/DEL [1]
Endif
Return
This macro will not give an error message if the histogram doesn't exist:
PAW > Exec HDEL 12345
PAW >
Unaligned access pid=27853These are merely warning messages that the program has made a memory access to a structure (a real*4 variable, for instance) that didn't begin on the most efficient address. The compiler(s) try to locate (align) all data structures for the fastest memory access, but it's not too hard to mess this up via overlayed data structures (FORTRAN equivalence statements, common blocks, etc).va=409dea6c pc=25003604 ra=201515c8 type=ldt
The program still works, it just prints out an error message that the memory reference was slow (thereby slowing itself down vastly more!)
The messages can be suppressed with the shell command:
uac p noprint
Macro Ndc2Cm
*
NT = $GRAFINFO('NT')
XNdc = [1]
YNdc = [2]
Sel 1
XWnMax = $GRAFINFO('WNXMAX')
YWnMax = $GRAFINFO('WNYMAX')
XVpMin = $GRAFINFO('VPXMIN')
XVpMax = $GRAFINFO('VPXMAX')
YVpMin = $GRAFINFO('VPYMIN')
YVpMax = $GRAFINFO('VPYMAX')
Sel [NT]
Global/Create X
Global/Create Y
X = [XWnMax]*(([XNdc]-[XVpMin])/([XVpMax]-[XVpMin]))
Y = [YWnMax]*(([YNdc]-[YVpMin])/([YVpMax]-[YVpMin]))
*
Return
Example:
PAW > Nul
PAW > Exe ndc2cm .5 .5
PAW > Mess [X] [Y]
$ set file/att=(rfm:fix,lrl:4096) [NFS_disk]:[directory][ntuple name]This creates the necessary interface info, and you can then open them from your VMS PAW in the usual way:
PAW> his/fil 1 [NFS_disk]:[directory][ntuple name]
CALL MNCOMD(fcn,'minimize 2000',IERR,futil)
will change the call limit to 2000.
Sometimes it is more convenient to define the value has an integer
(result of some computation). In that case it is easier to
use MNEXCM instead of
MNCOMD.
All this is in the MINUIT manual, but it may not
be very easy to find.
With PAW 2.07 I got the following error on a very basic instruction:
nt/plot 10.icel(1)
/NTUPLE/PLOT: Evt 3: Index out of range, end(1) > max(0)
whereas the same without index specified works perfectly.
nt/plot 10.icel
ICEL is variable length array variable
Since PAW version 2.07, the ntuple query processor does more
checking.
This is the case with this question. Here a variable length
array is used and, for some events, its dimension
is zero. For these events ICEL(1)
is not defined.
So just do:
nt/plot 10.icel(1) n>0
where n is the dimension of
icel.
More informations on the ntuple query processor are available here.
***** ERROR in HFNT bad float in column: 11 line: 1 : Negative infinity : ID= 1This means that you fill the ntuple with invalid number(s) (NaN, Infinity etc ...). Be sure that the values to give to HFTN are valid. A typical mistake is to forgot to initialise some variables (for instance with 0).
HBOOK provides routines to check if a
float
or a
double precision
number is valid:
ifps(x) for single precision numbers
ifpd(x) for double precision numbers
which return 0 if
x is invalid.
; General stuff specific to all versions
(setq search-repeat-char 10)
(setq auto-mode-alist (cons '("\\.h\\'" . c++-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.INC\\'" . fortran-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.inc\\'" . fortran-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.tex\\'" . latex-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.kumac\\'" . kumac-mode) auto-mode-alist))
(require 'font-lock)
(add-hook 'emacs-lisp-mode-hook 'turn-on-font-lock)
(add-hook 'lisp-mode-hook 'turn-on-font-lock)
(add-hook 'fortran-mode-hook 'turn-on-font-lock)
(add-hook 'kumac-mode-hook 'turn-on-font-lock)
(add-hook 'c-mode-hook 'turn-on-font-lock)
(add-hook 'c++-mode-hook 'turn-on-font-lock)
(add-hook 'perl-mode-hook 'turn-on-font-lock)
(add-hook 'tex-mode-hook 'turn-on-font-lock)
(add-hook 'texinfo-mode-hook 'turn-on-font-lock)
(add-hook 'dired-mode-hook 'turn-on-font-lock)
;; Non-Lucid version specific options (i.e. if on a vt100 etc...)
;;
(cond
((not (eq window-system 'x))
(global-set-key "\C-A" 'isearch-forward)
(global-set-key "\C-X\C-J" 'save-buffer))
)
(setq fortran-continuation-string "+")
(setq comment-start "*")
(setq adaptive-fill-mode nil)
(setq load-path (cons (expand-file-name "~/emacs") load-path))
(load "kumac-mode")
subroutine ellips(x1,x2,y1,y2)
dimension x(51),y(51)
a=(x2-x1)/2.
b=(y2-y1)/2.
xm=(x2+x1)/2.
ym=(y2+y1)/2.
dt=6.28/50.
t=0.
do 10 i=1,51
x(i)=a*cos(t)+xm
y(i)=b*sin(t)+ym
t=t+dt
10 continue
call ipl(51,x,y)
end
To use this routine just do:
PAW > nul 0 10 0 10 PAW > set ltyp 2 PAW > call ellips.f(1.,8., 2.,6.)

PAW > uwfunc 30 test.fThen edit test.f. The variable CFILE is the current file name in a chain. ICHEVT = 1 when you start the first event in the chain. IDNEVT is the current event number as usual. Suppose you have now defined an additional cut:
PAW > cut $5 x>0.and.y>0Then you can do:
PAW > Nt/plot 30.x $5*test.f
REAL FUNCTION test(XDUMMY)
REAL
+ X , Y , Z
*
LOGICAL CHAIN
CHARACTER*128 CFILE
*
COMMON /PAWCHN/ CHAIN, NCHEVT, ICHEVT
COMMON /PAWCHC/ CFILE
*
COMMON/PAWIDN/IDNEVT,OBS(10),
+ X , Y , Z
*
*-* set weight as a function of the file name
test=1.
if(cfile.eq.'test1.hbook')test=0.5
if(cfile.eq.'test2.hbook')test=0.3
END
Original question follows:
I have the following ntuples: 1.nt,2.nt,3.nt. I get the three
plots from respective ntuples as follows.
PAW > hist/file 1 1.nt
PAW > nt/pl 1.e $cuts.and.1 | weight 1
PAW > close 1
PAW > hist/file 1 2.nt
PAW > nt/pl 1.e $cuts.and..75 | weight .75
PAW > close 1
PAW > hist/file 1 3.nt
PAW > nt/pl 1.e $cuts.and..5 | weight .5
PAW > close 1
I wish to get a cumulative graph of the above three plots. I usually
define 3 histograms, and add them.
Is there a way to firstly define the three ntuples as chain:
PAW > nt/chain nt 1.nt 2.nt 3.nt
PAW > cd //nt
and get the same result by a command which works as follows?:
PAW > nt/pl $cuts.and.[(wt 1 for 1.nt),(wt .75 for 2.nt),(wt .5 for 3.nt)
#include "cfortran.h"
typedef struct {
int iquest[100];
} quest_def;
#define QUEST COMMON_BLOCK(QUEST,quest)
COMMON_BLOCK_DEF(quest_def,QUEST);
Then in the C program the iquest variable
can be used as follows:
.
.
.
QUEST.iquest[9] = 0;
.
.
.
if (QUEST.iquest[0] != 1 ) {
.
.
.
Note that IQUEST(1) in fortran
correspond to QUEST.iquest[0] in C.
PAW > nt/scan 10 nevent=5 varlis=flag
+-------+-------------+
| Event | flag |
+-------+-------------+
| 1 | z'f' |
| 2 | z'f' |
| 3 | z'f' |
| 4 | z'f' |
| 5 | z'f' |
+-------+-------------+
==> 5 events satisfied the imposed cuts
To have the integer representation of the unsigned integer variables
it is enough to do:
PAW > nt/scan 10 nevent=5 varlis=int(flag) flag
+-------+--------------+-------------+
| Event | int(flag) | flag |
+-------+--------------+-------------+
| 1 | 15 | z'f' |
| 2 | 15 | z'f' |
| 3 | 15 | z'f' |
| 4 | 15 | z'f' |
| 5 | 15 | z'f' |
+-------+--------------+-------------+
==> 5 events satisfied the imposed cuts
PAW > RECALL_STYLE KSHO(N.B. RECALL_STYLE ? will give you the current setting). Putting this in your pawlogon.kumac will change the default setting from "insert" to "overwrite".
Now, if you want to change this setting only for the current line (but
not change the default setting) typing
PAW > his/file 1 shift9:/usera/cp/julian/charm.hbooki.e. host name followed after a colon by full path name.
PAW > hi/file 1 /castor/cern.ch/user/u/user/pawt/pawhists.hbook
In most cases all X clients (applications) are using the same and current setting of the X server (the machine which does the display). In any case the command 'xrdb' can be used to get the current settings (type 'xrdb -q'), or to set new values. Note that having this information in the server (where it is available to all clients) instead of on disk, solves the problem in previous versions of X that required you to maintain defaults files on every machine that you might use. It also allows for dynamic changing of defaults without editing files.
nul 0 10 0 10 set chhe 1.5 v/create x(1) r 100. a = x(1) itx 1 5 x(1) = [a]
Paw++*dirlist*1d*iconForeground: black Paw++*dirlist*1d*iconBackground: white Paw++*dirlist*1d*iconLabelForeground: white Paw++*dirlist*1d*iconLabelBackground: black Paw++*dirlist*2d*iconForeground: black Paw++*dirlist*2d*iconBackground: white Paw++*dirlist*2d*iconLabelForeground: white Paw++*dirlist*2d*iconLabelBackground: black Paw++*dirlist*ntuple*iconForeground: black Paw++*dirlist*ntuple*iconBackground: white Paw++*dirlist*ntuple*iconLabelForeground: white Paw++*dirlist*ntuple*iconLabelBackground: black
Program Read_CWNtuple
*
Parameter (Nhmax = 100000)
Common /Pawc/ Hmemor(Nhmax)
Common /P/ N,K(4,10)
*
Call Hlimit(Nhmax)
*
* Create and fill the Ntuple 100
*
Call Hropen(10,'p','p.hbook','N',1024,Ista)
If (Ista.Ne.0) Stop
Call Hbnt(100,'Test','D')
Call Hbname(100,'P',n,'N[0,10],K(4,N)')
*
Do N=1,10
Do I=1,4
Do J=1,n
K(I,J)=I+N*10
EndDo
EndDo
Call Hfnt(100)
EndDo
*
Call Hrout(0,IC,' ')
Call Hrend('p')
Close(10)
Do I=1,10
Do J=1,4
K(J,I)=0
EndDo
EndDo
*
* Read back the ntuple 100
*
Call Hropen(10,'p','p.hbook','U',1024,Ista)
If (Ista.Ne.0) Stop
Call Hrin (100,9999,0)
Call Hbname (100,' ',0,'$CLEAR')
Call Hbname (100,'p',n,'$SET')
Call Hnoent (100,Noent)
*
Do I=1,Noent
Call Hgnt(100,I,Ierr)
Print*,'N = ',N
Do J=1,4
Do L=1,n
Print*,'K(',J,',',L,') = ',K(J,L)
EndDo
EndDo
EndDo
*
Call Hrend('p')
Close(10)
*
End
PAW > opt * PAW > fun1 1 cos(x)*sqrt(x) 100 0 12 PAW > exe zoom 1 30 70Where the macro ZOOM is:
Macro zoom id = [1] i1 = [2] i2 = [3] zone colo 9 1 1 1 h/pl [id] set xmgr 2.5 set ymgu 2.5 zone 2 2 2 s set bcol 1109 h/pl [id]([i1]:[i2]) zone set bcol set xmgr set ymgu return
Program Two_Windows
Common /Pawc/ H(20000)
Dimension Rval(2)
*
Call Mzebra (-3)
Call Mzpaw (20000,' ')
Call Iginit (0)
Call Iopks (6)
*
Iwk1 = 1
Iwkty1 = 1
Call Iopwk (Iwk1,1,Iwkty1)
Call Igqwk (Iwk1,'MXDS',Rval)
Xwkwn1 = Min(1.,Rval(1)/Rval(2))
Ywkwn1 = Min(1.,Rval(2)/Rval(1))
Call Iswkwn (Iwk1,0.,Xwkwn1,0.,Ywkwn1)
Call Iswkvp (Iwk1,0.,Rval(1),0.,Rval(2))
Call Iuwk (Iwk1,0)
*
Iwk2 = 2
Iwkty2 = 2
Call Iopwk (Iwk2,1,Iwkty2)
Call Igqwk (Iwk2,'MXDS',Rval)
Xwkwn2 = Min(1.,Rval(1)/Rval(2))
Ywkwn2 = Min(1.,Rval(2)/Rval(1))
Call Iswkwn (Iwk2,0.,Xwkwn2,0.,Ywkwn2)
Call Iswkvp (Iwk2,0.,Rval(1),0.,Rval(2))
Call Iuwk (Iwk2,0)
*
Call Isclip (0)
*
Call Iacwk (1)
Call Iswn (2,0.,10.,0.,10.)
Call Isvp (2,0.1*Xwkwn1,0.4*Xwkwn1,0.1*Ywkwn1,0.4*Ywkwn1)
Call Iselnt (2)
Call Igbox (0.,10.,0.,10.)
Call Igterm
Print*,'Type ...'
Read (*,*)
*
Call Idawk (1)
Call Iacwk (2)
Call Isvp (2,0.1*Xwkwn2,0.4*Xwkwn2,0.1*Ywkwn2,0.4*Ywkwn2)
Call Iselnt (2)
Call Igbox (0.,10.,0.,10.)
*
Call Igterm
Read (*,*)
*
Call Igend
*
End
| UNIT | Reserved by ... |
|---|---|
| 5 | KUIP |
| 6 | KUIP |
| 7 | KUIP |
| 10 | HIGZ |
| 11 | KUIP |
| 12 | KUIP |
| 13 | KUIP |
| 14 | KUIP |
| 15 | KUIP |
| 16 | KUIP |
| 17 | KUIP |
| 18 | KUIP |
| 19 | HIGZ |
| 81 | COMIS |
| 82 | COMIS |
| 83 | COMIS |
| 84 | COMIS |
| 89 | COMIS |
| 91 | HIGZ |
| 97 | COMIS |
Bad Ntuple header (try RECOVER)In PAW you might use the command RECOVER. The recover mechanism can also be performed in a batch program with:
CALL HRECOV(ID,' ')
In both cases the file on which the Ntuple resides must be open in Update mode.
SIGMA !PRINT SIGMA a=array(2,-3#-2) SIGMA B=A**0.5 SIGMA C=A**0.5 SIGMA AC=A*C SIGMA !NOPRINT
PAW > SET XTIC -0.3 PAW > SET YTIC -0.3
integer cem_ele
data cem_ele /'3FF'X/
only decimal constants can be used.
subroutine listfiles
PARAMETER (NLPATM=100, MXFILES=50)
COMMON /HCDIRN/NLCDIR,NLNDIR,NLPAT,ICDIR,NCHTOP,ICHTOP(MXFILES)
+ ,ICHTYP(MXFILES),ICHLUN(MXFILES)
CHARACTER*16 CHNDIR, CHCDIR, CHPAT ,CHTOP
COMMON /HCDIRC/CHCDIR(NLPATM),CHNDIR(NLPATM),CHPAT(NLPATM)
+ ,CHTOP(NLPATM)
CHARACTER*80 HFNAME
COMMON /HCFILE/HFNAME(MXFILES)
*
Do I=1,NCHTOP
J = Lenocc(HFNAME(I))
Print*,ICHTOP(I),' ',HFNAME(I)(1:J)
Enddo
*
End
Macro GetProb
output_lp 66 junk
diff [1] [2]
output_lp -1
close 66
appl comis quit
subroutine readprob
Character*80 Chline
vector vprob(1)
Open(UNIT=67,FILE='junk',FORM='FORMATTED',STATUS='OLD')
Read (67,10) Chline
Read (67,10) Chline
Read (67,10) Chline
10 Format(A)
Read (Chline(11:),'(f11.5)') vprob(1)
Close(67)
End
quit
call readprob
prob = vprob(1)
Message [prob]
return
It is enough to do:
PAW > exec getprob id1 id2to perform the command DIFF on the histograms id1 and id2 and get the value of PROB in vprob(1) and in the variable prob.
**** ERROR in IGTABL : Not enough space in memoryis due to the same problem.
The option ZFL1 is often used to be able to generate PostScript files with the command PI/PRINT. With such big pictures (too large to fit in memory) it is nevertheless possible to generate a PostScript file. First the option ZFL1 should be deactivated with the command OPTION NZFL, and then proceed as follow:
PAW > For/File 66 filename.ps
PAW > Metafile 66 -111
.
.
here put your graphic commands
.
.
PAW > close 66
#include <X11/Xlib.h>
#include <assert.h>
#include <unistd.h>
#include "cfortran.h"
#include "zebra.h"
#include "higz.h"
#define PAWC_SIZE 50000
typedef struct { float PAW[PAWC_SIZE]; } PAWC_DEF;
#define PAWC COMMON_BLOCK(PAWC,pawc)
COMMON_BLOCK_DEF(PAWC_DEF,PAWC);
PAWC_DEF PAWC;
#define NIL (0)
main()
{
int itype,istat;
Window w;
Display *dpy = XOpenDisplay(NIL);
assert(dpy);
w = XCreateWindow(dpy, DefaultRootWindow(dpy), 0, 0,
500, 500, 0,
CopyFromParent, CopyFromParent, CopyFromParent,
NIL, 0);
XMapWindow(dpy, w);
XFlush(dpy);
ixsdswi( dpy , w );
/*
* Initialisation
*/
MZEBRA(-3);
MZPAW(PAWC_SIZE," ");
IGINIT(0);
IGWKTY(itype);
IGSSE(6, itype);
IGRNG(20.,20.);
IGBOX(1.,19.,1.,19.);
IGTERM();
sleep(10);
}
The following script should be used to link that example on LINUX:
gcc -c $1.c -g -rdynamic -Df2cFortran
g77 -o ex01 ex01.c \
/cern/pro/lib/libgrafX11.a \
/cern/pro/lib/libpacklib.a \
-L/usr/X11R6/lib \
-lXt -lXext -lXp -lX11 -lcrypt -ldl -lnsl -lm
SUBROUTINE MAIFCN (NPAR,G,F,U,IFLAG,FUTIL)
EXTERNAL MAIANI
...
CALL FUTIL(A,B,C)
...
END
In the user's program, he calls MINUIT:
EXTERNAL (MAIFCN,MAIANI)
CALL MINUIT (MAIFCN,MAIANI)
which specifies that the name of the subroutine
FCN will be
MAIFCN and the
name of
FUTIL will be
MAIANI. This of course requires that he supply a
subroutine
MAIANI:
SUBROUTINE MAIANI(A,B,C)
which will be called from
MAIFCN with the statement
CALL FUTIL(A,B,C)
The above is only of limited usefulness, because if you want to call a
different subroutine from
MAIFCN, you have to call MINUIT again with a
different second argument to specify the name of the new routine
FUTIL.
That is all you can do in "data-card-driven mode". It is more useful in
"Fortran-driven mode", where the user can execute commands by calling
either
MNREAD (which reads in commands from a data stream) or
MNCOMD
(which executes a single command given in "card" format) or
MNEXCM (which
executes a single command given in "argument" format). All three of the
above subroutines allow the caller to specify the (new) name of the
FUTIL
subroutine for each MINUIT command executed. That is what PAW does.
#includeOn Linux the following script can be used to produce the executable:#include #include #if defined(__hpux) || defined(_IBMR2) # define extname #endif #ifdef extname #define UFIT ufit_ #else #define UFIT ufit #endif #define PAWC_SIZE 50000 typedef struct { float PAW[PAWC_SIZE]; } PAWC_DEF; #define PAWC COMMON_BLOCK(PAWC,pawc) COMMON_BLOCK_DEF(PAWC_DEF,PAWC); PAWC_DEF PAWC; typedef struct { double dpar[24]; double fitfun; } HCFITD_DEF; #define HCFITD COMMON_BLOCK(HCFITD,hcfitd) COMMON_BLOCK_DEF(HCFITD_DEF,HCFITD); HCFITD_DEF HCFITD; int h_shape=1000; extern float ufit(float *xi) { float a,b,c,d; float y, x; x = *xi; a=HCFITD.dpar[0]; b=HCFITD.dpar[1]; c=HCFITD.dpar[2]; d=HCFITD.dpar[3]; HCFITD.fitfun = b*exp(-b*(d-x))*pow(b*sqrt((x-d)*(x-d)),(a-1.))/c; y = HCFITD.fitfun; return (y); } void fill(int histo) { HFILL(histo,1.,0.,0.0156); HFILL(histo,2.,0.,0.0579); HFILL(histo,3.,0.,0.1189); HFILL(histo,4.,0.,0.1528); HFILL(histo,5.,0.,0.1576); HFILL(histo,6.,0.,0.1382); HFILL(histo,7.,0.,0.0973); HFILL(histo,8.,0.,0.0705); HFILL(histo,9.,0.,0.0541); HFILL(histo,10.,0.,0.0381); HFILL(histo,11.,0.,0.0282); HFILL(histo,12.,0.,0.0211); HFILL(histo,13.,0.,0.0151); HFILL(histo,14.,0.,0.0112); HFILL(histo,15.,0.,0.0092); HFILL(histo,16.,0.,0.0058); HFILL(histo,17.,0.,0.0044); HFILL(histo,18.,0.,0.0032); } void fit(int histo) { float par[4],step[4], pmin[4], pmax[4], sig[4], chi2; par[0] = 3.9; par[1] = 0.6; par[2] = 5.3; par[3] = 0.6; pmin[0] = 0.; pmin[1] = 0.; pmin[2] = 0.; pmin[3] = 0.; pmax[0] = 0.; pmax[1] = 0.; pmax[2] = 0.; pmax[3] = 0.; step[0] = -1.; step[1] = -1.; step[2] = -1.; step[3] = -1.; HFITH(histo,ufit," ",4 ,par,step,pmin,pmax,sig,chi2); } main() { int h_shape=1000; char title[80]="test"; int step=18; float min=1.; float max=19.; char file[80]="fit.dat"; HLIMIT(PAWC_SIZE); HBOOK1(h_shape,title,step,min,max,0.); fill(h_shape); fit(h_shape); HRPUT(0,file,"N"); }
gcc -g -c -Df2cFortran -I/cern/pro/include/cfortran fit.c g77 -o fit.exe fit.o `cernlib packlib,mathlib` -lm
sed -e "s/.$//" $1 > $1.tmp mv -f $1.tmp $1You can just copy/paste this two lines in the file cleanctrl and do:
$ chmod +x cleanctrland then each time you should clean an ASCII file coming from Windows type:
$ cleanctrl tobecleaned.kumac