36 |
c 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/120/ !maximum number of steps in the chi^2 minimization |
DATA ISTEPMAX/100/ !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 |
DATA ALMAX/dinf,dinf,dinf,dinf,dinf/ !limits on alpha vector components |
c DATA ALMAX/dinf,dinf,1.,dinf,dinf/ !limits on alpha vector components |
45 |
DATA ALMIN/-dinf,-dinf,-dinf,-dinf,-dinf/ !" |
c DATA ALMIN/-dinf,-dinf,-1.,-dinf,-dinf/ !" |
46 |
|
DATA ALMAX/dinf,dinf,1.,dinf,dinf/ !limits on alpha vector components |
47 |
|
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 |
105 |
* ---------------------------------------------------------- |
* ---------------------------------------------------------- |
106 |
* changed in order to evaluate energy-dependent |
* changed in order to evaluate energy-dependent |
107 |
* tolerances on all 5 parameters |
* tolerances on all 5 parameters |
108 |
FACT=100. !scale factor to define tolerance on alfa |
cPP FACT=1.0e10 !scale factor to define tolerance on alfa |
109 |
c deflection error (see PDG) |
c deflection error (see PDG) |
110 |
DELETA1 = 0.01/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) |
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 |
if(TRKDEBUG) print*,'guess: ',al |
127 |
if(TRKDEBUG) print*,'mini2: step ',istep,chi2,1./AL(5) |
if(TRKDEBUG) print*,'mini2: step ',istep,chi2,1./AL(5) |
141 |
RETURN |
RETURN |
142 |
ENDIF |
ENDIF |
143 |
|
|
144 |
COST=1e-9 |
COST=1e-5 |
|
costfac=1.1 |
|
|
flagstep=0 |
|
|
|
|
|
7 continue |
|
|
|
|
|
IF(costfac.le.1.) THEN |
|
|
IFAIL=1 |
|
|
PRINT *,'=== WARNING ===> no matrix inversion ' |
|
|
RETURN |
|
|
ENDIF |
|
|
|
|
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 |
155 |
* track fitting with FREE deflection |
* track fitting with FREE deflection |
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.or.jfa.ne.0) THEN !not positive-defined |
IF(IFA.NE.0) THEN !not positive-defined |
159 |
if(ifa.eq.-1)then |
if(TRKVERBOSE)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)' |
163 |
$ ,DET |
$ ,DET |
164 |
endif |
endif |
165 |
IF(CHI2.EQ.0) CHI2=-9999. |
IF(CHI2.EQ.0) CHI2=-9999. |
166 |
IF(CHI2.GT.0) CHI2=-CHI2 |
IF(CHI2.GT.0) CHI2=-CHI2 |
167 |
IFAIL=1 |
IFAIL=1 |
168 |
RETURN |
RETURN |
|
endif |
|
|
if(jfa.eq.-1)then |
|
|
if(flagstep.eq.-1.) costfac=(costfac-1)/2+1 |
|
|
cost=cost*costfact |
|
|
flagstep=1. |
|
|
goto 7 |
|
|
elseif(jfa.eq.1)then |
|
|
if(flagstep.eq.1.) costfac=(costfac-1)/2+1 |
|
|
cost=cost/costfac |
|
|
flagstep=-1. |
|
|
goto 7 |
|
|
endif |
|
169 |
ENDIF |
ENDIF |
170 |
CALL DSFINV(5,CHI2DD,5) !CHI2DD matrix inversion |
CALL DSFINV(5,CHI2DD,5) !CHI2DD matrix inversion |
171 |
* ******************************************* |
* ******************************************* |
248 |
* check number of steps: |
* check number of steps: |
249 |
*------------------------------------------------------------* |
*------------------------------------------------------------* |
250 |
IF(ISTEP.ge.ISTEPMAX) then |
IF(ISTEP.ge.ISTEPMAX) then |
251 |
IFAIL=1 |
c$$$ IFAIL=1 |
252 |
if(TRKVERBOSE) |
c$$$ if(TRKVERBOSE) |
253 |
$ PRINT *,'*** WARNING in mini *** ISTEP.GT.ISTEPMAX=', |
c$$$ $ PRINT *,'*** WARNING in mini *** ISTEP.GT.ISTEPMAX=', |
254 |
$ ISTEPMAX |
c$$$ $ ISTEPMAX |
255 |
goto 11 |
goto 11 |
256 |
endif |
endif |
257 |
*------------------------------------------------------------* |
*------------------------------------------------------------* |
267 |
ALTOL(3) = DSQRT(ALTOL(1)**2+ALTOL(2)**2)/44.51 |
ALTOL(3) = DSQRT(ALTOL(1)**2+ALTOL(2)**2)/44.51 |
268 |
ALTOL(4) = ALTOL(3) |
ALTOL(4) = ALTOL(3) |
269 |
|
|
270 |
|
c$$$ print*,' -- ',(DAL(I),ALTOL(I),' - ',i=1,5) !>>>> new step! |
271 |
|
|
272 |
*---- check tolerances: |
*---- check tolerances: |
273 |
c$$$ DO I=1,5 |
c$$$ DO I=1,5 |
274 |
c$$$ if(TRKVERBOSE)print*,i,' -- ',DAL(I),ALTOL(I) !>>>> new step! |
c$$$ if(TRKVERBOSE)print*,i,' -- ',DAL(I),ALTOL(I) !>>>> new step! |
275 |
c$$$ ENDDO |
c$$$ ENDDO |
276 |
c$$$ print*,'chi2 -- ',DCHI2 |
c$$$ print*,'chi2 -- ',DCHI2 |
277 |
|
|
278 |
|
IF(ISTEP.LT.ISTEPMIN) GOTO 10 ! ***PP*** |
279 |
DO I=1,5 |
DO I=1,5 |
280 |
IF(ABS(DAL(I)).GT.ALTOL(I))GOTO 10 !>>>> new step! |
IF(ABS(DAL(I)).GT.ALTOL(I))GOTO 10 !>>>> new step! |
281 |
ENDDO |
ENDDO |
366 |
$ print*,'*** WARNING *** in mini n.dof = 0 (set to 1)' |
$ print*,'*** WARNING *** in mini n.dof = 0 (set to 1)' |
367 |
endif |
endif |
368 |
|
|
|
if(TRKDEBUG) print*,'mini2: -ok- ',istep,chi2,1./AL(5) |
|
|
|
|
369 |
* ------------------------------------ |
* ------------------------------------ |
370 |
* Reduced chi^2 |
* Reduced chi^2 |
371 |
CHI2 = CHI2/dble(ndof) |
CHI2 = CHI2/dble(ndof) |
374 |
|
|
375 |
11 CONTINUE |
11 CONTINUE |
376 |
|
|
377 |
|
if(TRKDEBUG) print*,'mini2: -ok- ',istep,chi2,1./AL(5) |
378 |
|
|
379 |
NSTEP=ISTEP ! ***PP*** |
NSTEP=ISTEP ! ***PP*** |
380 |
|
|
381 |
|
c$$$ print*,'>>>>> NSTEP = ',NSTEP |
382 |
|
|
383 |
RETURN |
RETURN |
384 |
END |
END |
385 |
|
|
472 |
+ *( XGOOD(I)*(1-YGOOD(I)) ) |
+ *( XGOOD(I)*(1-YGOOD(I)) ) |
473 |
+ +((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 |
474 |
+ *( (1-XGOOD(I))*YGOOD(I) ) |
+ *( (1-XGOOD(I))*YGOOD(I) ) |
475 |
|
c$$$ print*,(XV(I)-XM(I))**2/RESX(i)**2 *( XGOOD(I)*YGOOD(I) ) |
476 |
|
c$$$ print*,(YV(I)-YM(I))**2/RESY(i)**2 *( YGOOD(I)*XGOOD(I) ) |
477 |
|
c$$$ print*,((XV(I)-XM(I))**2+(YV(I)-YM(I))**2)/RESX(i)**2 |
478 |
|
c$$$ + *( XGOOD(I)*(1-YGOOD(I)) ) |
479 |
|
c$$$ print*,((XV(I)-XM(I))**2+(YV(I)-YM(I))**2)/RESY(i)**2 |
480 |
|
c$$$ + *( (1-XGOOD(I))*YGOOD(I) ) |
481 |
|
c$$$ print*,XV(I),XM(I),XGOOD(I) |
482 |
|
c$$$ print*,YV(I),YM(I),YGOOD(I) |
483 |
ENDDO |
ENDDO |
484 |
c print*,'CHISQ ',chi2 |
c$$$ print*,'CHISQ ',chi2 |
485 |
* ------------------------------------------------ |
* ------------------------------------------------ |
486 |
* |
* |
487 |
* calculation of derivatives (dX/dAL_fa and dY/dAL_fa) |
* calculation of derivatives (dX/dAL_fa and dY/dAL_fa) |
640 |
c |
c |
641 |
DIMENSION AL_P(5) |
DIMENSION AL_P(5) |
642 |
* |
* |
643 |
DO I=1,nplanes |
cpp DO I=1,nplanes |
644 |
ZV(I)=ZM(I) ! |
cpp ZV(I)=ZM(I) ! |
645 |
ENDDO |
cpp ENDDO |
646 |
* |
* |
647 |
* set parameters for GRKUTA |
* set parameters for GRKUTA |
648 |
* |
* |
657 |
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)) |
658 |
IF(AL_P(5).EQ.0.) VOUT(7)=1.E8 |
IF(AL_P(5).EQ.0.) VOUT(7)=1.E8 |
659 |
|
|
660 |
c$$$ print*,'POSXY ',vout |
c$$$ print*,'POSXY (prima) ',vout |
661 |
|
|
662 |
DO I=1,nplanes |
DO I=1,nplanes |
663 |
step=vout(3)-zv(i) |
cpp step=vout(3)-zv(i) |
664 |
|
step=vout(3)-zm(i) |
665 |
10 DO J=1,7 |
10 DO J=1,7 |
666 |
VECT(J)=VOUT(J) |
VECT(J)=VOUT(J) |
667 |
VECTINI(J)=VOUT(J) |
VECTINI(J)=VOUT(J) |
693 |
GOTO 11 |
GOTO 11 |
694 |
ENDIF |
ENDIF |
695 |
|
|
696 |
|
|
697 |
* ----------------------------------------------- |
* ----------------------------------------------- |
698 |
* evaluate track coordinates |
* evaluate track coordinates |
699 |
100 XV(I)=VOUT(1) |
100 XV(I)=VOUT(1) |
703 |
AYV(I)=DATAN(VOUT(5)/VOUT(6))*180./ACOS(-1.) |
AYV(I)=DATAN(VOUT(5)/VOUT(6))*180./ACOS(-1.) |
704 |
* ----------------------------------------------- |
* ----------------------------------------------- |
705 |
|
|
706 |
|
IF(TRACKMODE.EQ.1) THEN |
707 |
|
* ----------------------------------------------- |
708 |
|
* change of energy by bremsstrahlung for electrons |
709 |
|
VOUT(7) = VOUT(7) * 0.997 !0.9968 |
710 |
|
* ----------------------------------------------- |
711 |
|
ENDIF |
712 |
|
|
713 |
ENDDO |
ENDDO |
714 |
|
|
715 |
|
c$$$ print*,'POSXY (dopo) ',vout |
716 |
|
|
717 |
|
|
718 |
RETURN |
RETURN |
719 |
END |
END |
720 |
|
|
825 |
ZP(NP)=ZM(I) |
ZP(NP)=ZM(I) |
826 |
ENDIF |
ENDIF |
827 |
ENDDO |
ENDDO |
828 |
|
IFLAG=0 !no debug mode |
829 |
CALL TRICIRCLE(NP,XP,ZP,AP,RP,CHI,XC,ZC,RADIUS,IFLAG) |
CALL TRICIRCLE(NP,XP,ZP,AP,RP,CHI,XC,ZC,RADIUS,IFLAG) |
830 |
c print*,' circle: ',XC,ZC,RADIUS,' --- ',CHI |
|
831 |
|
c$$$ print*,' circle: ',XC,ZC,RADIUS,' --- ',CHI,IFLAG |
832 |
|
c$$$ print*,' XP ',(xp(i),i=1,np) |
833 |
|
c$$$ print*,' ZP ',(zp(i),i=1,np) |
834 |
|
c$$$ print*,' AP ',(ap(i),i=1,np) |
835 |
|
c$$$ print*,' XP ',(rp(i),i=1,np) |
836 |
|
|
837 |
IF(IFLAG.NE.0)GOTO 10 !straigth fit |
IF(IFLAG.NE.0)GOTO 10 !straigth fit |
838 |
|
c if(CHI.gt.100)GOTO 10 !straigth fit |
839 |
ARG = RADIUS**2-(ZINI-ZC)**2 |
ARG = RADIUS**2-(ZINI-ZC)**2 |
840 |
IF(ARG.LT.0)GOTO 10 !straigth fit |
IF(ARG.LT.0)GOTO 10 !straigth fit |
841 |
DC = SQRT(ARG) |
DC = SQRT(ARG) |
844 |
AX = -(ZINI-ZC)/DC |
AX = -(ZINI-ZC)/DC |
845 |
DEF=100./(RADIUS*0.3*0.43) |
DEF=100./(RADIUS*0.3*0.43) |
846 |
IF(XC.GT.0)DEF=-DEF |
IF(XC.GT.0)DEF=-DEF |
847 |
|
|
848 |
|
|
849 |
|
|
850 |
|
IF(ABS(X0).GT.30)THEN |
851 |
|
c$$$ PRINT*,'STRANGE GUESS: XC,ZC,R ',XC,ZC,RADIUS |
852 |
|
c$$$ $ ,' - CHI ',CHI,' - X0,AX,DEF ',X0,AX,DEF |
853 |
|
GOTO 10 !straigth fit |
854 |
|
ENDIF |
855 |
GOTO 20 !guess is ok |
GOTO 20 !guess is ok |
856 |
|
|
857 |
* ---------------------------------------- |
* ---------------------------------------- |
893 |
AL(2) = Y0 |
AL(2) = Y0 |
894 |
tath = sqrt(AY**2+AX**2) |
tath = sqrt(AY**2+AX**2) |
895 |
AL(3) = tath/sqrt(1+tath**2) |
AL(3) = tath/sqrt(1+tath**2) |
896 |
IF(AX.NE.0)THEN |
c$$$ IF(AX.NE.0)THEN |
897 |
AL(4)= atan(AY/AX) |
c$$$ AL(4)= atan(AY/AX) |
898 |
ELSE |
c$$$ ELSE |
899 |
AL(4) = acos(-1.)/2 |
c$$$ AL(4) = acos(-1.)/2 |
900 |
IF(AY.LT.0)AL(4) = AL(4)+acos(-1.) |
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.AND.AY.NE.0)THEN |
907 |
|
c$$$ AL(4)= atan(AY/AX) |
908 |
|
c$$$ ELSEIF(AY.EQ.0)THEN |
909 |
|
c$$$ AL(4) = 0. |
910 |
|
c$$$ IF(AX.LT.0)AL(4) = AL(4)+acos(-1.) |
911 |
|
c$$$ ELSEIF(AX.EQ.0)THEN |
912 |
|
c$$$ AL(4) = acos(-1.)/2 |
913 |
|
c$$$ IF(AY.LT.0)AL(4) = AL(4)+acos(-1.) |
914 |
|
c$$$ ENDIF |
915 |
|
c$$$ IF(AX.LT.0)AL(4)= acos(-1.)+ AL(4) |
916 |
|
c$$$ AL(4) = -acos(-1.) + AL(4) !from incidence direction to tracking ref.sys. |
917 |
|
|
918 |
|
c$$$ AL(4)=0. |
919 |
|
c$$$ IF( AX.NE.0.OR.AY.NE.0. ) THEN |
920 |
|
c$$$ AL(4) = ASIN(AY/SQRT(AX**2+AY**2)) |
921 |
|
c$$$ IF(AX.LT.0.) AL(4) = ACOS(-1.0)-AL(4) |
922 |
|
c$$$ ENDIF |
923 |
|
|
924 |
|
AL(4)=0. |
925 |
|
IF( AX.NE.0.OR.AY.NE.0. ) THEN |
926 |
|
AL(4) = ASIN(AY/SQRT(AX**2+AY**2)) |
927 |
|
IF(AX.LT.0.AND.AY.GE.0) AL(4) = ACOS(-1.0)-AL(4) |
928 |
|
IF(AX.LT.0.AND.AY.LT.0) AL(4) = -ACOS(-1.0)-AL(4) |
929 |
ENDIF |
ENDIF |
930 |
IF(AX.LT.0)AL(4)= acos(-1.)+ AL(4) |
IF(AY.GT.0.) AL(4) = AL(4)-ACOS(-1.0) |
931 |
AL(4) = -acos(-1.) + AL(4) !from incidence direction to tracking rs |
IF(AY.LE.0.) AL(4) = AL(4)+ACOS(-1.0) |
932 |
|
|
933 |
AL(5) = DEF |
AL(5) = DEF |
934 |
|
|
935 |
c print*,' guess: ',(al(i),i=1,5) |
c print*,' guess: ',(al(i),i=1,5) |