C   27/03/82 311291149  MEMBER NAME  HDECLS   (S)           FORTRAN
      SUBROUTINE HDECLS(ECLS,ICHG,IPAR,PE,IBE,PLLG,PLLI)
C
C     INPUT ARGUMENTS
C       IPAR  :  TYPE OF INCIDENT PARTICLE
C                  GAMMA = 1
C                  E     = 2
C                  MU    = 3
C                  PI    = 4
C                  K     = 5
C                  P     = 6
C       PE    :  INCIDENT 4-MOMENTUM
C       IFLG = 0 FOR NO IMPACT POINT (CURLING ELECTRON)
C            = 1 FOR IMPACT POINT IN ENDCAPS (INCLUDING GAP ENDCAP-CYL)
C            = 2 FOR IMPACT POINT IN CYLINDER
C       PLLG  :  TOTAL PATH LENGTH IN THE LEAD GLASS  IN MM
C       PLLI  :            ...            LIGHT GUIDE  ...
C
C      30/06/82
C
C     INCIDENT ANGLE DEPENDENCE IS INTRODUCED FOR MINIMUM IONIZING
C     PARTICLES
C                               06/01/83     J. KANZAKI
C
      DIMENSION PE(4),DC(3),XYZ1(3),XYZ2(3)
      DIMENSION A(3)
      DATA PLIM/ 0.5/
      DATA ASIG0/ 0.05/
      DATA PLLG0E,PLLG0B/ 226., 300./
      DATA PLLI0/ 60./
      DATA PLAL0E,PLAL0B/ 104.13, 86.33/
      DIMENSION XLLG1(6),XLAL1(6)
      DATA XLLG1/ 309., 309., 309., 309., 309., 309./
      DATA XLAL1/ 172., 172., 172., 172., 172., 172./
      DATA ABSA1,ABSA2/ 0.0595, 0.0787/
      DATA ABS0/ 0.372/
      DATA AEXALA/ 18.51/,AEXALB/ 26.68/
      DATA A2NOA,A2ALA,A2ALB/ 3., 2.2, 2.8/
      DATA A3A,A3B,A3C/ 5.132, 5.313, -0.782/
      DATA A4A,A4B,A4C/ -4.795, 44.26, -3.170/
      DIMENSION AMAS1(6)
      DATA AMAS1/ 0., 0.000511, 0.109, 0.1396, 0.4937, 0.9383/
      DATA AN1,AN2/ 1.67, 1.52/
      DATA ALNOA,AHNOA/ 0.3021, 0.2406/
      DATA ALALA,AHALA/ 0.2900, 0.2335/
      DATA ALALB,AHALB/ 0.2806, 0.2351/
      DATA PLIM1/ 5./
      DATA ALSIGA,ALSIGB/ 7.05, 3.99/
      DATA AHSIGA,AHSIGB/ 6.74, 0.67/
      DATA ANCLP/ 2.3/,ANCLN/ 1.15/
C
C     PARAMETERS FOR THE ANGULAR DEPENDENCE
C
      DATA ANOINT/ 0.7042/,BNOINT/ 14.753/
      DATA AINT/ 0.8/,BINT/ 14.753/
C     DATA AINT/ 0.9/,BINT/ 14.753/
C
C
      ECLS=0.
      IF(IBE.LE.-2 .OR. IBE.GE.2) RETURN
      IF(IPAR.LE.2) RETURN
C
      PT=SQRT(PE(1)**2+PE(2)**2)
      PP=SQRT(PE(3)**2+PT**2)
      IF(PP.LE.0.) CALL ERRMSG('MOMENTUM = 0. ??$',&999)
C
      IF(IBE.NE.0) PLLG1=PLLG/PLLG0E
      IF(IBE.EQ.0) PLLG1=PLLG/PLLG0B
      PLLI1=PLLI/PLLI0
      IF(IBE.NE.0) PLAL=PLAL0E*PLLG1
      IF(IBE.EQ.0) PLAL=PLAL0B*PLLG1
C
      IAL=1
CC********
CC    SUPRESS NOAL DATA
CC    IF(IFLG.NE.2) IAL=0
CC********
C
 1000 IF(IPAR.NE.3) GO TO 2000
C
C     MUON
C
      GO TO 2100
C
C     HADRON
C
 2000 CONTINUE
