      PROGRAM HWIGPR
C---COMMON BLOCKS ARE INCLUDED AS FILE HERWIG65.INC
      INCLUDE 'HERWIG65.INC'
      INTEGER N
      DOUBLE PRECISION HWRUNI
      EXTERNAL HWUDAT,HWRUNI
C---MAX NUMBER OF EVENTS THIS RUN
      MAXEV=100
C---BEAM PARTICLES
      PART1='P'
      PART2='P'
C---BEAM MOMENTA
      PBEAM1=7000.0D0
      PBEAM2=7000.0D0
C---PROCESS
      IPROC=-100
C---INITIALISE OTHER COMMON BLOCKS
      CALL HWIGIN
C---USER CAN RESET PARAMETERS AT
C   THIS POINT, OTHERWISE DEFAULT
C   VALUES IN HWIGIN WILL BE USED.
      PRVTX = .FALSE.
      MAXPR = 1
C---COMPUTE PARAMETER-DEPENDENT CONSTANTS
      CALL HWUINC
C---CALL HWUSTA TO MAKE ANY PARTICLE STABLE
      CALL HWUSTA('PI0     ')
C---USER'S INITIAL CALCULATIONS
      CALL HWABEG
C---INITIALISE ELEMENTARY PROCESS
      CALL HWEINI
C---LOOP OVER EVENTS
      DO 100 N=1,MAXEV
C---INITIALISE EVENT
      CALL HWUINE
C---GENERATE HARD SUBPROCESS
      CALL HWEPRO
C---GENERATE PARTON CASCADES
      CALL HWBGEN
C---DO HEAVY OBJECT DECAYS
      CALL HWDHOB
C---DO CLUSTER FORMATION
      CALL HWCFOR
C---DO CLUSTER DECAYS
      CALL HWCDEC
C---DO UNSTABLE PARTICLE DECAYS
      CALL HWDHAD
C---DO HEAVY FLAVOUR HADRON DECAYS
      CALL HWDHVY
C---ADD SOFT UNDERLYING EVENT IF NEEDED
      CALL HWMEVT
C---FINISH EVENT
      CALL HWUFNE
C---USER'S EVENT ANALYSIS
      CALL HWANAL
  100 CONTINUE
C---TERMINATE ELEMENTARY PROCESS
      CALL HWEFIN
C---USER'S TERMINAL CALCULATIONS
      CALL HWAEND
      STOP
      END
C----------------------------------------------------------------------
      SUBROUTINE HWABEG
C     USER'S ROUTINE FOR INITIALIZATION
C----------------------------------------------------------------------
      END
C----------------------------------------------------------------------
      SUBROUTINE HWAEND
C     USER'S ROUTINE FOR TERMINAL CALCULATIONS, HISTOGRAM OUTPUT, ETC
C----------------------------------------------------------------------
      END
C----------------------------------------------------------------------
      SUBROUTINE HWANAL
C     USER'S ROUTINE TO ANALYSE DATA FROM EVENT
C----------------------------------------------------------------------
      INCLUDE 'HERWIG65.INC'
      DOUBLE PRECISION PTOTAL(4),EPS
      INTEGER ITOTAL,I,J
      PARAMETER(EPS=1.0D-4)
C--TEST CHARGE AND MOMENTUM CONSERVATION
      IF(IERROR.NE.0) RETURN
      DO I=1,4
         PTOTAL(I) = ZERO
      ENDDO
      ITOTAL = 0
      DO I=1,NHEP
         IF(ISTHEP(I).EQ.1) THEN
            ITOTAL = ITOTAL+ICHRG(IDHW(I))
            DO J=1,4
               PTOTAL(J) = PTOTAL(J)+PHEP(J,I)
            ENDDO
         ENDIF
      ENDDO
      DO I=1,2
         ITOTAL = ITOTAL-ICHRG(IDHW(I))
         DO J=1,4
            PTOTAL(J) = PTOTAL(J)-PHEP(J,I)
         ENDDO
      ENDDO
      IF(ITOTAL.NE.0) PRINT *,
     &     'NON-CONSERVATION OF CHARGE: CHARGE VIOLATION=',ITOTAL
      DO J=1,4
         IF(ABS(PTOTAL(J)).GT.EPS) PRINT *,
     &     'NON-CONSERVATION OF MOMENTUM: MOMENTUM VIOLATION=',PTOTAL(J)
      ENDDO
      END
C----------------------------------------------------------------------
