      subroutine hec_crl_pass1
c
c pass 1 over data set to fill some system histograms
c
      implicit none
c
      include'hec_par.inc'      !shared parameters
      include'hec_datacard.inc' !datacard values
      include'hec_evth.inc'     !event header
c
c local variable declaration
c
      logical hec_nextevt
      external hec_nextevt
      logical again
c
      print *, ' '
      print *, ' *** starting pass for correlations package'
c
c initialise data io for pass
c
      call hec_io_pass_ini
c
c loop over events
c
      i_event = 1
      again = .true.

      do while (i_event .le. n_evtmax .and. again)
c
c check on end of epio file and/or errors
c
         again = hec_nextevt()

         if(again)then
 
            if (mod(i_event, 1000) .eq. 0 .or. i_event .eq. 1) then
               print *, ' *** starting event number ', i_event
            endif
c
c process event
c
            call hec_trig_evt
c
c system correlation analysis for a given event
c
            call hec_crl_evt
c
c handle end of event data io
c
            call hec_io_pass_evt
c
            i_event = i_event + 1
c
         endif
c
      enddo                     ! enddo over events
c
      i_event = i_event - 1
      print *, ' *** events processed      ', i_event
c
c system histogram analysis at end of event loop
c
      call hec_crl_ana
c
c handle data io at pass end
c
      call hec_io_pass_ter
c
      print *, ' *** pass done for correlation pacakge'
c
      end

 
              
            
          
