      subroutine hec_slow_pass
c
c quick dummy pass to get slow control info 
c
      implicit none
c
c user datacard values common
c
      include'hec_par.inc'              !shared parameters
      include'hec_datacard.inc'
      include'hec_runh.inc'
      include'hec_hvstat.inc'
c
c set maximum epio buffers with dummy arrays
c
      include'hec_maxepio.inc'
c
c local variable declaration
c
      logical hec_nextevt_epio_slow
      external hec_nextevt_epio_slow
      integer iubuff, ierr
c
c initialize HV related variables
c
      lhvstat = .false.
      call vzero(ic_hvstat,i_adc_dim)
      call vzero(ic_hv_cor,i_adc_dim)
      call vzero(ic_hv_known,i_adc_dim)
c
c do not try to read slow control records before 1998
c
      if (irunpd. lt. 7) return
c
      print *, ' '
      print *, ' *** using hec_slow_pass.f to get slow control info'
c
c initialise data io for pass
c
      call hec_io_pass_ini
c
c two logical slow control records/run
c
      do while ( hec_nextevt_epio_slow(epdatabuf,iepbufset) )
c
c handle end of event data io
c
         call hec_io_pass_evt
c
      enddo
c
c print the epio banks stats
c
      if (in_typ(1) .eq. 2) call hec_stats_epio_print
c
c pass termination
c zebra
c
      if (in_typ(1) .eq. 1) then
        call fzendi(in_typ(2), 'T')
        call fzinfo(in_typ(2))
        rewind(in_typ(2))
c
c epio
c
      elseif (in_typ(1) .eq. 2) then
        call eprwnd(in_typ(2), iubuff, ierr)
        if (ierr .ne. 0) then
          print *, ' *** error calling eprwnd in hec_io_pass_ter', ierr
          stop
        endif
      endif
c
c fill HV status arrays for each cell. Skip it in online mode,
c unless calibrated energy histograms are asked for. 
c also skip first runs of june 2000 testbeam, when the SC bank where
c screwed up
c      
      if( irunpd.eq.12.and.run_no.lt.9420)then
         print*,' *** WARNING: PC HV information is wrong'
         print*,' *** cannot calculate HV correction factor'      
         print*,' '      
      else if( irunpd.gt.8 )then          
          if(run_mode.eq.1. or. histo_switch(5).eq.1) then
             call hec_hvstat
          endif
      endif
c
      print *, ' *** slow control pass done'
c
      end

 
              
            
          
