*$ CREATE USRMED.FOR
*COPY USRMED
*                                                                      *
*=== usrmed ===========================================================*
*                                                                      *
*****************
** THIS CODE IS DONE FOR A SPHERICAL OBSJECT
****************
      SUBROUTINE USRMED ( IJ, EKSCO, PLA, WEE, MREG, NEWREG, XX, YY, ZZ,
     &                    TXX, TYY, TZZ )

      INCLUDE '(DBLPRC)'
      INCLUDE '(DIMPAR)'
      INCLUDE '(IOUNIT)'
      INCLUDE '(FLKSTK)'
      INCLUDE '(EMFSTK)'
*
      CHARACTER*8 MRGNAM, NRGNAM
      CHARACTER*20 FILNAM
      DOUBLE PRECISION N_R, UX, UY, UZ 
      DOUBLE PRECISION OMEGA_P, H, E_C,OMEGA
      DOUBLE PRECISION TEMP1,TEMP2,SIN1,SIN2
      DOUBLE PRECISION COS1, TETA1, TETA2, P
      DOUBLE PRECISION DELTA_T, PX, PY, PZ
      DOUBLE PRECISION R11, R12, R13
      DOUBLE PRECISION R21, R22, R23
      DOUBLE PRECISION R31, R32, R33
      DOUBLE PRECISION COSDT, SINDT
      DOUBLE PRECISION TX2, TY2, TZ2,T
      DOUBLE PRECISION PI_2
* WIRE PARAMETERS 
      DOUBLE PRECISION X_C,Y_C,Z_C 
      LOGICAL LFCOPE
      SAVE LFCOPE
      DATA LFCOPE / .FALSE. /
*
      IF ( .NOT. LFCOPE ) THEN
      	   LFCOPE = .TRUE.
           IF ( KOMPUT .EQ. 2 ) THEN
	     FILNAM = 'SilviaTest.dat'
           ELSE
              FILNAM = 'SilviaTest.dat'
           END IF
         OPEN ( UNIT = 23, FILE = FILNAM, STATUS = 'NEW', FORM =
     &          'FORMATTED' )
         
      END IF
      CALL GEOR2N (MREG,MRGNAM,IERR1)
      CALL GEOR2N (NEWREG,NRGNAM,IERR2)
      WRITE (23,*) NRGNAM, MRGNAM
      IF (NRGNAM .EQ."TARGET1")THEN
        IF (MRGNAM .EQ."AROUND")THEN
		WRITE (23,*) TXNOR(NPFLKA),TYNOR(NPFLKA),TZNOR(NPFLKA)
	END IF
      END IF
*
*----------------------------------------------------------------------*
*                                                                      *
*     Copyright (C) 1991-2005      by    Alfredo Ferrari & Paola Sala  *
*     All Rights Reserved.                                             *
*                                                                      *
*                                                                      *
*     USeR MEDium dependent directives:                                *
*                                                                      *
*     Created on  10  may  1996    by    Alfredo Ferrari & Paola Sala  *
*                                                   Infn - Milan       *
*                                                                      *
*     Last change on   29-may-96   by    Alfredo Ferrari               *
*                                                                      *
*     Input variables:                                                 *
*             ij = particle id                                         *
*          Eksco = particle kinetic energy (GeV)                       *
*            Pla = particle momentum (GeV/c)                           *
*            Wee = particle weight                                     *
*           Mreg = (original) region number                            *
*         Newreg = (final)    region number                            *
*       Xx,Yy,Zz = particle position                                   *
*    Txx,Tyy,Tzz = particle direction                                  *
*                                                                      *
*     The user is supposed to change only WEE if MREG = NEWREG and     *
*     WEE, NEWREG, TXX, TYY, TZZ if MREG .NE. NEWREG                   *
*                                                                      *
*----------------------------------------------------------------------*
*
      RETURN
*=== End of subroutine Usrmed =========================================*
      END

