43 |
|
|
44 |
c DATA ALMAX/dinf,dinf,1.,dinf,dinf/ !limits on alpha vector components |
c DATA ALMAX/dinf,dinf,1.,dinf,dinf/ !limits on alpha vector components |
45 |
c DATA ALMIN/-dinf,-dinf,-1.,-dinf,-dinf/ !" |
c DATA ALMIN/-dinf,-dinf,-1.,-dinf,-dinf/ !" |
46 |
DATA ALMAX/dinf,dinf,dinf,dinf,dinf/ !limits on alpha vector components |
DATA ALMAX/dinf,dinf,1.,dinf,dinf/ !limits on alpha vector components |
47 |
DATA ALMIN/-dinf,-dinf,-dinf,-dinf,-dinf/ !" |
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 |
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-7 |
COST=1e-5 |
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 |
273 |
c$$$ ENDDO |
c$$$ ENDDO |
274 |
c$$$ print*,'chi2 -- ',DCHI2 |
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 |
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 |
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) |
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 ',vout |
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) |
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) |
700 |
|
|
701 |
ENDDO |
ENDDO |
702 |
|
|
703 |
|
c$$$ print*,'POSXY (dopo) ',vout |
704 |
|
|
705 |
|
|
706 |
RETURN |
RETURN |
707 |
END |
END |
708 |
|
|
813 |
ZP(NP)=ZM(I) |
ZP(NP)=ZM(I) |
814 |
ENDIF |
ENDIF |
815 |
ENDDO |
ENDDO |
816 |
|
IFLAG=0 !no debug mode |
817 |
CALL TRICIRCLE(NP,XP,ZP,AP,RP,CHI,XC,ZC,RADIUS,IFLAG) |
CALL TRICIRCLE(NP,XP,ZP,AP,RP,CHI,XC,ZC,RADIUS,IFLAG) |
818 |
print*,' circle: ',XC,ZC,RADIUS,' --- ',CHI,IFLAG |
c print*,' circle: ',XC,ZC,RADIUS,' --- ',CHI,IFLAG |
819 |
IF(IFLAG.NE.0)GOTO 10 !straigth fit |
IF(IFLAG.NE.0)GOTO 10 !straigth fit |
820 |
if(CHI.gt.100)GOTO 10 !straigth fit |
if(CHI.gt.100)GOTO 10 !straigth fit |
821 |
ARG = RADIUS**2-(ZINI-ZC)**2 |
ARG = RADIUS**2-(ZINI-ZC)**2 |
828 |
IF(XC.GT.0)DEF=-DEF |
IF(XC.GT.0)DEF=-DEF |
829 |
|
|
830 |
IF(ABS(X0).GT.30)THEN |
IF(ABS(X0).GT.30)THEN |
831 |
PRINT*,'STRANGE GUESS: XC,ZC,R ',XC,ZC,RADIUS |
c$$$ PRINT*,'STRANGE GUESS: XC,ZC,R ',XC,ZC,RADIUS |
832 |
$ ,' - CHI ',CHI,' - X0,AX,DEF ',X0,AX,DEF |
c$$$ $ ,' - CHI ',CHI,' - X0,AX,DEF ',X0,AX,DEF |
833 |
GOTO 10 !straigth fit |
GOTO 10 !straigth fit |
834 |
ENDIF |
ENDIF |
835 |
GOTO 20 !guess is ok |
GOTO 20 !guess is ok |
873 |
AL(2) = Y0 |
AL(2) = Y0 |
874 |
tath = sqrt(AY**2+AX**2) |
tath = sqrt(AY**2+AX**2) |
875 |
AL(3) = tath/sqrt(1+tath**2) |
AL(3) = tath/sqrt(1+tath**2) |
876 |
IF(AX.NE.0)THEN |
c$$$ IF(AX.NE.0)THEN |
877 |
AL(4)= atan(AY/AX) |
c$$$ AL(4)= atan(AY/AX) |
878 |
ELSE |
c$$$ ELSE |
879 |
AL(4) = acos(-1.)/2 |
c$$$ AL(4) = acos(-1.)/2 |
880 |
IF(AY.LT.0)AL(4) = AL(4)+acos(-1.) |
c$$$ IF(AY.LT.0)AL(4) = AL(4)+acos(-1.) |
881 |
|
c$$$ ENDIF |
882 |
|
c$$$ IF(AX.LT.0)AL(4)= acos(-1.)+ AL(4) |
883 |
|
c$$$ AL(4) = -acos(-1.) + AL(4) !from incidence direction to tracking ref.sys. |
884 |
|
|
885 |
|
c$$$ AL(4) = 0. |
886 |
|
c$$$ IF(AX.NE.0.AND.AY.NE.0)THEN |
887 |
|
c$$$ AL(4)= atan(AY/AX) |
888 |
|
c$$$ ELSEIF(AY.EQ.0)THEN |
889 |
|
c$$$ AL(4) = 0. |
890 |
|
c$$$ IF(AX.LT.0)AL(4) = AL(4)+acos(-1.) |
891 |
|
c$$$ ELSEIF(AX.EQ.0)THEN |
892 |
|
c$$$ AL(4) = acos(-1.)/2 |
893 |
|
c$$$ IF(AY.LT.0)AL(4) = AL(4)+acos(-1.) |
894 |
|
c$$$ ENDIF |
895 |
|
c$$$ IF(AX.LT.0)AL(4)= acos(-1.)+ AL(4) |
896 |
|
c$$$ AL(4) = -acos(-1.) + AL(4) !from incidence direction to tracking ref.sys. |
897 |
|
|
898 |
|
c$$$ AL(4)=0. |
899 |
|
c$$$ IF( AX.NE.0.OR.AY.NE.0. ) THEN |
900 |
|
c$$$ AL(4) = ASIN(AY/SQRT(AX**2+AY**2)) |
901 |
|
c$$$ IF(AX.LT.0.) AL(4) = ACOS(-1.0)-AL(4) |
902 |
|
c$$$ ENDIF |
903 |
|
|
904 |
|
AL(4)=0. |
905 |
|
IF( AX.NE.0.OR.AY.NE.0. ) THEN |
906 |
|
AL(4) = ASIN(AY/SQRT(AX**2+AY**2)) |
907 |
|
IF(AX.LT.0.AND.AY.GE.0) AL(4) = ACOS(-1.0)-AL(4) |
908 |
|
IF(AX.LT.0.AND.AY.LT.0) AL(4) = -ACOS(-1.0)-AL(4) |
909 |
ENDIF |
ENDIF |
910 |
IF(AX.LT.0)AL(4)= acos(-1.)+ AL(4) |
IF(AY.GT.0.) AL(4) = AL(4)-ACOS(-1.0) |
911 |
AL(4) = -acos(-1.) + AL(4) !from incidence direction to tracking rs |
IF(AY.LE.0.) AL(4) = AL(4)+ACOS(-1.0) |
912 |
|
|
913 |
AL(5) = DEF |
AL(5) = DEF |
914 |
|
|
915 |
c print*,' guess: ',(al(i),i=1,5) |
c print*,' guess: ',(al(i),i=1,5) |