5 * Revision 1.1.1.1 1995/10/24 10:20:53 cernlib
9 #include "geant321/pilot.h"
10 *CMZ : 3.21/02 29/03/94 15.41.30 by S.Giani
12 SUBROUTINE GNOTUB(X,P,IACT,IFL,SNEXT,SNXT,SAFE)
13 C. ******************************************************************
15 C. * Compute distance to intersection with boundary surface of *
16 C * volume TUBE or TUBS, from point X(1),X(2),X(3) outside *
17 C * the volume along track with direction cosines X(4),X(5), *
19 C. * P (input) : volume parameters *
20 C. * IACT (input) : action flag *
21 C. * = 0 Compute SAFE only *
22 C. * = 1 Compute SAFE, compute SNXT only if SAFE.LT.SNEXT *
23 C. * = 2 Compute both SAFE and SNXT *
24 C. * = 3 Compute SNXT only *
25 C. * IFL (input) : 1 for TUBE, 2 for PHI segmented TUBE *
26 C. * SNEXT (input) : see IACT = 1 *
27 C. * SNXT (output) : distance to volume boundary along track *
28 C. * SAFE (output) : not larger than scalar distance to *
29 C. * volume boundaray *
30 C. * Called by : GNEXT, GNOPCO, GTNEXT *
32 C. * Authors : Michel Maire and Rolf Nierhaus 21-JUN-1990 *
34 C. ******************************************************************
36 C. * 'TUBE' is a tube. It has 3 parameters, the inside radius, *
37 C. * the outside radius and the half length in z. *
38 C. * 'TUBS' is a phi segment of a tube. It has 5 parameters, *
39 C. * the same 3 as 'TUBE' plus the phi limits. The *
40 C. * segment starts at the first limit and includes *
41 C. * increasing phi value up to the second limit or *
42 C. * that plus 360 degrees. *
44 C. ******************************************************************
45 #if !defined(CERNLIB_SINGLE)
46 IMPLICIT DOUBLE PRECISION (A-H,O-Z)
48 #include "geant321/gconsp.inc"
49 REAL X(6),P(5),SNEXT,SNXT,SAFE
51 * this part has to be moved outside the routine
55 IF (P5.LT.P4) P5=P5+TWOPI
69 R=SQRT(X(1)**2+X(2)**2)
77 IF (IFL.EQ.2.AND.R.GT.0.) THEN
78 CPSI=(X(1)*CFIO+X(2)*SFIO)/R
79 IF (CPSI.LT.CDFI) THEN
80 IF ((X(2)*CFIO-X(1)*SFIO).LE.0.) THEN
81 SAF4=ABS(X(1)*S1-X(2)*C1)
83 SAF4=ABS(X(1)*S2-X(2)*C2)
87 SAFE=MAX(SAF1,SAF2,SAF3,SAF4)
88 IF (IACT.EQ.0) GO TO 999
89 IF (IACT.EQ.1.AND.SNEXT.LE.SAFE) GO TO 999
92 * Intersection with z-plane
93 * only points outside the z range need to be considered
94 IF (ABS(X(3)).GE.P(3)) THEN
95 IF (X(3)*X(6).LT.0.) THEN
96 S=(ABS(X(3))-P(3))/ABS(X(6))
100 IF (P(1)**2.LE.R2.AND.R2.LE.P(2)**2) THEN
101 IF (IFL.EQ.1) GO TO 101
102 IF (R2.EQ.0.) GO TO 101
103 CPSI=(XI*CFIO+YI*SFIO)/SQRT(R2)
104 IF (CPSI.GE.CDFI) GO TO 101
109 * Intersection with cylinders
110 * Intersection point (x,y,z)
111 * (x,y,z) is on track : x=X(1)+t*X(4)
114 * (x,y,z) is on cylinder : x**2 + y**2 = R**2
116 * (X(4)**2+X(5)**2)*t**2
117 * +2.*(X(1)*X(4)+X(2)*X(5))*t
118 * +X(1)**2+X(2)**2-R**2=0
121 T2=(X(1)*X(4)+X(2)*X(5))
123 * track parallel to the z axis ?
125 * IF (T1.EQ.0.) GO TO 999
126 IF (ABS(T1).LT.1.E-32) GO TO 999
129 * Intersection with outer cylinder
130 * only points outside the outer cylinder need to be considered
138 IF (ABS(ZI).LE.P(3)) THEN
139 IF (IFL.EQ.1) GO TO 101
142 CPSI=(XI*CFIO+YI*SFIO)/P(2)
143 IF (CPSI.GE.CDFI) GO TO 101
148 * Intersection with inner cylinder
156 IF (ABS(ZI).LE.P(3)) THEN
157 IF (IFL.EQ.1) GO TO 101
160 CPSI=(XI*CFIO+YI*SFIO)/P(1)
161 IF (CPSI.GE.CDFI) SNXT=S
167 * Intersection with phi-planes
168 * x=r*cos(phi)=X(1)+t*X(4)
169 * y=r*sin(phi)=X(2)+t*X(5)
171 * t=(X(2)*cos(phi)-X(1)*sin(phi))/(X(4)*sin(phi)-X(5)*cos(phi))
173 * track not parallel to the phi1 plane ?
176 S=(X(2)*C1-X(1)*S1)/UN
179 IF (ABS(ZI).LE.P(3)) THEN
183 IF (P(1)**2.LE.R2.AND.R2.LE.P(2)**2) THEN
184 IF ((YI*CFIO-XI*SFIO).LE.0.) THEN
185 IF (S.LT.SNXT) SNXT=S
191 * track not parallel to the phi2 plane ?
194 S=(X(2)*C2-X(1)*S2)/UN
197 IF (ABS(ZI).LE.P(3)) THEN
201 IF (P(1)**2.LE.R2.AND.R2.LE.P(2)**2) THEN
202 IF ((YI*CFIO-XI*SFIO).GE.0.) THEN
203 IF (S.LT.SNXT) SNXT=S