/[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.11 by mocchiut, Mon Apr 30 15:46:31 2007 UTC revision 1.16 by pam-de, Mon Mar 31 19:24:22 2008 UTC
# Line 7  C     Changed to use DOTRACK2 Line 7  C     Changed to use DOTRACK2
7  C     Beta calculation: now the flightpath (instead of cos(theta)) is used  C     Beta calculation: now the flightpath (instead of cos(theta)) is used
8  C     Beta calculation: all 4 TDV measurements must be < 4095 (in the old  C     Beta calculation: all 4 TDV measurements must be < 4095 (in the old
9  C     routine it was (t1+t2)<8000  C     routine it was (t1+t2)<8000
10  C      C
11  C     08-12-06 WM:  C     08-12-06 WM:
12  C     adc_c-bug :  The raw ADC value was multiplied with cos(theta)  C     adc_c-bug :  The raw ADC value was multiplied with cos(theta)
13  C     and AFTER that there was an if statement "if tof32(right,i,iadc) < 4095"  C     and AFTER that there was an if statement "if tof32(right,i,iadc) < 4095"
14  C      C
15  C  jan-07 GF: ADC/TDCflags(4,12) inserted to flag artificial ADC/TDC  C  jan-07 GF: ADC/TDCflags(4,12) inserted to flag artificial ADC/TDC
16  C             values  C             values
17  C  jan-07 WM: artificial ADC values created using attenuation calibration  C  jan-07 WM: artificial ADC values created using attenuation calibration
18  C  jan-07 WM: artificial TDC values created using xy_coor calibration  C  jan-07 WM: artificial TDC values created using xy_coor calibration
# Line 20  C  jan-07 WM: modified xtofpos flag "101 Line 20  C  jan-07 WM: modified xtofpos flag "101
20  C             dimension of the paddle +/- 10 cm  C             dimension of the paddle +/- 10 cm
21  C  jan-07 WM: if xtofpos=101 then this paddle is not used for beta  C  jan-07 WM: if xtofpos=101 then this paddle is not used for beta
22  C             calculation  C             calculation
23  C  jan-07 WM: in the xtofpos calculation a check for TDC.ne.4095 was  C  jan-07 WM: in the xtofpos calculation a check for TDC.ne.4095 was
24  C             inserted. In the old code one would still calculate a  C             inserted. In the old code one would still calculate a
25  C             xtofpos-value even if the TDC information was missing  C             xtofpos-value even if the TDC information was missing
26  C  jan-07 WM: flag for PMTs #10 and #35 added, TDC=819 due to bit-shift  C  jan-07 WM: flag for PMTs #10 and #35 added, TDC=819 due to bit-shift
27  C  jan-05 WM: bug fixed: calculation of zenith angles using DOTRACK2  C  jan-05 WM: bug fixed: calculation of zenith angles using DOTRACK2
# Line 30  C  jan-07 WM: bug fixed: in some cases t Line 30  C  jan-07 WM: bug fixed: in some cases t
30  C             leftover "xhelp" value  C             leftover "xhelp" value
31  C  apr-07 WM: attenuation fit curve is now a double exponential fit  C  apr-07 WM: attenuation fit curve is now a double exponential fit
32  C             conversion from raw ADC to pC using calibration function  C             conversion from raw ADC to pC using calibration function
33  C             new variables xtr_tof(6) and ytr_tof(6) give track position  C             new variables xtr_tof(6) and ytr_tof(6) give track position
34  C             at ToF layers  C             at ToF layers
35    C  aug-07 WM: artificial ADC creation revised: Now an ADC value is created
36    C             only if there is a TDC value (before ADC was created in ANY
37    C             case)
38    C  jan-08 WM: Major Update: Time Walk correction introduced
39    C             Additionally we use the information from the "check_charge"
40    C             function to fill artificial ADC values and make small corrections
41    C             to the k1-parameter (for Z>2)
42    C  feb-08 WM: Calculation of beta(13) changed: First a mean beta is calculated,
43    C             then in a second step we check the residuals of the single
44    C             measurements, reject if > 10 sigma, calculate chi2 and "quality"
45    C             beta is taken as good if chi2<20 and quality>10
46    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  C
51  C****************************************************************************  C****************************************************************************
52        IMPLICIT NONE        IMPLICIT NONE
53  C      C
54        include  'input_tof.txt'        include  'input_tof.txt'
55        include  'output_tof.txt'        include  'output_tof.txt'
56        include  'tofcomm.txt'        include  'tofcomm.txt'
57  C      C
58          
59  c     =======================================  c     =======================================
60  c     variables for tracking routine  c     variables for tracking routine
61  c     =======================================  c     =======================================
# Line 65  c      REAL dx,dy,dr Line 80  c      REAL dx,dy,dr
80        REAL ds        REAL ds
81        REAL t1,t2,t3,t4        REAL t1,t2,t3,t4
82        REAL yhelp,xhelp,xhelp1,xhelp2        REAL yhelp,xhelp,xhelp1,xhelp2
83        REAL c1,c2,sw,sxw,w_i        REAL c1,c2
84        REAL dist,dl,F  C     REAL sw,sxw,w_i
85        INTEGER icount,ievent        REAL dist,dl,F
86        REAL xhelp_a,xhelp_t        INTEGER ievent
87    C      INTEGER icount
88        REAL beta_mean  C      REAL beta_mean
89          REAL btemp(12)
90        REAL hepratio        REAL hepratio
         
       INTEGER j  
91    
92        real atten,pc_adc        INTEGER j,hitvec(6)
93    
94          real atten,pc_adc,check_charge,newbeta
95    
96    
97        REAL theta,phi        REAL theta,phi
98  C--   DATA ZTOF/53.74,53.04,23.94,23.44,-23.49,-24.34/ !Sergio 9.05.2006  C--   DATA ZTOF/53.74,53.04,23.94,23.44,-23.49,-24.34/ !Sergio 9.05.2006
99        REAL tofarm12        REAL tofarm12
100        PARAMETER (tofarm12 = 29.70) ! from 53.39 to 23.69        PARAMETER (tofarm12 = 29.70) ! from 53.39 to 23.69
101        REAL tofarm23                REAL tofarm23
102        PARAMETER (tofarm23 = 47.61) ! from 23.69 to -23.92        PARAMETER (tofarm23 = 47.61) ! from 23.69 to -23.92
103        REAL tofarm13        REAL tofarm13
104        PARAMETER (tofarm13 = 77.31) ! from 53.39 to -23.92        PARAMETER (tofarm13 = 77.31) ! from 53.39 to -23.92
105    
106          
107        INTEGER ihelp        INTEGER ihelp
108        REAL xkorr,xpos        REAL xkorr,xpos
109    
110          INTEGER IZ
111          REAL k1corrA1,k1corrB1,k1corrC1
112    
113        REAL yl,yh,xl,xh        REAL yl,yh,xl,xh
114  C      C
115        REAL hmemor(9000000)        REAL hmemor(9000000)
116        INTEGER Iquest(100)        INTEGER Iquest(100)
117  C      C
118        DATA ievent / 0 /        DATA ievent / 0 /
119    
120          INTEGER ifst
121          DATA ifst /0/
122    
123        COMMON / pawcd / hmemor        COMMON / pawcd / hmemor
124        save / pawcd /        save / pawcd /
125  C      C
126        Common / QUESTd / Iquest        Common / QUESTd / Iquest
127        save / questd /        save / questd /
128  C      C
129  C     Begin !  C     Begin !
130  C      C
131        TOFTRK = 0        TOFTRK = 0
132    
133  *******************************************************************  *******************************************************************
134    
135        ievent = ievent +1         if (ifst.eq.0) then
136           ifst=1
137    
138  C  ratio helium to proton ca. 4  C  ratio helium to proton ca. 4
139        hepratio = 4.        hepratio = 4.
# Line 126  C  ratio helium to proton ca. 4 Line 149  C  ratio helium to proton ca. 4
149        itdc = 1        itdc = 1
150        iadc = 2        iadc = 2
151    
152    
153          k1corrA1 = 0.
154          k1corrB1 = -5.0
155          k1corrC1=  8.0
156    
157          ENDIF   ! ifst
158    
159    *******************************************************************
160    
161          ievent = ievent +1
162    
163        do i=1,13        do i=1,13
164           beta_a(i) = 100.           beta_a(i) = 100.
165        enddo        enddo
# Line 166  C  ratio helium to proton ca. 4 Line 200  C  ratio helium to proton ca. 4
200        ytr_tof(j) = 100.        ytr_tof(j) = 100.
201        enddo        enddo
202    
203    
204  C----------------------------------------------------------------------  C----------------------------------------------------------------------
205  C-------------------------get ToF data --------------------------------  C-------------------------get ToF data --------------------------------
206  C     we cannot use the tofxx(x,x,x)  data  from tofl2com since it is  C     we cannot use the tofxx(x,x,x)  data  from tofl2com since it is
207  C     manipulated (Time-walk, artificila ADc and TDC values using ToF  C     manipulated (Time-walk, artificila ADc and TDC values using ToF
208  C     standalone information  C     standalone information
209  C----------------------------------------------------------------------  C----------------------------------------------------------------------
210    
# Line 302  c         print *,' TOF - WARNING F77: t Line 337  c         print *,' TOF - WARNING F77: t
337  C---  Fill xtr_tof  and ytr_tof: positions from tracker at ToF layers  C---  Fill xtr_tof  and ytr_tof: positions from tracker at ToF layers
338        do j=1,6        do j=1,6
339        xtr_tof(j) = XOUT(j)        xtr_tof(j) = XOUT(j)
340        ytr_tof(j) = YOUT(j)                ytr_tof(j) = YOUT(j)
341        enddo        enddo
342    
343    
# Line 368  C---- S116A TDC=819 Line 403  C---- S116A TDC=819
403               tof11(1,6,1) = 4095               tof11(1,6,1) = 4095
404               tdcflagtof(ch11a(6),hb11a(6))=2               tdcflagtof(ch11a(6),hb11a(6))=2
405         endif         endif
406      
407  C---- S222B TDC=819  C---- S222B TDC=819
408         if (tof22(2,2,1).EQ.819) then         if (tof22(2,2,1).EQ.819) then
409               tof22(2,2,1) = 4095               tof22(2,2,1) = 4095
410               tdcflagtof(ch22b(2),hb22b(2))=2               tdcflagtof(ch22b(2),hb22b(2))=2
411         endif         endif
412    
413  C-------------------------------------------------------------  C-------------------------------------------------------------
414  C-------check which paddle penetrated the track  -----------  C-------check which paddle penetrated the track  -----------
415  C-------------------------------------------------------------  C-------------------------------------------------------------
# Line 385  c     DATA tof21_y/  3.75,-3.75/  ! padd Line 420  c     DATA tof21_y/  3.75,-3.75/  ! padd
420  c     DATA tof22_x/ -4.5,4.5/  c     DATA tof22_x/ -4.5,4.5/
421  c     DATA tof31_x/ -6.0,0.,6.0/  c     DATA tof31_x/ -6.0,0.,6.0/
422  c     DATA tof32_y/ -5.0,0.0,5.0/  c     DATA tof32_y/ -5.0,0.0,5.0/
423  c      c
424  c     S11 8 paddles  33.0 x 5.1 cm  c     S11 8 paddles  33.0 x 5.1 cm
425  c     S12 6 paddles  40.8 x 5.5 cm  c     S12 6 paddles  40.8 x 5.5 cm
426  c     S21 2 paddles  18.0 x 7.5 cm  c     S21 2 paddles  18.0 x 7.5 cm
# Line 416  C--------------S11 --------------------- Line 451  C--------------S11 ---------------------
451  C--------------S12 --------------------------------------  C--------------S12 --------------------------------------
452    
453        tof12_i = none_find        tof12_i = none_find
454          
455        xl = -40.8/2.        xl = -40.8/2.
456        xh =  40.8/2.        xh =  40.8/2.
457    
# Line 433  C--------------S12 --------------------- Line 468  C--------------S12 ---------------------
468  C--------------S21 --------------------------------------  C--------------S21 --------------------------------------
469    
470        tof21_i = none_find        tof21_i = none_find
471          
472        xl = -18./2.        xl = -18./2.
473        xh =  18./2.        xh =  18./2.
474    
# Line 450  C--------------S21 --------------------- Line 485  C--------------S21 ---------------------
485  C--------------S22 --------------------------------------  C--------------S22 --------------------------------------
486    
487        tof22_i = none_find        tof22_i = none_find
488          
489        yl = -15./2.        yl = -15./2.
490        yh =  15./2.        yh =  15./2.
491    
# Line 467  C--------------S22 --------------------- Line 502  C--------------S22 ---------------------
502  C--------------S31 --------------------------------------  C--------------S31 --------------------------------------
503    
504        tof31_i = none_find        tof31_i = none_find
505          
506        yl = -15.0/2.        yl = -15.0/2.
507        yh =  15.0/2.        yh =  15.0/2.
508    
# Line 484  C--------------S31 --------------------- Line 519  C--------------S31 ---------------------
519  C--------------S32 --------------------------------------  C--------------S32 --------------------------------------
520    
521        tof32_i = none_find        tof32_i = none_find
522          
523        xl = -18.0/2.        xl = -18.0/2.
524        xh =  18.0/2.        xh =  18.0/2.
525    
# Line 501  C--------------S32 --------------------- Line 536  C--------------S32 ---------------------
536    
537  C     write(*,*) tof11_i,tof12_i,tof21_i,tof22_i,tof31_i,tof32_i  C     write(*,*) tof11_i,tof12_i,tof21_i,tof22_i,tof31_i,tof32_i
538    
539  C-----------------------------------------------------------------------         hitvec(1)=tof11_i
540  C--------------------Insert Artifical TDC Value  ---------------------         hitvec(2)=tof12_i
541  C     For each Paddle perform check:         hitvec(3)=tof21_i
542  C     if left paddle=4095  and right paddle OK => create TDC value left         hitvec(4)=tof22_i
543  C     if right paddle=4095  and left paddle OK => create TDC value right         hitvec(5)=tof31_i
544  C-----------------------------------------------------------------------         hitvec(6)=tof32_i
   
 C-----------------------S11 -----------------------------------------  
   
       IF (tof11_i.GT.none_find) THEN  
          xpos = yout(1)  
          i = tof11_i  
          if ((tof11(1,tof11_i,itdc).EQ.4095).AND.  
      &        (tof11(2,tof11_i,itdc).LT.4095)) THEN    
   
 c       write(*,*)'11lb4 ',i,tof11(1,tof11_i,itdc),tof11(2,tof11_i,itdc)  
   
             tof11(1,tof11_i,itdc) = tof11(2,tof11_i,itdc)  
      &           + 2*(y_coor_lin11(tof11_i,offset)  
      &           + xpos*y_coor_lin11(tof11_i,slope))  
   
 c       write(*,*)'11laf ',i,tof11(1,tof11_i,itdc),tof11(2,tof11_i,itdc)  
   
             tdcflag(ch11a(i),hb11a(i)) = 1  
     
         ENDIF  
          if ((tof11(2,tof11_i,itdc).EQ.4095).AND.  
      &        (tof11(1,tof11_i,itdc).LT.4095)) THEN    
   
 c       write(*,*)'11rb4 ',i,tof11(1,tof11_i,itdc),tof11(2,tof11_i,itdc)  
   
             tof11(2,tof11_i,itdc) = tof11(1,tof11_i,itdc)  
      &           - 2*(y_coor_lin11(tof11_i,offset)  
      &           + xpos*y_coor_lin11(tof11_i,slope))  
 c       write(*,*)'11raf ',i,tof11(1,tof11_i,itdc),tof11(2,tof11_i,itdc)  
   
             tdcflag(ch11b(i),hb11b(i)) = 1  
          ENDIF      
       ENDIF  
   
 C-----------------------S12 -----------------------------------------  
   
       IF (tof12_i.GT.none_find) THEN  
          xpos = xout(2)  
          i = tof12_i  
          if ((tof12(1,tof12_i,itdc).EQ.4095).AND.  
      &        (tof12(2,tof12_i,itdc).LT.4095)) THEN  
             tof12(1,tof12_i,itdc) = tof12(2,tof12_i,itdc)  
      &           + 2*(x_coor_lin12(tof12_i,offset)  
      &           + xpos*x_coor_lin12(tof12_i,slope))  
             tdcflag(ch12a(i),hb12a(i)) = 1  
          ENDIF  
          if ((tof12(2,tof12_i,itdc).EQ.4095).AND.  
      &        (tof12(1,tof12_i,itdc).LT.4095)) THEN  
             tof12(2,tof12_i,itdc) = tof12(1,tof12_i,itdc)  
      &           - 2*(x_coor_lin12(tof12_i,offset)  
      &           + xpos*x_coor_lin12(tof12_i,slope))  
             tdcflag(ch12b(i),hb12b(i)) = 1  
          ENDIF  
       ENDIF  
         
 C-----------------------S21 -----------------------------------------  
   
       IF (tof21_i.GT.none_find) THEN  
          xpos = xout(3)  
          i = tof21_i  
          if ((tof21(1,tof21_i,itdc).EQ.4095).AND.  
      &        (tof21(2,tof21_i,itdc).LT.4095)) THEN  
             tof21(1,tof21_i,itdc) = tof21(2,tof21_i,itdc)  
      &           + 2*(x_coor_lin21(tof21_i,offset)  
      &           + xpos*x_coor_lin21(tof21_i,slope))  
             tdcflag(ch21a(i),hb21a(i)) = 1  
          ENDIF  
          if ((tof21(2,tof21_i,itdc).EQ.4095).AND.  
      &        (tof21(1,tof21_i,itdc).LT.4095)) THEN  
             tof21(2,tof21_i,itdc) = tof21(1,tof21_i,itdc)  
      &           - 2*(x_coor_lin21(tof21_i,offset)  
      &           + xpos*x_coor_lin21(tof21_i,slope))  
             tdcflag(ch21b(i),hb21b(i)) = 1  
          ENDIF  
       ENDIF  
   
 C-----------------------S22 -----------------------------------------  
545    
546        IF (tof22_i.GT.none_find) THEN  c       write(*,*) 'toftrk ',
547           xpos = yout(4)  c     &  tof11_i,tof12_i,tof21_i,tof22_i,tof31_i,tof32_i
          i = tof22_i  
          if ((tof22(1,tof22_i,itdc).EQ.4095).AND.  
      &        (tof22(2,tof22_i,itdc).LT.4095)) THEN  
             tof22(1,tof22_i,itdc) = tof22(2,tof22_i,itdc)  
      &           + 2*(y_coor_lin22(tof22_i,offset)  
      &           + xpos*y_coor_lin22(tof22_i,slope))  
             tdcflag(ch22a(i),hb22a(i)) = 1  
          ENDIF  
          if ((tof22(2,tof22_i,itdc).EQ.4095).AND.  
      &        (tof22(1,tof22_i,itdc).LT.4095)) THEN  
             tof22(2,tof22_i,itdc) = tof22(1,tof22_i,itdc)  
      &           - 2*(y_coor_lin22(tof22_i,offset)  
      &           + xpos*y_coor_lin22(tof22_i,slope))  
             tdcflag(ch22b(i),hb22b(i)) = 1  
          ENDIF  
       ENDIF  
548    
549  C-----------------------S31 -----------------------------------------  C----------------------------------------------------------------------
550          C--- check charge:
551        IF (tof31_i.GT.none_find) THEN  C--- if Z=2 we should use the attenuation curve for helium to
552           xpos = yout(5)  C--- fill the artificail ADC values and NOT divide by "hepratio"
553           i = tof31_i  C--- if Z>2 we should do a correction to
554           if ((tof31(1,tof31_i,itdc).EQ.4095).AND.  C--- the k1 constants in the beta calculation
555       &        (tof31(2,tof31_i,itdc).LT.4095)) THEN  C----------------------------------------------------------------------
             tof31(1,tof31_i,itdc) = tof31(2,tof31_i,itdc)  
      &           + 2*(y_coor_lin31(tof31_i,offset)  
      &           + xpos*y_coor_lin31(tof31_i,slope))  
             tdcflag(ch31a(i),hb31a(i)) = 1  
          ENDIF  
          if ((tof31(2,tof31_i,itdc).EQ.4095).AND.  
      &        (tof31(1,tof31_i,itdc).LT.4095)) THEN  
             tof31(2,tof31_i,itdc) = tof31(1,tof31_i,itdc)  
      &           - 2*(y_coor_lin31(tof31_i,offset)  
      &           + xpos*y_coor_lin31(tof31_i,slope))  
             tdcflag(ch31b(i),hb31b(i)) = 1  
          ENDIF  
       ENDIF  
556    
557  C-----------------------S32 -----------------------------------------         theta=0.  
558           dist = ZTOF(1) - ZTOF(5)
559           dl = 0.
560           DO I=1,5
561             dl = dl + TLOUT(i)
562           ENDDO
563           F = dl/dist
564           theta = acos(1/F)
565    
566        IF (tof32_i.GT.none_find) THEN         iz = int(check_charge(theta,hitvec))
567           xpos = xout(6)  c       write(*,*) 'in toftrk',iz
          i = tof32_i  
          if ((tof32(1,tof32_i,itdc).EQ.4095).AND.  
      &        (tof32(2,tof32_i,itdc).LT.4095)) THEN  
             tof32(1,tof32_i,itdc) = tof32(2,tof32_i,itdc)  
      &           + 2*(x_coor_lin32(tof32_i,offset)  
      &           + xpos*x_coor_lin32(tof32_i,slope))  
             tdcflag(ch32a(i),hb32a(i)) = 1  
          ENDIF  
          if ((tof32(2,tof32_i,itdc).EQ.4095).AND.  
      &        (tof32(1,tof32_i,itdc).LT.4095)) THEN  
             tof32(2,tof32_i,itdc) = tof32(1,tof32_i,itdc)  
      &           - 2*(x_coor_lin32(tof32_i,offset)  
      &           + xpos*x_coor_lin32(tof32_i,slope))  
             tdcflag(ch32b(i),hb32b(i)) = 1  
          ENDIF  
       ENDIF  
568    
569  C--------------------------------------------------------------------  C--------------------------------------------------------------------
570  C---- if TDCleft.and.TDCright and NO ADC insert artificial ADC  C---- if paddle hit: if we have TDC value but no ADC, create ADC value
 C---- values  
571  C--------------------------------------------------------------------  C--------------------------------------------------------------------
572  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
573  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 663  C----------------------------S1 -------- Line 582  C----------------------------S1 --------
582        yhelp=yout(1)        yhelp=yout(1)
583        IF (tof11_i.GT.none_find.AND.abs(yout(1)).lt.100) THEN        IF (tof11_i.GT.none_find.AND.abs(yout(1)).lt.100) THEN
584           i = tof11_i           i = tof11_i
585  c         if (tof11(left,i,iadc).eq.4095) then           if ((tdc(ch11a(i),hb11a(i)).lt.4095).AND.
586           if (adc(ch11a(i),hb11a(i)).eq.4095) then       &       (adc(ch11a(i),hb11a(i)).eq.4095)) then
587              phi   = atan(tan(THYOUT(1))/tan(THXOUT(1)))              phi   = atan(tan(THYOUT(1))/tan(THXOUT(1)))
588              theta = atan(tan(THXOUT(1))/cos(phi))              theta = atan(tan(THXOUT(1))/cos(phi))
 c            xkorr=adcx11(left,i,1)*exp(-yhelp/adcx11(left,i,2))  
589              xkorr = atten(left,11,i,yhelp)              xkorr = atten(left,11,i,yhelp)
590              xkorr=xkorr/hepratio                          if (iz.le.1) xkorr=xkorr/hepratio
591              tof11(left,i,iadc)=xkorr/cos(theta)              tof11(left,i,iadc)=xkorr/cos(theta)
592              adcflag(ch11a(i),hb11a(i)) = 1              adcflag(ch11a(i),hb11a(i)) = 1
593           endif           endif
594  c         if (tof11(right,i,iadc).eq.4095) then           if ((tdc(ch11b(i),hb11b(i)).lt.4095).AND.
595           if (adc(ch11b(i),hb11b(i)).eq.4095) then       &       (adc(ch11b(i),hb11b(i)).eq.4095)) then
596              phi   = atan(tan(THYOUT(1))/tan(THXOUT(1)))              phi   = atan(tan(THYOUT(1))/tan(THXOUT(1)))
597              theta = atan(tan(THXOUT(1))/cos(phi))              theta = atan(tan(THXOUT(1))/cos(phi))
 c            xkorr=adcx11(right,i,1)*exp(yhelp/adcx11(right,i,2))  
598              xkorr = atten(right,11,i,yhelp)              xkorr = atten(right,11,i,yhelp)
599              xkorr=xkorr/hepratio                          if (iz.le.1) xkorr=xkorr/hepratio
600              tof11(right,i,iadc)=xkorr/cos(theta)              tof11(right,i,iadc)=xkorr/cos(theta)
601              adcflag(ch11b(i),hb11b(i)) = 1              adcflag(ch11b(i),hb11b(i)) = 1
602           endif           endif
# Line 688  c            xkorr=adcx11(right,i,1)*exp Line 605  c            xkorr=adcx11(right,i,1)*exp
605        xhelp=xout(2)        xhelp=xout(2)
606        IF (tof12_i.GT.none_find.AND.abs(xout(2)).lt.100) THEN        IF (tof12_i.GT.none_find.AND.abs(xout(2)).lt.100) THEN
607           i = tof12_i           i = tof12_i
608  c         if (tof12(left,i,iadc).eq.4095) then           if ((tdc(ch12a(i),hb12a(i)).lt.4095).AND.
609           if (adc(ch12a(i),hb12a(i)).eq.4095) then       &       (adc(ch12a(i),hb12a(i)).eq.4095)) then
610              phi   = atan(tan(THYOUT(2))/tan(THXOUT(2)))              phi   = atan(tan(THYOUT(2))/tan(THXOUT(2)))
611              theta = atan(tan(THXOUT(2))/cos(phi))              theta = atan(tan(THXOUT(2))/cos(phi))
612  c            xkorr=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2))  c            xkorr=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2))
613              xkorr = atten(left,12,i,xhelp)              xkorr = atten(left,12,i,xhelp)
614              xkorr=xkorr/hepratio                          if (iz.le.1) xkorr=xkorr/hepratio
615              tof12(left,i,iadc) = xkorr/cos(theta)              tof12(left,i,iadc) = xkorr/cos(theta)
616              adcflag(ch12a(i),hb12a(i)) = 1              adcflag(ch12a(i),hb12a(i)) = 1
617           endif           endif
618  c         if (tof12(right,i,iadc).eq.4095) then           if ((tdc(ch12b(i),hb12b(i)).lt.4095).AND.
619           if (adc(ch12b(i),hb12b(i)).eq.4095) then       &       (adc(ch12b(i),hb12b(i)).eq.4095)) then
620              phi   = atan(tan(THYOUT(2))/tan(THXOUT(2)))              phi   = atan(tan(THYOUT(2))/tan(THXOUT(2)))
621              theta = atan(tan(THXOUT(2))/cos(phi))              theta = atan(tan(THXOUT(2))/cos(phi))
622  c            xkorr=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2))  c            xkorr=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2))
623              xkorr = atten(right,12,i,xhelp)              xkorr = atten(right,12,i,xhelp)
624              xkorr=xkorr/hepratio                          if (iz.le.1) xkorr=xkorr/hepratio
625              tof12(right,i,iadc) = xkorr/cos(theta)              tof12(right,i,iadc) = xkorr/cos(theta)
626              adcflag(ch12b(i),hb12b(i)) = 1              adcflag(ch12b(i),hb12b(i)) = 1
627           endif           endif
# Line 715  C-----------------------------S2 ------- Line 632  C-----------------------------S2 -------
632        xhelp=xout(3)        xhelp=xout(3)
633        IF (tof21_i.GT.none_find.AND.abs(xout(3)).lt.100) THEN        IF (tof21_i.GT.none_find.AND.abs(xout(3)).lt.100) THEN
634           i = tof21_i           i = tof21_i
635  c         if (tof21(left,i,iadc).eq.4095) then           if ((tdc(ch21a(i),hb21a(i)).lt.4095).AND.
636           if (adc(ch21a(i),hb21a(i)).eq.4095) then       &       (adc(ch21a(i),hb21a(i)).eq.4095)) then
637              phi   = atan(tan(THYOUT(3))/tan(THXOUT(3)))              phi   = atan(tan(THYOUT(3))/tan(THXOUT(3)))
638              theta = atan(tan(THXOUT(3))/cos(phi))              theta = atan(tan(THXOUT(3))/cos(phi))
639  c            xkorr=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2))  c            xkorr=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2))
640              xkorr = atten(left,21,i,xhelp)              xkorr = atten(left,21,i,xhelp)
641              xkorr=xkorr/hepratio                          if (iz.le.1) xkorr=xkorr/hepratio
642              tof21(left,i,iadc) = xkorr/cos(theta)              tof21(left,i,iadc) = xkorr/cos(theta)
643              adcflag(ch21a(i),hb21a(i)) = 1              adcflag(ch21a(i),hb21a(i)) = 1
644           endif           endif
645  c         if (tof21(right,i,iadc).eq.4095) then           if ((tdc(ch21b(i),hb21b(i)).lt.4095).AND.
646           if (adc(ch21b(i),hb21b(i)).eq.4095) then       &       (adc(ch21b(i),hb21b(i)).eq.4095)) then
647              phi   = atan(tan(THYOUT(3))/tan(THXOUT(3)))              phi   = atan(tan(THYOUT(3))/tan(THXOUT(3)))
648              theta = atan(tan(THXOUT(3))/cos(phi))              theta = atan(tan(THXOUT(3))/cos(phi))
649  c            xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2))  c            xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2))
650              xkorr = atten(right,21,i,xhelp)              xkorr = atten(right,21,i,xhelp)
651              xkorr=xkorr/hepratio                          if (iz.le.1) xkorr=xkorr/hepratio
652              tof21(right,i,iadc) = xkorr/cos(theta)              tof21(right,i,iadc) = xkorr/cos(theta)
653              adcflag(ch21b(i),hb21b(i)) = 1              adcflag(ch21b(i),hb21b(i)) = 1
654           endif           endif
# Line 741  c            xkorr=adcx21(right,i,1)*exp Line 658  c            xkorr=adcx21(right,i,1)*exp
658        yhelp=yout(4)        yhelp=yout(4)
659        IF (tof22_i.GT.none_find.AND.abs(yout(4)).lt.100) THEN        IF (tof22_i.GT.none_find.AND.abs(yout(4)).lt.100) THEN
660           i = tof22_i           i = tof22_i
661  c         if (tof22(left,i,iadc).eq.4095) then           if ((tdc(ch22a(i),hb22a(i)).lt.4095).AND.
662           if (adc(ch22a(i),hb22a(i)).eq.4095) then       &       (adc(ch22a(i),hb22a(i)).eq.4095)) then
663              phi   = atan(tan(THYOUT(4))/tan(THXOUT(4)))              phi   = atan(tan(THYOUT(4))/tan(THXOUT(4)))
664              theta = atan(tan(THXOUT(4))/cos(phi))              theta = atan(tan(THXOUT(4))/cos(phi))
665  c            xkorr=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2))  c            xkorr=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2))
666              xkorr = atten(left,22,i,yhelp)              xkorr = atten(left,22,i,yhelp)
667              xkorr=xkorr/hepratio                          if (iz.le.1) xkorr=xkorr/hepratio
668              tof22(left,i,iadc) = xkorr/cos(theta)              tof22(left,i,iadc) = xkorr/cos(theta)
669              adcflag(ch22a(i),hb22a(i)) = 1              adcflag(ch22a(i),hb22a(i)) = 1
670           endif           endif
671  c         if (tof22(right,i,iadc).eq.4095) then           if ((tdc(ch22a(i),hb22b(i)).lt.4095).AND.
672           if (adc(ch22b(i),hb22b(i)).eq.4095) then       &       (adc(ch22b(i),hb22b(i)).eq.4095)) then
673              phi   = atan(tan(THYOUT(4))/tan(THXOUT(4)))              phi   = atan(tan(THYOUT(4))/tan(THXOUT(4)))
674              theta = atan(tan(THXOUT(4))/cos(phi))              theta = atan(tan(THXOUT(4))/cos(phi))
675  c            xkorr=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2))  c            xkorr=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2))
676              xkorr = atten(right,22,i,yhelp)              xkorr = atten(right,22,i,yhelp)
677              xkorr=xkorr/hepratio                          if (iz.le.1) xkorr=xkorr/hepratio
678              tof22(right,i,iadc) = xkorr/cos(theta)              tof22(right,i,iadc) = xkorr/cos(theta)
679              adcflag(ch22b(i),hb22b(i)) = 1              adcflag(ch22b(i),hb22b(i)) = 1
680           endif           endif
# Line 768  C-----------------------------S3 ------- Line 685  C-----------------------------S3 -------
685        yhelp=yout(5)        yhelp=yout(5)
686        IF (tof31_i.GT.none_find.AND.abs(yout(5)).lt.100) THEN        IF (tof31_i.GT.none_find.AND.abs(yout(5)).lt.100) THEN
687           i = tof31_i           i = tof31_i
688  c         if (tof31(left,i,iadc).eq.4095) then           if ((tdc(ch31a(i),hb31a(i)).lt.4095).AND.
689           if (adc(ch31a(i),hb31a(i)).eq.4095) then       &       (adc(ch31a(i),hb31a(i)).eq.4095)) then
690              phi   = atan(tan(THYOUT(5))/tan(THXOUT(5)))              phi   = atan(tan(THYOUT(5))/tan(THXOUT(5)))
691              theta = atan(tan(THXOUT(5))/cos(phi))              theta = atan(tan(THXOUT(5))/cos(phi))
692  c            xkorr=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2))  c            xkorr=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2))
693              xkorr = atten(left,31,i,yhelp)              xkorr = atten(left,31,i,yhelp)
694              xkorr=xkorr/hepratio                          if (iz.le.1) xkorr=xkorr/hepratio
695              tof31(left,i,iadc) = xkorr/cos(theta)              tof31(left,i,iadc) = xkorr/cos(theta)
696              adcflag(ch31a(i),hb31a(i)) = 1              adcflag(ch31a(i),hb31a(i)) = 1
697           endif           endif
698  c         if (tof31(right,i,iadc).eq.4095) then           if ((tdc(ch31b(i),hb31b(i)).lt.4095).AND.
699           if (adc(ch31b(i),hb31b(i)).eq.4095) then       &       (adc(ch31b(i),hb31b(i)).eq.4095)) then
700              phi   = atan(tan(THYOUT(5))/tan(THXOUT(5)))              phi   = atan(tan(THYOUT(5))/tan(THXOUT(5)))
701              theta = atan(tan(THXOUT(5))/cos(phi))              theta = atan(tan(THXOUT(5))/cos(phi))
702  c            xkorr=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2))  c            xkorr=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2))
703              xkorr = atten(right,31,i,yhelp)              xkorr = atten(right,31,i,yhelp)
704              xkorr=xkorr/hepratio                          if (iz.le.1) xkorr=xkorr/hepratio
705              tof31(right,i,iadc) = xkorr/cos(theta)              tof31(right,i,iadc) = xkorr/cos(theta)
706              adcflag(ch31b(i),hb31b(i)) = 1              adcflag(ch31b(i),hb31b(i)) = 1
707           endif           endif
# Line 794  c            xkorr=adcx31(right,i,1)*exp Line 711  c            xkorr=adcx31(right,i,1)*exp
711        xhelp=xout(6)        xhelp=xout(6)
712        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
713           i = tof32_i           i = tof32_i
714  c         if (tof32(left,i,iadc).eq.4095) then           if ((tdc(ch32a(i),hb32a(i)).lt.4095).AND.
715           if (adc(ch32a(i),hb32a(i)).eq.4095) then       &       (adc(ch32a(i),hb32a(i)).eq.4095)) then
716              phi   = atan(tan(THYOUT(6))/tan(THXOUT(6)))              phi   = atan(tan(THYOUT(6))/tan(THXOUT(6)))
717              theta = atan(tan(THXOUT(6))/cos(phi))              theta = atan(tan(THXOUT(6))/cos(phi))
718  c            xkorr=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2))  c            xkorr=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2))
719              xkorr = atten(left,32,i,xhelp)              xkorr = atten(left,32,i,xhelp)
720              xkorr=xkorr/hepratio                          if (iz.le.1) xkorr=xkorr/hepratio
721              tof32(left,i,iadc) = xkorr/cos(theta)              tof32(left,i,iadc) = xkorr/cos(theta)
722              adcflag(ch32a(i),hb32a(i)) = 1              adcflag(ch32a(i),hb32a(i)) = 1
723           endif           endif
724  c         if (tof32(right,i,iadc).eq.4095) then           if ((tdc(ch32b(i),hb32b(i)).lt.4095).AND.
725           if (adc(ch32b(i),hb32b(i)).eq.4095) then       &       (adc(ch32b(i),hb32b(i)).eq.4095)) then
726              phi   = atan(tan(THYOUT(6))/tan(THXOUT(6)))              phi   = atan(tan(THYOUT(6))/tan(THXOUT(6)))
727              theta = atan(tan(THXOUT(6))/cos(phi))              theta = atan(tan(THXOUT(6))/cos(phi))
728  c            xkorr=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2))  c            xkorr=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2))
729              xkorr = atten(right,32,i,xhelp)              xkorr = atten(right,32,i,xhelp)
730              xkorr=xkorr/hepratio                          if (iz.le.1) xkorr=xkorr/hepratio
731              tof32(right,i,iadc) = xkorr/cos(theta)              tof32(right,i,iadc) = xkorr/cos(theta)
732              adcflag(ch32b(i),hb32b(i)) = 1              adcflag(ch32b(i),hb32b(i)) = 1
733           endif           endif
734        ENDIF        ENDIF
735    
736    C-------------------------------------------------------------------
737    C Now there is for each hitted paddle a TDC and ADC value, if the
738    C TDC was < 4095.
739    C There might be also TDC-ADC pairs in paddles not hitted
740    C Let's correct the raw TDC value with the time walk
741    C-------------------------------------------------------------------
742    C--------------------Time walk correction  -------------------------
743    C-------------------------------------------------------------------
744    
745          DO i=1,8
746             if ((tdc(ch11a(i),hb11a(i)).lt.4095).and.
747         &             (tof11(left,i,iadc).lt.3786)) THEN
748             xhelp = tw11(left,i)/(tof11(left,i,iadc)**0.5)
749             tof11(left,i,itdc) = tof11(left,i,itdc) + xhelp
750             tdc_c(ch11a(i),hb11a(i))=tof11(left,i,itdc)
751                                                  ENDIF
752    
753             if ((tdc(ch11b(i),hb11b(i)).lt.4095).and.
754         &             (tof11(right,i,iadc).lt.3786)) THEN
755             xhelp = tw11(right,i)/(tof11(right,i,iadc)**0.5)
756             tof11(right,i,itdc) = tof11(right,i,itdc) + xhelp
757             tdc_c(ch11b(i),hb11b(i))=tof11(right,i,itdc)
758                                                 ENDIF
759          ENDDO
760    
761    
762          DO i=1,6
763             if ((tdc(ch12a(i),hb12a(i)).lt.4095).and.
764         &             (tof12(left,i,iadc).lt.3786)) THEN
765             xhelp = tw12(left,i)/(tof12(left,i,iadc)**0.5)
766             tof12(left,i,itdc) = tof12(left,i,itdc) + xhelp
767             tdc_c(ch12a(i),hb12a(i))=tof12(left,i,itdc)
768                                                  ENDIF
769    
770             if ((tdc(ch12b(i),hb12b(i)).lt.4095).and.
771         &             (tof12(right,i,iadc).lt.3786)) THEN
772             xhelp = tw12(right,i)/(tof12(right,i,iadc)**0.5)
773             tof12(right,i,itdc) = tof12(right,i,itdc) + xhelp
774             tdc_c(ch12b(i),hb12b(i))=tof12(right,i,itdc)
775                                                 ENDIF
776          ENDDO
777    
778    C----
779          DO I=1,2
780             if ((tdc(ch21a(i),hb21a(i)).lt.4095).and.
781         &             (tof21(left,i,iadc).lt.3786)) THEN
782             xhelp = tw21(left,i)/(tof21(left,i,iadc)**0.5)
783             tof21(left,i,itdc) = tof21(left,i,itdc) + xhelp
784             tdc_c(ch21a(i),hb21a(i))=tof21(left,i,itdc)
785                                                  ENDIF
786    
787             if ((tdc(ch21b(i),hb21b(i)).lt.4095).and.
788         &             (tof21(right,i,iadc).lt.3786)) THEN
789             xhelp = tw21(right,i)/(tof21(right,i,iadc)**0.5)
790             tof21(right,i,itdc) = tof21(right,i,itdc) + xhelp
791             tdc_c(ch21b(i),hb21b(i))=tof21(right,i,itdc)
792                                                 ENDIF
793          ENDDO
794    
795          DO I=1,2
796             if ((tdc(ch22a(i),hb22a(i)).lt.4095).and.
797         &             (tof22(left,i,iadc).lt.3786)) THEN
798             xhelp = tw22(left,i)/(tof22(left,i,iadc)**0.5)
799             tof22(left,i,itdc) = tof22(left,i,itdc) + xhelp
800             tdc_c(ch22a(i),hb22a(i))=tof22(left,i,itdc)
801                                                  ENDIF
802    
803             if ((tdc(ch22b(i),hb22b(i)).lt.4095).and.
804         &             (tof22(right,i,iadc).lt.3786)) THEN
805             xhelp = tw22(right,i)/(tof22(right,i,iadc)**0.5)
806             tof22(right,i,itdc) = tof22(right,i,itdc) + xhelp
807             tdc_c(ch22b(i),hb22b(i))=tof22(right,i,itdc)
808                                                 ENDIF
809          ENDDO
810    
811    C----
812          DO I=1,3
813             if ((tdc(ch31a(i),hb31a(i)).lt.4095).and.
814         &             (tof31(left,i,iadc).lt.3786)) THEN
815             xhelp = tw31(left,i)/(tof31(left,i,iadc)**0.5)
816             tof31(left,i,itdc) = tof31(left,i,itdc) + xhelp
817             tdc_c(ch31a(i),hb31a(i))=tof31(left,i,itdc)
818                                                  ENDIF
819    
820             if ((tdc(ch31b(i),hb31b(i)).lt.4095).and.
821         &             (tof31(right,i,iadc).lt.3786)) THEN
822             xhelp = tw31(right,i)/(tof31(right,i,iadc)**0.5)
823             tof31(right,i,itdc) = tof31(right,i,itdc) + xhelp
824             tdc_c(ch31b(i),hb31b(i))=tof31(right,i,itdc)
825                                                 ENDIF
826          ENDDO
827    
828          DO I=1,3
829             if ((tdc(ch32a(i),hb32a(i)).lt.4095).and.
830         &             (tof32(left,i,iadc).lt.3786)) THEN
831             xhelp = tw32(left,i)/(tof32(left,i,iadc)**0.5)
832             tof32(left,i,itdc) = tof32(left,i,itdc) + xhelp
833             tdc_c(ch32a(i),hb32a(i))=tof32(left,i,itdc)
834                                                  ENDIF
835    
836             if ((tdc(ch32b(i),hb32b(i)).lt.4095).and.
837         &             (tof32(right,i,iadc).lt.3786)) THEN
838             xhelp = tw32(right,i)/(tof32(right,i,iadc)**0.5)
839             tof32(right,i,itdc) = tof32(right,i,itdc) + xhelp
840             tdc_c(ch32b(i),hb32b(i))=tof32(right,i,itdc)
841                                                 ENDIF
842          ENDDO
843    
844    
845    C-----------------------------------------------------------------------
846    C--------------------Insert Artifical TDC Value  ---------------------
847    C     For each Paddle perform check:
848    C     if left paddle=4095  and right paddle OK => create TDC value left
849    C     if right paddle=4095  and left paddle OK => create TDC value right
850    C-----------------------------------------------------------------------
851    
852    C-----------------------S11 -----------------------------------------
853    
854          IF (tof11_i.GT.none_find) THEN
855             xpos = yout(1)
856             i = tof11_i
857            if ((tdc(ch11a(i),hb11a(i)).EQ.4095).AND.
858         &          (tdc(ch11b(i),hb11b(i)).LT.4095)) THEN
859              tof11(1,tof11_i,itdc) = tof11(2,tof11_i,itdc)
860         &           + 2*(y_coor_lin11(tof11_i,offset)
861         &           + xpos*y_coor_lin11(tof11_i,slope))
862                tdcflag(ch11a(i),hb11a(i)) = 1
863            ENDIF
864    
865            if ((tdc(ch11b(i),hb11b(i)).EQ.4095).AND.
866         &          (tdc(ch11a(i),hb11a(i)).LT.4095)) THEN
867                tof11(2,tof11_i,itdc) = tof11(1,tof11_i,itdc)
868         &           - 2*(y_coor_lin11(tof11_i,offset)
869         &           + xpos*y_coor_lin11(tof11_i,slope))
870                tdcflag(ch11b(i),hb11b(i)) = 1
871             ENDIF
872    
873          ENDIF
874    
875    C-----------------------S12 -----------------------------------------
876    
877          IF (tof12_i.GT.none_find) THEN
878             xpos = xout(2)
879             i = tof12_i
880            if ((tdc(ch12a(i),hb12a(i)).EQ.4095).AND.
881         &          (tdc(ch12b(i),hb12b(i)).LT.4095)) THEN
882                tof12(1,tof12_i,itdc) = tof12(2,tof12_i,itdc)
883         &           + 2*(x_coor_lin12(tof12_i,offset)
884         &           + xpos*x_coor_lin12(tof12_i,slope))
885                tdcflag(ch12a(i),hb12a(i)) = 1
886             ENDIF
887    
888            if ((tdc(ch12b(i),hb12b(i)).EQ.4095).AND.
889         &          (tdc(ch12a(i),hb12a(i)).LT.4095)) THEN
890                tof12(2,tof12_i,itdc) = tof12(1,tof12_i,itdc)
891         &           - 2*(x_coor_lin12(tof12_i,offset)
892         &           + xpos*x_coor_lin12(tof12_i,slope))
893                tdcflag(ch12b(i),hb12b(i)) = 1
894             ENDIF
895          ENDIF
896    
897    C-----------------------S21 -----------------------------------------
898    
899          IF (tof21_i.GT.none_find) THEN
900             xpos = xout(3)
901             i = tof21_i
902            if ((tdc(ch21a(i),hb21a(i)).EQ.4095).AND.
903         &          (tdc(ch21b(i),hb21b(i)).LT.4095)) THEN
904                tof21(1,tof21_i,itdc) = tof21(2,tof21_i,itdc)
905         &           + 2*(x_coor_lin21(tof21_i,offset)
906         &           + xpos*x_coor_lin21(tof21_i,slope))
907                tdcflag(ch21a(i),hb21a(i)) = 1
908             ENDIF
909    
910            if ((tdc(ch21b(i),hb21b(i)).EQ.4095).AND.
911         &          (tdc(ch21a(i),hb21a(i)).LT.4095)) THEN
912                tof21(2,tof21_i,itdc) = tof21(1,tof21_i,itdc)
913         &           - 2*(x_coor_lin21(tof21_i,offset)
914         &           + xpos*x_coor_lin21(tof21_i,slope))
915                tdcflag(ch21b(i),hb21b(i)) = 1
916             ENDIF
917          ENDIF
918    
919    C-----------------------S22 -----------------------------------------
920    
921          IF (tof22_i.GT.none_find) THEN
922             xpos = yout(4)
923             i = tof22_i
924            if ((tdc(ch22a(i),hb22a(i)).EQ.4095).AND.
925         &          (tdc(ch22b(i),hb22b(i)).LT.4095)) THEN
926                tof22(1,tof22_i,itdc) = tof22(2,tof22_i,itdc)
927         &           + 2*(y_coor_lin22(tof22_i,offset)
928         &           + xpos*y_coor_lin22(tof22_i,slope))
929                tdcflag(ch22a(i),hb22a(i)) = 1
930             ENDIF
931    
932            if ((tdc(ch22b(i),hb22b(i)).EQ.4095).AND.
933         &          (tdc(ch22a(i),hb22a(i)).LT.4095)) THEN
934                tof22(2,tof22_i,itdc) = tof22(1,tof22_i,itdc)
935         &           - 2*(y_coor_lin22(tof22_i,offset)
936         &           + xpos*y_coor_lin22(tof22_i,slope))
937                tdcflag(ch22b(i),hb22b(i)) = 1
938             ENDIF
939          ENDIF
940    
941    C-----------------------S31 -----------------------------------------
942    
943          IF (tof31_i.GT.none_find) THEN
944             xpos = yout(5)
945             i = tof31_i
946            if ((tdc(ch31a(i),hb31a(i)).EQ.4095).AND.
947         &          (tdc(ch31b(i),hb31b(i)).LT.4095)) THEN
948                tof31(1,tof31_i,itdc) = tof31(2,tof31_i,itdc)
949         &           + 2*(y_coor_lin31(tof31_i,offset)
950         &           + xpos*y_coor_lin31(tof31_i,slope))
951                tdcflag(ch31a(i),hb31a(i)) = 1
952             ENDIF
953    
954            if ((tdc(ch31b(i),hb31b(i)).EQ.4095).AND.
955         &          (tdc(ch31a(i),hb31a(i)).LT.4095)) THEN
956                tof31(2,tof31_i,itdc) = tof31(1,tof31_i,itdc)
957         &           - 2*(y_coor_lin31(tof31_i,offset)
958         &           + xpos*y_coor_lin31(tof31_i,slope))
959                tdcflag(ch31b(i),hb31b(i)) = 1
960             ENDIF
961          ENDIF
962    
963    C-----------------------S32 -----------------------------------------
964    
965          IF (tof32_i.GT.none_find) THEN
966             xpos = xout(6)
967             i = tof32_i
968            if ((tdc(ch32a(i),hb32a(i)).EQ.4095).AND.
969         &          (tdc(ch32b(i),hb32b(i)).LT.4095)) THEN
970                tof32(1,tof32_i,itdc) = tof32(2,tof32_i,itdc)
971         &           + 2*(x_coor_lin32(tof32_i,offset)
972         &           + xpos*x_coor_lin32(tof32_i,slope))
973                tdcflag(ch32a(i),hb32a(i)) = 1
974             ENDIF
975    
976            if ((tdc(ch32b(i),hb32b(i)).EQ.4095).AND.
977         &          (tdc(ch32a(i),hb32a(i)).LT.4095)) THEN
978                tof32(2,tof32_i,itdc) = tof32(1,tof32_i,itdc)
979         &           - 2*(x_coor_lin32(tof32_i,offset)
980         &           + xpos*x_coor_lin32(tof32_i,slope))
981                tdcflag(ch32b(i),hb32b(i)) = 1
982             ENDIF
983          ENDIF
984    
985    
986  C------------------------------------------------------------------  C------------------------------------------------------------------
987  C---  calculate track position in paddle using timing difference  C---  calculate track position in paddle using timing difference
# Line 824  C--------------------------------------- Line 990  C---------------------------------------
990        do i=1,3        do i=1,3
991           xtofpos(i)=100.           xtofpos(i)=100.
992           ytofpos(i)=100.           ytofpos(i)=100.
993        enddo        enddo
994    
995  C-----------------------------S1 --------------------------------  C-----------------------------S1 --------------------------------
996          
997        IF (tof11_i.GT.none_find) THEN        IF (tof11_i.GT.none_find) THEN
998           IF ((tof11(1,tof11_i,itdc).NE.4095).AND.           IF ((tof11(1,tof11_i,itdc).NE.4095).AND.
999       &       (tof11(2,tof11_i,itdc).NE.4095)) THEN       &       (tof11(2,tof11_i,itdc).NE.4095)) THEN
# Line 843  C-----------------------------S1 ------- Line 1010  C-----------------------------S1 -------
1010       +        -x_coor_lin12(tof12_i,offset))/x_coor_lin12(tof12_i,slope)       +        -x_coor_lin12(tof12_i,offset))/x_coor_lin12(tof12_i,slope)
1011          if (abs(xtofpos(1)).gt.31.)  xtofpos(1)=101.          if (abs(xtofpos(1)).gt.31.)  xtofpos(1)=101.
1012        endif        endif
1013        endif              endif
1014          
1015  C-----------------------------S2 --------------------------------  C-----------------------------S2 --------------------------------
1016          
1017        IF (tof21_i.GT.none_find) THEN        IF (tof21_i.GT.none_find) THEN
1018           IF ((tof21(1,tof21_i,itdc).NE.4095).AND.           IF ((tof21(1,tof21_i,itdc).NE.4095).AND.
1019       &       (tof21(2,tof21_i,itdc).NE.4095)) THEN       &       (tof21(2,tof21_i,itdc).NE.4095)) THEN
1020           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.
1021       +        -x_coor_lin21(tof21_i,offset))/x_coor_lin21(tof21_i,slope)       +        -x_coor_lin21(tof21_i,offset))/x_coor_lin21(tof21_i,slope)
1022          if (abs(xtofpos(2)).gt.19.)  xtofpos(2)=101.          if (abs(xtofpos(2)).gt.19.)  xtofpos(2)=101.
1023        endif        endif
1024        endif        endif
1025    
# Line 863  C-----------------------------S2 ------- Line 1030  C-----------------------------S2 -------
1030       +        -y_coor_lin22(tof22_i,offset))/y_coor_lin22(tof22_i,slope)       +        -y_coor_lin22(tof22_i,offset))/y_coor_lin22(tof22_i,slope)
1031          if (abs(ytofpos(2)).gt.18.)  ytofpos(2)=101.          if (abs(ytofpos(2)).gt.18.)  ytofpos(2)=101.
1032        endif        endif
1033        endif              endif
1034          
1035  C-----------------------------S3 --------------------------------  C-----------------------------S3 --------------------------------
1036          
1037        IF (tof31_i.GT.none_find) THEN        IF (tof31_i.GT.none_find) THEN
1038           IF ((tof31(1,tof31_i,itdc).NE.4095).AND.           IF ((tof31(1,tof31_i,itdc).NE.4095).AND.
1039       &       (tof31(2,tof31_i,itdc).NE.4095)) THEN       &       (tof31(2,tof31_i,itdc).NE.4095)) THEN
# Line 883  C-----------------------------S3 ------- Line 1050  C-----------------------------S3 -------
1050       +        -x_coor_lin32(tof32_i,offset))/x_coor_lin32(tof32_i,slope)       +        -x_coor_lin32(tof32_i,offset))/x_coor_lin32(tof32_i,slope)
1051          if (abs(xtofpos(3)).gt.19.)  xtofpos(3)=101.          if (abs(xtofpos(3)).gt.19.)  xtofpos(3)=101.
1052        endif        endif
1053        endif        endif
1054          
1055  c      do i=1,3  c      do i=1,3
1056  c         if (abs(xtofpos(i)).gt.100.) then  c         if (abs(xtofpos(i)).gt.100.) then
1057  c            xtofpos(i)=101.  c            xtofpos(i)=101.
# Line 892  c         endif Line 1059  c         endif
1059  c         if (abs(ytofpos(i)).gt.100.) then  c         if (abs(ytofpos(i)).gt.100.) then
1060  c            ytofpos(i)=101.  c            ytofpos(i)=101.
1061  c         endif  c         endif
1062  c      enddo  c      enddo
         
   
   
   
 C--------------------------------------------------------------------  
 C--------------------Time walk correction  -------------------------  
 C--------------------------------------------------------------------  
   
   
       DO i=1,8  
          xhelp= 0.  
          xhelp_a = tof11(left,i,iadc)  
          xhelp_t = tof11(left,i,itdc)  
 c          if (xhelp_a .eq.0) write (*,*) 'trk 11 ',i,xhelp_a  
   
          if(xhelp_a<3786) xhelp = tw11(left,i)/sqrt(xhelp_a)  
          tof11(left,i,itdc) = xhelp_t  + xhelp  
          tdc_c(ch11a(i),hb11a(i))=tof11(left,i,itdc)  
          xhelp_a = tof11(right,i,iadc)  
          xhelp_t = tof11(right,i,itdc)  
          if(xhelp_a<3786) xhelp = tw11(right,i)/sqrt(xhelp_a)  
          tof11(right,i,itdc) = xhelp_t  + xhelp  
          tdc_c(ch11b(i),hb11b(i))=tof11(right,i,itdc)  
       ENDDO  
   
       DO i=1,6  
          xhelp= 0.  
          xhelp_a = tof12(left,i,iadc)  
          xhelp_t = tof12(left,i,itdc)  
 c          if (xhelp_a .eq.0) write (*,*) 'trk 12 ',i,xhelp_a  
          if(xhelp_a<3786) xhelp = tw12(left,i)/sqrt(xhelp_a)  
          tof12(left,i,itdc) = xhelp_t  + xhelp  
          tdc_c(ch12a(i),hb12a(i))=tof12(left,i,itdc)  
          xhelp_a = tof12(right,i,iadc)  
          xhelp_t = tof12(right,i,itdc)  
          if(xhelp_a<3786) xhelp = tw12(right,i)/sqrt(xhelp_a)  
          tof12(right,i,itdc) = xhelp_t  + xhelp  
          tdc_c(ch12b(i),hb12b(i))=tof12(right,i,itdc)  
       ENDDO  
 C----  
       DO i=1,2  
          xhelp= 0.  
          xhelp_a = tof21(left,i,iadc)  
          xhelp_t = tof21(left,i,itdc)  
 c          if (xhelp_a .eq.0) write (*,*) ' trk 21 ',i,xhelp_a  
   
          if(xhelp_a<3786) xhelp = tw21(left,i)/sqrt(xhelp_a)  
          tof21(left,i,itdc) = xhelp_t  + xhelp  
          tdc_c(ch21a(i),hb21a(i))=tof21(left,i,itdc)  
          xhelp_a = tof21(right,i,iadc)  
          xhelp_t = tof21(right,i,itdc)  
          if(xhelp_a<3786) xhelp = tw21(right,i)/sqrt(xhelp_a)  
          tof21(right,i,itdc) = xhelp_t  + xhelp  
          tdc_c(ch21b(i),hb21b(i))=tof21(right,i,itdc)  
       ENDDO  
   
       DO i=1,2  
          xhelp= 0.  
          xhelp_a = tof22(left,i,iadc)  
          xhelp_t = tof22(left,i,itdc)  
 c          if (xhelp_a .eq.0) write (*,*) ' trk 22 ',i,xhelp_a  
          if(xhelp_a<3786) xhelp = tw22(left,i)/sqrt(xhelp_a)  
          tof22(left,i,itdc) = xhelp_t  + xhelp  
          tdc_c(ch22a(i),hb22a(i))=tof22(left,i,itdc)  
          xhelp_a = tof22(right,i,iadc)  
          xhelp_t = tof22(right,i,itdc)  
          if(xhelp_a<3786) xhelp = tw22(right,i)/sqrt(xhelp_a)  
          tof22(right,i,itdc) = xhelp_t  + xhelp  
          tdc_c(ch22b(i),hb22b(i))=tof22(right,i,itdc)  
       ENDDO  
 C----  
   
       DO i=1,3  
          xhelp= 0.  
          xhelp_a = tof31(left,i,iadc)  
          xhelp_t = tof31(left,i,itdc)  
 c          if (xhelp_a .eq.0) write (*,*) ' trk 31 ',i,xhelp_a  
   
          if(xhelp_a<3786) xhelp = tw31(left,i)/sqrt(xhelp_a)  
          tof31(left,i,itdc) = xhelp_t  + xhelp  
          tdc_c(ch31a(i),hb31a(i))=tof31(left,i,itdc)  
          xhelp_a = tof31(right,i,iadc)  
          xhelp_t = tof31(right,i,itdc)  
          if(xhelp_a<3786) xhelp = tw31(right,i)/sqrt(xhelp_a)  
          tof31(right,i,itdc) = xhelp_t  + xhelp  
          tdc_c(ch31b(i),hb31b(i))=tof31(right,i,itdc)  
       ENDDO  
   
       DO i=1,3  
          xhelp= 0.  
          xhelp_a = tof32(left,i,iadc)  
          xhelp_t = tof32(left,i,itdc)  
 c          if (xhelp_a .eq.0) write (*,*) ' trk 32 ',i,xhelp_a  
