/[PAMELA software]/DarthVader/TrackerLevel2/src/F77/analysissubroutines.f
ViewVC logotype

Diff of /DarthVader/TrackerLevel2/src/F77/analysissubroutines.f

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by pam-fi, Fri Feb 16 14:56:02 2007 UTC revision 1.22 by pam-fi, Wed May 9 07:50:58 2007 UTC
# Line 20  Line 20 
20        include 'calib.f'        include 'calib.f'
21        include 'level2.f'        include 'level2.f'
22    
23  c      include 'momanhough_init.f'  
24    
25    c      print*,'======================================================'
26    c$$$      do ic=1,NCLSTR1
27    c$$$         if(.false.
28    c$$$     $        .or.nsatstrips(ic).gt.0
29    c$$$c     $        .or.nbadstrips(0,ic).gt.0
30    c$$$c     $        .or.nbadstrips(4,ic).gt.0
31    c$$$c     $        .or.nbadstrips(3,ic).gt.0
32    c$$$     $        .or..false.)then
33    c$$$            print*,'--- cl-',ic,' ------------------------'
34    c$$$            istart = INDSTART(IC)
35    c$$$            istop  = TOTCLLENGTH
36    c$$$            if(ic.lt.NCLSTR1)istop=INDSTART(IC+1)-1
37    c$$$            print*,'ADC   ',(CLADC(i),i=istart,istop)
38    c$$$            print*,'s/n   ',(CLSIGNAL(i)/CLSIGMA(i),i=istart,istop)
39    c$$$            print*,'sgnl  ',(CLSIGNAL(i),i=istart,istop)
40    c$$$            print*,'strip ',(i-INDMAX(ic),i=istart,istop)
41    c$$$            print*,'view ',VIEW(ic)
42    c$$$            print*,'maxs ',MAXS(ic)
43    c$$$            print*,'COG4 ',cog(4,ic)
44    c$$$            ff = fbad_cog(4,ic)
45    c$$$            print*,'fbad ',ff
46    c$$$            print*,(CLBAD(i),i=istart,istop)
47    c$$$            bb=nbadstrips(0,ic)
48    c$$$            print*,'#BAD (tot)',bb
49    c$$$            bb=nbadstrips(4,ic)
50    c$$$            print*,'#BAD (4)',bb
51    c$$$            bb=nbadstrips(3,ic)
52    c$$$            print*,'#BAD (3)',bb
53    c$$$            ss=nsatstrips(ic)
54    c$$$            print*,'#saturated ',ss
55    c$$$         endif
56    c$$$      enddo
57                
58  *-------------------------------------------------------------------------------  *-------------------------------------------------------------------------------
59  *     STEP 1  *     STEP 1
# Line 41  c      include 'momanhough_init.f' Line 74  c      include 'momanhough_init.f'
74  *-------------------------------------------------------------------------------  *-------------------------------------------------------------------------------
75  *-------------------------------------------------------------------------------  *-------------------------------------------------------------------------------
76    
77  c      iflag=0  
78        call cl_to_couples(iflag)        call cl_to_couples(iflag)
79        if(iflag.eq.1)then        !bad event        if(iflag.eq.1)then        !bad event
80           goto 880               !go to next event           goto 880               !go to next event
# Line 75  c      iflag=0 Line 108  c      iflag=0
108  *-------------------------------------------------------------------------------  *-------------------------------------------------------------------------------
109  *-------------------------------------------------------------------------------  *-------------------------------------------------------------------------------
110    
111  c      iflag=0  
112        call cp_to_doubtrip(iflag)        call cp_to_doubtrip(iflag)
113        if(iflag.eq.1)then        !bad event        if(iflag.eq.1)then        !bad event
114           goto 880               !go to next event                       goto 880               !go to next event            
# Line 239  c$$$         if(ibest.eq.0)goto 880 !>> Line 272  c$$$         if(ibest.eq.0)goto 880 !>>
272  *     2nd) increasing chi**2  *     2nd) increasing chi**2
273  *     -------------------------------------------------------  *     -------------------------------------------------------
274           rchi2best=1000000000.           rchi2best=1000000000.
275           ndofbest=0             !(1)           ndofbest=0            
276           do i=1,ntracks           do i=1,ntracks
277             ndof=0               !(1)             ndof=0              
278             do ii=1,nplanes      !(1)             do ii=1,nplanes    
279               ndof=ndof          !(1)               ndof=ndof        
280       $            +int(xgood_store(ii,i)) !(1)       $            +int(xgood_store(ii,i))
281       $            +int(ygood_store(ii,i)) !(1)       $            +int(ygood_store(ii,i))
282             enddo                !(1)             enddo              
283             if(ndof.gt.ndofbest)then !(1)             if(ndof.gt.ndofbest)then
284               ibest=i               ibest=i
285               rchi2best=RCHI2_STORE(i)               rchi2best=RCHI2_STORE(i)
286               ndofbest=ndof      !(1)               ndofbest=ndof    
287             elseif(ndof.eq.ndofbest)then !(1)             elseif(ndof.eq.ndofbest)then
288               if(RCHI2_STORE(i).lt.rchi2best.and.               if(RCHI2_STORE(i).lt.rchi2best.and.
289       $            RCHI2_STORE(i).gt.0)then       $            RCHI2_STORE(i).gt.0)then
290                 ibest=i                 ibest=i
291                 rchi2best=RCHI2_STORE(i)                 rchi2best=RCHI2_STORE(i)
292                 ndofbest=ndof    !(1)                 ndofbest=ndof  
293               endif              !(1)               endif            
294             endif             endif
295           enddo           enddo
296    
# Line 298  c$$$         enddo Line 331  c$$$         enddo
331              iimage=0              iimage=0
332           endif           endif
333           if(icand.eq.0)then           if(icand.eq.0)then
334              print*,'HAI FATTO UN CASINO!!!!!! icand = ',icand              if(VERBOSE)then
335       $           ,ibest,iimage                 print*,'HAI FATTO UN CASINO!!!!!! icand = ',icand
336         $              ,ibest,iimage
337                endif
338              return              return
339           endif           endif
340    
# Line 523  c     $        rchi2best.lt.15..and. Line 558  c     $        rchi2best.lt.15..and.
558        include 'commontracker.f'        include 'commontracker.f'
559        include 'level1.f'        include 'level1.f'
560        include 'calib.f'        include 'calib.f'
 c      include 'level1.f'  
561        include 'common_align.f'        include 'common_align.f'
562        include 'common_mech.f'        include 'common_mech.f'
563        include 'common_xyzPAM.f'        include 'common_xyzPAM.f'
 c      include 'common_resxy.f'  
   
 c      logical DEBUG  
 c      common/dbg/DEBUG  
564    
565        integer icx,icy           !X-Y cluster ID        integer icx,icy           !X-Y cluster ID
566        integer sensor        integer sensor
# Line 545  c      common/dbg/DEBUG Line 575  c      common/dbg/DEBUG
575        double precision xrt,yrt,zrt        double precision xrt,yrt,zrt
576        double precision xrt_A,yrt_A,zrt_A        double precision xrt_A,yrt_A,zrt_A
577        double precision xrt_B,yrt_B,zrt_B        double precision xrt_B,yrt_B,zrt_B
 c      double precision xi,yi,zi  
 c      double precision xi_A,yi_A,zi_A  
 c      double precision xi_B,yi_B,zi_B  
578                
579    
580        parameter (ndivx=30)        parameter (ndivx=30)
# Line 565  c      double precision xi_B,yi_B,zi_B Line 592  c      double precision xi_B,yi_B,zi_B
592        yPAM_B = 0.        yPAM_B = 0.
593        zPAM_B = 0.        zPAM_B = 0.
594  c      print*,'## xyz_PAM: ',icx,icy,sensor,PFAx,PFAy,angx,angy  c      print*,'## xyz_PAM: ',icx,icy,sensor,PFAx,PFAy,angx,angy
595    
596  *     -----------------  *     -----------------
597  *     CLUSTER X  *     CLUSTER X
598  *     -----------------  *     -----------------
599    
600        if(icx.ne.0)then        if(icx.ne.0)then
601    
602           viewx = VIEW(icx)           viewx   = VIEW(icx)
603           nldx = nld(MAXS(icx),VIEW(icx))           nldx    = nld(MAXS(icx),VIEW(icx))
604           nplx = npl(VIEW(icx))           nplx    = npl(VIEW(icx))
605           resxPAM = RESXAV           resxPAM = RESXAV
606           stripx = float(MAXS(icx))           stripx  = float(MAXS(icx))
607  *        --------------------------  *        --------------------------
608  *        magnetic-field corrections  *        magnetic-field corrections
609  *        --------------------------  *        --------------------------
 c$$$         print*,nplx,ax,bfy/10.  
