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 |
|
c DATA ALMAX/dinf,dinf,1.,dinf,dinf/ !limits on alpha vector components |
45 |
|
c DATA ALMIN/-dinf,-dinf,-1.,-dinf,-dinf/ !" |
46 |
DATA ALMAX/dinf,dinf,1.,dinf,dinf/ !limits on alpha vector components |
DATA ALMAX/dinf,dinf,1.,dinf,dinf/ !limits on alpha vector components |
47 |
DATA ALMIN/-dinf,-dinf,-1.,-dinf,-dinf/ !" |
DATA ALMIN/-dinf,-dinf,-1.,-dinf,-dinf/ !" |
48 |
|
|
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 |
c elena-------- |
if(TRKDEBUG) print*,'guess: ',al |
|
CHI2 = 0 |
|
|
c elena-------- |
|
126 |
if(TRKDEBUG) print*,'mini2: step ',istep,chi2,1./AL(5) |
if(TRKDEBUG) print*,'mini2: step ',istep,chi2,1./AL(5) |
127 |
|
|
128 |
* |
* |
140 |
RETURN |
RETURN |
141 |
ENDIF |
ENDIF |
142 |
|
|
143 |
COST=1e-7 |
COST=1e-5 |
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 |
247 |
* check number of steps: |
* check number of steps: |
248 |
*------------------------------------------------------------* |
*------------------------------------------------------------* |
249 |
IF(ISTEP.ge.ISTEPMAX) then |
IF(ISTEP.ge.ISTEPMAX) then |
250 |
IFAIL=1 |
c$$$ IFAIL=1 |
251 |
if(TRKVERBOSE) |
c$$$ if(TRKVERBOSE) |
252 |
$ PRINT *,'*** WARNING in mini *** ISTEP.GT.ISTEPMAX=', |
c$$$ $ PRINT *,'*** WARNING in mini *** ISTEP.GT.ISTEPMAX=', |
253 |
$ ISTEPMAX |
c$$$ $ ISTEPMAX |
254 |
goto 11 |
goto 11 |
255 |
endif |
endif |
256 |
*------------------------------------------------------------* |
*------------------------------------------------------------* |
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) |
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 |
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 |
|
|
811 |
ZP(NP)=ZM(I) |
ZP(NP)=ZM(I) |
812 |
ENDIF |
ENDIF |
813 |
ENDDO |
ENDDO |
814 |
|
IFLAG=0 !no debug mode |
815 |
CALL TRICIRCLE(NP,XP,ZP,AP,RP,CHI,XC,ZC,RADIUS,IFLAG) |
CALL TRICIRCLE(NP,XP,ZP,AP,RP,CHI,XC,ZC,RADIUS,IFLAG) |
816 |
c print*,' circle: ',XC,ZC,RADIUS,' --- ',CHI |
c print*,' circle: ',XC,ZC,RADIUS,' --- ',CHI,IFLAG |
817 |
IF(IFLAG.NE.0)GOTO 10 !straigth fit |
IF(IFLAG.NE.0)GOTO 10 !straigth fit |
818 |
|
if(CHI.gt.100)GOTO 10 !straigth fit |
819 |
ARG = RADIUS**2-(ZINI-ZC)**2 |
ARG = RADIUS**2-(ZINI-ZC)**2 |
820 |
IF(ARG.LT.0)GOTO 10 !straigth fit |
IF(ARG.LT.0)GOTO 10 !straigth fit |
821 |
DC = SQRT(ARG) |
DC = SQRT(ARG) |
824 |
AX = -(ZINI-ZC)/DC |
AX = -(ZINI-ZC)/DC |
825 |
DEF=100./(RADIUS*0.3*0.43) |
DEF=100./(RADIUS*0.3*0.43) |
826 |
IF(XC.GT.0)DEF=-DEF |
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 |
GOTO 20 !guess is ok |
834 |
|
|
835 |
* ---------------------------------------- |
* ---------------------------------------- |
871 |
AL(2) = Y0 |
AL(2) = Y0 |
872 |
tath = sqrt(AY**2+AX**2) |
tath = sqrt(AY**2+AX**2) |
873 |
AL(3) = tath/sqrt(1+tath**2) |
AL(3) = tath/sqrt(1+tath**2) |
874 |
IF(AX.NE.0)THEN |
c$$$ IF(AX.NE.0)THEN |
875 |
AL(4)= atan(AY/AX) |
c$$$ AL(4)= atan(AY/AX) |
876 |
ELSE |
c$$$ ELSE |
877 |
AL(4) = acos(-1.)/2 |
c$$$ AL(4) = acos(-1.)/2 |
878 |
IF(AY.LT.0)AL(4) = AL(4)+acos(-1.) |
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 |
ENDIF |
908 |
IF(AX.LT.0)AL(4)= acos(-1.)+ AL(4) |
IF(AY.GT.0.) AL(4) = AL(4)-ACOS(-1.0) |
909 |
AL(4) = -acos(-1.) + AL(4) !from incidence direction to tracking rs |
IF(AY.LE.0.) AL(4) = AL(4)+ACOS(-1.0) |
910 |
|
|
911 |
AL(5) = DEF |
AL(5) = DEF |
912 |
|
|
913 |
c print*,' guess: ',(al(i),i=1,5) |
c print*,' guess: ',(al(i),i=1,5) |