| 233 |
c$$$ enddo |
c$$$ enddo |
| 234 |
c$$$ if(ibest.eq.0)goto 880 !>> no good candidates |
c$$$ if(ibest.eq.0)goto 880 !>> no good candidates |
| 235 |
|
|
| 236 |
rchi2best=1000000000. |
* ------------------------------------------------------- |
| 237 |
|
* order track-candidates according to: |
| 238 |
|
* 1st) decreasing n.points |
| 239 |
|
* 2nd) increasing chi**2 |
| 240 |
|
* ------------------------------------------------------- |
| 241 |
|
rchi2best=1000000000. |
| 242 |
ndofbest=0 !(1) |
ndofbest=0 !(1) |
| 243 |
do i=1,ntracks |
do i=1,ntracks |
| 244 |
if(RCHI2_STORE(i).lt.rchi2best.and. |
ndof=0 !(1) |
| 245 |
$ RCHI2_STORE(i).gt.0)then |
do ii=1,nplanes !(1) |
| 246 |
ndof=0 !(1) |
ndof=ndof !(1) |
| 247 |
do ii=1,nplanes !(1) |
$ +int(xgood_store(ii,i)) !(1) |
| 248 |
ndof=ndof !(1) |
$ +int(ygood_store(ii,i)) !(1) |
| 249 |
$ +int(xgood_store(ii,i)) !(1) |
enddo !(1) |
| 250 |
$ +int(ygood_store(ii,i)) !(1) |
if(ndof.gt.ndofbest)then !(1) |
| 251 |
enddo !(1) |
ibest=i |
| 252 |
if(ndof.ge.ndofbest)then !(1) |
rchi2best=RCHI2_STORE(i) |
| 253 |
|
ndofbest=ndof !(1) |
| 254 |
|
elseif(ndof.eq.ndofbest)then !(1) |
| 255 |
|
if(RCHI2_STORE(i).lt.rchi2best.and. |
| 256 |
|
$ RCHI2_STORE(i).gt.0)then |
| 257 |
ibest=i |
ibest=i |
| 258 |
rchi2best=RCHI2_STORE(i) |
rchi2best=RCHI2_STORE(i) |
| 259 |
ndofbest=ndof !(1) |
ndofbest=ndof !(1) |
| 260 |
endif !(1) |
endif !(1) |
| 261 |
endif |
endif |
| 262 |
enddo |
enddo |
| 263 |
|
|
| 264 |
|
c$$$ rchi2best=1000000000. |
| 265 |
|
c$$$ ndofbest=0 !(1) |
| 266 |
|
c$$$ do i=1,ntracks |
| 267 |
|
c$$$ if(RCHI2_STORE(i).lt.rchi2best.and. |
| 268 |
|
c$$$ $ RCHI2_STORE(i).gt.0)then |
| 269 |
|
c$$$ ndof=0 !(1) |
| 270 |
|
c$$$ do ii=1,nplanes !(1) |
| 271 |
|
c$$$ ndof=ndof !(1) |
| 272 |
|
c$$$ $ +int(xgood_store(ii,i)) !(1) |
| 273 |
|
c$$$ $ +int(ygood_store(ii,i)) !(1) |
| 274 |
|
c$$$ enddo !(1) |
| 275 |
|
c$$$ if(ndof.ge.ndofbest)then !(1) |
| 276 |
|
c$$$ ibest=i |
| 277 |
|
c$$$ rchi2best=RCHI2_STORE(i) |
| 278 |
|
c$$$ ndofbest=ndof !(1) |
| 279 |
|
c$$$ endif !(1) |
| 280 |
|
c$$$ endif |
| 281 |
|
c$$$ enddo |
| 282 |
|
|
| 283 |
if(ibest.eq.0)goto 880 !>> no good candidates |
if(ibest.eq.0)goto 880 !>> no good candidates |
| 284 |
*------------------------------------------------------------------------------- |
*------------------------------------------------------------------------------- |
| 285 |
* The best track candidate (ibest) is selected and a new fitting is performed. |
* The best track candidate (ibest) is selected and a new fitting is performed. |
| 314 |
do i=1,5 |
do i=1,5 |
| 315 |
AL_GUESS(i)=AL(i) |
AL_GUESS(i)=AL(i) |
| 316 |
enddo |
enddo |
| 317 |
|
c print*,'## guess: ',al |
| 318 |
|
|
| 319 |
do i=1,5 |
do i=1,5 |
| 320 |
AL(i)=dble(AL_STORE(i,icand)) |
AL(i)=dble(AL_STORE(i,icand)) |
| 327 |
iprint=0 |
iprint=0 |
| 328 |
c if(DEBUG)iprint=1 |
c if(DEBUG)iprint=1 |
| 329 |
if(VERBOSE)iprint=1 |
if(VERBOSE)iprint=1 |
| 330 |
|
if(DEBUG)iprint=2 |
| 331 |
call mini2(jstep,ifail,iprint) |
call mini2(jstep,ifail,iprint) |
| 332 |
if(ifail.ne.0) then |
if(ifail.ne.0) then |
| 333 |
if(.true.)then |
if(VERBOSE)then |
| 334 |
print *, |
print *, |
| 335 |
$ '*** MINIMIZATION FAILURE *** (after refinement) ' |
$ '*** MINIMIZATION FAILURE *** (after refinement) ' |
| 336 |
$ ,iev |
$ ,iev |
| 568 |
xPAM_B = 0. |
xPAM_B = 0. |
| 569 |
yPAM_B = 0. |
yPAM_B = 0. |
| 570 |
zPAM_B = 0. |
zPAM_B = 0. |
| 571 |
|
c print*,'## xyz_PAM: ',icx,icy,sensor,PFAx,PFAy,angx,angy |
| 572 |
* ----------------- |
* ----------------- |
| 573 |
* CLUSTER X |
* CLUSTER X |
| 574 |
* ----------------- |
* ----------------- |
| 687 |
|
|
| 688 |
endif |
endif |
| 689 |
|
|
| 690 |
|
c print*,'## stripx,stripy ',stripx,stripy |
| 691 |
|
|
| 692 |
c=========================================================== |
c=========================================================== |
| 693 |
C COUPLE |
C COUPLE |
| 694 |
C=========================================================== |
C=========================================================== |
| 890 |
|
|
| 891 |
endif |
endif |
| 892 |
|
|
| 893 |
|
|
| 894 |
|
c print*,'## xPAM,yPAM,zPAM ',xPAM,yPAM,zPAM |
| 895 |
|
c print*,'## xPAM_A,yPAM_A,zPAM_A ',xPAM_A,yPAM_A,zPAM_A |
| 896 |
|
c print*,'## xPAM_B,yPAM_B,zPAM_B ',xPAM_B,yPAM_B,zPAM_B |
| 897 |
|
|
| 898 |
100 continue |
100 continue |
| 899 |
end |
end |
| 900 |
|
|
| 1504 |
goto 20 !charge not consistent |
goto 20 !charge not consistent |
| 1505 |
endif |
endif |
| 1506 |
endif |
endif |
|
|
|
|
* ------------------> COUPLE <------------------ |
|
|
ncp_plane(nplx) = ncp_plane(nplx) + 1 |
|
|
clx(nplx,ncp_plane(nplx))=icx |
|
|
cly(nply,ncp_plane(nplx))=icy |
|
|
cl_single(icx)=0 |
|
|
cl_single(icy)=0 |
|
| 1507 |
|
|
| 1508 |
if(ncp_plane(nplx).eq.ncouplemax)then |
if(ncp_plane(nplx).gt.ncouplemax)then |
| 1509 |
if(verbose)print*, |
if(verbose)print*, |
| 1510 |
$ '** warning ** number of identified '// |
$ '** warning ** number of identified '// |
| 1511 |
$ 'couples on plane ',nplx, |
$ 'couples on plane ',nplx, |
| 1513 |
$ ,'( ',ncouplemax,' ) --> masked!' |
$ ,'( ',ncouplemax,' ) --> masked!' |
| 1514 |
mask_view(nviewx(nplx)) = 2 |
mask_view(nviewx(nplx)) = 2 |
| 1515 |
mask_view(nviewy(nply)) = 2 |
mask_view(nviewy(nply)) = 2 |
| 1516 |
|
goto 10 |
| 1517 |
endif |
endif |
| 1518 |
|
|
| 1519 |
|
* ------------------> COUPLE <------------------ |
| 1520 |
|
ncp_plane(nplx) = ncp_plane(nplx) + 1 |
| 1521 |
|
clx(nplx,ncp_plane(nplx))=icx |
| 1522 |
|
cly(nply,ncp_plane(nplx))=icy |
| 1523 |
|
cl_single(icx)=0 |
| 1524 |
|
cl_single(icy)=0 |
| 1525 |
* ---------------------------------------------- |
* ---------------------------------------------- |
| 1526 |
|
|
| 1527 |
endif |
endif |
| 2361 |
nplused=nplused+ hit_plane(ip) |
nplused=nplused+ hit_plane(ip) |
| 2362 |
enddo |
enddo |
| 2363 |
|
|
| 2364 |
if(nplused.lt.nplxz_min)goto 888 !next doublet |
c if(nplused.lt.nplxz_min)goto 888 !next doublet |
| 2365 |
|
if(nplused.lt.nplyz_min)goto 888 !next doublet |
| 2366 |
if(ncp_ok.lt.ncpok)goto 888 !next cloud |
if(ncp_ok.lt.ncpok)goto 888 !next cloud |
| 2367 |
|
|
| 2368 |
if(DEBUG)then |
if(DEBUG)then |
| 2495 |
jstep=0 !number of minimization steps |
jstep=0 !number of minimization steps |
| 2496 |
iprint=0 |
iprint=0 |
| 2497 |
c if(DEBUG)iprint=1 |
c if(DEBUG)iprint=1 |
| 2498 |
if(DEBUG)iprint=1 |
if(DEBUG)iprint=2 |
| 2499 |
call mini2(jstep,ifail,iprint) |
call mini2(jstep,ifail,iprint) |
| 2500 |
if(ifail.ne.0) then |
if(ifail.ne.0) then |
| 2501 |
if(DEBUG)then |
if(DEBUG)then |
| 2872 |
endif |
endif |
| 2873 |
11882 continue |
11882 continue |
| 2874 |
enddo !end loop on cluster inside couples |
enddo !end loop on cluster inside couples |
| 2875 |
*----- single clusters ----------------------------------------------- |
*----- single clusters ----------------------------------------------- |
| 2876 |
|
c print*,'## ncls(',ip,') ',ncls(ip) |
| 2877 |
do ic=1,ncls(ip) !loop on single clusters |
do ic=1,ncls(ip) !loop on single clusters |
| 2878 |
icl=cls(ip,ic) |
icl=cls(ip,ic) |
| 2879 |
|
c print*,'## ic ',ic,' ist ',ist |
| 2880 |
c if(cl_used(icl).eq.1.or. !if the cluster is already used |
c if(cl_used(icl).eq.1.or. !if the cluster is already used |
| 2881 |
if(cl_used(icl).ne.0.or. !if the cluster is already used !(3) |
if(cl_used(icl).ne.0.or. !if the cluster is already used !(3) |
| 2882 |
$ LADDER(icl).ne.nldt.or. !or the ladder number does not match |
$ LADDER(icl).ne.nldt.or. !or the ladder number does not match |
| 2896 |
distance = distance_to(XP,YP) |
distance = distance_to(XP,YP) |
| 2897 |
distance = distance / RCHI2_STORE(ibest)!<<< MS |
distance = distance / RCHI2_STORE(ibest)!<<< MS |
| 2898 |
if(DEBUG)print*,'( cl-s ',icl |
if(DEBUG)print*,'( cl-s ',icl |
| 2899 |
$ ,' ) normalized distance ',distance |
$ ,' ) normalized distance ',distance,'<',distmin,' ?' |
| 2900 |
if(distance.lt.distmin)then |
if(distance.lt.distmin)then |
| 2901 |
|
if(DEBUG)print*,'YES' |
| 2902 |
xmm_A = xPAM_A |
xmm_A = xPAM_A |
| 2903 |
ymm_A = yPAM_A |
ymm_A = yPAM_A |
| 2904 |
zmm_A = zPAM_A |
zmm_A = zPAM_A |
| 2920 |
endif |
endif |
| 2921 |
18882 continue |
18882 continue |
| 2922 |
enddo !end loop on single clusters |
enddo !end loop on single clusters |
| 2923 |
|
c print*,'## distmin ', distmin,' clinc ',clinc |
| 2924 |
if(distmin.le.clinc)then |
if(distmin.le.clinc)then |
| 2925 |
|
|
| 2926 |
CLS_STORE(nplanes-ip+1,ibest)=iclm !<<<< |
CLS_STORE(nplanes-ip+1,ibest)=iclm !<<<< |