      subroutine hec_ntuple_ana1
c
c pass 1 standard ntuples filling: run header and slow control 
c
      implicit none
      include'hec_par.inc'       ! parameters used by other commons
      include'hec_beam.inc'      ! beam chamber variables
      include'hec_cal_coef.inc'  ! calibration coefficients
      include'hec_datacard.inc'  ! common for datacard values
      include'hec_dig.inc'       ! digital filtering variables
      include'hec_dig_sys.inc'   ! digital filtering system variables
      include'hec_evth.inc'      ! event header common
      include'hec_geo.inc'       ! geometry correspondence tables common
      include'hec_ntuple.inc'    ! ntuple common
      include'hec_ntuple_sys.inc'! ntuple system common
      include'hec_ped.inc'       ! pedestal common
      include'hec_runh.inc'      ! run header common
      include'hec_hvpar.inc'     ! HV parameter common
      include'hec_hvstat.inc'    ! HV status and corrections common
      include'hec_slow_pc.inc'   ! HV, P, T info common
c
c local variables
c
      integer i
c
c fill run header variables
c
      hec_cells_used = i_good_cells
      hec_runno = run_no
      hec_runpd = irunpd
      hec_beame = e_beam
      hec_numevt = i_event
      hec_parttype = i_part
      hec_cryox = x_cryo
      hec_tabley = y_tabl
      hec_zbeam = zbeam
      hec_peakf = m_pref
c
c enter version of calibration and digital filtering used
c
      if (io_cal(1) .ne. 0) then
        hec_cal_version = cal_version
      else
        hec_cal_version = 0.
      endif
c
      if (mk_dig .ne. 0 .and. m_pref .ge. 2) then
        hec_dig_version = dig_weight_version
      else
        hec_dig_version = 0.
      endif      
c
c shower model type = 0 for real data
c
      hec_shower = 0
c
c energy units of maximum
c
      hec_eunit = eunits_ntp
c
c maximum adc channel number
c
      hec_adc_max = i_adc_used
c
c index for arrays (eg. hec_index(2) gives index corresponding to ic=2)
c
      call vzero(hec_index,i_adc_dim)
c
c values for each good channel
c
      do i = 1, hec_cells_used
        hec_ped_rms(i) = adc_rms(cell_list(i))
        hec_ieta(i) = ictoph(cell_list(i),1)
        hec_iphi(i) = ictoph(cell_list(i),2)
        hec_iz(i) = ictoph(cell_list(i),3)
        hec_ic(i) = cell_list(i)
        hec_index(cell_list(i)) = i
ccc
c        print *,'hec_index, ic ', hec_index(cell_list(i)), cell_list(i)
ccc
      enddo
c
c slow control ntupla
c
      hec_time  = run_start
      do i=1,8
        hec_lartemp(i) = cryo_temp(i) 
      enddo
      hec_press = cryo_press

      hec_adc_used = i_good_cells
      do i = 1, hec_adc_used
         if(ic_hv_known(cell_list(i)))then
            hec_hvcor(cell_list(i)) = ic_hv_cor(cell_list(i))
         else
            hec_hvcor(cell_list(i)) = 0
         endif
      enddo
c
c fill ntuple
c
      call hfnt(id_ntuple_run)
      call hfnt(id_ntuple_slc)
c
      return
      end