1063    
          if(xhelp_a<3786) xhelp = tw32(left,i)/sqrt(xhelp_a)  
          tof32(left,i,itdc) = xhelp_t  + xhelp  
          tdc_c(ch32a(i),hb32a(i))=tof32(left,i,itdc)  
          xhelp_a = tof32(right,i,iadc)  
          xhelp_t = tof32(right,i,itdc)  
          if(xhelp_a<3786) xhelp = tw32(right,i)/sqrt(xhelp_a)  
          tof32(right,i,itdc) = xhelp_t  + xhelp  
          tdc_c(ch32b(i),hb32b(i))=tof32(right,i,itdc)  
       ENDDO  
1064    
1065    
1066  C---------------------------------------------------------------------  C---------------------------------------------------------------------
# Line 1012  C-----------------------------S1 ------- Line 1077  C-----------------------------S1 -------
1077        IF (tof11_i.GT.none_find.AND.yhelp.lt.100) THEN        IF (tof11_i.GT.none_find.AND.yhelp.lt.100) THEN
1078    
1079           i = tof11_i           i = tof11_i
1080            
1081           if (tof11(left,i,iadc).lt.3786) then           if (tof11(left,i,iadc).lt.3786) then
1082  c         if (adc(ch11a(i),hb11a(i)).lt.4095) then              tof11(left,i,iadc) = tof11(left,i,iadc)*cos(theta)
             tof11(left,i,iadc) = tof11(left,i,iadc)*cos(theta)  
 c            xkorr=adcx11(left,i,1)*exp(-yhelp/adcx11(left,i,2))  
