*file member=anxx_ntp library=snoman language=fortran77 date=08:Nov:2004
     
    *     ANX: ANXX Banks Hbook histograms
     
    *     Contact:  M. Huang,  Texas.
     
    *     Parameters:-
    *     ==========
     
    *     hbook_file   in     hbook file name
     
    *     Common Block Access:-
    *     ===================
    *     (ignoring internal and environmental access)
     
    *     Specification:-
    *     =============
     
    *     anxx_ini_ntp: initialize hbook
    *     anxx_trm_ntp: close hbook
     
    *     Revision History:-
    *     ================
     
    *     5.01    M. Huang     First version.
     
     
    c ********************************************************************
    c     Subroutine anxx_ini_ntp                                        *
    c       Initialize ntuple                                            *
    c ********************************************************************
     
 <<<      subroutine anxx_ini_ntp(hbook_file)
          implicit none
     
          include 'fio_mnemonics.inc'
          include 'hbk_com.inc'
          include 'io.inc'
          include 'mt.inc'
          include 'anxx_count_com.inc'
          integer nwords, istat, iperiod, ihd
          character hbook_file*(kfio_mxc_file_name)
     
    * ... output ntuple file name .....
     
          nwords = icons(ldthbk+KTHBK_LRECL)
          call hropen (lun_anx_hbk,'anxx',hbook_file,'N',nwords,istat)
    *      call hcdir ('//anxx',' ')
     
    * -------------------------------------------------------------------
    * ............. TAC, QHS, QHL, QLX (for stage 1) ........
             call hbook1 (6100,'Calibrated TAC',220,-20.0,200.0,0.0)
             call hbook1 (6101,'Calibrated QHS',220,-20.0,200.0,0.0)
             call hbook1 (6102,'Calibrated QHL',220,-20.0,200.0,0.0)
             call hbook1 (6103,'Calibrated QLX',220,-20.0,200.0,0.0)
     
    * ............NHITs ......................................
             call hbook1 (1104,'NHITs',100,0.0,100.0, 0.0)
     
    * ............ TAC, QHS, QHL, QLX, OCC, Orphan fraction (for stage 2) .....
             call hbook1 (2000,'TAC Fraction',100,-0.05,1.05, 0.0)
             call hbook1 (2001,'QHS Fraction',100,-0.05,1.05, 0.0)
             call hbook1 (2002,'QHL Fraction',100,-0.05,1.05, 0.0)
             call hbook1 (2003,'QLC Fraction',100,-0.05,1.05, 0.0)
     
             call hbook1 (2010,'TAC Low Side Fraction',
         +                                   100,-0.05,1.05, 0.0)
             call hbook1 (2011,'QHS Low Side Fraction',
         +                                   100,-0.05,1.05, 0.0)
             call hbook1 (2012,'QHL Low Side Fraction',
         +                                   100,-0.05,1.05, 0.0)
             call hbook1 (2013,'QLX Low Side Fraction',
         +                                   100,-0.05,1.05, 0.0)
     
             call hbook1 (2020,'TAC High Side Fraction',
         +                                    100,-0.05,1.05, 0.0)
             call hbook1 (2021,'QHS High Side Fraction',
         +                                    100,-0.05,1.05, 0.0)
             call hbook1 (2022,'QHL High Side Fraction',
         +                                    100,-0.05,1.05, 0.0)
             call hbook1 (2023,'QLX High Side Fraction',
         +                                    100,-0.05,1.05, 0.0)
     
             call hbook1 (2004,'Neutrino Hi-Occ Fraction',
         +                                   100,-0.01,0.10, 0.0)
             call hbook1 (2005,'Orphan Hits Fraction',
         +                                   100,-0.005,1.005, 0.0)
     
             call hbook1 (2006,'Fail Gain Ratio Fraction',
         +                                   100,-0.01,1.01, 0.0)
     
             do iperiod = 1, nperiod+1
                ihd = 3000 + iperiod
                call hbook1 (ihd,'Period Occ Rate',
         +                        num_bin_low_occ,frac1,frac2,0.0)
             end do
     
          return
          end
     
     
     
    c ********************************************************************
    c     Subroutine anxx_trm_ntp                                        *
    c       close ntuple                                                 *
    c ********************************************************************
     
 <<<      subroutine anxx_trm_ntp
          implicit none
     
          include 'io.inc'
     
          integer icycle
     
          call hcdir ('//anxx',' ')
          call hrout (0,icycle,' ')
          call hrend ('anxx')
          close (lun_anx_hbk)
     
          return
          end
     
    *endfile member=anxx_ntp