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 |
|
CHI2=0 |
125 |
|
|
126 |
|
if(TRKDEBUG) print*,'guess: ',al |
127 |
|
if(TRKDEBUG) print*,'mini2: step ',istep,chi2,1./AL(5) |
128 |
|
|
129 |
* |
* |
130 |
* ----------------------- |
* ----------------------- |
131 |
* START MINIMIZATION LOOP |
* START MINIMIZATION LOOP |
136 |
IF(JFAIL.NE.0) THEN |
IF(JFAIL.NE.0) THEN |
137 |
IFAIL=1 |
IFAIL=1 |
138 |
CHI2=-9999. |
CHI2=-9999. |
139 |
if(TRKDEBUG) |
if(TRKVERBOSE) |
140 |
$ PRINT *,'*** ERROR in mini *** wrong CHISQ' |
$ PRINT *,'*** ERROR in mini *** wrong CHISQ' |
141 |
RETURN |
RETURN |
142 |
ENDIF |
ENDIF |
143 |
|
|
144 |
* CHI2_P=CHI2 |
COST=1e-5 |
|
|
|
|
c print*,'@@@@@ ',istep,' - ',al |
|
|
|
|
|
COST=1e-7 |
|
145 |
DO I=1,5 |
DO I=1,5 |
146 |
DO J=1,5 |
DO J=1,5 |
147 |
CHI2DD(I,J)=CHI2DD(I,J)*COST |
CHI2DD(I,J)=CHI2DD(I,J)*COST |
156 |
*------------------------------------------------------------* |
*------------------------------------------------------------* |
157 |
CALL DSFACT(5,CHI2DD,5,IFA,DET,JFA) !CHI2DD matrix determinant |
CALL DSFACT(5,CHI2DD,5,IFA,DET,JFA) !CHI2DD matrix determinant |
158 |
IF(IFA.NE.0) THEN !not positive-defined |
IF(IFA.NE.0) THEN !not positive-defined |
159 |
if(TRKDEBUG)then |
if(TRKVERBOSE)then |
160 |
PRINT *, |
PRINT *, |
161 |
$ '*** ERROR in mini ***'// |
$ '*** ERROR in mini ***'// |
162 |
$ 'on matrix inversion (not pos-def)' |
$ 'on matrix inversion (not pos-def)' |
170 |
CALL DSFINV(5,CHI2DD,5) !CHI2DD matrix inversion |
CALL DSFINV(5,CHI2DD,5) !CHI2DD matrix inversion |
171 |
* ******************************************* |
* ******************************************* |
172 |
* find new value of AL-pha |
* find new value of AL-pha |
173 |
* |
* ******************************************* |
174 |
DO I=1,5 |
DO I=1,5 |
175 |
DAL(I)=0. |
DAL(I)=0. |
176 |
DO J=1,5 |
DO J=1,5 |
194 |
ENDDO |
ENDDO |
195 |
CALL DSFACT(4,CHI2DD_R,4,IFA,DET,JFA) |
CALL DSFACT(4,CHI2DD_R,4,IFA,DET,JFA) |
196 |
IF(IFA.NE.0) THEN |
IF(IFA.NE.0) THEN |
197 |
if(TRKDEBUG)then |
if(TRKVERBOSE)then |
198 |
PRINT *, |
PRINT *, |
199 |
$ '*** ERROR in mini ***'// |
$ '*** ERROR in mini ***'// |
200 |
$ 'on matrix inversion (not pos-def)' |
$ 'on matrix inversion (not pos-def)' |
206 |
RETURN |
RETURN |
207 |
ENDIF |
ENDIF |
208 |
CALL DSFINV(4,CHI2DD_R,4) |
CALL DSFINV(4,CHI2DD_R,4) |
209 |
|
* ******************************************* |
210 |
|
* find new value of AL-pha |
211 |
|
* ******************************************* |
212 |
DO I=1,4 |
DO I=1,4 |
213 |
DAL(I)=0. |
DAL(I)=0. |
214 |
DO J=1,4 |
DO J=1,4 |
221 |
AL(I)=AL(I)+DAL(I) |
AL(I)=AL(I)+DAL(I) |
222 |
ENDDO |
ENDDO |
223 |
ENDIF |
ENDIF |
224 |
|
|
225 |
|
if(TRKDEBUG) print*,'mini2: step ',istep,chi2,1./AL(5) |
226 |
|
|
227 |
*------------------------------------------------------------* |
*------------------------------------------------------------* |
228 |
* ---------------------------------------------------- * |
* ---------------------------------------------------- * |
229 |
*------------------------------------------------------------* |
*------------------------------------------------------------* |
|
* ******************************************* |
|
230 |
* check parameter bounds: |
* check parameter bounds: |
231 |
|
*------------------------------------------------------------* |
232 |
DO I=1,5 |
DO I=1,5 |
233 |
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 |
234 |
if(TRKDEBUG)then |
if(TRKVERBOSE)then |
235 |
PRINT*,' *** WARNING in mini *** ' |
PRINT*,' *** WARNING in mini *** ' |
236 |
PRINT*,'MINI_2 ==> AL(',I,') out of range' |
PRINT*,'MINI_2 ==> AL(',I,') out of range' |
237 |
PRINT*,' value: ',AL(I), |
PRINT*,' value: ',AL(I), |
244 |
RETURN |
RETURN |
245 |
ENDIF |
ENDIF |
246 |
ENDDO |
ENDDO |
247 |
|
*------------------------------------------------------------* |
248 |
* check number of steps: |
* check number of steps: |
249 |
IF(ISTEP.gt.ISTEPMAX) then |
*------------------------------------------------------------* |
250 |
IFAIL=1 |
IF(ISTEP.ge.ISTEPMAX) then |
251 |
if(TRKDEBUG) |
c$$$ IFAIL=1 |
252 |
$ PRINT *,'*** WARNING in mini *** ISTEP.GT.ISTEPMAX=', |
c$$$ if(TRKVERBOSE) |
253 |
$ ISTEPMAX |
c$$$ $ PRINT *,'*** WARNING in mini *** ISTEP.GT.ISTEPMAX=', |
254 |
|
c$$$ $ ISTEPMAX |
255 |
goto 11 |
goto 11 |
256 |
endif |
endif |
257 |
|
*------------------------------------------------------------* |
258 |
* --------------------------------------------- |
* --------------------------------------------- |
259 |
* evaluate deflection tolerance on the basis of |
* evaluate deflection tolerance on the basis of |
260 |
* estimated deflection |
* estimated deflection |
261 |
* --------------------------------------------- |
* --------------------------------------------- |
262 |
ALTOL(5)=DSQRT(DELETA1**2+DELETA2**2*AL(5)**2)/FACT |
*------------------------------------------------------------* |
263 |
|
c$$$ ALTOL(5) = DSQRT(DELETA1**2+DELETA2**2*AL(5)**2)/FACT |
264 |
|
ALTOL(5) = DSQRT((DELETA1*AVRESX)**2+DELETA2**2*AL(5)**2)/FACT |
265 |
|
ALTOL(1) = ALTOL(5)/DELETA1 |
266 |
|
ALTOL(2) = ALTOL(1) |
267 |
|
ALTOL(3) = DSQRT(ALTOL(1)**2+ALTOL(2)**2)/44.51 |
268 |
|
ALTOL(4) = ALTOL(3) |
269 |
|
|
270 |
*---- check tolerances: |
*---- check tolerances: |
271 |
|
c$$$ DO I=1,5 |
272 |
|
c$$$ if(TRKVERBOSE)print*,i,' -- ',DAL(I),ALTOL(I) !>>>> new step! |
273 |
|
c$$$ ENDDO |
274 |
|
c$$$ print*,'chi2 -- ',DCHI2 |
275 |
|
|
276 |
|
IF(ISTEP.LT.3) GOTO 10 ! ***PP*** |
277 |
DO I=1,5 |
DO I=1,5 |
278 |
IF(ABS(DAL(I)).GT.ALTOL(I))GOTO 10 !>>>> new step! |
IF(ABS(DAL(I)).GT.ALTOL(I))GOTO 10 !>>>> new step! |
279 |
ENDDO |
ENDDO |
283 |
CALL CHISQ(IFLAG,JFAIL) !chi^2 and its derivatives |
CALL CHISQ(IFLAG,JFAIL) !chi^2 and its derivatives |
284 |
IF(JFAIL.NE.0) THEN |
IF(JFAIL.NE.0) THEN |
285 |
IFAIL=1 |
IFAIL=1 |
286 |
if(TRKDEBUG)THEN |
if(TRKVERBOSE)THEN |
287 |
CHI2=-9999. |
CHI2=-9999. |
288 |
if(TRKDEBUG) |
if(TRKVERBOSE) |
289 |
$ PRINT *,'*** ERROR in mini *** wrong CHISQ' |
$ PRINT *,'*** ERROR in mini *** wrong CHISQ' |
290 |
ENDIF |
ENDIF |
291 |
RETURN |
RETURN |
300 |
IF(PFIXED.EQ.0.) THEN |
IF(PFIXED.EQ.0.) THEN |
301 |
CALL DSFACT(5,CHI2DD,5,IFA,DET,JFA) !CHI2DD matrix determinant |
CALL DSFACT(5,CHI2DD,5,IFA,DET,JFA) !CHI2DD matrix determinant |
302 |
IF(IFA.NE.0) THEN !not positive-defined |
IF(IFA.NE.0) THEN !not positive-defined |
303 |
if(TRKDEBUG)then |
if(TRKVERBOSE)then |
304 |
PRINT *, |
PRINT *, |
305 |
$ '*** ERROR in mini ***'// |
$ '*** ERROR in mini ***'// |
306 |
$ 'on matrix inversion (not pos-def)' |
$ 'on matrix inversion (not pos-def)' |
327 |
ENDDO |
ENDDO |
328 |
CALL DSFACT(4,CHI2DD_R,4,IFA,DET,JFA) |
CALL DSFACT(4,CHI2DD_R,4,IFA,DET,JFA) |
329 |
IF(IFA.NE.0) THEN |
IF(IFA.NE.0) THEN |
330 |
if(TRKDEBUG)then |
if(TRKVERBOSE)then |
331 |
PRINT *, |
PRINT *, |
332 |
$ '*** ERROR in mini ***'// |
$ '*** ERROR in mini ***'// |
333 |
$ 'on matrix inversion (not pos-def)' |
$ 'on matrix inversion (not pos-def)' |
360 |
if(pfixed.ne.0.) ndof=ndof-4 ! ***PP*** |
if(pfixed.ne.0.) ndof=ndof-4 ! ***PP*** |
361 |
if(ndof.le.0.) then |
if(ndof.le.0.) then |
362 |
ndof = 1 |
ndof = 1 |
363 |
if(TRKDEBUG) |
if(TRKVERBOSE) |
364 |
$ print*,'*** WARNING *** in mini n.dof = 0 (set to 1)' |
$ print*,'*** WARNING *** in mini n.dof = 0 (set to 1)' |
365 |
endif |
endif |
366 |
|
|
367 |
|
if(TRKDEBUG) print*,'mini2: -ok- ',istep,chi2,1./AL(5) |
368 |
|
|
369 |
* ------------------------------------ |
* ------------------------------------ |
370 |
* Reduced chi^2 |
* Reduced chi^2 |
371 |
CHI2 = CHI2/dble(ndof) |
CHI2 = CHI2/dble(ndof) |
372 |
|
|
373 |
|
c print*,'mini2: chi2 ',chi2 |
374 |
|
|
375 |
11 CONTINUE |
11 CONTINUE |
376 |
|
|
377 |
NSTEP=ISTEP ! ***PP*** |
NSTEP=ISTEP ! ***PP*** |
402 |
$ ,XV0(nplanes),YV0(nplanes) |
$ ,XV0(nplanes),YV0(nplanes) |
403 |
DIMENSION AL_P(5) |
DIMENSION AL_P(5) |
404 |
|
|
405 |
LOGICAL TRKDEBUG |
c LOGICAL TRKVERBOSE |
406 |
COMMON/TRKD/TRKDEBUG |
c COMMON/TRKD/TRKVERBOSE |
407 |
|
LOGICAL TRKDEBUG,TRKVERBOSE |
408 |
|
COMMON/TRKD/TRKDEBUG,TRKVERBOSE |
409 |
* |
* |
410 |
* chi^2 computation |
* chi^2 computation |
411 |
* |
* |
415 |
JFAIL=0 !error flag |
JFAIL=0 !error flag |
416 |
CALL POSXYZ(AL_P,JFAIL) !track intersection with tracking planes |
CALL POSXYZ(AL_P,JFAIL) !track intersection with tracking planes |
417 |
IF(JFAIL.NE.0) THEN |
IF(JFAIL.NE.0) THEN |
418 |
IF(TRKDEBUG) |
IF(TRKVERBOSE) |
419 |
$ PRINT *,'CHISQ ==> error from trk routine POSXYZ !!' |
$ PRINT *,'CHISQ ==> error from trk routine POSXYZ !!' |
420 |
IFAIL=1 |
IFAIL=1 |
421 |
RETURN |
RETURN |
468 |
+ *( XGOOD(I)*(1-YGOOD(I)) ) |
+ *( XGOOD(I)*(1-YGOOD(I)) ) |
469 |
+ +((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 |
470 |
+ *( (1-XGOOD(I))*YGOOD(I) ) |
+ *( (1-XGOOD(I))*YGOOD(I) ) |
471 |
|
c$$$ print*,(XV(I)-XM(I))**2/RESX(i)**2 *( XGOOD(I)*YGOOD(I) ) |
472 |
|
c$$$ print*,(YV(I)-YM(I))**2/RESY(i)**2 *( YGOOD(I)*XGOOD(I) ) |
473 |
|
c$$$ print*,((XV(I)-XM(I))**2+(YV(I)-YM(I))**2)/RESX(i)**2 |
474 |
|
c$$$ + *( XGOOD(I)*(1-YGOOD(I)) ) |
475 |
|
c$$$ print*,((XV(I)-XM(I))**2+(YV(I)-YM(I))**2)/RESY(i)**2 |
476 |
|
c$$$ + *( (1-XGOOD(I))*YGOOD(I) ) |
477 |
|
c$$$ print*,XV(I),XM(I),XGOOD(I) |
478 |
|
c$$$ print*,YV(I),YM(I),YGOOD(I) |
479 |
ENDDO |
ENDDO |
480 |
|
c$$$ print*,'CHISQ ',chi2 |
481 |
* ------------------------------------------------ |
* ------------------------------------------------ |
482 |
* |
* |
483 |
* calculation of derivatives (dX/dAL_fa and dY/dAL_fa) |
* calculation of derivatives (dX/dAL_fa and dY/dAL_fa) |
496 |
JFAIL=0 |
JFAIL=0 |
497 |
CALL POSXYZ(AL_P,JFAIL) |
CALL POSXYZ(AL_P,JFAIL) |
498 |
IF(JFAIL.NE.0) THEN |
IF(JFAIL.NE.0) THEN |
499 |
IF(TRKDEBUG) |
IF(TRKVERBOSE) |
500 |
*23456789012345678901234567890123456789012345678901234567890123456789012 |
*23456789012345678901234567890123456789012345678901234567890123456789012 |
501 |
$ PRINT *,'CHISQ ==> error from trk routine POSXYZ' |
$ PRINT *,'CHISQ ==> error from trk routine POSXYZ' |
502 |
IFAIL=1 |
IFAIL=1 |
510 |
JFAIL=0 |
JFAIL=0 |
511 |
CALL POSXYZ(AL_P,JFAIL) |
CALL POSXYZ(AL_P,JFAIL) |
512 |
IF(JFAIL.NE.0) THEN |
IF(JFAIL.NE.0) THEN |
513 |
IF(TRKDEBUG) |
IF(TRKVERBOSE) |
514 |
$ PRINT *,'CHISQ ==> error from trk routine POSXYZ' |
$ PRINT *,'CHISQ ==> error from trk routine POSXYZ' |
515 |
IFAIL=1 |
IFAIL=1 |
516 |
RETURN |
RETURN |
542 |
|
|
543 |
COSTHE=DSQRT(1.-AL(3)**2) |
COSTHE=DSQRT(1.-AL(3)**2) |
544 |
IF(COSTHE.EQ.0.) THEN |
IF(COSTHE.EQ.0.) THEN |
545 |
IF(TRKDEBUG)PRINT *,'=== WARNING ===> COSTHE=0' |
IF(TRKVERBOSE)PRINT *,'=== WARNING ===> COSTHE=0' |
546 |
IFAIL=1 |
IFAIL=1 |
547 |
RETURN |
RETURN |
548 |
ENDIF |
ENDIF |
629 |
include 'commontracker.f' !tracker general common |
include 'commontracker.f' !tracker general common |
630 |
include 'common_mini_2.f' !common for the tracking procedure |
include 'common_mini_2.f' !common for the tracking procedure |
631 |
|
|
632 |
LOGICAL TRKDEBUG |
c LOGICAL TRKVERBOSE |
633 |
COMMON/TRKD/TRKDEBUG |
c COMMON/TRKD/TRKVERBOSE |
634 |
|
LOGICAL TRKDEBUG,TRKVERBOSE |
635 |
|
COMMON/TRKD/TRKDEBUG,TRKVERBOSE |
636 |
c |
c |
637 |
DIMENSION AL_P(5) |
DIMENSION AL_P(5) |
638 |
* |
* |
652 |
VOUT(6)=-1.*DSQRT(1.-AL_P(3)**2) |
VOUT(6)=-1.*DSQRT(1.-AL_P(3)**2) |
653 |
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)) |
654 |
IF(AL_P(5).EQ.0.) VOUT(7)=1.E8 |
IF(AL_P(5).EQ.0.) VOUT(7)=1.E8 |
655 |
|
|
656 |
|
c$$$ print*,'POSXY (prima) ',vout |
657 |
|
|
658 |
DO I=1,nplanes |
DO I=1,nplanes |
659 |
step=vout(3)-zv(i) |
step=vout(3)-zv(i) |
660 |
10 DO J=1,7 |
10 DO J=1,7 |
665 |
CALL GRKUTA(CHARGE,STEP,VECT,VOUT) |
CALL GRKUTA(CHARGE,STEP,VECT,VOUT) |
666 |
IF(VOUT(3).GT.VECT(3)) THEN |
IF(VOUT(3).GT.VECT(3)) THEN |
667 |
IFAIL=1 |
IFAIL=1 |
668 |
if(TRKDEBUG) |
if(TRKVERBOSE) |
669 |
$ PRINT *,'posxy (grkuta): WARNING ===> backward track!!' |
$ PRINT *,'posxy (grkuta): WARNING ===> backward track!!' |
670 |
if(.TRUE.)print*,'charge',charge |
c$$$ if(.TRUE.)print*,'charge',charge |
671 |
if(.TRUE.)print*,'vect',vect |
c$$$ if(.TRUE.)print*,'vect',vect |
672 |
if(.TRUE.)print*,'vout',vout |
c$$$ if(.TRUE.)print*,'vout',vout |
673 |
if(.TRUE.)print*,'step',step |
c$$$ if(.TRUE.)print*,'step',step |
674 |
|
if(TRKVERBOSE)print*,'charge',charge |
675 |
|
if(TRKVERBOSE)print*,'vect',vect |
676 |
|
if(TRKVERBOSE)print*,'vout',vout |
677 |
|
if(TRKVERBOSE)print*,'step',step |
678 |
RETURN |
RETURN |
679 |
ENDIF |
ENDIF |
680 |
Z=VOUT(3) |
Z=VOUT(3) |
688 |
GOTO 11 |
GOTO 11 |
689 |
ENDIF |
ENDIF |
690 |
|
|
691 |
|
|
692 |
* ----------------------------------------------- |
* ----------------------------------------------- |
693 |
* evaluate track coordinates |
* evaluate track coordinates |
694 |
100 XV(I)=VOUT(1) |
100 XV(I)=VOUT(1) |
698 |
AYV(I)=DATAN(VOUT(5)/VOUT(6))*180./ACOS(-1.) |
AYV(I)=DATAN(VOUT(5)/VOUT(6))*180./ACOS(-1.) |
699 |
* ----------------------------------------------- |
* ----------------------------------------------- |
700 |
|
|
701 |
|
IF(TRACKMODE.EQ.1) THEN |
702 |
|
* ----------------------------------------------- |
703 |
|
* change of energy by bremsstrahlung for electrons |
704 |
|
VOUT(7) = VOUT(7) * 0.997 !0.9968 |
705 |
|
* ----------------------------------------------- |
706 |
|
ENDIF |
707 |
|
|
708 |
ENDDO |
ENDDO |
709 |
|
|
710 |
|
c$$$ print*,'POSXY (dopo) ',vout |
711 |
|
|
712 |
|
|
713 |
RETURN |
RETURN |
714 |
END |
END |
715 |
|
|
754 |
|
|
755 |
return |
return |
756 |
end |
end |
757 |
|
|
758 |
|
|
759 |
|
*************************************************** |
760 |
|
* * |
761 |
|
* * |
762 |
|
* * |
763 |
|
* * |
764 |
|
* * |
765 |
|
* * |
766 |
|
************************************************** |
767 |
|
|
768 |
|
subroutine guess() |
769 |
|
|
770 |
|
c IMPLICIT DOUBLE PRECISION (A-H,O-Z) |
771 |
|
|
772 |
|
include 'commontracker.f' !tracker general common |
773 |
|
include 'common_mini_2.f' !common for the tracking procedure |
774 |
|
|
775 |
|
REAL*4 XP(NPLANES),ZP(NPLANES),AP(NPLANES),RP(NPLANES) |
776 |
|
REAL*4 CHI,XC,ZC,RADIUS |
777 |
|
* ---------------------------------------- |
778 |
|
* Y view |
779 |
|
* ---------------------------------------- |
780 |
|
* ---------------------------------------- |
781 |
|
* initial guess with a straigth line |
782 |
|
* ---------------------------------------- |
783 |
|
SZZ=0. |
784 |
|
SZY=0. |
785 |
|
SSY=0. |
786 |
|
SZ=0. |
787 |
|
S1=0. |
788 |
|
DO I=1,nplanes |
789 |
|
IF(YGOOD(I).EQ.1)THEN |
790 |
|
YY = YM(I) |
791 |
|
IF(XGOOD(I).EQ.0)THEN |
792 |
|
YY = (YM_A(I) + YM_B(I))/2 |
793 |
|
ENDIF |
794 |
|
SZZ=SZZ+ZM(I)*ZM(I) |
795 |
|
SZY=SZY+ZM(I)*YY |
796 |
|
SSY=SSY+YY |
797 |
|
SZ=SZ+ZM(I) |
798 |
|
S1=S1+1. |
799 |
|
ENDIF |
800 |
|
ENDDO |
801 |
|
DET=SZZ*S1-SZ*SZ |
802 |
|
AY=(SZY*S1-SZ*SSY)/DET |
803 |
|
BY=(SZZ*SSY-SZY*SZ)/DET |
804 |
|
Y0 = AY*ZINI+BY |
805 |
|
* ---------------------------------------- |
806 |
|
* X view |
807 |
|
* ---------------------------------------- |
808 |
|
* ---------------------------------------- |
809 |
|
* 1) initial guess with a circle |
810 |
|
* ---------------------------------------- |
811 |
|
NP=0 |
812 |
|
DO I=1,nplanes |
813 |
|
IF(XGOOD(I).EQ.1)THEN |
814 |
|
XX = XM(I) |
815 |
|
IF(YGOOD(I).EQ.0)THEN |
816 |
|
XX = (XM_A(I) + XM_B(I))/2 |
817 |
|
ENDIF |
818 |
|
NP=NP+1 |
819 |
|
XP(NP)=XX |
820 |
|
ZP(NP)=ZM(I) |
821 |
|
ENDIF |
822 |
|
ENDDO |
823 |
|
IFLAG=0 !no debug mode |
824 |
|
CALL TRICIRCLE(NP,XP,ZP,AP,RP,CHI,XC,ZC,RADIUS,IFLAG) |
825 |
|
c print*,' circle: ',XC,ZC,RADIUS,' --- ',CHI,IFLAG |
826 |
|
IF(IFLAG.NE.0)GOTO 10 !straigth fit |
827 |
|
if(CHI.gt.100)GOTO 10 !straigth fit |
828 |
|
ARG = RADIUS**2-(ZINI-ZC)**2 |
829 |
|
IF(ARG.LT.0)GOTO 10 !straigth fit |
830 |
|
DC = SQRT(ARG) |
831 |
|
IF(XC.GT.0)DC=-DC |
832 |
|
X0=XC+DC |
833 |
|
AX = -(ZINI-ZC)/DC |
834 |
|
DEF=100./(RADIUS*0.3*0.43) |
835 |
|
IF(XC.GT.0)DEF=-DEF |
836 |
|
|
837 |
|
IF(ABS(X0).GT.30)THEN |
838 |
|
c$$$ PRINT*,'STRANGE GUESS: XC,ZC,R ',XC,ZC,RADIUS |
839 |
|
c$$$ $ ,' - CHI ',CHI,' - X0,AX,DEF ',X0,AX,DEF |
840 |
|
GOTO 10 !straigth fit |
841 |
|
ENDIF |
842 |
|
GOTO 20 !guess is ok |
843 |
|
|
844 |
|
* ---------------------------------------- |
845 |
|
* 2) initial guess with a straigth line |
846 |
|
* - if circle does not intersect reference plane |
847 |
|
* - if bad chi**2 |
848 |
|
* ---------------------------------------- |
849 |
|
10 CONTINUE |
850 |
|
SZZ=0. |
851 |
|
SZX=0. |
852 |
|
SSX=0. |
853 |
|
SZ=0. |
854 |
|
S1=0. |
855 |
|
DO I=1,nplanes |
856 |
|
IF(XGOOD(I).EQ.1)THEN |
857 |
|
XX = XM(I) |
858 |
|
IF(YGOOD(I).EQ.0)THEN |
859 |
|
XX = (XM_A(I) + XM_B(I))/2 |
860 |
|
ENDIF |
861 |
|
SZZ=SZZ+ZM(I)*ZM(I) |
862 |
|
SZX=SZX+ZM(I)*XX |
863 |
|
SSX=SSX+XX |
864 |
|
SZ=SZ+ZM(I) |
865 |
|
S1=S1+1. |
866 |
|
ENDIF |
867 |
|
ENDDO |
868 |
|
DET=SZZ*S1-SZ*SZ |
869 |
|
AX=(SZX*S1-SZ*SSX)/DET |
870 |
|
BX=(SZZ*SSX-SZX*SZ)/DET |
871 |
|
DEF = 0 |
872 |
|
X0 = AX*ZINI+BX |
873 |
|
|
874 |
|
20 CONTINUE |
875 |
|
* ---------------------------------------- |
876 |
|
* guess |
877 |
|
* ---------------------------------------- |
878 |
|
|
879 |
|
AL(1) = X0 |
880 |
|
AL(2) = Y0 |
881 |
|
tath = sqrt(AY**2+AX**2) |
882 |
|
AL(3) = tath/sqrt(1+tath**2) |
883 |
|
c$$$ IF(AX.NE.0)THEN |
884 |
|
c$$$ AL(4)= atan(AY/AX) |
885 |
|
c$$$ ELSE |
886 |
|
c$$$ AL(4) = acos(-1.)/2 |
887 |
|
c$$$ IF(AY.LT.0)AL(4) = AL(4)+acos(-1.) |
888 |
|
c$$$ ENDIF |
889 |
|
c$$$ IF(AX.LT.0)AL(4)= acos(-1.)+ AL(4) |
890 |
|
c$$$ AL(4) = -acos(-1.) + AL(4) !from incidence direction to tracking ref.sys. |
891 |
|
|
892 |
|
c$$$ AL(4) = 0. |
893 |
|
c$$$ IF(AX.NE.0.AND.AY.NE.0)THEN |
894 |
|
c$$$ AL(4)= atan(AY/AX) |
895 |
|
c$$$ ELSEIF(AY.EQ.0)THEN |
896 |
|
c$$$ AL(4) = 0. |
897 |
|
c$$$ IF(AX.LT.0)AL(4) = AL(4)+acos(-1.) |
898 |
|
c$$$ ELSEIF(AX.EQ.0)THEN |
899 |
|
c$$$ AL(4) = acos(-1.)/2 |
900 |
|
c$$$ IF(AY.LT.0)AL(4) = AL(4)+acos(-1.) |
901 |
|
c$$$ ENDIF |
902 |
|
c$$$ IF(AX.LT.0)AL(4)= acos(-1.)+ AL(4) |
903 |
|
c$$$ AL(4) = -acos(-1.) + AL(4) !from incidence direction to tracking ref.sys. |
904 |
|
|
905 |
|
c$$$ AL(4)=0. |
906 |
|
c$$$ IF( AX.NE.0.OR.AY.NE.0. ) THEN |
907 |
|
c$$$ AL(4) = ASIN(AY/SQRT(AX**2+AY**2)) |
908 |
|
c$$$ IF(AX.LT.0.) AL(4) = ACOS(-1.0)-AL(4) |
909 |
|
c$$$ ENDIF |
910 |
|
|
911 |
|
AL(4)=0. |
912 |
|
IF( AX.NE.0.OR.AY.NE.0. ) THEN |
913 |
|
AL(4) = ASIN(AY/SQRT(AX**2+AY**2)) |
914 |
|
IF(AX.LT.0.AND.AY.GE.0) AL(4) = ACOS(-1.0)-AL(4) |
915 |
|
IF(AX.LT.0.AND.AY.LT.0) AL(4) = -ACOS(-1.0)-AL(4) |
916 |
|
ENDIF |
917 |
|
IF(AY.GT.0.) AL(4) = AL(4)-ACOS(-1.0) |
918 |
|
IF(AY.LE.0.) AL(4) = AL(4)+ACOS(-1.0) |
919 |
|
|
920 |
|
AL(5) = DEF |
921 |
|
|
922 |
|
c print*,' guess: ',(al(i),i=1,5) |
923 |
|
|
924 |
|
end |