1 |
mocchiut |
1.1 |
|
2 |
|
|
*** |
3 |
|
|
* subroutine to compute the Integral(B dl) along the trajectory |
4 |
|
|
*** |
5 |
|
|
|
6 |
|
|
|
7 |
|
|
*** |
8 |
|
|
* |
9 |
|
|
* created by paolo papini, 11 oct 2005 |
10 |
|
|
* |
11 |
|
|
* c$$$ max: modified by massimo bongi, 11 oct 2005 (later...) |
12 |
|
|
* |
13 |
|
|
*** |
14 |
|
|
|
15 |
|
|
|
16 |
|
|
subroutine CalcBdL(Nstep,BdL,IFAIL) |
17 |
|
|
IMPLICIT DOUBLE PRECISION (A-H,O-Z) |
18 |
|
|
real BdL,vvv(3),fff(3) |
19 |
|
|
real*8 f(3) |
20 |
|
|
include 'commontracker.f' !tracker general common |
21 |
|
|
include 'common_mini_2.f' !common for the tracking procedure |
22 |
|
|
* |
23 |
|
|
* set parameters for GRKUTA from ZINI to the first plane |
24 |
|
|
* |
25 |
|
|
c$$$ max IF(AL(5).NE.0) CHARGE=AL_P(5)/DABS(AL_P(5)) |
26 |
|
|
c$$$ max IF(AL(5).NE.0) CHARGE=AL_P(5)/DABS(AL_P(5)) |
27 |
|
|
c$$$ IF(AL(5).NE.0) CHARGE=AL(5)/DABS(AL(5)) |
28 |
|
|
IF(AL(5).NE.0) CHARGE=AL(5)/DABS(AL(5)) |
29 |
|
|
IF(AL(5).EQ.0) CHARGE=1. |
30 |
|
|
VOUT(1)=AL(1) |
31 |
|
|
VOUT(2)=AL(2) |
32 |
|
|
VOUT(3)=ZINI ! DBLE(Z0)-DBLE(ZSPEC) |
33 |
|
|
VOUT(4)=AL(3)*DCOS(AL(4)) |
34 |
|
|
VOUT(5)=AL(3)*DSIN(AL(4)) |
35 |
|
|
VOUT(6)=-1.*DSQRT(1.-AL(3)**2) |
36 |
|
|
IF(AL(5).NE.0.) VOUT(7)=DABS(1./AL(5)) |
37 |
|
|
IF(AL(5).EQ.0.) VOUT(7)=1.E8 |
38 |
|
|
* |
39 |
|
|
* first integrate the track from reference plane to first trk plane |
40 |
|
|
* |
41 |
|
|
* zout=zm(1) |
42 |
|
|
zout=zv(1) |
43 |
|
|
step=vout(3)-zout |
44 |
|
|
10 DO J=1,7 |
45 |
|
|
VECT(J)=VOUT(J) |
46 |
|
|
VECTINI(J)=VOUT(J) |
47 |
|
|
ENDDO |
48 |
|
|
11 continue |
49 |
|
|
CALL GRKUTA(CHARGE,STEP,VECT,VOUT) |
50 |
|
|
IF(VOUT(3).GT.VECT(3)) THEN |
51 |
|
|
IFAIL=1 |
52 |
|
|
PRINT *,'BdL (grkuta): WARNING ===> backward track!!' |
53 |
|
|
print*,'charge',charge |
54 |
|
|
print*,'vect',vect |
55 |
|
|
print*,'vout',vout |
56 |
|
|
print*,'step',step |
57 |
|
|
RETURN |
58 |
|
|
ENDIF |
59 |
|
|
Z=VOUT(3) |
60 |
|
|
IF(Z.LE.Zout+TOLL.AND.Z.GE.Zout-TOLL) GOTO 100 |
61 |
|
|
IF(Z.GT.Zout+TOLL) GOTO 10 |
62 |
|
|
IF(Z.LE.Zout-TOLL) THEN |
63 |
|
|
STEP=STEP*(Zout-VECT(3))/(Z-VECT(3)) |
64 |
|
|
DO J=1,7 |
65 |
|
|
VECT(J)=VECTINI(J) |
66 |
|
|
ENDDO |
67 |
|
|
GOTO 11 |
68 |
|
|
ENDIF |
69 |
|
|
* |
70 |
|
|
* then integrate B o dL along the track, from the first to the last plane |
71 |
|
|
* |
72 |
|
|
100 continue |
73 |
|
|
BdL=0. |
74 |
|
|
* dz=(zm(1)-zm(6))/float(Nstep) |
75 |
|
|
dz = (zv(1)-zv(6))/float(Nstep) |
76 |
|
|
zout = zv(6) |
77 |
|
|
|
78 |
|
|
do i=1,10*Nstep |
79 |
|
|
BdLstep=0. |
80 |
|
|
vvv(1)=sngl(vout(1)) |
81 |
|
|
vvv(2)=sngl(vout(2)) |
82 |
|
|
vvv(3)=sngl(vout(3)) |
83 |
|
|
CALL GUFLD(VVV,FFF) |
84 |
|
|
do j=1,3 |
85 |
|
|
f(j)=dble(fff(j)) |
86 |
|
|
enddo |
87 |
|
|
c zout=vout(3)-dz |
88 |
|
|
step = dz |
89 |
|
|
20 DO J=1,7 |
90 |
|
|
VECT(J)=VOUT(J) |
91 |
|
|
VECTINI(J)=VOUT(J) |
92 |
|
|
ENDDO |
93 |
|
|
21 continue |
94 |
|
|
CALL GRKUTA(CHARGE,STEP,VECT,VOUT) |
95 |
|
|
c$$$ BdLstep=BdLstep+ |
96 |
|
|
c$$$ $ (vout(1)-vect(1))*f(1)+ |
97 |
|
|
c$$$ $ (vout(2)-vect(2))*f(2)+ |
98 |
|
|
c$$$ $ (vout(3)-vect(3))*f(3) |
99 |
|
|
BdLstep=BdLstep+ |
100 |
|
|
$ sqrt( |
101 |
|
|
$ ((vout(2)-vect(2))*f(3)-(vout(3)-vect(3))*f(2))**2+ |
102 |
|
|
$ ((vout(3)-vect(3))*f(1)-(vout(1)-vect(1))*f(3))**2+ |
103 |
|
|
$ ((vout(1)-vect(1))*f(2)-(vout(2)-vect(2))*f(1))**2 |
104 |
|
|
$ ) |
105 |
|
|
IF(VOUT(3).GT.VECT(3)) THEN |
106 |
|
|
IFAIL=1 |
107 |
|
|
PRINT *,'BdL (grkuta): WARNING ===> backward track!!' |
108 |
|
|
print*,'charge',charge |
109 |
|
|
print*,'vect',vect |
110 |
|
|
print*,'vout',vout |
111 |
|
|
print*,'step',step |
112 |
|
|
RETURN |
113 |
|
|
ENDIF |
114 |
|
|
200 continue |
115 |
|
|
BdL=BdL+sngl(BdLstep*1.D-3) !Tesla * meters |
116 |
|
|
c print*,i,' #### ',BdL |
117 |
|
|
|
118 |
|
|
Z=VOUT(3) |
119 |
|
|
IF(Z.LE.Zout+TOLL.AND.Z.GE.Zout-TOLL) GOTO 2000 !end |
120 |
|
|
IF(Z.LE.Zout-TOLL) THEN |
121 |
|
|
STEP=STEP*(Zout-VECT(3))/(Z-VECT(3)) |
122 |
|
|
DO J=1,7 |
123 |
|
|
VECT(J)=VECTINI(J) |
124 |
|
|
ENDDO |
125 |
|
|
BdL=BdL-sngl(BdLstep*1.D-3) !Tesla * meters |
126 |
|
|
BdLstep=0. |
127 |
|
|
GOTO 21 |
128 |
|
|
ENDIF |
129 |
|
|
enddo |
130 |
|
|
2000 continue |
131 |
|
|
c$$$ print*,' #### ',BdL |
132 |
|
|
c$$$ print*,' #### ',xgood |
133 |
|
|
c$$$ print*,' #### ',ygood |
134 |
|
|
c$$$ print*,'=========================================' |
135 |
|
|
return |
136 |
|
|
end |
137 |
|
|
|
138 |
|
|
|