This commit was generated by cvs2svn to compensate for changes in r2,
[u/mrichter/AliRoot.git] / GEANT321 / gdraw / gdthrz.F
1 *
2 * $Id$
3 *
4 * $Log$
5 * Revision 1.1.1.1  1995/10/24 10:20:28  cernlib
6 * Geant
7 *
8 *
9 #include "geant321/pilot.h"
10 *CMZ :  3.21/02 29/03/94  15.41.27  by  S.Giani
11 *-- Author :
12       SUBROUTINE GDTHRZ(XYZ)
13 C.
14 C.    ******************************************************************
15 C.    *                                                                *
16 C.    *       Routine processing R-Z projection of tracks and hits     *
17 C.    *                                                                *
18 C.    *       XYZ    = Array of X,Y,Z coordinates (input/output)       *
19 C.    *                                                                *
20 C.    *    ==>Called by : GDFR3D                                       *
21 C.    *       Author : P.Zanarini   *********                          *
22 C.    *                                                                *
23 C.    ******************************************************************
24 C.
25 #include "geant321/gcdraw.inc"
26 #include "geant321/gcflag.inc"
27 #include "geant321/gcnum.inc"
28       DIMENSION XYZ(3),ITRSGN(20),ITRFLG(20)
29       LOGICAL BTEST
30       SAVE MAXITR,EPS,LIDEVT,LITR3D,ITRSGN,ITRFLG,IFACT
31       DATA MAXITR/20/,EPS/0.0001/,LIDEVT/0/
32 C.
33 C.    ------------------------------------------------------------------
34 C.
35       CALL UCTOH('360 ',I360,4,4)
36 C
37 C             If ITHRZ='ON  ' or '180 ' then use positive or negative ra
38 C             else if ITHRZ='360 ' then use only positive radius
39 C
40       IF (ITHRZ.EQ.I360) THEN
41          XYZ(2)=SQRT(XYZ(2)*XYZ(2)+XYZ(3)*XYZ(3))
42          GO TO 999
43       ENDIF
44 C
45 C             IDEVT  = Event number (in common GCFLAG)
46 C             LIDEVT = Last event number
47 C
48       IF (IDEVT.NE.LIDEVT) THEN
49          DO 10 I=1,MAXITR
50             ITRSGN(I)=0
51             ITRFLG(I)=0
52    10    CONTINUE
53          LIDEVT=IDEVT
54       ENDIF
55 C
56 C             NBIT   = Number of bit per machine word (in common GCNUM)
57 C             MAXITR = A maximum of NBIT*MAXITR significant track signs
58 C                      can be stored (after that all signs will be posit
59 C             IWORD  = 1,2,...,MAXITR
60 C             IOFSET = 0,1,...,NBIT-1
61 C
62       IWORD=(IABS(ITR3D)/NBIT)+1
63       IOFSET=MAX(MOD(IABS(ITR3D),NBIT)-1,0)
64 C
65       IF (IWORD.GT.MAXITR) THEN
66          IFACT=1
67          XYZ(2)=IFACT*SQRT(XYZ(2)*XYZ(2)+XYZ(3)*XYZ(3))
68          GO TO 999
69       ENDIF
70 C
71 C             If being drawing an hit, with sign already
72 C             set by previous track, then use that sign
73 C
74       IF (IOBJ.EQ.3.AND.BTEST(ITRFLG(IWORD),IOFSET)) THEN
75          IF(BTEST(ITRSGN(IWORD),IOFSET)) THEN
76             IFACT=1
77          ELSE
78             IFACT=-1
79          ENDIF
80          XYZ(2)=IFACT*SQRT(XYZ(2)*XYZ(2)+XYZ(3)*XYZ(3))
81          GO TO 999
82       ENDIF
83 C
84       IF (ITR3D.LT.0) THEN
85 C
86 C             First call to GDFR3D/GDTHRZ : initialize LITR3D and make I
87 C
88          ITR3D=-ITR3D
89          IF (.NOT.BTEST(ITRFLG(IWORD),IOFSET)) THEN
90             ITRFLG(IWORD) = IBSET(ITRFLG(IWORD),IOFSET)
91             LITR3D=0
92          ENDIF
93       ENDIF
94 C
95       IF (ITR3D.GT.0) THEN
96 C
97 C             LITR3D contains the last ITR3D value,
98 C             or zero if last point was at U-V origin (0,0,...)
99 C
100          IF (ITR3D.EQ.LITR3D) THEN
101 C
102 C             Old track : get R sign from ITRSGN into IFACT
103 C
104             IF(BTEST(ITRSGN(IWORD),IOFSET)) THEN
105                IFACT=1
106             ELSE
107                IFACT=-1
108             ENDIF
109 C
110          ELSE
111 C
112 C             New track : set R sign into ITRSGN and IFACT
113 C
114             IF (ABS(XYZ(2)).GT.EPS) THEN
115                IF (XYZ(2)/ABS(XYZ(2)).GT.0.) THEN
116                   ITRSGN(IWORD) = IBSET(ITRSGN(IWORD),IOFSET)
117                   IFACT=1
118                ELSE
119                   ITRSGN(IWORD) = IBCLR(ITRSGN(IWORD),IOFSET)
120                   IFACT=-1
121                ENDIF
122             ENDIF
123 C
124             LITR3D=ITR3D
125             IF ((ABS(XYZ(1)).LT.EPS).AND.(ABS(XYZ(2)).LT.EPS)) LITR3D=0
126 C
127          ENDIF
128 C
129    20    CONTINUE
130          XYZ(2)=IFACT*SQRT(XYZ(2)*XYZ(2)+XYZ(3)*XYZ(3))
131 C
132       ENDIF
133   999 RETURN
134       END