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 |
* |
32 |
REAL VVV(3),FFF(3) |
33 |
REAL*8 CHARGE, STEP, VECT(*), VOUT(*), F(4) |
34 |
REAL*8 XYZT(3), XYZ(3), X, Y, Z, XT, YT, ZT |
35 |
DIMENSION SECXS(4),SECYS(4),SECZS(4),HXP(3) |
36 |
EQUIVALENCE (X,XYZ(1)),(Y,XYZ(2)),(Z,XYZ(3)), |
37 |
+ (XT,XYZT(1)),(YT,XYZT(2)),(ZT,XYZT(3)) |
38 |
* |
39 |
PARAMETER (MAXIT = 1992, MAXCUT = 11) |
40 |
PARAMETER (EC=2.9979251D-4,DLT=1D-4,DLT32=DLT/32) |
41 |
PARAMETER (ZERO=0, ONE=1, TWO=2, THREE=3) |
42 |
PARAMETER (THIRD=ONE/THREE, HALF=ONE/TWO) |
43 |
PARAMETER (PISQUA=.986960440109D+01) |
44 |
PARAMETER (IX=1,IY=2,IZ=3,IPX=4,IPY=5,IPZ=6) |
45 |
|
46 |
*. |
47 |
*. ------------------------------------------------------------------ |
48 |
*. |
49 |
* This constant is for units CM,GEV/C and KGAUSS |
50 |
* |
51 |
ITER = 0 |
52 |
NCUT = 0 |
53 |
DO 10 J=1,7 |
54 |
VOUT(J)=VECT(J) |
55 |
10 CONTINUE |
56 |
PINV = EC * CHARGE / VECT(7) |
57 |
TL = 0. |
58 |
H = STEP |
59 |
* |
60 |
* |
61 |
20 REST = STEP-TL |
62 |
IF (DABS(H).GT.DABS(REST)) H = REST |
63 |
DO I=1,3 |
64 |
VVV(I)=SNGL(VOUT(I)) |
65 |
ENDDO |
66 |
|
67 |
CALL GUFLD(VVV,FFF) |
68 |
DO I=1,3 |
69 |
F(I)=DBLE(FFF(I)) |
70 |
ENDDO |
71 |
* |
72 |
* Start of integration |
73 |
* |
74 |
X = VOUT(1) |
75 |
Y = VOUT(2) |
76 |
Z = VOUT(3) |
77 |
A = VOUT(4) |
78 |
B = VOUT(5) |
79 |
C = VOUT(6) |
80 |
* |
81 |
H2 = HALF * H |
82 |
H4 = HALF * H2 |
83 |
PH = PINV * H |
84 |
PH2 = HALF * PH |
85 |
SECXS(1) = (B * F(3) - C * F(2)) * PH2 |
86 |
SECYS(1) = (C * F(1) - A * F(3)) * PH2 |
87 |
SECZS(1) = (A * F(2) - B * F(1)) * PH2 |
88 |
ANG2 = (SECXS(1)**2 + SECYS(1)**2 + SECZS(1)**2) |
89 |
IF (ANG2.GT.PISQUA) GO TO 40 |
90 |
DXT = H2 * A + H4 * SECXS(1) |
91 |
DYT = H2 * B + H4 * SECYS(1) |
92 |
DZT = H2 * C + H4 * SECZS(1) |
93 |
XT = X + DXT |
94 |
YT = Y + DYT |
95 |
ZT = Z + DZT |
96 |
* |
97 |
* Second intermediate point |
98 |
* |
99 |
EST = DABS(DXT)+DABS(DYT)+DABS(DZT) |
100 |
IF (EST.GT.H) GO TO 30 |
101 |
|
102 |
DO I=1,3 |
103 |
VVV(I)=SNGL(XYZT(I)) |
104 |
ENDDO |
105 |
CALL GUFLD(VVV,FFF) |
106 |
DO I=1,3 |
107 |
F(I)=DBLE(FFF(I)) |
108 |
ENDDO |
109 |
C CALL GUFLD(XYZT,F) |
110 |
AT = A + SECXS(1) |
111 |
BT = B + SECYS(1) |
112 |
CT = C + SECZS(1) |
113 |
* |
114 |
SECXS(2) = (BT * F(3) - CT * F(2)) * PH2 |
115 |
SECYS(2) = (CT * F(1) - AT * F(3)) * PH2 |
116 |
SECZS(2) = (AT * F(2) - BT * F(1)) * PH2 |
117 |
AT = A + SECXS(2) |
118 |
BT = B + SECYS(2) |
119 |
CT = C + SECZS(2) |
120 |
SECXS(3) = (BT * F(3) - CT * F(2)) * PH2 |
121 |
SECYS(3) = (CT * F(1) - AT * F(3)) * PH2 |
122 |
SECZS(3) = (AT * F(2) - BT * F(1)) * PH2 |
123 |
DXT = H * (A + SECXS(3)) |
124 |
DYT = H * (B + SECYS(3)) |
125 |
DZT = H * (C + SECZS(3)) |
126 |
XT = X + DXT |
127 |
YT = Y + DYT |
128 |
ZT = Z + DZT |
129 |
AT = A + TWO*SECXS(3) |
130 |
BT = B + TWO*SECYS(3) |
131 |
CT = C + TWO*SECZS(3) |
132 |
* |
133 |
EST = ABS(DXT)+ABS(DYT)+ABS(DZT) |
134 |
IF (EST.GT.2.*ABS(H)) GO TO 30 |
135 |
|
136 |
DO I=1,3 |
137 |
VVV(I)=SNGL(XYZT(I)) |
138 |
ENDDO |
139 |
CALL GUFLD(VVV,FFF) |
140 |
DO I=1,3 |
141 |
F(I)=DBLE(FFF(I)) |
142 |
ENDDO |
143 |
C CALL GUFLD(XYZT,F) |
144 |
* |
145 |
Z = Z + (C + (SECZS(1) + SECZS(2) + SECZS(3)) * THIRD) * H |
146 |
Y = Y + (B + (SECYS(1) + SECYS(2) + SECYS(3)) * THIRD) * H |
147 |
X = X + (A + (SECXS(1) + SECXS(2) + SECXS(3)) * THIRD) * H |
148 |
* |
149 |
SECXS(4) = (BT*F(3) - CT*F(2))* PH2 |
150 |
SECYS(4) = (CT*F(1) - AT*F(3))* PH2 |
151 |
SECZS(4) = (AT*F(2) - BT*F(1))* PH2 |
152 |
A = A+(SECXS(1)+SECXS(4)+TWO * (SECXS(2)+SECXS(3))) * THIRD |
153 |
B = B+(SECYS(1)+SECYS(4)+TWO * (SECYS(2)+SECYS(3))) * THIRD |
154 |
C = C+(SECZS(1)+SECZS(4)+TWO * (SECZS(2)+SECZS(3))) * THIRD |
155 |
* |
156 |
EST = ABS(SECXS(1)+SECXS(4) - (SECXS(2)+SECXS(3))) |
157 |
++ ABS(SECYS(1)+SECYS(4) - (SECYS(2)+SECYS(3))) |
158 |
++ ABS(SECZS(1)+SECZS(4) - (SECZS(2)+SECZS(3))) |
159 |
* |
160 |
IF (EST.GT.DLT .AND. ABS(H).GT.1.E-4) GO TO 30 |
161 |
ITER = ITER + 1 |
162 |
NCUT = 0 |
163 |
* If too many iterations, go to HELIX |
164 |
IF (ITER.GT.MAXIT) GO TO 40 |
165 |
* |
166 |
TL = TL + H |
167 |
IF (EST.LT.(DLT32)) THEN |
168 |
H = H*TWO |
169 |
ENDIF |
170 |
CBA = ONE/ SQRT(A*A + B*B + C*C) |
171 |
VOUT(1) = X |
172 |
VOUT(2) = Y |
173 |
VOUT(3) = Z |
174 |
VOUT(4) = CBA*A |
175 |
VOUT(5) = CBA*B |
176 |
VOUT(6) = CBA*C |
177 |
REST = STEP - TL |
178 |
IF (STEP.LT.0.) REST = -REST |
179 |
IF (REST .GT. 1.E-5*DABS(STEP)) GO TO 20 |
180 |
* |
181 |
GO TO 999 |
182 |
* |
183 |
** CUT STEP |
184 |
30 NCUT = NCUT + 1 |
185 |
* If too many cuts , go to HELIX |
186 |
IF (NCUT.GT.MAXCUT) GO TO 40 |
187 |
H = H*HALF |
188 |
GO TO 20 |
189 |
* |
190 |
** ANGLE TOO BIG, USE HELIX |
191 |
40 F1 = F(1) |
192 |
F2 = F(2) |
193 |
F3 = F(3) |
194 |
F4 = DSQRT(F1**2+F2**2+F3**2) |
195 |
RHO = -F4*PINV |
196 |
TET = RHO * STEP |
197 |
IF(TET.NE.0.) THEN |
198 |
HNORM = ONE/F4 |
199 |
F1 = F1*HNORM |
200 |
F2 = F2*HNORM |
201 |
F3 = F3*HNORM |
202 |
* |
203 |
HXP(1) = F2*VECT(IPZ) - F3*VECT(IPY) |
204 |
HXP(2) = F3*VECT(IPX) - F1*VECT(IPZ) |
205 |
HXP(3) = F1*VECT(IPY) - F2*VECT(IPX) |
206 |
|
207 |
HP = F1*VECT(IPX) + F2*VECT(IPY) + F3*VECT(IPZ) |
208 |
* |
209 |
RHO1 = ONE/RHO |
210 |
SINT = DSIN(TET) |
211 |
COST = TWO*DSIN(HALF*TET)**2 |
212 |
* |
213 |
G1 = SINT*RHO1 |
214 |
G2 = COST*RHO1 |
215 |
G3 = (TET-SINT) * HP*RHO1 |
216 |
G4 = -COST |
217 |
G5 = SINT |
218 |
G6 = COST * HP |
219 |
|
220 |
VOUT(IX) = VECT(IX) + (G1*VECT(IPX) + G2*HXP(1) + G3*F1) |
221 |
VOUT(IY) = VECT(IY) + (G1*VECT(IPY) + G2*HXP(2) + G3*F2) |
222 |
VOUT(IZ) = VECT(IZ) + (G1*VECT(IPZ) + G2*HXP(3) + G3*F3) |
223 |
|
224 |
VOUT(IPX) = VECT(IPX) + (G4*VECT(IPX) + G5*HXP(1) + G6*F1) |
225 |
VOUT(IPY) = VECT(IPY) + (G4*VECT(IPY) + G5*HXP(2) + G6*F2) |
226 |
VOUT(IPZ) = VECT(IPZ) + (G4*VECT(IPZ) + G5*HXP(3) + G6*F3) |
227 |
* |
228 |
ELSE |
229 |
VOUT(IX) = VECT(IX) + STEP*VECT(IPX) |
230 |
VOUT(IY) = VECT(IY) + STEP*VECT(IPY) |
231 |
VOUT(IZ) = VECT(IZ) + STEP*VECT(IPZ) |
232 |
* |
233 |
ENDIF |
234 |
* |
235 |
999 END |
236 |
* |
237 |
* |
238 |
|
239 |
|
240 |
|
241 |
********************************************************************** |
242 |
* |
243 |
* gives the value of the magnetic field in the tracking point |
244 |
* |
245 |
********************************************************************** |
246 |
|
247 |
subroutine gufld(v,f) !coordinates in cm, B field in kGauss |
248 |
|
249 |
real v(3),f(3) !coordinates in cm, B field in kGauss, error in kGauss |
250 |
|
251 |
real*8 vv(3),ff(3) !inter_B.f works in double precision |
252 |
|
253 |
|
254 |
do i=1,3 |
255 |
vv(i)=v(i)/100. !inter_B.f works in meters |
256 |
enddo |
257 |
c inter_B: coordinates in m, B field in Tesla |
258 |
call inter_B(vv(1),vv(2),vv(3),ff) |
259 |
do i=1,3 !change back the field in kGauss |
260 |
f(i)=ff(i)*10. |
261 |
enddo |
262 |
|
263 |
return |
264 |
end |
265 |
|