1 |
mocchiut |
1.1 |
********************************************************************** |
2 |
|
|
* |
3 |
|
|
* |
4 |
|
|
* routine per tracciare la particella di uno STEP |
5 |
|
|
* |
6 |
|
|
SUBROUTINE GRKUTA (CHARGE,STEP,VECT,VOUT) |
7 |
|
|
C. |
8 |
|
|
C. ****************************************************************** |
9 |
|
|
C. * * |
10 |
|
|
C. * Runge-Kutta method for tracking a particle through a magnetic * |
11 |
|
|
C. * field. Uses Nystroem algorithm (See Handbook Nat. Bur. of * |
12 |
|
|
C. * Standards, procedure 25.5.20) * |
13 |
|
|
C. * * |
14 |
|
|
C. * Input parameters * |
15 |
|
|
C. * CHARGE Particle charge * |
16 |
|
|
C. * STEP Step size * |
17 |
|
|
C. * VECT Initial co-ords,direction cosines,momentum * |
18 |
|
|
C. * Output parameters * |
19 |
|
|
C. * VOUT Output co-ords,direction cosines,momentum * |
20 |
|
|
C. * User routine called * |
21 |
|
|
C. * CALL GUFLD(X,F) * |
22 |
|
|
C. * * |
23 |
|
|
C. * ==>Called by : <USER>, GUSWIM * |
24 |
|
|
C. * Authors R.Brun, M.Hansroul ********* * |
25 |
|
|
C. * V.Perevoztchikov (CUT STEP implementation) * |
26 |
|
|
C. * * |
27 |
|
|
C. * * |
28 |
|
|
C. ****************************************************************** |
29 |
|
|
C. |
30 |
|
|
IMPLICIT DOUBLE PRECISION(A-H,O-Z) |
31 |
pam-fi |
1.7 |
COMMON/DELTAB/DELTA0,DELTA1,DLT |
32 |
mocchiut |
1.1 |
* |
33 |
|
|
REAL VVV(3),FFF(3) |
34 |
|
|
REAL*8 CHARGE, STEP, VECT(*), VOUT(*), F(4) |
35 |
|
|
REAL*8 XYZT(3), XYZ(3), X, Y, Z, XT, YT, ZT |
36 |
|
|
DIMENSION SECXS(4),SECYS(4),SECZS(4),HXP(3) |
37 |
|
|
EQUIVALENCE (X,XYZ(1)),(Y,XYZ(2)),(Z,XYZ(3)), |
38 |
|
|
+ (XT,XYZT(1)),(YT,XYZT(2)),(ZT,XYZT(3)) |
39 |
|
|
* |
40 |
|
|
PARAMETER (MAXIT = 1992, MAXCUT = 11) |
41 |
pam-fi |
1.7 |
cPP PARAMETER (EC=2.9979251D-4,DLT=1D-4,DLT32=DLT/32) |
42 |
|
|
PARAMETER (EC=2.99792458D-4) |
43 |
|
|
cPP PARAMETER (ZERO=0, ONE=1, TWO=2, THREE=3) |
44 |
|
|
PARAMETER (ZERO=0.D0, ONE=1.D0, TWO=2.D0, THREE=3.D0) |
45 |
mocchiut |
1.1 |
PARAMETER (THIRD=ONE/THREE, HALF=ONE/TWO) |
46 |
|
|
PARAMETER (PISQUA=.986960440109D+01) |
47 |
pam-fi |
1.2 |
PARAMETER (IX=1,IY=2,IZ=3,IPX=4,IPY=5,IPZ=6) |
48 |
mocchiut |
1.1 |
|
49 |
pam-fi |
1.6 |
REAL*8 DELTAB(3) |
50 |
pam-fi |
1.7 |
REAL*8 DLT32 |
51 |
|
|
DLT32=DLT/32. |
52 |
pam-fi |
1.6 |
|
53 |
mocchiut |
1.1 |
*. |
54 |
|
|
*. ------------------------------------------------------------------ |
55 |
|
|
*. |
56 |
|
|
* This constant is for units CM,GEV/C and KGAUSS |
57 |
|
|
* |
58 |
pam-fi |
1.6 |
|
59 |
mocchiut |
1.1 |
ITER = 0 |
60 |
|
|
NCUT = 0 |
61 |
|
|
DO 10 J=1,7 |
62 |
|
|
VOUT(J)=VECT(J) |
63 |
|
|
10 CONTINUE |
64 |
|
|
PINV = EC * CHARGE / VECT(7) |
65 |
|
|
TL = 0. |
66 |
|
|
H = STEP |
67 |
|
|
* |
68 |
|
|
* |
69 |
|
|
20 REST = STEP-TL |
70 |
|
|
IF (DABS(H).GT.DABS(REST)) H = REST |
71 |
|
|
DO I=1,3 |
72 |
|
|
VVV(I)=SNGL(VOUT(I)) |
73 |
|
|
ENDDO |
74 |
|
|
|
75 |
|
|
CALL GUFLD(VVV,FFF) |
76 |
|
|
* print*,'GRKUTA Bx,By,Bz: ',(FFF(i),i=1,3) |
77 |
|
|
DO I=1,3 |
78 |
|
|
F(I)=DBLE(FFF(I)) |
79 |
|
|
ENDDO |
80 |
pam-fi |
1.6 |
DELTAB(2) = -F(2)*VECT(7)*CHARGE*(DELTA0+DELTA1*VVV(2)) |
81 |
|
|
F(2) = F(2)+DELTAB(2) |
82 |
|
|
cPP ----------------- |
83 |
mocchiut |
1.1 |
* |
84 |
|
|
* Start of integration |
85 |
|
|
* |
86 |
|
|
X = VOUT(1) |
87 |
|
|
Y = VOUT(2) |
88 |
|
|
Z = VOUT(3) |
89 |
|
|
A = VOUT(4) |
90 |
|
|
B = VOUT(5) |
91 |
|
|
C = VOUT(6) |
92 |
|
|
* |
93 |
|
|
H2 = HALF * H |
94 |
|
|
H4 = HALF * H2 |
95 |
|
|
PH = PINV * H |
96 |
|
|
PH2 = HALF * PH |
97 |
|
|
SECXS(1) = (B * F(3) - C * F(2)) * PH2 |
98 |
|
|
SECYS(1) = (C * F(1) - A * F(3)) * PH2 |
99 |
|
|
SECZS(1) = (A * F(2) - B * F(1)) * PH2 |
100 |
|
|
ANG2 = (SECXS(1)**2 + SECYS(1)**2 + SECZS(1)**2) |
101 |
|
|
IF (ANG2.GT.PISQUA) GO TO 40 |
102 |
|
|
DXT = H2 * A + H4 * SECXS(1) |
103 |
|
|
DYT = H2 * B + H4 * SECYS(1) |
104 |
|
|
DZT = H2 * C + H4 * SECZS(1) |
105 |
|
|
XT = X + DXT |
106 |
|
|
YT = Y + DYT |
107 |
|
|
ZT = Z + DZT |
108 |
|
|
* |
109 |
|
|
* Second intermediate point |
110 |
|
|
* |
111 |
|
|
EST = DABS(DXT)+DABS(DYT)+DABS(DZT) |
112 |
|
|
IF (EST.GT.H) GO TO 30 |
113 |
|
|
|
114 |
|
|
DO I=1,3 |
115 |
|
|
VVV(I)=SNGL(XYZT(I)) |
116 |
|
|
ENDDO |
117 |
|
|
CALL GUFLD(VVV,FFF) |
118 |
|
|
DO I=1,3 |
119 |
|
|
F(I)=DBLE(FFF(I)) |
120 |
pam-fi |
1.6 |
ENDDO |
121 |
|
|
DELTAB(2) = -F(2)*VECT(7)*CHARGE*(DELTA0+DELTA1*VVV(2)) |
122 |
|
|
F(2) = F(2)+DELTAB(2) |
123 |
|
|
cPP ----------------- |
124 |
mocchiut |
1.1 |
C CALL GUFLD(XYZT,F) |
125 |
|
|
AT = A + SECXS(1) |
126 |
|
|
BT = B + SECYS(1) |
127 |
|
|
CT = C + SECZS(1) |
128 |
|
|
* |
129 |
|
|
SECXS(2) = (BT * F(3) - CT * F(2)) * PH2 |
130 |
|
|
SECYS(2) = (CT * F(1) - AT * F(3)) * PH2 |
131 |
|
|
SECZS(2) = (AT * F(2) - BT * F(1)) * PH2 |
132 |
|
|
AT = A + SECXS(2) |
133 |
|
|
BT = B + SECYS(2) |
134 |
|
|
CT = C + SECZS(2) |
135 |
|
|
SECXS(3) = (BT * F(3) - CT * F(2)) * PH2 |
136 |
|
|
SECYS(3) = (CT * F(1) - AT * F(3)) * PH2 |
137 |
|
|
SECZS(3) = (AT * F(2) - BT * F(1)) * PH2 |
138 |
|
|
DXT = H * (A + SECXS(3)) |
139 |
|
|
DYT = H * (B + SECYS(3)) |
140 |
|
|
DZT = H * (C + SECZS(3)) |
141 |
|
|
XT = X + DXT |
142 |
|
|
YT = Y + DYT |
143 |
|
|
ZT = Z + DZT |
144 |
|
|
AT = A + TWO*SECXS(3) |
145 |
|
|
BT = B + TWO*SECYS(3) |
146 |
|
|
CT = C + TWO*SECZS(3) |
147 |
|
|
* |
148 |
|
|
EST = ABS(DXT)+ABS(DYT)+ABS(DZT) |
149 |
|
|
IF (EST.GT.2.*ABS(H)) GO TO 30 |
150 |
|
|
|
151 |
|
|
DO I=1,3 |
152 |
|
|
VVV(I)=SNGL(XYZT(I)) |
153 |
|
|
ENDDO |
154 |
|
|
CALL GUFLD(VVV,FFF) |
155 |
|
|
DO I=1,3 |
156 |
|
|
F(I)=DBLE(FFF(I)) |
157 |
|
|
ENDDO |
158 |
pam-fi |
1.6 |
DELTAB(2) = -F(2)*VECT(7)*CHARGE*(DELTA0+DELTA1*VVV(2)) |
159 |
|
|
F(2) = F(2)+DELTAB(2) |
160 |
|
|
cPP ----------------- |
161 |
mocchiut |
1.1 |
C CALL GUFLD(XYZT,F) |
162 |
|
|
* |
163 |
|
|
Z = Z + (C + (SECZS(1) + SECZS(2) + SECZS(3)) * THIRD) * H |
164 |
|
|
Y = Y + (B + (SECYS(1) + SECYS(2) + SECYS(3)) * THIRD) * H |
165 |
|
|
X = X + (A + (SECXS(1) + SECXS(2) + SECXS(3)) * THIRD) * H |
166 |
|
|
* |
167 |
|
|
SECXS(4) = (BT*F(3) - CT*F(2))* PH2 |
168 |
|
|
SECYS(4) = (CT*F(1) - AT*F(3))* PH2 |
169 |
|
|
SECZS(4) = (AT*F(2) - BT*F(1))* PH2 |
170 |
|
|
A = A+(SECXS(1)+SECXS(4)+TWO * (SECXS(2)+SECXS(3))) * THIRD |
171 |
|
|
B = B+(SECYS(1)+SECYS(4)+TWO * (SECYS(2)+SECYS(3))) * THIRD |
172 |
|
|
C = C+(SECZS(1)+SECZS(4)+TWO * (SECZS(2)+SECZS(3))) * THIRD |
173 |
|
|
* |
174 |
|
|
EST = ABS(SECXS(1)+SECXS(4) - (SECXS(2)+SECXS(3))) |
175 |
|
|
++ ABS(SECYS(1)+SECYS(4) - (SECYS(2)+SECYS(3))) |
176 |
|
|
++ ABS(SECZS(1)+SECZS(4) - (SECZS(2)+SECZS(3))) |
177 |
|
|
* |
178 |
|
|
IF (EST.GT.DLT .AND. ABS(H).GT.1.E-4) GO TO 30 |
179 |
|
|
ITER = ITER + 1 |
180 |
|
|
NCUT = 0 |
181 |
|
|
* If too many iterations, go to HELIX |
182 |
|
|
IF (ITER.GT.MAXIT) GO TO 40 |
183 |
|
|
* |
184 |
|
|
TL = TL + H |
185 |
|
|
IF (EST.LT.(DLT32)) THEN |
186 |
|
|
H = H*TWO |
187 |
|
|
ENDIF |
188 |
|
|
CBA = ONE/ SQRT(A*A + B*B + C*C) |
189 |
|
|
VOUT(1) = X |
190 |
|
|
VOUT(2) = Y |
191 |
|
|
VOUT(3) = Z |
192 |
|
|
VOUT(4) = CBA*A |
193 |
|
|
VOUT(5) = CBA*B |
194 |
|
|
VOUT(6) = CBA*C |
195 |
|
|
REST = STEP - TL |
196 |
|
|
IF (STEP.LT.0.) REST = -REST |
197 |
|
|
IF (REST .GT. 1.E-5*DABS(STEP)) GO TO 20 |
198 |
|
|
* |
199 |
|
|
GO TO 999 |
200 |
|
|
* |
201 |
|
|
** CUT STEP |
202 |
|
|
30 NCUT = NCUT + 1 |
203 |
|
|
* If too many cuts , go to HELIX |
204 |
|
|
IF (NCUT.GT.MAXCUT) GO TO 40 |
205 |
|
|
H = H*HALF |
206 |
|
|
GO TO 20 |
207 |
|
|
* |
208 |
|
|
** ANGLE TOO BIG, USE HELIX |
209 |
|
|
40 F1 = F(1) |
210 |
|
|
F2 = F(2) |
211 |
|
|
F3 = F(3) |
212 |
|
|
F4 = DSQRT(F1**2+F2**2+F3**2) |
213 |
|
|
RHO = -F4*PINV |
214 |
|
|
TET = RHO * STEP |
215 |
|
|
IF(TET.NE.0.) THEN |
216 |
|
|
HNORM = ONE/F4 |
217 |
|
|
F1 = F1*HNORM |
218 |
|
|
F2 = F2*HNORM |
219 |
|
|
F3 = F3*HNORM |
220 |
|
|
* |
221 |
|
|
HXP(1) = F2*VECT(IPZ) - F3*VECT(IPY) |
222 |
|
|
HXP(2) = F3*VECT(IPX) - F1*VECT(IPZ) |
223 |
|
|
HXP(3) = F1*VECT(IPY) - F2*VECT(IPX) |
224 |
|
|
|
225 |
|
|
HP = F1*VECT(IPX) + F2*VECT(IPY) + F3*VECT(IPZ) |
226 |
|
|
* |
227 |
|
|
RHO1 = ONE/RHO |
228 |
|
|
SINT = DSIN(TET) |
229 |
|
|
COST = TWO*DSIN(HALF*TET)**2 |
230 |
|
|
* |
231 |
|
|
G1 = SINT*RHO1 |
232 |
|
|
G2 = COST*RHO1 |
233 |
|
|
G3 = (TET-SINT) * HP*RHO1 |
234 |
|
|
G4 = -COST |
235 |
|
|
G5 = SINT |
236 |
|
|
G6 = COST * HP |
237 |
|
|
|
238 |
|
|
VOUT(IX) = VECT(IX) + (G1*VECT(IPX) + G2*HXP(1) + G3*F1) |
239 |
|
|
VOUT(IY) = VECT(IY) + (G1*VECT(IPY) + G2*HXP(2) + G3*F2) |
240 |
|
|
VOUT(IZ) = VECT(IZ) + (G1*VECT(IPZ) + G2*HXP(3) + G3*F3) |
241 |
|
|
|
242 |
|
|
VOUT(IPX) = VECT(IPX) + (G4*VECT(IPX) + G5*HXP(1) + G6*F1) |
243 |
|
|
VOUT(IPY) = VECT(IPY) + (G4*VECT(IPY) + G5*HXP(2) + G6*F2) |
244 |
|
|
VOUT(IPZ) = VECT(IPZ) + (G4*VECT(IPZ) + G5*HXP(3) + G6*F3) |
245 |
|
|
* |
246 |
|
|
ELSE |
247 |
|
|
VOUT(IX) = VECT(IX) + STEP*VECT(IPX) |
248 |
|
|
VOUT(IY) = VECT(IY) + STEP*VECT(IPY) |
249 |
|
|
VOUT(IZ) = VECT(IZ) + STEP*VECT(IPZ) |
250 |
|
|
* |
251 |
|
|
ENDIF |
252 |
|
|
* |
253 |
|
|
999 END |
254 |
|
|
* |
255 |
|
|
* |
256 |
|
|
|
257 |
pam-fi |
1.2 |
********************************************************************** |
258 |
|
|
* |
259 |
|
|
* |
260 |
|
|
* routine per tracciare la particella di uno STEP |
261 |
|
|
* *** extended version *** |
262 |
|
|
* it return also the track-length |
263 |
|
|
* |
264 |
|
|
SUBROUTINE GRKUTA2 (CHARGE,STEP,VECT,VOUT) |
265 |
|
|
C. |
266 |
|
|
C. ****************************************************************** |
267 |
|
|
C. * * |
268 |
|
|
C. * Runge-Kutta method for tracking a particle through a magnetic * |
269 |
|
|
C. * field. Uses Nystroem algorithm (See Handbook Nat. Bur. of * |
270 |
|
|
C. * Standards, procedure 25.5.20) * |
271 |
|
|
C. * * |
272 |
|
|
C. * Input parameters * |
273 |
|
|
C. * CHARGE Particle charge * |
274 |
|
|
C. * STEP Step size * |
275 |
|
|
C. * VECT Initial co-ords,direction cosines,momentum * |
276 |
|
|
C. * Output parameters * |
277 |
|
|
C. * VOUT Output co-ords,direction cosines,momentum * |
278 |
|
|
C. * User routine called * |
279 |
|
|
C. * CALL GUFLD(X,F) * |
280 |
|
|
C. * * |
281 |
|
|
C. * ==>Called by : <USER>, GUSWIM * |
282 |
|
|
C. * Authors R.Brun, M.Hansroul ********* * |
283 |
|
|
C. * V.Perevoztchikov (CUT STEP implementation) * |
284 |
|
|
C. * * |
285 |
|
|
C. * * |
286 |
|
|
C. ****************************************************************** |
287 |
|
|
C. |
288 |
|
|
IMPLICIT DOUBLE PRECISION(A-H,O-Z) |
289 |
|
|
* |
290 |
|
|
REAL VVV(3),FFF(3) |
291 |
|
|
REAL*8 CHARGE, STEP, VECT(*), VOUT(*), F(4) |
292 |
|
|
REAL*8 XYZT(3), XYZ(3), X, Y, Z, XT, YT, ZT |
293 |
|
|
DIMENSION SECXS(4),SECYS(4),SECZS(4),HXP(3) |
294 |
|
|
EQUIVALENCE (X,XYZ(1)),(Y,XYZ(2)),(Z,XYZ(3)), |
295 |
|
|
+ (XT,XYZT(1)),(YT,XYZT(2)),(ZT,XYZT(3)) |
296 |
|
|
* |
297 |
|
|
PARAMETER (MAXIT = 1992, MAXCUT = 11) |
298 |
|
|
PARAMETER (EC=2.9979251D-4,DLT=1D-4,DLT32=DLT/32) |
299 |
|
|
PARAMETER (ZERO=0, ONE=1, TWO=2, THREE=3) |
300 |
|
|
PARAMETER (THIRD=ONE/THREE, HALF=ONE/TWO) |
301 |
|
|
PARAMETER (PISQUA=.986960440109D+01) |
302 |
|
|
PARAMETER (IX=1,IY=2,IZ=3,IPX=4,IPY=5,IPZ=6) |
303 |
|
|
|
304 |
|
|
* track length |
305 |
|
|
REAL*8 DL |
306 |
|
|
|
307 |
|
|
*. |
308 |
|
|
*. ------------------------------------------------------------------ |
309 |
|
|
*. |
310 |
|
|
* This constant is for units CM,GEV/C and KGAUSS |
311 |
|
|
* |
312 |
|
|
ITER = 0 |
313 |
|
|
NCUT = 0 |
314 |
|
|
DO 10 J=1,8 |
315 |
|
|
VOUT(J)=VECT(J) |
316 |
|
|
10 CONTINUE |
317 |
|
|
PINV = EC * CHARGE / VECT(7) |
318 |
|
|
TL = 0. |
319 |
|
|
H = STEP |
320 |
|
|
|
321 |
|
|
c print*,'===================== START GRKUTA2' |
322 |
|
|
|
323 |
|
|
* |
324 |
|
|
* |
325 |
|
|
20 REST = STEP-TL |
326 |
|
|
IF (DABS(H).GT.DABS(REST)) H = REST |
327 |
|
|
DO I=1,3 |
328 |
|
|
VVV(I)=SNGL(VOUT(I)) |
329 |
|
|
ENDDO |
330 |
|
|
|
331 |
|
|
CALL GUFLD(VVV,FFF) |
332 |
|
|
* print*,'GRKUTA Bx,By,Bz: ',(FFF(i),i=1,3) |
333 |
|
|
DO I=1,3 |
334 |
|
|
F(I)=DBLE(FFF(I)) |
335 |
|
|
ENDDO |
336 |
|
|
* |
337 |
|
|
* Start of integration |
338 |
|
|
* |
339 |
|
|
X = VOUT(1) |
340 |
|
|
Y = VOUT(2) |
341 |
|
|
Z = VOUT(3) |
342 |
|
|
A = VOUT(4) |
343 |
|
|
B = VOUT(5) |
344 |
|
|
C = VOUT(6) |
345 |
|
|
|
346 |
|
|
DL = VOUT(8) |
347 |
|
|
|
348 |
|
|
* |
349 |
|
|
H2 = HALF * H |
350 |
|
|
H4 = HALF * H2 |
351 |
|
|
PH = PINV * H |
352 |
|
|
PH2 = HALF * PH |
353 |
|
|
SECXS(1) = (B * F(3) - C * F(2)) * PH2 |
354 |
|
|
SECYS(1) = (C * F(1) - A * F(3)) * PH2 |
355 |
|
|
SECZS(1) = (A * F(2) - B * F(1)) * PH2 |
356 |
|
|
ANG2 = (SECXS(1)**2 + SECYS(1)**2 + SECZS(1)**2) |
357 |
|
|
IF (ANG2.GT.PISQUA) GO TO 40 |
358 |
|
|
DXT = H2 * A + H4 * SECXS(1) |
359 |
|
|
DYT = H2 * B + H4 * SECYS(1) |
360 |
|
|
DZT = H2 * C + H4 * SECZS(1) |
361 |
|
|
XT = X + DXT |
362 |
|
|
YT = Y + DYT |
363 |
|
|
ZT = Z + DZT |
364 |
|
|
* |
365 |
|
|
* Second intermediate point |
366 |
|
|
* |
367 |
|
|
EST = DABS(DXT)+DABS(DYT)+DABS(DZT) |
368 |
|
|
IF (EST.GT.H) GO TO 30 |
369 |
|
|
|
370 |
|
|
DO I=1,3 |
371 |
|
|
VVV(I)=SNGL(XYZT(I)) |
372 |
|
|
ENDDO |
373 |
|
|
CALL GUFLD(VVV,FFF) |
374 |
|
|
DO I=1,3 |
375 |
|
|
F(I)=DBLE(FFF(I)) |
376 |
|
|
ENDDO |
377 |
|
|
C CALL GUFLD(XYZT,F) |
378 |
|
|
AT = A + SECXS(1) |
379 |
|
|
BT = B + SECYS(1) |
380 |
|
|
CT = C + SECZS(1) |
381 |
|
|
* |
382 |
|
|
SECXS(2) = (BT * F(3) - CT * F(2)) * PH2 |
383 |
|
|
SECYS(2) = (CT * F(1) - AT * F(3)) * PH2 |
384 |
|
|
SECZS(2) = (AT * F(2) - BT * F(1)) * PH2 |
385 |
|
|
AT = A + SECXS(2) |
386 |
|
|
BT = B + SECYS(2) |
387 |
|
|
CT = C + SECZS(2) |
388 |
|
|
SECXS(3) = (BT * F(3) - CT * F(2)) * PH2 |
389 |
|
|
SECYS(3) = (CT * F(1) - AT * F(3)) * PH2 |
390 |
|
|
SECZS(3) = (AT * F(2) - BT * F(1)) * PH2 |
391 |
|
|
DXT = H * (A + SECXS(3)) |
392 |
|
|
DYT = H * (B + SECYS(3)) |
393 |
|
|
DZT = H * (C + SECZS(3)) |
394 |
|
|
XT = X + DXT |
395 |
|
|
YT = Y + DYT |
396 |
|
|
ZT = Z + DZT |
397 |
|
|
AT = A + TWO*SECXS(3) |
398 |
|
|
BT = B + TWO*SECYS(3) |
399 |
|
|
CT = C + TWO*SECZS(3) |
400 |
|
|
* |
401 |
|
|
EST = ABS(DXT)+ABS(DYT)+ABS(DZT) |
402 |
|
|
IF (EST.GT.2.*ABS(H)) GO TO 30 |
403 |
|
|
|
404 |
|
|
DO I=1,3 |
405 |
|
|
VVV(I)=SNGL(XYZT(I)) |
406 |
|
|
ENDDO |
407 |
|
|
CALL GUFLD(VVV,FFF) |
408 |
|
|
DO I=1,3 |
409 |
|
|
F(I)=DBLE(FFF(I)) |
410 |
|
|
ENDDO |
411 |
|
|
C CALL GUFLD(XYZT,F) |
412 |
|
|
* |
413 |
|
|
Z = Z + (C + (SECZS(1) + SECZS(2) + SECZS(3)) * THIRD) * H |
414 |
|
|
Y = Y + (B + (SECYS(1) + SECYS(2) + SECYS(3)) * THIRD) * H |
415 |
|
|
X = X + (A + (SECXS(1) + SECXS(2) + SECXS(3)) * THIRD) * H |
416 |
|
|
* |
417 |
|
|
SECXS(4) = (BT*F(3) - CT*F(2))* PH2 |
418 |
|
|
SECYS(4) = (CT*F(1) - AT*F(3))* PH2 |
419 |
|
|
SECZS(4) = (AT*F(2) - BT*F(1))* PH2 |
420 |
|
|
A = A+(SECXS(1)+SECXS(4)+TWO * (SECXS(2)+SECXS(3))) * THIRD |
421 |
|
|
B = B+(SECYS(1)+SECYS(4)+TWO * (SECYS(2)+SECYS(3))) * THIRD |
422 |
|
|
C = C+(SECZS(1)+SECZS(4)+TWO * (SECZS(2)+SECZS(3))) * THIRD |
423 |
|
|
* |
424 |
|
|
EST = ABS(SECXS(1)+SECXS(4) - (SECXS(2)+SECXS(3))) |
425 |
|
|
++ ABS(SECYS(1)+SECYS(4) - (SECYS(2)+SECYS(3))) |
426 |
|
|
++ ABS(SECZS(1)+SECZS(4) - (SECZS(2)+SECZS(3))) |
427 |
|
|
* |
428 |
|
|
IF (EST.GT.DLT .AND. ABS(H).GT.1.E-4) GO TO 30 |
429 |
mocchiut |
1.1 |
|
430 |
pam-fi |
1.2 |
ITER = ITER + 1 |
431 |
|
|
NCUT = 0 |
432 |
|
|
* If too many iterations, go to HELIX |
433 |
|
|
IF (ITER.GT.MAXIT) GO TO 40 |
434 |
|
|
* |
435 |
|
|
DL = VOUT(8) + |
436 |
|
|
$ DSQRT( 0 |
437 |
|
|
$ + (X-VOUT(1))**2 |
438 |
|
|
$ + (Y-VOUT(2))**2 |
439 |
|
|
$ + (Z-VOUT(3))**2 |
440 |
|
|
$ ) |
441 |
|
|
c print*,'- ',VOUT(3),z,VOUT(1),x,VOUT(2),y,DL |
442 |
|
|
* |
443 |
|
|
TL = TL + H |
444 |
|
|
IF (EST.LT.(DLT32)) THEN |
445 |
|
|
H = H*TWO |
446 |
|
|
ENDIF |
447 |
|
|
CBA = ONE/ SQRT(A*A + B*B + C*C) |
448 |
|
|
VOUT(1) = X |
449 |
|
|
VOUT(2) = Y |
450 |
|
|
VOUT(3) = Z |
451 |
|
|
VOUT(4) = CBA*A |
452 |
|
|
VOUT(5) = CBA*B |
453 |
|
|
VOUT(6) = CBA*C |
454 |
|
|
VOUT(8) = DL |
455 |
|
|
REST = STEP - TL |
456 |
|
|
IF (STEP.LT.0.) REST = -REST |
457 |
|
|
IF (REST .GT. 1.E-5*DABS(STEP)) GO TO 20 |
458 |
|
|
* |
459 |
|
|
GO TO 999 |
460 |
|
|
* |
461 |
|
|
** CUT STEP |
462 |
|
|
30 NCUT = NCUT + 1 |
463 |
|
|
* If too many cuts , go to HELIX |
464 |
|
|
IF (NCUT.GT.MAXCUT) GO TO 40 |
465 |
|
|
H = H*HALF |
466 |
|
|
GO TO 20 |
467 |
|
|
* |
468 |
|
|
** ANGLE TOO BIG, USE HELIX |
469 |
|
|
40 F1 = F(1) |
470 |
|
|
F2 = F(2) |
471 |
|
|
F3 = F(3) |
472 |
|
|
F4 = DSQRT(F1**2+F2**2+F3**2) |
473 |
|
|
RHO = -F4*PINV |
474 |
|
|
TET = RHO * STEP |
475 |
|
|
IF(TET.NE.0.) THEN |
476 |
|
|
HNORM = ONE/F4 |
477 |
|
|
F1 = F1*HNORM |
478 |
|
|
F2 = F2*HNORM |
479 |
|
|
F3 = F3*HNORM |
480 |
|
|
* |
481 |
|
|
HXP(1) = F2*VECT(IPZ) - F3*VECT(IPY) |
482 |
|
|
HXP(2) = F3*VECT(IPX) - F1*VECT(IPZ) |
483 |
|
|
HXP(3) = F1*VECT(IPY) - F2*VECT(IPX) |
484 |
|
|
|
485 |
|
|
HP = F1*VECT(IPX) + F2*VECT(IPY) + F3*VECT(IPZ) |
486 |
|
|
* |
487 |
|
|
RHO1 = ONE/RHO |
488 |
|
|
SINT = DSIN(TET) |
489 |
|
|
COST = TWO*DSIN(HALF*TET)**2 |
490 |
|
|
* |
491 |
|
|
G1 = SINT*RHO1 |
492 |
|
|
G2 = COST*RHO1 |
493 |
|
|
G3 = (TET-SINT) * HP*RHO1 |
494 |
|
|
G4 = -COST |
495 |
|
|
G5 = SINT |
496 |
|
|
G6 = COST * HP |
497 |
|
|
|
498 |
|
|
VOUT(IX) = VECT(IX) + (G1*VECT(IPX) + G2*HXP(1) + G3*F1) |
499 |
|
|
VOUT(IY) = VECT(IY) + (G1*VECT(IPY) + G2*HXP(2) + G3*F2) |
500 |
|
|
VOUT(IZ) = VECT(IZ) + (G1*VECT(IPZ) + G2*HXP(3) + G3*F3) |
501 |
|
|
|
502 |
|
|
VOUT(IPX) = VECT(IPX) + (G4*VECT(IPX) + G5*HXP(1) + G6*F1) |
503 |
|
|
VOUT(IPY) = VECT(IPY) + (G4*VECT(IPY) + G5*HXP(2) + G6*F2) |
504 |
|
|
VOUT(IPZ) = VECT(IPZ) + (G4*VECT(IPZ) + G5*HXP(3) + G6*F3) |
505 |
|
|
* |
506 |
|
|
ELSE |
507 |
|
|
VOUT(IX) = VECT(IX) + STEP*VECT(IPX) |
508 |
|
|
VOUT(IY) = VECT(IY) + STEP*VECT(IPY) |
509 |
|
|
VOUT(IZ) = VECT(IZ) + STEP*VECT(IPZ) |
510 |
|
|
* |
511 |
|
|
ENDIF |
512 |
|
|
* TEMP !!! TEMP !!! TEMP !!! TEMP !!! TEMP !!! TEMP !!! |
513 |
|
|
* devo mettere la lunghezza dell'elica!!!!!!!!!!!!!! |
514 |
|
|
* ma non mi riesce :-( |
515 |
|
|
VOUT(8) = DSQRT( 0 |
516 |
|
|
$ +(VOUT(IX)-VECT(IX))**2 |
517 |
|
|
$ +(VOUT(IY)-VECT(IY))**2 |
518 |
|
|
$ +(VOUT(IZ)-VECT(IZ))**2 |
519 |
|
|
$ ) |
520 |
pam-fi |
1.5 |
c print*,'WARNING: GRKUTA2 --> ' |
521 |
|
|
c $ ,'helix :-( ... length evaluated with straight line' |
522 |
pam-fi |
1.2 |
|
523 |
|
|
* |
524 |
|
|
999 END |
525 |
|
|
* |
526 |
|
|
* |
527 |
mocchiut |
1.1 |
|
528 |
|
|
********************************************************************** |
529 |
|
|
* |
530 |
|
|
* gives the value of the magnetic field in the tracking point |
531 |
|
|
* |
532 |
|
|
********************************************************************** |
533 |
|
|
|
534 |
|
|
subroutine gufld(v,f) !coordinates in cm, B field in kGauss |
535 |
|
|
|
536 |
|
|
real v(3),f(3) !coordinates in cm, B field in kGauss, error in kGauss |
537 |
|
|
|
538 |
|
|
real*8 vv(3),ff(3) !inter_B.f works in double precision |
539 |
|
|
|
540 |
|
|
|
541 |
pam-fi |
1.4 |
do i=1,3 |
542 |
|
|
vv(i)=v(i)/100. !inter_B.f works in meters |
543 |
|
|
enddo |
544 |
|
|
c inter_B: coordinates in m, B field in Tesla |
545 |
|
|
c$$$ print*,'GUFLD: v ',v |
546 |
|
|
call inter_B(vv(1),vv(2),vv(3),ff) |
547 |
|
|
do i=1,3 !change back the field in kGauss |
548 |
|
|
f(i)=ff(i)*10. |
549 |
|
|
enddo |
550 |
|
|
c$$$ print*,'GUFLD: b ',f |
551 |
|
|
|
552 |
mocchiut |
1.1 |
return |
553 |
|
|
end |
554 |
|
|
|