C   21/07/80 312171956  MEMBER NAME  LGCUTX   (JADEGS)      FORTRAN
      SUBROUTINE LGCUTX(IACC,ECYL,ECAMI,ECAPL,ETOT)
C
C     DETERMINES IF EVENT SHOULD BE KEPT OR REJECTED, BASED ON LG ENERGY
C     IACC=0 MEANS REJECT
C     IACC=1 MEANS ACCEPT
C
C          MODIFIED TO EXCLUDE EDGEBLOCKS IN ENDCAPS IN THE SPINNER TEST
C                     J.OLSSON   11.02.80
C
C OBS!!! THIS IS THE JADEGS VERSION, WITH NO CALLS TO HFILL.
C        IT IS CALLED FROM REDONE, AND INDIRECTLY FROM USREDUC2.
C
      IMPLICIT INTEGER*2 (H)
#include "cdata.for"
      COMMON /CHEADR/ HEAD(108)
      EQUIVALENCE (HRUN,HEAD(18)),(HEVENT,HEAD(19))
      COMMON /CIGG/ IPRN,IGG(80)
      DIMENSION HELP(2)
      EQUIVALENCE (HELP(1),LABL)
      DATA ETOTLM /6000./,EMIN /7000./,EMNCYL/3500./,HELP/0,0/
C     DATA ETOTLM /3000./,EMIN /3000./,EMNCYL/1500./,HELP/0,0/
      DATA MSK200 /Z200/
C
C     INITIALIZE BOS-POINTERS
      DATA MKSTRT /0/
      IF(MKSTRT.NE.0) GOTO 100
        MKSTRT = 1
        IQALGN = IBLN('ALGN')
  100 CONTINUE
C
C SET IACC=0 DIRECTLY; ONLY WAY FOR IACC=1 IS TO FULFILL LIMITS BELOW
      IACC = 0
C
C     FIND ENERGY IN CYLINDER AND ENDCAPS
      CALL ERGTOT(ECYL,ECAMI,ECAPL)
      ETOT=ECYL+ECAMI+ECAPL
      ETOT95 = ETOT * .95
      IF(ETOT.LT.ETOTLM) GO TO 1400
C     LT 95% OF ENERGY IN ENDCAPS MEANS NO BAD BLOCKS
      IF(ECAMI.LT.ETOT95 .AND. ECAPL.LT.ETOT95) GOTO 1400
C     CHECK FOR BAD BLOCKS HERE
      IPJ=IDATA(IQALGN)
      IF(IPJ.LE.0) GO TO 99
      NWO=IDATA(IPJ)
      IF(NWO.LE.3) GO TO 99
      IPJ=2*IPJ + 8
      NWO=IPJ+2*NWO-8
      DO 5004 IJK=IPJ,NWO,2
      IAD=HDATA(IJK-1)
      IF(IAD.LE.2687) GO TO 5004
      ETEST = HDATA(IJK)
      IF(ETEST.LT.ETOT95) GOTO 5004
C TEST HERE TO EXCLUDE EDGE BLOCKS FROM THE CHECK
C     REDUCE TO NUMBERS 1 - 192
      NO = IAD - 2687
C     0 FOR -Z, 1 FOR +Z
      NE = (NO - 1)/96
C     REDUCE TO 1 - 96
      NO = NO - NE*96
C     GET QUADRANT NUMBER 0 - 3
      NQ = (NO - 1)/24
C     REDUCE TO 1 - 24
      NO = NO - NQ*24
      IF(NO.LT.5) GO TO 5004
      IF(NO.GT.15.AND.NO.NE.20) GO TO 5004
      GO TO 5005
5004  CONTINUE
C     COME HERE IF NO BAD BLOCKS
1400  IF(ETOT.GT.EMIN.OR.ECYL.GT.EMNCYL) IACC = 1
      GO TO 1010
 99   CONTINUE
      DATA IPRN1 /0/
      IPRN1 = IPRN1 + 1
      IF(IPRN1.LT.10) WRITE(6,36) IPJ,NWO,HEAD(18),HEAD(19)
 36   FORMAT('  ERROR IN LG BANK  ',4I10)
      GO TO 1010
 5005 IF(IPRN.GT.0) WRITE(6,29) IAD,ETEST
 29   FORMAT(' ADDRESS AND ENERGY OF BAD BLOCK: ',I10,F10.2)
      IGG(71)=IGG(71)+1
1010  RETURN
      END
