      SUBROUTINE HEC_CRL_ANA
C ----------------------------------------------------------------------
C-
C-    User pass 1 analysis
C-
C ----------------------------------------------------------------------
C
      IMPLICIT NONE
C
      INCLUDE 'hec_par.inc'
      INCLUDE 'hec_geo.inc'
      INCLUDE 'hec_crl.inc'
C
C ****  Local variable declarations
C
      REAL    XVAR(4)
C
      INTEGER IA, IT, IA2, IT2
c
      integer nchan, nsamp
C ----------------------------------------------------------------------
C
C ****  Calculate pedestals, noise, correlation coefficients
C
      CALL HEC_CRL_CORREL (1)
c
c set number of channels/samplings to look at
c
        nchan = min(i_adc_used,crl_maxadc)
        nsamp = min(i_tim_used,crl_maxsamp)
C
C ****  Fill ntuple with pedestal and noise
C
      DO IA=1,NCHAN
        XVAR(1)=REAL(IA)
        DO IT=1,NSAMP
          XVAR(2)=REAL(IT)
          XVAR(3)=DPAVE(IT,IA)
          XVAR(4)=DPRMS(IT,IA)
          CALL HFN (1,XVAR)
        ENDDO
      ENDDO
C
C ****  Fill ntuple with correlation coefficients between time samplings
C
      DO IA=1,NCHAN
        XVAR(1)=REAL(IA)
        DO IT=1,NSAMP
          XVAR(2)=REAL(IT)
          DO IT2=IT,NSAMP
            XVAR(3)=REAL(IT2)
            XVAR(4)=DPCORTIM(IT,IT2,IA)
            CALL HFN (2,XVAR)
          ENDDO
        ENDDO
      ENDDO
C
C ****  Fill ntuple with correlation coefficients between ADC channles
C
      DO IT=1,NSAMP
        XVAR(1)=REAL(IT)
        DO IA=1,NCHAN
          XVAR(2)=REAL(IA)
          DO IA2=IA,NCHAN
            XVAR(3)=REAL(IA2)
            XVAR(4)=DPCORADC(IA,IA2,IT)
            CALL HFN (3,XVAR)
          ENDDO
        ENDDO
      ENDDO
C
      END
C ======================================================================