1083              xkorr = atten(left,11,i,yhelp)              xkorr = atten(left,11,i,yhelp)
1084              xkorr=xkorr/hepratio              xkorr=xkorr/hepratio
1085              adc_c(ch11a(i),hb11a(i))=tof11(left,i,iadc)/xkorr              adc_c(ch11a(i),hb11a(i))=tof11(left,i,iadc)/xkorr
1086           endif           endif
1087    
1088            
1089           if (tof11(right,i,iadc).lt.3786) then           if (tof11(right,i,iadc).lt.3786) then
 c         if (adc(ch11b(i),hb11b(i)).lt.4095) then  
1090              tof11(right,i,iadc) = tof11(right,i,iadc)*cos(theta)              tof11(right,i,iadc) = tof11(right,i,iadc)*cos(theta)
 c            xkorr=adcx11(right,i,1)*exp(yhelp/adcx11(right,i,2))  
1091              xkorr = atten(right,11,i,yhelp)              xkorr = atten(right,11,i,yhelp)
1092              xkorr=xkorr/hepratio                          xkorr=xkorr/hepratio
1093              adc_c(ch11b(i),hb11b(i))=tof11(right,i,iadc)/xkorr              adc_c(ch11b(i),hb11b(i))=tof11(right,i,iadc)/xkorr
1094           endif           endif
1095        ENDIF        ENDIF
# Line 1037  c            xkorr=adcx11(right,i,1)*exp Line 1098  c            xkorr=adcx11(right,i,1)*exp
1098        xhelp=xout(2)        xhelp=xout(2)
1099        phi   = atan(tan(THYOUT(2))/tan(THXOUT(2)))        phi   = atan(tan(THYOUT(2))/tan(THXOUT(2)))
1100        theta = atan(tan(THXOUT(2))/cos(phi))        theta = atan(tan(THXOUT(2))/cos(phi))
 c      write(*,*) 'theta12 ',theta  
       IF (tof12_i.GT.none_find.AND.xhelp.lt.100) THEN  
