Histograms are never created directly on a disk file.
They are always created in the current directory in memory
(//PAWC or //PAWC/subdir).
Histograms are saved on the disk file with a call of type
CALL \Rind{HROUT}
In case of disk-resident Ntuples, it is the same thing.
The Ntuple header
(data structure containing the column names) is always created
in the current directory in memory
(//PAWC or //PAWC/subdir).
However, the call to HBNT remembers the current
directory on disk (in the case below
the CD on disk is //K0).
When you fill the Ntuple, HFNT fills a buffer in memory.
When this buffer is full, HFNT knows what is the CD on disk.
The buffer is written into that directory.
Note that your current directory on disk may be somewhere else.
HFNT will temporarely change the CD to //K0
and will reset the CD to what it was before calling HFNT.
At the end of your job, you have to save the header and the current buffer
in memory on the disk file.
For that you have to:
//KO.
Creating a disk resident Ntuple
call HCDIR('//PAWC',' ')
*-- HROPEN sets the directory to //K0, so no call to HCDIR is needed
call HROPEN(50,'K0','~/mydir/K0.rz','N',1024,ISTAT)
if (ISTAT.ne.0) write(6,*) 'Error in HROPEN'
call HBNT(1000,'NTuple','D')
call HLDIR('//PAWC','T') ! Now you can see the header in //PAWC
call HLDIR('//K0','T') ! OK, nothing yet on //K0
*-- HBNAME describes the Ntuple
call HBNAME(1000,'Event',EvtNo,
+ 'RunNo:I,Evtno:I,NPos:I,NNeg:I,'//
+ ....
....
call HLDIR('//K0','T') ! Nothing yet on //K0
call HCDIR('//K0',' ') ! Useless, HFNT remembers that buffers are written to //KO
call HFNT(1000)
call HLDIR(' ','T') ! This will not show anything on //K0.
! However if you call HLDIR(' ','TA') you will see all Ntuple
! extensions in the case you have many calls to HFNT.
! In this particular example everything is still in memory.
....
call HCDIR('//K0',' ') ! Useless, you are already here
call HLDIR('//K0',' ') ! same as call hldir(' ','T')
call RZLDIR(' ',' ')
call HROUT(0,icycle,' ')
*-* If you call HLDIR(' ',' ') here you will see the header
*-* If you call HLDIR(' ','A') here you will see the header and your Ntuple extensions
call HREND('K0')