This commit was generated by cvs2svn to compensate for changes in r2,
[u/mrichter/AliRoot.git] / GEANT321 / ggeom / gmtod.F
1 *
2 * $Id$
3 *
4 * $Log$
5 * Revision 1.1.1.1  1995/10/24 10:20:51  cernlib
6 * Geant
7 *
8 *
9 #include "geant321/pilot.h"
10 *CMZ :  3.21/02 29/03/94  15.41.29  by  S.Giani
11 *-- Author :
12       SUBROUTINE GMTOD(XM,XD,IFLAG)
13 C.
14 C.    ******************************************************************
15 C.    *                                                                *
16 C.    *       Computes coordinates XD (in DRS)                         *
17 C.    *       from known coordinates XM in MRS                         *
18 C.    *       The local reference system can be initialized by         *
19 C.    *         - the tracking routines and GMTOD used in GUSTEP       *
20 C.    *         - a call to GMEDIA(XM,NUMED)                           *
21 C.    *         - a call to GLVOLU(NLEVEL,NAMES,NUMBER,IER)            *
22 C.    *             (inverse routine is GDTOM)                         *
23 C.    *                                                                *
24 C.    *        If IFLAG=1  convert coordinates                         *
25 C.    *           IFLAG=2  convert direction cosinus                   *
26 C.    *                                                                *
27 C.    *    ==>Called by : <USER>                                       *
28 C.    *       Author    R.Brun ,M Hansroul  *********                  *
29 C.    *                                                                *
30 C.    ******************************************************************
31 C.
32 #include "geant321/gcvolu.inc"
33       DIMENSION XD(3),XM(3)
34       EQUIVALENCE (N,NLEVEL)
35 C.
36 C.    ------------------------------------------------------------------
37 C.
38       IF(IFLAG.EQ.1)THEN
39          IF(GRMAT(10,N).NE.0.)THEN
40             T1 = XM(1) - GTRAN(1,N)
41             T2 = XM(2) - GTRAN(2,N)
42             T3 = XM(3) - GTRAN(3,N)
43             XD(1) = GRMAT(1,N)*T1+GRMAT(2,N)*T2+GRMAT(3,N)*T3
44             XD(2) = GRMAT(4,N)*T1+GRMAT(5,N)*T2+GRMAT(6,N)*T3
45             XD(3) = GRMAT(7,N)*T1+GRMAT(8,N)*T2+GRMAT(9,N)*T3
46 *
47          ELSE
48             XD(1) = XM(1) - GTRAN(1,N)
49             XD(2) = XM(2) - GTRAN(2,N)
50             XD(3) = XM(3) - GTRAN(3,N)
51 *
52          ENDIF
53 *
54       ELSE
55          IF(GRMAT(10,N).NE.0.)THEN
56             XD(1) = GRMAT(1,N)*XM(1)+GRMAT(2,N)*XM(2)+GRMAT(3,N)*XM(3)
57             XD(2) = GRMAT(4,N)*XM(1)+GRMAT(5,N)*XM(2)+GRMAT(6,N)*XM(3)
58             XD(3) = GRMAT(7,N)*XM(1)+GRMAT(8,N)*XM(2)+GRMAT(9,N)*XM(3)
59 *
60          ELSE
61             XD(1) = XM(1)
62             XD(2) = XM(2)
63             XD(3) = XM(3)
64 *
65          ENDIF
66 *
67       ENDIF
68       END