      subroutine hec_ped_fill
c
c fill preferred pedestals and rms
c
      implicit none
c
      include'hec_par.inc'      !shared parameters
      include'hec_datacard.inc' !datacard values
      include'hec_ped.inc'      !pedestal values
c
      integer ic
c
c fill preferred pedestals and rms 
c
c pedestals for each event
c
      if (mk_ped .eq. 1 .or. mk_ped .eq. 3) then
        do ic = 1, i_adc_dim
          adc_ped(ic) = adc_ped_evt(ic)
          adc_rms(ic) = adc_rms_evt(ic)
        enddo
c
c pedestals computed over all events
c
      elseif (mk_ped .eq. 2 .or. mk_ped .eq. 4 .or. 
     +        io_ped(1) .ge. 1) then
        do ic = 1, i_adc_dim
          adc_ped(ic) = adc_ped_run(ic)
          adc_rms(ic) = adc_rms_run(ic)
        enddo
      endif
c
      end
          
        
