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