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