1101    
1102          IF (tof12_i.GT.none_find.AND.xhelp.lt.100) THEN
1103           i = tof12_i           i = tof12_i
1104           if (tof12(left,i,iadc).lt.3786) then           if (tof12(left,i,iadc).lt.3786) then
 c         if (adc(ch12a(i),hb12a(i)).lt.4095) then  
1105              tof12(left,i,iadc) = tof12(left,i,iadc)*cos(theta)              tof12(left,i,iadc) = tof12(left,i,iadc)*cos(theta)
 c            xkorr=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2))  
1106              xkorr = atten(left,12,i,xhelp)              xkorr = atten(left,12,i,xhelp)
1107              xkorr=xkorr/hepratio                          xkorr=xkorr/hepratio
1108              adc_c(ch12a(i),hb12a(i))=tof12(left,i,iadc)/xkorr              adc_c(ch12a(i),hb12a(i))=tof12(left,i,iadc)/xkorr
1109           endif           endif
1110    
1111           if (tof12(right,i,iadc).lt.3786) then           if (tof12(right,i,iadc).lt.3786) then
 c         if (adc(ch12b(i),hb12b(i)).lt.4095) then  
1112              tof12(right,i,iadc) = tof12(right,i,iadc)*cos(theta)              tof12(right,i,iadc) = tof12(right,i,iadc)*cos(theta)
 c            xkorr=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2))  