610           angtemp  = ax           angtemp  = ax
611           bfytemp  = bfy           bfytemp  = bfy
612           if(nplx.eq.6) angtemp = -1. * ax  *        /////////////////////////////////
613           if(nplx.eq.6) bfytemp = -1. * bfy  *        AAAAHHHHHHHH!!!!!!!!!!!!!!!!!!!!!
614           tgtemp = tan(angtemp*acos(-1.)/180.) + pmuH_h*bfytemp*0.00001  *        *grvzkkjsdgjhhhgngbn###>:(
615           angx = 180.*atan(tgtemp)/acos(-1.)  *        /////////////////////////////////
616           stripx = stripx - 0.5*pmuH_h*bfytemp*0.00001*SiDimZ/pitchX  c         if(nplx.eq.6) angtemp = -1. * ax
617    c         if(nplx.eq.6) bfytemp = -1. * bfy
618             if(viewx.eq.12) angtemp = -1. * ax
619             if(viewx.eq.12) bfytemp = -1. * bfy
620             tgtemp   = tan(angtemp*acos(-1.)/180.) + pmuH_h*bfytemp*0.00001
621             angx     = 180.*atan(tgtemp)/acos(-1.)
622             stripx   = stripx - 0.5*pmuH_h*bfytemp*0.00001*SiDimZ/pitchX
623    c$$$         print*,nplx,ax,bfy/10.
624  c$$$         print*,angx,0.5*pmuH_h*bfytemp*0.00001*SiDimZ/pitchX  c$$$         print*,angx,0.5*pmuH_h*bfytemp*0.00001*SiDimZ/pitchX
625  c$$$         print*,'========================'  c$$$         print*,'========================'
626    c$$$         if(bfy.ne.0.)print*,viewx,'-x- '
627    c$$$     $        ,bfy,-1*0.5*pmuH_h*bfytemp*0.00001*SiDimZ
628  *        --------------------------  *        --------------------------
629    
630    c$$$         print*,'--- x-cl ---'
631    c$$$         istart = INDSTART(ICX)
632    c$$$         istop  = TOTCLLENGTH
633    c$$$         if(icx.lt.NCLSTR1)istop=INDSTART(ICX+1)-1
634    c$$$         print*,(CLSIGNAL(i)/CLSIGMA(i),i=istart,istop)
635    c$$$         print*,(CLSIGNAL(i),i=istart,istop)
636    c$$$         print*,INDMAX(icx)
637    c$$$         print*,cog(4,icx)
638    c$$$         print*,fbad_cog(4,icx)
639            
640    
641           if(PFAx.eq.'COG1')then           if(PFAx.eq.'COG1')then
642              stripx = stripx      
643              resxPAM = resxPAM                stripx  = stripx
644                resxPAM = 1e-4*pitchX/sqrt(12.)!!resxPAM
645    
646           elseif(PFAx.eq.'COG2')then           elseif(PFAx.eq.'COG2')then
647              stripx = stripx + cog(2,icx)              
648                stripx  = stripx + cog(2,icx)            
649                resxPAM = risx_cog(abs(angx))!TEMPORANEO              
650              resxPAM = resxPAM*fbad_cog(2,icx)              resxPAM = resxPAM*fbad_cog(2,icx)
651    
652           elseif(PFAx.eq.'COG3')then           elseif(PFAx.eq.'COG3')then
653              stripx = stripx + cog(3,icx)              
654                stripx  = stripx + cog(3,icx)            
655                resxPAM = risx_cog(abs(angx))!TEMPORANEO                      
656              resxPAM = resxPAM*fbad_cog(3,icx)              resxPAM = resxPAM*fbad_cog(3,icx)
657    
658           elseif(PFAx.eq.'COG4')then           elseif(PFAx.eq.'COG4')then
659  c            print*,'COG4'  
660              stripx = stripx + cog(4,icx)                          stripx  = stripx + cog(4,icx)            
661                resxPAM = risx_cog(abs(angx))!TEMPORANEO                      
662              resxPAM = resxPAM*fbad_cog(4,icx)              resxPAM = resxPAM*fbad_cog(4,icx)
663    
664           elseif(PFAx.eq.'ETA2')then           elseif(PFAx.eq.'ETA2')then
665              stripx = stripx + pfaeta2(icx,angx)            
666              resxPAM = risx_eta2(abs(angx))                                  stripx  = stripx + pfaeta2(icx,angx)          
667                resxPAM = risx_eta2(abs(angx))
668                resxPAM = resxPAM*fbad_cog(2,icx)
669              if(DEBUG.and.fbad_cog(2,icx).ne.1)              if(DEBUG.and.fbad_cog(2,icx).ne.1)
670       $           print*,'BAD icx >>> ',viewx,fbad_cog(2,icx)       $           print*,'BAD icx >>> ',viewx,fbad_cog(2,icx)
671              resxPAM = resxPAM*fbad_cog(2,icx)  
672           elseif(PFAx.eq.'ETA3')then                                   elseif(PFAx.eq.'ETA3')then                        
673              stripx = stripx + pfaeta3(icx,angx)            
674                stripx  = stripx + pfaeta3(icx,angx)          
675              resxPAM = risx_eta3(abs(angx))                                    resxPAM = risx_eta3(abs(angx))                      
676                resxPAM = resxPAM*fbad_cog(3,icx)              
677              if(DEBUG.and.fbad_cog(3,icx).ne.1)                          if(DEBUG.and.fbad_cog(3,icx).ne.1)            
678       $           print*,'BAD icx >>> ',viewx,fbad_cog(3,icx)       $           print*,'BAD icx >>> ',viewx,fbad_cog(3,icx)
679              resxPAM = resxPAM*fbad_cog(3,icx)                
680           elseif(PFAx.eq.'ETA4')then                                   elseif(PFAx.eq.'ETA4')then                        
681              stripx = stripx + pfaeta4(icx,angx)              
682                stripx  = stripx + pfaeta4(icx,angx)            
683              resxPAM = risx_eta4(abs(angx))                                    resxPAM = risx_eta4(abs(angx))                      
684                resxPAM = resxPAM*fbad_cog(4,icx)              
685              if(DEBUG.and.fbad_cog(4,icx).ne.1)                            if(DEBUG.and.fbad_cog(4,icx).ne.1)              
686       $           print*,'BAD icx >>> ',viewx,fbad_cog(4,icx)       $           print*,'BAD icx >>> ',viewx,fbad_cog(4,icx)
687              resxPAM = resxPAM*fbad_cog(4,icx)                
688           elseif(PFAx.eq.'ETA')then             elseif(PFAx.eq.'ETA')then  
689  c            print*,'ETA'  
690              stripx = stripx + pfaeta(icx,angx)                          stripx  = stripx + pfaeta(icx,angx)            
691              resxPAM = ris_eta(icx,angx)                                  resxPAM = ris_eta(icx,angx)                    
692                resxPAM = resxPAM*fbad_eta(icx,angx)            
693              if(DEBUG.and.fbad_cog(2,icx).ne.1)                            if(DEBUG.and.fbad_cog(2,icx).ne.1)              
694       $           print*,'BAD icx >>> ',viewx,fbad_cog(2,icx)       $           print*,'BAD icx >>> ',viewx,fbad_cog(2,icx)
695              resxPAM = resxPAM*fbad_eta(icx,angx)              
696           elseif(PFAx.eq.'COG')then                     elseif(PFAx.eq.'COG')then          
697              stripx = stripx + cog(0,icx)              
698                stripx  = stripx + cog(0,icx)            
699              resxPAM = risx_cog(abs(angx))                                  resxPAM = risx_cog(abs(angx))                    
700              resxPAM = resxPAM*fbad_cog(0,icx)              resxPAM = resxPAM*fbad_cog(0,icx)
701    
702           else           else
703              print*,'*** Non valid p.f.a. (x) --> ',PFAx              if(DEBUG) print*,'*** Non valid p.f.a. (x) --> ',PFAx
704           endif           endif
705    
706  c         print*,'%%%%%%%%%%%%'  
707    *     ======================================
708    *     temporary patch for saturated clusters
709    *     ======================================
710             if( nsatstrips(icx).gt.0 )then
711                stripx  = stripx + cog(4,icx)            
712                resxPAM = pitchX*1e-4/sqrt(12.)
713                cc=cog(4,icx)
714    c$$$            print*,icx,' *** ',cc
715    c$$$            print*,icx,' *** ',resxPAM
716             endif
717    
718        endif        endif
719                
# Line 654  c         print*,'%%%%%%%%%%%%' Line 730  c         print*,'%%%%%%%%%%%%'
730           stripy = float(MAXS(icy))           stripy = float(MAXS(icy))
731    
732           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
733              print*,'xyz_PAM   ***ERROR*** invalid cluster couple!!! '              if(DEBUG) then
734       $           ,icx,icy                 print*,'xyz_PAM   ***ERROR*** invalid cluster couple!!! '
735         $              ,icx,icy
736                endif
737              goto 100              goto 100
738           endif           endif
739  *        --------------------------  *        --------------------------
# Line 664  c         print*,'%%%%%%%%%%%%' Line 742  c         print*,'%%%%%%%%%%%%'
742           tgtemp = tan(ay*acos(-1.)/180.)+pmuH_e*bfx*0.00001                   tgtemp = tan(ay*acos(-1.)/180.)+pmuH_e*bfx*0.00001        
743           angy    = 180.*atan(tgtemp)/acos(-1.)           angy    = 180.*atan(tgtemp)/acos(-1.)
744           stripy = stripy + 0.5*pmuH_e*bfx*0.00001*SiDimZ/pitchY           stripy = stripy + 0.5*pmuH_e*bfx*0.00001*SiDimZ/pitchY
745    c$$$         if(bfx.ne.0.)print*,viewy,'-y- '
746    c$$$     $        ,bfx,0.5*pmuH_e*bfx*0.00001*SiDimZ
747  *        --------------------------  *        --------------------------
748                    
749           if(PFAy.eq.'COG1')then !(1)  c$$$         print*,'--- y-cl ---'
750              stripy = stripy     !(1)  c$$$         istart = INDSTART(ICY)
751              resyPAM = resyPAM   !(1)  c$$$         istop  = TOTCLLENGTH
752    c$$$         if(icy.lt.NCLSTR1)istop=INDSTART(ICY+1)-1
753    c$$$         print*,(CLSIGNAL(i)/CLSIGMA(i),i=istart,istop)
754    c$$$         print*,(CLSIGNAL(i),i=istart,istop)
755    c$$$         print*,INDMAX(icy)
756    c$$$         print*,cog(4,icy)
757    c$$$         print*,fbad_cog(4,icy)
758    
759             if(PFAy.eq.'COG1')then
760    
761                stripy  = stripy    
762                resyPAM = 1e-4*pitchY/sqrt(12.)!resyPAM  
763    
764           elseif(PFAy.eq.'COG2')then           elseif(PFAy.eq.'COG2')then
765              stripy = stripy + cog(2,icy)  
766                stripy  = stripy + cog(2,icy)
767                resyPAM = risy_cog(abs(angy))!TEMPORANEO
768              resyPAM = resyPAM*fbad_cog(2,icy)              resyPAM = resyPAM*fbad_cog(2,icy)
769    
770           elseif(PFAy.eq.'COG3')then           elseif(PFAy.eq.'COG3')then
771              stripy = stripy + cog(3,icy)  
772                stripy  = stripy + cog(3,icy)
773                resyPAM = risy_cog(abs(angy))!TEMPORANEO
774              resyPAM = resyPAM*fbad_cog(3,icy)              resyPAM = resyPAM*fbad_cog(3,icy)
775    
776           elseif(PFAy.eq.'COG4')then           elseif(PFAy.eq.'COG4')then
777              stripy = stripy + cog(4,icy)  
778                stripy  = stripy + cog(4,icy)
779                resyPAM = risy_cog(abs(angy))!TEMPORANEO
780              resyPAM = resyPAM*fbad_cog(4,icy)              resyPAM = resyPAM*fbad_cog(4,icy)
781    
782           elseif(PFAy.eq.'ETA2')then           elseif(PFAy.eq.'ETA2')then
783  c            cog2 = cog(2,icy)  
784  c            etacorr = pfaeta2(cog2,viewy,nldy,angy)              stripy  = stripy + pfaeta2(icy,angy)          
785  c            stripy = stripy + etacorr              resyPAM = risy_eta2(abs(angy))              
             stripy = stripy + pfaeta2(icy,angy)            !(3)  
             resyPAM = risy_eta2(abs(angy))                       !   (4)  
