215 |
c include 'momanhough_init.f' |
c include 'momanhough_init.f' |
216 |
|
|
217 |
logical FIMAGE ! |
logical FIMAGE ! |
218 |
|
real trackimage(NTRACKSMAX) |
219 |
real*8 AL_GUESS(5) |
real*8 AL_GUESS(5) |
220 |
|
|
221 |
*------------------------------------------------------------------------------- |
*------------------------------------------------------------------------------- |
332 |
iimage=0 |
iimage=0 |
333 |
endif |
endif |
334 |
if(icand.eq.0)then |
if(icand.eq.0)then |
335 |
if(VERBOSE)then |
if(VERBOSE.EQ.1)then |
336 |
print*,'HAI FATTO UN CASINO!!!!!! icand = ',icand |
print*,'HAI FATTO UN CASINO!!!!!! icand = ',icand |
337 |
$ ,ibest,iimage |
$ ,ibest,iimage |
338 |
endif |
endif |
361 |
jstep=0 !# minimization steps |
jstep=0 !# minimization steps |
362 |
|
|
363 |
iprint=0 |
iprint=0 |
364 |
c if(DEBUG)iprint=1 |
c if(DEBUG.EQ.1)iprint=1 |
365 |
if(VERBOSE)iprint=1 |
if(VERBOSE.EQ.1)iprint=1 |
366 |
if(DEBUG)iprint=2 |
if(DEBUG.EQ.1)iprint=2 |
367 |
call mini2(jstep,ifail,iprint) |
call mini2(jstep,ifail,iprint) |
368 |
if(ifail.ne.0) then |
if(ifail.ne.0) then |
369 |
if(VERBOSE)then |
if(VERBOSE.EQ.1)then |
370 |
print *, |
print *, |
371 |
$ '*** MINIMIZATION FAILURE *** (after refinement) ' |
$ '*** MINIMIZATION FAILURE *** (after refinement) ' |
372 |
$ ,iev |
$ ,iev |
381 |
c chi2=-chi2 |
c chi2=-chi2 |
382 |
endif |
endif |
383 |
|
|
384 |
if(DEBUG)then |
if(DEBUG.EQ.1)then |
385 |
print*,'----------------------------- improved track coord' |
print*,'----------------------------- improved track coord' |
386 |
22222 format(i2,' * ',3f10.4,' --- ',4f10.4,' --- ',2f4.0,2f10.5) |
22222 format(i2,' * ',3f10.4,' --- ',4f10.4,' --- ',2f4.0,2f10.5) |
387 |
do ip=1,6 |
do ip=1,6 |
392 |
endif |
endif |
393 |
|
|
394 |
c rchi2=chi2/dble(ndof) |
c rchi2=chi2/dble(ndof) |
395 |
if(DEBUG)then |
if(DEBUG.EQ.1)then |
396 |
print*,' ' |
print*,' ' |
397 |
print*,'****** SELECTED TRACK *************' |
print*,'****** SELECTED TRACK *************' |
398 |
print*,'# R. chi2 RIG' |
print*,'# R. chi2 RIG' |
408 |
* ------------- search if the track has an IMAGE ------------- |
* ------------- search if the track has an IMAGE ------------- |
409 |
* ------------- (also this is stored ) ------------- |
* ------------- (also this is stored ) ------------- |
410 |
if(FIMAGE)goto 122 !>>> jump! (this is already an image) |
if(FIMAGE)goto 122 !>>> jump! (this is already an image) |
411 |
* now search for track-image, by comparing couples IDs |
|
412 |
|
* ----------------------------------------------------- |
413 |
|
* first check if the track is ambiguous |
414 |
|
* ----------------------------------------------------- |
415 |
|
* (modified on august 2007 by ElenaV) |
416 |
|
is1=0 |
417 |
|
do ip=1,NPLANES |
418 |
|
if(SENSOR_STORE(ip,icand).ne.0)then |
419 |
|
is1=SENSOR_STORE(ip,icand) |
420 |
|
if(ip.eq.6)is1=3-is1 !last plane inverted |
421 |
|
endif |
422 |
|
enddo |
423 |
|
if(is1.eq.0)then |
424 |
|
if(WARNING.EQ.1)print*,'** WARNING ** sensor=0' |
425 |
|
goto 122 !jump |
426 |
|
endif |
427 |
|
c print*,'is1 ',is1 |
428 |
|
do ip=1,NPLANES |
429 |
|
is2 = SENSOR_STORE(ip,icand) !sensor |
430 |
|
c print*,'is2 ',is2,' ip ',ip |
431 |
|
if(ip.eq.6.and.is2.ne.0)is2=3-is2 !last plane inverted |
432 |
|
if( |
433 |
|
$ (is1.ne.is2.and.is2.ne.0) |
434 |
|
$ )goto 122 !jump (this track cannot have an image) |
435 |
|
enddo |
436 |
|
if(DEBUG.eq.1)print*,' >>> ambiguous track! ' |
437 |
|
* now search for track-image among track candidates |
438 |
|
c$$$ do i=1,ntracks |
439 |
|
c$$$ iimage=i |
440 |
|
c$$$ do ip=1,nplanes |
441 |
|
c$$$ if( CP_STORE(nplanes-ip+1,icand).ne. |
442 |
|
c$$$ $ -1*CP_STORE(nplanes-ip+1,i).and. |
443 |
|
c$$$ $ CP_STORE(nplanes-ip+1,i).ne.0.and. |
444 |
|
c$$$ $ CP_STORE(nplanes-ip+1,icand).ne.0 )iimage=0 |
445 |
|
c$$$ print*,' track ',i,' CP ',CP_STORE(nplanes-ip+1,i) |
446 |
|
c$$$ $ ,CP_STORE(nplanes-ip+1,icand),iimage |
447 |
|
c$$$ enddo |
448 |
|
c$$$ if( iimage.ne.0.and. |
449 |
|
c$$$c $ RCHI2_STORE(i).le.CHI2MAX.and. |
450 |
|
c$$$c $ RCHI2_STORE(i).gt.0.and. |
451 |
|
c$$$ $ .true.)then |
452 |
|
c$$$ if(DEBUG.EQ.1)print*,'Track candidate ',iimage |
453 |
|
c$$$ $ ,' >>> TRACK IMAGE >>> of' |
454 |
|
c$$$ $ ,ibest |
455 |
|
c$$$ goto 122 !image track found |
456 |
|
c$$$ endif |
457 |
|
c$$$ enddo |
458 |
|
* --------------------------------------------------------------- |
459 |
|
* take the candidate with the greatest number of matching couples |
460 |
|
* if more than one satisfies the requirement, |
461 |
|
* choose the one with more points and lower chi2 |
462 |
|
* --------------------------------------------------------------- |
463 |
|
* count the number of matching couples |
464 |
|
ncpmax = 0 |
465 |
|
iimage = 0 !id of candidate with better matching |
466 |
do i=1,ntracks |
do i=1,ntracks |
467 |
iimage=i |
ncp=0 |
468 |
do ip=1,nplanes |
do ip=1,nplanes |
469 |
if( CP_STORE(nplanes-ip+1,icand).ne. |
if(CP_STORE(nplanes-ip+1,icand).ne.0)then |
470 |
$ -1*CP_STORE(nplanes-ip+1,i) )iimage=0 |
if( |
471 |
|
$ CP_STORE(nplanes-ip+1,i).ne.0 |
472 |
|
$ .and. |
473 |
|
$ CP_STORE(nplanes-ip+1,icand).eq. |
474 |
|
$ -1*CP_STORE(nplanes-ip+1,i) |
475 |
|
$ )then |
476 |
|
ncp=ncp+1 !ok |
477 |
|
elseif( |
478 |
|
$ CP_STORE(nplanes-ip+1,i).ne.0 |
479 |
|
$ .and. |
480 |
|
$ CP_STORE(nplanes-ip+1,icand).ne. |
481 |
|
$ -1*CP_STORE(nplanes-ip+1,i) |
482 |
|
$ )then |
483 |
|
ncp = 0 |
484 |
|
goto 117 !it is not an image candidate |
485 |
|
else |
486 |
|
|
487 |
|
endif |
488 |
|
endif |
489 |
|
c$$$ print*,' track ',i,' CP ',CP_STORE(nplanes-ip+1,i) |
490 |
|
c$$$ $ ,CP_STORE(nplanes-ip+1,icand),ncp |
491 |
enddo |
enddo |
492 |
if( iimage.ne.0.and. |
117 continue |
493 |
c $ RCHI2_STORE(i).le.CHI2MAX.and. |
trackimage(i)=ncp !number of matching couples |
494 |
c $ RCHI2_STORE(i).gt.0.and. |
if(ncp>ncpmax)then |
495 |
$ .true.)then |
ncpmax=ncp |
496 |
if(DEBUG)print*,'Track candidate ',iimage |
iimage=i |
|
$ ,' >>> TRACK IMAGE >>> of' |
|
|
$ ,ibest |
|
|
goto 122 !image track found |
|
497 |
endif |
endif |
498 |
enddo |
enddo |
499 |
|
* check if there are more than one image candidates |
500 |
|
ngood=0 |
501 |
|
do i=1,ntracks |
502 |
|
if( ncpmax.ne.0.and.trackimage(i).eq.ncpmax )ngood=ngood+1 |
503 |
|
enddo |
504 |
|
* if there are, choose the best one |
505 |
|
if(ngood.gt.1)then |
506 |
|
* ------------------------------------------------------- |
507 |
|
* order track-candidates according to: |
508 |
|
* 1st) decreasing n.points |
509 |
|
* 2nd) increasing chi**2 |
510 |
|
* ------------------------------------------------------- |
511 |
|
rchi2best=1000000000. |
512 |
|
ndofbest=0 |
513 |
|
do i=1,ntracks |
514 |
|
if( trackimage(i).eq.ncpmax )then |
515 |
|
ndof=0 |
516 |
|
do ii=1,nplanes |
517 |
|
ndof=ndof |
518 |
|
$ +int(xgood_store(ii,i)) |
519 |
|
$ +int(ygood_store(ii,i)) |
520 |
|
enddo |
521 |
|
if(ndof.gt.ndofbest)then |
522 |
|
iimage=i |
523 |
|
rchi2best=RCHI2_STORE(i) |
524 |
|
ndofbest=ndof |
525 |
|
elseif(ndof.eq.ndofbest)then |
526 |
|
if(RCHI2_STORE(i).lt.rchi2best.and. |
527 |
|
$ RCHI2_STORE(i).gt.0)then |
528 |
|
iimage=i |
529 |
|
rchi2best=RCHI2_STORE(i) |
530 |
|
ndofbest=ndof |
531 |
|
endif |
532 |
|
endif |
533 |
|
endif |
534 |
|
enddo |
535 |
|
|
536 |
|
endif |
537 |
|
|
538 |
|
if(DEBUG.EQ.1)print*,'Track candidate ',iimage |
539 |
|
$ ,' >>> TRACK IMAGE >>> of' |
540 |
|
$ ,ibest |
541 |
|
|
542 |
122 continue |
122 continue |
543 |
|
|
544 |
|
|
545 |
* --- and store the results -------------------------------- |
* --- and store the results -------------------------------- |
546 |
ntrk = ntrk + 1 !counter of found tracks |
ntrk = ntrk + 1 !counter of found tracks |
547 |
if(.not.FIMAGE |
if(.not.FIMAGE |
554 |
c $ ,iimage,fimage,ntrk,image(ntrk) |
c $ ,iimage,fimage,ntrk,image(ntrk) |
555 |
|
|
556 |
if(ntrk.eq.NTRKMAX)then |
if(ntrk.eq.NTRKMAX)then |
557 |
if(verbose) |
if(verbose.eq.1) |
558 |
$ print*, |
$ print*, |
559 |
$ '** warning ** number of identified '// |
$ '** warning ** number of identified '// |
560 |
$ 'tracks exceeds vector dimension ' |
$ 'tracks exceeds vector dimension ' |
590 |
$ rchi2best.le.CHI2MAX.and. |
$ rchi2best.le.CHI2MAX.and. |
591 |
c $ rchi2best.lt.15..and. |
c $ rchi2best.lt.15..and. |
592 |
$ .true.)then |
$ .true.)then |
593 |
if(DEBUG)then |
if(DEBUG.EQ.1)then |
594 |
print*,'***** NEW SEARCH ****' |
print*,'***** NEW SEARCH ****' |
595 |
endif |
endif |
596 |
goto 11111 !try new search |
goto 11111 !try new search |
806 |
stripx = stripx + pfaeta2(icx,angx) |
stripx = stripx + pfaeta2(icx,angx) |
807 |
resxPAM = risxeta2(abs(angx)) |
resxPAM = risxeta2(abs(angx)) |
808 |
resxPAM = resxPAM*fbad_cog(2,icx) |
resxPAM = resxPAM*fbad_cog(2,icx) |
809 |
if(DEBUG.and.fbad_cog(2,icx).ne.1) |
c$$$ if(DEBUG.EQ.1.and.fbad_cog(2,icx).ne.1) |
810 |
$ print*,'BAD icx >>> ',viewx,fbad_cog(2,icx) |
c$$$ $ print*,'BAD icx >>> ',viewx,fbad_cog(2,icx) |
811 |
|
|
812 |
elseif(PFAx.eq.'ETA3')then |
elseif(PFAx.eq.'ETA3')then |
813 |
|
|
849 |
resxPAM = resxPAM*fbad_cog(0,icx) |
resxPAM = resxPAM*fbad_cog(0,icx) |
850 |
|
|
851 |
else |
else |
852 |
if(DEBUG) print*,'*** Non valid p.f.a. (x) --> ',PFAx |
if(DEBUG.EQ.1) print*,'*** Non valid p.f.a. (x) --> ',PFAx |
853 |
endif |
endif |
854 |
|
|
855 |
|
|
894 |
endif |
endif |
895 |
|
|
896 |
if(icx.ne.0.and.(nply.ne.nplx.or.nldy.ne.nldx))then |
if(icx.ne.0.and.(nply.ne.nplx.or.nldy.ne.nldx))then |
897 |
if(DEBUG) then |
if(DEBUG.EQ.1) then |
898 |
print*,'xyz_PAM ***ERROR*** invalid cluster couple!!! ' |
print*,'xyz_PAM ***ERROR*** invalid cluster couple!!! ' |
899 |
$ ,icx,icy |
$ ,icx,icy |
900 |
endif |
endif |
989 |
resyPAM = resyPAM*fbad_cog(0,icy) |
resyPAM = resyPAM*fbad_cog(0,icy) |
990 |
|
|
991 |
else |
else |
992 |
if(DEBUG) print*,'*** Non valid p.f.a. (x) --> ',PFAx |
if(DEBUG.EQ.1) print*,'*** Non valid p.f.a. (x) --> ',PFAx |
993 |
endif |
endif |
994 |
|
|
995 |
|
|
1019 |
c------------------------------------------------------------------------ |
c------------------------------------------------------------------------ |
1020 |
if(((mod(int(stripx+0.5)-1,1024)+1).le.3) |
if(((mod(int(stripx+0.5)-1,1024)+1).le.3) |
1021 |
$ .or.((mod(int(stripx+0.5)-1,1024)+1).ge.1022)) then !X has 1018 strips... |
$ .or.((mod(int(stripx+0.5)-1,1024)+1).ge.1022)) then !X has 1018 strips... |
1022 |
if(DEBUG) then |
if(DEBUG.EQ.1) then |
1023 |
print*,'xyz_PAM (couple):', |
print*,'xyz_PAM (couple):', |
1024 |
$ ' WARNING: false X strip: strip ',stripx |
$ ' WARNING: false X strip: strip ',stripx |
1025 |
endif |
endif |
1114 |
c if((stripx.le.3).or.(stripx.ge.1022)) then !X has 1018 strips... |
c if((stripx.le.3).or.(stripx.ge.1022)) then !X has 1018 strips... |
1115 |
if(((mod(int(stripx+0.5)-1,1024)+1).le.3) |
if(((mod(int(stripx+0.5)-1,1024)+1).le.3) |
1116 |
$ .or.((mod(int(stripx+0.5)-1,1024)+1).ge.1022)) then !X has 1018 strips... |
$ .or.((mod(int(stripx+0.5)-1,1024)+1).ge.1022)) then !X has 1018 strips... |
1117 |
if(DEBUG) then |
if(DEBUG.EQ.1) then |
1118 |
print*,'xyz_PAM (X-singlet):', |
print*,'xyz_PAM (X-singlet):', |
1119 |
$ ' WARNING: false X strip: strip ',stripx |
$ ' WARNING: false X strip: strip ',stripx |
1120 |
endif |
endif |
1139 |
c print*,yi_A,' <--> ',yi_B |
c print*,yi_A,' <--> ',yi_B |
1140 |
|
|
1141 |
else |
else |
1142 |
if(DEBUG) then |
if(DEBUG.EQ.1) then |
1143 |
print *,'routine xyz_PAM ---> not properly used !!!' |
print *,'routine xyz_PAM ---> not properly used !!!' |
1144 |
print *,'icx = ',icx |
print *,'icx = ',icx |
1145 |
print *,'icy = ',icy |
print *,'icy = ',icy |
1208 |
c print*,'A-(',xPAM_A,yPAM_A,') B-(',xPAM_B,yPAM_B,')' |
c print*,'A-(',xPAM_A,yPAM_A,') B-(',xPAM_B,yPAM_B,')' |
1209 |
|
|
1210 |
else |
else |
1211 |
if(DEBUG) then |
if(DEBUG.EQ.1) then |
1212 |
print *,'routine xyz_PAM ---> not properly used !!!' |
print *,'routine xyz_PAM ---> not properly used !!!' |
1213 |
print *,'icx = ',icx |
print *,'icx = ',icx |
1214 |
print *,'icy = ',icy |
print *,'icy = ',icy |
1393 |
|
|
1394 |
endif |
endif |
1395 |
|
|
1396 |
if(DEBUG)then |
if(DEBUG.EQ.1)then |
1397 |
c print*,'----------------------------- track coord' |
c print*,'----------------------------- track coord' |
1398 |
22222 format(i2,' * ',3f10.4,' --- ',4f10.4,' --- ',2f4.0,2f10.5) |
22222 format(i2,' * ',3f10.4,' --- ',4f10.4,' --- ',2f4.0,2f10.5) |
1399 |
write(*,22222)ip,zm(ip),xm(ip),ym(ip) |
write(*,22222)ip,zm(ip),xm(ip),ym(ip) |
1844 |
integer iflag |
integer iflag |
1845 |
|
|
1846 |
integer badseed,badclx,badcly |
integer badseed,badclx,badcly |
1847 |
|
|
1848 |
|
if(DEBUG.EQ.1)print*,'cl_to_couples:' |
1849 |
|
|
1850 |
* init variables |
* init variables |
1851 |
ncp_tot=0 |
ncp_tot=0 |
1878 |
if( ncl_view(iv).gt. nclusterlimit)then |
if( ncl_view(iv).gt. nclusterlimit)then |
1879 |
c mask_view(iv) = 1 |
c mask_view(iv) = 1 |
1880 |
mask_view(iv) = mask_view(iv) + 2**0 |
mask_view(iv) = mask_view(iv) + 2**0 |
1881 |
if(DEBUG)print*,' * WARNING * cl_to_couple: n.clusters > ' |
if(DEBUG.EQ.1) |
1882 |
$ ,nclusterlimit,' on view ', iv,' --> masked!' |
$ print*,' * WARNING * cl_to_couple: n.clusters > ' |
1883 |
|
$ ,nclusterlimit,' on view ', iv,' --> masked!' |
1884 |
endif |
endif |
1885 |
enddo |
enddo |
1886 |
|
|
2018 |
endif |
endif |
2019 |
|
|
2020 |
if(ncp_plane(nplx).gt.ncouplemax)then |
if(ncp_plane(nplx).gt.ncouplemax)then |
2021 |
if(verbose)print*, |
if(verbose.eq.1)print*, |
2022 |
$ '** warning ** number of identified '// |
$ '** warning ** number of identified '// |
2023 |
$ 'couples on plane ',nplx, |
$ 'couples on plane ',nplx, |
2024 |
$ 'exceeds vector dimention ' |
$ 'exceeds vector dimention ' |
2056 |
enddo |
enddo |
2057 |
|
|
2058 |
|
|
2059 |
if(DEBUG)then |
if(DEBUG.EQ.1)then |
2060 |
print*,'clusters ',nclstr1 |
print*,'clusters ',nclstr1 |
2061 |
print*,'good ',(cl_good(i),i=1,nclstr1) |
print*,'good ',(cl_good(i),i=1,nclstr1) |
2062 |
print*,'singles ',(cl_single(i),i=1,nclstr1) |
print*,'singlets',(cl_single(i),i=1,nclstr1) |
2063 |
print*,'couples per plane: ',(ncp_plane(ip),ip=1,nplanes) |
print*,'couples per plane: ',(ncp_plane(ip),ip=1,nplanes) |
2064 |
endif |
endif |
2065 |
|
|
2119 |
real xc,zc,radius |
real xc,zc,radius |
2120 |
* ----------------------------- |
* ----------------------------- |
2121 |
|
|
2122 |
|
if(DEBUG.EQ.1)print*,'cp_to_doubtrip:' |
2123 |
|
|
2124 |
* -------------------------------------------- |
* -------------------------------------------- |
2125 |
* put a limit to the maximum number of couples |
* put a limit to the maximum number of couples |
2157 |
do ip2=(ip1+1),nplanes !loop on planes - COPPIA 2 |
do ip2=(ip1+1),nplanes !loop on planes - COPPIA 2 |
2158 |
if( mask_view(nviewx(ip2)).ne.0 .or. |
if( mask_view(nviewx(ip2)).ne.0 .or. |
2159 |
$ mask_view(nviewy(ip2)).ne.0 )goto 20 !skip plane |
$ mask_view(nviewy(ip2)).ne.0 )goto 20 !skip plane |
2160 |
do is2=1,2 !loop on sensors -ndblt COPPIA 2 |
do is2=1,2 !loop on sensors -ndblt COPPIA 2 |
|
|
|
2161 |
do icp2=1,ncp_plane(ip2) !loop on COPPIA 2 |
do icp2=1,ncp_plane(ip2) !loop on COPPIA 2 |
2162 |
icx2=clx(ip2,icp2) |
icx2=clx(ip2,icp2) |
2163 |
icy2=cly(ip2,icp2) |
icy2=cly(ip2,icp2) |
2176 |
* (2 couples needed) |
* (2 couples needed) |
2177 |
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
2178 |
if(ndblt.eq.ndblt_max)then |
if(ndblt.eq.ndblt_max)then |
2179 |
if(verbose)print*, |
if(verbose.eq.1)print*, |
2180 |
$ '** warning ** number of identified '// |
$ '** warning ** number of identified '// |
2181 |
$ 'doublets exceeds vector dimention ' |
$ 'doublets exceeds vector dimention ' |
2182 |
$ ,'( ',ndblt_max,' )' |
$ ,'( ',ndblt_max,' )' |
2256 |
* (3 couples needed) |
* (3 couples needed) |
2257 |
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
2258 |
if(ntrpt.eq.ntrpt_max)then |
if(ntrpt.eq.ntrpt_max)then |
2259 |
if(verbose)print*, |
if(verbose.eq.1)print*, |
2260 |
$ '** warning ** number of identified '// |
$ '** warning ** number of identified '// |
2261 |
$ 'triplets exceeds vector dimention ' |
$ 'triplets exceeds vector dimention ' |
2262 |
$ ,'( ',ntrpt_max,' )' |
$ ,'( ',ntrpt_max,' )' |
2318 |
10 continue |
10 continue |
2319 |
enddo !end loop on planes - COPPIA 1 |
enddo !end loop on planes - COPPIA 1 |
2320 |
|
|
2321 |
if(DEBUG)then |
if(DEBUG.EQ.1)then |
2322 |
print*,'--- doublets ',ndblt |
print*,'--- doublets ',ndblt |
2323 |
print*,'--- triplets ',ntrpt |
print*,'--- triplets ',ntrpt |
2324 |
endif |
endif |
2365 |
integer cp_useds1(ncouplemaxtot) ! sensor 1 |
integer cp_useds1(ncouplemaxtot) ! sensor 1 |
2366 |
integer cp_useds2(ncouplemaxtot) ! sensor 2 |
integer cp_useds2(ncouplemaxtot) ! sensor 2 |
2367 |
|
|
2368 |
|
if(DEBUG.EQ.1)print*,'doub_to_YZcloud:' |
2369 |
|
|
2370 |
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
2371 |
* classification of DOUBLETS |
* classification of DOUBLETS |
2492 |
* >>> NEW CLOUD <<< |
* >>> NEW CLOUD <<< |
2493 |
|
|
2494 |
if(nclouds_yz.ge.ncloyz_max)then |
if(nclouds_yz.ge.ncloyz_max)then |
2495 |
if(verbose)print*, |
if(verbose.eq.1)print*, |
2496 |
$ '** warning ** number of identified '// |
$ '** warning ** number of identified '// |
2497 |
$ 'YZ clouds exceeds vector dimention ' |
$ 'YZ clouds exceeds vector dimention ' |
2498 |
$ ,'( ',ncloyz_max,' )' |
$ ,'( ',ncloyz_max,' )' |
2520 |
c print*,'>> ',ipt,db_all(ipt) |
c print*,'>> ',ipt,db_all(ipt) |
2521 |
enddo |
enddo |
2522 |
npt_tot=npt_tot+npt |
npt_tot=npt_tot+npt |
2523 |
if(DEBUG)then |
if(DEBUG.EQ.1)then |
2524 |
print*,'-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~' |
print*,'-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~' |
2525 |
print*,'>>>> cloud ',nclouds_yz,' --- ',npt,' points' |
print*,'>>>> cloud ',nclouds_yz,' --- ',npt,' points' |
2526 |
print*,'- alfayz1 ',alfayz1_av(nclouds_yz) |
print*,'- alfayz1 ',alfayz1_av(nclouds_yz) |
2527 |
print*,'- alfayz2 ',alfayz2_av(nclouds_yz) |
print*,'- alfayz2 ',alfayz2_av(nclouds_yz) |
2528 |
print*,'cp_useds1 ',(cp_useds1(icp),icp=1,ncp_tot) |
print*,'cp_useds1 ',(cp_useds1(icp),icp=1,ncp_tot) |
2529 |
print*,'cp_useds2 ',(cp_useds2(icp),icp=1,ncp_tot) |
print*,'cp_useds2 ',(cp_useds2(icp),icp=1,ncp_tot) |
2530 |
print*,'hit_plane ',(hit_plane(ip),ip=1,nplanes) |
print*,'cpcloud_yz ' |
2531 |
|
$ ,(cpcloud_yz(nclouds_yz,icp),icp=1,ncp_tot) |
2532 |
|
print*,'hit_plane ',(hit_plane(ip),ip=1,nplanes) |
2533 |
c$$$ print*,'nt-uple: ptcloud_yz(',nclouds_yz,') = ' |
c$$$ print*,'nt-uple: ptcloud_yz(',nclouds_yz,') = ' |
2534 |
c$$$ $ ,ptcloud_yz(nclouds_yz) |
c$$$ $ ,ptcloud_yz(nclouds_yz) |
2535 |
c$$$ print*,'nt-uple: db_cloud(...) = ' |
c$$$ print*,'nt-uple: db_cloud(...) = ' |
2547 |
goto 90 |
goto 90 |
2548 |
endif |
endif |
2549 |
|
|
2550 |
if(DEBUG)then |
if(DEBUG.EQ.1)then |
2551 |
print*,'---------------------- ' |
print*,'---------------------- ' |
2552 |
print*,'Y-Z total clouds ',nclouds_yz |
print*,'Y-Z total clouds ',nclouds_yz |
2553 |
print*,' ' |
print*,' ' |
2596 |
integer cp_useds1(ncouplemaxtot) ! sensor 1 |
integer cp_useds1(ncouplemaxtot) ! sensor 1 |
2597 |
integer cp_useds2(ncouplemaxtot) ! sensor 2 |
integer cp_useds2(ncouplemaxtot) ! sensor 2 |
2598 |
|
|
2599 |
|
if(DEBUG.EQ.1)print*,'trip_to_XZcloud:' |
2600 |
|
|
2601 |
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
2602 |
* classification of TRIPLETS |
* classification of TRIPLETS |
2603 |
* according to distance in parameter space |
* according to distance in parameter space |
2655 |
$ +((alfaxz2(itrref)-alfaxz2(itr2))/Dalfaxz2)**2 |
$ +((alfaxz2(itrref)-alfaxz2(itr2))/Dalfaxz2)**2 |
2656 |
distance = sqrt(distance) |
distance = sqrt(distance) |
2657 |
|
|
2658 |
if(distance.lt.cutdistxz)then |
* ------------------------------------------------------------------------ |
2659 |
|
* FORCE INCLUSION OF TRIPLETS COMPOSED BY SAME COUPLES, IGNORING THE IMAGE |
2660 |
|
* ------------------------------------------------------------------------ |
2661 |
|
* (added in august 2007) |
2662 |
|
istrimage=0 |
2663 |
|
if( |
2664 |
|
$ abs(cpxz1(itrref)).eq.abs(cpxz1(itr2)).and. |
2665 |
|
$ abs(cpxz2(itrref)).eq.abs(cpxz2(itr2)).and. |
2666 |
|
$ abs(cpxz3(itrref)).eq.abs(cpxz3(itr2)).and. |
2667 |
|
$ .true.)istrimage=1 |
2668 |
|
|
2669 |
|
if(distance.lt.cutdistxz.or.istrimage.eq.1)then |
2670 |
c print*,idb1,idb2,distance,' cloud ',nclouds_yz |
c print*,idb1,idb2,distance,' cloud ',nclouds_yz |
2671 |
if(cpxz1(itr2).gt.0)cp_useds2(cpxz1(itr2))=1 |
if(cpxz1(itr2).gt.0)cp_useds2(cpxz1(itr2))=1 |
2672 |
if(cpxz1(itr2).lt.0)cp_useds1(-cpxz1(itr2))=1 |
if(cpxz1(itr2).lt.0)cp_useds1(-cpxz1(itr2))=1 |
2730 |
* ~~~~~~~~~~~~~~~~~ |
* ~~~~~~~~~~~~~~~~~ |
2731 |
* >>> NEW CLOUD <<< |
* >>> NEW CLOUD <<< |
2732 |
if(nclouds_xz.ge.ncloxz_max)then |
if(nclouds_xz.ge.ncloxz_max)then |
2733 |
if(verbose)print*, |
if(verbose.eq.1)print*, |
2734 |
$ '** warning ** number of identified '// |
$ '** warning ** number of identified '// |
2735 |
$ 'XZ clouds exceeds vector dimention ' |
$ 'XZ clouds exceeds vector dimention ' |
2736 |
$ ,'( ',ncloxz_max,' )' |
$ ,'( ',ncloxz_max,' )' |
2757 |
enddo |
enddo |
2758 |
npt_tot=npt_tot+npt |
npt_tot=npt_tot+npt |
2759 |
|
|
2760 |
if(DEBUG)then |
if(DEBUG.EQ.1)then |
2761 |
print*,'-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~' |
print*,'-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~' |
2762 |
print*,'>>>> cloud ',nclouds_xz,' --- ',npt,' points' |
print*,'>>>> cloud ',nclouds_xz,' --- ',npt,' points' |
2763 |
print*,'- alfaxz1 ',alfaxz1_av(nclouds_xz) |
print*,'- alfaxz1 ',alfaxz1_av(nclouds_xz) |
2764 |
print*,'- alfaxz2 ',alfaxz2_av(nclouds_xz) |
print*,'- alfaxz2 ',alfaxz2_av(nclouds_xz) |
2765 |
print*,'- alfaxz3 ',alfaxz3_av(nclouds_xz) |
print*,'- alfaxz3 ',alfaxz3_av(nclouds_xz) |
2766 |
print*,'cp_useds1 ',(cp_useds1(icp),icp=1,ncp_tot) |
print*,'cp_useds1 ',(cp_useds1(icp),icp=1,ncp_tot) |
2767 |
print*,'cp_useds2 ',(cp_useds2(icp),icp=1,ncp_tot) |
print*,'cp_useds2 ',(cp_useds2(icp),icp=1,ncp_tot) |
2768 |
|
print*,'cpcloud_xz ' |
2769 |
|
$ ,(cpcloud_xz(nclouds_xz,icp),icp=1,ncp_tot) |
2770 |
print*,'hit_plane ',(hit_plane(ip),ip=1,nplanes) |
print*,'hit_plane ',(hit_plane(ip),ip=1,nplanes) |
2771 |
c$$$ print*,'nt-uple: ptcloud_xz(',nclouds_xz,') = ' |
c$$$ print*,'nt-uple: ptcloud_xz(',nclouds_xz,') = ' |
2772 |
c$$$ $ ,ptcloud_xz(nclouds_xz) |
c$$$ $ ,ptcloud_xz(nclouds_xz) |
2784 |
goto 91 |
goto 91 |
2785 |
endif |
endif |
2786 |
|
|
2787 |
if(DEBUG)then |
if(DEBUG.EQ.1)then |
2788 |
print*,'---------------------- ' |
print*,'---------------------- ' |
2789 |
print*,'X-Z total clouds ',nclouds_xz |
print*,'X-Z total clouds ',nclouds_xz |
2790 |
print*,' ' |
print*,' ' |
2836 |
* ----------------------------------------------------------- |
* ----------------------------------------------------------- |
2837 |
* variables for track fitting |
* variables for track fitting |
2838 |
double precision AL_INI(5) |
double precision AL_INI(5) |
|
c double precision tath |
|
2839 |
* ----------------------------------------------------------- |
* ----------------------------------------------------------- |
|
c real fitz(nplanes) !z coordinates of the planes in cm |
|
2840 |
|
|
2841 |
|
if(DEBUG.EQ.1)print*,'clouds_to_ctrack:' |
2842 |
|
|
2843 |
|
|
2844 |
ntracks=0 !counter of track candidates |
ntracks=0 !counter of track candidates |
2860 |
enddo |
enddo |
2861 |
enddo |
enddo |
2862 |
ncp_ok=0 |
ncp_ok=0 |
2863 |
do icp=1,ncp_tot !loop on couples |
do icp=1,ncp_tot !loop over couples |
2864 |
* get info on |
* get info on |
2865 |
cpintersec(icp)=min( |
cpintersec(icp)=min( |
2866 |
$ cpcloud_yz(iyz,icp), |
$ cpcloud_yz(iyz,icp), |
2869 |
$ (cpcloud_yz(iyz,icp).eq.1.and.cpcloud_xz(ixz,icp).eq.2).or. |
$ (cpcloud_yz(iyz,icp).eq.1.and.cpcloud_xz(ixz,icp).eq.2).or. |
2870 |
$ (cpcloud_yz(iyz,icp).eq.2.and.cpcloud_xz(ixz,icp).eq.1).or. |
$ (cpcloud_yz(iyz,icp).eq.2.and.cpcloud_xz(ixz,icp).eq.1).or. |
2871 |
$ .false.)cpintersec(icp)=0 |
$ .false.)cpintersec(icp)=0 |
2872 |
|
* cpintersec is >0 if yz and xz clouds contain the same image of couple icp |
2873 |
if(cpintersec(icp).ne.0)then |
if(cpintersec(icp).ne.0)then |
2874 |
ncp_ok=ncp_ok+1 |
ncp_ok=ncp_ok+1 |
2875 |
|
|
2902 |
nplused=nplused+ hit_plane(ip) |
nplused=nplused+ hit_plane(ip) |
2903 |
enddo |
enddo |
2904 |
|
|
|
c if(nplused.lt.nplxz_min)goto 888 !next doublet |
|
|
if(nplused.lt.nplyz_min)goto 888 !next doublet |
|
|
if(ncp_ok.lt.ncpok)goto 888 !next cloud |
|
2905 |
|
|
2906 |
if(DEBUG)then |
if(DEBUG.EQ.1)then |
2907 |
print*,'Combination ',iyz,ixz |
print*,'Combination ',iyz,ixz |
2908 |
$ ,' db ',ptcloud_yz(iyz) |
$ ,' db ',ptcloud_yz(iyz) |
2909 |
$ ,' tr ',ptcloud_xz(ixz) |
$ ,' tr ',ptcloud_xz(ixz) |
2910 |
$ ,' -----> # matching couples ',ncp_ok |
$ ,' -----> # matching couples ',ncp_ok |
2911 |
endif |
endif |
2912 |
|
|
2913 |
|
c if(nplused.lt.nplxz_min)goto 888 !next combination |
2914 |
|
if(nplused.lt.nplyz_min)goto 888 !next combination |
2915 |
|
if(ncp_ok.lt.ncpok)goto 888 !next combination |
2916 |
|
|
2917 |
c$$$ print*,'~~~~~~~~~~~~~~~~~~~~~~~~~' |
c$$$ print*,'~~~~~~~~~~~~~~~~~~~~~~~~~' |
2918 |
c$$$ print*,'Configurazione cluster XZ' |
c$$$ print*,'Configurazione cluster XZ' |
2919 |
c$$$ print*,'1 -- ',(clx(1,i),i=1,ncp_plane(1)) |
c$$$ print*,'1 -- ',(clx(1,i),i=1,ncp_plane(1)) |
2959 |
c$$$ |
c$$$ |
2960 |
c$$$ if(AL_INI(5).gt.defmax)goto 888 !next cloud |
c$$$ if(AL_INI(5).gt.defmax)goto 888 !next cloud |
2961 |
|
|
2962 |
if(DEBUG)then |
if(DEBUG.EQ.1)then |
2963 |
|
print*,'track candidate', ntracks+1 |
2964 |
print*,'1 >>> ',(cp_match(6,i),i=1,ncp_match(6)) |
print*,'1 >>> ',(cp_match(6,i),i=1,ncp_match(6)) |
2965 |
print*,'2 >>> ',(cp_match(5,i),i=1,ncp_match(5)) |
print*,'2 >>> ',(cp_match(5,i),i=1,ncp_match(5)) |
2966 |
print*,'3 >>> ',(cp_match(4,i),i=1,ncp_match(4)) |
print*,'3 >>> ',(cp_match(4,i),i=1,ncp_match(4)) |
2993 |
hit_plane(6)=icp6 |
hit_plane(6)=icp6 |
2994 |
if(ncp_match(6).eq.0)hit_plane(6)=0 !-icp6 |
if(ncp_match(6).eq.0)hit_plane(6)=0 !-icp6 |
2995 |
|
|
2996 |
|
* --------------------------------------- |
2997 |
|
* check if this group of couples has been |
2998 |
|
* already fitted |
2999 |
|
* --------------------------------------- |
3000 |
|
do ica=1,ntracks |
3001 |
|
isthesame=1 |
3002 |
|
do ip=1,NPLANES |
3003 |
|
if(hit_plane(ip).ne.0)then |
3004 |
|
if( CP_STORE(nplanes-ip+1,ica) |
3005 |
|
$ .ne. |
3006 |
|
$ cp_match(ip,hit_plane(ip)) ) |
3007 |
|
$ isthesame=0 |
3008 |
|
else |
3009 |
|
if( CP_STORE(nplanes-ip+1,ica) |
3010 |
|
$ .ne. |
3011 |
|
$ 0 ) |
3012 |
|
$ isthesame=0 |
3013 |
|
endif |
3014 |
|
enddo |
3015 |
|
if(isthesame.eq.1)then |
3016 |
|
if(DEBUG.eq.1) |
3017 |
|
$ print*,'(already fitted)' |
3018 |
|
goto 666 !jump to next combination |
3019 |
|
endif |
3020 |
|
enddo |
3021 |
|
|
3022 |
call track_init !init TRACK common |
call track_init !init TRACK common |
3023 |
|
|
3024 |
do ip=1,nplanes !loop on planes |
do ip=1,nplanes !loop on planes (bottom to top) |
3025 |
if(hit_plane(ip).ne.0)then |
if(hit_plane(ip).ne.0)then |
3026 |
id=cp_match(ip,hit_plane(ip)) |
id=cp_match(ip,hit_plane(ip)) |
3027 |
is=is_cp(id) |
is=is_cp(id) |
3065 |
ifail=0 !error flag in chi^2 computation |
ifail=0 !error flag in chi^2 computation |
3066 |
jstep=0 !number of minimization steps |
jstep=0 !number of minimization steps |
3067 |
iprint=0 |
iprint=0 |
3068 |
c if(DEBUG)iprint=1 |
c if(DEBUG.EQ.1)iprint=1 |
3069 |
if(DEBUG)iprint=2 |
if(DEBUG.EQ.1)iprint=2 |
3070 |
call mini2(jstep,ifail,iprint) |
call mini2(jstep,ifail,iprint) |
3071 |
if(ifail.ne.0) then |
if(ifail.ne.0) then |
3072 |
if(DEBUG)then |
if(DEBUG.EQ.1)then |
3073 |
print *, |
print *, |
3074 |
$ '*** MINIMIZATION FAILURE *** ' |
$ '*** MINIMIZATION FAILURE *** ' |
3075 |
$ //'(clouds_to_ctrack)' |
$ //'(clouds_to_ctrack)' |
3094 |
* -------------------------- |
* -------------------------- |
3095 |
if(ntracks.eq.NTRACKSMAX)then |
if(ntracks.eq.NTRACKSMAX)then |
3096 |
|
|
3097 |
if(verbose)print*, |
if(verbose.eq.1)print*, |
3098 |
$ '** warning ** number of candidate tracks '// |
$ '** warning ** number of candidate tracks '// |
3099 |
$ ' exceeds vector dimension ' |
$ ' exceeds vector dimension ' |
3100 |
$ ,'( ',NTRACKSMAX,' )' |
$ ,'( ',NTRACKSMAX,' )' |
3110 |
|
|
3111 |
ntracks = ntracks + 1 |
ntracks = ntracks + 1 |
3112 |
|
|
3113 |
do ip=1,nplanes |
do ip=1,nplanes !top to bottom |
3114 |
|
|
3115 |
XV_STORE(ip,ntracks)=sngl(xv(ip)) |
XV_STORE(ip,ntracks)=sngl(xv(ip)) |
3116 |
YV_STORE(ip,ntracks)=sngl(yv(ip)) |
YV_STORE(ip,ntracks)=sngl(yv(ip)) |
3127 |
AYV_STORE(ip,ntracks)=sngl(ayv(ip)) |
AYV_STORE(ip,ntracks)=sngl(ayv(ip)) |
3128 |
XGOOD_STORE(ip,ntracks)=sngl(xgood(ip)) |
XGOOD_STORE(ip,ntracks)=sngl(xgood(ip)) |
3129 |
YGOOD_STORE(ip,ntracks)=sngl(ygood(ip)) |
YGOOD_STORE(ip,ntracks)=sngl(ygood(ip)) |
3130 |
|
* NB! hit_plane is defined from bottom to top |
3131 |
if(hit_plane(ip).ne.0)then |
if(hit_plane(ip).ne.0)then |
3132 |
CP_STORE(nplanes-ip+1,ntracks)= |
CP_STORE(nplanes-ip+1,ntracks)= |
3133 |
$ cp_match(ip,hit_plane(ip)) |
$ cp_match(ip,hit_plane(ip)) |
3143 |
SENSOR_STORE(nplanes-ip+1,ntracks)=0 |
SENSOR_STORE(nplanes-ip+1,ntracks)=0 |
3144 |
LADDER_STORE(nplanes-ip+1,ntracks)=0 |
LADDER_STORE(nplanes-ip+1,ntracks)=0 |
3145 |
endif |
endif |
3146 |
BX_STORE(nplanes-ip+1,ntracks)=0!I dont need it now |
BX_STORE(ip,ntracks)=0!I dont need it now |
3147 |
BY_STORE(nplanes-ip+1,ntracks)=0!I dont need it now |
BY_STORE(ip,ntracks)=0!I dont need it now |
3148 |
CLS_STORE(nplanes-ip+1,ntracks)=0 |
CLS_STORE(ip,ntracks)=0 |
3149 |
do i=1,5 |
do i=1,5 |
3150 |
AL_STORE(i,ntracks)=sngl(AL(i)) |
AL_STORE(i,ntracks)=sngl(AL(i)) |
3151 |
enddo |
enddo |
3174 |
return |
return |
3175 |
endif |
endif |
3176 |
|
|
3177 |
c$$$ if(DEBUG)then |
c$$$ if(DEBUG.EQ.1)then |
3178 |
c$$$ print*,'****** TRACK CANDIDATES ***********' |
c$$$ print*,'****** TRACK CANDIDATES ***********' |
3179 |
c$$$ print*,'# R. chi2 RIG' |
c$$$ print*,'# R. chi2 RIG' |
3180 |
c$$$ do i=1,ntracks |
c$$$ do i=1,ntracks |
3183 |
c$$$ enddo |
c$$$ enddo |
3184 |
c$$$ print*,'***********************************' |
c$$$ print*,'***********************************' |
3185 |
c$$$ endif |
c$$$ endif |
3186 |
if(DEBUG)then |
if(DEBUG.EQ.1)then |
3187 |
print*,'****** TRACK CANDIDATES *****************' |
print*,'****** TRACK CANDIDATES *****************' |
3188 |
print*,'# R. chi2 RIG ndof' |
print*,'# R. chi2 RIG ndof' |
3189 |
do i=1,ntracks |
do i=1,ntracks |
3235 |
real xyzp(3),bxyz(3) |
real xyzp(3),bxyz(3) |
3236 |
equivalence (xp,xyzp(1)),(yp,xyzp(2)),(zp,xyzp(3)) |
equivalence (xp,xyzp(1)),(yp,xyzp(2)),(zp,xyzp(3)) |
3237 |
|
|
3238 |
|
if(DEBUG.EQ.1)print*,'refine_track:' |
3239 |
* ================================================= |
* ================================================= |
3240 |
* new estimate of positions using ETA algorithm |
* new estimate of positions using ETA algorithm |
3241 |
* and |
* and |
3317 |
LADDER_STORE(nplanes-ip+1,IBEST)=nldt |
LADDER_STORE(nplanes-ip+1,IBEST)=nldt |
3318 |
* -------------------------------------------------------------- |
* -------------------------------------------------------------- |
3319 |
|
|
3320 |
if(DEBUG)then |
if(DEBUG.EQ.1)then |
3321 |
print*, |
print*, |
3322 |
$ '------ Plane ',ip,' intersected on LADDER ',nldt |
$ '------ Plane ',ip,' intersected on LADDER ',nldt |
3323 |
$ ,' SENSOR ',ist |
$ ,' SENSOR ',ist |
3328 |
* =========================================== |
* =========================================== |
3329 |
* STEP 1 >>>>>>> try to include a new couple |
* STEP 1 >>>>>>> try to include a new couple |
3330 |
* =========================================== |
* =========================================== |
3331 |
c if(DEBUG)print*,'>>>> try to include a new couple' |
c if(DEBUG.EQ.1)print*,'>>>> try to include a new couple' |
3332 |
distmin=1000000. |
distmin=1000000. |
3333 |
xmm = 0. |
xmm = 0. |
3334 |
ymm = 0. |
ymm = 0. |
3360 |
distance = distance_to(XP,YP) |
distance = distance_to(XP,YP) |
3361 |
c distance = distance / RCHI2_STORE(ibest)!<<< MS !QUIQUI |
c distance = distance / RCHI2_STORE(ibest)!<<< MS !QUIQUI |
3362 |
id=id_cp(ip,icp,ist) |
id=id_cp(ip,icp,ist) |
3363 |
if(DEBUG)print*,'( couple ',id |
if(DEBUG.EQ.1)print*,'( couple ',id |
3364 |
$ ,' ) distance ',distance |
$ ,' ) distance ',distance |
3365 |
if(distance.lt.distmin)then |
if(distance.lt.distmin)then |
3366 |
xmm = xPAM |
xmm = xPAM |
3392 |
dedxtrk_y(nplanes-ip+1) = dedxmmy !<<< |
dedxtrk_y(nplanes-ip+1) = dedxmmy !<<< |
3393 |
* ----------------------------------- |
* ----------------------------------- |
3394 |
CP_STORE(nplanes-ip+1,ibest)=idm |
CP_STORE(nplanes-ip+1,ibest)=idm |
3395 |
if(DEBUG)print*,'%%%% included couple ',idm |
if(DEBUG.EQ.1)print*,'%%%% included couple ',idm |
3396 |
$ ,' (dist.= ',distmin,', cut ',clinc,' )' |
$ ,' (dist.= ',distmin,', cut ',clinc,' )' |
3397 |
goto 133 !next plane |
goto 133 !next plane |
3398 |
endif |
endif |
3400 |
* STEP 2 >>>>>>> try to include a single cluster |
* STEP 2 >>>>>>> try to include a single cluster |
3401 |
* either from a couple or single |
* either from a couple or single |
3402 |
* ================================================ |
* ================================================ |
3403 |
c if(DEBUG)print*,'>>>> try to include a new cluster' |
c if(DEBUG.EQ.1)print*,'>>>> try to include a new cluster' |
3404 |
distmin=1000000. |
distmin=1000000. |
3405 |
xmm_A = 0. !--------------------------- |
xmm_A = 0. !--------------------------- |
3406 |
ymm_A = 0. ! init variables that |
ymm_A = 0. ! init variables that |
3437 |
$ ) |
$ ) |
3438 |
distance = distance_to(XP,YP) |
distance = distance_to(XP,YP) |
3439 |
c distance = distance / RCHI2_STORE(ibest)!<<< MS !QUIQUI |
c distance = distance / RCHI2_STORE(ibest)!<<< MS !QUIQUI |
3440 |
if(DEBUG)print*,'( cl-X ',icx |
if(DEBUG.EQ.1)print*,'( cl-X ',icx |
3441 |
$ ,' in cp ',id,' ) distance ',distance |
$ ,' in cp ',id,' ) distance ',distance |
3442 |
if(distance.lt.distmin)then |
if(distance.lt.distmin)then |
3443 |
xmm_A = xPAM_A |
xmm_A = xPAM_A |
3470 |
$ ) |
$ ) |
3471 |
distance = distance_to(XP,YP) |
distance = distance_to(XP,YP) |
3472 |
c distance = distance / RCHI2_STORE(ibest)!<<< MS !QUIQUI |
c distance = distance / RCHI2_STORE(ibest)!<<< MS !QUIQUI |
3473 |
if(DEBUG)print*,'( cl-Y ',icy |
if(DEBUG.EQ.1)print*,'( cl-Y ',icy |
3474 |
$ ,' in cp ',id,' ) distance ',distance |
$ ,' in cp ',id,' ) distance ',distance |
3475 |
if(distance.lt.distmin)then |
if(distance.lt.distmin)then |
3476 |
xmm_A = xPAM_A |
xmm_A = xPAM_A |
3515 |
|
|
3516 |
distance = distance_to(XP,YP) |
distance = distance_to(XP,YP) |
3517 |
c distance = distance / RCHI2_STORE(ibest)!<<< MS !QUIQUI |
c distance = distance / RCHI2_STORE(ibest)!<<< MS !QUIQUI |
3518 |
if(DEBUG)print*,'( cl-s ',icl |
if(DEBUG.EQ.1)print*,'( cl-s ',icl |
3519 |
$ ,' ) distance ',distance,'<',distmin,' ?' |
$ ,' ) distance ',distance |
3520 |
if(distance.lt.distmin)then |
if(distance.lt.distmin)then |
3521 |
if(DEBUG)print*,'YES' |
c if(DEBUG.EQ.1)print*,'YES' |
3522 |
xmm_A = xPAM_A |
xmm_A = xPAM_A |
3523 |
ymm_A = yPAM_A |
ymm_A = yPAM_A |
3524 |
zmm_A = zPAM_A |
zmm_A = zPAM_A |
3564 |
if(mod(VIEW(iclm),2).eq.0)then |
if(mod(VIEW(iclm),2).eq.0)then |
3565 |
XGOOD(nplanes-ip+1)=1. |
XGOOD(nplanes-ip+1)=1. |
3566 |
resx(nplanes-ip+1)=rxmm |
resx(nplanes-ip+1)=rxmm |
3567 |
if(DEBUG)print*,'%%%% included X-cl ',iclm |
if(DEBUG.EQ.1)print*,'%%%% included X-cl ',iclm |
3568 |
$ ,'( chi^2, ',RCHI2_STORE(ibest) |
$ ,'( chi^2, ',RCHI2_STORE(ibest) |
3569 |
$ ,', dist.= ',distmin |
$ ,', dist.= ',distmin |
3570 |
$ ,', cut ',clinc,' )' |
$ ,', cut ',clinc,' )' |
3571 |
else |
else |
3572 |
YGOOD(nplanes-ip+1)=1. |
YGOOD(nplanes-ip+1)=1. |
3573 |
resy(nplanes-ip+1)=rymm |
resy(nplanes-ip+1)=rymm |
3574 |
if(DEBUG)print*,'%%%% included Y-cl ',iclm |
if(DEBUG.EQ.1)print*,'%%%% included Y-cl ',iclm |
3575 |
$ ,'( chi^2, ',RCHI2_STORE(ibest) |
$ ,'( chi^2, ',RCHI2_STORE(ibest) |
3576 |
$ ,', dist.= ', distmin |
$ ,', dist.= ', distmin |
3577 |
$ ,', cut ',clinc,' )' |
$ ,', cut ',clinc,' )' |
3613 |
include 'common_momanhough.f' |
include 'common_momanhough.f' |
3614 |
include 'level2.f' |
include 'level2.f' |
3615 |
|
|
3616 |
|
if(DEBUG.EQ.1)print*,'clean_XYclouds:' |
3617 |
|
|
3618 |
do ip=1,nplanes !loop on planes |
do ip=1,nplanes !loop on planes |
3619 |
|
|
3620 |
id=CP_STORE(nplanes-ip+1,ibest) |
id=CP_STORE(nplanes-ip+1,ibest) |
3623 |
if(id.ne.0)then |
if(id.ne.0)then |
3624 |
iclx=clx(ip,icp_cp(id)) |
iclx=clx(ip,icp_cp(id)) |
3625 |
icly=cly(ip,icp_cp(id)) |
icly=cly(ip,icp_cp(id)) |
3626 |
cl_used(iclx)=ntrk !tag used clusters |
c$$$ cl_used(iclx)=ntrk !tag used clusters |
3627 |
cl_used(icly)=ntrk !tag used clusters |
c$$$ cl_used(icly)=ntrk !tag used clusters |
3628 |
elseif(icl.ne.0)then |
elseif(icl.ne.0)then |
3629 |
cl_used(icl)=ntrk !tag used clusters |
c$$$ cl_used(icl)=ntrk !tag used clusters |
3630 |
endif |
endif |
3631 |
|
|
3632 |
* ----------------------------- |
* ----------------------------- |
3645 |
$ cly(ip,icp).eq.icl |
$ cly(ip,icp).eq.icl |
3646 |
$ )then |
$ )then |
3647 |
id=id_cp(ip,icp,1) |
id=id_cp(ip,icp,1) |
3648 |
if(DEBUG)then |
if(DEBUG.EQ.1)then |
3649 |
print*,ip,' <<< cp ',id |
print*,ip,' <<< cp ',id |
3650 |
$ ,' ( cl-x ' |
$ ,' ( cl-x ' |
3651 |
$ ,clx(ip,icp) |
$ ,clx(ip,icp) |
3905 |
zv_nt(ip,ntr) = sngl(zv(ip)) |
zv_nt(ip,ntr) = sngl(zv(ip)) |
3906 |
axv_nt(ip,ntr) = sngl(axv(ip)) |
axv_nt(ip,ntr) = sngl(axv(ip)) |
3907 |
ayv_nt(ip,ntr) = sngl(ayv(ip)) |
ayv_nt(ip,ntr) = sngl(ayv(ip)) |
3908 |
c l'avevo dimenticato!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
3909 |
factor = sqrt( |
factor = sqrt( |
3910 |
$ tan( acos(-1.) * sngl(axv(ip)) /180. )**2 + |
$ tan( acos(-1.) * sngl(axv(ip)) /180. )**2 + |
3911 |
$ tan( acos(-1.) * sngl(ayv(ip)) /180. )**2 + |
$ tan( acos(-1.) * sngl(ayv(ip)) /180. )**2 + |
3912 |
$ 1. ) |
$ 1. ) |
3913 |
c !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
3914 |
dedx_x(ip,ntr) = sngl(dedxtrk_x(ip)/factor) |
dedx_x(ip,ntr) = sngl(dedxtrk_x(ip)/factor) |
3915 |
dedx_y(ip,ntr) = sngl(dedxtrk_y(ip)/factor) |
dedx_y(ip,ntr) = sngl(dedxtrk_y(ip)/factor) |
3916 |
|
|
3940 |
c >>> is a couple |
c >>> is a couple |
3941 |
cltrx(ip,ntr) = clx(nplanes-ip+1,icp_cp(id)) |
cltrx(ip,ntr) = clx(nplanes-ip+1,icp_cp(id)) |
3942 |
cltry(ip,ntr) = cly(nplanes-ip+1,icp_cp(id)) |
cltry(ip,ntr) = cly(nplanes-ip+1,icp_cp(id)) |
3943 |
|
|
3944 |
|
cl_used(cltrx(ip,ntr)) = 1 !tag used clusters |
3945 |
|
cl_used(cltry(ip,ntr)) = 1 !tag used clusters |
3946 |
|
|
3947 |
c$$$ nnnnx = npfastrips(clx(nplanes-ip+1,icp_cp(id)),PFA,angx) |
c$$$ nnnnx = npfastrips(clx(nplanes-ip+1,icp_cp(id)),PFA,angx) |
3948 |
c$$$ nnnny = npfastrips(cly(nplanes-ip+1,icp_cp(id)),PFA,angy) |
c$$$ nnnny = npfastrips(cly(nplanes-ip+1,icp_cp(id)),PFA,angy) |
3949 |
c$$$ xbad(ip,ntr)= nbadstrips(nnnnx,clx(nplanes-ip+1,icp_cp(id))) |
c$$$ xbad(ip,ntr)= nbadstrips(nnnnx,clx(nplanes-ip+1,icp_cp(id))) |
3959 |
|
|
3960 |
elseif(icl.ne.0)then |
elseif(icl.ne.0)then |
3961 |
|
|
3962 |
|
cl_used(icl) = 1 !tag used clusters |
3963 |
|
|
3964 |
if(mod(VIEW(icl),2).eq.0)then |
if(mod(VIEW(icl),2).eq.0)then |
3965 |
cltrx(ip,ntr)=icl |
cltrx(ip,ntr)=icl |
3966 |
c$$$ nnnnn = npfastrips(icl,PFA,angx) |
c$$$ nnnnn = npfastrips(icl,PFA,angx) |
3980 |
|
|
3981 |
enddo |
enddo |
3982 |
|
|
3983 |
|
if(DEBUG.eq.1)then |
3984 |
|
print*,'> STORING TRACK ',ntr |
3985 |
|
print*,'clusters: ' |
3986 |
|
do ip=1,6 |
3987 |
|
print*,'> ',ip,' -- ',cltrx(ip,ntr),cltry(ip,ntr) |
3988 |
|
enddo |
3989 |
|
endif |
3990 |
|
|
3991 |
c$$$ print*,(xgood(i),i=1,6) |
c$$$ print*,(xgood(i),i=1,6) |
3992 |
c$$$ print*,(ygood(i),i=1,6) |
c$$$ print*,(ygood(i),i=1,6) |
4021 |
good2(iv) = good2(iv) + mask_view(iv)*2**8 |
good2(iv) = good2(iv) + mask_view(iv)*2**8 |
4022 |
enddo |
enddo |
4023 |
|
|
4024 |
|
if(DEBUG.eq.1)then |
4025 |
|
print*,'> STORING SINGLETS ' |
4026 |
|
endif |
4027 |
|
|
4028 |
do icl=1,nclstr1 |
do icl=1,nclstr1 |
4029 |
|
|
4030 |
|
ip=nplanes-npl(VIEW(icl))+1 |
4031 |
|
|
4032 |
if(cl_used(icl).eq.0)then !cluster not included in any track |
if(cl_used(icl).eq.0)then !cluster not included in any track |
|
ip=nplanes-npl(VIEW(icl))+1 |
|
4033 |
if(mod(VIEW(icl),2).eq.0)then !=== X views |
if(mod(VIEW(icl),2).eq.0)then !=== X views |
4034 |
nclsx = nclsx + 1 |
nclsx = nclsx + 1 |
4035 |
planex(nclsx) = ip |
planex(nclsx) = ip |
4069 |
|
|
4070 |
***** LO METTO QUI PERCHE` NON SO DOVE METTERLO |
***** LO METTO QUI PERCHE` NON SO DOVE METTERLO |
4071 |
whichtrack(icl) = cl_used(icl) |
whichtrack(icl) = cl_used(icl) |
4072 |
|
* -------------------------------------------------- |
4073 |
|
* per non perdere la testa... |
4074 |
|
* whichtrack(icl) e` una variabile del common level1 |
4075 |
|
* che serve solo per sapere quali cluster sono stati |
4076 |
|
* associati ad una traccia, e permettere di salvare |
4077 |
|
* solo questi nell'albero di uscita |
4078 |
|
* -------------------------------------------------- |
4079 |
|
|
4080 |
|
|
4081 |
|
c$$$ print*,' cl ',icl,' --> ',cl_used(icl) |
4082 |
|
c$$$ |
4083 |
|
c$$$ if( cl_used(icl).ne.0 )then |
4084 |
|
c$$$ if( |
4085 |
|
c$$$ $ mod(VIEW(icl),2).eq.0.and. |
4086 |
|
c$$$ $ cltrx(ip,whichtrack(icl)).ne.icl ) |
4087 |
|
c$$$ $ print*,'**WARNING** cltrx(',ip,',',whichtrack(icl) |
4088 |
|
c$$$ $ ,')=',cltrx(ip,whichtrack(icl)),'.ne.',icl |
4089 |
|
c$$$ if( |
4090 |
|
c$$$ $ mod(VIEW(icl),2).eq.1.and. |
4091 |
|
c$$$ $ cltry(ip,whichtrack(icl)).ne.icl ) |
4092 |
|
c$$$ $ print*,'**WARNING** cltry(',ip,',',whichtrack(icl) |
4093 |
|
c$$$ $ ,')=',cltry(ip,whichtrack(icl)),'.ne.',icl |
4094 |
|
c$$$ endif |
4095 |
|
|
4096 |
|
|
4097 |
enddo |
enddo |
4098 |
end |
end |