1113              xkorr = atten(right,12,i,xhelp)              xkorr = atten(right,12,i,xhelp)
1114              xkorr=xkorr/hepratio                          xkorr=xkorr/hepratio
1115              adc_c(ch12b(i),hb12b(i))=tof12(right,i,iadc)/xkorr              adc_c(ch12b(i),hb12b(i))=tof12(right,i,iadc)/xkorr
1116           endif           endif
1117        ENDIF        ENDIF
# Line 1065  C-----------------------------S2 ------- Line 1121  C-----------------------------S2 -------
1121        xhelp=xout(3)        xhelp=xout(3)
1122        phi   = atan(tan(THYOUT(3))/tan(THXOUT(3)))        phi   = atan(tan(THYOUT(3))/tan(THXOUT(3)))
1123        theta = atan(tan(THXOUT(3))/cos(phi))        theta = atan(tan(THXOUT(3))/cos(phi))
 c      write(*,*) 'theta21 ',theta  
       IF (tof21_i.GT.none_find.AND.xhelp.lt.100) THEN  
1124    
1125          IF (tof21_i.GT.none_find.AND.xhelp.lt.100) THEN
1126           i = tof21_i           i = tof21_i
1127           if (tof21(left,i,iadc).lt.3786) then           if (tof21(left,i,iadc).lt.3786) then
 c         if (adc(ch21a(i),hb21a(i)).lt.4095) then  
