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,1.,dinf,dinf/ !limits on alpha vector components |
DATA ALMAX/dinf,dinf,dinf,dinf,dinf/ !limits on alpha vector components |
45 |
DATA ALMIN/-dinf,-dinf,-1.,-dinf,-dinf/ !" |
DATA ALMIN/-dinf,-dinf,-dinf,-dinf,-dinf/ !" |
46 |
|
|
47 |
DIMENSION DAL(5) !increment of vector alfa |
DIMENSION DAL(5) !increment of vector alfa |
48 |
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 |
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 |
* |
* |
138 |
RETURN |
RETURN |
139 |
ENDIF |
ENDIF |
140 |
|
|
141 |
COST=1e-7 |
COST=1e-9 |
142 |
|
costfac=1.1 |
143 |
|
flagstep=0 |
144 |
|
|
145 |
|
7 continue |
146 |
|
|
147 |
|
IF(costfac.le.1.) THEN |
148 |
|
IFAIL=1 |
149 |
|
PRINT *,'=== WARNING ===> no matrix inversion ' |
150 |
|
RETURN |
151 |
|
ENDIF |
152 |
|
|
153 |
DO I=1,5 |
DO I=1,5 |
154 |
DO J=1,5 |
DO J=1,5 |
155 |
CHI2DD(I,J)=CHI2DD(I,J)*COST |
CHI2DD(I,J)=CHI2DD(I,J)*COST |
163 |
* track fitting with FREE deflection |
* track fitting with FREE deflection |
164 |
*------------------------------------------------------------* |
*------------------------------------------------------------* |
165 |
CALL DSFACT(5,CHI2DD,5,IFA,DET,JFA) !CHI2DD matrix determinant |
CALL DSFACT(5,CHI2DD,5,IFA,DET,JFA) !CHI2DD matrix determinant |
166 |
IF(IFA.NE.0) THEN !not positive-defined |
IF(IFA.NE.0.or.jfa.ne.0) THEN !not positive-defined |
167 |
if(TRKVERBOSE)then |
if(ifa.eq.-1)then |
168 |
|
if(TRKVERBOSE)then |
169 |
PRINT *, |
PRINT *, |
170 |
$ '*** ERROR in mini ***'// |
$ '*** ERROR in mini ***'// |
171 |
$ 'on matrix inversion (not pos-def)' |
$ 'on matrix inversion (not pos-def)' |
172 |
$ ,DET |
$ ,DET |
173 |
endif |
endif |
174 |
IF(CHI2.EQ.0) CHI2=-9999. |
IF(CHI2.EQ.0) CHI2=-9999. |
175 |
IF(CHI2.GT.0) CHI2=-CHI2 |
IF(CHI2.GT.0) CHI2=-CHI2 |
176 |
IFAIL=1 |
IFAIL=1 |
177 |
RETURN |
RETURN |
178 |
|
endif |
179 |
|
if(jfa.eq.-1)then |
180 |
|
if(flagstep.eq.-1.) costfac=(costfac-1)/2+1 |
181 |
|
cost=cost*costfact |
182 |
|
flagstep=1. |
183 |
|
goto 7 |
184 |
|
elseif(jfa.eq.1)then |
185 |
|
if(flagstep.eq.1.) costfac=(costfac-1)/2+1 |
186 |
|
cost=cost/costfac |
187 |
|
flagstep=-1. |
188 |
|
goto 7 |
189 |
|
endif |
190 |
ENDIF |
ENDIF |
191 |
CALL DSFINV(5,CHI2DD,5) !CHI2DD matrix inversion |
CALL DSFINV(5,CHI2DD,5) !CHI2DD matrix inversion |
192 |
* ******************************************* |
* ******************************************* |
489 |
+ +((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 |
490 |
+ *( (1-XGOOD(I))*YGOOD(I) ) |
+ *( (1-XGOOD(I))*YGOOD(I) ) |
491 |
ENDDO |
ENDDO |
492 |
|
c print*,'CHISQ ',chi2 |
493 |
* ------------------------------------------------ |
* ------------------------------------------------ |
494 |
* |
* |
495 |
* calculation of derivatives (dX/dAL_fa and dY/dAL_fa) |
* calculation of derivatives (dX/dAL_fa and dY/dAL_fa) |
664 |
VOUT(6)=-1.*DSQRT(1.-AL_P(3)**2) |
VOUT(6)=-1.*DSQRT(1.-AL_P(3)**2) |
665 |
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)) |
666 |
IF(AL_P(5).EQ.0.) VOUT(7)=1.E8 |
IF(AL_P(5).EQ.0.) VOUT(7)=1.E8 |
667 |
|
|
668 |
|
c$$$ print*,'POSXY ',vout |
669 |
|
|
670 |
DO I=1,nplanes |
DO I=1,nplanes |
671 |
step=vout(3)-zv(i) |
step=vout(3)-zv(i) |
672 |
10 DO J=1,7 |
10 DO J=1,7 |