786              resyPAM = resyPAM*fbad_cog(2,icy)              resyPAM = resyPAM*fbad_cog(2,icy)
787              if(DEBUG.and.fbad_cog(2,icy).ne.1)              if(DEBUG.and.fbad_cog(2,icy).ne.1)
788       $           print*,'BAD icy >>> ',viewy,fbad_cog(2,icy)       $           print*,'BAD icy >>> ',viewy,fbad_cog(2,icy)
789           elseif(PFAy.eq.'ETA3')then                         !(3)  
790              stripy = stripy + pfaeta3(icy,angy)            !(3)           elseif(PFAy.eq.'ETA3')then                      
791              resyPAM = resyPAM*fbad_cog(3,icy)               !(3)  
792              if(DEBUG.and.fbad_cog(3,icy).ne.1)              !(3)              stripy  = stripy + pfaeta3(icy,angy)
793       $           print*,'BAD icy >>> ',viewy,fbad_cog(3,icy)!(3)              resyPAM = resyPAM*fbad_cog(3,icy)  
794           elseif(PFAy.eq.'ETA4')then                         !(3)              if(DEBUG.and.fbad_cog(3,icy).ne.1)
795              stripy = stripy + pfaeta4(icy,angy)            !(3)       $           print*,'BAD icy >>> ',viewy,fbad_cog(3,icy)
796              resyPAM = resyPAM*fbad_cog(4,icy)               !(3)  
797              if(DEBUG.and.fbad_cog(4,icy).ne.1)              !(3)           elseif(PFAy.eq.'ETA4')then  
798       $           print*,'BAD icy >>> ',viewy,fbad_cog(4,icy)!(3)  
799           elseif(PFAy.eq.'ETA')then                          !(3)              stripy  = stripy + pfaeta4(icy,angy)
800              stripy = stripy + pfaeta(icy,angy)             !(3)              resyPAM = resyPAM*fbad_cog(4,icy)
801              resyPAM = ris_eta(icy,angy)                     !   (4)              if(DEBUG.and.fbad_cog(4,icy).ne.1)
802  c            resyPAM = resyPAM*fbad_cog(2,icy)              !(3)TEMPORANEO       $           print*,'BAD icy >>> ',viewy,fbad_cog(4,icy)
803              resyPAM = resyPAM*fbad_eta(icy,angy)            !   (4)  
804              if(DEBUG.and.fbad_cog(2,icy).ne.1)              !(3)           elseif(PFAy.eq.'ETA')then
805       $           print*,'BAD icy >>> ',viewy,fbad_cog(2,icy)!(3)  
806                stripy  = stripy + pfaeta(icy,angy)
807                resyPAM = ris_eta(icy,angy)  
808                resyPAM = resyPAM*fbad_eta(icy,angy)
809                if(DEBUG.and.fbad_cog(2,icy).ne.1)
810         $           print*,'BAD icy >>> ',viewy,fbad_cog(2,icy)
811    
812           elseif(PFAy.eq.'COG')then           elseif(PFAy.eq.'COG')then
813              stripy = stripy + cog(0,icy)              
814              resyPAM = risy_cog(abs(angy))                        !   (4)              stripy  = stripy + cog(0,icy)            
815  c            resyPAM = ris_eta(icy,angy)                    !   (4)              resyPAM = risy_cog(abs(angy))
816              resyPAM = resyPAM*fbad_cog(0,icy)              resyPAM = resyPAM*fbad_cog(0,icy)
817    
818           else           else
819              print*,'*** Non valid p.f.a. (x) --> ',PFAx              if(DEBUG) print*,'*** Non valid p.f.a. (x) --> ',PFAx
820             endif
821    
822    
823    *     ======================================
824    *     temporary patch for saturated clusters
825    *     ======================================
826             if( nsatstrips(icy).gt.0 )then
827                stripy  = stripy + cog(4,icy)            
828                resyPAM = pitchY*1e-4/sqrt(12.)
829                cc=cog(4,icy)
830    c$$$            print*,icy,' *** ',cc
831    c$$$            print*,icy,' *** ',resyPAM
832           endif           endif
833    
834    
835        endif        endif
836    
837  c      print*,'## stripx,stripy ',stripx,stripy  c      print*,'## stripx,stripy ',stripx,stripy
# Line 727  c     (xi,yi,zi) = mechanical coordinate Line 846  c     (xi,yi,zi) = mechanical coordinate
846  c------------------------------------------------------------------------  c------------------------------------------------------------------------
847           if(((mod(int(stripx+0.5)-1,1024)+1).le.3)           if(((mod(int(stripx+0.5)-1,1024)+1).le.3)
848       $        .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...
849              print*,'xyz_PAM (couple):',              if(DEBUG) then
850       $          ' WARNING: false X strip: strip ',stripx                 print*,'xyz_PAM (couple):',
851         $              ' WARNING: false X strip: strip ',stripx
852                endif
853           endif           endif
854           xi = acoordsi(stripx,viewx)           xi = acoordsi(stripx,viewx)
855           yi = acoordsi(stripy,viewy)           yi = acoordsi(stripy,viewy)
# Line 820  c            print*,'X-singlet ',icx,npl Line 941  c            print*,'X-singlet ',icx,npl
941  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...
942              if(((mod(int(stripx+0.5)-1,1024)+1).le.3)              if(((mod(int(stripx+0.5)-1,1024)+1).le.3)
943       $           .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...
944                 print*,'xyz_PAM (X-singlet):',                 if(DEBUG) then
945       $             ' WARNING: false X strip: strip ',stripx                    print*,'xyz_PAM (X-singlet):',
946         $                 ' WARNING: false X strip: strip ',stripx
947                   endif
948              endif              endif
949              xi   = acoordsi(stripx,viewx)              xi   = acoordsi(stripx,viewx)
950    
# Line 843  c            print*,'X-cl ',icx,stripx,' Line 966  c            print*,'X-cl ',icx,stripx,'
966  c            print*,yi_A,' <--> ',yi_B  c            print*,yi_A,' <--> ',yi_B
967    
968           else           else
969                if(DEBUG) then
970              print *,'routine xyz_PAM ---> not properly used !!!'                 print *,'routine xyz_PAM ---> not properly used !!!'
971              print *,'icx = ',icx                 print *,'icx = ',icx
972              print *,'icy = ',icy                 print *,'icy = ',icy
973                endif
974              goto 100              goto 100
975                            
976           endif           endif
# Line 911  c--------------------------------------- Line 1035  c---------------------------------------
1035  c         print*,'A-(',xPAM_A,yPAM_A,') B-(',xPAM_B,yPAM_B,')'  c         print*,'A-(',xPAM_A,yPAM_A,') B-(',xPAM_B,yPAM_B,')'
1036    
1037        else        else
1038                       if(DEBUG) then
1039           print *,'routine xyz_PAM ---> not properly used !!!'              print *,'routine xyz_PAM ---> not properly used !!!'
1040           print *,'icx = ',icx              print *,'icx = ',icx
1041           print *,'icy = ',icy              print *,'icy = ',icy
1042                         endif
1043        endif        endif
1044                    
1045    
# Line 1001  c      print*,'## xPAM_B,yPAM_B,zPAM_B ' Line 1125  c      print*,'## xPAM_B,yPAM_B,zPAM_B '
1125           endif                   endif        
1126    
1127           distance=           distance=
1128       $        ((xmi-XPP)**2+(ymi-YPP)**2)/RE**2       $       ((xmi-XPP)**2+(ymi-YPP)**2)!QUIQUI
1129    cc     $        ((xmi-XPP)**2+(ymi-YPP)**2)/RE**2
1130           distance=dsqrt(distance)                               distance=dsqrt(distance)                    
1131    
1132  c$$$         print*,xPAM_A,yPAM_A,zPAM_A,xPAM_b,yPAM_b,zPAM_b  c$$$         print*,xPAM_A,yPAM_A,zPAM_A,xPAM_b,yPAM_b,zPAM_b
# Line 1026  c$$$         print*,' resolution ',re Line 1151  c$$$         print*,' resolution ',re
1151  *     ----------------------  *     ----------------------
1152                    
1153           distance=           distance=
1154       $        ((xPAM-XPP)/resxPAM)**2       $       ((xPAM-XPP))**2 !QUIQUI
1155       $        +       $       +
1156       $        ((yPAM-YPP)/resyPAM)**2       $       ((yPAM-YPP))**2
1157    c$$$     $        ((xPAM-XPP)/resxPAM)**2
1158    c$$$     $        +
1159    c$$$     $        ((yPAM-YPP)/resyPAM)**2
1160           distance=dsqrt(distance)                               distance=dsqrt(distance)                    
1161    
1162  c$$$         print*,xPAM,yPAM,zPAM  c$$$         print*,xPAM,yPAM,zPAM
# Line 1037  c$$$         print*,' resolution ',resxP Line 1165  c$$$         print*,' resolution ',resxP
1165                    
1166        else        else
1167                    
1168           print*  c         print*
1169       $        ,' function distance_to ---> wrong usage!!!'  c     $        ,' function distance_to ---> wrong usage!!!'
1170           print*,' xPAM,yPAM,zPAM ',xPAM,yPAM,zPAM  c         print*,' xPAM,yPAM,zPAM ',xPAM,yPAM,zPAM
1171           print*,' xPAM_A,yPAM_A,zPAM_A,xPAM_b,yPAM_b,zPAM_b '  c         print*,' xPAM_A,yPAM_A,zPAM_A,xPAM_b,yPAM_b,zPAM_b '
1172       $        ,xPAM_A,yPAM_A,zPAM_A,xPAM_b,yPAM_b,zPAM_b  c     $        ,xPAM_A,yPAM_A,zPAM_A,xPAM_b,yPAM_b,zPAM_b
1173        endif          endif  
1174    
1175        distance_to = sngl(distance)        distance_to = sngl(distance)
# Line 1109  c--------------------------------------- Line 1237  c---------------------------------------
1237                 if(((mod(int(stripx+0.5)-1,1024)+1).le.3)                 if(((mod(int(stripx+0.5)-1,1024)+1).le.3)
1238       $              .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...
1239  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...
1240                    print*,'whichsensor: ',  c                  print*,'whichsensor: ',
1241       $                ' WARNING: false X strip: strip ',stripx  c     $                ' WARNING: false X strip: strip ',stripx
1242                 endif                 endif
1243                 xi = acoordsi(stripx,viewx)                 xi = acoordsi(stripx,viewx)
1244                 yi = acoordsi(stripy,viewy)                 yi = acoordsi(stripy,viewy)
# Line 1265  c      include 'common_analysis.f' Line 1393  c      include 'common_analysis.f'
1393        is_cp=0        is_cp=0
1394        if(id.lt.0)is_cp=1        if(id.lt.0)is_cp=1
1395        if(id.gt.0)is_cp=2        if(id.gt.0)is_cp=2
1396        if(id.eq.0)print*,'IS_CP ===> wrong couple id !!!'  c      if(id.eq.0)print*,'IS_CP ===> wrong couple id !!!'
1397    
1398        return        return
1399        end        end
# Line 2218  c     print*,'check cp_used' Line 2346  c     print*,'check cp_used'
2346           enddo           enddo
2347  c         if(ncpused.lt.ncpxz_min)goto 22288 !next triplet  c         if(ncpused.lt.ncpxz_min)goto 22288 !next triplet
2348           if(npt.lt.nptxz_min)goto 22288     !next triplet           if(npt.lt.nptxz_min)goto 22288     !next triplet
2349           if(nplused.lt.nplxz_min)goto 22288 !next doublet           if(nplused.lt.nplxz_min)goto 22288 !next triplet
2350                    
2351  *     ~~~~~~~~~~~~~~~~~  *     ~~~~~~~~~~~~~~~~~
2352  *     >>> NEW CLOUD <<<  *     >>> NEW CLOUD <<<
# Line 2295  c$$$     $           ,(tr_cloud(iii),iii Line 2423  c$$$     $           ,(tr_cloud(iii),iii
2423  **************************************************  **************************************************
2424    
2425        subroutine clouds_to_ctrack(iflag)        subroutine clouds_to_ctrack(iflag)
 c*****************************************************  
 c     02/02/2006 modified by Elena Vannuccini --> (1)  
 c*****************************************************  
2426    
2427        include 'commontracker.f'        include 'commontracker.f'
2428        include 'level1.f'        include 'level1.f'
# Line 2305  c*************************************** Line 2430  c***************************************
2430        include 'common_xyzPAM.f'        include 'common_xyzPAM.f'
2431        include 'common_mini_2.f'        include 'common_mini_2.f'
2432        include 'common_mech.f'        include 'common_mech.f'
2433  c      include 'momanhough_init.f'  
2434    
2435    
2436  *     output flag  *     output flag
# Line 2574  c                                 goto 8 Line 2699  c                                 goto 8
2699                                                                
2700                                ntracks = ntracks + 1                                ntracks = ntracks + 1
2701                                                                
 c$$$                              ndof=0                                  
2702                                do ip=1,nplanes                                do ip=1,nplanes
2703  c$$$                                 ndof=ndof  
 c$$$     $                                +int(xgood(ip))  
 c$$$     $                                +int(ygood(ip))  
2704                                   XV_STORE(ip,ntracks)=sngl(xv(ip))                                   XV_STORE(ip,ntracks)=sngl(xv(ip))
2705                                   YV_STORE(ip,ntracks)=sngl(yv(ip))                                   YV_STORE(ip,ntracks)=sngl(yv(ip))
2706                                   ZV_STORE(ip,ntracks)=sngl(zv(ip))                                                                       ZV_STORE(ip,ntracks)=sngl(zv(ip))                                    
# Line 2597  c$$$     $                               Line 2719  c$$$     $                              
2719                                   if(hit_plane(ip).ne.0)then                                   if(hit_plane(ip).ne.0)then
2720                                      CP_STORE(nplanes-ip+1,ntracks)=                                      CP_STORE(nplanes-ip+1,ntracks)=
2721       $                                   cp_match(ip,hit_plane(ip))       $                                   cp_match(ip,hit_plane(ip))
2722                                        SENSOR_STORE(nplanes-ip+1,ntracks)
2723         $                              = is_cp(cp_match(ip,hit_plane(ip)))
2724                                        LADDER_STORE(nplanes-ip+1,ntracks)
2725         $                                   = LADDER(
2726         $                                   clx(ip,icp_cp(
2727         $                                   cp_match(ip,hit_plane(ip)
2728         $                                   ))));
2729                                   else                                   else
2730                                      CP_STORE(nplanes-ip+1,ntracks)=0                                      CP_STORE(nplanes-ip+1,ntracks)=0
2731                                        SENSOR_STORE(nplanes-ip+1,ntracks)=0
2732                                        LADDER_STORE(nplanes-ip+1,ntracks)=0
2733                                   endif                                   endif
2734                                     BX_STORE(nplanes-ip+1,ntracks)=0!I dont need it now
2735                                     BY_STORE(nplanes-ip+1,ntracks)=0!I dont need it now
2736                                   CLS_STORE(nplanes-ip+1,ntracks)=0                                   CLS_STORE(nplanes-ip+1,ntracks)=0
2737                                   do i=1,5                                   do i=1,5
2738                                      AL_STORE(i,ntracks)=sngl(AL(i))                                      AL_STORE(i,ntracks)=sngl(AL(i))
2739                                   enddo                                   enddo
2740                                enddo                                enddo
2741                                                                
 c$$$  *                             Number of Degree Of Freedom  
 c$$$  ndof=ndof-5                            
 c$$$  *                             reduced chi^2  
 c$$$  rchi2=chi2/dble(ndof)  
2742                                RCHI2_STORE(ntracks)=chi2                                RCHI2_STORE(ntracks)=chi2
2743                                                                
2744  *     --------------------------------  *     --------------------------------
# Line 2633  c$$$  rchi2=chi2/dble(ndof) Line 2762  c$$$  rchi2=chi2/dble(ndof)
2762           return           return
2763        endif        endif
2764                
2765    c$$$      if(DEBUG)then
2766    c$$$         print*,'****** TRACK CANDIDATES ***********'
2767    c$$$         print*,'#         R. chi2        RIG'
2768    c$$$         do i=1,ntracks
2769    c$$$            print*,i,' --- ',rchi2_store(i),' --- '
2770    c$$$     $           ,1./abs(AL_STORE(5,i))
2771    c$$$         enddo
2772    c$$$         print*,'***********************************'
2773    c$$$      endif
2774        if(DEBUG)then        if(DEBUG)then
2775           print*,'****** TRACK CANDIDATES ***********'          print*,'****** TRACK CANDIDATES *****************'
2776           print*,'#         R. chi2        RIG'          print*,'#         R. chi2        RIG         ndof'
2777           do i=1,ntracks          do i=1,ntracks
2778              print*,i,' --- ',rchi2_store(i),' --- '            ndof=0                !(1)
2779       $           ,1./abs(AL_STORE(5,i))            do ii=1,nplanes       !(1)
2780           enddo              ndof=ndof           !(1)
2781           print*,'***********************************'       $           +int(xgood_store(ii,i)) !(1)
2782         $           +int(ygood_store(ii,i)) !(1)
2783              enddo                 !(1)
2784              print*,i,' --- ',rchi2_store(i),' --- '
2785         $         ,1./abs(AL_STORE(5,i)),' --- ',ndof
2786            enddo
2787            print*,'*****************************************'
2788        endif        endif
2789                
2790                
# Line 2659  c$$$  rchi2=chi2/dble(ndof) Line 2803  c$$$  rchi2=chi2/dble(ndof)
2803    
2804        subroutine refine_track(ibest)        subroutine refine_track(ibest)
2805    
 c******************************************************  
 cccccc 06/10/2005 modified by elena vannuccini ---> (1)  
 cccccc 31/01/2006 modified by elena vannuccini ---> (2)  
 cccccc 12/08/2006 modified by elena vannucicni ---> (3)  
 c******************************************************  
2806    
2807        include 'commontracker.f'        include 'commontracker.f'
2808        include 'level1.f'        include 'level1.f'
# Line 2671  c*************************************** Line 2810  c***************************************
2810        include 'common_xyzPAM.f'        include 'common_xyzPAM.f'
2811        include 'common_mini_2.f'        include 'common_mini_2.f'
2812        include 'common_mech.f'        include 'common_mech.f'
 c      include 'momanhough_init.f'  
 c      include 'level1.f'  
2813        include 'calib.f'        include 'calib.f'
2814    
2815  *     flag to chose PFA  *     flag to chose PFA
2816        character*10 PFA        character*10 PFA
2817        common/FINALPFA/PFA        common/FINALPFA/PFA
2818    
2819          real k(6)
2820          DATA k/1.099730,0.418900,0.220939,0.220907,0.418771,1.100674/
2821    
2822        real xp,yp,zp        real xp,yp,zp
2823        real xyzp(3),bxyz(3)        real xyzp(3),bxyz(3)
2824        equivalence (xp,xyzp(1)),(yp,xyzp(2)),(zp,xyzp(3))        equivalence (xp,xyzp(1)),(yp,xyzp(2)),(zp,xyzp(3))
# Line 2695  c      include 'level1.f' Line 2835  c      include 'level1.f'
2835           yP=YV_STORE(nplanes-ip+1,ibest)           yP=YV_STORE(nplanes-ip+1,ibest)
2836           zP=ZV_STORE(nplanes-ip+1,ibest)           zP=ZV_STORE(nplanes-ip+1,ibest)
2837           call gufld(xyzp,bxyz)           call gufld(xyzp,bxyz)
2838  c$$$         bxyz(1)=0           BX_STORE(nplanes-ip+1,ibest)=bxyz(1)
2839             BY_STORE(nplanes-ip+1,ibest)=bxyz(2)
2840    c$$$  bxyz(1)=0
2841  c$$$         bxyz(2)=0  c$$$         bxyz(2)=0
2842  c$$$         bxyz(3)=0  c$$$         bxyz(3)=0
2843  *     |||||||||||||||||||||||||||||||||||||||||||||||||  *     |||||||||||||||||||||||||||||||||||||||||||||||||
# Line 2729  c     $           AYV_STORE(nplanes-ip+1 Line 2871  c     $           AYV_STORE(nplanes-ip+1
2871       $           bxyz(1),       $           bxyz(1),
2872       $           bxyz(2)       $           bxyz(2)
2873       $           )       $           )
2874  c$$$  call xyz_PAM(icx,icy,is,  
 c$$$  $              'COG2','COG2',  
 c$$$  $              0.,  
 c$$$  $              0.)  
2875              xm(nplanes-ip+1) = xPAM              xm(nplanes-ip+1) = xPAM
2876              ym(nplanes-ip+1) = yPAM              ym(nplanes-ip+1) = yPAM
2877              zm(nplanes-ip+1) = zPAM              zm(nplanes-ip+1) = zPAM
# Line 2741  c$$$  $              0.) Line 2880  c$$$  $              0.)
2880              resx(nplanes-ip+1) = resxPAM              resx(nplanes-ip+1) = resxPAM
2881              resy(nplanes-ip+1) = resyPAM              resy(nplanes-ip+1) = resyPAM
2882    
2883  c            dedxtrk(nplanes-ip+1) = (sgnl(icx)+sgnl(icy))/2. !(1)              dedxtrk_x(nplanes-ip+1)=sgnl(icx)/mip(VIEW(icx),LADDER(icx))
2884              dedxtrk_x(nplanes-ip+1)=sgnl(icx)/mip(VIEW(icx),LADDER(icx)) !(1)(2)              dedxtrk_y(nplanes-ip+1)=sgnl(icy)/mip(VIEW(icy),LADDER(icy))
             dedxtrk_y(nplanes-ip+1)=sgnl(icy)/mip(VIEW(icy),LADDER(icy)) !(1)(2)  
2885                            
2886  *     |||||||||||||||||||||||||||||||||||||||||||||||||  *     |||||||||||||||||||||||||||||||||||||||||||||||||
2887  *     -------------------------------------------------  *     -------------------------------------------------
# Line 2758  c            dedxtrk(nplanes-ip+1) = (sg Line 2896  c            dedxtrk(nplanes-ip+1) = (sg
2896                                
2897  *     --------------------------------------------------------------  *     --------------------------------------------------------------
2898  *     determine which ladder and sensor are intersected by the track  *     determine which ladder and sensor are intersected by the track
 c$$$            xP=XV_STORE(nplanes-ip+1,ibest)  
 c$$$            yP=YV_STORE(nplanes-ip+1,ibest)  
 c$$$            zP=ZV_STORE(nplanes-ip+1,ibest)  
2899              call whichsensor(ip,xP,yP,nldt,ist)              call whichsensor(ip,xP,yP,nldt,ist)
2900  *     if the track hit the plane in a dead area, go to the next plane  *     if the track hit the plane in a dead area, go to the next plane
2901              if(nldt.eq.0.or.ist.eq.0)goto 133              if(nldt.eq.0.or.ist.eq.0)goto 133
2902    
2903                SENSOR_STORE(nplanes-ip+1,IBEST)=ist
2904                LADDER_STORE(nplanes-ip+1,IBEST)=nldt
2905  *     --------------------------------------------------------------  *     --------------------------------------------------------------
2906    
2907              if(DEBUG)then              if(DEBUG)then
# Line 2798  c     $              cl_used(icy).eq.1.o Line 2936  c     $              cl_used(icy).eq.1.o
2936       $              cl_used(icy).ne.0.or. !or the Y cluster is already used !(3)       $              cl_used(icy).ne.0.or. !or the Y cluster is already used !(3)
2937       $              .false.)goto 1188 !then jump to next couple.       $              .false.)goto 1188 !then jump to next couple.
2938  *            *          
 c               call xyz_PAM(icx,icy,ist,  
 c     $              PFA,PFA,  
 c     $              AXV_STORE(nplanes-ip+1,ibest),  
 c     $              AYV_STORE(nplanes-ip+1,ibest))  
2939                 call xyz_PAM(icx,icy,ist,                 call xyz_PAM(icx,icy,ist,
2940       $              PFA,PFA,       $              PFA,PFA,
2941       $              AXV_STORE(nplanes-ip+1,ibest),       $              AXV_STORE(nplanes-ip+1,ibest),
# Line 2811  c     $              AYV_STORE(nplanes-i Line 2945  c     $              AYV_STORE(nplanes-i
2945       $              )       $              )
2946                                
2947                 distance = distance_to(XP,YP)                 distance = distance_to(XP,YP)
2948                 distance = distance / RCHI2_STORE(ibest)!<<< MS  c               distance = distance / RCHI2_STORE(ibest)!<<< MS !QUIQUI
2949                 id=id_cp(ip,icp,ist)                 id=id_cp(ip,icp,ist)
2950                 if(DEBUG)print*,'( couple ',id                 if(DEBUG)print*,'( couple ',id
2951       $              ,' ) normalized distance ',distance       $              ,' ) distance ',distance
2952                 if(distance.lt.distmin)then                 if(distance.lt.distmin)then
2953                    xmm = xPAM                    xmm = xPAM
2954                    ymm = yPAM                    ymm = yPAM
# Line 2823  c     $              AYV_STORE(nplanes-i Line 2957  c     $              AYV_STORE(nplanes-i
2957                    rymm = resyPAM                    rymm = resyPAM
2958                    distmin = distance                    distmin = distance
2959                    idm = id                                      idm = id                  
 c                 dedxmm = (sgnl(icx)+sgnl(icy))/2. !(1)  
2960                    dedxmmx = sgnl(icx)/mip(VIEW(icx),LADDER(icx)) !(1)(2)                    dedxmmx = sgnl(icx)/mip(VIEW(icx),LADDER(icx)) !(1)(2)
2961                    dedxmmy = sgnl(icy)/mip(VIEW(icy),LADDER(icy)) !(1)(2)                    dedxmmy = sgnl(icy)/mip(VIEW(icy),LADDER(icy)) !(1)(2)
2962    c     QUIQUI --> non devo moltiplicare per clinc?!?!?!
2963                      clincnewc=10*sqrt(rymm**2+rxmm**2 !QUIQUI
2964         $                 +RCHI2_STORE(ibest)*k(ip)*(cov(1,1)+cov(2,2))) !QUIQUI
2965                 endif                 endif
2966   1188          continue   1188          continue
2967              enddo               !end loop on couples on plane icp              enddo               !end loop on couples on plane icp
2968              if(distmin.le.clinc)then                    c            if(distmin.le.clinc)then     !QUIQUI              
2969                if(distmin.le.clincnewc)then     !QUIQUI              
2970  *              -----------------------------------  *              -----------------------------------
2971                 xm(nplanes-ip+1) = xmm         !<<<                 xm(nplanes-ip+1) = xmm !<<<
2972                 ym(nplanes-ip+1) = ymm         !<<<                 ym(nplanes-ip+1) = ymm !<<<
2973                 zm(nplanes-ip+1) = zmm         !<<<                 zm(nplanes-ip+1) = zmm !<<<
2974                 xgood(nplanes-ip+1) = 1        !<<<                 xgood(nplanes-ip+1) = 1 !<<<
2975                 ygood(nplanes-ip+1) = 1        !<<<                 ygood(nplanes-ip+1) = 1 !<<<
2976                 resx(nplanes-ip+1)=rxmm        !<<<                 resx(nplanes-ip+1)=rxmm !<<<
2977                 resy(nplanes-ip+1)=rymm        !<<<                 resy(nplanes-ip+1)=rymm !<<<
2978  c              dedxtrk(nplanes-ip+1) = dedxmm !<<<  !(1)                 dedxtrk_x(nplanes-ip+1) = dedxmmx !<<<
2979                 dedxtrk_x(nplanes-ip+1) = dedxmmx    !(1)                 dedxtrk_y(nplanes-ip+1) = dedxmmy !<<<
                dedxtrk_y(nplanes-ip+1) = dedxmmy    !(1)  
2980  *              -----------------------------------  *              -----------------------------------
2981                 CP_STORE(nplanes-ip+1,ibest)=idm                       CP_STORE(nplanes-ip+1,ibest)=idm      
2982                 if(DEBUG)print*,'%%%% included couple ',idm                 if(DEBUG)print*,'%%%% included couple ',idm
2983       $              ,' (norm.dist.= ',distmin,', cut ',clinc,' )'       $              ,' (dist.= ',distmin,', cut ',clinc,' )'
2984                 goto 133         !next plane                 goto 133         !next plane
2985              endif              endif
2986  *     ================================================  *     ================================================
# Line 2887  c     $              AXV_STORE(nplanes-i Line 3023  c     $              AXV_STORE(nplanes-i
3023       $              bxyz(2)       $              bxyz(2)
3024       $              )                     $              )              
3025                 distance = distance_to(XP,YP)                 distance = distance_to(XP,YP)
3026                 distance = distance / RCHI2_STORE(ibest)!<<< MS  c               distance = distance / RCHI2_STORE(ibest)!<<< MS !QUIQUI
3027                 if(DEBUG)print*,'( cl-X ',icx                 if(DEBUG)print*,'( cl-X ',icx
3028       $              ,' in cp ',id,' ) normalized distance ',distance       $              ,' in cp ',id,' ) distance ',distance
3029                 if(distance.lt.distmin)then                 if(distance.lt.distmin)then
3030                    xmm_A = xPAM_A                    xmm_A = xPAM_A
3031                    ymm_A = yPAM_A                    ymm_A = yPAM_A
# Line 2920  c     $              0.,AYV_STORE(nplane Line 3056  c     $              0.,AYV_STORE(nplane
3056       $              bxyz(2)       $              bxyz(2)
3057       $              )       $              )
3058                 distance = distance_to(XP,YP)                 distance = distance_to(XP,YP)
3059                 distance = distance / RCHI2_STORE(ibest)!<<< MS  c               distance = distance / RCHI2_STORE(ibest)!<<< MS !QUIQUI
3060                 if(DEBUG)print*,'( cl-Y ',icy                 if(DEBUG)print*,'( cl-Y ',icy
3061       $              ,' in cp ',id,' ) normalized distance ',distance       $              ,' in cp ',id,' ) distance ',distance
3062                 if(distance.lt.distmin)then                 if(distance.lt.distmin)then
3063                    xmm_A = xPAM_A                    xmm_A = xPAM_A
3064                    ymm_A = yPAM_A                    ymm_A = yPAM_A
# Line 2944  c                 dedxmm = sgnl(icy)  !( Line 3080  c                 dedxmm = sgnl(icy)  !(
3080  c            print*,'## ncls(',ip,') ',ncls(ip)  c            print*,'## ncls(',ip,') ',ncls(ip)
3081              do ic=1,ncls(ip)    !loop on single clusters              do ic=1,ncls(ip)    !loop on single clusters
3082                 icl=cls(ip,ic)                 icl=cls(ip,ic)
 c              print*,'## ic ',ic,' ist ',ist  
