/[PAMELA software]/DarthVader/ToFLevel2/src/toftrk.for
ViewVC logotype

Diff of /DarthVader/ToFLevel2/src/toftrk.for

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

revision 1.15 by mocchiut, Mon Mar 3 09:51:04 2008 UTC revision 1.21 by mocchiut, Wed Jul 14 10:00:01 2010 UTC
# Line 44  C             then in a second step we c Line 44  C             then in a second step we c
44  C             measurements, reject if > 10 sigma, calculate chi2 and "quality"  C             measurements, reject if > 10 sigma, calculate chi2 and "quality"
45  C             beta is taken as good if chi2<20 and quality>10  C             beta is taken as good if chi2<20 and quality>10
46  C             The function "newbeta" is located in "tofl2com.for"  C             The function "newbeta" is located in "tofl2com.for"
47    C  mar-08 WM: Call to "newbeta" changed, now a flag tells the function if the
48    C             call comes from "tofl2com" or form "toftrack"
49    C  mar-08 WM: Bug found in dEdx if check_charge>1
50    C  apr-08 WM: Bug found in S22 artificial ADC, mismatch found between the track
51    C             length  from DOTRACK2 and "GetLength" method for 4 combinations
52    C  oct-08 WM: New method to create artificial ADC values. Do NOT take the position
53    C             from the tracking, but the position from timing. This method gives a
54    C             better time resolution
55    C  nov-09 WM: the dEdx part ("adc_c") moved to the new dEdx routine from Napoli
56    C  feb-10 WM: k1 values now for Z=1, Z=2, Z>2, k2 values are fix
57    C  feb-10 WM: charge calculation with tracker dEdx vs. deflection^2
58  C  C
59  C****************************************************************************  C****************************************************************************
60        IMPLICIT NONE        IMPLICIT NONE
# Line 71  c     define TOF Z-coordinates Line 82  c     define TOF Z-coordinates
82       &     xout(NPOINT_MAX),yout(NPOINT_MAX),zin(NPTOF),       &     xout(NPOINT_MAX),yout(NPOINT_MAX),zin(NPTOF),
83       &     THXOUT(NPOINT_MAX),THYOUT(NPOINT_MAX),TLOUT(NPOINT_MAX)       &     THXOUT(NPOINT_MAX),THYOUT(NPOINT_MAX),TLOUT(NPOINT_MAX)
84    
85          DOUBLE PRECISION dedxtrk
86          DOUBLE PRECISION deflection
87    
88        INTEGER IFAIL        INTEGER IFAIL
89  c      REAL dx,dy,dr  c      REAL dx,dy,dr
90        REAL ds        REAL ds
91        REAL t1,t2,t3,t4        REAL t1,t2,t3,t4
92        REAL yhelp,xhelp,xhelp1,xhelp2        REAL yhelp,xhelp,xhelp1,xhelp2
93          REAL yhelp1,yhelp2
94        REAL c1,c2        REAL c1,c2
95  C     REAL sw,sxw,w_i  C     REAL sw,sxw,w_i
96        REAL dist,dl,F        REAL dist,dl,F
# Line 88  C      REAL beta_mean Line 102  C      REAL beta_mean
102    
103        INTEGER j,hitvec(6)        INTEGER j,hitvec(6)
104    
105        real atten,pc_adc,check_charge,newbeta        real atten,pc_adc,newbeta
106    C      real check_charge
107    
108    
109        REAL theta,phi        REAL theta,phi
# Line 101  C--   DATA ZTOF/53.74,53.04,23.94,23.44, Line 116  C--   DATA ZTOF/53.74,53.04,23.94,23.44,
116        PARAMETER (tofarm13 = 77.31) ! from 53.39 to -23.92        PARAMETER (tofarm13 = 77.31) ! from 53.39 to -23.92
117    
118    
119    C--- new
120          REAL xtofpre(3),ytofpre(3)
121    
122          REAL y_coor_lin11c(8,2),x_coor_lin12c(6,2)
123          REAL x_coor_lin21c(2,2),y_coor_lin22c(2,2)
124          REAL y_coor_lin31c(3,2),x_coor_lin32c(3,2)
125    
126          DATA y_coor_lin11c(1,1),y_coor_lin11c(1,2) /-20.66,-2.497/
127          DATA y_coor_lin11c(2,1),y_coor_lin11c(2,2) /-9.10, -2.52/
128          DATA y_coor_lin11c(3,1),y_coor_lin11c(3,2) /-24.07,-2.12/
129          DATA y_coor_lin11c(4,1),y_coor_lin11c(4,2) /-13.40,-2.47/
130          DATA y_coor_lin11c(5,1),y_coor_lin11c(5,2) /-31.07,-2.32/
131          DATA y_coor_lin11c(6,1),y_coor_lin11c(6,2) /-21.69,-2.63/
132          DATA y_coor_lin11c(7,1),y_coor_lin11c(7,2) /-12.37,-2.65/
133          DATA y_coor_lin11c(8,1),y_coor_lin11c(8,2) /-10.81,-3.15/
134    
135          DATA x_coor_lin12c(1,1),x_coor_lin12c(1,2) /12.96, -2.65/
136          DATA x_coor_lin12c(2,1),x_coor_lin12c(2,2) /17.12,-2.44/
137          DATA x_coor_lin12c(3,1),x_coor_lin12c(3,2) /7.26, -1.98/
138          DATA x_coor_lin12c(4,1),x_coor_lin12c(4,2) /-22.52,-2.27/
139          DATA x_coor_lin12c(5,1),x_coor_lin12c(5,2) /-18.54,-2.28/
140          DATA x_coor_lin12c(6,1),x_coor_lin12c(6,2) /-7.67,-2.15/
141    
142          DATA x_coor_lin21c(1,1),x_coor_lin21c(1,2) /22.56,-1.56/
143          DATA x_coor_lin21c(2,1),x_coor_lin21c(2,2) /13.94,-1.56/
144    
145          DATA y_coor_lin22c(1,1),y_coor_lin22c(1,2) /-24.24,-2.23/
146          DATA y_coor_lin22c(2,1),y_coor_lin22c(2,2) /-45.99,-1.68/
147    
148          DATA y_coor_lin31c(1,1),y_coor_lin31c(1,2) /-22.99,-3.54/
149          DATA y_coor_lin31c(2,1),y_coor_lin31c(2,2) /-42.28,-4.10/
150          DATA y_coor_lin31c(3,1),y_coor_lin31c(3,2) /-41.29,-3.69/
151    
152          DATA x_coor_lin32c(1,1),x_coor_lin32c(1,2) /0.961, -3.22/
153          DATA x_coor_lin32c(2,1),x_coor_lin32c(2,2) /4.98,-3.48/
154          DATA x_coor_lin32c(3,1),x_coor_lin32c(3,2) /-22.08,-3.37/
155    
156    C---
157    
158        INTEGER ihelp        INTEGER ihelp
159        REAL xkorr,xpos        REAL xkorr,xpos
160    
161        INTEGER IZ        INTEGER IZ
       REAL k1corrA1,k1corrB1,k1corrC1  
162    
163        REAL yl,yh,xl,xh        REAL yl,yh,xl,xh
164  C  C
# Line 146  C  ratio helium to proton ca. 4 Line 199  C  ratio helium to proton ca. 4
199        itdc = 1        itdc = 1
200        iadc = 2        iadc = 2
201    
   
       k1corrA1 = 0.  
       k1corrB1 = -5.0  
       k1corrC1=  8.0  
   
