C   19/08/80 009221742  MEMBER NAME  FWDDET   (S)           FORTRAN
      SUBROUTINE FWDDET(PV,R0,IHIT)
C---  PREPARE AND SUPERVISE SIMULATION OF FORWARD DETECTORS' LEAD-GLASS
C---  (WITHOUT SHOWER SIMULATION)
C
C     H.WRIEDT     18.03.80    15:30
C     LAST MODIFICATION     21.08.80    13:55
C
      IMPLICIT INTEGER*2 (H)
C
      DIMENSION PV(10),R0(3),X(3),DX(3)
C
      COMMON /CGGRAW/ HGG(192)
C
      COMMON /CPARTC/ PRTCIN(3,3),PRTCL(3,3),EMEV,AMASSQ,ISIGNZ,EBEAM,
     &                THETA,PHI
C
      DATA TWOPI/6.2831853/,PI/3.1415927/,PIHALF/1.5707963/
      DATA ELEMAS/0.511E-3/,RADIAN/1.745329E-2/
      DATA EMINC / .005 /
C
C***  FOR TESTS ONLY
      DATA I1/0/
      I1 = I1 + 1
C***  END OF TEST INSERT
      IT = PV(8)+0.5
C---  THROW OUT PARTICLES WITHOUT TYPE-CODE
      IF (IT.LE.0) RETURN
      IF( PV(4) .LE. EMINC )  RETURN
C---  PREPARE INFORMATION NEEDED FOR FORWARD DETECTORS' LEAD-GLASS
      PRTCL(1,1) = PV(7)
      PRTCL(2,1) = PV(4)/ELEMAS
      PRTCL(3,1) = 0.
        DO 1 J = 1,3
        PRTCL(J,2) = R0(J)
        PRTCL(J,3) = PV(J)/PV(4)
          DO 2 K = 1,3
    2     PRTCIN(J,K) = PRTCL(J,K)
    1   CONTINUE
      EOLD = PV(4)
      EMEV = EOLD*1000.
      ISIGNZ = SIGN(1.,PV(3))
      THETA = ARCOS(PRTCL(3,3))
C---  DETERMINE PHI
      IF (PV(1).NE.0.) GOTO 3
      PHI = SIGN(PIHALF,PV(2))*ISIGNZ
      GOTO 4
    3 PHI = ATAN(PV(2)/PV(1))
      IF (PV(1).LT.0.) PHI = PI+PHI
    4 IF (PHI.GT.PI) PHI = PHI-TWOPI
    5 PHI = PHI/RADIAN
C
C---  COMPUTE X- AND Y-COORDINATES IN PB-GLASS SURFACE PLANE
C     (EACH IN MM)
      ZPBGL = 4850.
      X(3) = ZPBGL
      CALL COORD(X,DX)
C---  DETERMINE ADDRESS OF HIT BLOCK
      X1 = X(1)
      Y1 = X(2)
      CALL GGBLNO(X1,Y1,NOBL)
C***
C***  IF(I1.LE.20) WRITE(6,600) NOBL,X1,Y1,DX,P,PHI,THETA
C*600 FORMAT(' FWDDET-TEST: BLOCK-NR.,X,Y,DX,DY,DZ:',I6,5(2X,E12.4)/
C*** &       '   P(1)-P(4),PHI,THETA:',6(2X,E12.4))
C***
      IF (NOBL.LE.0) RETURN
      IHIT = IHIT + 1
C---  DEPOSIT ENERGY ACCORDING TO PARTICLE TYPE
      IF (IT.GT.2) GOTO 10
C---  PHOTONS AND ELECTRONS
C---  SMEAR ENERGY (FWHM: 20% AT 15 GEV BEAM-ENERGY)
      SIGMA = 0.33*SQRT(EOLD)
      CALL NVERT(SIGMA,EOLD,ENEW)
      PHEIGH = ENEW*1000./5.5
      HGG(NOBL) = HGG(NOBL) + PHEIGH
      RETURN
C---  NON-SHOWERING PARTICLES
C***  HAS TO BE WRITTEN
   10 RETURN
      END