3083  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
3084                 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)
3085       $              LADDER(icl).ne.nldt.or. !or the ladder number does not match       $              LADDER(icl).ne.nldt.or. !or the ladder number does not match
3086       $              .false.)goto 18882      !jump to the next singlet       $              .false.)goto 18882      !jump to the next singlet
3087                 if(mod(VIEW(icl),2).eq.0)then!<---- X view                 if(mod(VIEW(icl),2).eq.0)then!<---- X view
 c                  call xyz_PAM(icl,0,ist,  
 c     $                 PFA,PFA,  
 c     $                 AXV_STORE(nplanes-ip+1,ibest),0.)  
3088                    call xyz_PAM(icl,0,ist,                    call xyz_PAM(icl,0,ist,
3089       $                 PFA,PFA,       $                 PFA,PFA,
3090       $                 AXV_STORE(nplanes-ip+1,ibest),0.,       $                 AXV_STORE(nplanes-ip+1,ibest),0.,
# Line 2960  c     $                 AXV_STORE(nplane Line 3092  c     $                 AXV_STORE(nplane
3092       $                 bxyz(2)       $                 bxyz(2)
3093       $                 )       $                 )
3094                 else                         !<---- Y view                 else                         !<---- Y view
 c                  call xyz_PAM(0,icl,ist,  
 c     $                 PFA,PFA,  
 c     $                 0.,AYV_STORE(nplanes-ip+1,ibest))  