202        ENDIF   ! ifst        ENDIF   ! ifst
203    
204  *******************************************************************  *******************************************************************
# Line 228  c     put the adc and tdc values from nt Line 276  c     put the adc and tdc values from nt
276           tof21(1,j,1) = (tdc(ch21a(j),hb21a(j)))           tof21(1,j,1) = (tdc(ch21a(j),hb21a(j)))
277           tof21(2,j,1) = (tdc(ch21b(j),hb21b(j)))           tof21(2,j,1) = (tdc(ch21b(j),hb21b(j)))
278        enddo        enddo
279    
280        do j=1,2        do j=1,2
281           tof22(1,j,2) = pc_adc(adc(ch22a(j),hb22a(j)))           tof22(1,j,2) = pc_adc(adc(ch22a(j),hb22a(j)))
282           tof22(2,j,2) = pc_adc(adc(ch22b(j),hb22b(j)))           tof22(2,j,2) = pc_adc(adc(ch22b(j),hb22b(j)))
# Line 309  C     COPY THE ALFA VECTOR FROM AL_PP TO Line 357  C     COPY THE ALFA VECTOR FROM AL_PP TO
357        do i=1,5        do i=1,5
358           AL_P(i) = al_pp(i)           AL_P(i) = al_pp(i)
359        enddo        enddo
360          deflection = AL_P(5)
361    *     3) tracker dEdx
362          dedxtrk = trkmip
363        
364  c      write(*,*) AL_P  c      write(*,*) AL_P
365    c      write(*,*) 'Rig, Def, dEdx ',(1./AL_P(5)),AL_P(5),dedxtrk
366    
367    
368    C--  charge selection with tracker using dedx vs. deflection^2  ----
369    
370           yhelp1 = 3.5 + 4.5*deflection*deflection
371           yhelp2 = 9. + 20.*deflection*deflection
372    c       write(*,*) yhelp1,yhelp2
373    
374           iz = 0
375           if  (dedxtrk.lt.yhelp1) iz=1
376           if ((dedxtrk.gt.yhelp1).and.(dedxtrk.lt.yhelp2)) iz=2
377           if  (dedxtrk.gt.yhelp2) iz=3
378    c       write(*,*) 'tracker charge ',iz
379    
380    C--------------------------------------------------------------------
381    
382        if (al_p(5).eq.0.) THEN        if (al_p(5).eq.0.) THEN
383  c         PRINT *,' TOF - WARNING F77: track with R = 0, discarded'  c         PRINT *,' TOF - WARNING F77: track with R = 0, discarded'
# Line 335  C---  Fill xtr_tof  and ytr_tof: positio Line 402  C---  Fill xtr_tof  and ytr_tof: positio
402        do j=1,6        do j=1,6
403        xtr_tof(j) = XOUT(j)        xtr_tof(j) = XOUT(j)
404        ytr_tof(j) = YOUT(j)        ytr_tof(j) = YOUT(j)
405    c      write(*,*) XOUT(j),YOUT(j)
406        enddo        enddo
407    
408    
# Line 425  c     S22 2 paddles  15.0 x 9.0 cm Line 493  c     S22 2 paddles  15.0 x 9.0 cm
493  c     S31 3 paddles  15.0 x 6.0 cm  c     S31 3 paddles  15.0 x 6.0 cm
494  c     S32 3 paddles  18.0 x 5.0 cm  c     S32 3 paddles  18.0 x 5.0 cm
495    
 c     write(*,*) xout(1),xout(2),xout(3),xout(4),xout(5),xout(6)  
 c     write(*,*) yout(1),yout(2),yout(3),yout(4),yout(5),yout(6)  
496    
497  C--------------S11 --------------------------------------  C--------------S11 --------------------------------------
498    
# Line 531  C--------------S32 --------------------- Line 597  C--------------S32 ---------------------
597        endif        endif
598    
599    
 C     write(*,*) tof11_i,tof12_i,tof21_i,tof22_i,tof31_i,tof32_i  
600    
601         hitvec(1)=tof11_i         hitvec(1)=tof11_i
602         hitvec(2)=tof12_i         hitvec(2)=tof12_i
# Line 540  C     write(*,*) tof11_i,tof12_i,tof21_i Line 605  C     write(*,*) tof11_i,tof12_i,tof21_i
605         hitvec(5)=tof31_i         hitvec(5)=tof31_i
606         hitvec(6)=tof32_i         hitvec(6)=tof32_i
607    
 c       write(*,*) 'toftrk ',  
 c     &  tof11_i,tof12_i,tof21_i,tof22_i,tof31_i,tof32_i  
