--- DarthVader/TrackerLevel2/src/F77/analysissubroutines.f 2006/05/19 13:15:54 1.1.1.1 +++ DarthVader/TrackerLevel2/src/F77/analysissubroutines.f 2007/08/28 13:25:50 1.30 @@ -12,19 +12,49 @@ subroutine track_finding(iflag) include 'commontracker.f' + include 'level1.f' include 'common_momanhough.f' include 'common_mech.f' include 'common_xyzPAM.f' include 'common_mini_2.f' include 'calib.f' - include 'level1.f' include 'level2.f' - include 'momanhough_init.f' - - logical DEBUG - common/dbg/DEBUG + +c print*,'======================================================' +c$$$ do ic=1,NCLSTR1 +c$$$ if(.false. +c$$$ $ .or.nsatstrips(ic).gt.0 +c$$$c $ .or.nbadstrips(0,ic).gt.0 +c$$$c $ .or.nbadstrips(4,ic).gt.0 +c$$$c $ .or.nbadstrips(3,ic).gt.0 +c$$$ $ .or..false.)then +c$$$ print*,'--- cl-',ic,' ------------------------' +c$$$ istart = INDSTART(IC) +c$$$ istop = TOTCLLENGTH +c$$$ if(ic.lt.NCLSTR1)istop=INDSTART(IC+1)-1 +c$$$ print*,'ADC ',(CLADC(i),i=istart,istop) +c$$$ print*,'s/n ',(CLSIGNAL(i)/CLSIGMA(i),i=istart,istop) +c$$$ print*,'sgnl ',(CLSIGNAL(i),i=istart,istop) +c$$$ print*,'strip ',(i-INDMAX(ic),i=istart,istop) +c$$$ print*,'view ',VIEW(ic) +c$$$ print*,'maxs ',MAXS(ic) +c$$$ print*,'COG4 ',cog(4,ic) +c$$$ ff = fbad_cog(4,ic) +c$$$ print*,'fbad ',ff +c$$$ print*,(CLBAD(i),i=istart,istop) +c$$$ bb=nbadstrips(0,ic) +c$$$ print*,'#BAD (tot)',bb +c$$$ bb=nbadstrips(4,ic) +c$$$ print*,'#BAD (4)',bb +c$$$ bb=nbadstrips(3,ic) +c$$$ print*,'#BAD (3)',bb +c$$$ ss=nsatstrips(ic) +c$$$ print*,'#saturated ',ss +c$$$ endif +c$$$ enddo + *------------------------------------------------------------------------------- * STEP 1 *------------------------------------------------------------------------------- @@ -44,25 +74,12 @@ *------------------------------------------------------------------------------- *------------------------------------------------------------------------------- -c iflag=0 + call cl_to_couples(iflag) if(iflag.eq.1)then !bad event - goto 880 !fill ntp and go to next event + goto 880 !go to next event endif -*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -* selezione di tracce pulite per diagnostica -*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -c$$$ if(DEBUG)then -c$$$ do ip=1,nplanes -c$$$ if(ncp_plane(ip).ne.1)good2=.false. -c$$$ enddo -c$$$c if(good2.eq.0)goto 100!next event -c$$$c if(good2.eq.0)goto 880!fill ntp and go to next event -c$$$ endif - - - *----------------------------------------------------- *----------------------------------------------------- * HOUGH TRASFORM @@ -91,10 +108,10 @@ *------------------------------------------------------------------------------- *------------------------------------------------------------------------------- -c iflag=0 + call cp_to_doubtrip(iflag) if(iflag.eq.1)then !bad event - goto 880 !fill ntp and go to next event + goto 880 !go to next event endif @@ -123,18 +140,61 @@ * $ ,ptcloud_xz,tr_cloud,cpcloud_xz *------------------------------------------------------------------------------- *------------------------------------------------------------------------------- +* count number of hit planes + planehit=0 + do np=1,nplanes + if(ncp_plane(np).ne.0)then + planehit=planehit+1 + endif + enddo + if(planehit.lt.3) goto 880 ! exit + + nptxz_min=x_min_start + nplxz_min=x_min_start + + nptyz_min=y_min_start + nplyz_min=y_min_start + + cutdistyz=cutystart + cutdistxz=cutxstart -c iflag=0 + 878 continue call doub_to_YZcloud(iflag) if(iflag.eq.1)then !bad event goto 880 !fill ntp and go to next event - endif -c iflag=0 + endif + if(nclouds_yz.eq.0.and.cutdistyz.lt.maxcuty)then + if(cutdistyz.lt.maxcuty/2)then + cutdistyz=cutdistyz+cutystep + else + cutdistyz=cutdistyz+(3*cutystep) + endif + goto 878 + endif + + if(planehit.eq.3) goto 881 + + 879 continue call trip_to_XZcloud(iflag) if(iflag.eq.1)then !bad event goto 880 !fill ntp and go to next event endif - + + if(nclouds_xz.eq.0.and.cutdistxz.lt.maxcutx)then + cutdistxz=cutdistxz+cutxstep + goto 879 + endif + + + 881 continue +* if there is at least three planes on the Y view decreases cuts on X view + if(nclouds_xz.eq.0.and.nclouds_yz.gt.0.and. + $ nplxz_min.ne.y_min_start)then + nptxz_min=x_min_step + nplxz_min=x_min_start-x_min_step + goto 879 + endif + 880 return end @@ -144,20 +204,19 @@ subroutine track_fitting(iflag) include 'commontracker.f' + include 'level1.f' include 'common_momanhough.f' include 'common_mech.f' include 'common_xyzPAM.f' include 'common_mini_2.f' include 'calib.f' - include 'level1.f' include 'level2.f' - include 'momanhough_init.f' +c include 'momanhough_init.f' - logical DEBUG - common/dbg/DEBUG - logical FIMAGE ! + real trackimage(NTRACKSMAX) + real*8 AL_GUESS(5) *------------------------------------------------------------------------------- * STEP 4 (ITERATED until any other physical track isn't found) @@ -198,14 +257,63 @@ ibest=0 !best track among candidates iimage=0 !track image * ------------- select the best track ------------- - rchi2best=1000000000. +c$$$ rchi2best=1000000000. +c$$$ do i=1,ntracks +c$$$ if(RCHI2_STORE(i).lt.rchi2best.and. +c$$$ $ RCHI2_STORE(i).gt.0)then +c$$$ ibest=i +c$$$ rchi2best=RCHI2_STORE(i) +c$$$ endif +c$$$ enddo +c$$$ if(ibest.eq.0)goto 880 !>> no good candidates + +* ------------------------------------------------------- +* order track-candidates according to: +* 1st) decreasing n.points +* 2nd) increasing chi**2 +* ------------------------------------------------------- + rchi2best=1000000000. + ndofbest=0 do i=1,ntracks - if(RCHI2_STORE(i).lt.rchi2best.and. - $ RCHI2_STORE(i).gt.0)then + ndof=0 + do ii=1,nplanes + ndof=ndof + $ +int(xgood_store(ii,i)) + $ +int(ygood_store(ii,i)) + enddo + if(ndof.gt.ndofbest)then + ibest=i + rchi2best=RCHI2_STORE(i) + ndofbest=ndof + elseif(ndof.eq.ndofbest)then + if(RCHI2_STORE(i).lt.rchi2best.and. + $ RCHI2_STORE(i).gt.0)then ibest=i rchi2best=RCHI2_STORE(i) - endif + ndofbest=ndof + endif + endif enddo + +c$$$ rchi2best=1000000000. +c$$$ ndofbest=0 !(1) +c$$$ do i=1,ntracks +c$$$ if(RCHI2_STORE(i).lt.rchi2best.and. +c$$$ $ RCHI2_STORE(i).gt.0)then +c$$$ ndof=0 !(1) +c$$$ do ii=1,nplanes !(1) +c$$$ ndof=ndof !(1) +c$$$ $ +int(xgood_store(ii,i)) !(1) +c$$$ $ +int(ygood_store(ii,i)) !(1) +c$$$ enddo !(1) +c$$$ if(ndof.ge.ndofbest)then !(1) +c$$$ ibest=i +c$$$ rchi2best=RCHI2_STORE(i) +c$$$ ndofbest=ndof !(1) +c$$$ endif !(1) +c$$$ endif +c$$$ enddo + if(ibest.eq.0)goto 880 !>> no good candidates *------------------------------------------------------------------------------- * The best track candidate (ibest) is selected and a new fitting is performed. @@ -224,8 +332,10 @@ iimage=0 endif if(icand.eq.0)then - print*,'HAI FATTO UN CASINO!!!!!! icand = ',icand - $ ,ibest,iimage + if(VERBOSE.EQ.1)then + print*,'HAI FATTO UN CASINO!!!!!! icand = ',icand + $ ,ibest,iimage + endif return endif @@ -236,23 +346,42 @@ * ********************************************************** * ************************** FIT *** FIT *** FIT *** FIT *** * ********************************************************** + call guess() do i=1,5 - AL(i)=dble(AL_STORE(i,icand)) + AL_GUESS(i)=AL(i) enddo +c print*,'## guess: ',al + + do i=1,5 + AL(i)=dble(AL_STORE(i,icand)) + enddo + + IDCAND = icand !fitted track-candidate ifail=0 !error flag in chi2 computation jstep=0 !# minimization steps - call mini_2(jstep,ifail) + iprint=0 +c if(DEBUG.EQ.1)iprint=1 + if(VERBOSE.EQ.1)iprint=1 + if(DEBUG.EQ.1)iprint=2 + call mini2(jstep,ifail,iprint) if(ifail.ne.0) then - if(DEBUG)then + if(VERBOSE.EQ.1)then print *, - $ '*** MINIMIZATION FAILURE *** (mini_2) ' + $ '*** MINIMIZATION FAILURE *** (after refinement) ' $ ,iev + +c$$$ print*,'guess: ',(al_guess(i),i=1,5) +c$$$ print*,'previous: ',(al_store(i,icand),i=1,5) +c$$$ print*,'result: ',(al(i),i=1,5) +c$$$ print*,'xgood ',xgood +c$$$ print*,'ygood ',ygood +c$$$ print*,'----------------------------------------------' endif - chi2=-chi2 +c chi2=-chi2 endif - if(DEBUG)then + if(DEBUG.EQ.1)then print*,'----------------------------- improved track coord' 22222 format(i2,' * ',3f10.4,' --- ',4f10.4,' --- ',2f4.0,2f10.5) do ip=1,6 @@ -263,7 +392,7 @@ endif c rchi2=chi2/dble(ndof) - if(DEBUG)then + if(DEBUG.EQ.1)then print*,' ' print*,'****** SELECTED TRACK *************' print*,'# R. chi2 RIG' @@ -279,25 +408,140 @@ * ------------- search if the track has an IMAGE ------------- * ------------- (also this is stored ) ------------- if(FIMAGE)goto 122 !>>> jump! (this is already an image) -* now search for track-image, by comparing couples IDs + +* ----------------------------------------------------- +* first check if the track is ambiguous +* ----------------------------------------------------- +* (modified on august 2007 by ElenaV) + is1=0 + do ip=1,NPLANES + if(SENSOR_STORE(ip,icand).ne.0)then + is1=SENSOR_STORE(ip,icand) + if(ip.eq.6)is1=3-is1 !last plane inverted + endif + enddo + if(is1.eq.0)then + if(WARNING.EQ.1)print*,'** WARNING ** sensor=0' + goto 122 !jump + endif +c print*,'is1 ',is1 + do ip=1,NPLANES + is2 = SENSOR_STORE(ip,icand) !sensor +c print*,'is2 ',is2,' ip ',ip + if(ip.eq.6.and.is2.ne.0)is2=3-is2 !last plane inverted + if( + $ (is1.ne.is2.and.is2.ne.0) + $ )goto 122 !jump (this track cannot have an image) + enddo + if(DEBUG.eq.1)print*,' >>> ambiguous track! ' +* now search for track-image among track candidates +c$$$ do i=1,ntracks +c$$$ iimage=i +c$$$ do ip=1,nplanes +c$$$ if( CP_STORE(nplanes-ip+1,icand).ne. +c$$$ $ -1*CP_STORE(nplanes-ip+1,i).and. +c$$$ $ CP_STORE(nplanes-ip+1,i).ne.0.and. +c$$$ $ CP_STORE(nplanes-ip+1,icand).ne.0 )iimage=0 +c$$$ print*,' track ',i,' CP ',CP_STORE(nplanes-ip+1,i) +c$$$ $ ,CP_STORE(nplanes-ip+1,icand),iimage +c$$$ enddo +c$$$ if( iimage.ne.0.and. +c$$$c $ RCHI2_STORE(i).le.CHI2MAX.and. +c$$$c $ RCHI2_STORE(i).gt.0.and. +c$$$ $ .true.)then +c$$$ if(DEBUG.EQ.1)print*,'Track candidate ',iimage +c$$$ $ ,' >>> TRACK IMAGE >>> of' +c$$$ $ ,ibest +c$$$ goto 122 !image track found +c$$$ endif +c$$$ enddo +* --------------------------------------------------------------- +* take the candidate with the greatest number of matching couples +* if more than one satisfies the requirement, +* choose the one with more points and lower chi2 +* --------------------------------------------------------------- +* count the number of matching couples + ncpmax = 0 + iimage = 0 !id of candidate with better matching do i=1,ntracks - iimage=i + ncp=0 do ip=1,nplanes - if( CP_STORE(nplanes-ip+1,icand).ne. - $ -1*CP_STORE(nplanes-ip+1,i) )iimage=0 + if(CP_STORE(nplanes-ip+1,icand).ne.0)then + if( + $ CP_STORE(nplanes-ip+1,i).ne.0 + $ .and. + $ CP_STORE(nplanes-ip+1,icand).eq. + $ -1*CP_STORE(nplanes-ip+1,i) + $ )then + ncp=ncp+1 !ok + elseif( + $ CP_STORE(nplanes-ip+1,i).ne.0 + $ .and. + $ CP_STORE(nplanes-ip+1,icand).ne. + $ -1*CP_STORE(nplanes-ip+1,i) + $ )then + ncp = 0 + goto 117 !it is not an image candidate + else + + endif + endif +c$$$ print*,' track ',i,' CP ',CP_STORE(nplanes-ip+1,i) +c$$$ $ ,CP_STORE(nplanes-ip+1,icand),ncp enddo - if( iimage.ne.0.and. -c $ RCHI2_STORE(i).le.CHI2MAX.and. -c $ RCHI2_STORE(i).gt.0.and. - $ .true.)then - if(DEBUG)print*,'Track candidate ',iimage - $ ,' >>> TRACK IMAGE >>> of' - $ ,ibest - goto 122 !image track found + 117 continue + trackimage(i)=ncp !number of matching couples + if(ncp>ncpmax)then + ncpmax=ncp + iimage=i endif enddo +* check if there are more than one image candidates + ngood=0 + do i=1,ntracks + if( ncpmax.ne.0.and.trackimage(i).eq.ncpmax )ngood=ngood+1 + enddo +* if there are, choose the best one + if(ngood.gt.1)then +* ------------------------------------------------------- +* order track-candidates according to: +* 1st) decreasing n.points +* 2nd) increasing chi**2 +* ------------------------------------------------------- + rchi2best=1000000000. + ndofbest=0 + do i=1,ntracks + if( trackimage(i).eq.ncpmax )then + ndof=0 + do ii=1,nplanes + ndof=ndof + $ +int(xgood_store(ii,i)) + $ +int(ygood_store(ii,i)) + enddo + if(ndof.gt.ndofbest)then + iimage=i + rchi2best=RCHI2_STORE(i) + ndofbest=ndof + elseif(ndof.eq.ndofbest)then + if(RCHI2_STORE(i).lt.rchi2best.and. + $ RCHI2_STORE(i).gt.0)then + iimage=i + rchi2best=RCHI2_STORE(i) + ndofbest=ndof + endif + endif + endif + enddo + + endif + + if(DEBUG.EQ.1)print*,'Track candidate ',iimage + $ ,' >>> TRACK IMAGE >>> of' + $ ,ibest + 122 continue + * --- and store the results -------------------------------- ntrk = ntrk + 1 !counter of found tracks if(.not.FIMAGE @@ -310,7 +554,7 @@ c $ ,iimage,fimage,ntrk,image(ntrk) if(ntrk.eq.NTRKMAX)then - if(DEBUG) + if(verbose.eq.1) $ print*, $ '** warning ** number of identified '// $ 'tracks exceeds vector dimension ' @@ -346,7 +590,7 @@ $ rchi2best.le.CHI2MAX.and. c $ rchi2best.lt.15..and. $ .true.)then - if(DEBUG)then + if(DEBUG.EQ.1)then print*,'***** NEW SEARCH ****' endif goto 11111 !try new search @@ -360,178 +604,6 @@ end - - -c$$$************************************************************ -c$$$ -c$$$ subroutine readmipparam -c$$$ -c$$$ include 'commontracker.f' -c$$$ include 'calib.f' -c$$$ -c$$$ character*60 fname_param -c$$$ 201 format('trk-LADDER',i1,'-mip.dat') -c$$$ do ilad=1,nladders_view -c$$$ write(fname_param,201)ilad -c$$$ print *,'Opening file: ',fname_param -c$$$ open(10, -c$$$ $ FILE='./bin-aux/'//fname_param(1:LNBLNK(fname_param)) -c$$$ $ ,STATUS='UNKNOWN' -c$$$ $ ,IOSTAT=iostat -c$$$ $ ) -c$$$ if(iostat.ne.0)then -c$$$ print*,'READMIPPARAM: *** Error in opening file ***' -c$$$ return -c$$$ endif -c$$$ do iv=1,nviews -c$$$ read(10,* -c$$$ $ ,IOSTAT=iostat -c$$$ $ )pip, -c$$$ $ mip(int(pip),ilad) -c$$$c print*,ilad,iv,pip,mip(int(pip),ilad) -c$$$ enddo -c$$$ close(10) -c$$$ enddo -c$$$ -c$$$ return -c$$$ end -c$$$*** * * * *** * * * *** * * * *** * * * *** * * * *** * * * *** -c$$$ subroutine readchargeparam -c$$$ -c$$$ -c$$$ include 'commontracker.f' -c$$$ include 'calib.f' -c$$$ -c$$$ character*60 fname_param -c$$$ 201 format('charge-l',i1,'.dat') -c$$$ do ilad=1,nladders_view -c$$$ write(fname_param,201)ilad -c$$$ print *,'Opening file: ',fname_param -c$$$ open(10, -c$$$ $ FILE='./bin-aux/'//fname_param(1:LNBLNK(fname_param)) -c$$$ $ ,STATUS='UNKNOWN' -c$$$ $ ,IOSTAT=iostat -c$$$ $ ) -c$$$ if(iostat.ne.0)then -c$$$ print*,'READCHARGEPARAM: *** Error in opening file ***' -c$$$ return -c$$$ endif -c$$$ do ip=1,nplanes -c$$$ read(10,* -c$$$ $ ,IOSTAT=iostat -c$$$ $ )pip, -c$$$ $ kch(ip,ilad),cch(ip,ilad),sch(ip,ilad) -c$$$c print*,ilad,ip,pip,kch(ip,ilad), -c$$$c $ cch(ip,ilad),sch(ip,ilad) -c$$$ enddo -c$$$ close(10) -c$$$ enddo -c$$$ -c$$$ return -c$$$ end -c$$$*** * * * *** * * * *** * * * *** * * * *** * * * *** * * * *** -c$$$ subroutine readetaparam -c$$$* ----------------------------------------- -c$$$* read eta2,3,4 calibration parameters -c$$$* and fill variables: -c$$$* -c$$$* eta2(netabin,nladders_view,nviews) -c$$$* eta3(2*netabin,nladders_view,nviews) -c$$$* eta4(2*netabin,nladders_view,nviews) -c$$$* -c$$$ include 'commontracker.f' -c$$$ include 'calib.f' -c$$$ -c$$$ character*40 fname_binning -c$$$ character*40 fname_param -c$$$c character*120 cmd1 -c$$$c character*120 cmd2 -c$$$ -c$$$ -c$$$******retrieve ANGULAR BINNING info -c$$$ fname_binning='binning.dat' -c$$$ print *,'Opening file: ',fname_binning -c$$$ open(10, -c$$$ $ FILE='./bin-aux/'//fname_binning(1:LNBLNK(fname_binning)) -c$$$ $ ,STATUS='UNKNOWN' -c$$$ $ ,IOSTAT=iostat -c$$$ $ ) -c$$$ if(iostat.ne.0)then -c$$$ print*,'READETAPARAM: *** Error in opening file ***' -c$$$ return -c$$$ endif -c$$$ print*,'---- ANGULAR BINNING ----' -c$$$ print*,'Bin - angL - angR' -c$$$ 101 format(i2,' ',f6.2,' ',f6.2) -c$$$ do ibin=1,nangmax -c$$$ read(10,* -c$$$ $ ,IOSTAT=iostat -c$$$ $ )xnn,angL(ibin),angR(ibin) -c$$$ if(iostat.ne.0)goto 1000 -c$$$ write(*,101)int(xnn),angL(ibin),angR(ibin) -c$$$ enddo -c$$$ 1000 nangbin=int(xnn) -c$$$ close(10) -c$$$ print*,'-------------------------' -c$$$ -c$$$ -c$$$ -c$$$ do ieta=2,4 !loop on eta 2,3,4 -c$$$******retrieve correction parameters -c$$$ 200 format(' Opening eta',i1,' files...') -c$$$ write(*,200)ieta -c$$$ -c$$$ 201 format('eta',i1,'-bin',i1,'-l',i1,'.dat') -c$$$ 202 format('eta',i1,'-bin',i2,'-l',i1,'.dat') -c$$$ do iang=1,nangbin -c$$$ do ilad=1,nladders_view -c$$$ if(iang.lt.10)write(fname_param,201)ieta,iang,ilad -c$$$ if(iang.ge.10)write(fname_param,202)ieta,iang,ilad -c$$$c print *,'Opening file: ',fname_param -c$$$ open(10, -c$$$ $ FILE='./bin-aux/'//fname_param(1:LNBLNK(fname_param)) -c$$$ $ ,STATUS='UNKNOWN' -c$$$ $ ,IOSTAT=iostat -c$$$ $ ) -c$$$ if(iostat.ne.0)then -c$$$ print*,'READETAPARAM: *** Error in opening file ***' -c$$$ return -c$$$ endif -c$$$ do ival=1,netavalmax -c$$$ if(ieta.eq.2)read(10,* -c$$$ $ ,IOSTAT=iostat -c$$$ $ ) -c$$$ $ eta2(ival,iang), -c$$$ $ (feta2(ival,iv,ilad,iang),iv=1,nviews) -c$$$ if(ieta.eq.3)read(10,* -c$$$ $ ,IOSTAT=iostat -c$$$ $ ) -c$$$ $ eta3(ival,iang), -c$$$ $ (feta3(ival,iv,ilad,iang),iv=1,nviews) -c$$$ if(ieta.eq.4)read(10,* -c$$$ $ ,IOSTAT=iostat -c$$$ $ ) -c$$$ $ eta4(ival,iang), -c$$$ $ (feta4(ival,iv,ilad,iang),iv=1,nviews) -c$$$ if(iostat.ne.0)then -c$$$ netaval=ival-1 -c$$$c$$$ if(eta2(1,iang).ne.-eta2(netaval,iang)) -c$$$c$$$ $ print*,'**** ERROR on parameters !!! ****' -c$$$ goto 2000 -c$$$ endif -c$$$ enddo -c$$$ 2000 close(10) -c$$$* print*,'... done' -c$$$ enddo -c$$$ enddo -c$$$ -c$$$ enddo !end loop on eta 2,3,4 -c$$$ -c$$$ -c$$$ return -c$$$ end -c$$$ - ************************************************************ ************************************************************ @@ -556,6 +628,8 @@ * PFAy - Position Finding Algorithm in y (COG2,ETA2,...) * angx - Projected angle in x * angy - Projected angle in y +* bfx - x-component of magnetci field +* bfy - y-component of magnetic field * * --------- COUPLES ------------------------------------------------------- * The couple defines a point in the space. @@ -594,45 +668,35 @@ * * - subroutine xyz_PAM(icx,icy,sensor,PFAx,PFAy,angx,angy) + subroutine xyz_PAM(icx,icy,sensor,PFAx,PFAy,ax,ay,bfx,bfy) -c***************************************************** -c 07/10/2005 modified by elena vannuccini --> (1) -c 01/02/2006 modified by elena vannuccini --> (2) -c 02/02/2006 modified by Elena Vannuccini --> (3) -c (implemented new p.f.a.) -c 03/02/2006 modified by Elena Vannuccini --> (4) -c (implemented variable resolution) -c***************************************************** include 'commontracker.f' - include 'calib.f' include 'level1.f' + include 'calib.f' include 'common_align.f' include 'common_mech.f' include 'common_xyzPAM.f' - include 'common_resxy.f' - - logical DEBUG - common/dbg/DEBUG integer icx,icy !X-Y cluster ID integer sensor integer viewx,viewy character*4 PFAx,PFAy !PFA to be used - real angx,angy !X-Y angle + real ax,ay !X-Y geometric angle + real angx,angy !X-Y effective angle + real bfx,bfy !X-Y b-field components real stripx,stripy double precision xrt,yrt,zrt double precision xrt_A,yrt_A,zrt_A 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 parameter (ndivx=30) + + +c$$$ print*,icx,icy,sensor,PFAx,PFAy,ax,ay,bfx,bfy resxPAM = 0 resyPAM = 0 @@ -646,124 +710,305 @@ xPAM_B = 0. yPAM_B = 0. zPAM_B = 0. +c print*,'## xyz_PAM: ',icx,icy,sensor,PFAx,PFAy,angx,angy + + if(sensor.lt.1.or.sensor.gt.2)then + print*,'xyz_PAM ***ERROR*** wrong input ' + print*,'sensor ',sensor + icx=0 + icy=0 + endif * ----------------- * CLUSTER X -* ----------------- - +* ----------------- if(icx.ne.0)then - viewx = VIEW(icx) - nldx = nld(MAXS(icx),VIEW(icx)) - nplx = npl(VIEW(icx)) - resxPAM = RESXAV !!!!!!!TEMPORANEO!!!!!!!!!!!!!!!! - - stripx = float(MAXS(icx)) - if(PFAx.eq.'COG1')then !(1) - stripx = stripx !(1) - resxPAM = resxPAM !(1) + + viewx = VIEW(icx) + nldx = nld(MAXS(icx),VIEW(icx)) + nplx = npl(VIEW(icx)) + resxPAM = RESXAV + stripx = float(MAXS(icx)) + + if( + $ viewx.lt.1.or. + $ viewx.gt.12.or. + $ nldx.lt.1.or. + $ nldx.gt.3.or. + $ stripx.lt.1.or. + $ stripx.gt.3072.or. + $ .false.)then + print*,'xyz_PAM ***ERROR*** wrong input ' + print*,'icx ',icx,'view ',viewx,'nld ',nldx,'strip ',stripx + icx = 0 + goto 10 + endif + +* -------------------------- +* magnetic-field corrections +* -------------------------- + angtemp = ax + bfytemp = bfy +* ///////////////////////////////// +* AAAAHHHHHHHH!!!!!!!!!!!!!!!!!!!!! +* *grvzkkjsdgjhhhgngbn###>:( +* ///////////////////////////////// +c if(nplx.eq.6) angtemp = -1. * ax +c if(nplx.eq.6) bfytemp = -1. * bfy + if(viewx.eq.12) angtemp = -1. * ax + if(viewx.eq.12) bfytemp = -1. * bfy + tgtemp = tan(angtemp*acos(-1.)/180.) + pmuH_h*bfytemp*0.00001 + angx = 180.*atan(tgtemp)/acos(-1.) + stripx = stripx - 0.5*pmuH_h*bfytemp*0.00001*SiDimZ/pitchX +c$$$ print*,nplx,ax,bfy/10. +c$$$ print*,angx,0.5*pmuH_h*bfytemp*0.00001*SiDimZ/pitchX +c$$$ print*,'========================' +c$$$ if(bfy.ne.0.)print*,viewx,'-x- ' +c$$$ $ ,bfy,-1*0.5*pmuH_h*bfytemp*0.00001*SiDimZ +* -------------------------- + +c$$$ print*,'--- x-cl ---' +c$$$ istart = INDSTART(ICX) +c$$$ istop = TOTCLLENGTH +c$$$ if(icx.lt.NCLSTR1)istop=INDSTART(ICX+1)-1 +c$$$ print*,(CLSIGNAL(i)/CLSIGMA(i),i=istart,istop) +c$$$ print*,(CLSIGNAL(i),i=istart,istop) +c$$$ print*,INDMAX(icx) +c$$$ print*,cog(4,icx) +c$$$ print*,fbad_cog(4,icx) + + + if(PFAx.eq.'COG1')then + + stripx = stripx + resxPAM = 1e-4*pitchX/sqrt(12.)!!resxPAM + elseif(PFAx.eq.'COG2')then - stripx = stripx + cog(2,icx) + + stripx = stripx + cog(2,icx) + resxPAM = risx_cog(abs(angx))!TEMPORANEO resxPAM = resxPAM*fbad_cog(2,icx) + + elseif(PFAx.eq.'COG3')then + + stripx = stripx + cog(3,icx) + resxPAM = risx_cog(abs(angx))!TEMPORANEO + resxPAM = resxPAM*fbad_cog(3,icx) + + elseif(PFAx.eq.'COG4')then + + stripx = stripx + cog(4,icx) + resxPAM = risx_cog(abs(angx))!TEMPORANEO + resxPAM = resxPAM*fbad_cog(4,icx) + elseif(PFAx.eq.'ETA2')then -c cog2 = cog(2,icx) -c etacorr = pfa_eta2(cog2,viewx,nldx,angx) -c stripx = stripx + etacorr - stripx = stripx + pfa_eta2(icx,angx) !(3) - resxPAM = risx_eta2(angx) ! (4) - if(DEBUG.and.fbad_cog(2,icx).ne.1) - $ print*,'BAD icx >>> ',viewx,fbad_cog(2,icx) + + stripx = stripx + pfaeta2(icx,angx) + resxPAM = risxeta2(abs(angx)) resxPAM = resxPAM*fbad_cog(2,icx) - elseif(PFAx.eq.'ETA3')then !(3) - stripx = stripx + pfa_eta3(icx,angx) !(3) - resxPAM = risx_eta3(angx) ! (4) - if(DEBUG.and.fbad_cog(3,icx).ne.1) !(3) - $ print*,'BAD icx >>> ',viewx,fbad_cog(3,icx)!(3) - resxPAM = resxPAM*fbad_cog(3,icx) !(3) - elseif(PFAx.eq.'ETA4')then !(3) - stripx = stripx + pfa_eta4(icx,angx) !(3) - resxPAM = risx_eta4(angx) ! (4) - if(DEBUG.and.fbad_cog(4,icx).ne.1) !(3) - $ print*,'BAD icx >>> ',viewx,fbad_cog(4,icx)!(3) - resxPAM = resxPAM*fbad_cog(4,icx) !(3) - elseif(PFAx.eq.'ETA')then !(3) - stripx = stripx + pfa_eta(icx,angx) !(3) - resxPAM = ris_eta(icx,angx) ! (4) - if(DEBUG.and.fbad_cog(2,icx).ne.1) !(3) - $ print*,'BAD icx >>> ',viewx,fbad_cog(2,icx)!(3) -c resxPAM = resxPAM*fbad_cog(2,icx) !(3)TEMPORANEO - resxPAM = resxPAM*fbad_eta(icx,angx) !(3)(4) - elseif(PFAx.eq.'COG')then !(2) - stripx = stripx + cog(0,icx) !(2) - resxPAM = risx_cog(angx) ! (4) - resxPAM = resxPAM*fbad_cog(0,icx)!(2) +c$$$ if(DEBUG.EQ.1.and.fbad_cog(2,icx).ne.1) +c$$$ $ print*,'BAD icx >>> ',viewx,fbad_cog(2,icx) + + elseif(PFAx.eq.'ETA3')then + + stripx = stripx + pfaeta3(icx,angx) + resxPAM = risxeta3(abs(angx)) + resxPAM = resxPAM*fbad_cog(3,icx) +c if(DEBUG.and.fbad_cog(3,icx).ne.1) +c $ print*,'BAD icx >>> ',viewx,fbad_cog(3,icx) + + elseif(PFAx.eq.'ETA4')then + + stripx = stripx + pfaeta4(icx,angx) + resxPAM = risxeta4(abs(angx)) + resxPAM = resxPAM*fbad_cog(4,icx) +c if(DEBUG.and.fbad_cog(4,icx).ne.1) +c $ print*,'BAD icx >>> ',viewx,fbad_cog(4,icx) + + elseif(PFAx.eq.'ETA')then + + stripx = stripx + pfaeta(icx,angx) +c resxPAM = riseta(icx,angx) + resxPAM = riseta(viewx,angx) + resxPAM = resxPAM*fbad_eta(icx,angx) +c if(DEBUG.and.fbad_cog(2,icx).ne.1) +c $ print*,'BAD icx >>> ',viewx,fbad_cog(2,icx) + + elseif(PFAx.eq.'ETAL')then + + stripx = stripx + pfaetal(icx,angx) + resxPAM = riseta(viewx,angx) + resxPAM = resxPAM*fbad_eta(icx,angx) +c if(DEBUG.and.fbad_cog(2,icx).ne.1) +c $ print*,'BAD icx >>> ',viewx,fbad_cog(2,icx) + + elseif(PFAx.eq.'COG')then + + stripx = stripx + cog(0,icx) + resxPAM = risx_cog(abs(angx)) + resxPAM = resxPAM*fbad_cog(0,icx) + else - print*,'*** Non valid p.f.a. (x) --> ',PFAx + if(DEBUG.EQ.1) print*,'*** Non valid p.f.a. (x) --> ',PFAx endif - endif - + +* ====================================== +* temporary patch for saturated clusters +* ====================================== + if( nsatstrips(icx).gt.0 )then + stripx = stripx + cog(4,icx) + resxPAM = pitchX*1e-4/sqrt(12.) +cc cc=cog(4,icx) +c$$$ print*,icx,' *** ',cc +c$$$ print*,icx,' *** ',resxPAM + endif + + 10 endif + + * ----------------- * CLUSTER Y * ----------------- if(icy.ne.0)then + viewy = VIEW(icy) nldy = nld(MAXS(icy),VIEW(icy)) nply = npl(VIEW(icy)) - resyPAM = RESYAV !!!!!!!TEMPORANEO!!!!!!!!!!!!!!!! + resyPAM = RESYAV + stripy = float(MAXS(icy)) + if( + $ viewy.lt.1.or. + $ viewy.gt.12.or. + $ nldy.lt.1.or. + $ nldy.gt.3.or. + $ stripy.lt.1.or. + $ stripy.gt.3072.or. + $ .false.)then + print*,'xyz_PAM ***ERROR*** wrong input ' + print*,'icy ',icy,'view ',viewy,'nld ',nldy,'strip ',stripy + icy = 0 + goto 20 + endif if(icx.ne.0.and.(nply.ne.nplx.or.nldy.ne.nldx))then - print*,'xyz_PAM ***ERROR*** invalid cluster couple!!! ' - $ ,icx,icy + if(DEBUG.EQ.1) then + print*,'xyz_PAM ***ERROR*** invalid cluster couple!!! ' + $ ,icx,icy + endif goto 100 endif - - stripy = float(MAXS(icy)) - if(PFAy.eq.'COG1')then !(1) - stripy = stripy !(1) - resyPAM = resyPAM !(1) +* -------------------------- +* magnetic-field corrections +* -------------------------- + tgtemp = tan(ay*acos(-1.)/180.)+pmuH_e*bfx*0.00001 + angy = 180.*atan(tgtemp)/acos(-1.) + stripy = stripy + 0.5*pmuH_e*bfx*0.00001*SiDimZ/pitchY +c$$$ if(bfx.ne.0.)print*,viewy,'-y- ' +c$$$ $ ,bfx,0.5*pmuH_e*bfx*0.00001*SiDimZ +* -------------------------- + +c$$$ print*,'--- y-cl ---' +c$$$ istart = INDSTART(ICY) +c$$$ istop = TOTCLLENGTH +c$$$ if(icy.lt.NCLSTR1)istop=INDSTART(ICY+1)-1 +c$$$ print*,(CLSIGNAL(i)/CLSIGMA(i),i=istart,istop) +c$$$ print*,(CLSIGNAL(i),i=istart,istop) +c$$$ print*,INDMAX(icy) +c$$$ print*,cog(4,icy) +c$$$ print*,fbad_cog(4,icy) + + if(PFAy.eq.'COG1')then + + stripy = stripy + resyPAM = 1e-4*pitchY/sqrt(12.)!resyPAM + elseif(PFAy.eq.'COG2')then - stripy = stripy + cog(2,icy) + + stripy = stripy + cog(2,icy) + resyPAM = risy_cog(abs(angy))!TEMPORANEO resyPAM = resyPAM*fbad_cog(2,icy) + + elseif(PFAy.eq.'COG3')then + + stripy = stripy + cog(3,icy) + resyPAM = risy_cog(abs(angy))!TEMPORANEO + resyPAM = resyPAM*fbad_cog(3,icy) + + elseif(PFAy.eq.'COG4')then + + stripy = stripy + cog(4,icy) + resyPAM = risy_cog(abs(angy))!TEMPORANEO + resyPAM = resyPAM*fbad_cog(4,icy) + elseif(PFAy.eq.'ETA2')then -c cog2 = cog(2,icy) -c etacorr = pfa_eta2(cog2,viewy,nldy,angy) -c stripy = stripy + etacorr - stripy = stripy + pfa_eta2(icy,angy) !(3) - resyPAM = risy_eta2(angy) ! (4) + + stripy = stripy + pfaeta2(icy,angy) + resyPAM = risyeta2(abs(angy)) resyPAM = resyPAM*fbad_cog(2,icy) - if(DEBUG.and.fbad_cog(2,icy).ne.1) - $ print*,'BAD icy >>> ',viewy,fbad_cog(2,icy) - elseif(PFAy.eq.'ETA3')then !(3) - stripy = stripy + pfa_eta3(icy,angy) !(3) - resyPAM = resyPAM*fbad_cog(3,icy) !(3) - if(DEBUG.and.fbad_cog(3,icy).ne.1) !(3) - $ print*,'BAD icy >>> ',viewy,fbad_cog(3,icy)!(3) - elseif(PFAy.eq.'ETA4')then !(3) - stripy = stripy + pfa_eta4(icy,angy) !(3) - resyPAM = resyPAM*fbad_cog(4,icy) !(3) - if(DEBUG.and.fbad_cog(4,icy).ne.1) !(3) - $ print*,'BAD icy >>> ',viewy,fbad_cog(4,icy)!(3) - elseif(PFAy.eq.'ETA')then !(3) - stripy = stripy + pfa_eta(icy,angy) !(3) - resyPAM = ris_eta(icy,angy) ! (4) -c resyPAM = resyPAM*fbad_cog(2,icy) !(3)TEMPORANEO - resyPAM = resyPAM*fbad_eta(icy,angy) ! (4) - if(DEBUG.and.fbad_cog(2,icy).ne.1) !(3) - $ print*,'BAD icy >>> ',viewy,fbad_cog(2,icy)!(3) +c if(DEBUG.and.fbad_cog(2,icy).ne.1) +c $ print*,'BAD icy >>> ',viewy,fbad_cog(2,icy) + + elseif(PFAy.eq.'ETA3')then + + stripy = stripy + pfaeta3(icy,angy) + resyPAM = resyPAM*fbad_cog(3,icy) +c if(DEBUG.and.fbad_cog(3,icy).ne.1) +c $ print*,'BAD icy >>> ',viewy,fbad_cog(3,icy) + + elseif(PFAy.eq.'ETA4')then + + stripy = stripy + pfaeta4(icy,angy) + resyPAM = resyPAM*fbad_cog(4,icy) +c if(DEBUG.and.fbad_cog(4,icy).ne.1) +c $ print*,'BAD icy >>> ',viewy,fbad_cog(4,icy) + + elseif(PFAy.eq.'ETA')then + + stripy = stripy + pfaeta(icy,angy) +c resyPAM = riseta(icy,angy) + resyPAM = riseta(viewy,angy) + resyPAM = resyPAM*fbad_eta(icy,angy) +c if(DEBUG.and.fbad_cog(2,icy).ne.1) +c $ print*,'BAD icy >>> ',viewy,fbad_cog(2,icy) + + elseif(PFAy.eq.'ETAL')then + + stripy = stripy + pfaetal(icy,angy) + resyPAM = riseta(viewy,angy) + resyPAM = resyPAM*fbad_eta(icy,angy) +c if(DEBUG.and.fbad_cog(2,icy).ne.1) +c $ print*,'BAD icy >>> ',viewy,fbad_cog(2,icy) + elseif(PFAy.eq.'COG')then - stripy = stripy + cog(0,icy) - resyPAM = risy_cog(angy) ! (4) -c resyPAM = ris_eta(icy,angy) ! (4) + + stripy = stripy + cog(0,icy) + resyPAM = risy_cog(abs(angy)) resyPAM = resyPAM*fbad_cog(0,icy) + else - print*,'*** Non valid p.f.a. (x) --> ',PFAx + if(DEBUG.EQ.1) print*,'*** Non valid p.f.a. (x) --> ',PFAx endif - endif - +* ====================================== +* temporary patch for saturated clusters +* ====================================== + if( nsatstrips(icy).gt.0 )then + stripy = stripy + cog(4,icy) + resyPAM = pitchY*1e-4/sqrt(12.) +cc cc=cog(4,icy) +c$$$ print*,icy,' *** ',cc +c$$$ print*,icy,' *** ',resyPAM + endif + + + 20 endif + +c$$$ print*,'## stripx,stripy ',stripx,stripy + c=========================================================== C COUPLE C=========================================================== @@ -772,6 +1017,13 @@ c------------------------------------------------------------------------ c (xi,yi,zi) = mechanical coordinates in the silicon sensor frame c------------------------------------------------------------------------ + if(((mod(int(stripx+0.5)-1,1024)+1).le.3) + $ .or.((mod(int(stripx+0.5)-1,1024)+1).ge.1022)) then !X has 1018 strips... + if(DEBUG.EQ.1) then + print*,'xyz_PAM (couple):', + $ ' WARNING: false X strip: strip ',stripx + endif + endif xi = acoordsi(stripx,viewx) yi = acoordsi(stripy,viewy) zi = 0. @@ -858,6 +1110,15 @@ nldy = nldx viewy = viewx - 1 +c print*,'X-singlet ',icx,nplx,nldx,viewx,stripx +c if((stripx.le.3).or.(stripx.ge.1022)) then !X has 1018 strips... + if(((mod(int(stripx+0.5)-1,1024)+1).le.3) + $ .or.((mod(int(stripx+0.5)-1,1024)+1).ge.1022)) then !X has 1018 strips... + if(DEBUG.EQ.1) then + print*,'xyz_PAM (X-singlet):', + $ ' WARNING: false X strip: strip ',stripx + endif + endif xi = acoordsi(stripx,viewx) xi_A = xi @@ -878,10 +1139,11 @@ c print*,yi_A,' <--> ',yi_B else - - print *,'routine xyz_PAM ---> not properly used !!!' - print *,'icx = ',icx - print *,'icy = ',icy + if(DEBUG.EQ.1) then + print *,'routine xyz_PAM ---> not properly used !!!' + print *,'icx = ',icx + print *,'icy = ',icy + endif goto 100 endif @@ -946,16 +1208,203 @@ c print*,'A-(',xPAM_A,yPAM_A,') B-(',xPAM_B,yPAM_B,')' else - - print *,'routine xyz_PAM ---> not properly used !!!' - print *,'icx = ',icx - print *,'icy = ',icy - + if(DEBUG.EQ.1) then + print *,'routine xyz_PAM ---> not properly used !!!' + print *,'icx = ',icx + print *,'icy = ',icy + endif endif + +c print*,'## xPAM,yPAM,zPAM ',xPAM,yPAM,zPAM +c print*,'## xPAM_A,yPAM_A,zPAM_A ',xPAM_A,yPAM_A,zPAM_A +c print*,'## xPAM_B,yPAM_B,zPAM_B ',xPAM_B,yPAM_B,zPAM_B + 100 continue end +************************************************************************ +* Call xyz_PAM subroutine with default PFA and fill the mini2 common. +* (done to be called from c/c++) +************************************************************************ + + subroutine xyzpam(ip,icx,icy,lad,sensor,ax,ay,bfx,bfy) + + include 'commontracker.f' + include 'level1.f' + include 'common_mini_2.f' + include 'common_xyzPAM.f' + include 'common_mech.f' + include 'calib.f' + +* flag to chose PFA +c$$$ character*10 PFA +c$$$ common/FINALPFA/PFA + + integer icx,icy !X-Y cluster ID + integer sensor + character*4 PFAx,PFAy !PFA to be used + real ax,ay !X-Y geometric angle + real bfx,bfy !X-Y b-field components + + ipx=0 + ipy=0 + +c$$$ PFAx = 'COG4'!PFA +c$$$ PFAy = 'COG4'!PFA + + + if(icx.gt.nclstr1.or.icy.gt.nclstr1)then + print*,'xyzpam: ***WARNING*** clusters ',icx,icy + $ ,' does not exists (nclstr1=',nclstr1,')' + icx = -1*icx + icy = -1*icy + return + + endif + + call idtoc(pfaid,PFAx) + call idtoc(pfaid,PFAy) + +cc print*,PFAx,PFAy + +c$$$ call xyz_PAM(icx,icy,sensor,PFAx,PFAy,ax,ay,bfx,bfy) + +c$$$ print*,icx,icy,sensor,PFAx,PFAy,ax,ay,bfx,bfy + + if(icx.ne.0.and.icy.ne.0)then + + ipx=npl(VIEW(icx)) + ipy=npl(VIEW(icy)) +c$$$ if( (nplanes-ipx+1).ne.ip.or.(nplanes-ipy+1).ne.ip ) +c$$$ $ print*,'xyzpam: ***WARNING*** clusters ',icx,icy +c$$$ $ ,' does not belong to the correct plane: ',ip,ipx,ipy + + if( (nplanes-ipx+1).ne.ip )then + print*,'xyzpam: ***WARNING*** cluster ',icx + $ ,' does not belong to plane: ',ip + icx = -1*icx + return + endif + if( (nplanes-ipy+1).ne.ip )then + print*,'xyzpam: ***WARNING*** cluster ',icy + $ ,' does not belong to plane: ',ip + icy = -1*icy + return + endif + + call xyz_PAM(icx,icy,sensor,PFAx,PFAy,ax,ay,bfx,bfy) + + xgood(ip) = 1. + ygood(ip) = 1. + resx(ip) = resxPAM + resy(ip) = resyPAM + + xm(ip) = xPAM + ym(ip) = yPAM + zm(ip) = zPAM + xm_A(ip) = 0. + ym_A(ip) = 0. + xm_B(ip) = 0. + ym_B(ip) = 0. + +c zv(ip) = zPAM + + elseif(icx.eq.0.and.icy.ne.0)then + + ipy=npl(VIEW(icy)) +c$$$ if((nplanes-ipy+1).ne.ip) +c$$$ $ print*,'xyzpam: ***WARNING*** clusters ',icx,icy +c$$$ $ ,' does not belong to the correct plane: ',ip,ipx,ipy + if( (nplanes-ipy+1).ne.ip )then + print*,'xyzpam: ***WARNING*** cluster ',icy + $ ,' does not belong to plane: ',ip + icy = -1*icy + return + endif + + call xyz_PAM(icx,icy,sensor,PFAx,PFAy,ax,ay,bfx,bfy) + + xgood(ip) = 0. + ygood(ip) = 1. + resx(ip) = 1000. + resy(ip) = resyPAM + + xm(ip) = -100. + ym(ip) = -100. + zm(ip) = (zPAM_A+zPAM_B)/2. + xm_A(ip) = xPAM_A + ym_A(ip) = yPAM_A + xm_B(ip) = xPAM_B + ym_B(ip) = yPAM_B + +c zv(ip) = (zPAM_A+zPAM_B)/2. + + elseif(icx.ne.0.and.icy.eq.0)then + + ipx=npl(VIEW(icx)) +c$$$ if((nplanes-ipx+1).ne.ip) +c$$$ $ print*,'xyzpam: ***WARNING*** clusters ',icx,icy +c$$$ $ ,' does not belong to the correct plane: ',ip,ipx,ipy + + if( (nplanes-ipx+1).ne.ip )then + print*,'xyzpam: ***WARNING*** cluster ',icx + $ ,' does not belong to plane: ',ip + icx = -1*icx + return + endif + + call xyz_PAM(icx,icy,sensor,PFAx,PFAy,ax,ay,bfx,bfy) + + xgood(ip) = 1. + ygood(ip) = 0. + resx(ip) = resxPAM + resy(ip) = 1000. + + xm(ip) = -100. + ym(ip) = -100. + zm(ip) = (zPAM_A+zPAM_B)/2. + xm_A(ip) = xPAM_A + ym_A(ip) = yPAM_A + xm_B(ip) = xPAM_B + ym_B(ip) = yPAM_B + +c zv(ip) = (zPAM_A+zPAM_B)/2. + + else + + il = 2 + if(lad.ne.0)il=lad + is = 1 + if(sensor.ne.0)is=sensor +c print*,nplanes-ip+1,il,is + + xgood(ip) = 0. + ygood(ip) = 0. + resx(ip) = 1000. + resy(ip) = 1000. + + xm(ip) = -100. + ym(ip) = -100. + zm(ip) = z_mech_sensor(nplanes-ip+1,il,is)*1000./1.d4 + xm_A(ip) = 0. + ym_A(ip) = 0. + xm_B(ip) = 0. + ym_B(ip) = 0. + +c zv(ip) = z_mech_sensor(nplanes-ip+1,il,is)*1000./1.d4 + + endif + + if(DEBUG.EQ.1)then +c print*,'----------------------------- track coord' +22222 format(i2,' * ',3f10.4,' --- ',4f10.4,' --- ',2f4.0,2f10.5) + write(*,22222)ip,zm(ip),xm(ip),ym(ip) + $ ,xm_A(ip),ym_A(ip),xm_B(ip),ym_B(ip) + $ ,xgood(ip),ygood(ip),resx(ip),resy(ip) +c$$$ print*,'-----------------------------' + endif + end ******************************************************************************** ******************************************************************************** @@ -1031,7 +1480,8 @@ endif distance= - $ ((xmi-XPP)**2+(ymi-YPP)**2)/RE**2 + $ ((xmi-XPP)**2+(ymi-YPP)**2)!QUIQUI +cc $ ((xmi-XPP)**2+(ymi-YPP)**2)/RE**2 distance=dsqrt(distance) c$$$ print*,xPAM_A,yPAM_A,zPAM_A,xPAM_b,yPAM_b,zPAM_b @@ -1056,9 +1506,12 @@ * ---------------------- distance= - $ ((xPAM-XPP)/resxPAM)**2 - $ + - $ ((yPAM-YPP)/resyPAM)**2 + $ ((xPAM-XPP))**2 !QUIQUI + $ + + $ ((yPAM-YPP))**2 +c$$$ $ ((xPAM-XPP)/resxPAM)**2 +c$$$ $ + +c$$$ $ ((yPAM-YPP)/resyPAM)**2 distance=dsqrt(distance) c$$$ print*,xPAM,yPAM,zPAM @@ -1067,11 +1520,11 @@ else - print* - $ ,' function distance_to ---> wrong usage!!!' - print*,' xPAM,yPAM,zPAM ',xPAM,yPAM,zPAM - print*,' xPAM_A,yPAM_A,zPAM_A,xPAM_b,yPAM_b,zPAM_b ' - $ ,xPAM_A,yPAM_A,zPAM_A,xPAM_b,yPAM_b,zPAM_b +c print* +c $ ,' function distance_to ---> wrong usage!!!' +c print*,' xPAM,yPAM,zPAM ',xPAM,yPAM,zPAM +c print*,' 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 endif distance_to = sngl(distance) @@ -1136,6 +1589,12 @@ c------------------------------------------------------------------------ c (xi,yi,zi) = mechanical coordinates in the silicon sensor frame c------------------------------------------------------------------------ + if(((mod(int(stripx+0.5)-1,1024)+1).le.3) + $ .or.((mod(int(stripx+0.5)-1,1024)+1).ge.1022)) then !X has 1018 strips... +c if((stripx.le.3).or.(stripx.ge.1022)) then !X has 1018 strips... +c print*,'whichsensor: ', +c $ ' WARNING: false X strip: strip ',stripx + endif xi = acoordsi(stripx,viewx) yi = acoordsi(stripy,viewy) zi = 0. @@ -1263,6 +1722,7 @@ * it returns the plane number * include 'commontracker.f' + include 'level1.f' c include 'common_analysis.f' include 'common_momanhough.f' @@ -1288,7 +1748,7 @@ is_cp=0 if(id.lt.0)is_cp=1 if(id.gt.0)is_cp=2 - if(id.eq.0)print*,'IS_CP ===> wrong couple id !!!' +c if(id.eq.0)print*,'IS_CP ===> wrong couple id !!!' return end @@ -1300,6 +1760,7 @@ * it returns the id number ON THE PLANE * include 'commontracker.f' + include 'level1.f' c include 'common_analysis.f' include 'common_momanhough.f' @@ -1328,6 +1789,7 @@ * positive if sensor =2 * include 'commontracker.f' + include 'level1.f' c include 'calib.f' c include 'level1.f' c include 'common_analysis.f' @@ -1357,274 +1819,6 @@ ************************************************************************* ************************************************************************* ************************************************************************* -c$$$ subroutine book_debug -c$$$ -c$$$ include 'commontracker.f' -c$$$ include 'common_momanhough.f' -c$$$ include 'common_level2debug.f' -c$$$ -c$$$ character*35 block1,block2,block3!,block4 -c$$$ $ ,block5!,block6 -c$$$ -c$$$* * * * * * * * * * * * * * * * * * * * * * * * -c$$$* HOUGH TRANSFORM PARAMETERS -c$$$ -c$$$ call HBOOK2(1003 -c$$$ $ ,'y vs tg thyz' -c$$$ $ ,300,-1.,1. !x -c$$$ $ ,3000,-70.,70.,0.) !y -c$$$ -c$$$ call HBOOK1(1004 -c$$$ $ ,'Dy' -c$$$ $ ,100,0.,2.,0.) -c$$$ -c$$$ call HBOOK1(1005 -c$$$ $ ,'D thyz' -c$$$ $ ,100,0.,.05,0.) -c$$$ -c$$$ -c$$$ -c$$$* DEBUG ntuple: -c$$$ call HBNT(ntp_level2+1,'LEVEL2',' ') -c$$$ -c$$$ call HBNAME(ntp_level2+1,'EVENT',good2_nt, -c$$$ $ 'GOOD2:L,NEV2:I') -c$$$ -c$$$ 411 format('NDBLT:I::[0,',I5,']') -c$$$ write(block1,411) ndblt_max_nt -c$$$ call HBNAME(ntp_level2+1,'HOUGH YZ',ndblt_nt, -c$$$ $ block1//' -c$$$ $ ,ALFAYZ1(NDBLT):R -c$$$ $ ,ALFAYZ2(NDBLT):R -c$$$ $ ,DB_CLOUD(NDBLT):I -c$$$ $ ') -c$$$ -c$$$ 412 format('NTRPT:I::[0,',I5,']') -c$$$ write(block2,412) ntrpt_max_nt -c$$$ call HBNAME(ntp_level2+1,'HOUGH XZ',NTRPT_nt, -c$$$ $ block2//' -c$$$ $ ,ALFAXZ1(NTRPT):R -c$$$ $ ,ALFAXZ2(NTRPT):R -c$$$ $ ,ALFAXZ3(NTRPT):R -c$$$ $ ,TR_CLOUD(NTRPT):I -c$$$ $ ') -c$$$ -c$$$ -c$$$ 413 format('NCLOUDS_YZ:I::[0,',I4,']') -c$$$c$$$ 414 format('DB_CLOUD(',I4,'):I') -c$$$ write(block3,413) ncloyz_max -c$$$c$$$ write(block4,414) ndblt_max_nt -c$$$ call HBNAME(ntp_level2+1,'CLOUD YZ',NCLOUDS_YZ, -c$$$ $ block3//' -c$$$ $ ,ALFAYZ1_AV(NCLOUDS_YZ):R -c$$$ $ ,ALFAYZ2_AV(NCLOUDS_YZ):R -c$$$ $ ,PTCLOUD_YZ(NCLOUDS_YZ):I' -c$$$c$$$ $ ,'//block4 -c$$$ $ ) -c$$$ -c$$$ 415 format('NCLOUDS_XZ:I::[0,',I4,']') -c$$$c$$$ 416 format('TR_CLOUD(',I5,'):I') -c$$$ write(block5,415) ncloxz_max -c$$$c$$$ write(block6,416) ntrpt_max_nt -c$$$ call HBNAME(ntp_level2+1,'CLOUD XZ',NCLOUDS_XZ, -c$$$ $ block5//' -c$$$ $ ,ALFAXZ1_AV(NCLOUDS_XZ):R -c$$$ $ ,ALFAXZ2_AV(NCLOUDS_XZ):R -c$$$ $ ,ALFAXZ3_AV(NCLOUDS_XZ):R -c$$$ $ ,PTCLOUD_XZ(NCLOUDS_XZ):I' -c$$$c$$$ $ ,'//block6 -c$$$ $ ) -c$$$ -c$$$ -c$$$ return -c$$$ end -***...***...***...***...***...***...***...***...***...***...***...***...***...***...***...*** -* -* -* -* -* -* -* -* -* -***...***...***...***...***...***...***...***...***...***...***...***...***...***...***...*** -c$$$ subroutine book_level2 -c$$$c***************************************************** -c$$$cccccc 11/9/2005 modified by david fedele -c$$$cccccc 07/10/2005 modified by elena vannuccini --> (2) -c$$$c***************************************************** -c$$$ -c$$$ include 'commontracker.f' -c$$$ include 'common_momanhough.f' -c$$$ include 'level2.f' -c$$$ -c$$$ character*35 block1,block2 -c$$$ -c$$$c print*,'__________ booking LEVEL2 n-tuple __________' -c$$$ -c$$$* LEVEL1 ntuple: -c$$$ call HBNT(ntp_level2,'LEVEL2',' ') -c$$$ -c$$$c***************************************************** -c$$$cccccc 11/9/2005 modified by david fedele -c$$$c call HBNAME(ntp_level2,'EVENT',good2,'GOOD2:L,NEV2:I') -c$$$cccccc 06/10/2005 modified by elena vannuccini -c$$$c call HBNAME(ntp_level2,'GENERAL',good2,'GOOD2:L,NEV2:I -c$$$c $ ,WHIC_CALIB:I,SWCODE:I') -c$$$ call HBNAME(ntp_level2,'GENERAL',good2,'GOOD2:L,NEV2:I -c$$$ $ ,WHICH_CALIB:I,SWCODE:I,CRC(12):L') -c$$$c********************************************************* -c$$$ -c$$$ -c$$$c$$$# ifndef TEST2003 -c$$$c$$$ -c$$$c$$$ call HBNAME(ntp_level2,'CPU',pkt_type -c$$$c$$$ $ ,'PKT_TYPE:I::[0,50] -c$$$c$$$ $ ,PKT_NUM:I -c$$$c$$$ $ ,OBT:I'// -c$$$c$$$c******************************************************** -c$$$c$$$cccccc 11/9/2005 modified by david fedele -c$$$c$$$c $ ,WHICH_CALIB:I::[0,50]') -c$$$c$$$ $ ',CPU_CRC:L') -c$$$c$$$c******************************************************** -c$$$c$$$ -c$$$c$$$# endif -c$$$ -c$$$ 417 format('NTRK:I::[0,',I4,']') -c$$$ 418 format(',IMAGE(NTRK):I::[0,',I4,']') -c$$$ write(block1,417)NTRKMAX -c$$$ write(block2,418)NTRKMAX -c$$$ call HBNAME(ntp_level2,'TRACKS',NTRK, -c$$$ $ block1// -c$$$ $ block2//' -c$$$ $ ,XM(6,NTRK):R -c$$$ $ ,YM(6,NTRK):R -c$$$ $ ,ZM(6,NTRK):R -c$$$ $ ,RESX(6,NTRK):R -c$$$ $ ,RESY(6,NTRK):R -c$$$ $ ,AL(5,NTRK):R -c$$$ $ ,COVAL(5,5,NTRK):R -c$$$ $ ,CHI2(NTRK):R -c$$$ $ ,XGOOD(6,NTRK):I::[0,1] -c$$$ $ ,YGOOD(6,NTRK):I::[0,1] -c$$$ $ ,XV(6,NTRK):R -c$$$ $ ,YV(6,NTRK):R -c$$$ $ ,ZV(6,NTRK):R -c$$$ $ ,AXV(6,NTRK):R -c$$$ $ ,AYV(6,NTRK):R'// -c$$$c***************************************************** -c$$$cccccc 11/9/2005 modified by david fedele -c$$$c $ ,DEDXP(6,NTRK):R'// -c$$$c $ ') -c$$$ $ ',DEDX_X(6,NTRK):R -c$$$ $ ,DEDX_Y(6,NTRK):R'// -c$$$c**************************************************** -c$$$cccccc 06/10/2005 modified by elena vannuccini -c$$$c $ ,CRC(12):L -c$$$ $ ',BdL(NTRK):R' -c$$$ $ ) -c$$$c**************************************************** -c$$$ -c$$$ -c$$$ call HBNAME(ntp_level2,'SINGLETX',nclsx, -c$$$c***************************************************** -c$$$cccccc 11/9/2005 modified by david fedele -c$$$c $ 'NCLSX(6):I,NCLSY(6):I') -c$$$ $ 'NCLSX:I::[0,500],PLANEX(NCLSX):I -c$$$ $ ,XS(2,NCLSX):R,SGNLXS(NCLSX):R') !(2) -c$$$c $ ,XS(NCLSX):R,SGNLXS(NCLSX):R') !(2) -c$$$ call HBNAME(ntp_level2,'SINGLETY',nclsy, -c$$$ $ 'NCLSY:I::[0,500],PLANEY(NCLSY):I -c$$$ $ ,YS(2,NCLSY):R,SGNLYS(NCLSY):R') !(2) -c$$$c $ ,YS(NCLSY):R,SGNLYS(NCLSY):R') !(2) -c$$$ return -c$$$ end - -c$$$ subroutine fill_level2_clouds -c$$$c***************************************************** -c$$$c 29/11/2005 created by elena vannuccini -c$$$c***************************************************** -c$$$ -c$$$* ------------------------------------------------------- -c$$$* This routine fills the variables related to the hough -c$$$* transform, for the debig n-tuple -c$$$* ------------------------------------------------------- -c$$$ -c$$$ include 'commontracker.f' -c$$$ include 'common_momanhough.f' -c$$$ include 'common_level2debug.f' -c$$$ include 'level2.f' -c$$$ -c$$$ good2_nt=.true.!good2 -c$$$c nev2_nt=nev2 -c$$$ -c$$$ if(.false. -c$$$ $ .or.ntrpt.gt.ntrpt_max_nt -c$$$ $ .or.ndblt.gt.ndblt_max_nt -c$$$ $ .or.NCLOUDS_XZ.gt.ncloxz_max -c$$$ $ .or.NCLOUDS_yZ.gt.ncloyz_max -c$$$ $ )then -c$$$ good2_nt=.false. -c$$$ ntrpt_nt=0 -c$$$ ndblt_nt=0 -c$$$ NCLOUDS_XZ_nt=0 -c$$$ NCLOUDS_YZ_nt=0 -c$$$ else -c$$$ ndblt_nt=ndblt -c$$$ ntrpt_nt=ntrpt -c$$$ if(ndblt.ne.0)then -c$$$ do id=1,ndblt -c$$$ alfayz1_nt(id)=alfayz1(id) !Y0 -c$$$ alfayz2_nt(id)=alfayz2(id) !tg theta-yz -c$$$c db_cloud_nt(id)=db_cloud(id) -c$$$ enddo -c$$$ endif -c$$$ if(ndblt.ne.0)then -c$$$ do it=1,ntrpt -c$$$ alfaxz1_nt(it)=alfaxz1(it) !X0 -c$$$ alfaxz2_nt(it)=alfaxz2(it) !tg theta-xz -c$$$ alfaxz3_nt(it)=alfaxz3(it) !1/r -c$$$c tr_cloud_nt(it)=tr_cloud(it) -c$$$ enddo -c$$$ endif -c$$$ nclouds_yz_nt=nclouds_yz -c$$$ nclouds_xz_nt=nclouds_xz -c$$$ if(nclouds_yz.ne.0)then -c$$$ nnn=0 -c$$$ do iyz=1,nclouds_yz -c$$$ ptcloud_yz_nt(iyz)=ptcloud_yz(iyz) -c$$$ alfayz1_av_nt(iyz)=alfayz1_av(iyz) -c$$$ alfayz2_av_nt(iyz)=alfayz2_av(iyz) -c$$$ nnn=nnn+ptcloud_yz(iyz) -c$$$ enddo -c$$$ do ipt=1,nnn -c$$$ db_cloud_nt(ipt)=db_cloud(ipt) -c$$$ enddo -c$$$c print*,'#### ntupla #### ptcloud_yz ' -c$$$c $ ,(ptcloud_yz(i),i=1,nclouds_yz) -c$$$c print*,'#### ntupla #### db_cloud ' -c$$$c $ ,(db_cloud(i),i=1,nnn) -c$$$ endif -c$$$ if(nclouds_xz.ne.0)then -c$$$ nnn=0 -c$$$ do ixz=1,nclouds_xz -c$$$ ptcloud_xz_nt(ixz)=ptcloud_xz(ixz) -c$$$ alfaxz1_av_nt(ixz)=alfaxz1_av(ixz) -c$$$ alfaxz2_av_nt(ixz)=alfaxz2_av(ixz) -c$$$ alfaxz3_av_nt(ixz)=alfaxz3_av(ixz) -c$$$ nnn=nnn+ptcloud_xz(ixz) -c$$$ enddo -c$$$ do ipt=1,nnn -c$$$ tr_cloud_nt(ipt)=tr_cloud(ipt) -c$$$ enddo -c$$$c print*,'#### ntupla #### ptcloud_xz ' -c$$$c $ ,(ptcloud_xz(i),i=1,nclouds_xz) -c$$$c print*,'#### ntupla #### tr_cloud ' -c$$$c $ ,(tr_cloud(i),i=1,nnn) -c$$$ endif -c$$$ endif -c$$$ end *************************************************** @@ -1639,13 +1833,11 @@ subroutine cl_to_couples(iflag) include 'commontracker.f' + include 'level1.f' include 'common_momanhough.f' - include 'momanhough_init.f' +c include 'momanhough_init.f' include 'calib.f' - include 'level1.f' - - logical DEBUG - common/dbg/DEBUG +c include 'level1.f' * output flag * -------------- @@ -1654,7 +1846,9 @@ * -------------- integer iflag - integer badseed,badcl + integer badseed,badclx,badcly + + if(DEBUG.EQ.1)print*,'cl_to_couples:' * init variables ncp_tot=0 @@ -1670,237 +1864,49 @@ ncls(ip)=0 enddo do icl=1,nclstrmax_level2 - cl_single(icl)=1 - cl_good(icl)=0 + cl_single(icl) = 1 + cl_good(icl) = 0 + enddo + do iv=1,nviews + ncl_view(iv) = 0 + mask_view(iv) = 0 !all included enddo -* start association - ncouples=0 - do icx=1,nclstr1 !loop on cluster (X) - if(mod(VIEW(icx),2).eq.1)goto 10 - -* ---------------------------------------------------- -* cut on charge (X VIEW) - if(dedx(icx).lt.dedx_x_min)then - cl_single(icx)=0 - goto 10 - endif -* cut BAD (X VIEW) - badseed=BAD(VIEW(icx),nvk(MAXS(icx)),nst(MAXS(icx))) - ifirst=INDSTART(icx) - if(icx.ne.nclstr1) then - ilast=INDSTART(icx+1)-1 - else - ilast=TOTCLLENGTH - endif - badcl=badseed - do igood=-ngoodstr,ngoodstr - ibad=1 - if((INDMAX(icx)+igood).gt.ifirst.and. - $ (INDMAX(icx)+igood).lt.ilast.and. - $ .true.)then - ibad=BAD(VIEW(icx), - $ nvk(MAXS(icx)+igood), - $ nst(MAXS(icx)+igood)) - endif - badcl=badcl*ibad - enddo -c if(badcl.eq.0)then -c cl_single(icx)=0 -c goto 10 -c endif -* ---------------------------------------------------- - - cl_good(icx)=1 - nplx=npl(VIEW(icx)) - nldx=nld(MAXS(icx),VIEW(icx)) - - do icy=1,nclstr1 !loop on cluster (Y) - if(mod(VIEW(icy),2).eq.0)goto 20 - -* ---------------------------------------------------- -* cut on charge (Y VIEW) - if(dedx(icy).lt.dedx_y_min)then - cl_single(icy)=0 - goto 20 - endif -* cut BAD (Y VIEW) - badseed=BAD(VIEW(icy),nvk(MAXS(icy)),nst(MAXS(icy))) - ifirst=INDSTART(icy) - if(icy.ne.nclstr1) then - ilast=INDSTART(icy+1)-1 - else - ilast=TOTCLLENGTH - endif - badcl=badseed - do igood=-ngoodstr,ngoodstr - ibad=1 - if((INDMAX(icy)+igood).gt.ifirst.and. - $ (INDMAX(icy)+igood).lt.ilast.and. - $ .true.) - $ ibad=BAD(VIEW(icy), - $ nvk(MAXS(icy)+igood), - $ nst(MAXS(icy)+igood)) - badcl=badcl*ibad - enddo -c if(badcl.eq.0)then -c cl_single(icy)=0 -c goto 20 -c endif -* ---------------------------------------------------- - - - cl_good(icy)=1 - nply=npl(VIEW(icy)) - nldy=nld(MAXS(icy),VIEW(icy)) - -* ---------------------------------------------- -* CONDITION TO FORM A COUPLE -* ---------------------------------------------- -* geometrical consistency (same plane and ladder) - if(nply.eq.nplx.and.nldy.eq.nldx)then -* charge correlation - ddd=(dedx(icy) - $ -kch(nplx,nldx)*dedx(icx)-cch(nplx,nldx)) - ddd=ddd/sqrt(kch(nplx,nldx)**2+1) - cut=chcut*sch(nplx,nldx) - if(abs(ddd).gt.cut)goto 20 !charge not consistent - - -* ------------------> COUPLE <------------------ -* check to do not overflow vector dimentions - if(ncp_plane(nplx).gt.ncouplemax)then - if(DEBUG)print*, - $ ' ** warning ** number of identified'// - $ ' couples on plane ',nplx, - $ ' exceeds vector dimention'// - $ ' ( ',ncouplemax,' )' -c good2=.false. -c goto 880 !fill ntp and go to next event - iflag=1 - return - endif - - if(ncp_plane(nplx).eq.ncouplemax)then - if(DEBUG)print*, - $ '** warning ** number of identified '// - $ 'couples on plane ',nplx, - $ 'exceeds vector dimention ' - $ ,'( ',ncouplemax,' )' -c good2=.false. -c goto 880 !fill ntp and go to next event - iflag=1 - return - endif - - ncp_plane(nplx) = ncp_plane(nplx) + 1 - clx(nplx,ncp_plane(nplx))=icx - cly(nply,ncp_plane(nplx))=icy - cl_single(icx)=0 - cl_single(icy)=0 - endif -* ---------------------------------------------- - - 20 continue - enddo !end loop on clusters(Y) - - 10 continue - enddo !end loop on clusters(X) - - +* count number of cluster per view do icl=1,nclstr1 - if(cl_single(icl).eq.1)then - ip=npl(VIEW(icl)) - ncls(ip)=ncls(ip)+1 - cls(ip,ncls(ip))=icl - endif + ncl_view(VIEW(icl)) = ncl_view(VIEW(icl)) + 1 enddo - - - if(DEBUG)then - print*,'clusters ',nclstr1 - print*,'good ',(cl_good(i),i=1,nclstr1) - print*,'singles ',(cl_single(i),i=1,nclstr1) - print*,'couples per plane: ',(ncp_plane(ip),ip=1,nplanes) - endif - - do ip=1,6 - ncp_tot=ncp_tot+ncp_plane(ip) +* mask views with too many clusters + do iv=1,nviews + if( ncl_view(iv).gt. nclusterlimit)then +c mask_view(iv) = 1 + mask_view(iv) = mask_view(iv) + 2**0 + if(DEBUG.EQ.1) + $ print*,' * WARNING * cl_to_couple: n.clusters > ' + $ ,nclusterlimit,' on view ', iv,' --> masked!' + endif enddo -c if(ncp_tot.gt.ncp_max)goto 100!next event (TEMPORANEO!!!) - - if(ncp_tot.gt.ncp_max)then - if(DEBUG)print*, - $ '** warning ** number of identified '// - $ 'couples exceeds upper limit for Hough tr. ' - $ ,'( ',ncp_max,' )' -c good2=.false. -c goto 880 !fill ntp and go to next event - iflag=1 - return - endif - - return - end - -*************************************************** -* * -* * -* * -* * -* * -* * -************************************************** - subroutine cl_to_couples_nocharge(iflag) - include 'commontracker.f' - include 'common_momanhough.f' - include 'momanhough_init.f' - include 'calib.f' - include 'level1.f' - logical DEBUG - common/dbg/DEBUG - -* output flag -* -------------- -* 0 = good event -* 1 = bad event -* -------------- - integer iflag - - integer badseed,badcl - -* init variables - ncp_tot=0 - do ip=1,nplanes - do ico=1,ncouplemax - clx(ip,ico)=0 - cly(ip,ico)=0 - enddo - ncp_plane(ip)=0 - do icl=1,nclstrmax_level2 - cls(ip,icl)=1 - enddo - ncls(ip)=0 - enddo - do icl=1,nclstrmax_level2 - cl_single(icl)=1 - cl_good(icl)=0 - enddo - * start association ncouples=0 do icx=1,nclstr1 !loop on cluster (X) if(mod(VIEW(icx),2).eq.1)goto 10 * ---------------------------------------------------- +* jump masked views (X VIEW) +* ---------------------------------------------------- + if( mask_view(VIEW(icx)).ne.0 ) goto 10 +* ---------------------------------------------------- * cut on charge (X VIEW) - if(dedx(icx).lt.dedx_x_min)then +* ---------------------------------------------------- + if(sgnl(icx).lt.dedx_x_min)then cl_single(icx)=0 goto 10 endif +* ---------------------------------------------------- * cut BAD (X VIEW) +* ---------------------------------------------------- badseed=BAD(VIEW(icx),nvk(MAXS(icx)),nst(MAXS(icx))) ifirst=INDSTART(icx) if(icx.ne.nclstr1) then @@ -1908,7 +1914,7 @@ else ilast=TOTCLLENGTH endif - badcl=badseed + badclx=badseed do igood=-ngoodstr,ngoodstr ibad=1 if((INDMAX(icx)+igood).gt.ifirst.and. @@ -1918,12 +1924,15 @@ $ nvk(MAXS(icx)+igood), $ nst(MAXS(icx)+igood)) endif - badcl=badcl*ibad + badclx=badclx*ibad enddo - if(badcl.eq.0)then !<<<<<<<<<<<<<< BAD cut - cl_single(icx)=0 !<<<<<<<<<<<<<< BAD cut - goto 10 !<<<<<<<<<<<<<< BAD cut - endif !<<<<<<<<<<<<<< BAD cut +* ---------------------------------------------------- +* >>> eliminato il taglio sulle BAD <<< +* ---------------------------------------------------- +c if(badcl.eq.0)then +c cl_single(icx)=0 +c goto 10 +c endif * ---------------------------------------------------- cl_good(icx)=1 @@ -1934,12 +1943,20 @@ if(mod(VIEW(icy),2).eq.0)goto 20 * ---------------------------------------------------- +* jump masked views (Y VIEW) +* ---------------------------------------------------- + if( mask_view(VIEW(icy)).ne.0 ) goto 20 + +* ---------------------------------------------------- * cut on charge (Y VIEW) - if(dedx(icy).lt.dedx_y_min)then +* ---------------------------------------------------- + if(sgnl(icy).lt.dedx_y_min)then cl_single(icy)=0 goto 20 endif +* ---------------------------------------------------- * cut BAD (Y VIEW) +* ---------------------------------------------------- badseed=BAD(VIEW(icy),nvk(MAXS(icy)),nst(MAXS(icy))) ifirst=INDSTART(icy) if(icy.ne.nclstr1) then @@ -1947,7 +1964,7 @@ else ilast=TOTCLLENGTH endif - badcl=badseed + badcly=badseed do igood=-ngoodstr,ngoodstr ibad=1 if((INDMAX(icy)+igood).gt.ifirst.and. @@ -1956,14 +1973,16 @@ $ ibad=BAD(VIEW(icy), $ nvk(MAXS(icy)+igood), $ nst(MAXS(icy)+igood)) - badcl=badcl*ibad + badcly=badcly*ibad enddo - if(badcl.eq.0)then !<<<<<<<<<<<<<< BAD cut - cl_single(icy)=0 !<<<<<<<<<<<<<< BAD cut - goto 20 !<<<<<<<<<<<<<< BAD cut - endif !<<<<<<<<<<<<<< BAD cut * ---------------------------------------------------- - +* >>> eliminato il taglio sulle BAD <<< +* ---------------------------------------------------- +c if(badcl.eq.0)then +c cl_single(icy)=0 +c goto 20 +c endif +* ---------------------------------------------------- cl_good(icy)=1 nply=npl(VIEW(icy)) @@ -1974,53 +1993,56 @@ * ---------------------------------------------- * geometrical consistency (same plane and ladder) if(nply.eq.nplx.and.nldy.eq.nldx)then -* charge correlation -* =========================================================== -* this version of the subroutine is used for the calibration -* thus charge-correlation selection is obviously removed -* =========================================================== -c$$$ ddd=(dedx(icy) -c$$$ $ -kch(nplx,nldx)*dedx(icx)-cch(nplx,nldx)) -c$$$ ddd=ddd/sqrt(kch(nplx,nldx)**2+1) -c$$$ cut=chcut*sch(nplx,nldx) -c$$$ if(abs(ddd).gt.cut)goto 20 !charge not consistent -* =========================================================== - - -* ------------------> COUPLE <------------------ -* check to do not overflow vector dimentions - if(ncp_plane(nplx).gt.ncouplemax)then - if(DEBUG)print*, - $ ' ** warning ** number of identified'// - $ ' couples on plane ',nplx, - $ ' exceeds vector dimention'// - $ ' ( ',ncouplemax,' )' -c good2=.false. -c goto 880 !fill ntp and go to next event - iflag=1 - return +* charge correlation +* (modified to be applied only below saturation... obviously) + + if( .not.(sgnl(icy).gt.chsaty.and.sgnl(icx).gt.chsatx) + $ .and. + $ .not.(sgnl(icy).lt.chmipy.and.sgnl(icx).lt.chmipx) + $ .and. + $ (badclx.eq.1.and.badcly.eq.1) + $ .and. + $ .true.)then + + ddd=(sgnl(icy) + $ -kch(nplx,nldx)*sgnl(icx)-cch(nplx,nldx)) + ddd=ddd/sqrt(kch(nplx,nldx)**2+1) + +c cut = chcut * sch(nplx,nldx) + + sss=(kch(nplx,nldx)*sgnl(icy)+sgnl(icx) + $ -kch(nplx,nldx)*cch(nplx,nldx)) + sss=sss/sqrt(kch(nplx,nldx)**2+1) + cut = chcut * (16 + sss/50.) + + if(abs(ddd).gt.cut)then + goto 20 !charge not consistent + endif endif - - if(ncp_plane(nplx).eq.ncouplemax)then - if(DEBUG)print*, + + if(ncp_plane(nplx).gt.ncouplemax)then + if(verbose.eq.1)print*, $ '** warning ** number of identified '// $ 'couples on plane ',nplx, $ 'exceeds vector dimention ' - $ ,'( ',ncouplemax,' )' -c good2=.false. -c goto 880 !fill ntp and go to next event - iflag=1 - return + $ ,'( ',ncouplemax,' ) --> masked!' +c mask_view(nviewx(nplx)) = 2 +c mask_view(nviewy(nply)) = 2 + mask_view(nviewx(nplx))= mask_view(nviewx(nplx))+ 2**1 + mask_view(nviewy(nply))= mask_view(nviewy(nply))+ 2**1 + goto 10 endif +* ------------------> COUPLE <------------------ ncp_plane(nplx) = ncp_plane(nplx) + 1 clx(nplx,ncp_plane(nplx))=icx cly(nply,ncp_plane(nplx))=icy cl_single(icx)=0 cl_single(icy)=0 - endif * ---------------------------------------------- + endif + 20 continue enddo !end loop on clusters(Y) @@ -2037,241 +2059,19 @@ enddo - if(DEBUG)then + if(DEBUG.EQ.1)then print*,'clusters ',nclstr1 print*,'good ',(cl_good(i),i=1,nclstr1) - print*,'singles ',(cl_single(i),i=1,nclstr1) + print*,'singlets',(cl_single(i),i=1,nclstr1) print*,'couples per plane: ',(ncp_plane(ip),ip=1,nplanes) endif do ip=1,6 - ncp_tot=ncp_tot+ncp_plane(ip) + ncp_tot = ncp_tot + ncp_plane(ip) enddo -c if(ncp_tot.gt.ncp_max)goto 100!next event (TEMPORANEO!!!) - - if(ncp_tot.gt.ncp_max)then - if(DEBUG)print*, - $ '** warning ** number of identified '// - $ 'couples exceeds upper limit for Hough tr. ' - $ ,'( ',ncp_max,' )' -c good2=.false. -c goto 880 !fill ntp and go to next event - iflag=1 - return - endif return end - -c$$$ subroutine cl_to_couples_2(iflag) -c$$$ -c$$$ include 'commontracker.f' -c$$$ include 'common_momanhough.f' -c$$$ include 'momanhough_init.f' -c$$$ include 'calib.f' -c$$$ include 'level1.f' -c$$$ -c$$$ logical DEBUG -c$$$ common/dbg/DEBUG -c$$$ -c$$$* output flag -c$$$* -------------- -c$$$* 0 = good event -c$$$* 1 = bad event -c$$$* -------------- -c$$$ integer iflag -c$$$ -c$$$ integer badseed,badcl -c$$$ -c$$$* init variables -c$$$ ncp_tot=0 -c$$$ do ip=1,nplanes -c$$$ do ico=1,ncouplemax -c$$$ clx(ip,ico)=0 -c$$$ cly(ip,ico)=0 -c$$$ enddo -c$$$ ncp_plane(ip)=0 -c$$$ do icl=1,nclstrmax_level2 -c$$$ cls(ip,icl)=1 -c$$$ enddo -c$$$ ncls(ip)=0 -c$$$ enddo -c$$$ do icl=1,nclstrmax_level2 -c$$$ cl_single(icl)=1 -c$$$ cl_good(icl)=0 -c$$$ enddo -c$$$ -c$$$* start association -c$$$ ncouples=0 -c$$$ do icx=1,nclstr1 !loop on cluster (X) -c$$$ if(mod(VIEW(icx),2).eq.1)goto 10 -c$$$ -c$$$* ---------------------------------------------------- -c$$$* cut on charge (X VIEW) -c$$$ if(dedx(icx).lt.dedx_x_min)then -c$$$ cl_single(icx)=0 -c$$$ goto 10 -c$$$ endif -c$$$* cut BAD (X VIEW) -c$$$ badseed=BAD(VIEW(icx),nvk(MAXS(icx)),nst(MAXS(icx))) -c$$$ ifirst=INDSTART(icx) -c$$$ if(icx.ne.nclstr1) then -c$$$ ilast=INDSTART(icx+1)-1 -c$$$ else -c$$$ ilast=TOTCLLENGTH -c$$$ endif -c$$$ badcl=badseed -c$$$ do igood=-ngoodstr,ngoodstr -c$$$ ibad=1 -c$$$ if((INDMAX(icx)+igood).gt.ifirst.and. -c$$$ $ (INDMAX(icx)+igood).lt.ilast.and. -c$$$ $ .true.)then -c$$$ ibad=BAD(VIEW(icx), -c$$$ $ nvk(MAXS(icx)+igood), -c$$$ $ nst(MAXS(icx)+igood)) -c$$$ endif -c$$$ badcl=badcl*ibad -c$$$ enddo -c$$$* print*,'icx ',icx,badcl -c$$$ if(badcl.eq.0)then -c$$$ cl_single(icx)=0 -c$$$ goto 10 -c$$$ endif -c$$$* ---------------------------------------------------- -c$$$ -c$$$ cl_good(icx)=1 -c$$$ nplx=npl(VIEW(icx)) -c$$$ nldx=nld(MAXS(icx),VIEW(icx)) -c$$$ -c$$$ do icy=1,nclstr1 !loop on cluster (Y) -c$$$ if(mod(VIEW(icy),2).eq.0)goto 20 -c$$$ -c$$$* ---------------------------------------------------- -c$$$* cut on charge (Y VIEW) -c$$$ if(dedx(icy).lt.dedx_y_min)then -c$$$ cl_single(icy)=0 -c$$$ goto 20 -c$$$ endif -c$$$* cut BAD (Y VIEW) -c$$$ badseed=BAD(VIEW(icy),nvk(MAXS(icy)),nst(MAXS(icy))) -c$$$ ifirst=INDSTART(icy) -c$$$ if(icy.ne.nclstr1) then -c$$$ ilast=INDSTART(icy+1)-1 -c$$$ else -c$$$ ilast=TOTCLLENGTH -c$$$ endif -c$$$ badcl=badseed -c$$$ do igood=-ngoodstr,ngoodstr -c$$$ ibad=1 -c$$$ if((INDMAX(icy)+igood).gt.ifirst.and. -c$$$ $ (INDMAX(icy)+igood).lt.ilast.and. -c$$$ $ .true.) -c$$$ $ ibad=BAD(VIEW(icy), -c$$$ $ nvk(MAXS(icy)+igood), -c$$$ $ nst(MAXS(icy)+igood)) -c$$$ badcl=badcl*ibad -c$$$ enddo -c$$$* print*,'icy ',icy,badcl -c$$$ if(badcl.eq.0)then -c$$$ cl_single(icy)=0 -c$$$ goto 20 -c$$$ endif -c$$$* ---------------------------------------------------- -c$$$ -c$$$ -c$$$ cl_good(icy)=1 -c$$$ nply=npl(VIEW(icy)) -c$$$ nldy=nld(MAXS(icy),VIEW(icy)) -c$$$ -c$$$* ---------------------------------------------- -c$$$* CONDITION TO FORM A COUPLE -c$$$* ---------------------------------------------- -c$$$* geometrical consistency (same plane and ladder) -c$$$ if(nply.eq.nplx.and.nldy.eq.nldx)then -c$$$ -c$$$c$$$* charge correlation -c$$$c$$$ ddd=(dedx(icy) -c$$$c$$$ $ -kch(nplx,nldx)*dedx(icx)-cch(nplx,nldx)) -c$$$c$$$ ddd=ddd/sqrt(kch(nplx,nldx)**2+1) -c$$$c$$$ cut=chcut*sch(nplx,nldx) -c$$$c$$$ if(abs(ddd).gt.cut)goto 20 !charge not consistent -c$$$ -c$$$* ------------------> COUPLE <------------------ -c$$$* check to do not overflow vector dimentions -c$$$ if(ncp_plane(nplx).gt.ncouplemax)then -c$$$ if(DEBUG)print*, -c$$$ $ ' ** warning ** number of identified'// -c$$$ $ ' couples on plane ',nplx, -c$$$ $ ' exceeds vector dimention'// -c$$$ $ ' ( ',ncouplemax,' )' -c$$$c good2=.false. -c$$$c goto 880 !fill ntp and go to next event -c$$$ iflag=1 -c$$$ return -c$$$ endif -c$$$ -c$$$ if(ncp_plane(nplx).eq.ncouplemax)then -c$$$ if(DEBUG)print*, -c$$$ $ '** warning ** number of identified '// -c$$$ $ 'couples on plane ',nplx, -c$$$ $ 'exceeds vector dimention ' -c$$$ $ ,'( ',ncouplemax,' )' -c$$$c good2=.false. -c$$$c goto 880 !fill ntp and go to next event -c$$$ iflag=1 -c$$$ return -c$$$ endif -c$$$ -c$$$ ncp_plane(nplx) = ncp_plane(nplx) + 1 -c$$$ clx(nplx,ncp_plane(nplx))=icx -c$$$ cly(nply,ncp_plane(nplx))=icy -c$$$ cl_single(icx)=0 -c$$$ cl_single(icy)=0 -c$$$c print*,'couple ',nplx,ncp_plane(nplx),' --- ',icx,icy -c$$$ endif -c$$$* ---------------------------------------------- -c$$$ -c$$$ 20 continue -c$$$ enddo !end loop on clusters(Y) -c$$$ -c$$$ 10 continue -c$$$ enddo !end loop on clusters(X) -c$$$ -c$$$ -c$$$ do icl=1,nclstr1 -c$$$ if(cl_single(icl).eq.1)then -c$$$ ip=npl(VIEW(icl)) -c$$$ ncls(ip)=ncls(ip)+1 -c$$$ cls(ip,ncls(ip))=icl -c$$$ endif -c$$$ enddo -c$$$ -c$$$ -c$$$ if(DEBUG)then -c$$$ print*,'clusters ',nclstr1 -c$$$ print*,'good ',(cl_good(i),i=1,nclstr1) -c$$$ print*,'singles ',(cl_single(i),i=1,nclstr1) -c$$$ print*,'couples per plane: ',(ncp_plane(ip),ip=1,nplanes) -c$$$ endif -c$$$ -c$$$ do ip=1,6 -c$$$ ncp_tot=ncp_tot+ncp_plane(ip) -c$$$ enddo -c$$$c if(ncp_tot.gt.ncp_max)goto 100!next event (TEMPORANEO!!!) -c$$$ -c$$$ if(ncp_tot.gt.ncp_max)then -c$$$ if(DEBUG)print*, -c$$$ $ '** warning ** number of identified '// -c$$$ $ 'couples exceeds upper limit for Hough tr. ' -c$$$ $ ,'( ',ncp_max,' )' -c$$$c good2=.false. -c$$$c goto 880 !fill ntp and go to next event -c$$$ iflag=1 -c$$$ return -c$$$ endif -c$$$ -c$$$ return -c$$$ end *************************************************** * * @@ -2283,20 +2083,14 @@ ************************************************** subroutine cp_to_doubtrip(iflag) -c***************************************************** -c 02/02/2006 modified by Elena Vannuccini --> (1) -c***************************************************** include 'commontracker.f' + include 'level1.f' include 'common_momanhough.f' - include 'momanhough_init.f' include 'common_xyzPAM.f' include 'common_mini_2.f' include 'calib.f' - include 'level1.f' - logical DEBUG - common/dbg/DEBUG * output flag * -------------- @@ -2328,33 +2122,54 @@ real xc,zc,radius * ----------------------------- + if(DEBUG.EQ.1)print*,'cp_to_doubtrip:' + +* -------------------------------------------- +* put a limit to the maximum number of couples +* per plane, in order to apply hough transform +* (couples recovered during track refinement) +* -------------------------------------------- + do ip=1,nplanes + if(ncp_plane(ip).gt.ncouplelimit)then +c mask_view(nviewx(ip)) = 8 +c mask_view(nviewy(ip)) = 8 + mask_view(nviewx(ip)) = mask_view(nviewx(ip)) + 2**7 + mask_view(nviewy(ip)) = mask_view(nviewy(ip)) + 2**7 + endif + enddo ndblt=0 !number of doublets ntrpt=0 !number of triplets do ip1=1,(nplanes-1) !loop on planes - COPPIA 1 - do is1=1,2 !loop on sensors - COPPIA 1 - + if( mask_view(nviewx(ip1)).ne.0 .or. + $ mask_view(nviewy(ip1)).ne.0 )goto 10 !skip plane + do is1=1,2 !loop on sensors - COPPIA 1 do icp1=1,ncp_plane(ip1) !loop on COPPIA 1 icx1=clx(ip1,icp1) icy1=cly(ip1,icp1) c call xyz_PAM(icx1,icy1,is1,'COG2','COG2',0.,0.)!(1) - call xyz_PAM(icx1,icy1,is1,PFAdef,PFAdef,0.,0.) !(1) +c call xyz_PAM(icx1,icy1,is1,PFAdef,PFAdef,0.,0.) !(1) + call xyz_PAM(icx1,icy1,is1,PFAdef,PFAdef,0.,0.,0.,0.) xm1=xPAM ym1=yPAM zm1=zPAM c print*,'***',is1,xm1,ym1,zm1 + do ip2=(ip1+1),nplanes !loop on planes - COPPIA 2 - do is2=1,2 !loop on sensors -ndblt COPPIA 2 - + if( mask_view(nviewx(ip2)).ne.0 .or. + $ mask_view(nviewy(ip2)).ne.0 )goto 20 !skip plane + do is2=1,2 !loop on sensors -ndblt COPPIA 2 do icp2=1,ncp_plane(ip2) !loop on COPPIA 2 icx2=clx(ip2,icp2) icy2=cly(ip2,icp2) c call xyz_PAM c $ (icx2,icy2,is2,'COG2','COG2',0.,0.)!(1) +c call xyz_PAM +c $ (icx2,icy2,is2,PFAdef,PFAdef,0.,0.) !(1) call xyz_PAM - $ (icx2,icy2,is2,PFAdef,PFAdef,0.,0.) !(1) + $ (icx2,icy2,is2,PFAdef,PFAdef,0.,0.,0.,0.) xm2=xPAM ym2=yPAM zm2=zPAM @@ -2364,12 +2179,16 @@ * (2 couples needed) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - if(ndblt.eq.ndblt_max)then - if(DEBUG)print*, + if(verbose.eq.1)print*, $ '** warning ** number of identified '// $ 'doublets exceeds vector dimention ' $ ,'( ',ndblt_max,' )' c good2=.false. c goto 880 !fill ntp and go to next event + do iv=1,12 +c mask_view(iv) = 3 + mask_view(iv) = mask_view(iv)+ 2**2 + enddo iflag=1 return endif @@ -2403,8 +2222,11 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if(ip2.eq.nplanes)goto 30 !no possible combination with 3 couples + if(ip2.eq.nplanes)goto 31 !no possible combination with 3 couples + do ip3=(ip2+1),nplanes !loop on planes - COPPIA 3 + if( mask_view(nviewx(ip3)).ne.0 .or. + $ mask_view(nviewy(ip3)).ne.0 )goto 30 !skip plane do is3=1,2 !loop on sensors - COPPIA 3 do icp3=1,ncp_plane(ip3) !loop on COPPIA 3 @@ -2412,12 +2234,18 @@ icy3=cly(ip3,icp3) c call xyz_PAM c $ (icx3,icy3,is3,'COG2','COG2',0.,0.)!(1) +c call xyz_PAM +c $ (icx3,icy3,is3,PFAdef,PFAdef,0.,0.) !(1) call xyz_PAM - $ (icx3,icy3,is3,PFAdef,PFAdef,0.,0.) !(1) + $ (icx3,icy3,is3,PFAdef,PFAdef + $ ,0.,0.,0.,0.) xm3=xPAM ym3=yPAM zm3=zPAM * find the circle passing through the three points +c$$$ call tricircle(3,xp,zp,angp,resp,chi +c$$$ $ ,xc,zc,radius,iflag) + iflag = DEBUG call tricircle(3,xp,zp,angp,resp,chi $ ,xc,zc,radius,iflag) c print*,xc,zc,radius @@ -2434,12 +2262,16 @@ * (3 couples needed) * - - - - - - - - - - - - - - - - - - - - - - - - - - - - if(ntrpt.eq.ntrpt_max)then - if(DEBUG)print*, + if(verbose.eq.1)print*, $ '** warning ** number of identified '// $ 'triplets exceeds vector dimention ' $ ,'( ',ntrpt_max,' )' c good2=.false. c goto 880 !fill ntp and go to next event + do iv=1,nviews +c mask_view(iv) = 4 + mask_view(iv)=mask_view(iv)+ 2**3 + enddo iflag=1 return endif @@ -2478,18 +2310,21 @@ endif enddo !end loop on COPPIA 3 enddo !end loop on sensors - COPPIA 3 + 30 continue enddo !end loop on planes - COPPIA 3 - 30 continue + 31 continue 1 enddo !end loop on COPPIA 2 enddo !end loop on sensors - COPPIA 2 + 20 continue enddo !end loop on planes - COPPIA 2 enddo !end loop on COPPIA1 enddo !end loop on sensors - COPPIA 1 + 10 continue enddo !end loop on planes - COPPIA 1 - if(DEBUG)then + if(DEBUG.EQ.1)then print*,'--- doublets ',ndblt print*,'--- triplets ',ntrpt endif @@ -2514,11 +2349,10 @@ subroutine doub_to_YZcloud(iflag) include 'commontracker.f' + include 'level1.f' include 'common_momanhough.f' - include 'momanhough_init.f' +c include 'momanhough_init.f' - logical DEBUG - common/dbg/DEBUG * output flag * -------------- @@ -2537,6 +2371,7 @@ integer cp_useds1(ncouplemaxtot) ! sensor 1 integer cp_useds2(ncouplemaxtot) ! sensor 2 + if(DEBUG.EQ.1)print*,'doub_to_YZcloud:' *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * classification of DOUBLETS @@ -2550,6 +2385,8 @@ distance=0 nclouds_yz=0 !number of clouds npt_tot=0 + nloop=0 + 90 continue do idb1=1,ndblt !loop (1) on DOUBLETS if(db_used(idb1).eq.1)goto 2228 !db already included in a cloud @@ -2653,7 +2490,7 @@ nplused=nplused+ hit_plane(ip) enddo c print*,'>>>> ',ncpused,npt,nplused - if(ncpused.lt.ncpyz_min)goto 2228 !next doublet +c if(ncpused.lt.ncpyz_min)goto 2228 !next doublet if(npt.lt.nptyz_min)goto 2228 !next doublet if(nplused.lt.nplyz_min)goto 2228 !next doublet @@ -2661,12 +2498,16 @@ * >>> NEW CLOUD <<< if(nclouds_yz.ge.ncloyz_max)then - if(DEBUG)print*, + if(verbose.eq.1)print*, $ '** warning ** number of identified '// $ 'YZ clouds exceeds vector dimention ' $ ,'( ',ncloyz_max,' )' c good2=.false. c goto 880 !fill ntp and go to next event + do iv=1,nviews +c mask_view(iv) = 5 + mask_view(iv) = mask_view(iv) + 2**4 + enddo iflag=1 return endif @@ -2685,14 +2526,16 @@ c print*,'>> ',ipt,db_all(ipt) enddo npt_tot=npt_tot+npt - if(DEBUG)then + if(DEBUG.EQ.1)then print*,'-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~' print*,'>>>> cloud ',nclouds_yz,' --- ',npt,' points' - print*,'- alfayz1 ',alfayz1_av(nclouds_yz) - print*,'- alfayz2 ',alfayz2_av(nclouds_yz) - print*,'cp_useds1 ',(cp_useds1(icp),icp=1,ncp_tot) - print*,'cp_useds2 ',(cp_useds2(icp),icp=1,ncp_tot) - print*,'hit_plane ',(hit_plane(ip),ip=1,nplanes) + print*,'- alfayz1 ',alfayz1_av(nclouds_yz) + print*,'- alfayz2 ',alfayz2_av(nclouds_yz) + print*,'cp_useds1 ',(cp_useds1(icp),icp=1,ncp_tot) + print*,'cp_useds2 ',(cp_useds2(icp),icp=1,ncp_tot) + print*,'cpcloud_yz ' + $ ,(cpcloud_yz(nclouds_yz,icp),icp=1,ncp_tot) + print*,'hit_plane ',(hit_plane(ip),ip=1,nplanes) c$$$ print*,'nt-uple: ptcloud_yz(',nclouds_yz,') = ' c$$$ $ ,ptcloud_yz(nclouds_yz) c$$$ print*,'nt-uple: db_cloud(...) = ' @@ -2704,7 +2547,13 @@ enddo !end loop (1) on DOUBLETS - if(DEBUG)then + if(nloop.lt.nstepy)then + cutdistyz = cutdistyz+cutystep + nloop = nloop+1 + goto 90 + endif + + if(DEBUG.EQ.1)then print*,'---------------------- ' print*,'Y-Z total clouds ',nclouds_yz print*,' ' @@ -2730,11 +2579,10 @@ subroutine trip_to_XZcloud(iflag) include 'commontracker.f' + include 'level1.f' include 'common_momanhough.f' - include 'momanhough_init.f' +c include 'momanhough_init.f' - logical DEBUG - common/dbg/DEBUG * output flag * -------------- @@ -2754,6 +2602,8 @@ integer cp_useds1(ncouplemaxtot) ! sensor 1 integer cp_useds2(ncouplemaxtot) ! sensor 2 + if(DEBUG.EQ.1)print*,'trip_to_XZcloud:' + *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * classification of TRIPLETS * according to distance in parameter space @@ -2765,6 +2615,8 @@ distance=0 nclouds_xz=0 !number of clouds npt_tot=0 !total number of selected triplets + nloop=0 + 91 continue do itr1=1,ntrpt !loop (1) on TRIPLETS if(tr_used(itr1).eq.1)goto 22288 !already included in a cloud c print*,'--------------' @@ -2809,7 +2661,18 @@ $ +((alfaxz2(itrref)-alfaxz2(itr2))/Dalfaxz2)**2 distance = sqrt(distance) - if(distance.lt.cutdistxz)then +* ------------------------------------------------------------------------ +* FORCE INCLUSION OF TRIPLETS COMPOSED BY SAME COUPLES, IGNORING THE IMAGE +* ------------------------------------------------------------------------ +* (added in august 2007) + istrimage=0 + if( + $ abs(cpxz1(itrref)).eq.abs(cpxz1(itr2)).and. + $ abs(cpxz2(itrref)).eq.abs(cpxz2(itr2)).and. + $ abs(cpxz3(itrref)).eq.abs(cpxz3(itr2)).and. + $ .true.)istrimage=1 + + if(distance.lt.cutdistxz.or.istrimage.eq.1)then c print*,idb1,idb2,distance,' cloud ',nclouds_yz if(cpxz1(itr2).gt.0)cp_useds2(cpxz1(itr2))=1 if(cpxz1(itr2).lt.0)cp_useds1(-cpxz1(itr2))=1 @@ -2866,19 +2729,23 @@ do ip=1,nplanes nplused=nplused+ hit_plane(ip) enddo - if(ncpused.lt.ncpxz_min)goto 22288 !next triplet +c if(ncpused.lt.ncpxz_min)goto 22288 !next triplet if(npt.lt.nptxz_min)goto 22288 !next triplet - if(nplused.lt.nplxz_min)goto 22288 !next doublet + if(nplused.lt.nplxz_min)goto 22288 !next triplet * ~~~~~~~~~~~~~~~~~ * >>> NEW CLOUD <<< if(nclouds_xz.ge.ncloxz_max)then - if(DEBUG)print*, + if(verbose.eq.1)print*, $ '** warning ** number of identified '// $ 'XZ clouds exceeds vector dimention ' $ ,'( ',ncloxz_max,' )' c good2=.false. c goto 880 !fill ntp and go to next event + do iv=1,nviews +c mask_view(iv) = 6 + mask_view(iv) = mask_view(iv) + 2**5 + enddo iflag=1 return endif @@ -2896,14 +2763,16 @@ enddo npt_tot=npt_tot+npt - if(DEBUG)then + if(DEBUG.EQ.1)then print*,'-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~' print*,'>>>> cloud ',nclouds_xz,' --- ',npt,' points' - print*,'- alfaxz1 ',alfaxz1_av(nclouds_xz) - print*,'- alfaxz2 ',alfaxz2_av(nclouds_xz) - print*,'- alfaxz3 ',alfaxz3_av(nclouds_xz) - print*,'cp_useds1 ',(cp_useds1(icp),icp=1,ncp_tot) - print*,'cp_useds2 ',(cp_useds2(icp),icp=1,ncp_tot) + print*,'- alfaxz1 ',alfaxz1_av(nclouds_xz) + print*,'- alfaxz2 ',alfaxz2_av(nclouds_xz) + print*,'- alfaxz3 ',alfaxz3_av(nclouds_xz) + print*,'cp_useds1 ',(cp_useds1(icp),icp=1,ncp_tot) + print*,'cp_useds2 ',(cp_useds2(icp),icp=1,ncp_tot) + print*,'cpcloud_xz ' + $ ,(cpcloud_xz(nclouds_xz,icp),icp=1,ncp_tot) print*,'hit_plane ',(hit_plane(ip),ip=1,nplanes) c$$$ print*,'nt-uple: ptcloud_xz(',nclouds_xz,') = ' c$$$ $ ,ptcloud_xz(nclouds_xz) @@ -2914,8 +2783,14 @@ * ~~~~~~~~~~~~~~~~~ 22288 continue enddo !end loop (1) on DOUBLETS - - if(DEBUG)then + + if(nloop.lt.nstepx)then + cutdistxz=cutdistxz+cutxstep + nloop=nloop+1 + goto 91 + endif + + if(DEBUG.EQ.1)then print*,'---------------------- ' print*,'X-Z total clouds ',nclouds_xz print*,' ' @@ -2936,19 +2811,15 @@ ************************************************** subroutine clouds_to_ctrack(iflag) -c***************************************************** -c 02/02/2006 modified by Elena Vannuccini --> (1) -c***************************************************** include 'commontracker.f' + include 'level1.f' include 'common_momanhough.f' include 'common_xyzPAM.f' include 'common_mini_2.f' include 'common_mech.f' - include 'momanhough_init.f' - logical DEBUG - common/dbg/DEBUG + * output flag * -------------- @@ -2964,17 +2835,16 @@ * ----------------------------------------------------------- * list of matching couples in the combination * between a XZ and YZ cloud - integer cp_match(nplanes,ncouplemax) + integer cp_match(nplanes,2*ncouplemax) integer ncp_match(nplanes) * ----------------------------------------------------------- integer hit_plane(nplanes) * ----------------------------------------------------------- * variables for track fitting double precision AL_INI(5) - double precision tath * ----------------------------------------------------------- -c real fitz(nplanes) !z coordinates of the planes in cm + if(DEBUG.EQ.1)print*,'clouds_to_ctrack:' ntracks=0 !counter of track candidates @@ -2996,7 +2866,7 @@ enddo enddo ncp_ok=0 - do icp=1,ncp_tot !loop on couples + do icp=1,ncp_tot !loop over couples * get info on cpintersec(icp)=min( $ cpcloud_yz(iyz,icp), @@ -3005,6 +2875,7 @@ $ (cpcloud_yz(iyz,icp).eq.1.and.cpcloud_xz(ixz,icp).eq.2).or. $ (cpcloud_yz(iyz,icp).eq.2.and.cpcloud_xz(ixz,icp).eq.1).or. $ .false.)cpintersec(icp)=0 +* cpintersec is >0 if yz and xz clouds contain the same image of couple icp if(cpintersec(icp).ne.0)then ncp_ok=ncp_ok+1 @@ -3037,15 +2908,18 @@ nplused=nplused+ hit_plane(ip) enddo - if(nplused.lt.nplxz_min)goto 888 !next doublet - if(ncp_ok.lt.ncpok)goto 888 !next cloud - if(DEBUG)then + if(DEBUG.EQ.1)then print*,'Combination ',iyz,ixz $ ,' db ',ptcloud_yz(iyz) $ ,' tr ',ptcloud_xz(ixz) $ ,' -----> # matching couples ',ncp_ok endif + +c if(nplused.lt.nplxz_min)goto 888 !next combination + if(nplused.lt.nplyz_min)goto 888 !next combination + if(ncp_ok.lt.ncpok)goto 888 !next combination + c$$$ print*,'~~~~~~~~~~~~~~~~~~~~~~~~~' c$$$ print*,'Configurazione cluster XZ' c$$$ print*,'1 -- ',(clx(1,i),i=1,ncp_plane(1)) @@ -3064,24 +2938,35 @@ c$$$ print*,'~~~~~~~~~~~~~~~~~~~~~~~~~' * -------> INITIAL GUESS <------- - AL_INI(1)=dreal(alfaxz1_av(ixz)) - AL_INI(2)=dreal(alfayz1_av(iyz)) - AL_INI(4)=datan(dreal(alfayz2_av(iyz)) - $ /dreal(alfaxz2_av(ixz))) - tath=-dreal(alfaxz2_av(ixz))/dcos(AL_INI(4)) - AL_INI(3)=tath/sqrt(1+tath**2) - AL_INI(5)=(1.e2*alfaxz3_av(ixz))/(0.3*0.43) !0. - -c print*,'*******',AL_INI(5) - if(AL_INI(5).gt.defmax)goto 888 !next cloud - -c print*,'alfaxz2, alfayz2 ' -c $ ,alfaxz2_av(ixz),alfayz2_av(iyz) - -* -------> INITIAL GUESS <------- -c print*,'AL_INI ',(al_ini(i),i=1,5) - - if(DEBUG)then +cccc SBAGLIATO +c$$$ AL_INI(1) = dreal(alfaxz1_av(ixz)) +c$$$ AL_INI(2) = dreal(alfayz1_av(iyz)) +c$$$ AL_INI(4) = PIGR + datan(dreal(alfayz2_av(iyz)) +c$$$ $ /dreal(alfaxz2_av(ixz))) +c$$$ tath = -dreal(alfaxz2_av(ixz))/dcos(AL_INI(4)) +c$$$ AL_INI(3) = tath/sqrt(1+tath**2) +c$$$ AL_INI(5) = (1.e2*alfaxz3_av(ixz))/(0.3*0.43) !0. +cccc GIUSTO (ma si sua guess()) +c$$$ AL_INI(1) = dreal(alfaxz1_av(ixz)) +c$$$ AL_INI(2) = dreal(alfayz1_av(iyz)) +c$$$ tath = -dreal(alfaxz2_av(ixz))/dcos(AL_INI(4)) +c$$$ AL_INI(3) = tath/sqrt(1+tath**2) +c$$$ IF(alfaxz2_av(ixz).NE.0)THEN +c$$$ AL_INI(4) = PIGR + datan(dreal(alfayz2_av(iyz)) +c$$$ $ /dreal(alfaxz2_av(ixz))) +c$$$ ELSE +c$$$ AL_INI(4) = acos(-1.)/2 +c$$$ IF(alfayz2_av(iyz).LT.0)AL_INI(4) = AL_INI(4)+acos(-1.) +c$$$ ENDIF +c$$$ IF(alfaxz2_av(ixz).LT.0)AL_INI(4)= acos(-1.)+ AL_INI(4) +c$$$ AL_INI(4) = -acos(-1.) + AL_INI(4) !from incidence direction to tracking rs +c$$$ +c$$$ AL_INI(5) = (1.e2*alfaxz3_av(ixz))/(0.3*0.43) !0. +c$$$ +c$$$ if(AL_INI(5).gt.defmax)goto 888 !next cloud + + if(DEBUG.EQ.1)then + print*,'track candidate', ntracks+1 print*,'1 >>> ',(cp_match(6,i),i=1,ncp_match(6)) print*,'2 >>> ',(cp_match(5,i),i=1,ncp_match(5)) print*,'3 >>> ',(cp_match(4,i),i=1,ncp_match(4)) @@ -3114,10 +2999,35 @@ hit_plane(6)=icp6 if(ncp_match(6).eq.0)hit_plane(6)=0 !-icp6 - +* --------------------------------------- +* check if this group of couples has been +* already fitted +* --------------------------------------- + do ica=1,ntracks + isthesame=1 + do ip=1,NPLANES + if(hit_plane(ip).ne.0)then + if( CP_STORE(nplanes-ip+1,ica) + $ .ne. + $ cp_match(ip,hit_plane(ip)) ) + $ isthesame=0 + else + if( CP_STORE(nplanes-ip+1,ica) + $ .ne. + $ 0 ) + $ isthesame=0 + endif + enddo + if(isthesame.eq.1)then + if(DEBUG.eq.1) + $ print*,'(already fitted)' + goto 666 !jump to next combination + endif + enddo + call track_init !init TRACK common - do ip=1,nplanes !loop on planes + do ip=1,nplanes !loop on planes (bottom to top) if(hit_plane(ip).ne.0)then id=cp_match(ip,hit_plane(ip)) is=is_cp(id) @@ -3131,8 +3041,10 @@ * ************************* c call xyz_PAM(icx,icy,is, c $ 'COG2','COG2',0.,0.) +c call xyz_PAM(icx,icy,is, !(1) +c $ PFAdef,PFAdef,0.,0.) !(1) call xyz_PAM(icx,icy,is, !(1) - $ PFAdef,PFAdef,0.,0.) !(1) + $ PFAdef,PFAdef,0.,0.,0.,0.) * ************************* * ----------------------------- xgood(nplanes-ip+1)=1. @@ -3148,19 +3060,34 @@ * ********************************************************** * ************************** FIT *** FIT *** FIT *** FIT *** * ********************************************************** +cccc scommentare se si usa al_ini della nuvola +c$$$ do i=1,5 +c$$$ AL(i)=AL_INI(i) +c$$$ enddo + call guess() do i=1,5 - AL(i)=AL_INI(i) + AL_INI(i)=AL(i) enddo ifail=0 !error flag in chi^2 computation jstep=0 !number of minimization steps - call mini_2(jstep,ifail) + iprint=0 +c if(DEBUG.EQ.1)iprint=1 + if(DEBUG.EQ.1)iprint=2 + call mini2(jstep,ifail,iprint) if(ifail.ne.0) then - if(DEBUG)then + if(DEBUG.EQ.1)then print *, $ '*** MINIMIZATION FAILURE *** ' - $ //'(mini_2 in clouds_to_ctrack)' + $ //'(clouds_to_ctrack)' + print*,'initial guess: ' + + print*,'AL_INI(1) = ',AL_INI(1) + print*,'AL_INI(2) = ',AL_INI(2) + print*,'AL_INI(3) = ',AL_INI(3) + print*,'AL_INI(4) = ',AL_INI(4) + print*,'AL_INI(5) = ',AL_INI(5) endif - chi2=-chi2 +c chi2=-chi2 endif * ********************************************************** * ************************** FIT *** FIT *** FIT *** FIT *** @@ -3173,23 +3100,24 @@ * -------------------------- if(ntracks.eq.NTRACKSMAX)then - if(DEBUG)print*, + if(verbose.eq.1)print*, $ '** warning ** number of candidate tracks '// $ ' exceeds vector dimension ' $ ,'( ',NTRACKSMAX,' )' c good2=.false. c goto 880 !fill ntp and go to next event + do iv=1,nviews +c mask_view(iv) = 7 + mask_view(iv) = mask_view(iv) + 2**6 + enddo iflag=1 return endif ntracks = ntracks + 1 -c$$$ ndof=0 - do ip=1,nplanes -c$$$ ndof=ndof -c$$$ $ +int(xgood(ip)) -c$$$ $ +int(ygood(ip)) + do ip=1,nplanes !top to bottom + XV_STORE(ip,ntracks)=sngl(xv(ip)) YV_STORE(ip,ntracks)=sngl(yv(ip)) ZV_STORE(ip,ntracks)=sngl(zv(ip)) @@ -3205,22 +3133,30 @@ AYV_STORE(ip,ntracks)=sngl(ayv(ip)) XGOOD_STORE(ip,ntracks)=sngl(xgood(ip)) YGOOD_STORE(ip,ntracks)=sngl(ygood(ip)) +* NB! hit_plane is defined from bottom to top if(hit_plane(ip).ne.0)then CP_STORE(nplanes-ip+1,ntracks)= $ cp_match(ip,hit_plane(ip)) + SENSOR_STORE(nplanes-ip+1,ntracks) + $ = is_cp(cp_match(ip,hit_plane(ip))) + LADDER_STORE(nplanes-ip+1,ntracks) + $ = LADDER( + $ clx(ip,icp_cp( + $ cp_match(ip,hit_plane(ip) + $ )))); else CP_STORE(nplanes-ip+1,ntracks)=0 + SENSOR_STORE(nplanes-ip+1,ntracks)=0 + LADDER_STORE(nplanes-ip+1,ntracks)=0 endif - CLS_STORE(nplanes-ip+1,ntracks)=0 + BX_STORE(ip,ntracks)=0!I dont need it now + BY_STORE(ip,ntracks)=0!I dont need it now + CLS_STORE(ip,ntracks)=0 do i=1,5 AL_STORE(i,ntracks)=sngl(AL(i)) enddo enddo -c$$$ * Number of Degree Of Freedom -c$$$ ndof=ndof-5 -c$$$ * reduced chi^2 -c$$$ rchi2=chi2/dble(ndof) RCHI2_STORE(ntracks)=chi2 * -------------------------------- @@ -3244,14 +3180,29 @@ return endif - if(DEBUG)then - print*,'****** TRACK CANDIDATES ***********' - print*,'# R. chi2 RIG' - do i=1,ntracks - print*,i,' --- ',rchi2_store(i),' --- ' - $ ,1./abs(AL_STORE(5,i)) - enddo - print*,'***********************************' +c$$$ if(DEBUG.EQ.1)then +c$$$ print*,'****** TRACK CANDIDATES ***********' +c$$$ print*,'# R. chi2 RIG' +c$$$ do i=1,ntracks +c$$$ print*,i,' --- ',rchi2_store(i),' --- ' +c$$$ $ ,1./abs(AL_STORE(5,i)) +c$$$ enddo +c$$$ print*,'***********************************' +c$$$ endif + if(DEBUG.EQ.1)then + print*,'****** TRACK CANDIDATES *****************' + print*,'# R. chi2 RIG ndof' + do i=1,ntracks + ndof=0 !(1) + do ii=1,nplanes !(1) + ndof=ndof !(1) + $ +int(xgood_store(ii,i)) !(1) + $ +int(ygood_store(ii,i)) !(1) + enddo !(1) + print*,i,' --- ',rchi2_store(i),' --- ' + $ ,1./abs(AL_STORE(5,i)),' --- ',ndof + enddo + print*,'*****************************************' endif @@ -3270,27 +3221,27 @@ subroutine refine_track(ibest) -c****************************************************** -cccccc 06/10/2005 modified by elena vannuccini ---> (1) -cccccc 31/01/2006 modified by elena vannuccini ---> (2) -c****************************************************** include 'commontracker.f' + include 'level1.f' include 'common_momanhough.f' include 'common_xyzPAM.f' include 'common_mini_2.f' include 'common_mech.f' - include 'momanhough_init.f' - include 'level1.f' include 'calib.f' - logical DEBUG - common/dbg/DEBUG - * flag to chose PFA character*10 PFA common/FINALPFA/PFA + real k(6) + DATA k/1.099730,0.418900,0.220939,0.220907,0.418771,1.100674/ + + real xp,yp,zp + real xyzp(3),bxyz(3) + equivalence (xp,xyzp(1)),(yp,xyzp(2)),(zp,xyzp(3)) + + if(DEBUG.EQ.1)print*,'refine_track:' * ================================================= * new estimate of positions using ETA algorithm * and @@ -3299,11 +3250,22 @@ call track_init do ip=1,nplanes !loop on planes + xP=XV_STORE(nplanes-ip+1,ibest) + yP=YV_STORE(nplanes-ip+1,ibest) + zP=ZV_STORE(nplanes-ip+1,ibest) + call gufld(xyzp,bxyz) + BX_STORE(nplanes-ip+1,ibest)=bxyz(1) + BY_STORE(nplanes-ip+1,ibest)=bxyz(2) +c$$$ bxyz(1)=0 +c$$$ bxyz(2)=0 +c$$$ bxyz(3)=0 +* ||||||||||||||||||||||||||||||||||||||||||||||||| * ------------------------------------------------- * If the plane has been already included, it just * computes again the coordinates of the x-y couple * using improved PFAs * ------------------------------------------------- +* ||||||||||||||||||||||||||||||||||||||||||||||||| if(XGOOD_STORE(nplanes-ip+1,ibest).eq.1..and. $ YGOOD_STORE(nplanes-ip+1,ibest).eq.1. )then @@ -3317,15 +3279,18 @@ $ ,ip_cp(id),ip icx=clx(ip,icp) icy=cly(ip,icp) +c call xyz_PAM(icx,icy,is, +c $ PFA,PFA, +c $ AXV_STORE(nplanes-ip+1,ibest), +c $ AYV_STORE(nplanes-ip+1,ibest)) call xyz_PAM(icx,icy,is, -c $ 'ETA2','ETA2', $ PFA,PFA, $ AXV_STORE(nplanes-ip+1,ibest), - $ AYV_STORE(nplanes-ip+1,ibest)) -c$$$ call xyz_PAM(icx,icy,is, -c$$$ $ 'COG2','COG2', -c$$$ $ 0., -c$$$ $ 0.) + $ AYV_STORE(nplanes-ip+1,ibest), + $ bxyz(1), + $ bxyz(2) + $ ) + xm(nplanes-ip+1) = xPAM ym(nplanes-ip+1) = yPAM zm(nplanes-ip+1) = zPAM @@ -3334,14 +3299,15 @@ resx(nplanes-ip+1) = resxPAM resy(nplanes-ip+1) = resyPAM -c dedxtrk(nplanes-ip+1) = (dedx(icx)+dedx(icy))/2. !(1) - dedxtrk_x(nplanes-ip+1)=dedx(icx)/mip(VIEW(icx),LADDER(icx)) !(1)(2) - dedxtrk_y(nplanes-ip+1)=dedx(icy)/mip(VIEW(icy),LADDER(icy)) !(1)(2) + dedxtrk_x(nplanes-ip+1)=sgnl(icx)/mip(VIEW(icx),LADDER(icx)) + dedxtrk_y(nplanes-ip+1)=sgnl(icy)/mip(VIEW(icy),LADDER(icy)) +* ||||||||||||||||||||||||||||||||||||||||||||||||| * ------------------------------------------------- * If the plane has NOT been already included, * it tries to include a COUPLE or a single cluster * ------------------------------------------------- +* ||||||||||||||||||||||||||||||||||||||||||||||||| else xgood(nplanes-ip+1)=0 @@ -3349,15 +3315,15 @@ * -------------------------------------------------------------- * determine which ladder and sensor are intersected by the track - xP=XV_STORE(nplanes-ip+1,ibest) - yP=YV_STORE(nplanes-ip+1,ibest) - zP=ZV_STORE(nplanes-ip+1,ibest) call whichsensor(ip,xP,yP,nldt,ist) * if the track hit the plane in a dead area, go to the next plane if(nldt.eq.0.or.ist.eq.0)goto 133 + + SENSOR_STORE(nplanes-ip+1,IBEST)=ist + LADDER_STORE(nplanes-ip+1,IBEST)=nldt * -------------------------------------------------------------- - if(DEBUG)then + if(DEBUG.EQ.1)then print*, $ '------ Plane ',ip,' intersected on LADDER ',nldt $ ,' SENSOR ',ist @@ -3368,7 +3334,7 @@ * =========================================== * STEP 1 >>>>>>> try to include a new couple * =========================================== -c if(DEBUG)print*,'>>>> try to include a new couple' +c if(DEBUG.EQ.1)print*,'>>>> try to include a new couple' distmin=1000000. xmm = 0. ymm = 0. @@ -3383,20 +3349,25 @@ icx=clx(ip,icp) icy=cly(ip,icp) if(LADDER(icx).ne.nldt.or. !If the ladder number does not match - $ cl_used(icx).eq.1.or. !or the X cluster is already used - $ cl_used(icy).eq.1.or. !or the Y cluster is already used +c $ cl_used(icx).eq.1.or. !or the X cluster is already used +c $ cl_used(icy).eq.1.or. !or the Y cluster is already used + $ cl_used(icx).ne.0.or. !or the X cluster is already used !(3) + $ cl_used(icy).ne.0.or. !or the Y cluster is already used !(3) $ .false.)goto 1188 !then jump to next couple. * call xyz_PAM(icx,icy,ist, $ PFA,PFA, -c $ 'ETA2','ETA2', $ AXV_STORE(nplanes-ip+1,ibest), - $ AYV_STORE(nplanes-ip+1,ibest)) + $ AYV_STORE(nplanes-ip+1,ibest), + $ bxyz(1), + $ bxyz(2) + $ ) distance = distance_to(XP,YP) +c distance = distance / RCHI2_STORE(ibest)!<<< MS !QUIQUI id=id_cp(ip,icp,ist) - if(DEBUG)print*,'( couple ',id - $ ,' ) normalized distance ',distance + if(DEBUG.EQ.1)print*,'( couple ',id + $ ,' ) distance ',distance if(distance.lt.distmin)then xmm = xPAM ymm = yPAM @@ -3405,35 +3376,37 @@ rymm = resyPAM distmin = distance idm = id -c dedxmm = (dedx(icx)+dedx(icy))/2. !(1) - dedxmmx = dedx(icx)/mip(VIEW(icx),LADDER(icx)) !(1)(2) - dedxmmy = dedx(icy)/mip(VIEW(icy),LADDER(icy)) !(1)(2) + dedxmmx = sgnl(icx)/mip(VIEW(icx),LADDER(icx)) !(1)(2) + dedxmmy = sgnl(icy)/mip(VIEW(icy),LADDER(icy)) !(1)(2) +c QUIQUI --> non devo moltiplicare per clinc?!?!?! + clincnewc=10*sqrt(rymm**2+rxmm**2 !QUIQUI + $ +RCHI2_STORE(ibest)*k(ip)*(cov(1,1)+cov(2,2))) !QUIQUI endif 1188 continue enddo !end loop on couples on plane icp - if(distmin.le.clinc)then +c if(distmin.le.clinc)then !QUIQUI + if(distmin.le.clincnewc)then !QUIQUI * ----------------------------------- - xm(nplanes-ip+1) = xmm !<<< - ym(nplanes-ip+1) = ymm !<<< - zm(nplanes-ip+1) = zmm !<<< - xgood(nplanes-ip+1) = 1 !<<< - ygood(nplanes-ip+1) = 1 !<<< - resx(nplanes-ip+1)=rxmm !<<< - resy(nplanes-ip+1)=rymm !<<< -c dedxtrk(nplanes-ip+1) = dedxmm !<<< !(1) - dedxtrk_x(nplanes-ip+1) = dedxmmx !(1) - dedxtrk_y(nplanes-ip+1) = dedxmmy !(1) + xm(nplanes-ip+1) = xmm !<<< + ym(nplanes-ip+1) = ymm !<<< + zm(nplanes-ip+1) = zmm !<<< + xgood(nplanes-ip+1) = 1 !<<< + ygood(nplanes-ip+1) = 1 !<<< + resx(nplanes-ip+1)=rxmm !<<< + resy(nplanes-ip+1)=rymm !<<< + dedxtrk_x(nplanes-ip+1) = dedxmmx !<<< + dedxtrk_y(nplanes-ip+1) = dedxmmy !<<< * ----------------------------------- CP_STORE(nplanes-ip+1,ibest)=idm - if(DEBUG)print*,'%%%% included couple ',idm - $ ,' (norm.dist.= ',distmin,', cut ',clinc,' )' + if(DEBUG.EQ.1)print*,'%%%% included couple ',idm + $ ,' (dist.= ',distmin,', cut ',clinc,' )' goto 133 !next plane endif * ================================================ * STEP 2 >>>>>>> try to include a single cluster * either from a couple or single * ================================================ -c if(DEBUG)print*,'>>>> try to include a new cluster' +c if(DEBUG.EQ.1)print*,'>>>> try to include a new cluster' distmin=1000000. xmm_A = 0. !--------------------------- ymm_A = 0. ! init variables that @@ -3456,16 +3429,22 @@ if(LADDER(icx).ne.nldt)goto 11882 !if the ladder number does not match * !jump to the next couple *----- try cluster x ----------------------------------------------- - if(cl_used(icx).eq.1)goto 11881 !if the X cluster is already used +c if(cl_used(icx).eq.1)goto 11881 !if the X cluster is already used + if(cl_used(icx).ne.0)goto 11881 !if the X cluster is already used !(3) * !jump to the Y cluster +c call xyz_PAM(icx,0,ist, +c $ PFA,PFA, +c $ AXV_STORE(nplanes-ip+1,ibest),0.) call xyz_PAM(icx,0,ist, -c $ 'ETA2','ETA2', $ PFA,PFA, - $ AXV_STORE(nplanes-ip+1,ibest),0.) + $ AXV_STORE(nplanes-ip+1,ibest),0., + $ bxyz(1), + $ bxyz(2) + $ ) distance = distance_to(XP,YP) -c if(DEBUG)print*,'normalized distance ',distance - if(DEBUG)print*,'( cl-X ',icx - $ ,' in cp ',id,' ) normalized distance ',distance +c distance = distance / RCHI2_STORE(ibest)!<<< MS !QUIQUI + if(DEBUG.EQ.1)print*,'( cl-X ',icx + $ ,' in cp ',id,' ) distance ',distance if(distance.lt.distmin)then xmm_A = xPAM_A ymm_A = yPAM_A @@ -3477,21 +3456,28 @@ rymm = resyPAM distmin = distance iclm = icx -c dedxmm = dedx(icx) !(1) - dedxmmx = dedx(icx)/mip(VIEW(icx),LADDER(icx)) !(1)(2) +c dedxmm = sgnl(icx) !(1) + dedxmmx = sgnl(icx)/mip(VIEW(icx),LADDER(icx)) !(1)(2) dedxmmy = 0. !(1) endif 11881 continue *----- try cluster y ----------------------------------------------- - if(cl_used(icy).eq.1)goto 11882 !if the Y cluster is already used +c if(cl_used(icy).eq.1)goto 11882 !if the Y cluster is already used + if(cl_used(icy).ne.0)goto 11882 !if the Y cluster is already used !(3) * !jump to the next couple +c call xyz_PAM(0,icy,ist, +c $ PFA,PFA, +c $ 0.,AYV_STORE(nplanes-ip+1,ibest)) call xyz_PAM(0,icy,ist, -c $ 'ETA2','ETA2', $ PFA,PFA, - $ 0.,AYV_STORE(nplanes-ip+1,ibest)) + $ 0.,AYV_STORE(nplanes-ip+1,ibest), + $ bxyz(1), + $ bxyz(2) + $ ) distance = distance_to(XP,YP) - if(DEBUG)print*,'( cl-Y ',icy - $ ,' in cp ',id,' ) normalized distance ',distance +c distance = distance / RCHI2_STORE(ibest)!<<< MS !QUIQUI + if(DEBUG.EQ.1)print*,'( cl-Y ',icy + $ ,' in cp ',id,' ) distance ',distance if(distance.lt.distmin)then xmm_A = xPAM_A ymm_A = yPAM_A @@ -3503,34 +3489,42 @@ rymm = resyPAM distmin = distance iclm = icy -c dedxmm = dedx(icy) !(1) +c dedxmm = sgnl(icy) !(1) dedxmmx = 0. !(1) - dedxmmy = dedx(icy)/mip(VIEW(icy),LADDER(icy)) !(1)(2) + dedxmmy = sgnl(icy)/mip(VIEW(icy),LADDER(icy)) !(1)(2) endif 11882 continue enddo !end loop on cluster inside couples -*----- single clusters ----------------------------------------------- +*----- single clusters ----------------------------------------------- +c print*,'## ncls(',ip,') ',ncls(ip) do ic=1,ncls(ip) !loop on single clusters icl=cls(ip,ic) - 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 + if(cl_used(icl).ne.0.or. !if the cluster is already used !(3) $ LADDER(icl).ne.nldt.or. !or the ladder number does not match $ .false.)goto 18882 !jump to the next singlet if(mod(VIEW(icl),2).eq.0)then!<---- X view call xyz_PAM(icl,0,ist, -c $ 'ETA2','ETA2', $ PFA,PFA, - $ AXV_STORE(nplanes-ip+1,ibest),0.) + $ AXV_STORE(nplanes-ip+1,ibest),0., + $ bxyz(1), + $ bxyz(2) + $ ) else !<---- Y view call xyz_PAM(0,icl,ist, -c $ 'ETA2','ETA2', $ PFA,PFA, - $ 0.,AYV_STORE(nplanes-ip+1,ibest)) + $ 0.,AYV_STORE(nplanes-ip+1,ibest), + $ bxyz(1), + $ bxyz(2) + $ ) endif distance = distance_to(XP,YP) - if(DEBUG)print*,'( cl-s ',icl - $ ,' ) normalized distance ',distance +c distance = distance / RCHI2_STORE(ibest)!<<< MS !QUIQUI + if(DEBUG.EQ.1)print*,'( cl-s ',icl + $ ,' ) distance ',distance if(distance.lt.distmin)then +c if(DEBUG.EQ.1)print*,'YES' xmm_A = xPAM_A ymm_A = yPAM_A zmm_A = zPAM_A @@ -3541,43 +3535,64 @@ rymm = resyPAM distmin = distance iclm = icl -c dedxmm = dedx(icl) !(1) if(mod(VIEW(icl),2).eq.0)then !<---- X view - dedxmmx = dedx(icl)/mip(VIEW(icl),LADDER(icl)) !(1)(2) - dedxmmy = 0. !(1) + dedxmmx = sgnl(icl)/mip(VIEW(icl),LADDER(icl)) + dedxmmy = 0. else !<---- Y view - dedxmmx = 0. !(1) - dedxmmy = dedx(icl)/mip(VIEW(icl),LADDER(icl)) !(1)(2) + dedxmmx = 0. + dedxmmy = sgnl(icl)/mip(VIEW(icl),LADDER(icl)) endif endif 18882 continue enddo !end loop on single clusters +c print*,'## distmin ', distmin,' clinc ',clinc - if(distmin.le.clinc)then - - CLS_STORE(nplanes-ip+1,ibest)=iclm !<<<< -* ---------------------------- +c QUIQUI------------ +c anche qui: non ci vuole clinc??? + if(iclm.ne.0)then if(mod(VIEW(iclm),2).eq.0)then - XGOOD(nplanes-ip+1)=1. - resx(nplanes-ip+1)=rxmm - if(DEBUG)print*,'%%%% included X-cl ',iclm - $ ,' ( norm.dist.= ',distmin,', cut ',clinc,' )' - else - YGOOD(nplanes-ip+1)=1. - resy(nplanes-ip+1)=rymm - if(DEBUG)print*,'%%%% included Y-cl ',iclm - $ ,' ( norm.dist.= ',distmin,', cut ',clinc,' )' + clincnew= + $ 20* + $ sqrt(rxmm**2+RCHI2_STORE(ibest)*k(ip)*cov(1,1)) + else if(mod(VIEW(iclm),2).ne.0)then + clincnew= + $ 10* + $ sqrt(rymm**2+RCHI2_STORE(ibest)*k(ip)*cov(2,2)) + endif +c QUIQUI------------ + + if(distmin.le.clincnew)then !QUIQUI +c if(distmin.le.clinc)then !QUIQUI + + CLS_STORE(nplanes-ip+1,ibest)=iclm !<<<< +* ---------------------------- +c print*,'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~' + if(mod(VIEW(iclm),2).eq.0)then + XGOOD(nplanes-ip+1)=1. + resx(nplanes-ip+1)=rxmm + if(DEBUG.EQ.1)print*,'%%%% included X-cl ',iclm + $ ,'( chi^2, ',RCHI2_STORE(ibest) + $ ,', dist.= ',distmin + $ ,', cut ',clinc,' )' + else + YGOOD(nplanes-ip+1)=1. + resy(nplanes-ip+1)=rymm + if(DEBUG.EQ.1)print*,'%%%% included Y-cl ',iclm + $ ,'( chi^2, ',RCHI2_STORE(ibest) + $ ,', dist.= ', distmin + $ ,', cut ',clinc,' )' + 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. + dedxtrk_x(nplanes-ip+1) = dedxmmx !<<< + dedxtrk_y(nplanes-ip+1) = dedxmmy !<<< +* ---------------------------- endif -* ---------------------------- - 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) -* ---------------------------- endif endif 133 continue @@ -3596,18 +3611,15 @@ * * * * ************************************************** - +* subroutine clean_XYclouds(ibest,iflag) include 'commontracker.f' + include 'level1.f' include 'common_momanhough.f' - include 'momanhough_init.f' -c include 'calib.f' -c include 'level1.f' - - logical DEBUG - common/dbg/DEBUG + include 'level2.f' + if(DEBUG.EQ.1)print*,'clean_XYclouds:' do ip=1,nplanes !loop on planes @@ -3617,15 +3629,12 @@ if(id.ne.0)then iclx=clx(ip,icp_cp(id)) icly=cly(ip,icp_cp(id)) - cl_used(iclx)=1 !tag used clusters - cl_used(icly)=1 !tag used clusters +c$$$ cl_used(iclx)=ntrk !tag used clusters +c$$$ cl_used(icly)=ntrk !tag used clusters elseif(icl.ne.0)then - cl_used(icl)=1 !tag used clusters +c$$$ cl_used(icl)=ntrk !tag used clusters endif -c if(DEBUG)then -c print*,ip,' <<< ',id -c endif * ----------------------------- * remove the couple from clouds * remove also vitual couples containing the @@ -3642,7 +3651,7 @@ $ cly(ip,icp).eq.icl $ )then id=id_cp(ip,icp,1) - if(DEBUG)then + if(DEBUG.EQ.1)then print*,ip,' <<< cp ',id $ ,' ( cl-x ' $ ,clx(ip,icp) @@ -3676,161 +3685,53 @@ -c$$$*** * * * *** * * * *** * * * *** * * * *** * * * *** * * * *** -c$$$ real function fbad_cog(ncog,ic) -c$$$ -c$$$ -c$$$ include 'commontracker.f' -c$$$ include 'level1.f' -c$$$ include 'calib.f' -c$$$ -c$$$* --> signal of the central strip -c$$$ sc = CLSIGNAL(INDMAX(ic)) !center -c$$$ -c$$$* signal of adjacent strips -c$$$* --> left -c$$$ sl1 = 0 !left 1 -c$$$ if( -c$$$ $ (INDMAX(ic)-1).ge.INDSTART(ic) -c$$$ $ ) -c$$$ $ sl1 = max(0.,CLSIGNAL(INDMAX(ic)-1)) -c$$$ -c$$$ sl2 = 0 !left 2 -c$$$ if( -c$$$ $ (INDMAX(ic)-2).ge.INDSTART(ic) -c$$$ $ ) -c$$$ $ sl2 = max(0.,CLSIGNAL(INDMAX(ic)-2)) -c$$$ -c$$$* --> right -c$$$ sr1 = 0 !right 1 -c$$$ if( -c$$$ $ (ic.ne.NCLSTR1.and.(INDMAX(ic)+1).lt.INDSTART(ic+1)) -c$$$ $ .or. -c$$$ $ (ic.eq.NCLSTR1.and.(INDMAX(ic)+1).le.TOTCLLENGTH) -c$$$ $ ) -c$$$ $ sr1 = max(0.,CLSIGNAL(INDMAX(ic)+1)) -c$$$ -c$$$ sr2 = 0 !right 2 -c$$$ if( -c$$$ $ (ic.ne.NCLSTR1.and.(INDMAX(ic)+2).lt.INDSTART(ic+1)) -c$$$ $ .or. -c$$$ $ (ic.eq.NCLSTR1.and.(INDMAX(ic)+2).le.TOTCLLENGTH) -c$$$ $ ) -c$$$ $ sr2 = max(0.,CLSIGNAL(INDMAX(ic)+2)) -c$$$ -c$$$ -c$$$ if(mod(int(VIEW(ic)),2).eq.1)then !Y-view -c$$$ f = 4. -c$$$ si = 8.4 -c$$$ else !X-view -c$$$ f = 6. -c$$$ si = 3.9 -c$$$ endif -c$$$ -c$$$ fbad_cog = 1. -c$$$ f0 = 1 -c$$$ f1 = 1 -c$$$ f2 = 1 -c$$$ f3 = 1 -c$$$ if(sl1.gt.sr1.and.sl1.gt.0.)then -c$$$ -c$$$ if(BAD(VIEW(ic),nvk(MAXS(ic)),nst(MAXS(ic)) ).eq.0)f0=f -c$$$ if(BAD(VIEW(ic),nvk(MAXS(ic)),nst(MAXS(ic)-1)).eq.0)f1=f -c$$$c if(BAD(VIEW(ic),nvk(MAXS(ic)),nst(MAXS(ic)+1)).eq.0)f3=f -c$$$ -c$$$ if(ncog.eq.2.and.sl1.ne.0)then -c$$$ fbad_cog = (f1**2*sc**2/sl1**2+f0**2)/(sc**2/sl1**2+1.) -c$$$ elseif(ncog.eq.3.and.sl1.ne.0.and.sr1.ne.0)then -c$$$ fbad_cog = 1. -c$$$ elseif(ncog.eq.4.and.sl1.ne.0.and.sr1.ne.0.and.sl2.ne.0)then -c$$$ fbad_cog = 1. -c$$$ else -c$$$ fbad_cog = 1. -c$$$ endif -c$$$ -c$$$ elseif(sl1.le.sr1.and.sr1.gt.0.)then -c$$$ -c$$$ -c$$$ if(BAD(VIEW(ic),nvk(MAXS(ic)),nst(MAXS(ic)) ).eq.0)f0=f -c$$$ if(BAD(VIEW(ic),nvk(MAXS(ic)),nst(MAXS(ic)+1)).eq.0)f1=f -c$$$c if(BAD(VIEW(ic),nvk(MAXS(ic)),nst(MAXS(ic)-1)).eq.0)f3=f -c$$$ -c$$$ if(ncog.eq.2.and.sr1.ne.0)then -c$$$ fbad_cog = (f1**2*sc**2/sr1**2+f0**2)/(sc**2/sr1**2+1.) -c$$$ elseif(ncog.eq.3.and.sr1.ne.0.and.sl1.ne.0)then -c$$$ fbad_cog = 1. -c$$$ elseif(ncog.eq.4.and.sr1.ne.0.and.sl1.ne.0.and.sr2.ne.0)then -c$$$ fbad_cog = 1. -c$$$ else -c$$$ fbad_cog = 1. -c$$$ endif -c$$$ -c$$$ endif -c$$$ -c$$$ fbad_cog = sqrt(fbad_cog) -c$$$ -c$$$ return -c$$$ end -c$$$ - * **************************************************** subroutine init_level2 -c***************************************************** -c 07/10/2005 modified by elena vannuccini --> (1) -c***************************************************** - include 'commontracker.f' + include 'level1.f' include 'common_momanhough.f' include 'level2.f' - include 'level1.f' - - - - good2 = 0!.false. -c$$$ nev2 = nev1 - -c$$$# ifndef TEST2003 -c$$$c***************************************************** -c$$$cccccc 11/9/2005 modified by david fedele -c$$$c pkt_type = pkt_type1 -c$$$c pkt_num = pkt_num1 -c$$$c obt = obt1 -c$$$c which_calib = which_calib1 -c$$$ swcode = 302 -c$$$ -c$$$ which_calib = which_calib1 -c$$$ pkt_type = pkt_type1 -c$$$ pkt_num = pkt_num1 -c$$$ obt = obt1 -c$$$ cpu_crc = cpu_crc1 -c$$$ do iv=1,12 -c$$$ crc(iv)=crc1(iv) -c$$$ enddo -c$$$# endif -c***************************************************** +* --------------------------------- +* variables initialized from level1 +* --------------------------------- + do i=1,nviews + good2(i)=good1(i) + do j=1,nva1_view + vkflag(i,j)=1 + if(cnnev(i,j).le.0)then + vkflag(i,j)=cnnev(i,j) + endif + enddo + enddo +* ---------------- +* level2 variables +* ---------------- NTRK = 0 - do it=1,NTRKMAX!NTRACKSMAX + do it=1,NTRKMAX IMAGE(IT)=0 CHI2_nt(IT) = -100000. - BdL(IT) = 0. do ip=1,nplanes XM_nt(IP,IT) = 0 YM_nt(IP,IT) = 0 ZM_nt(IP,IT) = 0 RESX_nt(IP,IT) = 0 RESY_nt(IP,IT) = 0 + TAILX_nt(IP,IT) = 0 + TAILY_nt(IP,IT) = 0 + XBAD(IP,IT) = 0 + YBAD(IP,IT) = 0 XGOOD_nt(IP,IT) = 0 YGOOD_nt(IP,IT) = 0 -c***************************************************** -cccccc 11/9/2005 modified by david fedele + LS(IP,IT) = 0 DEDX_X(IP,IT) = 0 DEDX_Y(IP,IT) = 0 -c****************************************************** + CLTRX(IP,IT) = 0 + CLTRY(IP,IT) = 0 enddo do ipa=1,5 AL_nt(IPA,IT) = 0 @@ -3839,25 +3740,18 @@ enddo enddo enddo - - -c***************************************************** -cccccc 11/9/2005 modified by david fedele nclsx=0 nclsy=0 do ip=1,NSINGMAX planex(ip)=0 -c xs(ip)=0 xs(1,ip)=0 xs(2,ip)=0 sgnlxs(ip)=0 planey(ip)=0 -c ys(ip)=0 ys(1,ip)=0 ys(2,ip)=0 sgnlys(ip)=0 enddo -c******************************************************* end @@ -3872,6 +3766,90 @@ ************************************************************ + subroutine init_hough + + include 'commontracker.f' + include 'level1.f' + include 'common_momanhough.f' + include 'common_hough.f' + include 'level2.f' + + ntrpt_nt=0 + ndblt_nt=0 + NCLOUDS_XZ_nt=0 + NCLOUDS_YZ_nt=0 + do idb=1,ndblt_max_nt + db_cloud_nt(idb)=0 + alfayz1_nt(idb)=0 + alfayz2_nt(idb)=0 + enddo + do itr=1,ntrpt_max_nt + tr_cloud_nt(itr)=0 + alfaxz1_nt(itr)=0 + alfaxz2_nt(itr)=0 + alfaxz3_nt(itr)=0 + enddo + do idb=1,ncloyz_max + ptcloud_yz_nt(idb)=0 + alfayz1_av_nt(idb)=0 + alfayz2_av_nt(idb)=0 + enddo + do itr=1,ncloxz_max + ptcloud_xz_nt(itr)=0 + alfaxz1_av_nt(itr)=0 + alfaxz2_av_nt(itr)=0 + alfaxz3_av_nt(itr)=0 + enddo + + ntrpt=0 + ndblt=0 + NCLOUDS_XZ=0 + NCLOUDS_YZ=0 + do idb=1,ndblt_max + db_cloud(idb)=0 + cpyz1(idb)=0 + cpyz2(idb)=0 + alfayz1(idb)=0 + alfayz2(idb)=0 + enddo + do itr=1,ntrpt_max + tr_cloud(itr)=0 + cpxz1(itr)=0 + cpxz2(itr)=0 + cpxz3(itr)=0 + alfaxz1(itr)=0 + alfaxz2(itr)=0 + alfaxz3(itr)=0 + enddo + do idb=1,ncloyz_max + ptcloud_yz(idb)=0 + alfayz1_av(idb)=0 + alfayz2_av(idb)=0 + do idbb=1,ncouplemaxtot + cpcloud_yz(idb,idbb)=0 + enddo + enddo + do itr=1,ncloxz_max + ptcloud_xz(itr)=0 + alfaxz1_av(itr)=0 + alfaxz2_av(itr)=0 + alfaxz3_av(itr)=0 + do itrr=1,ncouplemaxtot + cpcloud_xz(itr,itrr)=0 + enddo + enddo + end +************************************************************ +* +* +* +* +* +* +* +************************************************************ + + subroutine fill_level2_tracks(ntr) * ------------------------------------------------------- @@ -3882,35 +3860,42 @@ include 'commontracker.f' + include 'level1.f' + include 'common_momanhough.f' include 'level2.f' include 'common_mini_2.f' - real sinth,phi,pig !(4) + include 'calib.f' + + character*10 PFA + common/FINALPFA/PFA + + real sinth,phi,pig + integer ssensor,sladder pig=acos(-1.) - good2=1!.true. +* ------------------------------------- chi2_nt(ntr) = sngl(chi2) - - phi = al(4) !(4) - sinth = al(3) !(4) - if(sinth.lt.0)then !(4) - sinth = -sinth !(4) - phi = phi + pig !(4) - endif !(4) - npig = aint(phi/(2*pig)) !(4) - phi = phi - npig*2*pig !(4) - if(phi.lt.0) !(4) - $ phi = phi + 2*pig !(4) - al(4) = phi !(4) - al(3) = sinth !(4) -***************************************************** + nstep_nt(ntr) = nstep +* ------------------------------------- + phi = al(4) + sinth = al(3) + if(sinth.lt.0)then + sinth = -sinth + phi = phi + pig + endif + npig = aint(phi/(2*pig)) + phi = phi - npig*2*pig + if(phi.lt.0) + $ phi = phi + 2*pig + al(4) = phi + al(3) = sinth do i=1,5 al_nt(i,ntr) = sngl(al(i)) do j=1,5 coval(i,j,ntr) = sngl(cov(i,j)) enddo -c print*,al_nt(i,ntr) enddo - +* ------------------------------------- do ip=1,nplanes ! loop on planes xgood_nt(ip,ntr) = int(xgood(ip)) ygood_nt(ip,ntr) = int(ygood(ip)) @@ -3919,31 +3904,106 @@ zm_nt(ip,ntr) = sngl(zm(ip)) RESX_nt(IP,ntr) = sngl(resx(ip)) RESY_nt(IP,ntr) = sngl(resy(ip)) + TAILX_nt(IP,ntr) = 0. + TAILY_nt(IP,ntr) = 0. xv_nt(ip,ntr) = sngl(xv(ip)) yv_nt(ip,ntr) = sngl(yv(ip)) zv_nt(ip,ntr) = sngl(zv(ip)) axv_nt(ip,ntr) = sngl(axv(ip)) - ayv_nt(ip,ntr) = sngl(ayv(ip)) -c dedxp(ip,ntr) = sngl(dedxtrk(ip)) !(1) - dedx_x(ip,ntr) = sngl(dedxtrk_x(ip)) !(2) - dedx_y(ip,ntr) = sngl(dedxtrk_y(ip)) !(2) - enddo -c call CalcBdL(100,xxxx,IFAIL) -c if(ifps(xxxx).eq.1)BdL(ntr) = xxxx -c$$$ print*,'xgood(ip,ntr) ',(xgood_nt(ip,ntr),ip=1,6) -c$$$ print*,'ygood(ip,ntr) ',(ygood_nt(ip,ntr),ip=1,6) -c$$$ print*,'dedx_x(ip,ntr) ',(dedx_x(ip,ntr),ip=1,6) -c$$$ print*,'dedx_y(ip,ntr) ',(dedx_y(ip,ntr),ip=1,6) + ayv_nt(ip,ntr) = sngl(ayv(ip)) + + factor = sqrt( + $ tan( acos(-1.) * sngl(axv(ip)) /180. )**2 + + $ tan( acos(-1.) * sngl(ayv(ip)) /180. )**2 + + $ 1. ) + + dedx_x(ip,ntr) = sngl(dedxtrk_x(ip)/factor) + dedx_y(ip,ntr) = sngl(dedxtrk_y(ip)/factor) + + ax = axv_nt(ip,ntr) + ay = ayv_nt(ip,ntr) + bfx = BX_STORE(ip,IDCAND) + bfy = BY_STORE(ip,IDCAND) + if(ip.eq.6) ax = -1. * axv_nt(ip,ntr) + if(ip.eq.6) bfy = -1. * BY_STORE(ip,IDCAND) + tgtemp = tan(ax*acos(-1.)/180.) + pmuH_h*bfy*0.00001 + angx = 180.*atan(tgtemp)/acos(-1.) + tgtemp = tan(ay*acos(-1.)/180.)+pmuH_e*bfx*0.00001 + angy = 180.*atan(tgtemp)/acos(-1.) + +c print*,'* ',ip,bfx,bfy,angx,angy + + id = CP_STORE(ip,IDCAND) ! couple id + icl = CLS_STORE(ip,IDCAND) + ssensor = -1 + sladder = -1 + ssensor = SENSOR_STORE(ip,IDCAND) + sladder = LADDER_STORE(ip,IDCAND) + if(ip.eq.6.and.ssensor.ne.0)ssensor = 3 - ssensor !notazione paolo x align + LS(IP,ntr) = ssensor+10*sladder + + if(id.ne.0)then +c >>> is a couple + cltrx(ip,ntr) = clx(nplanes-ip+1,icp_cp(id)) + cltry(ip,ntr) = cly(nplanes-ip+1,icp_cp(id)) + + cl_used(cltrx(ip,ntr)) = 1 !tag used clusters + cl_used(cltry(ip,ntr)) = 1 !tag used clusters + +c$$$ nnnnx = npfastrips(clx(nplanes-ip+1,icp_cp(id)),PFA,angx) +c$$$ nnnny = npfastrips(cly(nplanes-ip+1,icp_cp(id)),PFA,angy) +c$$$ xbad(ip,ntr)= nbadstrips(nnnnx,clx(nplanes-ip+1,icp_cp(id))) +c$$$ ybad(ip,ntr)= nbadstrips(nnnny,cly(nplanes-ip+1,icp_cp(id))) + xbad(ip,ntr)= nbadstrips(4,clx(nplanes-ip+1,icp_cp(id))) + ybad(ip,ntr)= nbadstrips(4,cly(nplanes-ip+1,icp_cp(id))) + + + if(nsatstrips(clx(nplanes-ip+1,icp_cp(id))).gt.0) + $ dedx_x(ip,ntr)=-dedx_x(ip,ntr) + if(nsatstrips(cly(nplanes-ip+1,icp_cp(id))).gt.0) + $ dedx_y(ip,ntr)=-dedx_y(ip,ntr) + + elseif(icl.ne.0)then + + cl_used(icl) = 1 !tag used clusters + + if(mod(VIEW(icl),2).eq.0)then + cltrx(ip,ntr)=icl +c$$$ nnnnn = npfastrips(icl,PFA,angx) +c$$$ xbad(ip,ntr) = nbadstrips(nnnnn,icl) + xbad(ip,ntr) = nbadstrips(4,icl) + + if(nsatstrips(icl).gt.0)dedx_x(ip,ntr)=-dedx_x(ip,ntr) + elseif(mod(VIEW(icl),2).eq.1)then + cltry(ip,ntr)=icl +c$$$ nnnnn = npfastrips(icl,PFA,angy) +c$$$ ybad(ip,ntr) = nbadstrips(nnnnn,icl) + ybad(ip,ntr) = nbadstrips(4,icl) + if(nsatstrips(icl).gt.0)dedx_y(ip,ntr)=-dedx_y(ip,ntr) + endif + + endif + + enddo + if(DEBUG.eq.1)then + print*,'> STORING TRACK ',ntr + print*,'clusters: ' + do ip=1,6 + print*,'> ',ip,' -- ',cltrx(ip,ntr),cltry(ip,ntr) + enddo + endif + +c$$$ print*,(xgood(i),i=1,6) +c$$$ print*,(ygood(i),i=1,6) +c$$$ print*,(ls(i,ntr),i=1,6) +c$$$ print*,(dedx_x(i,ntr),i=1,6) +c$$$ print*,(dedx_y(i,ntr),i=1,6) +c$$$ print*,'-----------------------' end subroutine fill_level2_siglets -c***************************************************** -c 07/10/2005 created by elena vannuccini -c 31/01/2006 modified by elena vannuccini -* to convert adc to mip --> (2) -c***************************************************** * ------------------------------------------------------- * This routine fills the elements of the variables @@ -3952,27 +4012,40 @@ * ------------------------------------------------------- include 'commontracker.f' - include 'level1.f' - include 'level2.f' include 'calib.f' + include 'level1.f' include 'common_momanhough.f' + include 'level2.f' include 'common_xyzPAM.f' * count #cluster per plane not associated to any track - good2=1!.true. nclsx = 0 nclsy = 0 + do iv = 1,nviews +c if( mask_view(iv).ne.0 )good2(iv) = 20+mask_view(iv) + good2(iv) = good2(iv) + mask_view(iv)*2**8 + enddo + + if(DEBUG.eq.1)then + print*,'> STORING SINGLETS ' + endif + do icl=1,nclstr1 + + ip=nplanes-npl(VIEW(icl))+1 + if(cl_used(icl).eq.0)then !cluster not included in any track - ip=nplanes-npl(VIEW(icl))+1 if(mod(VIEW(icl),2).eq.0)then !=== X views nclsx = nclsx + 1 planex(nclsx) = ip - sgnlxs(nclsx) = dedx(icl)/mip(VIEW(icl),LADDER(icl))!(2) + sgnlxs(nclsx) = sgnl(icl)/mip(VIEW(icl),LADDER(icl)) + if(nsatstrips(icl).gt.0)sgnlxs(nclsx)=-sgnlxs(nclsx) + clsx(nclsx) = icl do is=1,2 c call xyz_PAM(icl,0,is,'COG1',' ',0.,0.) - call xyz_PAM(icl,0,is,PFAdef,' ',0.,0.) +c call xyz_PAM(icl,0,is,PFAdef,' ',0.,0.) + call xyz_PAM(icl,0,is,PFAdef,' ',0.,0.,0.,0.) xs(is,nclsx) = (xPAM_A+xPAM_B)/2 enddo c$$$ print*,'nclsx ',nclsx @@ -3983,10 +4056,13 @@ else !=== Y views nclsy = nclsy + 1 planey(nclsy) = ip - sgnlys(nclsy) = dedx(icl)/mip(VIEW(icl),LADDER(icl))!(2) + sgnlys(nclsy) = sgnl(icl)/mip(VIEW(icl),LADDER(icl)) + if(nsatstrips(icl).gt.0)sgnlys(nclsy)=-sgnlys(nclsy) + clsy(nclsy) = icl do is=1,2 c call xyz_PAM(0,icl,is,' ','COG1',0.,0.) - call xyz_PAM(0,icl,is,' ',PFAdef,0.,0.) +c call xyz_PAM(0,icl,is,' ',PFAdef,0.,0.) + call xyz_PAM(0,icl,is,' ',PFAdef,0.,0.,0.,0.) ys(is,nclsy) = (yPAM_A+yPAM_B)/2 enddo c$$$ print*,'nclsy ',nclsy @@ -3996,11 +4072,112 @@ c$$$ print*,'ys(2,nclsy) ',ys(2,nclsy) endif endif -c print*,icl,cl_used(icl),cl_good(icl),ip,VIEW(icl)!nclsx(ip),nclsy(ip) + +***** LO METTO QUI PERCHE` NON SO DOVE METTERLO + whichtrack(icl) = cl_used(icl) +* -------------------------------------------------- +* per non perdere la testa... +* whichtrack(icl) e` una variabile del common level1 +* che serve solo per sapere quali cluster sono stati +* associati ad una traccia, e permettere di salvare +* solo questi nell'albero di uscita +* -------------------------------------------------- + + +c$$$ print*,' cl ',icl,' --> ',cl_used(icl) +c$$$ +c$$$ if( cl_used(icl).ne.0 )then +c$$$ if( +c$$$ $ mod(VIEW(icl),2).eq.0.and. +c$$$ $ cltrx(ip,whichtrack(icl)).ne.icl ) +c$$$ $ print*,'**WARNING** cltrx(',ip,',',whichtrack(icl) +c$$$ $ ,')=',cltrx(ip,whichtrack(icl)),'.ne.',icl +c$$$ if( +c$$$ $ mod(VIEW(icl),2).eq.1.and. +c$$$ $ cltry(ip,whichtrack(icl)).ne.icl ) +c$$$ $ print*,'**WARNING** cltry(',ip,',',whichtrack(icl) +c$$$ $ ,')=',cltry(ip,whichtrack(icl)),'.ne.',icl +c$$$ endif + + enddo end +*************************************************** +* * +* * +* * +* * +* * +* * +************************************************** + subroutine fill_hough +* ------------------------------------------------------- +* This routine fills the variables related to the hough +* transform, for the debig n-tuple +* ------------------------------------------------------- + include 'commontracker.f' + include 'level1.f' + include 'common_momanhough.f' + include 'common_hough.f' + include 'level2.f' + if(.false. + $ .or.ntrpt.gt.ntrpt_max_nt + $ .or.ndblt.gt.ndblt_max_nt + $ .or.NCLOUDS_XZ.gt.ncloxz_max + $ .or.NCLOUDS_yZ.gt.ncloyz_max + $ )then + ntrpt_nt=0 + ndblt_nt=0 + NCLOUDS_XZ_nt=0 + NCLOUDS_YZ_nt=0 + else + ndblt_nt=ndblt + ntrpt_nt=ntrpt + if(ndblt.ne.0)then + do id=1,ndblt + alfayz1_nt(id)=alfayz1(id) !Y0 + alfayz2_nt(id)=alfayz2(id) !tg theta-yz + enddo + endif + if(ndblt.ne.0)then + do it=1,ntrpt + alfaxz1_nt(it)=alfaxz1(it) !X0 + alfaxz2_nt(it)=alfaxz2(it) !tg theta-xz + alfaxz3_nt(it)=alfaxz3(it) !1/r + enddo + endif + nclouds_yz_nt=nclouds_yz + nclouds_xz_nt=nclouds_xz + if(nclouds_yz.ne.0)then + nnn=0 + do iyz=1,nclouds_yz + ptcloud_yz_nt(iyz)=ptcloud_yz(iyz) + alfayz1_av_nt(iyz)=alfayz1_av(iyz) + alfayz2_av_nt(iyz)=alfayz2_av(iyz) + nnn=nnn+ptcloud_yz(iyz) + enddo + do ipt=1,nnn + db_cloud_nt(ipt)=db_cloud(ipt) + enddo + endif + if(nclouds_xz.ne.0)then + nnn=0 + do ixz=1,nclouds_xz + ptcloud_xz_nt(ixz)=ptcloud_xz(ixz) + alfaxz1_av_nt(ixz)=alfaxz1_av(ixz) + alfaxz2_av_nt(ixz)=alfaxz2_av(ixz) + alfaxz3_av_nt(ixz)=alfaxz3_av(ixz) + nnn=nnn+ptcloud_xz(ixz) + enddo + do ipt=1,nnn + tr_cloud_nt(ipt)=tr_cloud(ipt) + enddo + endif + endif + end +