3095                    call xyz_PAM(0,icl,ist,                    call xyz_PAM(0,icl,ist,
3096       $                 PFA,PFA,       $                 PFA,PFA,
3097       $                 0.,AYV_STORE(nplanes-ip+1,ibest),       $                 0.,AYV_STORE(nplanes-ip+1,ibest),
# Line 2972  c     $                 0.,AYV_STORE(npl Line 3101  c     $                 0.,AYV_STORE(npl
3101                 endif                 endif
3102    
3103                 distance = distance_to(XP,YP)                 distance = distance_to(XP,YP)
3104                 distance = distance / RCHI2_STORE(ibest)!<<< MS  c               distance = distance / RCHI2_STORE(ibest)!<<< MS !QUIQUI
3105                 if(DEBUG)print*,'( cl-s ',icl                 if(DEBUG)print*,'( cl-s ',icl
3106       $              ,' ) normalized distance ',distance,'<',distmin,' ?'       $              ,' ) distance ',distance,'<',distmin,' ?'
3107                 if(distance.lt.distmin)then                 if(distance.lt.distmin)then
3108                    if(DEBUG)print*,'YES'                    if(DEBUG)print*,'YES'
3109                    xmm_A = xPAM_A                    xmm_A = xPAM_A
# Line 2987  c     $                 0.,AYV_STORE(npl Line 3116  c     $                 0.,AYV_STORE(npl
3116                    rymm = resyPAM                    rymm = resyPAM
3117                    distmin = distance                      distmin = distance  
3118                    iclm = icl                    iclm = icl
 c                  dedxmm = sgnl(icl)                   !(1)  
3119                    if(mod(VIEW(icl),2).eq.0)then !<---- X view                    if(mod(VIEW(icl),2).eq.0)then !<---- X view
3120                       dedxmmx = sgnl(icl)/mip(VIEW(icl),LADDER(icl)) !(1)(2)                       dedxmmx = sgnl(icl)/mip(VIEW(icl),LADDER(icl))
3121                       dedxmmy = 0.                       !(1)                       dedxmmy = 0.                  
3122                    else          !<---- Y view                    else          !<---- Y view
3123                       dedxmmx = 0.                       !(1)                       dedxmmx = 0.                  
3124                       dedxmmy = sgnl(icl)/mip(VIEW(icl),LADDER(icl)) !(1)(2)                       dedxmmy = sgnl(icl)/mip(VIEW(icl),LADDER(icl))
3125                    endif                    endif
3126                 endif                                   endif                  
3127  18882          continue  18882          continue
3128              enddo               !end loop on single clusters              enddo               !end loop on single clusters
3129  c            print*,'## distmin ', distmin,' clinc ',clinc  c            print*,'## distmin ', distmin,' clinc ',clinc
3130              if(distmin.le.clinc)then                    
3131                  c     QUIQUI------------
3132                 CLS_STORE(nplanes-ip+1,ibest)=iclm !<<<<      c     anche qui: non ci vuole clinc???
3133  *              ----------------------------              if(iclm.ne.0)then
 c               print*,'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'  
3134                 if(mod(VIEW(iclm),2).eq.0)then                 if(mod(VIEW(iclm),2).eq.0)then
3135                    XGOOD(nplanes-ip+1)=1.                    clincnew=
3136                    resx(nplanes-ip+1)=rxmm       $                 20*
3137                    if(DEBUG)print*,'%%%% included X-cl ',iclm       $                 sqrt(rxmm**2+RCHI2_STORE(ibest)*k(ip)*cov(1,1))
3138  c                  if(.true.)print*,'%%%% included X-cl ',iclm                 else if(mod(VIEW(iclm),2).ne.0)then
3139       $                 ,'( chi^2, ',RCHI2_STORE(ibest)                    clincnew=
3140       $                 ,', norm.dist.= ',distmin       $                 10*
3141       $                 ,', cut ',clinc,' )'       $                 sqrt(rymm**2+RCHI2_STORE(ibest)*k(ip)*cov(2,2))
3142                 else                 endif
3143                    YGOOD(nplanes-ip+1)=1.  c     QUIQUI------------
3144                    resy(nplanes-ip+1)=rymm                
3145                    if(DEBUG)print*,'%%%% included Y-cl ',iclm                 if(distmin.le.clincnew)then   !QUIQUI
3146  c                  if(.true.)print*,'%%%% included Y-cl ',iclm  c     if(distmin.le.clinc)then          !QUIQUI          
3147       $                 ,'( chi^2, ',RCHI2_STORE(ibest)                    
3148       $                 ,', norm.dist.= ', distmin                    CLS_STORE(nplanes-ip+1,ibest)=iclm !<<<<    
3149       $                 ,', cut ',clinc,' )'  *     ----------------------------
3150    c     print*,'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
3151                      if(mod(VIEW(iclm),2).eq.0)then
3152                         XGOOD(nplanes-ip+1)=1.
3153                         resx(nplanes-ip+1)=rxmm
3154                         if(DEBUG)print*,'%%%% included X-cl ',iclm
3155         $                    ,'( chi^2, ',RCHI2_STORE(ibest)
3156         $                    ,', dist.= ',distmin
3157         $                    ,', cut ',clinc,' )'
3158                      else
3159                         YGOOD(nplanes-ip+1)=1.
3160                         resy(nplanes-ip+1)=rymm
3161                         if(DEBUG)print*,'%%%% included Y-cl ',iclm
3162         $                    ,'( chi^2, ',RCHI2_STORE(ibest)
3163         $                    ,', dist.= ', distmin
3164         $                    ,', cut ',clinc,' )'
3165                      endif
3166    c     print*,'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
3167    *     ----------------------------
3168                      xm_A(nplanes-ip+1) = xmm_A
3169                      ym_A(nplanes-ip+1) = ymm_A
3170                      xm_B(nplanes-ip+1) = xmm_B
3171                      ym_B(nplanes-ip+1) = ymm_B
3172                      zm(nplanes-ip+1) = (zmm_A+zmm_B)/2.
3173                      dedxtrk_x(nplanes-ip+1) = dedxmmx !<<<
3174                      dedxtrk_y(nplanes-ip+1) = dedxmmy !<<<
3175    *     ----------------------------
3176                 endif                 endif
 c               print*,'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'  
 *              ----------------------------  
                xm_A(nplanes-ip+1) = xmm_A  
                ym_A(nplanes-ip+1) = ymm_A  
                xm_B(nplanes-ip+1) = xmm_B  
                ym_B(nplanes-ip+1) = ymm_B  
                zm(nplanes-ip+1) = (zmm_A+zmm_B)/2.  
 c              dedxtrk(nplanes-ip+1) = dedxmm !<<<    !(1)  
                dedxtrk_x(nplanes-ip+1) = dedxmmx !<<< !(1)  
                dedxtrk_y(nplanes-ip+1) = dedxmmy !<<< !(1)  
 *              ----------------------------  
3177              endif              endif
3178           endif           endif
3179   133     continue   133     continue
# Line 3050  c              dedxtrk(nplanes-ip+1) = d Line 3192  c              dedxtrk(nplanes-ip+1) = d
3192  *                                                 *  *                                                 *
3193  *                                                 *  *                                                 *
3194  **************************************************  **************************************************
 cccccc 12/08/2006 modified by elena ---> (1)  
3195  *  *
3196        subroutine clean_XYclouds(ibest,iflag)        subroutine clean_XYclouds(ibest,iflag)
3197    
3198        include 'commontracker.f'        include 'commontracker.f'
3199        include 'level1.f'        include 'level1.f'
3200        include 'common_momanhough.f'        include 'common_momanhough.f'
3201  c      include 'momanhough_init.f'        include 'level2.f'      
       include 'level2.f'        !(1)  
 c      include 'calib.f'  
 c      include 'level1.f'  
   
   
3202    
3203        do ip=1,nplanes           !loop on planes        do ip=1,nplanes           !loop on planes
3204    
# Line 3072  c      include 'level1.f' Line 3208  c      include 'level1.f'
3208              if(id.ne.0)then              if(id.ne.0)then
3209                 iclx=clx(ip,icp_cp(id))                 iclx=clx(ip,icp_cp(id))
3210                 icly=cly(ip,icp_cp(id))                 icly=cly(ip,icp_cp(id))
3211  c               cl_used(iclx)=1  !tag used clusters                 cl_used(iclx)=ntrk  !tag used clusters
3212  c               cl_used(icly)=1  !tag used clusters                 cl_used(icly)=ntrk  !tag used clusters
                cl_used(iclx)=ntrk  !tag used clusters !(1)  
                cl_used(icly)=ntrk  !tag used clusters !(1)  
3213              elseif(icl.ne.0)then              elseif(icl.ne.0)then
3214  c               cl_used(icl)=1   !tag used clusters                 cl_used(icl)=ntrk   !tag used clusters
                cl_used(icl)=ntrk   !tag used clusters !1)  
3215              endif              endif
3216                            
 c               if(DEBUG)then  
 c                  print*,ip,' <<< ',id  
 c               endif  
3217  *     -----------------------------  *     -----------------------------
3218  *     remove the couple from clouds  *     remove the couple from clouds
3219  *     remove also vitual couples containing the  *     remove also vitual couples containing the
# Line 3144  c               endif Line 3274  c               endif
3274        include 'level1.f'        include 'level1.f'
3275        include 'common_momanhough.f'        include 'common_momanhough.f'
3276        include 'level2.f'        include 'level2.f'
 c      include 'level1.f'  
3277    
3278    *     ---------------------------------
3279    *     variables initialized from level1
3280    *     ---------------------------------
3281        do i=1,nviews        do i=1,nviews
3282           good2(i)=good1(i)           good2(i)=good1(i)
3283             do j=1,nva1_view
3284                vkflag(i,j)=1
3285                if(cnnev(i,j).le.0)then
3286                   vkflag(i,j)=cnnev(i,j)
3287                endif
3288             enddo
3289        enddo        enddo
3290    *     ----------------
3291    *     level2 variables
3292    *     ----------------
3293        NTRK = 0        NTRK = 0
3294        do it=1,NTRKMAX        do it=1,NTRKMAX
3295           IMAGE(IT)=0           IMAGE(IT)=0
# Line 3161  c      include 'level1.f' Line 3300  c      include 'level1.f'
3300              ZM_nt(IP,IT) = 0              ZM_nt(IP,IT) = 0
3301              RESX_nt(IP,IT) = 0              RESX_nt(IP,IT) = 0
3302              RESY_nt(IP,IT) = 0              RESY_nt(IP,IT) = 0
3303                TAILX_nt(IP,IT) = 0
3304                TAILY_nt(IP,IT) = 0
3305                XBAD(IP,IT) = 0
3306                YBAD(IP,IT) = 0
3307              XGOOD_nt(IP,IT) = 0              XGOOD_nt(IP,IT) = 0
3308              YGOOD_nt(IP,IT) = 0              YGOOD_nt(IP,IT) = 0
3309                LS(IP,IT) = 0
3310              DEDX_X(IP,IT) = 0              DEDX_X(IP,IT) = 0
3311              DEDX_Y(IP,IT) = 0              DEDX_Y(IP,IT) = 0
3312              CLTRX(IP,IT) = 0              CLTRX(IP,IT) = 0
# Line 3295  c      include 'level1.f' Line 3439  c      include 'level1.f'
3439    
3440            
3441        include 'commontracker.f'        include 'commontracker.f'
 c      include 'level1.f'  
3442        include 'level1.f'        include 'level1.f'
3443        include 'common_momanhough.f'        include 'common_momanhough.f'
3444        include 'level2.f'        include 'level2.f'
3445        include 'common_mini_2.f'        include 'common_mini_2.f'
3446        real sinth,phi,pig              include 'calib.f'
3447    
3448          character*10 PFA
3449          common/FINALPFA/PFA
3450    
3451          real sinth,phi,pig
3452          integer ssensor,sladder
3453        pig=acos(-1.)        pig=acos(-1.)
3454    
3455    *     -------------------------------------
3456        chi2_nt(ntr)        = sngl(chi2)        chi2_nt(ntr)        = sngl(chi2)
3457        nstep_nt(ntr)       = nstep        nstep_nt(ntr)       = nstep
3458    *     -------------------------------------
3459        phi   = al(4)                  phi   = al(4)          
3460        sinth = al(3)                    sinth = al(3)            
3461        if(sinth.lt.0)then              if(sinth.lt.0)then      
# Line 3318  c      include 'level1.f' Line 3468  c      include 'level1.f'
3468       $     phi = phi + 2*pig         $     phi = phi + 2*pig  
3469        al(4) = phi                      al(4) = phi              
3470        al(3) = sinth                    al(3) = sinth            
   
3471        do i=1,5        do i=1,5
3472           al_nt(i,ntr)     = sngl(al(i))           al_nt(i,ntr)     = sngl(al(i))
3473           do j=1,5           do j=1,5
3474              coval(i,j,ntr) = sngl(cov(i,j))              coval(i,j,ntr) = sngl(cov(i,j))
3475           enddo           enddo
3476        enddo        enddo
3477          *     -------------------------------------      
3478        do ip=1,nplanes           ! loop on planes        do ip=1,nplanes           ! loop on planes
3479           xgood_nt(ip,ntr) = int(xgood(ip))           xgood_nt(ip,ntr) = int(xgood(ip))
3480           ygood_nt(ip,ntr) = int(ygood(ip))           ygood_nt(ip,ntr) = int(ygood(ip))
# Line 3334  c      include 'level1.f' Line 3483  c      include 'level1.f'
3483           zm_nt(ip,ntr)    = sngl(zm(ip))           zm_nt(ip,ntr)    = sngl(zm(ip))
3484           RESX_nt(IP,ntr)  = sngl(resx(ip))           RESX_nt(IP,ntr)  = sngl(resx(ip))
3485           RESY_nt(IP,ntr)  = sngl(resy(ip))           RESY_nt(IP,ntr)  = sngl(resy(ip))
3486             TAILX_nt(IP,ntr) = 0.
3487             TAILY_nt(IP,ntr) = 0.
3488           xv_nt(ip,ntr)    = sngl(xv(ip))           xv_nt(ip,ntr)    = sngl(xv(ip))
3489           yv_nt(ip,ntr)    = sngl(yv(ip))           yv_nt(ip,ntr)    = sngl(yv(ip))
3490           zv_nt(ip,ntr)    = sngl(zv(ip))           zv_nt(ip,ntr)    = sngl(zv(ip))
# Line 3341  c      include 'level1.f' Line 3492  c      include 'level1.f'
3492           ayv_nt(ip,ntr)   = sngl(ayv(ip))             ayv_nt(ip,ntr)   = sngl(ayv(ip))  
3493  c     l'avevo dimenticato!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  c     l'avevo dimenticato!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3494           factor = sqrt(           factor = sqrt(
3495       $        sin( acos(-1.) * sngl(axv(ip)) /180. )**2 +       $        tan( acos(-1.) * sngl(axv(ip)) /180. )**2 +
3496       $        sin( acos(-1.) * sngl(ayv(ip)) /180. )**2 +       $        tan( acos(-1.) * sngl(ayv(ip)) /180. )**2 +
3497       $        1. )       $        1. )
3498  c     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  c     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3499           dedx_x(ip,ntr)   = sngl(dedxtrk_x(ip)/factor)           dedx_x(ip,ntr)   = sngl(dedxtrk_x(ip)/factor)
3500           dedx_y(ip,ntr)   = sngl(dedxtrk_y(ip)/factor)             dedx_y(ip,ntr)   = sngl(dedxtrk_y(ip)/factor)  
3501        
3502           id  = CP_STORE(ip,IDCAND)           ax   = axv_nt(ip,ntr)
3503             ay   = ayv_nt(ip,ntr)
3504             bfx  = BX_STORE(ip,IDCAND)
3505             bfy  = BY_STORE(ip,IDCAND)
3506             if(ip.eq.6) ax = -1. * axv_nt(ip,ntr)
3507             if(ip.eq.6) bfy = -1. * BY_STORE(ip,IDCAND)
3508             tgtemp   = tan(ax*acos(-1.)/180.) + pmuH_h*bfy*0.00001
3509             angx     = 180.*atan(tgtemp)/acos(-1.)
3510             tgtemp = tan(ay*acos(-1.)/180.)+pmuH_e*bfx*0.00001        
3511             angy    = 180.*atan(tgtemp)/acos(-1.)
3512            
3513    c         print*,'* ',ip,bfx,bfy,angx,angy
3514    
3515             id  = CP_STORE(ip,IDCAND) ! couple id
3516           icl = CLS_STORE(ip,IDCAND)           icl = CLS_STORE(ip,IDCAND)
3517             ssensor = -1
3518             sladder = -1
3519             ssensor = SENSOR_STORE(ip,IDCAND)
3520             sladder = LADDER_STORE(ip,IDCAND)
3521             if(ip.eq.6.and.ssensor.ne.0)ssensor = 3 - ssensor !notazione paolo x align
3522             LS(IP,ntr)      = ssensor+10*sladder
3523    
3524           if(id.ne.0)then           if(id.ne.0)then
3525    c           >>> is a couple
3526              cltrx(ip,ntr)   = clx(nplanes-ip+1,icp_cp(id))              cltrx(ip,ntr)   = clx(nplanes-ip+1,icp_cp(id))
3527              cltry(ip,ntr)   = cly(nplanes-ip+1,icp_cp(id))              cltry(ip,ntr)   = cly(nplanes-ip+1,icp_cp(id))
3528  c            print*,ip,' ',cltrx(ip,ntr),cltry(ip,ntr)  
3529    c$$$            if(is_cp(id).ne.ssensor)
3530    c$$$     $           print*,'ERROR is sensor assignment (couple)'
3531    c$$$     $           ,is_cp(id),ssensor
3532    c$$$            if(LADDER(clx(nplanes-ip+1,icp_cp(id))).ne.sladder)
3533    c$$$     $           print*,'ERROR is ladder assignment (couple)'
3534    c$$$     $           ,LADDER(clx(nplanes-ip+1,icp_cp(id))),sladder
3535                
3536                nnnnx = npfastrips(clx(nplanes-ip+1,icp_cp(id)),PFA,angx)
3537                nnnny = npfastrips(cly(nplanes-ip+1,icp_cp(id)),PFA,angy)            
3538                xbad(ip,ntr)= nbadstrips(nnnnx,clx(nplanes-ip+1,icp_cp(id)))
3539                ybad(ip,ntr)= nbadstrips(nnnny,cly(nplanes-ip+1,icp_cp(id)))
3540    
3541                if(nsatstrips(clx(nplanes-ip+1,icp_cp(id))).gt.0)
3542         $           dedx_x(ip,ntr)=-dedx_x(ip,ntr)
3543                if(nsatstrips(cly(nplanes-ip+1,icp_cp(id))).gt.0)
3544         $           dedx_y(ip,ntr)=-dedx_y(ip,ntr)
3545    
3546           elseif(icl.ne.0)then           elseif(icl.ne.0)then
3547              if(mod(VIEW(icl),2).eq.0)cltrx(ip,ntr)=icl  c           >>> is a singlet
3548              if(mod(VIEW(icl),2).eq.1)cltry(ip,ntr)=icl  c$$$            if(LADDER(icl).ne.sladder)
3549  c            print*,ip,' ',cltrx(ip,ntr),cltry(ip,ntr)  c$$$     $           print*,'ERROR is ladder assignment (single)'
3550    c$$$     $           ,LADDER(icl),sladder
3551                if(mod(VIEW(icl),2).eq.0)then
3552                   cltrx(ip,ntr)=icl
3553                   nnnnn = npfastrips(icl,PFA,angx)
3554                   xbad(ip,ntr) = nbadstrips(nnnnn,icl)
3555                   if(nsatstrips(icl).gt.0)dedx_x(ip,ntr)=-dedx_x(ip,ntr)
3556                elseif(mod(VIEW(icl),2).eq.1)then
3557                   cltry(ip,ntr)=icl
3558                   nnnnn = npfastrips(icl,PFA,angy)
3559                   ybad(ip,ntr) = nbadstrips(nnnnn,icl)
3560                   if(nsatstrips(icl).gt.0)dedx_y(ip,ntr)=-dedx_y(ip,ntr)
3561                endif
3562           endif                     endif          
3563    
3564        enddo        enddo
3565    
3566    
3567    c$$$      print*,(xgood(i),i=1,6)
3568    c$$$      print*,(ygood(i),i=1,6)
3569    c$$$      print*,(ls(i,ntr),i=1,6)
3570    c$$$      print*,(dedx_x(i,ntr),i=1,6)
3571    c$$$      print*,(dedx_y(i,ntr),i=1,6)
3572    c$$$      print*,'-----------------------'
3573    
3574        end        end
3575    
3576        subroutine fill_level2_siglets        subroutine fill_level2_siglets
# Line 3374  c            print*,ip,' ',cltrx(ip,ntr) Line 3582  c            print*,ip,' ',cltrx(ip,ntr)
3582  *     -------------------------------------------------------  *     -------------------------------------------------------
3583    
3584        include 'commontracker.f'        include 'commontracker.f'
 c      include 'level1.f'  
3585        include 'calib.f'        include 'calib.f'
3586        include 'level1.f'        include 'level1.f'
3587        include 'common_momanhough.f'        include 'common_momanhough.f'
# Line 3382  c      include 'level1.f' Line 3589  c      include 'level1.f'
3589        include 'common_xyzPAM.f'        include 'common_xyzPAM.f'
3590    
3591  *     count #cluster per plane not associated to any track  *     count #cluster per plane not associated to any track
 c      good2=1!.true.  
3592        nclsx = 0        nclsx = 0
3593        nclsy = 0        nclsy = 0
3594    
# Line 3396  c      good2=1!.true. Line 3602  c      good2=1!.true.
3602              if(mod(VIEW(icl),2).eq.0)then !=== X views              if(mod(VIEW(icl),2).eq.0)then !=== X views
3603                 nclsx = nclsx + 1                 nclsx = nclsx + 1
3604                 planex(nclsx) = ip                 planex(nclsx) = ip
3605                 sgnlxs(nclsx) = sgnl(icl)/mip(VIEW(icl),LADDER(icl))!(2)                 sgnlxs(nclsx) = sgnl(icl)/mip(VIEW(icl),LADDER(icl))
3606                   if(nsatstrips(icl).gt.0)sgnlxs(nclsx)=-sgnlxs(nclsx)
3607                 clsx(nclsx)   = icl                 clsx(nclsx)   = icl
3608                 do is=1,2                 do is=1,2
3609  c                  call xyz_PAM(icl,0,is,'COG1',' ',0.,0.)  c                  call xyz_PAM(icl,0,is,'COG1',' ',0.,0.)
# Line 3412  c$$$               print*,'xs(2,nclsx)   Line 3619  c$$$               print*,'xs(2,nclsx)  
3619              else                          !=== Y views              else                          !=== Y views
3620                 nclsy = nclsy + 1                 nclsy = nclsy + 1
3621                 planey(nclsy) = ip                 planey(nclsy) = ip
3622                 sgnlys(nclsy) = sgnl(icl)/mip(VIEW(icl),LADDER(icl))!(2)                 sgnlys(nclsy) = sgnl(icl)/mip(VIEW(icl),LADDER(icl))
3623                   if(nsatstrips(icl).gt.0)sgnlys(nclsy)=-sgnlys(nclsy)
3624                 clsy(nclsy)   = icl                 clsy(nclsy)   = icl
3625                 do is=1,2                 do is=1,2
3626  c                  call xyz_PAM(0,icl,is,' ','COG1',0.,0.)  c                  call xyz_PAM(0,icl,is,' ','COG1',0.,0.)
# Line 3427  c$$$               print*,'ys(1,nclsy)   Line 3635  c$$$               print*,'ys(1,nclsy)  
3635  c$$$               print*,'ys(2,nclsy)   ',ys(2,nclsy)  c$$$               print*,'ys(2,nclsy)   ',ys(2,nclsy)
3636              endif              endif
3637           endif           endif
 c      print*,icl,cl_used(icl),cl_good(icl),ip,VIEW(icl)!nclsx(ip),nclsy(ip)  
3638    
3639  ***** LO METTO QUI PERCHE` NON SO DOVE METTERLO  ***** LO METTO QUI PERCHE` NON SO DOVE METTERLO
3640           whichtrack(icl) = cl_used(icl)           whichtrack(icl) = cl_used(icl)

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.22

  ViewVC Help
Powered by ViewVC 1.1.23