608    
609  C----------------------------------------------------------------------  C----------------------------------------------------------------------
610  C--- check charge:  C--- check charge:
# Line 560  C--------------------------------------- Line 623  C---------------------------------------
623         F = dl/dist         F = dl/dist
624         theta = acos(1/F)         theta = acos(1/F)
625    
626         iz = int(check_charge(theta,hitvec))  c       iz = int(check_charge(theta,hitvec))
627  c       write(*,*) 'in toftrk',iz  c       write(*,*) 'in toftrk',iz
628    
629    
630    C-------------------------------  new  ---------------------------
631    C--  calculate track position in paddle using timing difference
632    C--  this calculation is preliminary and uses some standard
633    C--  calibration values, but we need to find a rough position to
634    C--  be able to calculate artificial ADC values (needed for the
635    C--  timewalk...
636    C------------------------------------------------------------------
637    
638           do i=1,3
639             xtofpre(i)=100.
640             ytofpre(i)=100.
641           enddo
642    
643    C-----------------------------S1 --------------------------------
644    
645          IF (tof11_i.GT.none_find) THEN
646          IF ((tof11(1,tof11_i,itdc).LT.2000).AND.
647         +                             (tof11(2,tof11_i,itdc).LT.2000))
648         +   ytofpre(1)  = ((tof11(1,tof11_i,itdc)-tof11(2,tof11_i,itdc))/2.
649         +   -y_coor_lin11c(tof11_i,offset))/y_coor_lin11c(tof11_i,slope)
650          endif
651    
652          IF (tof12_i.GT.none_find) THEN
653          IF ((tof12(1,tof12_i,itdc).LT.2000).AND.
654         +                             (tof12(2,tof12_i,itdc).LT.2000))
655         +   xtofpre(1)  = ((tof12(1,tof12_i,itdc)-tof12(2,tof12_i,itdc))/2.
656         +   -x_coor_lin12c(tof12_i,offset))/x_coor_lin12c(tof12_i,slope)
657          endif
658    
659    
660    C-----------------------------S2 --------------------------------
661    
662          IF (tof21_i.GT.none_find) THEN
663          IF ((tof21(1,tof21_i,itdc).LT.2000).AND.
664         +                             (tof21(2,tof21_i,itdc).LT.2000))
665         +   xtofpre(2) = ((tof21(1,tof21_i,itdc)-tof21(2,tof21_i,itdc))/2.
666         +    -x_coor_lin21c(tof21_i,offset))/x_coor_lin21c(tof21_i,slope)
667          endif
668    
669          IF (tof22_i.GT.none_find) THEN
670          IF ((tof22(1,tof22_i,itdc).LT.2000).AND.
671         +                             (tof22(2,tof22_i,itdc).LT.2000))
672         +    ytofpre(2) = ((tof22(1,tof22_i,itdc)-tof22(2,tof22_i,itdc))/2.
673         +    -y_coor_lin22c(tof22_i,offset))/y_coor_lin22c(tof22_i,slope)
674          endif
675    
676    
677    C-----------------------------S3 --------------------------------
678    
679          IF (tof31_i.GT.none_find) THEN
680          IF ((tof31(1,tof31_i,itdc).LT.2000).AND.
681         +                             (tof31(2,tof31_i,itdc).LT.2000))
682         +   ytofpre(3)  = ((tof31(1,tof31_i,itdc)-tof31(2,tof31_i,itdc))/2.
683         +    -y_coor_lin31c(tof31_i,offset))/y_coor_lin31c(tof31_i,slope)
684          endif
685    
686          IF (tof32_i.GT.none_find) THEN
687          IF ((tof32(1,tof32_i,itdc).LT.2000).AND.
688         +                             (tof32(2,tof32_i,itdc).LT.2000))
689         +   xtofpre(3)  = ((tof32(1,tof32_i,itdc)-tof32(2,tof32_i,itdc))/2.
690         +    -x_coor_lin32c(tof32_i,offset))/x_coor_lin32c(tof32_i,slope)
691          endif
692    
693    
694    C--  restrict TDC measurements to physical paddle dimensions +/- 10 cm
695    
696            if (abs(xtofpre(1)).gt.31.)  xtofpre(1)=100.
697            if (abs(xtofpre(2)).gt.19.)  xtofpre(2)=100.
698            if (abs(xtofpre(3)).gt.19.)  xtofpre(3)=100.
699    
700            if (abs(ytofpre(1)).gt.26.)  ytofpre(1)=100.
701            if (abs(ytofpre(2)).gt.18.)  ytofpre(2)=100.
702            if (abs(ytofpre(3)).gt.18.)  ytofpre(3)=100.
703    
704  C--------------------------------------------------------------------  C--------------------------------------------------------------------
705  C---- if paddle hit: if we have TDC value but no ADC, create ADC value  C---- if paddle hit: if we have TDC value but no ADC, create ADC value
706    C---- use the "pre" position if possible, since this gives better time
707    C---- resolution ... october 2008
708  C--------------------------------------------------------------------  C--------------------------------------------------------------------
709  c     middle y (or x) position of the upper and middle ToF-Paddle  c     middle y (or x) position of the upper and middle ToF-Paddle
710  c     DATA tof11_x/ -17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85/  c     DATA tof11_x/ -17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85/
# Line 576  c     DATA tof32_y/ -5.0,0.0,5.0/ Line 716  c     DATA tof32_y/ -5.0,0.0,5.0/
716    
717  C----------------------------S1 -------------------------------------  C----------------------------S1 -------------------------------------
718    
719        yhelp=yout(1)  c     yhelp=yout(1)
720        IF (tof11_i.GT.none_find.AND.abs(yout(1)).lt.100) THEN        yhelp = ytofpre(1)
721          if (yhelp.eq.100) yhelp=yout(1)
722    
723          IF (tof11_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
724           i = tof11_i           i = tof11_i
725           if ((tdc(ch11a(i),hb11a(i)).lt.4095).AND.           if ((tdc(ch11a(i),hb11a(i)).lt.4095).AND.
726       &       (adc(ch11a(i),hb11a(i)).eq.4095)) then       &       (adc(ch11a(i),hb11a(i)).eq.4095)) then
# Line 599  C----------------------------S1 -------- Line 742  C----------------------------S1 --------
742           endif           endif
743        ENDIF        ENDIF
744    
745        xhelp=xout(2)  c      xhelp=xout(2)
746        IF (tof12_i.GT.none_find.AND.abs(xout(2)).lt.100) THEN        xhelp = xtofpre(1)
747          if (xhelp.eq.100) xhelp=xout(2)
748    
749          IF (tof12_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
750           i = tof12_i           i = tof12_i
751           if ((tdc(ch12a(i),hb12a(i)).lt.4095).AND.           if ((tdc(ch12a(i),hb12a(i)).lt.4095).AND.
752       &       (adc(ch12a(i),hb12a(i)).eq.4095)) then       &       (adc(ch12a(i),hb12a(i)).eq.4095)) then
# Line 626  c            xkorr=adcx12(right,i,1)*exp Line 772  c            xkorr=adcx12(right,i,1)*exp
772    
773  C-----------------------------S2 --------------------------------  C-----------------------------S2 --------------------------------
774    
775        xhelp=xout(3)  c      xhelp=xout(3)
776        IF (tof21_i.GT.none_find.AND.abs(xout(3)).lt.100) THEN        xhelp = xtofpre(2)
777          if (xhelp.eq.100) xhelp=xout(3)
778    
779          IF (tof21_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
780           i = tof21_i           i = tof21_i
781           if ((tdc(ch21a(i),hb21a(i)).lt.4095).AND.           if ((tdc(ch21a(i),hb21a(i)).lt.4095).AND.
782       &       (adc(ch21a(i),hb21a(i)).eq.4095)) then       &       (adc(ch21a(i),hb21a(i)).eq.4095)) then
# Line 652  c            xkorr=adcx21(right,i,1)*exp Line 801  c            xkorr=adcx21(right,i,1)*exp
801        ENDIF        ENDIF
802    
803    
804        yhelp=yout(4)  c      yhelp=yout(4)
805        IF (tof22_i.GT.none_find.AND.abs(yout(4)).lt.100) THEN        yhelp = ytofpre(2)
806          if (yhelp.eq.100) yhelp=yout(4)
807    
808          IF (tof22_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
809           i = tof22_i           i = tof22_i
810           if ((tdc(ch22a(i),hb22a(i)).lt.4095).AND.           if ((tdc(ch22a(i),hb22a(i)).lt.4095).AND.
811       &       (adc(ch22a(i),hb22a(i)).eq.4095)) then       &       (adc(ch22a(i),hb22a(i)).eq.4095)) then
# Line 665  c            xkorr=adcx22(left,i,1)*exp( Line 817  c            xkorr=adcx22(left,i,1)*exp(
817              tof22(left,i,iadc) = xkorr/cos(theta)              tof22(left,i,iadc) = xkorr/cos(theta)
818              adcflag(ch22a(i),hb22a(i)) = 1              adcflag(ch22a(i),hb22a(i)) = 1
819           endif           endif
820           if ((tdc(ch22a(i),hb22b(i)).lt.4095).AND.           if ((tdc(ch22b(i),hb22b(i)).lt.4095).AND.
821       &       (adc(ch22b(i),hb22b(i)).eq.4095)) then       &       (adc(ch22b(i),hb22b(i)).eq.4095)) then
822              phi   = atan(tan(THYOUT(4))/tan(THXOUT(4)))              phi   = atan(tan(THYOUT(4))/tan(THXOUT(4)))
823              theta = atan(tan(THXOUT(4))/cos(phi))              theta = atan(tan(THXOUT(4))/cos(phi))
# Line 679  c            xkorr=adcx22(right,i,1)*exp Line 831  c            xkorr=adcx22(right,i,1)*exp
831    
832  C-----------------------------S3 --------------------------------  C-----------------------------S3 --------------------------------
833    
834        yhelp=yout(5)  c      yhelp=yout(5)
835        IF (tof31_i.GT.none_find.AND.abs(yout(5)).lt.100) THEN        yhelp = ytofpre(3)
836          if (yhelp.eq.100) yhelp=yout(5)
837    
838          IF (tof31_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
839           i = tof31_i           i = tof31_i
840           if ((tdc(ch31a(i),hb31a(i)).lt.4095).AND.           if ((tdc(ch31a(i),hb31a(i)).lt.4095).AND.
841       &       (adc(ch31a(i),hb31a(i)).eq.4095)) then       &       (adc(ch31a(i),hb31a(i)).eq.4095)) then
# Line 705  c            xkorr=adcx31(right,i,1)*exp Line 860  c            xkorr=adcx31(right,i,1)*exp
860        ENDIF        ENDIF
861    
862    
863        xhelp=xout(6)  c      xhelp=xout(6)
864          xhelp = xtofpre(3)
865          if (xhelp.eq.100) xhelp=xout(6)
866    
867        IF (tof32_i.GT.none_find.AND.abs(xout(6)).lt.100) THEN        IF (tof32_i.GT.none_find.AND.abs(xout(6)).lt.100) THEN
868           i = tof32_i           i = tof32_i
869           if ((tdc(ch32a(i),hb32a(i)).lt.4095).AND.           if ((tdc(ch32a(i),hb32a(i)).lt.4095).AND.
# Line 997  C-----------------------------S1 ------- Line 1155  C-----------------------------S1 -------
1155           ytofpos(1)  = ((tof11(1,tof11_i,itdc)-tof11(2,tof11_i,itdc))/2.           ytofpos(1)  = ((tof11(1,tof11_i,itdc)-tof11(2,tof11_i,itdc))/2.
1156       +        -y_coor_lin11(tof11_i,offset))/y_coor_lin11(tof11_i,slope)       +        -y_coor_lin11(tof11_i,offset))/y_coor_lin11(tof11_i,slope)
1157          if (abs(ytofpos(1)).gt.26.)  ytofpos(1)=101.          if (abs(ytofpos(1)).gt.26.)  ytofpos(1)=101.
1158          i=tof11_i
1159        endif        endif
1160        endif        endif
1161    
# Line 1006  C-----------------------------S1 ------- Line 1165  C-----------------------------S1 -------
1165           xtofpos(1)  = ((tof12(1,tof12_i,itdc)-tof12(2,tof12_i,itdc))/2.           xtofpos(1)  = ((tof12(1,tof12_i,itdc)-tof12(2,tof12_i,itdc))/2.
1166       +        -x_coor_lin12(tof12_i,offset))/x_coor_lin12(tof12_i,slope)       +        -x_coor_lin12(tof12_i,offset))/x_coor_lin12(tof12_i,slope)
1167          if (abs(xtofpos(1)).gt.31.)  xtofpos(1)=101.          if (abs(xtofpos(1)).gt.31.)  xtofpos(1)=101.
1168          i=tof12_i
1169        endif        endif
1170        endif        endif
1171    
# Line 1017  C-----------------------------S2 ------- Line 1177  C-----------------------------S2 -------
1177           xtofpos(2) = ((tof21(1,tof21_i,itdc)-tof21(2,tof21_i,itdc))/2.           xtofpos(2) = ((tof21(1,tof21_i,itdc)-tof21(2,tof21_i,itdc))/2.
1178       +        -x_coor_lin21(tof21_i,offset))/x_coor_lin21(tof21_i,slope)       +        -x_coor_lin21(tof21_i,offset))/x_coor_lin21(tof21_i,slope)
1179          if (abs(xtofpos(2)).gt.19.)  xtofpos(2)=101.          if (abs(xtofpos(2)).gt.19.)  xtofpos(2)=101.
1180          i=tof21_i
1181        endif        endif
1182        endif        endif
1183    
# Line 1026  C-----------------------------S2 ------- Line 1187  C-----------------------------S2 -------
1187           ytofpos(2) = ((tof22(1,tof22_i,itdc)-tof22(2,tof22_i,itdc))/2.           ytofpos(2) = ((tof22(1,tof22_i,itdc)-tof22(2,tof22_i,itdc))/2.
1188       +        -y_coor_lin22(tof22_i,offset))/y_coor_lin22(tof22_i,slope)       +        -y_coor_lin22(tof22_i,offset))/y_coor_lin22(tof22_i,slope)
1189          if (abs(ytofpos(2)).gt.18.)  ytofpos(2)=101.          if (abs(ytofpos(2)).gt.18.)  ytofpos(2)=101.
1190          i=tof22_i
1191        endif        endif
1192        endif        endif
1193    
# Line 1037  C-----------------------------S3 ------- Line 1199  C-----------------------------S3 -------
1199           ytofpos(3)  = ((tof31(1,tof31_i,itdc)-tof31(2,tof31_i,itdc))/2.           ytofpos(3)  = ((tof31(1,tof31_i,itdc)-tof31(2,tof31_i,itdc))/2.
1200       +        -y_coor_lin31(tof31_i,offset))/y_coor_lin31(tof31_i,slope)       +        -y_coor_lin31(tof31_i,offset))/y_coor_lin31(tof31_i,slope)
1201          if (abs(ytofpos(3)).gt.18.)  ytofpos(3)=101.          if (abs(ytofpos(3)).gt.18.)  ytofpos(3)=101.
1202          i=tof31_i
1203        endif        endif
1204        endif        endif
1205    
# Line 1046  C-----------------------------S3 ------- Line 1209  C-----------------------------S3 -------
1209           xtofpos(3)  = ((tof32(1,tof32_i,itdc)-tof32(2,tof32_i,itdc))/2.           xtofpos(3)  = ((tof32(1,tof32_i,itdc)-tof32(2,tof32_i,itdc))/2.
1210       +        -x_coor_lin32(tof32_i,offset))/x_coor_lin32(tof32_i,slope)       +        -x_coor_lin32(tof32_i,offset))/x_coor_lin32(tof32_i,slope)
1211          if (abs(xtofpos(3)).gt.19.)  xtofpos(3)=101.          if (abs(xtofpos(3)).gt.19.)  xtofpos(3)=101.
1212          i=tof32_i
1213        endif        endif
1214        endif        endif
1215    
# Line 1060  c      enddo Line 1224  c      enddo
1224    
1225    
1226    
1227  C---------------------------------------------------------------------  C--------------------------------------------------------------------
1228  C--------------------Corrections on ADC-data -------------------------  C-------------------Corrections on ADC-data -------------------------
1229  C-----------------angle and ADC(x) correction -----------------------  C-----------------angle and ADC(x) correction -----------------------
1230    C----------------   moved to the new dEdx routine -------------------
1231    
1232  C-----------------------------S1 -------------------------------------  C--------------------------------------------------------------------
   
       yhelp=yout(1)  
   
       phi   = atan(tan(THYOUT(1))/tan(THXOUT(1)))  
       theta = atan(tan(THXOUT(1))/cos(phi))  
   
       IF (tof11_i.GT.none_find.AND.yhelp.lt.100) THEN  
   
          i = tof11_i  
   
          if (tof11(left,i,iadc).lt.3786) then  
             tof11(left,i,iadc) = tof11(left,i,iadc)*cos(theta)  
             xkorr = atten(left,11,i,yhelp)  
             if (iz.le.1) xkorr=xkorr/hepratio  
             adc_c(ch11a(i),hb11a(i))=tof11(left,i,iadc)/xkorr  
          endif  
   
   
          if (tof11(right,i,iadc).lt.3786) then  
             tof11(right,i,iadc) = tof11(right,i,iadc)*cos(theta)  
             xkorr = atten(right,11,i,yhelp)  
             if (iz.le.1) xkorr=xkorr/hepratio  
             adc_c(ch11b(i),hb11b(i))=tof11(right,i,iadc)/xkorr  
          endif  
       ENDIF  
   
   
       xhelp=xout(2)  
       phi   = atan(tan(THYOUT(2))/tan(THXOUT(2)))  
       theta = atan(tan(THXOUT(2))/cos(phi))  
   
       IF (tof12_i.GT.none_find.AND.xhelp.lt.100) THEN  
          i = tof12_i  
          if (tof12(left,i,iadc).lt.3786) then  
             tof12(left,i,iadc) = tof12(left,i,iadc)*cos(theta)  
             xkorr = atten(left,12,i,xhelp)  
             if (iz.le.1) xkorr=xkorr/hepratio  
             adc_c(ch12a(i),hb12a(i))=tof12(left,i,iadc)/xkorr  
          endif  
   
          if (tof12(right,i,iadc).lt.3786) then  
             tof12(right,i,iadc) = tof12(right,i,iadc)*cos(theta)  
             xkorr = atten(right,12,i,xhelp)  
             if (iz.le.1) xkorr=xkorr/hepratio  
             adc_c(ch12b(i),hb12b(i))=tof12(right,i,iadc)/xkorr  
          endif  
       ENDIF  
   
 C-----------------------------S2 --------------------------------  
   
       xhelp=xout(3)  
       phi   = atan(tan(THYOUT(3))/tan(THXOUT(3)))  
       theta = atan(tan(THXOUT(3))/cos(phi))  
   
       IF (tof21_i.GT.none_find.AND.xhelp.lt.100) THEN  
          i = tof21_i  
          if (tof21(left,i,iadc).lt.3786) then  
             tof21(left,i,iadc) = tof21(left,i,iadc)*cos(theta)  
             xkorr = atten(left,21,i,xhelp)  
             if (iz.le.1) xkorr=xkorr/hepratio  
             adc_c(ch21a(i),hb21a(i))=tof21(left,i,iadc)/xkorr  
          endif  
   
          if (tof21(right,i,iadc).lt.3786) then  
             tof21(right,i,iadc) = tof21(right,i,iadc)*cos(theta)  
             xkorr = atten(right,21,i,xhelp)  
             if (iz.le.1) xkorr=xkorr/hepratio  
             adc_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr  
          endif  
       ENDIF  
   
       yhelp=yout(4)  
       phi   = atan(tan(THYOUT(4))/tan(THXOUT(4)))  
       theta = atan(tan(THXOUT(4))/cos(phi))  
   
       IF (tof22_i.GT.none_find.AND.yhelp.lt.100) THEN  
          i = tof22_i  
          if (tof22(left,i,iadc).lt.3786) then  
             tof22(left,i,iadc) = tof22(left,i,iadc)*cos(theta)  
             xkorr = atten(left,22,i,yhelp)  
             if (iz.le.1) xkorr=xkorr/hepratio  
             adc_c(ch22a(i),hb22a(i))=tof22(left,i,iadc)/xkorr  
          endif  
   
          if (tof22(right,i,iadc).lt.3786) then  
             tof22(right,i,iadc) = tof22(right,i,iadc)*cos(theta)  
             xkorr = atten(right,22,i,yhelp)  
             if (iz.le.1) xkorr=xkorr/hepratio  
             adc_c(ch22b(i),hb22b(i))=tof22(right,i,iadc)/xkorr  
          endif  
       ENDIF  
   
 C-----------------------------S3 --------------------------------  
   
       yhelp=yout(5)  
       phi   = atan(tan(THYOUT(5))/tan(THXOUT(5)))  
       theta = atan(tan(THXOUT(5))/cos(phi))  
   
       IF (tof31_i.GT.none_find.AND.yhelp.lt.100) THEN  
   
          i = tof31_i  
          if (tof31(left,i,iadc).lt.3786) then  
             tof31(left,i,iadc) = tof31(left,i,iadc)*cos(theta)  
             xkorr = atten(left,31,i,yhelp)  
             if (iz.le.1) xkorr=xkorr/hepratio  
             adc_c(ch31a(i),hb31a(i))=tof31(left,i,iadc)/xkorr  
          endif  
   
          if (tof31(right,i,iadc).lt.3786) then  
             tof31(right,i,iadc) = tof31(right,i,iadc)*cos(theta)  
             xkorr = atten(right,31,i,yhelp)  
             if (iz.le.1) xkorr=xkorr/hepratio  
             adc_c(ch31b(i),hb31b(i))=tof31(right,i,iadc)/xkorr  
          endif  
       ENDIF  
   
       xhelp=xout(6)  
       phi   = atan(tan(THYOUT(6))/tan(THXOUT(6)))  
       theta = atan(tan(THXOUT(6))/cos(phi))  
   
       IF (tof32_i.GT.none_find.AND.xhelp.lt.100) THEN  
          i = tof32_i  
          if (tof32(left,i,iadc).lt.3786) then  
             tof32(left,i,iadc) = tof32(left,i,iadc)*cos(theta)  
             xkorr = atten(left,32,i,xhelp)  
             if (iz.le.1) xkorr=xkorr/hepratio  
             adc_c(ch32a(i),hb32a(i))=tof32(left,i,iadc)/xkorr  
          endif  
   
          if (tof32(right,i,iadc).lt.3786) then  
             tof32(right,i,iadc) = tof32(right,i,iadc)*cos(theta)  
             xkorr = atten(right,32,i,xhelp)  
             if (iz.le.1) xkorr=xkorr/hepratio  
             adc_c(ch32b(i),hb32b(i))=tof32(right,i,iadc)/xkorr  
          endif  
       ENDIF  
   
   
 C-----------------------------------------------------------------------  
1233  C----------------------calculate Beta  ------------------------------  C----------------------calculate Beta  ------------------------------
1234  C-----------------------------------------------------------------------  C--------------------------------------------------------------------
1235  C-------------------difference of sums  ---------------------------  C---------------------difference of sums  ---------------------------
1236  C  C
1237  C     DS = (t1+t2) - t3+t4)  C     DS = (t1+t2) - t3+t4)
1238  C     DS = c1 + c2/beta*cos(theta)  C     DS = c1 + c2/beta*cos(theta)
# Line 1217  C     instead of cos(theta) use factor F Line 1243  C     instead of cos(theta) use factor F
1243  C     F =  pathlength/d  C     F =  pathlength/d
1244  C     => beta = c2*F/(DS-c1))  C     => beta = c2*F/(DS-c1))
1245    
1246    C---------------------     S11 - S31  ------------------------
1247    
1248        dist = ZTOF(1) - ZTOF(5)        dist = ZTOF(1) - ZTOF(5)
1249        dl = 0.        dl = 0.
1250        DO I=1,5        DO I=1,5
# Line 1224  C     => beta = c2*F/(DS-c1)) Line 1252  C     => beta = c2*F/(DS-c1))
1252        ENDDO        ENDDO
1253        F = dl/dist        F = dl/dist
1254    
1255  C     S11 - S31        c2 = (2.*0.01*dist)/(3.E08*50.E-12  )
1256    
1257  C      IF (tof11_i.GT.none_find.AND.tof31_i.GT.none_find) THEN  C      IF (tof11_i.GT.none_find.AND.tof31_i.GT.none_find) THEN
1258        IF ((tof11_i.GT.none_find).AND.(tof31_i.GT.none_find).AND.        IF ((tof11_i.GT.none_find).AND.(tof31_i.GT.none_find).AND.
1259       &    (ytofpos(1).NE.101.).AND.(ytofpos(3).NE.101.)) THEN       &    (ytofpos(1).NE.101.).AND.(ytofpos(3).NE.101.)) THEN
# Line 1238  C      IF (tof11_i.GT.none_find.AND.tof3 Line 1267  C      IF (tof11_i.GT.none_find.AND.tof3
1267              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1268              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1269              ihelp=(tof11_i-1)*3+tof31_i              ihelp=(tof11_i-1)*3+tof31_i
1270              c1 = k_S11S31(1,ihelp)              if (iz.le.1) c1 = k_S11S31(1,ihelp)
1271              if (iz.gt.2) c1 = c1 + k1corrA1              if (iz.eq.2) c1 = k_S11S31(2,ihelp)
1272              c2 = k_S11S31(2,ihelp)              if (iz.gt.2) c1 = k_S11S31(3,ihelp)
1273    c        write(*,*)k_S11S31(1,ihelp),k_S11S31(2,ihelp),k_S11S31(3,ihelp)
1274    c        write(*,*)iz,c1,c2
1275              beta_a(1) = c2*F/(ds-c1)              beta_a(1) = c2*F/(ds-c1)
1276  c       write(*,*) 'S11-S31 ',c1,c2,F  c       write(*,*) 'S11-S31 ',c1,c2,F
1277  c       write(*,*) 'S11-S31 ',xhelp1,xhelp2, beta_a(1)  c       write(*,*) 'S11-S31 ',xhelp1,xhelp2, beta_a(1)
# Line 1259  C-------ToF Mask - S11 - S31 Line 1290  C-------ToF Mask - S11 - S31
1290           ENDIF           ENDIF
1291        ENDIF        ENDIF
1292    
1293    C---------------------     S11 - S32  ------------------------
1294    
1295        dist = ZTOF(1) - ZTOF(6)        dist = ZTOF(1) - ZTOF(6)
1296        dl = 0.        dl = 0.
1297        DO I=1,6        DO I=1,6
# Line 1266  C-------ToF Mask - S11 - S31 Line 1299  C-------ToF Mask - S11 - S31
1299        ENDDO        ENDDO
1300        F = dl/dist        F = dl/dist
1301    
1302  C     S11 - S32        c2 = (2.*0.01*dist)/(3.E08*50.E-12  )
1303    
1304  C      IF (tof11_i.GT.none_find.AND.tof32_i.GT.none_find) THEN  C      IF (tof11_i.GT.none_find.AND.tof32_i.GT.none_find) THEN
1305         IF ((tof11_i.GT.none_find).AND.(tof32_i.GT.none_find).AND.         IF ((tof11_i.GT.none_find).AND.(tof32_i.GT.none_find).AND.
1306       &    (ytofpos(1).NE.101.).AND.(xtofpos(3).NE.101.)) THEN       &    (ytofpos(1).NE.101.).AND.(xtofpos(3).NE.101.)) THEN
# Line 1280  C      IF (tof11_i.GT.none_find.AND.tof3 Line 1314  C      IF (tof11_i.GT.none_find.AND.tof3
1314              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1315              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1316              ihelp=(tof11_i-1)*3+tof32_i              ihelp=(tof11_i-1)*3+tof32_i
1317              c1 = k_S11S32(1,ihelp)              if (iz.le.1) c1 = k_S11S32(1,ihelp)
1318              if (iz.gt.2) c1 = c1 + k1corrA1              if (iz.eq.2) c1 = k_S11S32(2,ihelp)
1319              c2 = k_S11S32(2,ihelp)              if (iz.gt.2) c1 = k_S11S32(3,ihelp)
1320              beta_a(2) = c2*F/(ds-c1)              beta_a(2) = c2*F/(ds-c1)
1321  C     write(*,*) 'S11-S32 ',xhelp1,xhelp2, beta_a(2)  C     write(*,*) 'S11-S32 ',xhelp1,xhelp2, beta_a(2)
1322    
# Line 1303  C------- Line 1337  C-------
1337           ENDIF           ENDIF
1338        ENDIF        ENDIF
1339    
1340  C     S12 - S31  C---------------------     S12 - S31  ------------------------
1341    
1342        dist = ZTOF(2) - ZTOF(5)        dist = ZTOF(2) - ZTOF(5)
1343        dl = 0.        dl = 0.
1344        DO I=2,5        DO I=2,5
# Line 1311  C     S12 - S31 Line 1346  C     S12 - S31
1346        ENDDO        ENDDO
1347        F = dl/dist        F = dl/dist
1348    
1349          c2 = (2.*0.01*dist)/(3.E08*50.E-12  )
1350    
1351  C      IF (tof12_i.GT.none_find.AND.tof31_i.GT.none_find) THEN  C      IF (tof12_i.GT.none_find.AND.tof31_i.GT.none_find) THEN
1352         IF ((tof12_i.GT.none_find).AND.(tof31_i.GT.none_find).AND.         IF ((tof12_i.GT.none_find).AND.(tof31_i.GT.none_find).AND.
1353       &    (xtofpos(1).NE.101.).AND.(ytofpos(3).NE.101.)) THEN       &    (xtofpos(1).NE.101.).AND.(ytofpos(3).NE.101.)) THEN
# Line 1324  C      IF (tof12_i.GT.none_find.AND.tof3 Line 1361  C      IF (tof12_i.GT.none_find.AND.tof3
1361              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1362              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1363              ihelp=(tof12_i-1)*3+tof31_i              ihelp=(tof12_i-1)*3+tof31_i
1364              c1 = k_S12S31(1,ihelp)              if (iz.le.1) c1 = k_S12S31(1,ihelp)
1365              if (iz.gt.2) c1 = c1 + k1corrA1              if (iz.eq.2) c1 = k_S12S31(2,ihelp)
1366              c2 = k_S12S31(2,ihelp)              if (iz.gt.2) c1 = k_S12S31(3,ihelp)
1367              beta_a(3) = c2*F/(ds-c1)              beta_a(3) = c2*F/(ds-c1)
1368  C     write(*,*) 'S12-S31 ',xhelp1,xhelp2, beta_a(3)  C     write(*,*) 'S12-S31 ',xhelp1,xhelp2, beta_a(3)
1369    
# Line 1347  C------- Line 1384  C-------
1384           ENDIF           ENDIF
1385        ENDIF        ENDIF
1386    
1387  C     S12 - S32  C---------------------     S12 - S32  ------------------------
1388    
1389        dist = ZTOF(2) - ZTOF(6)        dist = ZTOF(2) - ZTOF(6)
1390        dl = 0.        dl = 0.
# Line 1355  C     S12 - S32 Line 1392  C     S12 - S32
1392           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1393        ENDDO        ENDDO
1394        F = dl/dist        F = dl/dist
1395          
1396          c2 = (2.*0.01*dist)/(3.E08*50.E-12  )
1397    
1398  C      IF (tof12_i.GT.none_find.AND.tof32_i.GT.none_find) THEN  C      IF (tof12_i.GT.none_find.AND.tof32_i.GT.none_find) THEN
1399         IF ((tof12_i.GT.none_find).AND.(tof32_i.GT.none_find).AND.         IF ((tof12_i.GT.none_find).AND.(tof32_i.GT.none_find).AND.
# Line 1369  C      IF (tof12_i.GT.none_find.AND.tof3 Line 1408  C      IF (tof12_i.GT.none_find.AND.tof3
1408              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1409              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1410              ihelp=(tof12_i-1)*3+tof32_i              ihelp=(tof12_i-1)*3+tof32_i
1411              c1 = k_S12S32(1,ihelp)              if (iz.le.1) c1 = k_S12S32(1,ihelp)
1412              if (iz.gt.2) c1 = c1 + k1corrA1              if (iz.eq.2) c1 = k_S12S32(2,ihelp)
1413              c2 = k_S12S32(2,ihelp)              if (iz.gt.2) c1 = k_S12S32(3,ihelp)
1414              beta_a(4) = c2*F/(ds-c1)              beta_a(4) = c2*F/(ds-c1)
1415  C     write(*,*) 'S12-S32 ',xhelp1,xhelp2, beta_a(4)  C     write(*,*) 'S12-S32 ',xhelp1,xhelp2, beta_a(4)
1416    
# Line 1392  C------- Line 1431  C-------
1431           ENDIF           ENDIF
1432        ENDIF        ENDIF
1433    
1434  C     S21 - S31  C---------------------     S21 - S31  ------------------------
1435    
1436        dist = ZTOF(3) - ZTOF(5)        dist = ZTOF(3) - ZTOF(5)
1437        dl = 0.        dl = 0.
# Line 1401  C     S21 - S31 Line 1440  C     S21 - S31
1440        ENDDO        ENDDO
1441        F = dl/dist        F = dl/dist
1442    
1443          c2 = (2.*0.01*dist)/(3.E08*50.E-12  )
1444    
1445  C      IF (tof21_i.GT.none_find.AND.tof31_i.GT.none_find) THEN  C      IF (tof21_i.GT.none_find.AND.tof31_i.GT.none_find) THEN
1446         IF ((tof21_i.GT.none_find).AND.(tof31_i.GT.none_find).AND.         IF ((tof21_i.GT.none_find).AND.(tof31_i.GT.none_find).AND.
1447       &    (xtofpos(2).NE.101.).AND.(ytofpos(3).NE.101.)) THEN       &    (xtofpos(2).NE.101.).AND.(ytofpos(3).NE.101.)) THEN
# Line 1414  C      IF (tof21_i.GT.none_find.AND.tof3 Line 1455  C      IF (tof21_i.GT.none_find.AND.tof3
1455              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1456              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1457              ihelp=(tof21_i-1)*3+tof31_i              ihelp=(tof21_i-1)*3+tof31_i
1458              c1 = k_S21S31(1,ihelp)              if (iz.le.1) c1 = k_S21S31(1,ihelp)
1459              if (iz.gt.2) c1 = c1 + k1corrB1              if (iz.eq.2) c1 = k_S21S31(2,ihelp)
1460              c2 = k_S21S31(2,ihelp)              if (iz.gt.2) c1 = k_S21S31(3,ihelp)
1461              beta_a(5) = c2*F/(ds-c1)              beta_a(5) = c2*F/(ds-c1)
1462    
1463  C-------ToF Mask - S21 - S31  C-------ToF Mask - S21 - S31
# Line 1436  C------- Line 1477  C-------
1477           ENDIF           ENDIF
1478        ENDIF        ENDIF
1479    
1480  C     S21 - S32  C---------------------     S21 - S32  ------------------------
1481    
1482        dist = ZTOF(3) - ZTOF(6)        dist = ZTOF(3) - ZTOF(6)
1483        dl = 0.        dl = 0.
# Line 1445  C     S21 - S32 Line 1486  C     S21 - S32
1486        ENDDO        ENDDO
1487        F = dl/dist        F = dl/dist
1488    
1489          c2 = (2.*0.01*dist)/(3.E08*50.E-12  )
1490    
1491  C      IF (tof21_i.GT.none_find.AND.tof32_i.GT.none_find) THEN  C      IF (tof21_i.GT.none_find.AND.tof32_i.GT.none_find) THEN
1492         IF ((tof21_i.GT.none_find).AND.(tof32_i.GT.none_find).AND.         IF ((tof21_i.GT.none_find).AND.(tof32_i.GT.none_find).AND.
1493       &    (xtofpos(2).NE.101.).AND.(xtofpos(3).NE.101.)) THEN       &    (xtofpos(2).NE.101.).AND.(xtofpos(3).NE.101.)) THEN
# Line 1458  C      IF (tof21_i.GT.none_find.AND.tof3 Line 1501  C      IF (tof21_i.GT.none_find.AND.tof3
1501              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1502              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1503              ihelp=(tof21_i-1)*3+tof32_i              ihelp=(tof21_i-1)*3+tof32_i
1504              c1 = k_S21S32(1,ihelp)              if (iz.le.1) c1 = k_S21S32(1,ihelp)
1505              if (iz.gt.2) c1 = c1 + k1corrB1              if (iz.eq.2) c1 = k_S21S32(2,ihelp)
1506              c2 = k_S21S32(2,ihelp)              if (iz.gt.2) c1 = k_S21S32(3,ihelp)
1507              beta_a(6) = c2*F/(ds-c1)              beta_a(6) = c2*F/(ds-c1)
1508    
1509  C-------ToF Mask - S21 - S32  C-------ToF Mask - S21 - S32
# Line 1480  C------- Line 1523  C-------
1523           ENDIF           ENDIF
1524        ENDIF        ENDIF
1525    
1526  C     S22 - S31  C---------------------     S22 - S31  ------------------------
1527    
1528        dist = ZTOF(4) - ZTOF(5)        dist = ZTOF(4) - ZTOF(5)
1529        dl = 0.        dl = 0.
# Line 1489  C     S22 - S31 Line 1532  C     S22 - S31
1532        ENDDO        ENDDO
1533        F = dl/dist        F = dl/dist
1534    
1535          c2 = (2.*0.01*dist)/(3.E08*50.E-12  )
1536    
1537    C WM workaround
1538          dl = dl - 0.06*F
1539          F = dl/dist
1540    
1541  C      IF (tof22_i.GT.none_find.AND.tof31_i.GT.none_find) THEN  C      IF (tof22_i.GT.none_find.AND.tof31_i.GT.none_find) THEN
1542         IF ((tof22_i.GT.none_find).AND.(tof31_i.GT.none_find).AND.         IF ((tof22_i.GT.none_find).AND.(tof31_i.GT.none_find).AND.
1543       &    (ytofpos(2).NE.101.).AND.(ytofpos(3).NE.101.)) THEN       &    (ytofpos(2).NE.101.).AND.(ytofpos(3).NE.101.)) THEN
# Line 1502  C      IF (tof22_i.GT.none_find.AND.tof3 Line 1551  C      IF (tof22_i.GT.none_find.AND.tof3
1551              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1552              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1553              ihelp=(tof22_i-1)*3+tof31_i              ihelp=(tof22_i-1)*3+tof31_i
1554              c1 = k_S22S31(1,ihelp)              if (iz.le.1) c1 = k_S22S31(1,ihelp)
1555              if (iz.gt.2) c1 = c1 + k1corrB1              if (iz.eq.2) c1 = k_S22S31(2,ihelp)
1556              c2 = k_S22S31(2,ihelp)              if (iz.gt.2) c1 = k_S22S31(3,ihelp)
1557              beta_a(7) = c2*F/(ds-c1)              beta_a(7) = c2*F/(ds-c1)
1558    
1559  C-------ToF Mask - S22 - S31  C-------ToF Mask - S22 - S31
# Line 1524  C------- Line 1573  C-------
1573           ENDIF           ENDIF
1574        ENDIF        ENDIF
1575    
1576  C     S22 - S32  C---------------------     S22 - S32  ------------------------
1577    
1578    
1579        dist = ZTOF(4) - ZTOF(6)        dist = ZTOF(4) - ZTOF(6)
1580        dl = 0.        dl = 0.
# Line 1532  C     S22 - S32 Line 1582  C     S22 - S32
1582           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1583        ENDDO        ENDDO
1584        F = dl/dist        F = dl/dist
1585          
1586          c2 = (2.*0.01*dist)/(3.E08*50.E-12  )
1587    
1588    C WM workaround      
1589          dl = dl - 0.06*F
1590          F = dl/dist
1591    
1592    
1593  C      IF (tof22_i.GT.none_find.AND.tof32_i.GT.none_find) THEN  C      IF (tof22_i.GT.none_find.AND.tof32_i.GT.none_find) THEN
1594         IF ((tof22_i.GT.none_find).AND.(tof32_i.GT.none_find).AND.         IF ((tof22_i.GT.none_find).AND.(tof32_i.GT.none_find).AND.
# Line 1546  C      IF (tof22_i.GT.none_find.AND.tof3 Line 1603  C      IF (tof22_i.GT.none_find.AND.tof3
1603              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1604              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1605              ihelp=(tof22_i-1)*3+tof32_i              ihelp=(tof22_i-1)*3+tof32_i
1606              c1 = k_S22S32(1,ihelp)              if (iz.le.1) c1 = k_S22S32(1,ihelp)
1607              if (iz.gt.2) c1 = c1 + k1corrB1              if (iz.eq.2) c1 = k_S22S32(2,ihelp)
1608              c2 = k_S22S32(2,ihelp)              if (iz.gt.2) c1 = k_S22S32(3,ihelp)
1609              beta_a(8) = c2*F/(ds-c1)              beta_a(8) = c2*F/(ds-c1)
1610    
1611  C-------ToF Mask - S22 - S32  C-------ToF Mask - S22 - S32
# Line 1568  C------- Line 1625  C-------
1625           ENDIF           ENDIF
1626        ENDIF        ENDIF
1627    
1628  C     S11 - S21  C---------------------     S11 - S21  ------------------------
1629    
1630        dist = ZTOF(1) - ZTOF(3)        dist = ZTOF(1) - ZTOF(3)
1631        dl = 0.        dl = 0.
# Line 1577  C     S11 - S21 Line 1634  C     S11 - S21
1634        ENDDO        ENDDO
1635        F = dl/dist        F = dl/dist
1636    
1637          c2 = (2.*0.01*dist)/(3.E08*50.E-12  )
1638    
1639    C WM workaround      
1640          dl = dl - 0.442*F
1641          F = dl/dist
1642    
1643  C      IF (tof11_i.GT.none_find.AND.tof21_i.GT.none_find) THEN  C      IF (tof11_i.GT.none_find.AND.tof21_i.GT.none_find) THEN
1644         IF ((tof11_i.GT.none_find).AND.(tof21_i.GT.none_find).AND.         IF ((tof11_i.GT.none_find).AND.(tof21_i.GT.none_find).AND.
1645       &    (ytofpos(1).NE.101.).AND.(xtofpos(2).NE.101.)) THEN       &    (ytofpos(1).NE.101.).AND.(xtofpos(2).NE.101.)) THEN
# Line 1590  C      IF (tof11_i.GT.none_find.AND.tof2 Line 1653  C      IF (tof11_i.GT.none_find.AND.tof2
1653              xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)              xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1654              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1655              ihelp=(tof11_i-1)*2+tof21_i              ihelp=(tof11_i-1)*2+tof21_i
1656              c1 = k_S11S21(1,ihelp)              if (iz.le.1) c1 = k_S11S21(1,ihelp)
1657              if (iz.gt.2) c1 = c1 + k1corrC1              if (iz.eq.2) c1 = k_S11S21(2,ihelp)
1658              c2 = k_S11S21(2,ihelp)              if (iz.gt.2) c1 = k_S11S21(3,ihelp)
1659              beta_a(9) = c2*F/(ds-c1)              beta_a(9) = c2*F/(ds-c1)
1660    
1661  C-------ToF Mask - S11 - S21  C-------ToF Mask - S11 - S21
# Line 1612  C------- Line 1675  C-------
1675           ENDIF           ENDIF
1676        ENDIF        ENDIF
1677    
1678  C     S11 - S22  C---------------------     S11 - S22  ------------------------
1679    
1680        dist = ZTOF(1) - ZTOF(4)        dist = ZTOF(1) - ZTOF(4)
1681        dl = 0.        dl = 0.
# Line 1621  C     S11 - S22 Line 1684  C     S11 - S22
1684        ENDDO        ENDDO
1685        F = dl/dist        F = dl/dist
1686    
1687          c2 = (2.*0.01*dist)/(3.E08*50.E-12  )
1688    
1689  C      IF (tof11_i.GT.none_find.AND.tof22_i.GT.none_find) THEN  C      IF (tof11_i.GT.none_find.AND.tof22_i.GT.none_find) THEN
1690         IF ((tof11_i.GT.none_find).AND.(tof22_i.GT.none_find).AND.         IF ((tof11_i.GT.none_find).AND.(tof22_i.GT.none_find).AND.
1691       &    (ytofpos(1).NE.101.).AND.(ytofpos(2).NE.101.)) THEN       &    (ytofpos(1).NE.101.).AND.(ytofpos(2).NE.101.)) THEN
# Line 1634  C      IF (tof11_i.GT.none_find.AND.tof2 Line 1699  C      IF (tof11_i.GT.none_find.AND.tof2
1699              xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)              xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1700              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1701              ihelp=(tof11_i-1)*2+tof22_i              ihelp=(tof11_i-1)*2+tof22_i
1702              c1 = k_S11S22(1,ihelp)              if (iz.le.1) c1 = k_S11S22(1,ihelp)
1703              if (iz.gt.2) c1 = c1 + k1corrC1              if (iz.eq.2) c1 = k_S11S22(2,ihelp)
1704              c2 = k_S11S22(2,ihelp)              if (iz.gt.2) c1 = k_S11S22(3,ihelp)
1705              beta_a(10) = c2*F/(ds-c1)              beta_a(10) = c2*F/(ds-c1)
1706    
1707  C-------ToF Mask - S11 - S22  C-------ToF Mask - S11 - S22
# Line 1656  C------- Line 1721  C-------
1721           ENDIF           ENDIF
1722        ENDIF        ENDIF
1723    
1724  C     S12 - S21  C---------------------     S12 - S21  ------------------------
1725    
1726        dist = ZTOF(2) - ZTOF(3)        dist = ZTOF(2) - ZTOF(3)
1727        dl = 0.        dl = 0.
# Line 1665  C     S12 - S21 Line 1730  C     S12 - S21
1730        ENDDO        ENDDO
1731        F = dl/dist        F = dl/dist
1732    
1733          c2 = (2.*0.01*dist)/(3.E08*50.E-12  )
1734    
1735    C  WM workaround
1736          dl = dl - 0.442*F
1737          F = dl/dist
1738    
1739  C      IF (tof12_i.GT.none_find.AND.tof21_i.GT.none_find) THEN  C      IF (tof12_i.GT.none_find.AND.tof21_i.GT.none_find) THEN
1740         IF ((tof12_i.GT.none_find).AND.(tof21_i.GT.none_find).AND.         IF ((tof12_i.GT.none_find).AND.(tof21_i.GT.none_find).AND.
1741       &    (xtofpos(1).NE.101.).AND.(xtofpos(2).NE.101.)) THEN       &    (xtofpos(1).NE.101.).AND.(xtofpos(2).NE.101.)) THEN
# Line 1678  C      IF (tof12_i.GT.none_find.AND.tof2 Line 1749  C      IF (tof12_i.GT.none_find.AND.tof2
1749              xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)              xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1750              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1751              ihelp=(tof12_i-1)*2+tof21_i              ihelp=(tof12_i-1)*2+tof21_i
1752              c1 = k_S12S21(1,ihelp)              if (iz.le.1) c1 = k_S12S21(1,ihelp)
1753              if (iz.gt.2) c1 = c1 + k1corrC1              if (iz.eq.2) c1 = k_S12S21(2,ihelp)
1754              c2 = k_S12S21(2,ihelp)              if (iz.gt.2) c1 = k_S12S21(3,ihelp)
1755              beta_a(11) = c2*F/(ds-c1)              beta_a(11) = c2*F/(ds-c1)
1756    
1757  C-------ToF Mask - S12 - S21  C-------ToF Mask - S12 - S21
# Line 1700  C------- Line 1771  C-------
1771           ENDIF           ENDIF
1772        ENDIF        ENDIF
1773    
1774  C     S12 - S22  C---------------------     S12 - S22  ------------------------
1775    
1776        dist = ZTOF(2) - ZTOF(4)        dist = ZTOF(2) - ZTOF(4)
1777        dl = 0.        dl = 0.
# Line 1709  C     S12 - S22 Line 1780  C     S12 - S22
1780        ENDDO        ENDDO
1781        F = dl/dist        F = dl/dist
1782    
1783          c2 = (2.*0.01*dist)/(3.E08*50.E-12  )
1784    
1785  C      IF (tof12_i.GT.none_find.AND.tof22_i.GT.none_find) THEN  C      IF (tof12_i.GT.none_find.AND.tof22_i.GT.none_find) THEN
1786         IF ((tof12_i.GT.none_find).AND.(tof22_i.GT.none_find).AND.         IF ((tof12_i.GT.none_find).AND.(tof22_i.GT.none_find).AND.
1787       &    (xtofpos(1).NE.101.).AND.(ytofpos(2).NE.101.)) THEN       &    (xtofpos(1).NE.101.).AND.(ytofpos(2).NE.101.)) THEN
# Line 1721  C      IF (tof12_i.GT.none_find.AND.tof2 Line 1794  C      IF (tof12_i.GT.none_find.AND.tof2
1794              xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)              xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1795              xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)              xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1796              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1797              ihelp=(tof12_i-1)*2+tof22_i              ihelp=(tof12_i-1)*2+tof22_i          
1798              c1 = k_S12S22(1,ihelp)              if (iz.le.1) c1 = k_S12S22(1,ihelp)
1799              if (iz.gt.2) c1 = c1 + k1corrC1              if (iz.eq.2) c1 = k_S12S22(2,ihelp)
1800              c2 = k_S12S22(2,ihelp)              if (iz.gt.2) c1 = k_S12S22(3,ihelp)
1801              beta_a(12) = c2*F/(ds-c1)              beta_a(12) = c2*F/(ds-c1)
1802    
1803  C-------ToF Mask - S12 - S22  C-------ToF Mask - S12 - S22
# Line 1765  C Line 1838  C
1838  C      if (icount.gt.0) beta_mean=sxw/sw  C      if (icount.gt.0) beta_mean=sxw/sw
1839  C      beta_a(13) = beta_mean  C      beta_a(13) = beta_mean
1840  C  C
1841    
1842  C-------  New mean beta  calculation  C-------  New mean beta  calculation
1843    
1844         do i=1,12         do i=1,12
1845           btemp(i) =  beta_a(i)           btemp(i) =  beta_a(i)
1846         enddo         enddo
1847    
1848         beta_a(13)=newbeta(btemp,hitvec,10.,10.,20.)         beta_a(13)=newbeta(2,btemp,hitvec,10.,10.,20.)
1849    
1850  C-------  C-------
1851    
# Line 1802  c      write(*,*) ytofpos Line 1876  c      write(*,*) ytofpos
1876  c      write(*,*) xtr_tof  c      write(*,*) xtr_tof
1877  c      write(*,*) ytr_tof  c      write(*,*) ytr_tof
1878    
1879    c       write(*,*) '---------  end toftrk ----------'
1880    
1881        RETURN        RETURN
1882        END        END
# Line 1812  c      write(*,*) ytr_tof Line 1886  c      write(*,*) ytr_tof
1886    
1887  C------------------------------------------------------------------  C------------------------------------------------------------------
1888    
1889    

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.23