C   15/02/82 704061535  MEMBER NAME  TAGF82   (S)           FORTRAN
      SUBROUTINE TAGF82(IFLAG)
C
C  INTRODUCED ON THIS LIBRARY ON 6.4., BY COPY FROM JADEPR.JADESR
C
C THE PREVIOUS VERSION SEEMS TO HAVE BEEN A TEST VERSION, IT GAVE
C WRONG RESULTS (DID NOT FIND THE MAJORITY OF TAGGED EVENTS)
C  (INTRODUCED IN MARCH 85 BY JOHN NYE, FROM GOD KNOWS WHERE)
C  (IT CAN BE INSPECTED IN TAGF820)
C
C                               6.4.87  J.OLSSON
C
C---  TAGF82 IS AN UPDATED VERSION (1982 ONWARDS) OF TAGFLG
C---  TAGF82 CHECKS THE CONTENT OF WORD 24 IN THE LATC-BANK
C---  IF FOR A TAGG-LATCH SET THE SMZ-/SPZ-BIT IS MISSING,
C---     THE CONTENT OF WORD 28 IS CHECKED AS WELL
C---  TAGF82 RETURNS THE SUM OF THE FOLLOWING NUMBERS VIA IFLAG:
C       0  IF NO LEAD-GLASS OF THE FORWARD DETECTOR IS HIT
C       1  IF THE LEAD-GLASS ENERGY OF THE MINUS Z-SIDE IS ABOVE
C             THRESHOLD (SMZ)
C       2  IF THE LEAD-GLASS ENERGY OF THE PLUS Z-SIDE IS ABOVE
C             THRESHOLD (SPZ)
C      10  IF THE TAGG-LATCH (SMZ.OR.SPZ) IS SET
C     100  IF THE LUMI-LATCH (SMZ.AND.SPZ) IS SET
C
C     H.WRIEDT     15.02.82     13:40
C     LAST MODIFICATION    23.02.82    13:10
C
      EXTERNAL BDLM
C
      COMMON /BCS/ IDATA(30000)
C
      DATA I2/2/,I5/5/,I6/6/,I7/7/,I13/13/,I15/15/,N3/3/
C
      IFLAG = 0
C---  FETCH LATC-POINTER
      IND = IDATA(IBLN('LATC'))
      IF (IND.EQ.0) RETURN
C---  FETCH LATC-DATA
C---  LATCH 22 (I*2-WORD 24)
      LAT = IDATA(IND+12)
C---  LUMI-BIT (#5)
      LLAT = JBIT(LAT,I5)
      IF (LLAT.EQ.1) IFLAG = 100
C---  TAGG-BITS (#2 - #4)
      LLAT = JBYT(LAT,I2,N3)
      IF (LLAT.NE.0) IFLAG = IFLAG + 10
C---  SMZ- AND SPZ-BITS
C     SMZ (#6)
      LLAT = JBIT(LAT,I6)
      IF (LLAT.EQ.1) IFLAG = IFLAG+1
C     SPZ (#7)
      LLAT = JBIT(LAT,I7)
      IF (LLAT.EQ.1) IFLAG = IFLAG+2
      IF (IFLAG.NE.10) RETURN
C---  IF SMZ- AND SPZ-BITS ARE MISSING ALTHOUGH THE TAGG-BIT IS SET,
C     LATCH 26 (I*2-WORD 28) IS CHECKED AS WELL
      LAT = IDATA(IND+14)
C---  SMZ- AND SPZ-BITS
C     SMZ-LO (#13)
      LLAT = JBIT(LAT,I13)
      IF (LLAT.EQ.1) IFLAG = IFLAG+1
C     SPZ-LO (#15)
      LLAT = JBIT(LAT,I15)
      IF (LLAT.EQ.1) IFLAG = IFLAG+2
      RETURN
      END
