      REAL FUNCTION MUEVENT(ICH)
*********************************************************
*                                                       *
* This file was generated by HUWFUN.                    *
*                                                       *
*********************************************************
*
*     Ntuple Id:      1000 
*     Ntuple Title:   DATA
*     Creation:       06/01/2006 23.39.31
*
*********************************************************
*
      LOGICAL         CHAIN
      CHARACTER*128   CFILE
      INTEGER         IDNEVT,NCHEVT,ICHEVT
      REAL            OBS(13)
*
      COMMON /PAWIDN/ IDNEVT,OBS
      COMMON /PAWCHN/ CHAIN, NCHEVT, ICHEVT
      COMMON /PAWCHC/ CFILE
*
*--   Ntuple Variable Declarations
*
      REAL TIME
      INTEGER IEV,NH,IHITS(1024)
*
      COMMON /PAWCR4/ IEV,TIME,NH,IHITS
*

*
*--   Enter user code here
*
      INTEGER I,ICH
      INTEGER ADCDAT,TDCDAT,CH,EDGE

      IF (NH.GT.0) THEN
        DO I=1,NH
          TDCDAT=IBITS(IHITS(I),0,16)
          CH = IBITS(IHITS(I),17,5)
          EDGE = IBITS(IHITS(I),16,1)
          IF (CH.EQ.ICH) THEN            
            CALL HFILL(10+EDGE,FLOAT(TDCDAT),0.,1.)
            CALL HFILL(20+EDGE,FLOAT(TDCDAT),0.,1.)
          ENDIF
        ENDDO
        MUEVENT=1
       ELSE
        MUEVENT=0
      ENDIF 

      END
