C
C---------------------------------------------------------------------
      SUBROUTINE LATERALE(RQT1,RQT2)
C---------------------------------------------------------------------
C RQT1 (IT WILL BE CALLED QTRACK IN THE N-TUPLE) IS THE SUM OF THE DETECTED
C ENERGY IN THE STRIP ALONG THE TRACK AND THE TWO CLOSEST STRIPS . FOR ALL THE
C LAYERS . RQT2 (IS NOT USED IN THE N-TUPLA) IS THE TOTAL ENERGY MINUS RQT1 .
C
      INCLUDE 'INTEST.TXT'
C
      INTEGER A,B, INPIA
      INTEGER IBAR(2,NPLAV)
      REAL BAR(2,NPLAV)
      REAL RQT1, RQT2
      COMMON / ANGOLO / BAR, IBAR
      SAVE / ANGOLO /
C
      RQT1 = 0.
      RQT2 = 0.
C
      INPIA = 1
C     
      DO I = INPIA, NPLA
         A = IBAR(1,I)
C     
C     EM
C     
         IF (A.EQ.-1) GOTO 600
C     
C     END EM
C     
         IF (A.LE.2) A = 2
         IF (A.GE.NCHA) A = NCHA - 1
         DO J = A-1,A+1
            IF (DEXY(1,I,J).GE.EMIN) RQT1 = RQT1 + DEXY(1,I,J)
         ENDDO
C
         IF ((A-2).GE.1) THEN
            DO J=1,A-2
               PXY = DEXY(1,I,J)
               IF (PXY.GE.EMIN) RQT2 = RQT2 + PXY
            ENDDO
         ENDIF
C
         IF ((A+2).LE.NCHA) THEN
            DO J=A+2,NCHA
               PXY = DEXY(1,I,J)
               IF (PXY.GE.EMIN) RQT2 = RQT2 + PXY
            ENDDO
         ENDIF
C
c         print *,' I ',I,' A ',RQT1
 600     CONTINUE
C
         B = IBAR(2,I)
C
C     EM
C
         IF (B.EQ.-1) GOTO 700
C
C     END EM
C
         IF (B.LE.2) B = 2
         IF (B.GE.NCHA) B = NCHA - 1
         DO J = B-1,B+1
            IF (DEXY(2,I,J).GE.EMIN) RQT1 = RQT1 + DEXY(2,I,J)
c            print *,' ==> J ',j,' dexy ',DEXY(2,I,J)
         ENDDO
C     
         IF ((B-2).GE.1) THEN
            DO J=1,B-2
               PXY = DEXY(2,I,J)
               IF (PXY.GE.EMIN) RQT2 = RQT2 + PXY
            ENDDO
         ENDIF
C     
         IF ((B+2).LE.NCHA) THEN
            DO J=B+2,NCHA
               PXY = DEXY(2,I,J)
               IF (PXY.GE.EMIN) RQT2 = RQT2 + PXY
            ENDDO
         ENDIF
C
c         print *,' I ',I,' B ',RQT1
 700     CONTINUE
      ENDDO
C     
C
c 800  RETURN
      RETURN
      END

