       SUBROUTINE UGDEFMAT
C
       IMPLICIT NONE
C
       include 'materials.inc'
C
C     Define materials and compounds. The atomic makeup of various compounds
C     are defined in materials.inc

      REAL TMAXFD, STEMAX, DEEMAX, EPSIL, STMIN, FIELDM
      PARAMETER (TMAXFD = 1.0)
      PARAMETER (STEMAX = 0.0001)
      PARAMETER (DEEMAX = 0.0005)
      PARAMETER (EPSIL  = 0.0001)
      PARAMETER (STMIN  = 0.0001)

      
      INTEGER IFIELD
      INTEGER sensitive, insensitive, j
      PARAMETER (insensitive = 0)
      PARAMETER (sensitive = 1)

C Geant's default for air is a single "element". We replace that with
C the correct mixture, so that we can recover the list of elements later.

      CALL GSMIXT(AIRMAT,'AIR', A_AIR,Z_AIR,RHO_AIR,-3,W_AIR)

C Define polyethylene

      CALL GSMIXT(SCINTMAT,'Polyethylene',A_CH,Z_CH,RHO_CH,-2,W_CH2)

C Define Rock

      CALL GSMIXT(ROCKMAT, 'Rock', A_ROCK, Z_ROCK, RHO_ROCK, -4, W_ROCK)

C Define Water

      CALL GSMIXT(WATERMAT,'Water',A_WATER,Z_WATER,RHO_WATER,-2,W_WATER)

C Create Stainless Steel

      CALL GSMIXT(SSMAT, 'Stainless Steel', A_SS,Z_SS,RHO_SS,-3,W_SS)

C Define Caesium

      CALL GSMATE(CSMAT,'Caesium',A_CS,Z_CS,RHO_CS,RADL_CS,ABSL_CS,0,0)

C There is no magnetic field, so just set it to 0

      FIELDM = 0.
      IFIELD = 0

C Now define the tracking media associated with each material. The Air
C will be defined to be 'insensitive' which means that one cannot define and store
C 'hits' in the material. The scintillator will be defined as 'sensitive' as it
C is the detector...

C Air
       CALL GSTMED(IMATAIR, 'AIR ', AIRMAT, insensitive, iField, fieldM,
     +            TMAXFD,STEMAX,DEEMAX,EPSIL,STMIN,0,0)

C Scintillator
       CALL GSTMED(IMATSCINT,'SCIN ',SCINTMAT, sensitive, iField, fieldM
     +            ,TMAXFD,STEMAX,DEEMAX,EPSIL,STMIN,0,0)

C Lead
       CALL GSTMED(IMATLEAD,'LEAD',13, insensitive, iField, fieldM,
     +            TMAXFD,STEMAX,DEEMAX,EPSIL,STMIN,0,0)

C Rock
       CALL GSTMED(IMATROCK, 'ROCK ', ROCKMAT, insensitive, iField, fiel
     +            dM,TMAXFD,STEMAX,DEEMAX,EPSIL,STMIN,0,0)

C Caesium
       CALL GSTMED(IMATCS, 'Caesium ', CSMAT, insensitive, iField, field
     +            M,TMAXFD,STEMAX,DEEMAX,EPSIL,STMIN,0,0)

C WATER
       CALL GSTMED(IMATWATER, 'Water ', WATERMAT, sensitive, iField,
     +           fieldM,TMAXFD,STEMAX,DEEMAX,EPSIL,STMIN,0,0)

C Carbon(skin)
       CALL GSTMED(IMATCARBON,'Carbon',6, insensitive, iField, fieldM,
     +            TMAXFD,STEMAX,DEEMAX,EPSIL,STMIN,0,0)

C Stainless Steel
       CALL GSTMED(IMATSS,'Stainless Steel', SSMAT, insensitive,iField,
     +            fieldM,TMAXFD,STEMAX,DEEMAX,EPSIL,STMIN,0,0)

C Print the materials

      CALL GPTMED(0)

      RETURN     
      END
