program extendhbook implicit none integer nsize parameter (nsize=1500000) real h(nsize) common/pawc/h integer ierr,icycle integer i,j integer noent ! # of events in original ntuple integer nmxhep parameter (nmxhep=3950) C block HEPEVT integer nevhep integer nhep integer idhep(nmxhep) integer jsmhep(nmxhep) integer jsdhep(nmxhep) real phep(5,nmxhep) real vhep(4,nmxhep) common/HEPEVT/nevhep,nhep,idhep,jsmhep,jsdhep,phep,vhep integer nmxpar parameter (nmxpar=200) C block MC_PARAM integer irun integer ievt real weight real xsecn integer ifilter integer nparam real param(nmxpar) common/MC_PARAM/irun,ievt,weight,xsecn,ifilter,nparam,param call hlimit(nsize) call hropen(1,'INHEPEVT','test.ntpl',' ',4096,ierr) call hcdir('//INHEPEVT',' ') call hrin(101,99999,20) call hbname(121,' ',0,'$CLEAR') call hbname(121,'HEPEVT',nevhep,'$SET') call hbname(121,'MC_PARAM',irun,'$SET') C get nr. of events in the original ntuple call hnoent(121,noent) C output ntuple call hcdir('//PAWC',' ') call hropen(2,'HEPEVT','test_ex.ntpl','N',4096,ierr) call hcdir('//HEPEVT',' ') call hbnt(101,'HEPEVT','D') call hbname(101,'HEPEVT',nevhep, + 'NEVHEP:I,'// + 'NHEP:I::[0,3950],'// + 'IDHEP(NHEP):I,'// + 'JSMHEP(NHEP):I,'// + 'JSDHEP(NHEP):I,'// + 'PHEP(5,NHEP):R,'// + 'VHEP(4,NHEP):R') call hbname(101,'MC_PARAM',irun, + 'IRUN:I,'// + 'IEVT:I,'// + 'WEIGHT:R,'// + 'XSECN:R,'// + 'IFILTER:I,'// + 'NPARAM:I::[0,200],'// + 'PARAM(NPARAM):R') C set every field to zero call nullify C event loop: write anything you want into ntuple. do i=1,noent C read original content call hcdir('//INHEPEVT',' ') call hgnt(121,i,ierr) C modify on demand nparam=2 do j=1,2 param(j)=j enddo C write data into the new ntuple call hcdir('//HEPEVT',' ') call hfnt(101) enddo C call nullify C add some more events into ntuple do i=noent+1,noent+10 nhep=1 idhep(1)=211 C write data into the new ntuple call hcdir('//HEPEVT',' ') call hfnt(101) enddo call hcdir('//HEPEVT',' ') call hrout(101,icycle,' ') call hrend('HEPEVT') call hrend('INHEPEVT') close(1) close(2) end subroutine nullify C*********************** integer i,j integer nmxhep parameter (nmxhep=3950) C block HEPEVT integer nevhep integer nhep integer idhep(nmxhep) integer jsmhep(nmxhep) integer jsdhep(nmxhep) real phep(5,nmxhep) real vhep(4,nmxhep) common/HEPEVT/nevhep,nhep,idhep,jsmhep,jsdhep,phep,vhep integer nmxpar parameter (nmxpar=200) C block MC_PARAM integer irun integer ievt real weight real xsecn integer ifilter integer nparam real param(nmxpar) common/MC_PARAM/irun,ievt,weight,xsecn,ifilter,nparam,param C nullify, just for sure nevhep=0 nhep=0 do i=1,nmxhep idhep(i)=0 jsmhep(i)=0 jsdhep(i)=0 do j=1,4 phep(j,i)=0.0 vhep(j,i)=0.0 enddo phep(5,i)=0.0 enddo irun=0 ievt=0 weight=0.0 xsecn=0.0 ifilter=0 nparam=0 do i=1,nmxpar param(i)=0.0 enddo return end