Ntuple creation


Creation of an Row-Wise Ntuple (RWN) and first look at its contents

1 NTUPLE/CREATE 10 'CERN Population' 11 ' ' 3500 _ Category Division Flag Age Service Children Grade _ Step Nation Hrweek Cost * 2 NTUPLE/READ 10 APTUPLE.DAT 3 HISTO/FILE 1 RWN_APTUPLE.HBOOK 1024 N 3 HROUT 10 4 NTUPLE/PRINT 10 zone 1 2 6 OPT STAT 6 SET STAT 110 4 NTUPLE/PLOT 10.Age ntuple/plot 10.Division

  1. /NTUPLE/CREATE IDN TITLE NVAR CHRZPA NPRIME VARLIST : Allows to create an Ntuple. An Ntuple is a matrix of n columns. Each line of the matrix is often called an ``event''. Internally there is two different way to access the data: by rows (Row-Wise Ntuple) or by columns (Column-Wise Ntuple). The Ntuple may be created either in memory or, if necessary, using an automatic overflow to an histogram file.
  2. NT/READ allows to fill an RW/Ntuple with numeric values read from an existing ASCII file.
  3. Like histograms, Ntuples are HBOOK objects and can be stored into histogram files opened via the command HIST/FILE .
  4. The command NT/PRINT gives the description of the Ntuple (see next page).
  5. NT/PLOT allows to plot an Ntuple. The syntax is:
                          NT/PLOT nid.n ......
    
    where `` nid '' is the Ntuple identifier (a number) and `` n '' is the number or the name of one of the variable in the Ntuple. By default, if `` n '' is not specified, the first variable of the Ntuple is ploted.

    Note also:

  6. OPT STAT and SET STAT are used to plot some statistical informations.


Creation of Column-Wise Ntuple (CWN)

1 HISTO/FILE 1 CWN_APTUPLE.HBOOK 1024 N 2 CALL CERNPOP.F hrout 11 ntuple/print 11 zone 1 2 opt stat set stat 110 ntuple/plot 11.Age 3 NTUPLE/PLOT 11.Division

  1. A new HBOOK file is open. If the Ntuple created after doesn't fit in memory, it will be automatically write on this file.
  2. This command create and read a CW/Ntuple. It is the equivalent of the /NTUPLE/CREATE and /NTUPLE/READ commands in the previous example (for the time being these commands work only with the RWN format). For more details on the CW/Nutples management see the HBOOK manual. The main advantages of the CW/Nutples compare to the RW/Nutples are:
    1. The speed: only the used data are read.
    2. The possibility to have typed variable (not only real).
    3. The compactness.
    4. The ``Array variables'' with a fixed or variable length.
  3. The axis are directly drawn with character labels.


COMIS routine used to create a CW/Ntuple

Subroutine cernpop * integer category, flag, age, service, children, grade, step, + hrweek, cost common /cern/ category, flag, age, service, children, grade, + step, hrweek, cost character*4 division, nation common /cernc/ division, nation * character*132 chform dimension rdata(11) character*4 divs(13), nats(15) data divs /'AG', 'DD', 'DG', 'EF', 'EP', 'FI', 'LEP', 'PE', + 'PS', 'SPS', 'ST', 'TH', 'TIS'/ data nats /'AT', 'BE', 'CH', 'DE', 'DK', 'ES', 'FR', 'GB', + 'GR', 'IT', 'NL', 'NO', 'PT', 'SE', 'ZZ'/ * open(unit=41,file='aptuple.dat',status='old') * call hbnt(11,'CERN Population (CWN)',' ') chform = ' CATEGORY[100,600]:I, FLAG:U:6, AGE[1,100]:I,'// + ' SERVICE[0,60]:I, CHILDREN[0,10]:I, GRADE[3,14]:I,'// + ' STEP[0,15]:I, HRWEEK:I, COST:I' call hbname(11, 'CERN', category, chform) chform = 'DIVISION:C, NATION:C' call hbnamc(11, 'CERN', division, chform) * 10 read(41, '(10F4.0, F7.0)', end=20) rdata category = rdata(1) division = divs(int(rdata(2))) flag = rdata(3) age = rdata(4) service = rdata(5) children = rdata(6) grade = rdata(7) step = rdata(8) nation = nats(int(rdata(9))) hrweek = rdata(10) cost = rdata(11) call hfnt(11) goto 10 * 20 close (41) end

RWN NT/PRINT output

******************************************************** * NTUPLE ID= 10 ENTRIES= 3354 CERN Population * ******************************************************** * Var numb * Name * Lower * Upper * ******************************************************** * 1 * CATEGORY * 0.102000E+03 * 0.567000E+03 * * 2 * DIVISION * 0.100000E+01 * 0.130000E+02 * * 3 * FLAG * 0.000000E+00 * 0.310000E+02 * * 4 * AGE * 0.210000E+02 * 0.640000E+02 * * 5 * SERVICE * 0.000000E+00 * 0.350000E+02 * * 6 * CHILDREN * 0.000000E+00 * 0.600000E+01 * * 7 * GRADE * 0.300000E+01 * 0.140000E+02 * * 8 * STEP * 0.000000E+00 * 0.150000E+02 * * 9 * NATION * 0.100000E+01 * 0.150000E+02 * * 10 * HRWEEK * 0.200000E+01 * 0.440000E+02 * * 11 * COST * 0.686000E+03 * 0.188530E+05 * ********************************************************

CWN NT/PRINT output

****************************************************************** * Ntuple ID = 11 Entries = 3354 CERN Population (CWN) ****************************************************************** * Var numb * Type * Packing * Range * Block * Name * ****************************************************************** * 1 * I*4 * 11 * [100,600] * CERN * CATEGORY * 2 * U*4 * 6 * * CERN * FLAG * 3 * I*4 * 8 * [1,100] * CERN * AGE * 4 * I*4 * 7 * [0,60] * CERN * SERVICE * 5 * I*4 * 5 * [0,10] * CERN * CHILDREN * 6 * I*4 * 5 * [3,14] * CERN * GRADE * 7 * I*4 * 5 * [0,15] * CERN * STEP * 8 * I*4 * * * CERN * HRWEEK * 9 * I*4 * * * CERN * COST * 10 * C*4 * * * CERN * DIVISION * 11 * C*4 * * * CERN * NATION ****************************************************************** * Block * Unpacked Bytes * Packed Bytes * Packing Factor * ****************************************************************** * CERN * 44 * 22 * 2.000 * * Total * 44 * 22 * 2.000 * ****************************************************************** * Number of blocks = 1 Number of columns = 11 * ******************************************************************

PAW TutorialLast update: 1999/04/01 14.58
Olivier.Couet@Cern.Ch