      subroutine hec_ped
c
c pedestals package
c
      implicit none
c
      include'hec_par.inc'      !shared parameters
      include'hec_datacard.inc' !user datacard values
      include'hec_ped.inc'      !pedestals
c
c reset pedestal arrays
c
      call vzero(adc_ped_run, i_adc_dim)
      call vzero(adc_rms_run, i_adc_dim)
      call vzero(adc_ped_evt, i_adc_dim)
      call vzero(adc_rms_evt, i_adc_dim)
c
c read pedestal file if requested
c
      if (io_ped(1) .ge. 1) call hec_ped_read
c
c make pedestals over all events if requested
c
      if (mk_ped .le. 1) return
c
c first pass over data set
c
      call hec_ped_pass1
c
c second pass over data set if required
c
      if (sc_ped .gt. 0.) call hec_ped_pass2
c
c reset pedestal arrays for each event
c
      call vzero(adc_ped_evt, i_adc_dim)
      call vzero(adc_rms_evt, i_adc_dim)
c
      print *, ' *** end of pedestal computation over all events'
c
c write pedestal file if requested and if it has been made
c
      if (io_ped(3) .ge. 1) call hec_ped_write
c
      end

 
              
            
          
