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 |
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 |
c DATA ALMAX/dinf,dinf,1.,dinf,dinf/ !limits on alpha vector components |
45 |
c DATA ALMIN/-inf,-inf,-inf,-inf,-0.25e2/ !" |
c DATA ALMIN/-dinf,-dinf,-1.,-dinf,-dinf/ !" |
46 |
DATA ALMAX/inf,inf,1.,inf,0.25e2/ !limits on alpha vector components |
DATA ALMAX/dinf,dinf,1.,dinf,dinf/ !limits on alpha vector components |
47 |
DATA ALMIN/-inf,-inf,-1.,-inf,-0.25e2/ !" |
DATA ALMIN/-dinf,-dinf,-1.,-dinf,-dinf/ !" |
|
|
|
48 |
|
|
49 |
DIMENSION DAL(5) !increment of vector alfa |
DIMENSION DAL(5) !increment of vector alfa |
50 |
DIMENSION CHI2DD_R(4,4),CHI2D_R(4) !hessiano e gradiente di chi2 |
DIMENSION CHI2DD_R(4,4),CHI2D_R(4) !hessiano e gradiente di chi2 |
51 |
|
|
52 |
|
c elena-------- |
53 |
|
REAL*8 AVRESX,AVRESY |
54 |
|
c elena-------- |
55 |
|
|
56 |
INTEGER IFLAG |
INTEGER IFLAG |
57 |
c-------------------------------------------------------- |
c-------------------------------------------------------- |
58 |
c IFLAG =1 ---- chi2 derivatives computed by using |
c IFLAG =1 ---- chi2 derivatives computed by using |
65 |
c-------------------------------------------------------- |
c-------------------------------------------------------- |
66 |
DATA IFLAG/2/ |
DATA IFLAG/2/ |
67 |
|
|
68 |
LOGICAL TRKDEBUG |
c LOGICAL TRKDEBUG,TRKVERBOSE |
69 |
COMMON/TRKD/TRKDEBUG |
c COMMON/TRKD/TRKDEBUG,TRKVERBOSE |
70 |
|
LOGICAL TRKDEBUG,TRKVERBOSE |
71 |
|
COMMON/TRKD/TRKDEBUG,TRKVERBOSE |
72 |
|
|
73 |
IF(IPRINT.EQ.1) THEN |
IF(IPRINT.EQ.1) THEN |
74 |
TRKDEBUG = .TRUE. |
TRKVERBOSE = .TRUE. |
75 |
|
TRKDEBUG = .FALSE. |
76 |
|
ELSEIF(IPRINT.EQ.2)THEN |
77 |
|
TRKVERBOSE = .TRUE. |
78 |
|
TRKDEBUG = .TRUE. |
79 |
ELSE |
ELSE |
80 |
TRKDEBUG = .FALSE. |
TRKVERBOSE = .FALSE. |
81 |
|
TRKDEBUG = .FALSE. |
82 |
ENDIF |
ENDIF |
83 |
|
|
84 |
* ---------------------------------------------------------- |
* ---------------------------------------------------------- |
85 |
|
* evaluate average spatial resolution |
86 |
|
* ---------------------------------------------------------- |
87 |
|
AVRESX = RESXAV |
88 |
|
AVRESY = RESYAV |
89 |
|
DO IP=1,6 |
90 |
|
IF( XGOOD(IP).EQ.1 )THEN |
91 |
|
NX=NX+1 |
92 |
|
AVRESX=AVRESX+RESX(IP) |
93 |
|
ENDIF |
94 |
|
IF(NX.NE.0)AVRESX=AVRESX/NX |
95 |
|
IF( YGOOD(IP).EQ.1 )THEN |
96 |
|
NY=NY+1 |
97 |
|
AVRESY=AVRESY+RESY(IP) |
98 |
|
ENDIF |
99 |
|
IF(NX.NE.0)AVRESY=AVRESY/NY |
100 |
|
ENDDO |
101 |
|
|
102 |
|
* ---------------------------------------------------------- |
103 |
* define ALTOL(5) ---> tolerances on state vector |
* define ALTOL(5) ---> tolerances on state vector |
104 |
* |
* |
105 |
* ---------------------------------------------------------- |
* ---------------------------------------------------------- |
106 |
FACT=10. !scale factor to define |
* changed in order to evaluate energy-dependent |
107 |
!tolerance on alfa |
* tolerances on all 5 parameters |
108 |
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 |
|
109 |
c deflection error (see PDG) |
c deflection error (see PDG) |
110 |
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.)) |
111 |
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) |
112 |
|
c$$$ ALTOL(1) = AVRESX/FACT !al(1) = x |
113 |
|
c$$$ ALTOL(2) = AVRESY/FACT !al(2) = y |
114 |
|
c$$$ ALTOL(3) = DSQRT(AVRESX**2 !al(3)=sin(theta) |
115 |
|
c$$$ $ +AVRESY**2)/44.51/FACT |
116 |
|
c$$$ ALTOL(4) = ALTOL(3) !al(4)=phi |
117 |
|
c deflection error (see PDG) |
118 |
|
c$$$ DELETA1 = 0.01*AVRESX/0.3/0.4/0.4451**2*SQRT(720./(6.+4.)) |
119 |
|
c$$$ DELETA2 = 0.016/0.3/0.4/0.4451*SQRT(0.4451/9.36) |
120 |
* ---------------------------------------------------------- |
* ---------------------------------------------------------- |
121 |
* |
* |
122 |
ISTEP=0 !num. steps to minimize chi^2 |
ISTEP=0 !num. steps to minimize chi^2 |
123 |
JFAIL=0 !error flag |
JFAIL=0 !error flag |
124 |
|
|
125 |
|
if(TRKDEBUG) print*,'guess: ',al |
126 |
|
if(TRKDEBUG) print*,'mini2: step ',istep,chi2,1./AL(5) |
127 |
|
|
128 |
* |
* |
129 |
* ----------------------- |
* ----------------------- |
130 |
* START MINIMIZATION LOOP |
* START MINIMIZATION LOOP |
135 |
IF(JFAIL.NE.0) THEN |
IF(JFAIL.NE.0) THEN |
136 |
IFAIL=1 |
IFAIL=1 |
137 |
CHI2=-9999. |
CHI2=-9999. |
138 |
if(TRKDEBUG) |
if(TRKVERBOSE) |
139 |
$ PRINT *,'*** ERROR in mini *** wrong CHISQ' |
$ PRINT *,'*** ERROR in mini *** wrong CHISQ' |
140 |
RETURN |
RETURN |
141 |
ENDIF |
ENDIF |
142 |
|
|
143 |
* CHI2_P=CHI2 |
COST=1e-5 |
|
|
|
|
c print*,'@@@@@ ',istep,' - ',al |
|
|
|
|
|
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 |
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(TRKDEBUG)then |
if(TRKVERBOSE)then |
159 |
PRINT *, |
PRINT *, |
160 |
$ '*** ERROR in mini ***'// |
$ '*** ERROR in mini ***'// |
161 |
$ 'on matrix inversion (not pos-def)' |
$ 'on matrix inversion (not pos-def)' |
169 |
CALL DSFINV(5,CHI2DD,5) !CHI2DD matrix inversion |
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 |
193 |
ENDDO |
ENDDO |
194 |
CALL DSFACT(4,CHI2DD_R,4,IFA,DET,JFA) |
CALL DSFACT(4,CHI2DD_R,4,IFA,DET,JFA) |
195 |
IF(IFA.NE.0) THEN |
IF(IFA.NE.0) THEN |
196 |
if(TRKDEBUG)then |
if(TRKVERBOSE)then |
197 |
PRINT *, |
PRINT *, |
198 |
$ '*** ERROR in mini ***'// |
$ '*** ERROR in mini ***'// |
199 |
$ 'on matrix inversion (not pos-def)' |
$ 'on matrix inversion (not pos-def)' |
205 |
RETURN |
RETURN |
206 |
ENDIF |
ENDIF |
207 |
CALL DSFINV(4,CHI2DD_R,4) |
CALL DSFINV(4,CHI2DD_R,4) |
208 |
|
* ******************************************* |
209 |
|
* find new value of AL-pha |
210 |
|
* ******************************************* |
211 |
DO I=1,4 |
DO I=1,4 |
212 |
DAL(I)=0. |
DAL(I)=0. |
213 |
DO J=1,4 |
DO J=1,4 |
220 |
AL(I)=AL(I)+DAL(I) |
AL(I)=AL(I)+DAL(I) |
221 |
ENDDO |
ENDDO |
222 |
ENDIF |
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(TRKDEBUG)then |
if(TRKVERBOSE)then |
234 |
PRINT*,' *** WARNING in mini *** ' |
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), |
243 |
RETURN |
RETURN |
244 |
ENDIF |
ENDIF |
245 |
ENDDO |
ENDDO |
246 |
|
*------------------------------------------------------------* |
247 |
* check number of steps: |
* check number of steps: |
248 |
IF(ISTEP.gt.ISTEPMAX) then |
*------------------------------------------------------------* |
249 |
IFAIL=1 |
IF(ISTEP.ge.ISTEPMAX) then |
250 |
if(TRKDEBUG) |
c$$$ IFAIL=1 |
251 |
$ PRINT *,'*** WARNING in mini *** ISTEP.GT.ISTEPMAX=', |
c$$$ if(TRKVERBOSE) |
252 |
$ ISTEPMAX |
c$$$ $ PRINT *,'*** WARNING in mini *** ISTEP.GT.ISTEPMAX=', |
253 |
|
c$$$ $ 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 |
281 |
CALL CHISQ(IFLAG,JFAIL) !chi^2 and its derivatives |
CALL CHISQ(IFLAG,JFAIL) !chi^2 and its derivatives |
282 |
IF(JFAIL.NE.0) THEN |
IF(JFAIL.NE.0) THEN |
283 |
IFAIL=1 |
IFAIL=1 |
284 |
if(TRKDEBUG)THEN |
if(TRKVERBOSE)THEN |
285 |
CHI2=-9999. |
CHI2=-9999. |
286 |
if(TRKDEBUG) |
if(TRKVERBOSE) |
287 |
$ PRINT *,'*** ERROR in mini *** wrong CHISQ' |
$ PRINT *,'*** ERROR in mini *** wrong CHISQ' |
288 |
ENDIF |
ENDIF |
289 |
RETURN |
RETURN |
298 |
IF(PFIXED.EQ.0.) THEN |
IF(PFIXED.EQ.0.) THEN |
299 |
CALL DSFACT(5,CHI2DD,5,IFA,DET,JFA) !CHI2DD matrix determinant |
CALL DSFACT(5,CHI2DD,5,IFA,DET,JFA) !CHI2DD matrix determinant |
300 |
IF(IFA.NE.0) THEN !not positive-defined |
IF(IFA.NE.0) THEN !not positive-defined |
301 |
if(TRKDEBUG)then |
if(TRKVERBOSE)then |
302 |
PRINT *, |
PRINT *, |
303 |
$ '*** ERROR in mini ***'// |
$ '*** ERROR in mini ***'// |
304 |
$ 'on matrix inversion (not pos-def)' |
$ 'on matrix inversion (not pos-def)' |
325 |
ENDDO |
ENDDO |
326 |
CALL DSFACT(4,CHI2DD_R,4,IFA,DET,JFA) |
CALL DSFACT(4,CHI2DD_R,4,IFA,DET,JFA) |
327 |
IF(IFA.NE.0) THEN |
IF(IFA.NE.0) THEN |
328 |
if(TRKDEBUG)then |
if(TRKVERBOSE)then |
329 |
PRINT *, |
PRINT *, |
330 |
$ '*** ERROR in mini ***'// |
$ '*** ERROR in mini ***'// |
331 |
$ 'on matrix inversion (not pos-def)' |
$ 'on matrix inversion (not pos-def)' |
358 |
if(pfixed.ne.0.) ndof=ndof-4 ! ***PP*** |
if(pfixed.ne.0.) ndof=ndof-4 ! ***PP*** |
359 |
if(ndof.le.0.) then |
if(ndof.le.0.) then |
360 |
ndof = 1 |
ndof = 1 |
361 |
if(TRKDEBUG) |
if(TRKVERBOSE) |
362 |
$ print*,'*** WARNING *** in mini n.dof = 0 (set to 1)' |
$ print*,'*** WARNING *** in mini n.dof = 0 (set to 1)' |
363 |
endif |
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 |
372 |
|
|
373 |
11 CONTINUE |
11 CONTINUE |
374 |
|
|
375 |
NSTEP=ISTEP ! ***PP*** |
NSTEP=ISTEP ! ***PP*** |
400 |
$ ,XV0(nplanes),YV0(nplanes) |
$ ,XV0(nplanes),YV0(nplanes) |
401 |
DIMENSION AL_P(5) |
DIMENSION AL_P(5) |
402 |
|
|
403 |
LOGICAL TRKDEBUG |
c LOGICAL TRKVERBOSE |
404 |
COMMON/TRKD/TRKDEBUG |
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 |
IF(TRKDEBUG) |
IF(TRKVERBOSE) |
417 |
$ PRINT *,'CHISQ ==> error from trk routine POSXYZ !!' |
$ PRINT *,'CHISQ ==> error from trk routine POSXYZ !!' |
418 |
IFAIL=1 |
IFAIL=1 |
419 |
RETURN |
RETURN |
466 |
+ *( XGOOD(I)*(1-YGOOD(I)) ) |
+ *( XGOOD(I)*(1-YGOOD(I)) ) |
467 |
+ +((XV(I)-XM(I))**2+(YV(I)-YM(I))**2)/RESY(i)**2 |
+ +((XV(I)-XM(I))**2+(YV(I)-YM(I))**2)/RESY(i)**2 |
468 |
+ *( (1-XGOOD(I))*YGOOD(I) ) |
+ *( (1-XGOOD(I))*YGOOD(I) ) |
469 |
|
c$$$ print*,(XV(I)-XM(I))**2/RESX(i)**2 *( XGOOD(I)*YGOOD(I) ) |
470 |
|
c$$$ print*,(YV(I)-YM(I))**2/RESY(i)**2 *( YGOOD(I)*XGOOD(I) ) |
471 |
|
c$$$ print*,((XV(I)-XM(I))**2+(YV(I)-YM(I))**2)/RESX(i)**2 |
472 |
|
c$$$ + *( XGOOD(I)*(1-YGOOD(I)) ) |
473 |
|
c$$$ print*,((XV(I)-XM(I))**2+(YV(I)-YM(I))**2)/RESY(i)**2 |
474 |
|
c$$$ + *( (1-XGOOD(I))*YGOOD(I) ) |
475 |
|
c$$$ print*,XV(I),XM(I),XGOOD(I) |
476 |
|
c$$$ print*,YV(I),YM(I),YGOOD(I) |
477 |
ENDDO |
ENDDO |
478 |
|
c$$$ print*,'CHISQ ',chi2 |
479 |
* ------------------------------------------------ |
* ------------------------------------------------ |
480 |
* |
* |
481 |
* calculation of derivatives (dX/dAL_fa and dY/dAL_fa) |
* calculation of derivatives (dX/dAL_fa and dY/dAL_fa) |
494 |
JFAIL=0 |
JFAIL=0 |
495 |
CALL POSXYZ(AL_P,JFAIL) |
CALL POSXYZ(AL_P,JFAIL) |
496 |
IF(JFAIL.NE.0) THEN |
IF(JFAIL.NE.0) THEN |
497 |
IF(TRKDEBUG) |
IF(TRKVERBOSE) |
498 |
*23456789012345678901234567890123456789012345678901234567890123456789012 |
*23456789012345678901234567890123456789012345678901234567890123456789012 |
499 |
$ PRINT *,'CHISQ ==> error from trk routine POSXYZ' |
$ PRINT *,'CHISQ ==> error from trk routine POSXYZ' |
500 |
IFAIL=1 |
IFAIL=1 |
508 |
JFAIL=0 |
JFAIL=0 |
509 |
CALL POSXYZ(AL_P,JFAIL) |
CALL POSXYZ(AL_P,JFAIL) |
510 |
IF(JFAIL.NE.0) THEN |
IF(JFAIL.NE.0) THEN |
511 |
IF(TRKDEBUG) |
IF(TRKVERBOSE) |
512 |
$ PRINT *,'CHISQ ==> error from trk routine POSXYZ' |
$ PRINT *,'CHISQ ==> error from trk routine POSXYZ' |
513 |
IFAIL=1 |
IFAIL=1 |
514 |
RETURN |
RETURN |
540 |
|
|
541 |
COSTHE=DSQRT(1.-AL(3)**2) |
COSTHE=DSQRT(1.-AL(3)**2) |
542 |
IF(COSTHE.EQ.0.) THEN |
IF(COSTHE.EQ.0.) THEN |
543 |
IF(TRKDEBUG)PRINT *,'=== WARNING ===> COSTHE=0' |
IF(TRKVERBOSE)PRINT *,'=== WARNING ===> COSTHE=0' |
544 |
IFAIL=1 |
IFAIL=1 |
545 |
RETURN |
RETURN |
546 |
ENDIF |
ENDIF |
627 |
include 'commontracker.f' !tracker general common |
include 'commontracker.f' !tracker general common |
628 |
include 'common_mini_2.f' !common for the tracking procedure |
include 'common_mini_2.f' !common for the tracking procedure |
629 |
|
|
630 |
LOGICAL TRKDEBUG |
c LOGICAL TRKVERBOSE |
631 |
COMMON/TRKD/TRKDEBUG |
c COMMON/TRKD/TRKVERBOSE |
632 |
|
LOGICAL TRKDEBUG,TRKVERBOSE |
633 |
|
COMMON/TRKD/TRKDEBUG,TRKVERBOSE |
634 |
c |
c |
635 |
DIMENSION AL_P(5) |
DIMENSION AL_P(5) |
636 |
* |
* |
650 |
VOUT(6)=-1.*DSQRT(1.-AL_P(3)**2) |
VOUT(6)=-1.*DSQRT(1.-AL_P(3)**2) |
651 |
IF(AL_P(5).NE.0.) VOUT(7)=DABS(1./AL_P(5)) |
IF(AL_P(5).NE.0.) VOUT(7)=DABS(1./AL_P(5)) |
652 |
IF(AL_P(5).EQ.0.) VOUT(7)=1.E8 |
IF(AL_P(5).EQ.0.) VOUT(7)=1.E8 |
653 |
|
|
654 |
|
c$$$ print*,'POSXY (prima) ',vout |
655 |
|
|
656 |
DO I=1,nplanes |
DO I=1,nplanes |
657 |
step=vout(3)-zv(i) |
step=vout(3)-zv(i) |
658 |
10 DO J=1,7 |
10 DO J=1,7 |
663 |
CALL GRKUTA(CHARGE,STEP,VECT,VOUT) |
CALL GRKUTA(CHARGE,STEP,VECT,VOUT) |
664 |
IF(VOUT(3).GT.VECT(3)) THEN |
IF(VOUT(3).GT.VECT(3)) THEN |
665 |
IFAIL=1 |
IFAIL=1 |
666 |
if(TRKDEBUG) |
if(TRKVERBOSE) |
667 |
$ PRINT *,'posxy (grkuta): WARNING ===> backward track!!' |
$ PRINT *,'posxy (grkuta): WARNING ===> backward track!!' |
668 |
if(.TRUE.)print*,'charge',charge |
c$$$ if(.TRUE.)print*,'charge',charge |
669 |
if(.TRUE.)print*,'vect',vect |
c$$$ if(.TRUE.)print*,'vect',vect |
670 |
if(.TRUE.)print*,'vout',vout |
c$$$ if(.TRUE.)print*,'vout',vout |
671 |
if(.TRUE.)print*,'step',step |
c$$$ if(.TRUE.)print*,'step',step |
672 |
|
if(TRKVERBOSE)print*,'charge',charge |
673 |
|
if(TRKVERBOSE)print*,'vect',vect |
674 |
|
if(TRKVERBOSE)print*,'vout',vout |
675 |
|
if(TRKVERBOSE)print*,'step',step |
676 |
RETURN |
RETURN |
677 |
ENDIF |
ENDIF |
678 |
Z=VOUT(3) |
Z=VOUT(3) |
686 |
GOTO 11 |
GOTO 11 |
687 |
ENDIF |
ENDIF |
688 |
|
|
689 |
|
|
690 |
* ----------------------------------------------- |
* ----------------------------------------------- |
691 |
* evaluate track coordinates |
* evaluate track coordinates |
692 |
100 XV(I)=VOUT(1) |
100 XV(I)=VOUT(1) |
698 |
|
|
699 |
ENDDO |
ENDDO |
700 |
|
|
701 |
|
c$$$ print*,'POSXY (dopo) ',vout |
702 |
|
|
703 |
|
|
704 |
RETURN |
RETURN |
705 |
END |
END |
706 |
|
|
745 |
|
|
746 |
return |
return |
747 |
end |
end |
748 |
|
|
749 |
|
|
750 |
|
*************************************************** |
751 |
|
* * |
752 |
|
* * |
753 |
|
* * |
754 |
|
* * |
755 |
|
* * |
756 |
|
* * |
757 |
|
************************************************** |
758 |
|
|
759 |
|
subroutine guess() |
760 |
|
|
761 |
|
c IMPLICIT DOUBLE PRECISION (A-H,O-Z) |
762 |
|
|
763 |
|
include 'commontracker.f' !tracker general common |
764 |
|
include 'common_mini_2.f' !common for the tracking procedure |
765 |
|
|
766 |
|
REAL*4 XP(NPLANES),ZP(NPLANES),AP(NPLANES),RP(NPLANES) |
767 |
|
REAL*4 CHI,XC,ZC,RADIUS |
768 |
|
* ---------------------------------------- |
769 |
|
* Y view |
770 |
|
* ---------------------------------------- |
771 |
|
* ---------------------------------------- |
772 |
|
* initial guess with a straigth line |
773 |
|
* ---------------------------------------- |
774 |
|
SZZ=0. |
775 |
|
SZY=0. |
776 |
|
SSY=0. |
777 |
|
SZ=0. |
778 |
|
S1=0. |
779 |
|
DO I=1,nplanes |
780 |
|
IF(YGOOD(I).EQ.1)THEN |
781 |
|
YY = YM(I) |
782 |
|
IF(XGOOD(I).EQ.0)THEN |
783 |
|
YY = (YM_A(I) + YM_B(I))/2 |
784 |
|
ENDIF |
785 |
|
SZZ=SZZ+ZM(I)*ZM(I) |
786 |
|
SZY=SZY+ZM(I)*YY |
787 |
|
SSY=SSY+YY |
788 |
|
SZ=SZ+ZM(I) |
789 |
|
S1=S1+1. |
790 |
|
ENDIF |
791 |
|
ENDDO |
792 |
|
DET=SZZ*S1-SZ*SZ |
793 |
|
AY=(SZY*S1-SZ*SSY)/DET |
794 |
|
BY=(SZZ*SSY-SZY*SZ)/DET |
795 |
|
Y0 = AY*ZINI+BY |
796 |
|
* ---------------------------------------- |
797 |
|
* X view |
798 |
|
* ---------------------------------------- |
799 |
|
* ---------------------------------------- |
800 |
|
* 1) initial guess with a circle |
801 |
|
* ---------------------------------------- |
802 |
|
NP=0 |
803 |
|
DO I=1,nplanes |
804 |
|
IF(XGOOD(I).EQ.1)THEN |
805 |
|
XX = XM(I) |
806 |
|
IF(YGOOD(I).EQ.0)THEN |
807 |
|
XX = (XM_A(I) + XM_B(I))/2 |
808 |
|
ENDIF |
809 |
|
NP=NP+1 |
810 |
|
XP(NP)=XX |
811 |
|
ZP(NP)=ZM(I) |
812 |
|
ENDIF |
813 |
|
ENDDO |
814 |
|
IFLAG=0 !no debug mode |
815 |
|
CALL TRICIRCLE(NP,XP,ZP,AP,RP,CHI,XC,ZC,RADIUS,IFLAG) |
816 |
|
c print*,' circle: ',XC,ZC,RADIUS,' --- ',CHI,IFLAG |
817 |
|
IF(IFLAG.NE.0)GOTO 10 !straigth fit |
818 |
|
if(CHI.gt.100)GOTO 10 !straigth fit |
819 |
|
ARG = RADIUS**2-(ZINI-ZC)**2 |
820 |
|
IF(ARG.LT.0)GOTO 10 !straigth fit |
821 |
|
DC = SQRT(ARG) |
822 |
|
IF(XC.GT.0)DC=-DC |
823 |
|
X0=XC+DC |
824 |
|
AX = -(ZINI-ZC)/DC |
825 |
|
DEF=100./(RADIUS*0.3*0.43) |
826 |
|
IF(XC.GT.0)DEF=-DEF |
827 |
|
|
828 |
|
IF(ABS(X0).GT.30)THEN |
829 |
|
c$$$ PRINT*,'STRANGE GUESS: XC,ZC,R ',XC,ZC,RADIUS |
830 |
|
c$$$ $ ,' - CHI ',CHI,' - X0,AX,DEF ',X0,AX,DEF |
831 |
|
GOTO 10 !straigth fit |
832 |
|
ENDIF |
833 |
|
GOTO 20 !guess is ok |
834 |
|
|
835 |
|
* ---------------------------------------- |
836 |
|
* 2) initial guess with a straigth line |
837 |
|
* - if circle does not intersect reference plane |
838 |
|
* - if bad chi**2 |
839 |
|
* ---------------------------------------- |
840 |
|
10 CONTINUE |
841 |
|
SZZ=0. |
842 |
|
SZX=0. |
843 |
|
SSX=0. |
844 |
|
SZ=0. |
845 |
|
S1=0. |
846 |
|
DO I=1,nplanes |
847 |
|
IF(XGOOD(I).EQ.1)THEN |
848 |
|
XX = XM(I) |
849 |
|
IF(YGOOD(I).EQ.0)THEN |
850 |
|
XX = (XM_A(I) + XM_B(I))/2 |
851 |
|
ENDIF |
852 |
|
SZZ=SZZ+ZM(I)*ZM(I) |
853 |
|
SZX=SZX+ZM(I)*XX |
854 |
|
SSX=SSX+XX |
855 |
|
SZ=SZ+ZM(I) |
856 |
|
S1=S1+1. |
857 |
|
ENDIF |
858 |
|
ENDDO |
859 |
|
DET=SZZ*S1-SZ*SZ |
860 |
|
AX=(SZX*S1-SZ*SSX)/DET |
861 |
|
BX=(SZZ*SSX-SZX*SZ)/DET |
862 |
|
DEF = 0 |
863 |
|
X0 = AX*ZINI+BX |
864 |
|
|
865 |
|
20 CONTINUE |
866 |
|
* ---------------------------------------- |
867 |
|
* guess |
868 |
|
* ---------------------------------------- |
869 |
|
|
870 |
|
AL(1) = X0 |
871 |
|
AL(2) = Y0 |
872 |
|
tath = sqrt(AY**2+AX**2) |
873 |
|
AL(3) = tath/sqrt(1+tath**2) |
874 |
|
c$$$ IF(AX.NE.0)THEN |
875 |
|
c$$$ AL(4)= atan(AY/AX) |
876 |
|
c$$$ ELSE |
877 |
|
c$$$ AL(4) = acos(-1.)/2 |
878 |
|
c$$$ IF(AY.LT.0)AL(4) = AL(4)+acos(-1.) |
879 |
|
c$$$ ENDIF |
880 |
|
c$$$ IF(AX.LT.0)AL(4)= acos(-1.)+ AL(4) |
881 |
|
c$$$ AL(4) = -acos(-1.) + AL(4) !from incidence direction to tracking ref.sys. |
882 |
|
|
883 |
|
c$$$ AL(4) = 0. |
884 |
|
c$$$ IF(AX.NE.0.AND.AY.NE.0)THEN |
885 |
|
c$$$ AL(4)= atan(AY/AX) |
886 |
|
c$$$ ELSEIF(AY.EQ.0)THEN |
887 |
|
c$$$ AL(4) = 0. |
888 |
|
c$$$ IF(AX.LT.0)AL(4) = AL(4)+acos(-1.) |
889 |
|
c$$$ ELSEIF(AX.EQ.0)THEN |
890 |
|
c$$$ AL(4) = acos(-1.)/2 |
891 |
|
c$$$ IF(AY.LT.0)AL(4) = AL(4)+acos(-1.) |
892 |
|
c$$$ ENDIF |
893 |
|
c$$$ IF(AX.LT.0)AL(4)= acos(-1.)+ AL(4) |
894 |
|
c$$$ AL(4) = -acos(-1.) + AL(4) !from incidence direction to tracking ref.sys. |
895 |
|
|
896 |
|
c$$$ AL(4)=0. |
897 |
|
c$$$ IF( AX.NE.0.OR.AY.NE.0. ) THEN |
898 |
|
c$$$ AL(4) = ASIN(AY/SQRT(AX**2+AY**2)) |
899 |
|
c$$$ IF(AX.LT.0.) AL(4) = ACOS(-1.0)-AL(4) |
900 |
|
c$$$ ENDIF |
901 |
|
|
902 |
|
AL(4)=0. |
903 |
|
IF( AX.NE.0.OR.AY.NE.0. ) THEN |
904 |
|
AL(4) = ASIN(AY/SQRT(AX**2+AY**2)) |
905 |
|
IF(AX.LT.0.AND.AY.GE.0) AL(4) = ACOS(-1.0)-AL(4) |
906 |
|
IF(AX.LT.0.AND.AY.LT.0) AL(4) = -ACOS(-1.0)-AL(4) |
907 |
|
ENDIF |
908 |
|
IF(AY.GT.0.) AL(4) = AL(4)-ACOS(-1.0) |
909 |
|
IF(AY.LE.0.) AL(4) = AL(4)+ACOS(-1.0) |
910 |
|
|
911 |
|
AL(5) = DEF |
912 |
|
|
913 |
|
c print*,' guess: ',(al(i),i=1,5) |
914 |
|
|
915 |
|
end |