C
C     DETERMINE WHETHER THE PARTICLE INTERACTS OR NOT.
C
      XLLG0=XLLG1(IPAR)
      EXPLG=PLLG/XLLG0
      RINT=1.
      IF(EXPLG.LT.10.) RINT=1.-EXP(-EXPLG)
      IF(IAL.EQ.0) GO TO 2005
      XLAL0=XLAL1(IPAR)
      EXPAL=PLAL/XLAL0
      RINT=1.
      IF(EXPAL.LT.10. .AND. EXPLG.LT.10.)RINT=1.-EXP(-EXPAL)*EXP(-EXPLG)
 2005 IF(RN(DUM).GT.RINT) GO TO 2100
C
C     INTERACTING PARTICLE
C
      PMOM=PP
      IF(PP.LT.PLIM) PMOM=PLIM
      RINTAL=1./RINT
      IF(EXPAL.LT.10.) RINTAL=(1.-EXP(-EXPAL))/RINT
      IF(RN(DUM).GT.RINTAL) GO TO 2020
      RABS=(ABSA1+ABSA2/PMOM)/ABS0
      IF(RN(DUM).GT.RABS) GO TO 2020
      AEX=AEXALB+(AEXALA-AEXALB)*PLLI1
      EV=PP*RNEXP0(AEX)
      ECLS=EV
      RETURN
C
 2020 A(1)=0.
      IF(IAL.EQ.0) A(1)=A2NOA
      IF(IAL.EQ.1) A(1)=A2ALB+(A2ALA-A2ALB)*PLLI1
      A(2)=-(A3A+A3B*EXP(A3C*PMOM))
      A(3)=A4A+A4B*EXP(A4C*PMOM)
      PMOM=PP
C
      ELIM=PP+3.*ASIG0*SQRT(PP)
 2003 EV=PP*RNCONT(A)
      IF(EV.GT.ELIM) GO TO 2003
C
      ESIG=ASIG0*SQRT(EV)
 2010 ECLS=RNGAU(EV,ESIG)
      IF(ECLS.LT.0.) ECLS=0.
      IF(ECLS.GT.ELIM) GO TO 2010
C
C     SPECIAL CASE FOR ANTI-NUCLEON
C
      IF(IPAR.EQ.6 .AND. ICHG.EQ.0) ECLS=ANCLN*ECLS
      IF(IPAR.EQ.6 .AND. ICHG.EQ.-1) ECLS=ANCLP*ECLS
      IF(IBE.EQ.0) COSTH=PLLG0B/PLLG
      IF(IBE.NE.0) COSTH=PLLG0E/PLLG
      FCOR=FCRANG(COSTH,AINT,BINT)
      ECLS=FCOR*ECLS
      RETURN
C
C     NON-INTERACTING PARTICLE
C
 2100 IF(ICHG.EQ.0) RETURN
      PMOM=PP
      AMAS=AMAS1(IPAR)
      ALOW=0.
      AHIG=0.
      IF(IAL.EQ.0) ALOW=ALNOA
      IF(IAL.EQ.0) AHIG=AHNOA
      IF(IAL.NE.0) ALOW=ALALB+(ALALA-ALALB)*PLLI1
      IF(IAL.NE.0) AHIG=AHALB+(AHALA-AHALB)*PLLI1
C
      APKL=ALOW*(1.-AMAS**2/PMOM/(AN1**2-1))*PLLG1
      IF(APKL.LT.0.) APKL=0.
      APKH=AHIG*(1.-AMAS**2/PMOM/(AN2**2-1))*PLLI1
      IF(APKH.LT.0.) APKH=0.
      APK=APKL+APKH
C
      IF(APK.LE.0.) RETURN
C
      IF(IBE.EQ.0) COSTH=PLLG0B/PLLG
      IF(IBE.NE.0) COSTH=PLLG0E/PLLG
      FCOR=FCRANG(COSTH,ANOINT,BNOINT)
      APK=FCOR*APK
C
      PMOM1=PMOM
      IF(PMOM.GT.PLIM1) PMOM1=PLIM1
C
      ALSIG=ALSIGA+ALSIGB*PMOM1
      AHSIG=AHSIGA+AHSIGB*PMOM1
      ASIG=0.01*(ALSIG+(AHSIG-ALSIG)*PLLI1)*APK
C
      ECLS=RNGAU(APK,ASIG)
      IF(ECLS.LT.0.) ECLS=0.
C
      RETURN
C
  999 RETURN
      END
