C   20/03/79 003112233  MEMBER NAME  LGAVDP   (LGSOURCE)    FORTRAN
      SUBROUTINE LGAVDP(ZAV,EMEV,JEG,DEP)
C
C     S.YAMADA  11-12-78  14:55
C     LAST MODIFICATION    29-02-80   13:25   (CHARGED PARTICL)
C
C----   AVERAGE DEPTH OF THE SHOWER IS CALCULATED BY ITERATION.
C     INPUT
C     ZAV = AVERAGE Z IN MM
C     EMEV = SHOWER ENERGY IN MEV(JEG=0,1)
C          = KINETIC ENERGY OF THE TRACK (JEG=2)
C     JEG  =0(GAMMA), 1(ELECTRO & POSITRON), 2(OTHER CHARGED PARTICLE)
C     OUTPUT
C     DEP = RADIAL AVERAGE DEPTH IN MM
C
      COMMON /CLGDMS/ X0,RADIUS(6),RADSX0(6),THX0(4),
     $                ZEND(2),ZENDX0(2),ZWID(2),ZGAP(2),PHWID(2),
     $                ZECAP(4),ZECAPX(4),THECPX(2)
C
      COMMON /CLGPRM/ ITH,MAXCLS,IRLTHD,IRLTH2,IRLTH3, ZVRTX
      COMMON /CLGMSB/ MSGVAL,AMSGV1,AMSGV2
      DATA DP0/150./
C
      ZAV2 = (ZAV-ZVRTX)**2
      IF(JEG-2) 1,10,10
C
C---- ELECTROMAGNETIC SHOWER
    1 DEPO = 0.
C
C---- AVERAGE SHOWER DEPTH ALONG THE AXIS = SM
      SM = SHMAX(EMEV,JEG)
C
      NTRY = 0
    4 NTRY = NTRY+1
      IF(NTRY.GT.20) GO TO 21
      DEP = SM/SQRT(1.0+ZAV2/(RADIUS(3)+DEPO)**2)
      IF(ABS(DEP-DEPO)/DEP.LE.0.01) GO TO 100
      DEPO = DEP
      GO TO 4
C
   21 MSGVAL = NTRY
      AMSGV1 = DEPO
      AMSGV2 = DEP
      CALL LGMESG( 10,1 )
      GO TO 100
C
C---- PENETRATING CHARGED TRACK
   10 DEP = DP0
      RANGE = EMEV/10.2*X0
      EFDEP = RANGE/SQRT(1.0+ZAV2/(RADIUS(3)+DEP)**2)
      IF( EFDEP.LT.DEP ) DEP = EFDEP
C
  100 RETURN
      END
