| 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 | 
| 120 | 
       ISTEP=0                   !num. steps to minimize chi^2 | 
       ISTEP=0                   !num. steps to minimize chi^2 | 
| 121 | 
       JFAIL=0                   !error flag | 
       JFAIL=0                   !error flag | 
| 122 | 
  | 
  | 
| 123 | 
 c     elena-------- | 
       if(TRKDEBUG) print*,'guess: ',al | 
 | 
       CHI2   = 0 | 
  | 
 | 
 c     elena-------- | 
  | 
| 124 | 
       if(TRKDEBUG) print*,'mini2: step ',istep,chi2,1./AL(5) | 
       if(TRKDEBUG) print*,'mini2: step ',istep,chi2,1./AL(5) | 
| 125 | 
  | 
  | 
| 126 | 
 *      | 
 *      | 
| 245 | 
 *     check number of steps: | 
 *     check number of steps: | 
| 246 | 
 *------------------------------------------------------------* | 
 *------------------------------------------------------------* | 
| 247 | 
       IF(ISTEP.ge.ISTEPMAX) then | 
       IF(ISTEP.ge.ISTEPMAX) then | 
| 248 | 
          IFAIL=1 | 
 c$$$         IFAIL=1 | 
| 249 | 
          if(TRKVERBOSE) | 
 c$$$         if(TRKVERBOSE) | 
| 250 | 
      $        PRINT *,'*** WARNING in mini *** ISTEP.GT.ISTEPMAX=', | 
 c$$$     $        PRINT *,'*** WARNING in mini *** ISTEP.GT.ISTEPMAX=', | 
| 251 | 
      $        ISTEPMAX | 
 c$$$     $        ISTEPMAX | 
| 252 | 
          goto 11 | 
          goto 11 | 
| 253 | 
       endif | 
       endif | 
| 254 | 
 *------------------------------------------------------------* | 
 *------------------------------------------------------------* | 
| 465 | 
      +        +((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  | 
| 466 | 
      +                                       *( (1-XGOOD(I))*YGOOD(I) ) | 
      +                                       *( (1-XGOOD(I))*YGOOD(I) ) | 
| 467 | 
       ENDDO | 
       ENDDO | 
| 468 | 
  | 
 c      print*,'CHISQ ',chi2 | 
| 469 | 
 *     ------------------------------------------------ | 
 *     ------------------------------------------------ | 
| 470 | 
 *      | 
 *      | 
| 471 | 
 *     calculation of derivatives (dX/dAL_fa and dY/dAL_fa)      | 
 *     calculation of derivatives (dX/dAL_fa and dY/dAL_fa)      | 
| 640 | 
       VOUT(6)=-1.*DSQRT(1.-AL_P(3)**2) | 
       VOUT(6)=-1.*DSQRT(1.-AL_P(3)**2) | 
| 641 | 
       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)) | 
| 642 | 
       IF(AL_P(5).EQ.0.) VOUT(7)=1.E8 | 
       IF(AL_P(5).EQ.0.) VOUT(7)=1.E8 | 
| 643 | 
  | 
  | 
| 644 | 
  | 
 c$$$      print*,'POSXY ',vout | 
| 645 | 
  | 
  | 
| 646 | 
       DO I=1,nplanes | 
       DO I=1,nplanes | 
| 647 | 
          step=vout(3)-zv(i) | 
          step=vout(3)-zv(i) | 
| 648 | 
  10      DO J=1,7 | 
  10      DO J=1,7 |