12 |
************************************************************************ |
************************************************************************ |
13 |
|
|
14 |
|
|
15 |
SUBROUTINE MINI_2(ISTEP,IFAIL) |
SUBROUTINE MINI2(ISTEP,IFAIL,IPRINT) |
16 |
|
|
17 |
IMPLICIT DOUBLE PRECISION (A-H,O-Z) |
IMPLICIT DOUBLE PRECISION (A-H,O-Z) |
18 |
|
|
22 |
c logical DEBUG |
c logical DEBUG |
23 |
c common/dbg/DEBUG |
c common/dbg/DEBUG |
24 |
|
|
25 |
parameter (inf=1.e8) !just a huge number... |
parameter (dinf=1.d15) !just a huge number... |
26 |
c------------------------------------------------------------------------ |
c------------------------------------------------------------------------ |
27 |
c variables used in the tracking procedure (mini and its subroutines) |
c variables used in the tracking procedure (mini and its subroutines) |
28 |
c |
c |
31 |
c ordering, but they maintain their Z coordinates. so plane number 1 is |
c ordering, but they maintain their Z coordinates. so plane number 1 is |
32 |
c the first one that a particle meets, and its Z coordinate is > 0 |
c the first one that a particle meets, and its Z coordinate is > 0 |
33 |
c------------------------------------------------------------------------ |
c------------------------------------------------------------------------ |
34 |
DATA ZINI/23.5/ !z coordinate of the reference plane |
DATA ZINI/23.5/ !!! ***PP*** to be changed !z coordinate of the reference plane |
35 |
|
|
36 |
DATA XGOOD,YGOOD/nplanes*1.,nplanes*1./ !planes to be used in the tracking |
c DATA XGOOD,YGOOD/nplanes*1.,nplanes*1./ !planes to be used in the tracking |
37 |
|
|
38 |
DATA STEPAL/5*1.d-7/ !alpha vector step |
DATA STEPAL/5*1.d-7/ !alpha vector step |
39 |
DATA ISTEPMAX/100/ !maximum number of steps in the chi^2 minimization |
DATA ISTEPMAX/120/ !maximum number of steps in the chi^2 minimization |
40 |
DATA TOLL/1.d-8/ !tolerance in reaching the next plane during |
DATA TOLL/1.d-8/ !tolerance in reaching the next plane during |
41 |
* !the tracking procedure |
* !the tracking procedure |
42 |
DATA STEPMAX/100./ !maximum number of steps in the trackin gprocess |
DATA STEPMAX/100./ !maximum number of steps in the trackin gprocess |
43 |
|
|
44 |
c DATA ALMAX/inf,inf,inf,inf,0.25e2/ !limits on alpha vector components |
DATA ALMAX/dinf,dinf,1.,dinf,dinf/ !limits on alpha vector components |
45 |
c DATA ALMIN/-inf,-inf,-inf,-inf,-0.25e2/ !" |
DATA ALMIN/-dinf,-dinf,-1.,-dinf,-dinf/ !" |
|
DATA ALMAX/inf,inf,1.,inf,0.25e2/ !limits on alpha vector components |
|
|
DATA ALMIN/-inf,-inf,-1.,-inf,-0.25e2/ !" |
|
|
|
|
46 |
|
|
47 |
DIMENSION DAL(5) !increment of vector alfa |
DIMENSION DAL(5) !increment of vector alfa |
48 |
|
DIMENSION CHI2DD_R(4,4),CHI2D_R(4) !hessiano e gradiente di chi2 |
49 |
|
|
50 |
|
c elena-------- |
51 |
|
REAL*8 AVRESX,AVRESY |
52 |
|
c elena-------- |
53 |
|
|
54 |
INTEGER IFLAG |
INTEGER IFLAG |
55 |
c-------------------------------------------------------- |
c-------------------------------------------------------- |
56 |
c IFLAG =1 ---- chi2 derivatives computed by using |
c IFLAG =1 ---- chi2 derivatives computed by using |
61 |
c NB: the two metods gives equivalent results BUT |
c NB: the two metods gives equivalent results BUT |
62 |
c method 2 is faster!! |
c method 2 is faster!! |
63 |
c-------------------------------------------------------- |
c-------------------------------------------------------- |
64 |
DATA IFLAG/2/ |
DATA IFLAG/2/ |
65 |
|
|
66 |
|
c LOGICAL TRKDEBUG,TRKVERBOSE |
67 |
|
c COMMON/TRKD/TRKDEBUG,TRKVERBOSE |
68 |
|
LOGICAL TRKDEBUG,TRKVERBOSE |
69 |
|
COMMON/TRKD/TRKDEBUG,TRKVERBOSE |
70 |
|
|
71 |
|
IF(IPRINT.EQ.1) THEN |
72 |
|
TRKVERBOSE = .TRUE. |
73 |
|
TRKDEBUG = .FALSE. |
74 |
|
ELSEIF(IPRINT.EQ.2)THEN |
75 |
|
TRKVERBOSE = .TRUE. |
76 |
|
TRKDEBUG = .TRUE. |
77 |
|
ELSE |
78 |
|
TRKVERBOSE = .FALSE. |
79 |
|
TRKDEBUG = .FALSE. |
80 |
|
ENDIF |
81 |
|
|
82 |
|
* ---------------------------------------------------------- |
83 |
|
* evaluate average spatial resolution |
84 |
|
* ---------------------------------------------------------- |
85 |
|
AVRESX = RESXAV |
86 |
|
AVRESY = RESYAV |
87 |
|
DO IP=1,6 |
88 |
|
IF( XGOOD(IP).EQ.1 )THEN |
89 |
|
NX=NX+1 |
90 |
|
AVRESX=AVRESX+RESX(IP) |
91 |
|
ENDIF |
92 |
|
IF(NX.NE.0)AVRESX=AVRESX/NX |
93 |
|
IF( YGOOD(IP).EQ.1 )THEN |
94 |
|
NY=NY+1 |
95 |
|
AVRESY=AVRESY+RESY(IP) |
96 |
|
ENDIF |
97 |
|
IF(NX.NE.0)AVRESY=AVRESY/NY |
98 |
|
ENDDO |
99 |
|
|
100 |
* ---------------------------------------------------------- |
* ---------------------------------------------------------- |
101 |
* define ALTOL(5) ---> tolerances on state vector |
* define ALTOL(5) ---> tolerances on state vector |
102 |
* |
* |
103 |
* ---------------------------------------------------------- |
* ---------------------------------------------------------- |
104 |
FACT=10. !scale factor to define |
* changed in order to evaluate energy-dependent |
105 |
!tolerance on alfa |
* tolerances on all 5 parameters |
106 |
ALTOL(1)=RESX(1)/FACT !al(1) = x |
FACT=100. !scale factor to define tolerance on alfa |
|
ALTOL(2)=RESY(1)/FACT !al(2) = y |
|
|
ALTOL(3)=DSQRT(RESX(1)**2 !al(3)=sin(theta) |
|
|
$ +RESY(1)**2)/44.51/FACT |
|
|
ALTOL(4)=ALTOL(3) !al(4)=phi |
|
107 |
c deflection error (see PDG) |
c deflection error (see PDG) |
108 |
DELETA1=0.01*RESX(1)/0.3/0.4/0.4451**2*SQRT(720./(6.+4.)) |
DELETA1 = 0.01/0.3/0.4/0.4451**2*SQRT(720./(6.+4.)) |
109 |
DELETA2=0.016/0.3/0.4/0.4451*SQRT(0.4451/9.36) |
DELETA2 = 0.016/0.3/0.4/0.4451*SQRT(0.4451/9.36) |
110 |
|
c$$$ ALTOL(1) = AVRESX/FACT !al(1) = x |
111 |
|
c$$$ ALTOL(2) = AVRESY/FACT !al(2) = y |
112 |
|
c$$$ ALTOL(3) = DSQRT(AVRESX**2 !al(3)=sin(theta) |
113 |
|
c$$$ $ +AVRESY**2)/44.51/FACT |
114 |
|
c$$$ ALTOL(4) = ALTOL(3) !al(4)=phi |
115 |
|
c deflection error (see PDG) |
116 |
|
c$$$ DELETA1 = 0.01*AVRESX/0.3/0.4/0.4451**2*SQRT(720./(6.+4.)) |
117 |
|
c$$$ DELETA2 = 0.016/0.3/0.4/0.4451*SQRT(0.4451/9.36) |
118 |
* ---------------------------------------------------------- |
* ---------------------------------------------------------- |
119 |
* |
* |
120 |
ISTEP=0 !num. steps to minimize chi^2 |
ISTEP=0 !num. steps to minimize chi^2 |
121 |
JFAIL=0 !error flag |
JFAIL=0 !error flag |
122 |
CALL CHISQ(IFLAG,JFAIL) !chi^2 and its derivatives |
|
123 |
IF(JFAIL.NE.0) THEN |
c elena-------- |
124 |
IFAIL=1 |
CHI2 = 0 |
125 |
if(DEBUG) |
c elena-------- |
126 |
$ PRINT *,'mini_2 ===> error on CHISQ computation !!!' |
if(TRKDEBUG) print*,'mini2: step ',istep,chi2,1./AL(5) |
127 |
RETURN |
|
|
ENDIF |
|
128 |
* |
* |
129 |
* ----------------------- |
* ----------------------- |
130 |
* START MINIMIZATION LOOP |
* START MINIMIZATION LOOP |
131 |
* ----------------------- |
* ----------------------- |
132 |
10 ISTEP=ISTEP+1 !<<<<<<<<<<<<<< NEW STEP !! |
10 ISTEP=ISTEP+1 !<<<<<<<<<<<<<< NEW STEP !! |
|
CHI2_P=CHI2 |
|
|
|
|
|
c print*,'@@@@@ ',istep,' - ',al |
|
133 |
|
|
134 |
cost=1e-7 |
CALL CHISQ(IFLAG,JFAIL) !chi^2 and its derivatives |
135 |
|
IF(JFAIL.NE.0) THEN |
136 |
|
IFAIL=1 |
137 |
|
CHI2=-9999. |
138 |
|
if(TRKVERBOSE) |
139 |
|
$ PRINT *,'*** ERROR in mini *** wrong CHISQ' |
140 |
|
RETURN |
141 |
|
ENDIF |
142 |
|
|
143 |
|
COST=1e-7 |
144 |
DO I=1,5 |
DO I=1,5 |
145 |
DO J=1,5 |
DO J=1,5 |
146 |
CHI2DD(I,J)=CHI2DD(I,J)*COST |
CHI2DD(I,J)=CHI2DD(I,J)*COST |
147 |
ENDDO |
ENDDO |
148 |
CHI2D(I)=CHI2D(I)*COST |
CHI2D(I)=CHI2D(I)*COST |
149 |
ENDDO |
ENDDO |
150 |
|
|
151 |
|
IF(PFIXED.EQ.0.) THEN |
152 |
|
|
153 |
*------------------------------------------------------------* |
*------------------------------------------------------------* |
154 |
* track fitting with FREE deflection |
* track fitting with FREE deflection |
155 |
*------------------------------------------------------------* |
*------------------------------------------------------------* |
156 |
CALL DSFACT(5,CHI2DD,5,IFA,DET,JFA) !CHI2DD matrix determinant |
CALL DSFACT(5,CHI2DD,5,IFA,DET,JFA) !CHI2DD matrix determinant |
157 |
IF(IFA.NE.0) THEN !not positive-defined |
IF(IFA.NE.0) THEN !not positive-defined |
158 |
if(DEBUG)then |
if(TRKVERBOSE)then |
159 |
PRINT *, |
PRINT *, |
160 |
$ 'MINI_HOUGH ==> '// |
$ '*** ERROR in mini ***'// |
161 |
$ '** ERROR ** on matrix inversion (not positive-defined)!!!' |
$ 'on matrix inversion (not pos-def)' |
162 |
$ ,DET |
$ ,DET |
163 |
endif |
endif |
164 |
IFAIL=1 |
IF(CHI2.EQ.0) CHI2=-9999. |
165 |
RETURN |
IF(CHI2.GT.0) CHI2=-CHI2 |
166 |
ENDIF |
IFAIL=1 |
167 |
CALL DSFINV(5,CHI2DD,5) !CHI2DD matrix inversion |
RETURN |
168 |
|
ENDIF |
169 |
|
CALL DSFINV(5,CHI2DD,5) !CHI2DD matrix inversion |
170 |
* ******************************************* |
* ******************************************* |
171 |
* find new value of AL-pha !* |
* find new value of AL-pha |
172 |
* !* |
* ******************************************* |
173 |
DO I=1,5 !* |
DO I=1,5 |
174 |
DAL(I)=0. !* |
DAL(I)=0. |
175 |
DO J=1,5 !* |
DO J=1,5 |
176 |
DAL(I)=DAL(I)-CHI2DD(I,J)*CHI2D(J) !* |
DAL(I)=DAL(I)-CHI2DD(I,J)*CHI2D(J) |
177 |
COV(I,J)=CHI2DD(I,J) !* |
COV(I,J)=2.*COST*CHI2DD(I,J) |
178 |
ENDDO !* |
ENDDO |
179 |
ENDDO !* |
ENDDO |
180 |
DO I=1,5 !* |
DO I=1,5 |
181 |
AL(I)=AL(I)+DAL(I) !* |
AL(I)=AL(I)+DAL(I) |
182 |
ENDDO !* |
ENDDO |
183 |
|
*------------------------------------------------------------* |
184 |
|
* track fitting with FIXED deflection |
185 |
|
*------------------------------------------------------------* |
186 |
|
ELSE |
187 |
|
AL(5)=1./PFIXED |
188 |
|
DO I=1,4 |
189 |
|
CHI2D_R(I)=CHI2D(I) |
190 |
|
DO J=1,4 |
191 |
|
CHI2DD_R(I,J)=CHI2DD(I,J) |
192 |
|
ENDDO |
193 |
|
ENDDO |
194 |
|
CALL DSFACT(4,CHI2DD_R,4,IFA,DET,JFA) |
195 |
|
IF(IFA.NE.0) THEN |
196 |
|
if(TRKVERBOSE)then |
197 |
|
PRINT *, |
198 |
|
$ '*** ERROR in mini ***'// |
199 |
|
$ 'on matrix inversion (not pos-def)' |
200 |
|
$ ,DET |
201 |
|
endif |
202 |
|
IF(CHI2.EQ.0) CHI2=-9999. |
203 |
|
IF(CHI2.GT.0) CHI2=-CHI2 |
204 |
|
IFAIL=1 |
205 |
|
RETURN |
206 |
|
ENDIF |
207 |
|
CALL DSFINV(4,CHI2DD_R,4) |
208 |
* ******************************************* |
* ******************************************* |
209 |
|
* find new value of AL-pha |
210 |
|
* ******************************************* |
211 |
|
DO I=1,4 |
212 |
|
DAL(I)=0. |
213 |
|
DO J=1,4 |
214 |
|
DAL(I)=DAL(I)-CHI2DD_R(I,J)*CHI2D_R(J) |
215 |
|
COV(I,J)=2.*COST*CHI2DD_R(I,J) |
216 |
|
ENDDO |
217 |
|
ENDDO |
218 |
|
DAL(5)=0. |
219 |
|
DO I=1,4 |
220 |
|
AL(I)=AL(I)+DAL(I) |
221 |
|
ENDDO |
222 |
|
ENDIF |
223 |
|
|
224 |
|
if(TRKDEBUG) print*,'mini2: step ',istep,chi2,1./AL(5) |
225 |
|
|
226 |
|
*------------------------------------------------------------* |
227 |
|
* ---------------------------------------------------- * |
228 |
|
*------------------------------------------------------------* |
229 |
* check parameter bounds: |
* check parameter bounds: |
230 |
|
*------------------------------------------------------------* |
231 |
DO I=1,5 |
DO I=1,5 |
232 |
IF(AL(I).GT.ALMAX(I).OR.AL(I).LT.ALMIN(I))THEN |
IF(AL(I).GT.ALMAX(I).OR.AL(I).LT.ALMIN(I))THEN |
233 |
if(DEBUG)then |
if(TRKVERBOSE)then |
234 |
PRINT*,' **WARNING** ' |
PRINT*,' *** WARNING in mini *** ' |
235 |
PRINT*,'MINI_2 ==> AL(',I,') out of range' |
PRINT*,'MINI_2 ==> AL(',I,') out of range' |
236 |
PRINT*,' value: ',AL(I), |
PRINT*,' value: ',AL(I), |
237 |
$ ' limits: ',ALMIN(I),ALMAX(I) |
$ ' limits: ',ALMIN(I),ALMAX(I) |
238 |
print*,'istep ',istep |
print*,'istep ',istep |
239 |
endif |
endif |
240 |
|
IF(CHI2.EQ.0) CHI2=-9999. |
241 |
|
IF(CHI2.GT.0) CHI2=-CHI2 |
242 |
IFAIL=1 |
IFAIL=1 |
243 |
RETURN |
RETURN |
244 |
ENDIF |
ENDIF |
245 |
ENDDO |
ENDDO |
246 |
* new estimate of chi^2: |
*------------------------------------------------------------* |
|
JFAIL=0 !error flag |
|
|
CALL CHISQ(IFLAG,JFAIL) !chi^2 and its derivatives |
|
|
IF(JFAIL.NE.0) THEN |
|
|
IFAIL=1 |
|
|
if(DEBUG) |
|
|
$ PRINT *,'mini_2: ===> error on CHISQ computation !!!' |
|
|
RETURN |
|
|
ENDIF |
|
247 |
* check number of steps: |
* check number of steps: |
248 |
IF(ISTEP.gt.ISTEPMAX) then |
*------------------------------------------------------------* |
249 |
|
IF(ISTEP.ge.ISTEPMAX) then |
250 |
IFAIL=1 |
IFAIL=1 |
251 |
if(DEBUG) |
if(TRKVERBOSE) |
252 |
$ PRINT *,'mini_2: WARNING ===> ISTEP.GT.ISTEPMAX=',ISTEPMAX |
$ PRINT *,'*** WARNING in mini *** ISTEP.GT.ISTEPMAX=', |
253 |
|
$ ISTEPMAX |
254 |
goto 11 |
goto 11 |
255 |
endif |
endif |
256 |
|
*------------------------------------------------------------* |
257 |
* --------------------------------------------- |
* --------------------------------------------- |
258 |
* evaluate deflection tolerance on the basis of |
* evaluate deflection tolerance on the basis of |
259 |
* estimated deflection |
* estimated deflection |
260 |
* --------------------------------------------- |
* --------------------------------------------- |
261 |
ALTOL(5)=DSQRT(DELETA1**2+DELETA2**2*AL(5)**2)/FACT |
*------------------------------------------------------------* |
262 |
|
c$$$ ALTOL(5) = DSQRT(DELETA1**2+DELETA2**2*AL(5)**2)/FACT |
263 |
|
ALTOL(5) = DSQRT((DELETA1*AVRESX)**2+DELETA2**2*AL(5)**2)/FACT |
264 |
|
ALTOL(1) = ALTOL(5)/DELETA1 |
265 |
|
ALTOL(2) = ALTOL(1) |
266 |
|
ALTOL(3) = DSQRT(ALTOL(1)**2+ALTOL(2)**2)/44.51 |
267 |
|
ALTOL(4) = ALTOL(3) |
268 |
|
|
269 |
*---- check tolerances: |
*---- check tolerances: |
270 |
|
c$$$ DO I=1,5 |
271 |
|
c$$$ if(TRKVERBOSE)print*,i,' -- ',DAL(I),ALTOL(I) !>>>> new step! |
272 |
|
c$$$ ENDDO |
273 |
|
c$$$ print*,'chi2 -- ',DCHI2 |
274 |
|
|
275 |
DO I=1,5 |
DO I=1,5 |
276 |
IF(ABS(DAL(I)).GT.ALTOL(I))GOTO 10 !>>>> new step! |
IF(ABS(DAL(I)).GT.ALTOL(I))GOTO 10 !>>>> new step! |
277 |
ENDDO |
ENDDO |
278 |
|
|
279 |
|
* new estimate of chi^2: |
280 |
|
JFAIL=0 !error flag |
281 |
|
CALL CHISQ(IFLAG,JFAIL) !chi^2 and its derivatives |
282 |
|
IF(JFAIL.NE.0) THEN |
283 |
|
IFAIL=1 |
284 |
|
if(TRKVERBOSE)THEN |
285 |
|
CHI2=-9999. |
286 |
|
if(TRKVERBOSE) |
287 |
|
$ PRINT *,'*** ERROR in mini *** wrong CHISQ' |
288 |
|
ENDIF |
289 |
|
RETURN |
290 |
|
ENDIF |
291 |
|
COST=1e-7 |
292 |
|
DO I=1,5 |
293 |
|
DO J=1,5 |
294 |
|
CHI2DD(I,J)=CHI2DD(I,J)*COST |
295 |
|
ENDDO |
296 |
|
CHI2D(I)=CHI2D(I)*COST |
297 |
|
ENDDO |
298 |
|
IF(PFIXED.EQ.0.) THEN |
299 |
|
CALL DSFACT(5,CHI2DD,5,IFA,DET,JFA) !CHI2DD matrix determinant |
300 |
|
IF(IFA.NE.0) THEN !not positive-defined |
301 |
|
if(TRKVERBOSE)then |
302 |
|
PRINT *, |
303 |
|
$ '*** ERROR in mini ***'// |
304 |
|
$ 'on matrix inversion (not pos-def)' |
305 |
|
$ ,DET |
306 |
|
endif |
307 |
|
IF(CHI2.EQ.0) CHI2=-9999. |
308 |
|
IF(CHI2.GT.0) CHI2=-CHI2 |
309 |
|
IFAIL=1 |
310 |
|
RETURN |
311 |
|
ENDIF |
312 |
|
CALL DSFINV(5,CHI2DD,5) !CHI2DD matrix inversion |
313 |
|
DO I=1,5 |
314 |
|
DAL(I)=0. |
315 |
|
DO J=1,5 |
316 |
|
COV(I,J)=2.*COST*CHI2DD(I,J) |
317 |
|
ENDDO |
318 |
|
ENDDO |
319 |
|
ELSE |
320 |
|
DO I=1,4 |
321 |
|
CHI2D_R(I)=CHI2D(I) |
322 |
|
DO J=1,4 |
323 |
|
CHI2DD_R(I,J)=CHI2DD(I,J) |
324 |
|
ENDDO |
325 |
|
ENDDO |
326 |
|
CALL DSFACT(4,CHI2DD_R,4,IFA,DET,JFA) |
327 |
|
IF(IFA.NE.0) THEN |
328 |
|
if(TRKVERBOSE)then |
329 |
|
PRINT *, |
330 |
|
$ '*** ERROR in mini ***'// |
331 |
|
$ 'on matrix inversion (not pos-def)' |
332 |
|
$ ,DET |
333 |
|
endif |
334 |
|
IF(CHI2.EQ.0) CHI2=-9999. |
335 |
|
IF(CHI2.GT.0) CHI2=-CHI2 |
336 |
|
IFAIL=1 |
337 |
|
RETURN |
338 |
|
ENDIF |
339 |
|
CALL DSFINV(4,CHI2DD_R,4) |
340 |
|
DO I=1,4 |
341 |
|
DAL(I)=0. |
342 |
|
DO J=1,4 |
343 |
|
COV(I,J)=2.*COST*CHI2DD_R(I,J) |
344 |
|
ENDDO |
345 |
|
ENDDO |
346 |
|
ENDIF |
347 |
|
***************************** |
348 |
|
|
349 |
* ------------------------------------ |
* ------------------------------------ |
350 |
* Number of Degree Of Freedom |
* Number of Degree Of Freedom |
354 |
$ +int(xgood(ip)) |
$ +int(xgood(ip)) |
355 |
$ +int(ygood(ip)) |
$ +int(ygood(ip)) |
356 |
enddo |
enddo |
357 |
ndof=ndof-5 |
if(pfixed.eq.0.) ndof=ndof-5 ! ***PP*** |
358 |
|
if(pfixed.ne.0.) ndof=ndof-4 ! ***PP*** |
359 |
|
if(ndof.le.0.) then |
360 |
|
ndof = 1 |
361 |
|
if(TRKVERBOSE) |
362 |
|
$ print*,'*** WARNING *** in mini n.dof = 0 (set to 1)' |
363 |
|
endif |
364 |
|
|
365 |
|
if(TRKDEBUG) print*,'mini2: -ok- ',istep,chi2,1./AL(5) |
366 |
|
|
367 |
* ------------------------------------ |
* ------------------------------------ |
368 |
* Reduced chi^2 |
* Reduced chi^2 |
369 |
CHI2 = CHI2/dble(ndof) |
CHI2 = CHI2/dble(ndof) |
370 |
|
|
371 |
|
c print*,'mini2: chi2 ',chi2 |
|
11 CONTINUE |
|
372 |
|
|
373 |
101 CONTINUE |
11 CONTINUE |
374 |
|
|
375 |
c print*,'END MINI' |
NSTEP=ISTEP ! ***PP*** |
376 |
|
|
377 |
RETURN |
RETURN |
378 |
END |
END |
399 |
DIMENSION XV2(nplanes),YV2(nplanes),XV1(nplanes),YV1(nplanes) |
DIMENSION XV2(nplanes),YV2(nplanes),XV1(nplanes),YV1(nplanes) |
400 |
$ ,XV0(nplanes),YV0(nplanes) |
$ ,XV0(nplanes),YV0(nplanes) |
401 |
DIMENSION AL_P(5) |
DIMENSION AL_P(5) |
402 |
|
|
403 |
|
c LOGICAL TRKVERBOSE |
404 |
|
c COMMON/TRKD/TRKVERBOSE |
405 |
|
LOGICAL TRKDEBUG,TRKVERBOSE |
406 |
|
COMMON/TRKD/TRKDEBUG,TRKVERBOSE |
407 |
* |
* |
408 |
* chi^2 computation |
* chi^2 computation |
409 |
* |
* |
413 |
JFAIL=0 !error flag |
JFAIL=0 !error flag |
414 |
CALL POSXYZ(AL_P,JFAIL) !track intersection with tracking planes |
CALL POSXYZ(AL_P,JFAIL) !track intersection with tracking planes |
415 |
IF(JFAIL.NE.0) THEN |
IF(JFAIL.NE.0) THEN |
416 |
PRINT *,'CHISQ ==> error from tracking routine POSXYZ !!' |
IF(TRKVERBOSE) |
417 |
|
$ PRINT *,'CHISQ ==> error from trk routine POSXYZ !!' |
418 |
IFAIL=1 |
IFAIL=1 |
419 |
RETURN |
RETURN |
420 |
ENDIF |
ENDIF |
485 |
JFAIL=0 |
JFAIL=0 |
486 |
CALL POSXYZ(AL_P,JFAIL) |
CALL POSXYZ(AL_P,JFAIL) |
487 |
IF(JFAIL.NE.0) THEN |
IF(JFAIL.NE.0) THEN |
488 |
PRINT *,'CHISQ ==> error from tracking routine POSXYZ !!' |
IF(TRKVERBOSE) |
489 |
|
*23456789012345678901234567890123456789012345678901234567890123456789012 |
490 |
|
$ PRINT *,'CHISQ ==> error from trk routine POSXYZ' |
491 |
IFAIL=1 |
IFAIL=1 |
492 |
RETURN |
RETURN |
493 |
ENDIF |
ENDIF |
499 |
JFAIL=0 |
JFAIL=0 |
500 |
CALL POSXYZ(AL_P,JFAIL) |
CALL POSXYZ(AL_P,JFAIL) |
501 |
IF(JFAIL.NE.0) THEN |
IF(JFAIL.NE.0) THEN |
502 |
PRINT *,'CHISQ ==> error from tracking routine POSXYZ !!' |
IF(TRKVERBOSE) |
503 |
|
$ PRINT *,'CHISQ ==> error from trk routine POSXYZ' |
504 |
IFAIL=1 |
IFAIL=1 |
505 |
RETURN |
RETURN |
506 |
ENDIF |
ENDIF |
531 |
|
|
532 |
COSTHE=DSQRT(1.-AL(3)**2) |
COSTHE=DSQRT(1.-AL(3)**2) |
533 |
IF(COSTHE.EQ.0.) THEN |
IF(COSTHE.EQ.0.) THEN |
534 |
PRINT *,'=== WARNING ===> COSTHE=0' |
IF(TRKVERBOSE)PRINT *,'=== WARNING ===> COSTHE=0' |
535 |
STOP |
IFAIL=1 |
536 |
|
RETURN |
537 |
ENDIF |
ENDIF |
538 |
|
|
539 |
DXDAL(I,3)=(ZINI-ZM(I))*DCOS(AL(4))/COSTHE**3 |
DXDAL(I,3)=(ZINI-ZM(I))*DCOS(AL(4))/COSTHE**3 |
617 |
|
|
618 |
include 'commontracker.f' !tracker general common |
include 'commontracker.f' !tracker general common |
619 |
include 'common_mini_2.f' !common for the tracking procedure |
include 'common_mini_2.f' !common for the tracking procedure |
620 |
|
|
621 |
|
c LOGICAL TRKVERBOSE |
622 |
|
c COMMON/TRKD/TRKVERBOSE |
623 |
|
LOGICAL TRKDEBUG,TRKVERBOSE |
624 |
|
COMMON/TRKD/TRKDEBUG,TRKVERBOSE |
625 |
c |
c |
626 |
DIMENSION AL_P(5) |
DIMENSION AL_P(5) |
627 |
* |
* |
651 |
CALL GRKUTA(CHARGE,STEP,VECT,VOUT) |
CALL GRKUTA(CHARGE,STEP,VECT,VOUT) |
652 |
IF(VOUT(3).GT.VECT(3)) THEN |
IF(VOUT(3).GT.VECT(3)) THEN |
653 |
IFAIL=1 |
IFAIL=1 |
654 |
if(WARNING) |
if(TRKVERBOSE) |
655 |
$ PRINT *,'posxy (grkuta): WARNING ===> backward track!!' |
$ PRINT *,'posxy (grkuta): WARNING ===> backward track!!' |
656 |
if(WARNING)print*,'charge',charge |
c$$$ if(.TRUE.)print*,'charge',charge |
657 |
if(WARNING)print*,'vect',vect |
c$$$ if(.TRUE.)print*,'vect',vect |
658 |
if(WARNING)print*,'vout',vout |
c$$$ if(.TRUE.)print*,'vout',vout |
659 |
if(WARNING)print*,'step',step |
c$$$ if(.TRUE.)print*,'step',step |
660 |
|
if(TRKVERBOSE)print*,'charge',charge |
661 |
|
if(TRKVERBOSE)print*,'vect',vect |
662 |
|
if(TRKVERBOSE)print*,'vout',vout |
663 |
|
if(TRKVERBOSE)print*,'step',step |
664 |
RETURN |
RETURN |
665 |
ENDIF |
ENDIF |
666 |
Z=VOUT(3) |
Z=VOUT(3) |
729 |
|
|
730 |
return |
return |
731 |
end |
end |
732 |
|
|
733 |
|
|
734 |
|
*************************************************** |
735 |
|
* * |
736 |
|
* * |
737 |
|
* * |
738 |
|
* * |
739 |
|
* * |
740 |
|
* * |
741 |
|
************************************************** |
742 |
|
|
743 |
|
subroutine guess() |
744 |
|
|
745 |
|
c IMPLICIT DOUBLE PRECISION (A-H,O-Z) |
746 |
|
|
747 |
|
include 'commontracker.f' !tracker general common |
748 |
|
include 'common_mini_2.f' !common for the tracking procedure |
749 |
|
|
750 |
|
REAL*4 XP(NPLANES),ZP(NPLANES),AP(NPLANES),RP(NPLANES) |
751 |
|
REAL*4 CHI,XC,ZC,RADIUS |
752 |
|
* ---------------------------------------- |
753 |
|
* Y view |
754 |
|
* ---------------------------------------- |
755 |
|
* ---------------------------------------- |
756 |
|
* initial guess with a straigth line |
757 |
|
* ---------------------------------------- |
758 |
|
SZZ=0. |
759 |
|
SZY=0. |
760 |
|
SSY=0. |
761 |
|
SZ=0. |
762 |
|
S1=0. |
763 |
|
DO I=1,nplanes |
764 |
|
IF(YGOOD(I).EQ.1)THEN |
765 |
|
YY = YM(I) |
766 |
|
IF(XGOOD(I).EQ.0)THEN |
767 |
|
YY = (YM_A(I) + YM_B(I))/2 |
768 |
|
ENDIF |
769 |
|
SZZ=SZZ+ZM(I)*ZM(I) |
770 |
|
SZY=SZY+ZM(I)*YY |
771 |
|
SSY=SSY+YY |
772 |
|
SZ=SZ+ZM(I) |
773 |
|
S1=S1+1. |
774 |
|
ENDIF |
775 |
|
ENDDO |
776 |
|
DET=SZZ*S1-SZ*SZ |
777 |
|
AY=(SZY*S1-SZ*SSY)/DET |
778 |
|
BY=(SZZ*SSY-SZY*SZ)/DET |
779 |
|
Y0 = AY*ZINI+BY |
780 |
|
* ---------------------------------------- |
781 |
|
* X view |
782 |
|
* ---------------------------------------- |
783 |
|
* ---------------------------------------- |
784 |
|
* 1) initial guess with a circle |
785 |
|
* ---------------------------------------- |
786 |
|
NP=0 |
787 |
|
DO I=1,nplanes |
788 |
|
IF(XGOOD(I).EQ.1)THEN |
789 |
|
XX = XM(I) |
790 |
|
IF(YGOOD(I).EQ.0)THEN |
791 |
|
XX = (XM_A(I) + XM_B(I))/2 |
792 |
|
ENDIF |
793 |
|
NP=NP+1 |
794 |
|
XP(NP)=XX |
795 |
|
ZP(NP)=ZM(I) |
796 |
|
ENDIF |
797 |
|
ENDDO |
798 |
|
CALL TRICIRCLE(NP,XP,ZP,AP,RP,CHI,XC,ZC,RADIUS,IFLAG) |
799 |
|
c print*,' circle: ',XC,ZC,RADIUS,' --- ',CHI |
800 |
|
IF(IFLAG.NE.0)GOTO 10 !straigth fit |
801 |
|
ARG = RADIUS**2-(ZINI-ZC)**2 |
802 |
|
IF(ARG.LT.0)GOTO 10 !straigth fit |
803 |
|
DC = SQRT(ARG) |
804 |
|
IF(XC.GT.0)DC=-DC |
805 |
|
X0=XC+DC |
806 |
|
AX = -(ZINI-ZC)/DC |
807 |
|
DEF=100./(RADIUS*0.3*0.43) |
808 |
|
IF(XC.GT.0)DEF=-DEF |
809 |
|
GOTO 20 !guess is ok |
810 |
|
|
811 |
|
* ---------------------------------------- |
812 |
|
* 2) initial guess with a straigth line |
813 |
|
* - if circle does not intersect reference plane |
814 |
|
* - if bad chi**2 |
815 |
|
* ---------------------------------------- |
816 |
|
10 CONTINUE |
817 |
|
SZZ=0. |
818 |
|
SZX=0. |
819 |
|
SSX=0. |
820 |
|
SZ=0. |
821 |
|
S1=0. |
822 |
|
DO I=1,nplanes |
823 |
|
IF(XGOOD(I).EQ.1)THEN |
824 |
|
XX = XM(I) |
825 |
|
IF(YGOOD(I).EQ.0)THEN |
826 |
|
XX = (XM_A(I) + XM_B(I))/2 |
827 |
|
ENDIF |
828 |
|
SZZ=SZZ+ZM(I)*ZM(I) |
829 |
|
SZX=SZX+ZM(I)*XX |
830 |
|
SSX=SSX+XX |
831 |
|
SZ=SZ+ZM(I) |
832 |
|
S1=S1+1. |
833 |
|
ENDIF |
834 |
|
ENDDO |
835 |
|
DET=SZZ*S1-SZ*SZ |
836 |
|
AX=(SZX*S1-SZ*SSX)/DET |
837 |
|
BX=(SZZ*SSX-SZX*SZ)/DET |
838 |
|
DEF = 0 |
839 |
|
X0 = AX*ZINI+BX |
840 |
|
|
841 |
|
20 CONTINUE |
842 |
|
* ---------------------------------------- |
843 |
|
* guess |
844 |
|
* ---------------------------------------- |
845 |
|
|
846 |
|
AL(1) = X0 |
847 |
|
AL(2) = Y0 |
848 |
|
tath = sqrt(AY**2+AX**2) |
849 |
|
AL(3) = tath/sqrt(1+tath**2) |
850 |
|
IF(AX.NE.0)THEN |
851 |
|
AL(4)= atan(AY/AX) |
852 |
|
ELSE |
853 |
|
AL(4) = acos(-1.)/2 |
854 |
|
IF(AY.LT.0)AL(4) = AL(4)+acos(-1.) |
855 |
|
ENDIF |
856 |
|
IF(AX.LT.0)AL(4)= acos(-1.)+ AL(4) |
857 |
|
AL(4) = -acos(-1.) + AL(4) !from incidence direction to tracking rs |
858 |
|
AL(5) = DEF |
859 |
|
|
860 |
|
c print*,' guess: ',(al(i),i=1,5) |
861 |
|
|
862 |
|
end |