C------------------------------------------------
      FUNCTION OPTRKLEV2(name,trnev)
C------------------------------------------------
C     Written by Emiliano Mocchiutti
C     v. 0.2
C	  
      INCLUDE 'COMMON2.TXT'
C
      CHARACTER*100 name
C
      INTEGER lrec, optrklev2,trnev
      INTEGER istat
      PARAMETER (lrec=8190)
      REAL hmemor(9000000)
      integer Iquest(100)    
      COMMON /pawc/hmemor
      save /pawc/
      Common /QUEST/ Iquest
      save /quest/
      CALL HLIMIT(9000000)
      Iquest(10) = 256000
C
      optrklev2 = 0
      trnev = 0
C 
C     CHANGE here (hbname and hbnt if you want another ntuple id number
C
      call HROPEN(81,'LEVEL2',name,'QP',4096,istat)
      if(istat.ne.0) goto 19      
      call HRIN(22,9999,20)       
      call access_level2
      call HNOENT(42,trnev)

 19   continue

C
c
      RETURN
      END


      SUBROUTINE access_level2
*
      include 'COMMON2.TXT'

      CALL HBNAME(42,' ',0,'$CLEAR')
*
      CALL HBNAME(42,'GENERAL',GOOD2,'$SET')
*
      CALL HBNAME(42,'CPU',PKT_TYPE,'$SET')
*
      CALL HBNAME(42,'TRACKS',NTRK,'$SET')
*
      CALL HBNAME(42,'SINGLETX',NCLSX,'$SET')
*
      CALL HBNAME(42,'SINGLETY',NCLSY,'$SET')
*

*
      return
      END
