C   26/10/81 712202140  MEMBER NAME  LGMC56   (S)           FORTRAN
       SUBROUTINE LGMC56(LGMDMP,PV,RH, JBC ,IMASS)
C**********************************************************************
C    MAIN ROUTINE FOR TOKYO SHOWER PROGRAM, AS CALLED FROM TRKGAM
C                 IN JADE MC TRACKING PROGRAM
C**********************************************************************
C
C      PROGRAM TO CREATE  EM SHOWER IN THE LG-DETECTER USING THE
C          FOUR VECTOR OF GAMMAS  AND PUT THE GENERATED LG-DATA
C          INTO RAW DATA.
C
C     S.YAMADA   26-10-81  22:25    COPIED FROM @LGMCINC,LGMCMM
C     LAST MODIFICATION       27-11-81   18:10
C                         END CAP ABSORBER THICKNESS INCREASED.
C                         LGMCIN (WITHOUT RANDOM NO.INIT.) IS ADDED.
C
C     MODIFIED FOR USE WITH 56 VERSION OF SHOWER MC  (SF5+SF6)
C     ONE MORE ARGUMENT (IMASS), FOR PHOTON (0) OR ELECTRON (1)
C     LAST MODIFICATION    16.1.1986     J.OLSSON
C
C   MADE STANDARD LGMC56  ON 20.12.1987
C
C  INPUT
C     LGMDMP= TEST DUMP FLAG, 0-NODUMP, 1-->3 MORE DETAILED DUMPS.
C     PV= MOM.FOUR VECTOR OF THE GAMMA TO BE TRACED IN GEV.
C         PV(1,2,3)=PX,PY,PZ   PV(4)=ENERGY
C     RH= HIT POINT COORDINATE EITHER ON THE COIL SURFACE IN MM.
C     JBC = 0         BARREL
C           +-1       +Z,-Z END CAP
C     IMASS           MASS INDEX, 0 --> PHOTON, 1 --> ELECTRON
C     **** IMPORTANT ****
C     *    MODIFIED FOR BOTH THE BARREL AND END CAP PARTS!!
C     *    USE FOR THE COIL INNER RADIUS  RADIUS(1) IN THE /CLGD56/.
C     *    USE FOR THE P.V. INNER DIST.   ZPV(1 OR 3) IN THE /CLGD56/.
C     *    (P.V. = PRESSURE VESSEL)
C     ********************************************************
C
      IMPLICIT INTEGER *2 (H)
C
C  SHOWER MC COMMON
C
      COMMON /CLGD56/ RADIUS(6),ZEND(2),ZWID,ZGAP,PHWID,
     2                ECXLST(24), ECYLST(24),ZECAP(4),ZPV(4),TPV,
     3                TH(4),THECP
C
      COMMON /ENECUT/ ECUT,ECUTLS(3)
C
      DIMENSION PRTCL(3,3)
      DIMENSION PV(4),RH(3)
C
      COMMON / COLSON/ IPRO,ELODIF
C
      DATA ELEMAS/0.000511/
      DATA  ISTART/0/
C
      IF( ISTART.GT.0 ) GO TO 1
C
C  INITIALIZE  * * * *
C
      CALL MCIN56
      ISTART = 1
1     CONTINUE
C
C---- CHECK USED TIME
C
      IF(NTIME(DUM).LT.200) GO TO 100
C
      IF(IPRO.NE.0) WRITE(6,551) PV(4)
551   FORMAT(' LGMC56: PV4 ',E12.4)
C
      IF( PV(4).LE.0. ) RETURN
C
C UPDATE THICKNESS OF ABSORBER, IN THIS VERSION THETA DEPENDENT
C   ONLY FOR JBC = 0
C
      IF(JBC.NE.0) GO TO 6210
      COSTPV = PV(3)/PV(4)
      CALL TJOCKI(COSTPV,XLEN90,XLENDM,ELODF)
      ELODIF = ELODF
C
      RADIUS(2) = RADIUS(1) + XLEN90*89.
C
      IF(IPRO.GT.0) WRITE(6,6209) PV(3),PV(4),COSTPV,XLEN90,RADIUS(2)
6209  FORMAT(' LGMC56TJ: PV3-4 COS XLEN90 RAD2 ELODIF ',6E12.4)
C
6210  CONTINUE
C
C---- TRANSFER EACH FINAL STATE (INCLUDING DECAY PRODUCTS) TO LGSTRC.
C----   COPY TRACK INFORMATION
C----
C----    PRTCL:    0.        ENERGY(ELMASS)          0.
C----            POS X         POS Y              POS Z      (MM)
C----           DIRCOS        DIRCOS             DIRCOS
C----
C
        PRTCL(1,1)=0.0
        PRTCL(2,1)=PV(4)/ELEMAS
        PRTCL(3,1)=0.
          DO 11 K=1,3
          PRTCL(K,2) = RH(K)
          PRTCL(K,3) = PV(K)/PV(4)
   11     CONTINUE
C
        IF(LGMDMP.GE.2.OR.IPRO.NE.0) WRITE(6,6002) PRTCL
 6002   FORMAT('0INPUT INF.',3F9.2,3F9.1,3F9.3)
C
C----   LEAD-GLASS SHOWER TRACING FOR THE BARREL AND ENDCAP PARTS.
C   MASS IN MEV/C**2
        AMG = 0.
        IF(IMASS.NE.0) AMG = 0.511
C
C  ON CALL, PRTCL POSITION COMPONENT (1-3,2,N) HAS UNIT MM.
C
C
      IF(IPRO.NE.0) WRITE(6,552)
552   FORMAT(' LGMC56: CALLING LGST56 ')
C
        CALL LGST56(JBC,PRTCL,PV(4)*1000.0, AMG,LGMDMP)
      RETURN
100   CONTINUE
      WRITE(6,5730)
5730  FORMAT('  TIME OUT IN LGMC56...')
      RETURN
      END