1128              tof21(left,i,iadc) = tof21(left,i,iadc)*cos(theta)              tof21(left,i,iadc) = tof21(left,i,iadc)*cos(theta)
 c            xkorr=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2))  
1129              xkorr = atten(left,21,i,xhelp)              xkorr = atten(left,21,i,xhelp)
1130              xkorr=xkorr/hepratio                          xkorr=xkorr/hepratio
1131              adc_c(ch21a(i),hb21a(i))=tof21(left,i,iadc)/xkorr              adc_c(ch21a(i),hb21a(i))=tof21(left,i,iadc)/xkorr
1132           endif           endif
1133    
1134           if (tof21(right,i,iadc).lt.3786) then           if (tof21(right,i,iadc).lt.3786) then
 c         if (adc(ch21b(i),hb21b(i)).lt.4095) then  
1135              tof21(right,i,iadc) = tof21(right,i,iadc)*cos(theta)              tof21(right,i,iadc) = tof21(right,i,iadc)*cos(theta)
 c            xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2))  
1136              xkorr = atten(right,21,i,xhelp)              xkorr = atten(right,21,i,xhelp)
1137              xkorr=xkorr/hepratio                          xkorr=xkorr/hepratio
1138              adc_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr              adc_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr
1139           endif           endif
1140        ENDIF        ENDIF
# Line 1091  c            xkorr=adcx21(right,i,1)*exp Line 1142  c            xkorr=adcx21(right,i,1)*exp
1142        yhelp=yout(4)        yhelp=yout(4)
1143        phi   = atan(tan(THYOUT(4))/tan(THXOUT(4)))        phi   = atan(tan(THYOUT(4))/tan(THXOUT(4)))
1144        theta = atan(tan(THXOUT(4))/cos(phi))        theta = atan(tan(THXOUT(4))/cos(phi))
 c      write(*,*) 'theta22 ',theta  
1145    
1146        IF (tof22_i.GT.none_find.AND.yhelp.lt.100) THEN        IF (tof22_i.GT.none_find.AND.yhelp.lt.100) THEN
   
1147           i = tof22_i           i = tof22_i
1148           if (tof22(left,i,iadc).lt.3786) then           if (tof22(left,i,iadc).lt.3786) then
 c         if (adc(ch22a(i),hb22a(i)).lt.4095) then  
1149              tof22(left,i,iadc) = tof22(left,i,iadc)*cos(theta)              tof22(left,i,iadc) = tof22(left,i,iadc)*cos(theta)
 c            xkorr=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2))  
1150              xkorr = atten(left,22,i,yhelp)              xkorr = atten(left,22,i,yhelp)
1151              xkorr=xkorr/hepratio                          xkorr=xkorr/hepratio
1152              adc_c(ch22a(i),hb22a(i))=tof22(left,i,iadc)/xkorr              adc_c(ch22a(i),hb22a(i))=tof22(left,i,iadc)/xkorr
1153           endif           endif
1154    
1155           if (tof22(right,i,iadc).lt.3786) then           if (tof22(right,i,iadc).lt.3786) then
 c         if (adc(ch22b(i),hb22b(i)).lt.4095) then  
1156              tof22(right,i,iadc) = tof22(right,i,iadc)*cos(theta)              tof22(right,i,iadc) = tof22(right,i,iadc)*cos(theta)
 c            xkorr=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2))  
1157              xkorr = atten(right,22,i,yhelp)              xkorr = atten(right,22,i,yhelp)
1158              xkorr=xkorr/hepratio                          xkorr=xkorr/hepratio
1159              adc_c(ch22b(i),hb22b(i))=tof22(right,i,iadc)/xkorr              adc_c(ch22b(i),hb22b(i))=tof22(right,i,iadc)/xkorr
1160           endif           endif
1161        ENDIF        ENDIF
# Line 1120  C-----------------------------S3 ------- Line 1165  C-----------------------------S3 -------
1165        yhelp=yout(5)        yhelp=yout(5)
1166        phi   = atan(tan(THYOUT(5))/tan(THXOUT(5)))        phi   = atan(tan(THYOUT(5))/tan(THXOUT(5)))
1167        theta = atan(tan(THXOUT(5))/cos(phi))        theta = atan(tan(THXOUT(5))/cos(phi))
1168  c      write(*,*) 'theta31 ',theta  
         
1169        IF (tof31_i.GT.none_find.AND.yhelp.lt.100) THEN        IF (tof31_i.GT.none_find.AND.yhelp.lt.100) THEN
1170    
1171           i = tof31_i           i = tof31_i
1172           if (tof31(left,i,iadc).lt.3786) then           if (tof31(left,i,iadc).lt.3786) then
 c         if (adc(ch31a(i),hb31a(i)).lt.4095) then  
1173              tof31(left,i,iadc) = tof31(left,i,iadc)*cos(theta)              tof31(left,i,iadc) = tof31(left,i,iadc)*cos(theta)
 c            xkorr=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2))  
1174              xkorr = atten(left,31,i,yhelp)              xkorr = atten(left,31,i,yhelp)
1175              xkorr=xkorr/hepratio                          xkorr=xkorr/hepratio
1176              adc_c(ch31a(i),hb31a(i))=tof31(left,i,iadc)/xkorr              adc_c(ch31a(i),hb31a(i))=tof31(left,i,iadc)/xkorr
1177           endif           endif
1178    
1179           if (tof31(right,i,iadc).lt.3786) then           if (tof31(right,i,iadc).lt.3786) then
 c         if (adc(ch31b(i),hb31b(i)).lt.4095) then  
1180              tof31(right,i,iadc) = tof31(right,i,iadc)*cos(theta)              tof31(right,i,iadc) = tof31(right,i,iadc)*cos(theta)
 c            xkorr=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2))  
1181              xkorr = atten(right,31,i,yhelp)              xkorr = atten(right,31,i,yhelp)
1182              xkorr=xkorr/hepratio                          xkorr=xkorr/hepratio
1183              adc_c(ch31b(i),hb31b(i))=tof31(right,i,iadc)/xkorr              adc_c(ch31b(i),hb31b(i))=tof31(right,i,iadc)/xkorr
1184           endif           endif
1185        ENDIF        ENDIF
# Line 1147  c            xkorr=adcx31(right,i,1)*exp Line 1187  c            xkorr=adcx31(right,i,1)*exp
1187        xhelp=xout(6)        xhelp=xout(6)
1188        phi   = atan(tan(THYOUT(6))/tan(THXOUT(6)))        phi   = atan(tan(THYOUT(6))/tan(THXOUT(6)))
1189        theta = atan(tan(THXOUT(6))/cos(phi))        theta = atan(tan(THXOUT(6))/cos(phi))
 c      write(*,*) 'theta32 ',theta  
1190    
1191        IF (tof32_i.GT.none_find.AND.xhelp.lt.100) THEN        IF (tof32_i.GT.none_find.AND.xhelp.lt.100) THEN
   
1192           i = tof32_i           i = tof32_i
1193           if (tof32(left,i,iadc).lt.3786) then           if (tof32(left,i,iadc).lt.3786) then
 c         if (adc(ch32a(i),hb32a(i)).lt.4095) then  
1194              tof32(left,i,iadc) = tof32(left,i,iadc)*cos(theta)              tof32(left,i,iadc) = tof32(left,i,iadc)*cos(theta)
 c            xkorr=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2))  
1195              xkorr = atten(left,32,i,xhelp)              xkorr = atten(left,32,i,xhelp)
1196              xkorr=xkorr/hepratio                          xkorr=xkorr/hepratio
1197              adc_c(ch32a(i),hb32a(i))=tof32(left,i,iadc)/xkorr              adc_c(ch32a(i),hb32a(i))=tof32(left,i,iadc)/xkorr
1198           endif           endif
1199    
1200           if (tof32(right,i,iadc).lt.3786) then           if (tof32(right,i,iadc).lt.3786) then
 c         if (adc(ch32b(i),hb32b(i)).lt.4095) then  
1201              tof32(right,i,iadc) = tof32(right,i,iadc)*cos(theta)              tof32(right,i,iadc) = tof32(right,i,iadc)*cos(theta)
 c            xkorr=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2))  
