      subroutine hec_dig
c
c initialize digital filtering package
c initialize variables and read in weight file 
c ML 08/2001  Global timing correction corrections are applied here
c
      implicit none
c
      include'hec_par.inc'      ! shared parameters
      include'hec_datacard.inc' !user datacard values
      include'hec_dig.inc'      ! digital filtering common
      include'hec_dig_sys.inc'  ! digital filtering system commo
      include'hec_runh.inc'     ! run header
c
      integer ic
c
c reset hec_dig_sys.inc quantities
c
      dig_weight_version = 0
      dig_nslice = 0
      dig_nwpar = 0
      dig_slice_1 = 0
      dig_t_global = 0.
      dig_ic_ref = 1
      call vzero(dig_amp_par, i_adc_dim*mx_dig_nslice*mx_dig_nwpar)
      call vzero(dig_tim_par, i_adc_dim*mx_dig_nslice*mx_dig_nwpar)
      call vzero(dig_t0_raw, i_adc_dim)
      call vzero(dig_t0, i_adc_dim)
c
      call vzero(dig_weight_amp, i_adc_dim*mx_dig_nslice)    
      call vzero(dig_weight_tim, i_adc_dim*mx_dig_nslice)
      call vzero(dig_ns, i_adc_dim)
      call vzero(dig_slice_shift, i_adc_dim)
c
c zero hec_dig.inc quantities
c
      call vzero(adc_dig_ic, i_adc_dim*2)
      do ic = 1, i_adc_dim  
        ic_has_amp_weights(ic) = .false.
        ic_has_tim_weights(ic) = .false.
      enddo
c 
      if (mk_dig .gt. 0) then
c
c read in parameters for amplitude weights
c read in parameters for time weights and read in raw t0's
c produce t0's
c
        call hec_dig_read_weights
c
c apply global timing correction
c
c correct pretrigger delay change in aug98
        if (irunpd.eq.8.and.run_no.lt.7871) then
          dig_t_global = dig_t_global + 4.5
        endif
c
c correct pretrigger delay change in aug00
        if (irunpd.eq.13.and.run_no.lt.10368) then
          dig_t_global = dig_t_global + 36.75
        elseif (irunpd.eq.13.and.run_no.lt.10663) then
c really this boundary is somewhere between runs 10657 and 10684
          dig_t_global = dig_t_global + 13.7
        endif
c
c print the weight parameters and raw t0's if requested
c
        if (pr_dig .gt. 0) call hec_dig_print
c
      endif
c
      end




