      subroutine hec_ntuple_evt1
c
c pass 1 standard ntuples filling event routine
c
      implicit none
c
      include'hec_par.inc'       ! parameters used in other includes
      include'hec_adc.inc'       ! adc values
      include'hec_beam.inc'      ! beam chamber variables
      include'hec_cal.inc'       ! calibrated energies common
      include'hec_datacard.inc'  ! common for datacard values
      include'hec_dig.inc'       ! digital filtering variables
      include'hec_evth.inc'      ! event header common
      include'hec_geo.inc'       ! geometry correspondence tables common
      include'hec_his_sys.inc'   ! system histogram id common
      include'hec_max.inc'       ! max adc and time values common
      include'hec_ntuple.inc'    ! ntuple common
      include'hec_ntuple_sys.inc'! ntuple system common
      include'hec_ped.inc'       ! pedestal values common
      include'hec_search.inc'    ! search common
      include'hec_tdc.inc'       ! tdc common
      include'hec_trig.inc'      ! trigger common
c
      integer i
c
c do over all "good" adc channels 
c
      hec_evtno = i_event
      do i = 1, i_good_cells
c
c fill ntuple variables for adc max, use either calibrated
c or uncalibrated depending on eunit datacard
c
        if (eunits_ntp .eq. 1) then
          hec_signal(i) = adc_max_ic(cell_list(i),1)
        elseif (eunits_ntp .eq. 2) then
          hec_signal(i) = hec_cal_ic(cell_list(i))
        else
          hec_signal(i) = 0.    
        endif
c
      enddo
c
c fill ntuple variable with trigger value
c
      call vzero (hec_trig,5)
      if (trig_physics) hec_trig(1) = 1
      if (trig_e) hec_trig(2) = 1
      if (trig_mu) hec_trig(3) = 1
      if (trig_pi) hec_trig(4) = 1
      if (random_ntp .eq. 0) then
         if (trig_random.or.trig_random_hard) hec_trig(5) = 1
      else if (random_ntp .eq. 1) then
         if (trig_random_hard) hec_trig(5) = 1
      else if (random_ntp .eq. 2) then
         if (trig_random) hec_trig(5) = 1      
      endif
c
c fill standard event block
c
      call hfntb(id_ntuple_evt,'hecevt')
c
c if requested fill mwpc block
c
      if (mk_beam .ne. 0) then
        hec_xbeam = xbeam
        hec_ybeam = ybeam
        hec_xslop = xslop
        hec_yslop = yslop
        if (xbeam_ok) then
          hec_xbeam_ok = 1
        else
          hec_xbeam_ok = 0
        endif
        if (ybeam_ok) then
          hec_ybeam_ok = 1
        else
          hec_ybeam_ok = 0
        endif
c
        call hfntb(id_ntuple_evt,'hecmwpc')
      endif
c

      return
      end