1202              xkorr = atten(right,32,i,xhelp)              xkorr = atten(right,32,i,xhelp)
1203              xkorr=xkorr/hepratio                          xkorr=xkorr/hepratio
1204              adc_c(ch32b(i),hb32b(i))=tof32(right,i,iadc)/xkorr              adc_c(ch32b(i),hb32b(i))=tof32(right,i,iadc)/xkorr
1205           endif           endif
1206        ENDIF        ENDIF
1207    
1208    
1209  C-----------------------------------------------------------------------  C-----------------------------------------------------------------------
1210  C----------------------calculate Beta  ------------------------------  C----------------------calculate Beta  ------------------------------
1211  C-----------------------------------------------------------------------  C-----------------------------------------------------------------------
1212  C-------------------difference of sums  ---------------------------  C-------------------difference of sums  ---------------------------
1213  C      C
1214  C     DS = (t1+t2) - t3+t4)  C     DS = (t1+t2) - t3+t4)
1215  C     DS = c1 + c2/beta*cos(theta)  C     DS = c1 + c2/beta*cos(theta)
1216  C     c2 = 2d/c   gives c2 = 2d/(c*TDCresolution)  TDC=50ps/channel  C     c2 = 2d/c   gives c2 = 2d/(c*TDCresolution)  TDC=50ps/channel
1217  C     =>  c2 =  ca.60 for  0.45 m    c2 = ca.109  for 0.81 m  C     =>  c2 =  ca.60 for  0.45 m    c2 = ca.109  for 0.81 m
1218  C     since TDC resolution varies slightly c2 has to be calibrated  C     since TDC resolution varies slightly c2 has to be calibrated
1219  C     instead of cos(theta) use factor F:  C     instead of cos(theta) use factor F:
1220  C     F =  pathlength/d  C     F =  pathlength/d
1221  C     => beta = c2*F/(DS-c1))  C     => beta = c2*F/(DS-c1))
1222    
1223        dist = ZTOF(1) - ZTOF(5)        dist = ZTOF(1) - ZTOF(5)
# Line 1190  C     => beta = c2*F/(DS-c1)) Line 1225  C     => beta = c2*F/(DS-c1))
1225        DO I=1,5        DO I=1,5
1226           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1227        ENDDO        ENDDO
1228        F = dl/dist        F = dl/dist
1229    
1230  C     S11 - S31  C     S11 - S31
1231  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
# Line 1200  C      IF (tof11_i.GT.none_find.AND.tof3 Line 1235  C      IF (tof11_i.GT.none_find.AND.tof3
1235           t2 = tof11(2,tof11_i,itdc)           t2 = tof11(2,tof11_i,itdc)
1236           t3 = tof31(1,tof31_i,itdc)           t3 = tof31(1,tof31_i,itdc)
1237           t4 = tof31(2,tof31_i,itdc)           t4 = tof31(2,tof31_i,itdc)
1238           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1239       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1240              xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)              xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
1241              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1242              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1243              ihelp=(tof11_i-1)*3+tof31_i              ihelp=(tof11_i-1)*3+tof31_i
1244              c1 = k_S11S31(1,ihelp)              c1 = k_S11S31(1,ihelp)
1245              c2 = k_S11S31(2,ihelp)                      if (iz.gt.2) c1 = c1 + k1corrA1
1246                c2 = k_S11S31(2,ihelp)
1247              beta_a(1) = c2*F/(ds-c1)              beta_a(1) = c2*F/(ds-c1)
1248  C     write(*,*) 'S11-S31 ',xhelp1,xhelp2, beta_a(1)  c       write(*,*) 'S11-S31 ',c1,c2,F
1249    c       write(*,*) 'S11-S31 ',xhelp1,xhelp2, beta_a(1)
1250  C-------ToF Mask - S11 - S31  C-------ToF Mask - S11 - S31
1251    
1252              tofmask(ch11a(tof11_i),hb11a(tof11_i)) =              tofmask(ch11a(tof11_i),hb11a(tof11_i)) =
# Line 1219  C-------ToF Mask - S11 - S31 Line 1256  C-------ToF Mask - S11 - S31
1256    
1257              tofmask(ch31a(tof31_i),hb31a(tof31_i)) =              tofmask(ch31a(tof31_i),hb31a(tof31_i)) =
1258       $           tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1       $           tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1
1259              tofmask(ch31b(tof31_i),hb31b(tof31_i)) =              tofmask(ch31b(tof31_i),hb31b(tof31_i)) =
1260       $           tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1       $           tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1
1261    
1262           ENDIF           ENDIF
# Line 1230  C-------ToF Mask - S11 - S31 Line 1267  C-------ToF Mask - S11 - S31
1267        DO I=1,6        DO I=1,6
1268           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1269        ENDDO        ENDDO
1270        F = dl/dist        F = dl/dist
1271          
1272  C     S11 - S32  C     S11 - S32
1273  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
1274         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.
# Line 1240  C      IF (tof11_i.GT.none_find.AND.tof3 Line 1277  C      IF (tof11_i.GT.none_find.AND.tof3
1277           t2 = tof11(2,tof11_i,itdc)           t2 = tof11(2,tof11_i,itdc)
1278           t3 = tof32(1,tof32_i,itdc)           t3 = tof32(1,tof32_i,itdc)
1279           t4 = tof32(2,tof32_i,itdc)           t4 = tof32(2,tof32_i,itdc)
1280           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1281       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1282              xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)              xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
1283              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1284              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1285              ihelp=(tof11_i-1)*3+tof32_i              ihelp=(tof11_i-1)*3+tof32_i
1286              c1 = k_S11S32(1,ihelp)              c1 = k_S11S32(1,ihelp)
1287              c2 = k_S11S32(2,ihelp)                      if (iz.gt.2) c1 = c1 + k1corrA1
1288                c2 = k_S11S32(2,ihelp)
1289              beta_a(2) = c2*F/(ds-c1)              beta_a(2) = c2*F/(ds-c1)
1290  C     write(*,*) 'S11-S32 ',xhelp1,xhelp2, beta_a(2)  C     write(*,*) 'S11-S32 ',xhelp1,xhelp2, beta_a(2)
1291    
# Line 1260  C-------ToF Mask - S11 - S32 Line 1298  C-------ToF Mask - S11 - S32
1298    
1299              tofmask(ch32a(tof32_i),hb32a(tof32_i)) =              tofmask(ch32a(tof32_i),hb32a(tof32_i)) =
1300       $           tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1       $           tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1
1301              tofmask(ch32b(tof32_i),hb32b(tof32_i)) =              tofmask(ch32b(tof32_i),hb32b(tof32_i)) =
1302       $           tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1       $           tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1
1303    
1304  C-------  C-------
# Line 1274  C     S12 - S31 Line 1312  C     S12 - S31
1312        DO I=2,5        DO I=2,5
1313           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1314        ENDDO        ENDDO
1315        F = dl/dist        F = dl/dist
1316    
1317  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
1318         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.
# Line 1283  C      IF (tof12_i.GT.none_find.AND.tof3 Line 1321  C      IF (tof12_i.GT.none_find.AND.tof3
1321           t2 = tof12(2,tof12_i,itdc)           t2 = tof12(2,tof12_i,itdc)
1322           t3 = tof31(1,tof31_i,itdc)           t3 = tof31(1,tof31_i,itdc)
1323           t4 = tof31(2,tof31_i,itdc)           t4 = tof31(2,tof31_i,itdc)
1324           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1325       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1326              xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)              xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1327              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1328              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1329              ihelp=(tof12_i-1)*3+tof31_i              ihelp=(tof12_i-1)*3+tof31_i
1330              c1 = k_S12S31(1,ihelp)              c1 = k_S12S31(1,ihelp)
1331                if (iz.gt.2) c1 = c1 + k1corrA1
1332              c2 = k_S12S31(2,ihelp)              c2 = k_S12S31(2,ihelp)
1333              beta_a(3) = c2*F/(ds-c1)              beta_a(3) = c2*F/(ds-c1)
1334  C     write(*,*) 'S12-S31 ',xhelp1,xhelp2, beta_a(3)  C     write(*,*) 'S12-S31 ',xhelp1,xhelp2, beta_a(3)
# Line 1303  C-------ToF Mask - S12 - S31 Line 1342  C-------ToF Mask - S12 - S31
1342    
1343              tofmask(ch31a(tof31_i),hb31a(tof31_i)) =              tofmask(ch31a(tof31_i),hb31a(tof31_i)) =
1344       $           tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1       $           tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1
1345              tofmask(ch31b(tof31_i),hb31b(tof31_i)) =              tofmask(ch31b(tof31_i),hb31b(tof31_i)) =
1346       $           tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1       $           tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1
1347    
1348  C-------  C-------
# Line 1318  C     S12 - S32 Line 1357  C     S12 - S32
1357        DO I=2,6        DO I=2,6
1358           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1359        ENDDO        ENDDO
1360        F = dl/dist        F = dl/dist
1361    
1362  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
1363         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 1327  C      IF (tof12_i.GT.none_find.AND.tof3 Line 1366  C      IF (tof12_i.GT.none_find.AND.tof3
1366           t2 = tof12(2,tof12_i,itdc)           t2 = tof12(2,tof12_i,itdc)
1367           t3 = tof32(1,tof32_i,itdc)           t3 = tof32(1,tof32_i,itdc)
1368           t4 = tof32(2,tof32_i,itdc)           t4 = tof32(2,tof32_i,itdc)
1369           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1370       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1371              xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)              xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1372              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1373              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1374              ihelp=(tof12_i-1)*3+tof32_i              ihelp=(tof12_i-1)*3+tof32_i
1375              c1 = k_S12S32(1,ihelp)              c1 = k_S12S32(1,ihelp)
1376                if (iz.gt.2) c1 = c1 + k1corrA1
1377              c2 = k_S12S32(2,ihelp)              c2 = k_S12S32(2,ihelp)
1378              beta_a(4) = c2*F/(ds-c1)              beta_a(4) = c2*F/(ds-c1)
1379  C     write(*,*) 'S12-S32 ',xhelp1,xhelp2, beta_a(4)  C     write(*,*) 'S12-S32 ',xhelp1,xhelp2, beta_a(4)
# Line 1347  C-------ToF Mask - S12 - S32 Line 1387  C-------ToF Mask - S12 - S32
1387    
1388              tofmask(ch32a(tof32_i),hb32a(tof32_i)) =              tofmask(ch32a(tof32_i),hb32a(tof32_i)) =
1389       $           tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1       $           tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1
1390              tofmask(ch32b(tof32_i),hb32b(tof32_i)) =              tofmask(ch32b(tof32_i),hb32b(tof32_i)) =
1391       $           tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1       $           tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1
1392    
1393  C-------  C-------
# Line 1362  C     S21 - S31 Line 1402  C     S21 - S31
1402        DO I=3,5        DO I=3,5
1403           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1404        ENDDO        ENDDO
1405        F = dl/dist        F = dl/dist
1406    
1407  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
1408         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.
# Line 1371  C      IF (tof21_i.GT.none_find.AND.tof3 Line 1411  C      IF (tof21_i.GT.none_find.AND.tof3
1411           t2 = tof21(2,tof21_i,itdc)           t2 = tof21(2,tof21_i,itdc)
1412           t3 = tof31(1,tof31_i,itdc)           t3 = tof31(1,tof31_i,itdc)
1413           t4 = tof31(2,tof31_i,itdc)           t4 = tof31(2,tof31_i,itdc)
1414           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1415       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1416              xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)              xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1417              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1418              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1419              ihelp=(tof21_i-1)*3+tof31_i              ihelp=(tof21_i-1)*3+tof31_i
1420              c1 = k_S21S31(1,ihelp)              c1 = k_S21S31(1,ihelp)
1421                if (iz.gt.2) c1 = c1 + k1corrB1
1422              c2 = k_S21S31(2,ihelp)              c2 = k_S21S31(2,ihelp)
1423              beta_a(5) = c2*F/(ds-c1)              beta_a(5) = c2*F/(ds-c1)
1424    
# Line 1390  C-------ToF Mask - S21 - S31 Line 1431  C-------ToF Mask - S21 - S31
1431    
1432              tofmask(ch31a(tof31_i),hb31a(tof31_i)) =              tofmask(ch31a(tof31_i),hb31a(tof31_i)) =
1433       $           tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1       $           tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1
1434              tofmask(ch31b(tof31_i),hb31b(tof31_i)) =              tofmask(ch31b(tof31_i),hb31b(tof31_i)) =
1435       $           tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1       $           tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1
1436    
1437  C-------  C-------
# Line 1405  C     S21 - S32 Line 1446  C     S21 - S32
1446        DO I=3,6        DO I=3,6
1447           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1448        ENDDO        ENDDO
1449        F = dl/dist        F = dl/dist
1450    
1451  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
1452         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.
# Line 1414  C      IF (tof21_i.GT.none_find.AND.tof3 Line 1455  C      IF (tof21_i.GT.none_find.AND.tof3
1455           t2 = tof21(2,tof21_i,itdc)           t2 = tof21(2,tof21_i,itdc)
1456           t3 = tof32(1,tof32_i,itdc)           t3 = tof32(1,tof32_i,itdc)
1457           t4 = tof32(2,tof32_i,itdc)           t4 = tof32(2,tof32_i,itdc)
1458           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1459       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1460              xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)              xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1461              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1462              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1463              ihelp=(tof21_i-1)*3+tof32_i              ihelp=(tof21_i-1)*3+tof32_i
1464              c1 = k_S21S32(1,ihelp)              c1 = k_S21S32(1,ihelp)
1465                if (iz.gt.2) c1 = c1 + k1corrB1
1466              c2 = k_S21S32(2,ihelp)              c2 = k_S21S32(2,ihelp)
1467              beta_a(6) = c2*F/(ds-c1)              beta_a(6) = c2*F/(ds-c1)
1468    
# Line 1433  C-------ToF Mask - S21 - S32 Line 1475  C-------ToF Mask - S21 - S32
1475    
1476              tofmask(ch32a(tof32_i),hb32a(tof32_i)) =              tofmask(ch32a(tof32_i),hb32a(tof32_i)) =
1477       $           tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1       $           tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1
1478              tofmask(ch32b(tof32_i),hb32b(tof32_i)) =              tofmask(ch32b(tof32_i),hb32b(tof32_i)) =
1479       $           tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1       $           tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1
1480    
1481  C-------  C-------
# Line 1448  C     S22 - S31 Line 1490  C     S22 - S31
1490        DO I=4,5        DO I=4,5
1491           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1492        ENDDO        ENDDO
1493        F = dl/dist        F = dl/dist
1494    
1495  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
1496         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.
# Line 1457  C      IF (tof22_i.GT.none_find.AND.tof3 Line 1499  C      IF (tof22_i.GT.none_find.AND.tof3
1499           t2 = tof22(2,tof22_i,itdc)           t2 = tof22(2,tof22_i,itdc)
1500           t3 = tof31(1,tof31_i,itdc)           t3 = tof31(1,tof31_i,itdc)
1501           t4 = tof31(2,tof31_i,itdc)           t4 = tof31(2,tof31_i,itdc)
1502           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1503       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1504              xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)              xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1505              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1506              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1507              ihelp=(tof22_i-1)*3+tof31_i              ihelp=(tof22_i-1)*3+tof31_i
1508              c1 = k_S22S31(1,ihelp)              c1 = k_S22S31(1,ihelp)
1509                if (iz.gt.2) c1 = c1 + k1corrB1
1510              c2 = k_S22S31(2,ihelp)              c2 = k_S22S31(2,ihelp)
1511              beta_a(7) = c2*F/(ds-c1)              beta_a(7) = c2*F/(ds-c1)
1512    
# Line 1476  C-------ToF Mask - S22 - S31 Line 1519  C-------ToF Mask - S22 - S31
1519    
1520              tofmask(ch31a(tof31_i),hb31a(tof31_i)) =              tofmask(ch31a(tof31_i),hb31a(tof31_i)) =
1521       $           tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1       $           tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1
1522              tofmask(ch31b(tof31_i),hb31b(tof31_i)) =              tofmask(ch31b(tof31_i),hb31b(tof31_i)) =
1523       $           tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1       $           tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1
1524    
1525  C-------  C-------
1526    
1527           ENDIF           ENDIF
1528        ENDIF        ENDIF
1529          
1530  C     S22 - S32  C     S22 - S32
1531    
1532        dist = ZTOF(4) - ZTOF(6)        dist = ZTOF(4) - ZTOF(6)
# Line 1491  C     S22 - S32 Line 1534  C     S22 - S32
1534        DO I=4,6        DO I=4,6
1535           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1536        ENDDO        ENDDO
1537        F = dl/dist        F = dl/dist
1538    
1539  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
1540         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 1500  C      IF (tof22_i.GT.none_find.AND.tof3 Line 1543  C      IF (tof22_i.GT.none_find.AND.tof3
1543           t2 = tof22(2,tof22_i,itdc)           t2 = tof22(2,tof22_i,itdc)
1544           t3 = tof32(1,tof32_i,itdc)           t3 = tof32(1,tof32_i,itdc)
1545           t4 = tof32(2,tof32_i,itdc)           t4 = tof32(2,tof32_i,itdc)
1546           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1547       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1548              xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)              xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1549              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1550              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1551              ihelp=(tof22_i-1)*3+tof32_i              ihelp=(tof22_i-1)*3+tof32_i
1552              c1 = k_S22S32(1,ihelp)              c1 = k_S22S32(1,ihelp)
1553                if (iz.gt.2) c1 = c1 + k1corrB1
1554              c2 = k_S22S32(2,ihelp)              c2 = k_S22S32(2,ihelp)
1555              beta_a(8) = c2*F/(ds-c1)              beta_a(8) = c2*F/(ds-c1)
1556    
# Line 1519  C-------ToF Mask - S22 - S32 Line 1563  C-------ToF Mask - S22 - S32
1563    
1564              tofmask(ch32a(tof32_i),hb32a(tof32_i)) =              tofmask(ch32a(tof32_i),hb32a(tof32_i)) =
1565       $           tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1       $           tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1
1566              tofmask(ch32b(tof32_i),hb32b(tof32_i)) =              tofmask(ch32b(tof32_i),hb32b(tof32_i)) =
1567       $           tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1       $           tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1
1568    
1569  C-------  C-------
# Line 1534  C     S11 - S21 Line 1578  C     S11 - S21
1578        DO I=1,3        DO I=1,3
1579           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1580        ENDDO        ENDDO
1581        F = dl/dist        F = dl/dist
1582    
1583  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
1584         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.
# Line 1543  C      IF (tof11_i.GT.none_find.AND.tof2 Line 1587  C      IF (tof11_i.GT.none_find.AND.tof2
1587           t2 = tof11(2,tof11_i,itdc)           t2 = tof11(2,tof11_i,itdc)
1588           t3 = tof21(1,tof21_i,itdc)           t3 = tof21(1,tof21_i,itdc)
1589           t4 = tof21(2,tof21_i,itdc)           t4 = tof21(2,tof21_i,itdc)
1590           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1591       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1592              xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)              xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
1593              xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)              xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1594              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1595              ihelp=(tof11_i-1)*2+tof21_i              ihelp=(tof11_i-1)*2+tof21_i
1596              c1 = k_S11S21(1,ihelp)              c1 = k_S11S21(1,ihelp)
1597                if (iz.gt.2) c1 = c1 + k1corrC1
1598              c2 = k_S11S21(2,ihelp)              c2 = k_S11S21(2,ihelp)
1599              beta_a(9) = c2*F/(ds-c1)              beta_a(9) = c2*F/(ds-c1)
1600    
# Line 1562  C-------ToF Mask - S11 - S21 Line 1607  C-------ToF Mask - S11 - S21
1607    
1608              tofmask(ch21a(tof21_i),hb21a(tof21_i)) =              tofmask(ch21a(tof21_i),hb21a(tof21_i)) =
1609       $           tofmask(ch21a(tof21_i),hb21a(tof21_i)) + 1       $           tofmask(ch21a(tof21_i),hb21a(tof21_i)) + 1
1610              tofmask(ch21b(tof21_i),hb21b(tof21_i)) =              tofmask(ch21b(tof21_i),hb21b(tof21_i)) =
1611       $           tofmask(ch21b(tof21_i),hb21b(tof21_i)) + 1       $           tofmask(ch21b(tof21_i),hb21b(tof21_i)) + 1
1612    
1613  C-------  C-------
1614    
1615           ENDIF           ENDIF
1616        ENDIF        ENDIF
1617          
1618  C     S11 - S22  C     S11 - S22
1619    
1620        dist = ZTOF(1) - ZTOF(4)        dist = ZTOF(1) - ZTOF(4)
# Line 1577  C     S11 - S22 Line 1622  C     S11 - S22
1622        DO I=1,4        DO I=1,4
1623           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1624        ENDDO        ENDDO
1625        F = dl/dist        F = dl/dist
1626    
1627  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
1628         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.
# Line 1586  C      IF (tof11_i.GT.none_find.AND.tof2 Line 1631  C      IF (tof11_i.GT.none_find.AND.tof2
1631           t2 = tof11(2,tof11_i,itdc)           t2 = tof11(2,tof11_i,itdc)
1632           t3 = tof22(1,tof22_i,itdc)           t3 = tof22(1,tof22_i,itdc)
1633           t4 = tof22(2,tof22_i,itdc)           t4 = tof22(2,tof22_i,itdc)
1634           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1635       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1636              xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)              xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
1637              xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)              xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1638              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1639              ihelp=(tof11_i-1)*2+tof22_i              ihelp=(tof11_i-1)*2+tof22_i
1640              c1 = k_S11S22(1,ihelp)              c1 = k_S11S22(1,ihelp)
1641                if (iz.gt.2) c1 = c1 + k1corrC1
1642              c2 = k_S11S22(2,ihelp)              c2 = k_S11S22(2,ihelp)
1643              beta_a(10) = c2*F/(ds-c1)              beta_a(10) = c2*F/(ds-c1)
1644    
# Line 1605  C-------ToF Mask - S11 - S22 Line 1651  C-------ToF Mask - S11 - S22
1651    
1652              tofmask(ch22a(tof22_i),hb22a(tof22_i)) =              tofmask(ch22a(tof22_i),hb22a(tof22_i)) =
1653       $           tofmask(ch22a(tof22_i),hb22a(tof22_i)) + 1       $           tofmask(ch22a(tof22_i),hb22a(tof22_i)) + 1
1654              tofmask(ch22b(tof22_i),hb22b(tof22_i)) =              tofmask(ch22b(tof22_i),hb22b(tof22_i)) =
1655       $           tofmask(ch22b(tof22_i),hb22b(tof22_i)) + 1       $           tofmask(ch22b(tof22_i),hb22b(tof22_i)) + 1
1656    
1657  C-------  C-------
# Line 1620  C     S12 - S21 Line 1666  C     S12 - S21
1666        DO I=2,3        DO I=2,3
1667           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1668        ENDDO        ENDDO
1669        F = dl/dist        F = dl/dist
1670    
1671  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
1672         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.
# Line 1629  C      IF (tof12_i.GT.none_find.AND.tof2 Line 1675  C      IF (tof12_i.GT.none_find.AND.tof2
1675           t2 = tof12(2,tof12_i,itdc)           t2 = tof12(2,tof12_i,itdc)
1676           t3 = tof21(1,tof21_i,itdc)           t3 = tof21(1,tof21_i,itdc)
1677           t4 = tof21(2,tof21_i,itdc)           t4 = tof21(2,tof21_i,itdc)
1678           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1679       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1680              xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)              xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1681              xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)              xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1682              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1683              ihelp=(tof12_i-1)*2+tof21_i              ihelp=(tof12_i-1)*2+tof21_i
1684              c1 = k_S12S21(1,ihelp)              c1 = k_S12S21(1,ihelp)
1685                if (iz.gt.2) c1 = c1 + k1corrC1
1686              c2 = k_S12S21(2,ihelp)              c2 = k_S12S21(2,ihelp)
1687              beta_a(11) = c2*F/(ds-c1)              beta_a(11) = c2*F/(ds-c1)
1688    
# Line 1648  C-------ToF Mask - S12 - S21 Line 1695  C-------ToF Mask - S12 - S21
1695    
1696              tofmask(ch21a(tof21_i),hb21a(tof21_i)) =              tofmask(ch21a(tof21_i),hb21a(tof21_i)) =
1697       $           tofmask(ch21a(tof21_i),hb21a(tof21_i)) + 1       $           tofmask(ch21a(tof21_i),hb21a(tof21_i)) + 1
1698              tofmask(ch21b(tof21_i),hb21b(tof21_i)) =              tofmask(ch21b(tof21_i),hb21b(tof21_i)) =
1699       $           tofmask(ch21b(tof21_i),hb21b(tof21_i)) + 1       $           tofmask(ch21b(tof21_i),hb21b(tof21_i)) + 1
1700    
1701  C-------  C-------
# Line 1663  C     S12 - S22 Line 1710  C     S12 - S22
1710        DO I=2,4        DO I=2,4
1711           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1712        ENDDO        ENDDO
1713        F = dl/dist        F = dl/dist
1714    
1715  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
1716         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.
# Line 1672  C      IF (tof12_i.GT.none_find.AND.tof2 Line 1719  C      IF (tof12_i.GT.none_find.AND.tof2
1719           t2 = tof12(2,tof12_i,itdc)           t2 = tof12(2,tof12_i,itdc)
1720           t3 = tof22(1,tof22_i,itdc)           t3 = tof22(1,tof22_i,itdc)
1721           t4 = tof22(2,tof22_i,itdc)           t4 = tof22(2,tof22_i,itdc)
1722           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1723       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1724              xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)              xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1725              xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)              xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1726              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1727              ihelp=(tof12_i-1)*2+tof22_i              ihelp=(tof12_i-1)*2+tof22_i
1728              c1 = k_S12S22(1,ihelp)              c1 = k_S12S22(1,ihelp)
1729                if (iz.gt.2) c1 = c1 + k1corrC1
1730              c2 = k_S12S22(2,ihelp)              c2 = k_S12S22(2,ihelp)
1731              beta_a(12) = c2*F/(ds-c1)              beta_a(12) = c2*F/(ds-c1)
1732    
# Line 1691  C-------ToF Mask - S12 - S22 Line 1739  C-------ToF Mask - S12 - S22
1739    
1740              tofmask(ch22a(tof22_i),hb22a(tof22_i)) =              tofmask(ch22a(tof22_i),hb22a(tof22_i)) =
1741       $           tofmask(ch22a(tof22_i),hb22a(tof22_i)) + 1       $           tofmask(ch22a(tof22_i),hb22a(tof22_i)) + 1
1742              tofmask(ch22b(tof22_i),hb22b(tof22_i)) =              tofmask(ch22b(tof22_i),hb22b(tof22_i)) =
1743       $           tofmask(ch22b(tof22_i),hb22b(tof22_i)) + 1       $           tofmask(ch22b(tof22_i),hb22b(tof22_i)) + 1
1744    
1745  C-------  C-------
1746    
1747           ENDIF           ENDIF
1748        ENDIF        ENDIF
1749          
1750  C-------  C-------
1751    C
1752    C      icount=0
1753    C      sw=0.
1754    C      sxw=0.
1755    C      beta_mean=100.
1756    C
1757    C      do i=1,12
1758    C         if ((beta_a(i).gt.-1.5).and.(beta_a(i).lt.1.5)) then
1759    C            icount= icount+1
1760    C            if (i.le.4) w_i=1./(0.13**2.)
1761    C            if ((i.ge.5).and.(i.le.8)) w_i=1./(0.16**2.)
1762    C            if (i.ge.9) w_i=1./(0.25**2.) ! to be checked
1763    C            sxw=sxw + beta_a(i)*w_i
1764    C            sw =sw + w_i
1765    C         endif
1766    C      enddo
1767    C
1768    C      if (icount.gt.0) beta_mean=sxw/sw
1769    C      beta_a(13) = beta_mean
1770    C
1771    
1772        icount=0  C-------  New mean beta  calculation
       sw=0.  
       sxw=0.  
       beta_mean=100.  
1773    
1774        do i=1,12         do i=1,12
1775           if ((beta_a(i).gt.-1.5).and.(beta_a(i).lt.1.5)) then           btemp(i) =  beta_a(i)
1776              icount= icount+1         enddo
1777              if (i.le.4) w_i=1./(0.13**2.)  
1778              if ((i.ge.5).and.(i.le.8)) w_i=1./(0.16**2.)         beta_a(13)=newbeta(2,btemp,hitvec,10.,10.,20.)
             if (i.ge.9) w_i=1./(0.25**2.) ! to be checked  
             sxw=sxw + beta_a(i)*w_i  
             sw =sw + w_i  
          endif  
       enddo  
         
       if (icount.gt.0) beta_mean=sxw/sw  
       beta_a(13) = beta_mean  
1779    
1780    C-------
1781    
1782  c       IF (tof11_i.GT.none_find)  
1783    c       IF (tof11_i.GT.none_find)
1784  c     &  write(*,*) '11 ',tof11(1,tof11_i,itdc),tof11(2,tof11_i,itdc)  c     &  write(*,*) '11 ',tof11(1,tof11_i,itdc),tof11(2,tof11_i,itdc)
1785  c       IF (tof12_i.GT.none_find)  c       IF (tof12_i.GT.none_find)
1786  c     &  write(*,*) '12 ',tof12(1,tof12_i,itdc),tof12(2,tof12_i,itdc)  c     &  write(*,*) '12 ',tof12(1,tof12_i,itdc),tof12(2,tof12_i,itdc)
1787    
1788  c       IF (tof21_i.GT.none_find)  c       IF (tof21_i.GT.none_find)
1789  c     &  write(*,*) '21 ',tof21(1,tof21_i,itdc),tof21(2,tof21_i,itdc)  c     &  write(*,*) '21 ',tof21(1,tof21_i,itdc),tof21(2,tof21_i,itdc)
1790  c       IF (tof22_i.GT.none_find)  c       IF (tof22_i.GT.none_find)
1791  c     &  write(*,*) '22 ',tof22(1,tof22_i,itdc),tof22(2,tof22_i,itdc)  c     &  write(*,*) '22 ',tof22(1,tof22_i,itdc),tof22(2,tof22_i,itdc)
1792    
1793  c       IF (tof31_i.GT.none_find)  c       IF (tof31_i.GT.none_find)
1794  c     &  write(*,*) '31 ',tof31(1,tof31_i,itdc),tof31(2,tof31_i,itdc)  c     &  write(*,*) '31 ',tof31(1,tof31_i,itdc),tof31(2,tof31_i,itdc)
1795  c       IF (tof32_i.GT.none_find)  c       IF (tof32_i.GT.none_find)
1796  c     &  write(*,*) '32 ',tof32(1,tof32_i,itdc),tof32(2,tof32_i,itdc)  c     &  write(*,*) '32 ',tof32(1,tof32_i,itdc),tof32(2,tof32_i,itdc)
1797    
1798  c      write(*,*) xtofpos  c      write(*,*) xtofpos
# Line 1748  c      write(*,*) xtr_tof Line 1807  c      write(*,*) xtr_tof
1807  c      write(*,*) ytr_tof  c      write(*,*) ytr_tof
1808    
1809    
   
1810        RETURN        RETURN
1811        END        END
1812    
# Line 1756  c      write(*,*) ytr_tof Line 1814  c      write(*,*) ytr_tof
1814    
1815    
1816  C------------------------------------------------------------------  C------------------------------------------------------------------
1817  C------------------------------------------------------------------  
1818    

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.23