/[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.8 by mocchiut, Mon Jan 22 10:45:26 2007 UTC revision 1.13 by mocchiut, Thu Aug 30 07:18:32 2007 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
28    C             was incorrect
29    C  jan-07 WM: bug fixed: in some cases tdc_tw was calculated due to a
30    C             leftover "xhelp" value
31    C  apr-07 WM: attenuation fit curve is now a double exponential fit
32    C             conversion from raw ADC to pC using calibration function
33    C             new variables xtr_tof(6) and ytr_tof(6) give track position
34    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  C
39  C****************************************************************************  C****************************************************************************
40        IMPLICIT NONE        IMPLICIT NONE
41  C      C
42        include  'input_tof.txt'        include  'input_tof.txt'
43        include  'output_tof.txt'        include  'output_tof.txt'
44        include  'tofcomm.txt'        include  'tofcomm.txt'
45  C      C
46          
47  c     =======================================  c     =======================================
48  c     variables for tracking routine  c     variables for tracking routine
49  c     =======================================  c     =======================================
# Line 53  c     define TOF Z-coordinates Line 64  c     define TOF Z-coordinates
64    
65    
66        INTEGER IFAIL        INTEGER IFAIL
67  c      REAL dx,dy,dr,xdummy  c      REAL dx,dy,dr
68        REAL ds        REAL ds
69        REAL t1,t2,t3,t4        REAL t1,t2,t3,t4
70        REAL yhelp,xhelp,xhelp1,xhelp2        REAL yhelp,xhelp,xhelp1,xhelp2
71        REAL c1,c2,sw,sxw,w_i        REAL c1,c2,sw,sxw,w_i
72        REAL dist,dl,F        REAL dist,dl,F
73        INTEGER icount,ievent        INTEGER icount,ievent
74        REAL xhelp_a,xhelp_t        REAL xhelp_a,xhelp_t
75    
76        REAL beta_mean        REAL beta_mean
77        REAL hepratio        REAL hepratio
78          
79        INTEGER j        INTEGER j
80    
81          real atten,pc_adc
82    
83    
84        REAL theta,phi        REAL theta,phi
85  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
86        REAL tofarm12        REAL tofarm12
87        PARAMETER (tofarm12 = 29.70) ! from 53.39 to 23.69        PARAMETER (tofarm12 = 29.70) ! from 53.39 to 23.69
88        REAL tofarm23                REAL tofarm23
89        PARAMETER (tofarm23 = 47.61) ! from 23.69 to -23.92        PARAMETER (tofarm23 = 47.61) ! from 23.69 to -23.92
90        REAL tofarm13        REAL tofarm13
91        PARAMETER (tofarm13 = 77.31) ! from 53.39 to -23.92        PARAMETER (tofarm13 = 77.31) ! from 53.39 to -23.92
92    
93          
94        INTEGER ihelp        INTEGER ihelp
95        REAL xkorr,xpos        REAL xkorr,xpos
96    
97        REAL yl,yh,xl,xh        REAL yl,yh,xl,xh
98  C      C
99        REAL hmemor(9000000)        REAL hmemor(9000000)
100        INTEGER Iquest(100)        INTEGER Iquest(100)
101  C      C
102        DATA ievent / 0 /        DATA ievent / 0 /
103    
104        COMMON / pawcd / hmemor        COMMON / pawcd / hmemor
105        save / pawcd /        save / pawcd /
106  C      C
107        Common / QUESTd / Iquest        Common / QUESTd / Iquest
108        save / questd /        save / questd /
109  C      C
110  C     Begin !  C     Begin !
111  C      C
112        TOFTRK = 0        TOFTRK = 0
113    
114  *******************************************************************  *******************************************************************
# Line 102  C     Line 116  C    
116        ievent = ievent +1        ievent = ievent +1
117    
118  C  ratio helium to proton ca. 4  C  ratio helium to proton ca. 4
119        hepratio = 4.5        hepratio = 4.
120    
121        offset = 1        offset = 1
122        slope = 2        slope = 2
# Line 145  C  ratio helium to proton ca. 4 Line 159  C  ratio helium to proton ca. 4
159    
160        pmt_id=0        pmt_id=0
161    
162          do j=1,6
163          THXOUT(j) = 0.
164          THYOUT(j) = 0.
165          enddo
166    
167          do j=1,6
168          xtr_tof(j) = 100.
169          ytr_tof(j) = 100.
170          enddo
171    
172  C----------------------------------------------------------------------  C----------------------------------------------------------------------
173  C-------------------------get ToF data --------------------------------  C-------------------------get ToF data --------------------------------
174  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
175  C     manipulated (Time-walk, artificila ADc and TDC values using ToF  C     manipulated (Time-walk, artificila ADc and TDC values using ToF
176  C     standalone information  C     standalone information
177  C----------------------------------------------------------------------  C----------------------------------------------------------------------
 C     put the adc and tdc values from ntuple into tofxx(i,j,k) variables  
178    
179    c     put the adc and tdc values from ntuple into tofxx(i,j,k) variables
180    
181        do j=1,8        do j=1,8
182           tof11(1,j,2) = adc(ch11a(j),hb11a(j))           tof11(1,j,2) = pc_adc(adc(ch11a(j),hb11a(j)))
183           tof11(2,j,2) = adc(ch11b(j),hb11b(j))           tof11(2,j,2) = pc_adc(adc(ch11b(j),hb11b(j)))
184           tof11(1,j,1) = tdc(ch11a(j),hb11a(j))           tof11(1,j,1) = (tdc(ch11a(j),hb11a(j)))
185           tof11(2,j,1) = tdc(ch11b(j),hb11b(j))           tof11(2,j,1) = (tdc(ch11b(j),hb11b(j)))
186        enddo        enddo
187    
188    
189        do j=1,6        do j=1,6
190           tof12(1,j,2) = adc(ch12a(j),hb12a(j))           tof12(1,j,2) = pc_adc(adc(ch12a(j),hb12a(j)))
191           tof12(2,j,2) = adc(ch12b(j),hb12b(j))           tof12(2,j,2) = pc_adc(adc(ch12b(j),hb12b(j)))
192           tof12(1,j,1) = tdc(ch12a(j),hb12a(j))           tof12(1,j,1) = (tdc(ch12a(j),hb12a(j)))
193           tof12(2,j,1) = tdc(ch12b(j),hb12b(j))           tof12(2,j,1) = (tdc(ch12b(j),hb12b(j)))
194        enddo        enddo
195    
196        do j=1,2        do j=1,2
197           tof21(1,j,2) = adc(ch21a(j),hb21a(j))           tof21(1,j,2) = pc_adc(adc(ch21a(j),hb21a(j)))
198           tof21(2,j,2) = adc(ch21b(j),hb21b(j))           tof21(2,j,2) = pc_adc(adc(ch21b(j),hb21b(j)))
199           tof21(1,j,1) = tdc(ch21a(j),hb21a(j))           tof21(1,j,1) = (tdc(ch21a(j),hb21a(j)))
200           tof21(2,j,1) = tdc(ch21b(j),hb21b(j))           tof21(2,j,1) = (tdc(ch21b(j),hb21b(j)))
201        enddo        enddo
202    
203        do j=1,2        do j=1,2
204           tof22(1,j,2) = adc(ch22a(j),hb22a(j))           tof22(1,j,2) = pc_adc(adc(ch22a(j),hb22a(j)))
205           tof22(2,j,2) = adc(ch22b(j),hb22b(j))           tof22(2,j,2) = pc_adc(adc(ch22b(j),hb22b(j)))
206           tof22(1,j,1) = tdc(ch22a(j),hb22a(j))           tof22(1,j,1) = (tdc(ch22a(j),hb22a(j)))
207           tof22(2,j,1) = tdc(ch22b(j),hb22b(j))           tof22(2,j,1) = (tdc(ch22b(j),hb22b(j)))
208        enddo        enddo
209    
210        do j=1,3        do j=1,3
211           tof31(1,j,2) = adc(ch31a(j),hb31a(j))           tof31(1,j,2) = pc_adc(adc(ch31a(j),hb31a(j)))
212           tof31(2,j,2) = adc(ch31b(j),hb31b(j))           tof31(2,j,2) = pc_adc(adc(ch31b(j),hb31b(j)))
213           tof31(1,j,1) = tdc(ch31a(j),hb31a(j))           tof31(1,j,1) = (tdc(ch31a(j),hb31a(j)))
214           tof31(2,j,1) = tdc(ch31b(j),hb31b(j))           tof31(2,j,1) = (tdc(ch31b(j),hb31b(j)))
215        enddo        enddo
216    
217        do j=1,3        do j=1,3
218           tof32(1,j,2) = adc(ch32a(j),hb32a(j))           tof32(1,j,2) = pc_adc(adc(ch32a(j),hb32a(j)))
219           tof32(2,j,2) = adc(ch32b(j),hb32b(j))           tof32(2,j,2) = pc_adc(adc(ch32b(j),hb32b(j)))
220           tof32(1,j,1) = tdc(ch32a(j),hb32a(j))           tof32(1,j,1) = (tdc(ch32a(j),hb32a(j)))
221           tof32(2,j,1) = tdc(ch32b(j),hb32b(j))           tof32(2,j,1) = (tdc(ch32b(j),hb32b(j)))
222        enddo        enddo
223    
224  C----------------------------------------------------------------------  C----------------------------------------------------------------------
# Line 242  C--------------------------------------- Line 266  C---------------------------------------
266           if (abs(tof32(2,i,iadc)).gt.10000.) tof32(2,i,iadc)= 10000.           if (abs(tof32(2,i,iadc)).gt.10000.) tof32(2,i,iadc)= 10000.
267        ENDDO        ENDDO
268    
269  C-------------------------------------------------------------------  C----------------------------------------------------------------------
270    
271  C------read  tracking routine  C------read  tracking routine
272  *     igoodevent = igoodevent+1  *     igoodevent = igoodevent+1
# Line 257  C     COPY THE ALFA VECTOR FROM AL_PP TO Line 281  C     COPY THE ALFA VECTOR FROM AL_PP TO
281           AL_P(i) = al_pp(i)           AL_P(i) = al_pp(i)
282        enddo        enddo
283    
284  c     write(*,*) AL_P  c      write(*,*) AL_P
285    
286        if (al_p(5).eq.0.) THEN        if (al_p(5).eq.0.) THEN
287           PRINT *,' TOF - WARNING F77: track with R = 0, discarded'           PRINT *,' TOF - WARNING F77: track with R = 0, discarded'
# Line 268  c     write(*,*) AL_P Line 292  c     write(*,*) AL_P
292  C     call DOTRACK(NPTOF,ZIN,XOUT,YOUT,AL_P,IFAIL)  C     call DOTRACK(NPTOF,ZIN,XOUT,YOUT,AL_P,IFAIL)
293        call DOTRACK2(NPTOF,ZIN,XOUT,YOUT,THXOUT,THYOUT,TLOUT,AL_P,IFAIL)        call DOTRACK2(NPTOF,ZIN,XOUT,YOUT,THXOUT,THYOUT,TLOUT,AL_P,IFAIL)
294    
   
295  C     write(*,*) (TLOUT(i),i=1,6)  C     write(*,*) (TLOUT(i),i=1,6)
296    
297        if(IFAIL.ne.0)then        if(IFAIL.ne.0)then
# Line 279  C     write(*,*) (TLOUT(i),i=1,6) Line 302  C     write(*,*) (TLOUT(i),i=1,6)
302    
303   969  continue   969  continue
304    
305    C---  Fill xtr_tof  and ytr_tof: positions from tracker at ToF layers
306          do j=1,6
307          xtr_tof(j) = XOUT(j)
308          ytr_tof(j) = YOUT(j)
309          enddo
310    
311    
312    C---  convert  angles to radian
313          do j=1,6
314          THXOUT(j) = 3.1415927*THXOUT(j)/180.
315          THYOUT(j) = 3.1415927*THYOUT(j)/180.
316          enddo
317    
318          do j=1,6
319    c      write (*,*) j,THXOUT(j),THYOUT(j)
320          enddo
321    
322    
323  C----------------------------------------------------------------------  C----------------------------------------------------------------------
324  C------------------  set ADC & TDC flag = 0    ------------------------  C------------------  set ADC & TDC flag = 0    ------------------------
# Line 348  c     DATA tof21_y/  3.75,-3.75/  ! padd Line 388  c     DATA tof21_y/  3.75,-3.75/  ! padd
388  c     DATA tof22_x/ -4.5,4.5/  c     DATA tof22_x/ -4.5,4.5/
389  c     DATA tof31_x/ -6.0,0.,6.0/  c     DATA tof31_x/ -6.0,0.,6.0/
390  c     DATA tof32_y/ -5.0,0.0,5.0/  c     DATA tof32_y/ -5.0,0.0,5.0/
391  c      c
392  c     S11 8 paddles  33.0 x 5.1 cm  c     S11 8 paddles  33.0 x 5.1 cm
393  c     S12 6 paddles  40.8 x 5.5 cm  c     S12 6 paddles  40.8 x 5.5 cm
394  c     S21 2 paddles  18.0 x 7.5 cm  c     S21 2 paddles  18.0 x 7.5 cm
# Line 379  C--------------S11 --------------------- Line 419  C--------------S11 ---------------------
419  C--------------S12 --------------------------------------  C--------------S12 --------------------------------------
420    
421        tof12_i = none_find        tof12_i = none_find
422          
423        xl = -40.8/2.        xl = -40.8/2.
424        xh =  40.8/2.        xh =  40.8/2.
425    
# Line 396  C--------------S12 --------------------- Line 436  C--------------S12 ---------------------
436  C--------------S21 --------------------------------------  C--------------S21 --------------------------------------
437    
438        tof21_i = none_find        tof21_i = none_find
439          
440        xl = -18./2.        xl = -18./2.
441        xh =  18./2.        xh =  18./2.
442    
# Line 413  C--------------S21 --------------------- Line 453  C--------------S21 ---------------------
453  C--------------S22 --------------------------------------  C--------------S22 --------------------------------------
454    
455        tof22_i = none_find        tof22_i = none_find
456          
457        yl = -15./2.        yl = -15./2.
458        yh =  15./2.        yh =  15./2.
459    
# Line 430  C--------------S22 --------------------- Line 470  C--------------S22 ---------------------
470  C--------------S31 --------------------------------------  C--------------S31 --------------------------------------
471    
472        tof31_i = none_find        tof31_i = none_find
473          
474        yl = -15.0/2.        yl = -15.0/2.
475        yh =  15.0/2.        yh =  15.0/2.
476    
# Line 447  C--------------S31 --------------------- Line 487  C--------------S31 ---------------------
487  C--------------S32 --------------------------------------  C--------------S32 --------------------------------------
488    
489        tof32_i = none_find        tof32_i = none_find
490          
491        xl = -18.0/2.        xl = -18.0/2.
492        xh =  18.0/2.        xh =  18.0/2.
493    
# Line 474  C--------------------------------------- Line 514  C---------------------------------------
514  C-----------------------S11 -----------------------------------------  C-----------------------S11 -----------------------------------------
515    
516        IF (tof11_i.GT.none_find) THEN        IF (tof11_i.GT.none_find) THEN
517           xpos = yout(1)           xpos = yout(1)
518           i = tof11_i           i = tof11_i
519           if ((tof11(1,tof11_i,itdc).EQ.4095).AND.           if ((tof11(1,tof11_i,itdc).EQ.4095).AND.
520       &        (tof11(2,tof11_i,itdc).LT.4095)) THEN         &        (tof11(2,tof11_i,itdc).LT.4095)) THEN
521    
522  c       write(*,*)'11lb4 ',i,tof11(1,tof11_i,itdc),tof11(2,tof11_i,itdc)  c       write(*,*)'11lb4 ',i,tof11(1,tof11_i,itdc),tof11(2,tof11_i,itdc)
523    
524              tof11(1,tof11_i,itdc) = tof11(2,tof11_i,itdc)              tof11(1,tof11_i,itdc) = tof11(2,tof11_i,itdc)
525       &           + 2*(y_coor_lin11(tof11_i,offset)       &           + 2*(y_coor_lin11(tof11_i,offset)
526       &           + xpos*y_coor_lin11(tof11_i,slope))       &           + xpos*y_coor_lin11(tof11_i,slope))
527    
528  c       write(*,*)'11laf ',i,tof11(1,tof11_i,itdc),tof11(2,tof11_i,itdc)  c       write(*,*)'11laf ',i,tof11(1,tof11_i,itdc),tof11(2,tof11_i,itdc)
529    
530              tdcflag(ch11a(i),hb11a(i)) = 1              tdcflag(ch11a(i),hb11a(i)) = 1
531      
532          ENDIF          ENDIF
533           if ((tof11(2,tof11_i,itdc).EQ.4095).AND.           if ((tof11(2,tof11_i,itdc).EQ.4095).AND.
534       &        (tof11(1,tof11_i,itdc).LT.4095)) THEN         &        (tof11(1,tof11_i,itdc).LT.4095)) THEN
535    
536  c       write(*,*)'11rb4 ',i,tof11(1,tof11_i,itdc),tof11(2,tof11_i,itdc)  c       write(*,*)'11rb4 ',i,tof11(1,tof11_i,itdc),tof11(2,tof11_i,itdc)
537    
538              tof11(2,tof11_i,itdc) = tof11(1,tof11_i,itdc)              tof11(2,tof11_i,itdc) = tof11(1,tof11_i,itdc)
539       &           - 2*(y_coor_lin11(tof11_i,offset)       &           - 2*(y_coor_lin11(tof11_i,offset)
540       &           + xpos*y_coor_lin11(tof11_i,slope))       &           + xpos*y_coor_lin11(tof11_i,slope))
541  c       write(*,*)'11raf ',i,tof11(1,tof11_i,itdc),tof11(2,tof11_i,itdc)  c       write(*,*)'11raf ',i,tof11(1,tof11_i,itdc),tof11(2,tof11_i,itdc)
542    
543              tdcflag(ch11b(i),hb11b(i)) = 1              tdcflag(ch11b(i),hb11b(i)) = 1
544           ENDIF               ENDIF
545        ENDIF        ENDIF
546    
547  C-----------------------S12 -----------------------------------------  C-----------------------S12 -----------------------------------------
548    
549        IF (tof12_i.GT.none_find) THEN        IF (tof12_i.GT.none_find) THEN
550           xpos = xout(2)           xpos = xout(2)
551           i = tof12_i           i = tof12_i
552           if ((tof12(1,tof12_i,itdc).EQ.4095).AND.           if ((tof12(1,tof12_i,itdc).EQ.4095).AND.
553       &        (tof12(2,tof12_i,itdc).LT.4095)) THEN       &        (tof12(2,tof12_i,itdc).LT.4095)) THEN
# Line 524  C-----------------------S12 ------------ Line 564  C-----------------------S12 ------------
564              tdcflag(ch12b(i),hb12b(i)) = 1              tdcflag(ch12b(i),hb12b(i)) = 1
565           ENDIF           ENDIF
566        ENDIF        ENDIF
567          
568  C-----------------------S21 -----------------------------------------  C-----------------------S21 -----------------------------------------
569    
570        IF (tof21_i.GT.none_find) THEN        IF (tof21_i.GT.none_find) THEN
571           xpos = xout(3)           xpos = xout(3)
572           i = tof21_i           i = tof21_i
573           if ((tof21(1,tof21_i,itdc).EQ.4095).AND.           if ((tof21(1,tof21_i,itdc).EQ.4095).AND.
574       &        (tof21(2,tof21_i,itdc).LT.4095)) THEN       &        (tof21(2,tof21_i,itdc).LT.4095)) THEN
# Line 549  C-----------------------S21 ------------ Line 589  C-----------------------S21 ------------
589  C-----------------------S22 -----------------------------------------  C-----------------------S22 -----------------------------------------
590    
591        IF (tof22_i.GT.none_find) THEN        IF (tof22_i.GT.none_find) THEN
592           xpos = yout(4)           xpos = yout(4)
593           i = tof22_i           i = tof22_i
594           if ((tof22(1,tof22_i,itdc).EQ.4095).AND.           if ((tof22(1,tof22_i,itdc).EQ.4095).AND.
595       &        (tof22(2,tof22_i,itdc).LT.4095)) THEN       &        (tof22(2,tof22_i,itdc).LT.4095)) THEN
# Line 568  C-----------------------S22 ------------ Line 608  C-----------------------S22 ------------
608        ENDIF        ENDIF
609    
610  C-----------------------S31 -----------------------------------------  C-----------------------S31 -----------------------------------------
611          
612        IF (tof31_i.GT.none_find) THEN        IF (tof31_i.GT.none_find) THEN
613           xpos = yout(5)           xpos = yout(5)
614           i = tof31_i           i = tof31_i
615           if ((tof31(1,tof31_i,itdc).EQ.4095).AND.           if ((tof31(1,tof31_i,itdc).EQ.4095).AND.
616       &        (tof31(2,tof31_i,itdc).LT.4095)) THEN       &        (tof31(2,tof31_i,itdc).LT.4095)) THEN
# Line 591  C-----------------------S31 ------------ Line 631  C-----------------------S31 ------------
631  C-----------------------S32 -----------------------------------------  C-----------------------S32 -----------------------------------------
632    
633        IF (tof32_i.GT.none_find) THEN        IF (tof32_i.GT.none_find) THEN
634           xpos = xout(6)           xpos = xout(6)
635           i = tof32_i           i = tof32_i
636           if ((tof32(1,tof32_i,itdc).EQ.4095).AND.           if ((tof32(1,tof32_i,itdc).EQ.4095).AND.
637       &        (tof32(2,tof32_i,itdc).LT.4095)) THEN       &        (tof32(2,tof32_i,itdc).LT.4095)) THEN
# Line 610  C-----------------------S32 ------------ Line 650  C-----------------------S32 ------------
650        ENDIF        ENDIF
651    
652  C--------------------------------------------------------------------  C--------------------------------------------------------------------
653  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  
654  C--------------------------------------------------------------------  C--------------------------------------------------------------------
655  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
656  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 626  C----------------------------S1 -------- Line 665  C----------------------------S1 --------
665        yhelp=yout(1)        yhelp=yout(1)
666        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
667           i = tof11_i           i = tof11_i
668           if (tof11(left,i,iadc).eq.4095) then           if ((tof11(left,tof11_i,itdc).LT.4095).AND.
669              phi   = atan(tan(THXOUT(1))/tan(THYOUT(1)))       &       (adc(ch11a(i),hb11a(i)).eq.4095)) then
670  c            theta = atan(tan(THXOUT(1))/cos(phi)              phi   = atan(tan(THYOUT(1))/tan(THXOUT(1)))
671              theta = atan(tan(THXOUT(1))/cos(phi))              theta = atan(tan(THXOUT(1))/cos(phi))
672              xkorr=adcx11(left,i,1)*exp(-yhelp/adcx11(left,i,2))  c            xkorr=adcx11(left,i,1)*exp(-yhelp/adcx11(left,i,2))
673              xkorr=xkorr/hepratio                          xkorr = atten(left,11,i,yhelp)
674                xkorr=xkorr/hepratio
675              tof11(left,i,iadc)=xkorr/cos(theta)              tof11(left,i,iadc)=xkorr/cos(theta)
676              adcflag(ch11a(i),hb11a(i)) = 1              adcflag(ch11a(i),hb11a(i)) = 1
677           endif           endif
678           if (tof11(right,i,iadc).eq.4095) then           if ((tof11(right,tof11_i,itdc).LT.4095).AND.
679              phi   = atan(tan(THXOUT(1))/tan(THYOUT(1)))       &       (adc(ch11b(i),hb11b(i)).eq.4095)) then
680  c            theta = atan(tan(THXOUT(1))/cos(phi)              phi   = atan(tan(THYOUT(1))/tan(THXOUT(1)))
681              theta = atan(tan(THXOUT(1))/cos(phi))              theta = atan(tan(THXOUT(1))/cos(phi))
682              xkorr=adcx11(right,i,1)*exp(yhelp/adcx11(right,i,2))  c            xkorr=adcx11(right,i,1)*exp(yhelp/adcx11(right,i,2))
683              xkorr=xkorr/hepratio                          xkorr = atten(right,11,i,yhelp)
684                xkorr=xkorr/hepratio
685              tof11(right,i,iadc)=xkorr/cos(theta)              tof11(right,i,iadc)=xkorr/cos(theta)
686              adcflag(ch11b(i),hb11b(i)) = 1              adcflag(ch11b(i),hb11b(i)) = 1
687           endif           endif
# Line 649  c            theta = atan(tan(THXOUT(1)) Line 690  c            theta = atan(tan(THXOUT(1))
690        xhelp=xout(2)        xhelp=xout(2)
691        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
692           i = tof12_i           i = tof12_i
693           if (tof12(left,i,iadc).eq.4095) then           if ((tof12(left,tof12_i,itdc).LT.4095).AND.
694              phi   = atan(tan(THXOUT(2))/tan(THYOUT(2)))       &       (adc(ch12a(i),hb12a(i)).eq.4095)) then
695  c            theta = atan(tan(THXOUT(2))/cos(phi)              phi   = atan(tan(THYOUT(2))/tan(THXOUT(2)))
696              theta = atan(tan(THXOUT(2))/cos(phi))              theta = atan(tan(THXOUT(2))/cos(phi))
697              xkorr=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2))  c            xkorr=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2))
698              xkorr=xkorr/hepratio                          xkorr = atten(left,12,i,xhelp)
699                xkorr=xkorr/hepratio
700              tof12(left,i,iadc) = xkorr/cos(theta)              tof12(left,i,iadc) = xkorr/cos(theta)
701              adcflag(ch12a(i),hb12a(i)) = 1              adcflag(ch12a(i),hb12a(i)) = 1
702           endif           endif
703           if (tof12(right,i,iadc).eq.4095) then           if ((tof12(right,tof12_i,itdc).LT.4095).AND.
704              phi   = atan(tan(THXOUT(2))/tan(THYOUT(2)))       &       (adc(ch12b(i),hb12b(i)).eq.4095)) then
705  c            theta = atan(tan(THXOUT(2))/cos(phi)              phi   = atan(tan(THYOUT(2))/tan(THXOUT(2)))
706              theta = atan(tan(THXOUT(2))/cos(phi))              theta = atan(tan(THXOUT(2))/cos(phi))
707              xkorr=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2))  c            xkorr=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2))
708              xkorr=xkorr/hepratio                          xkorr = atten(right,12,i,xhelp)
709                xkorr=xkorr/hepratio
710              tof12(right,i,iadc) = xkorr/cos(theta)              tof12(right,i,iadc) = xkorr/cos(theta)
711              adcflag(ch12b(i),hb12b(i)) = 1              adcflag(ch12b(i),hb12b(i)) = 1
712           endif           endif
# Line 674  C-----------------------------S2 ------- Line 717  C-----------------------------S2 -------
717        xhelp=xout(3)        xhelp=xout(3)
718        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
719           i = tof21_i           i = tof21_i
720           if (tof21(left,i,iadc).eq.4095) then           if ((tof21(left,tof21_i,itdc).LT.4095).AND.
721              phi   = atan(tan(THXOUT(3))/tan(THYOUT(3)))       &       (adc(ch21a(i),hb21a(i)).eq.4095)) then
722  c            theta = atan(tan(THXOUT(3))/cos(phi)              phi   = atan(tan(THYOUT(3))/tan(THXOUT(3)))
723              theta = atan(tan(THXOUT(3))/cos(phi))              theta = atan(tan(THXOUT(3))/cos(phi))
724              xkorr=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2))  c            xkorr=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2))
725              xkorr=xkorr/hepratio                          xkorr = atten(left,21,i,xhelp)
726                xkorr=xkorr/hepratio
727              tof21(left,i,iadc) = xkorr/cos(theta)              tof21(left,i,iadc) = xkorr/cos(theta)
728              adcflag(ch21a(i),hb21a(i)) = 1              adcflag(ch21a(i),hb21a(i)) = 1
729           endif           endif
730           if (tof21(right,i,iadc).eq.4095) then           if ((tof21(right,tof21_i,itdc).LT.4095).AND.
731              phi   = atan(tan(THXOUT(3))/tan(THYOUT(3)))       &       (adc(ch21b(i),hb21b(i)).eq.4095)) then
732  c            theta = atan(tan(THXOUT(3))/cos(phi)              phi   = atan(tan(THYOUT(3))/tan(THXOUT(3)))
733              theta = atan(tan(THXOUT(3))/cos(phi))              theta = atan(tan(THXOUT(3))/cos(phi))
734              xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2))  c            xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2))
735              xkorr=xkorr/hepratio                          xkorr = atten(right,21,i,xhelp)
736                xkorr=xkorr/hepratio
737              tof21(right,i,iadc) = xkorr/cos(theta)              tof21(right,i,iadc) = xkorr/cos(theta)
738              adcflag(ch21b(i),hb21b(i)) = 1              adcflag(ch21b(i),hb21b(i)) = 1
739           endif           endif
# Line 698  c            theta = atan(tan(THXOUT(3)) Line 743  c            theta = atan(tan(THXOUT(3))
743        yhelp=yout(4)        yhelp=yout(4)
744        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
745           i = tof22_i           i = tof22_i
746           if (tof22(left,i,iadc).eq.4095) then           if ((tof22(left,tof22_i,itdc).LT.4095).AND.
747              phi   = atan(tan(THXOUT(4))/tan(THYOUT(4)))       &       (adc(ch22a(i),hb22a(i)).eq.4095)) then
748  c            theta = atan(tan(THXOUT(4))/cos(phi)              phi   = atan(tan(THYOUT(4))/tan(THXOUT(4)))
749              theta = atan(tan(THXOUT(4))/cos(phi))              theta = atan(tan(THXOUT(4))/cos(phi))
750              xkorr=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2))  c            xkorr=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2))
751              xkorr=xkorr/hepratio                          xkorr = atten(left,22,i,yhelp)
752                xkorr=xkorr/hepratio
753              tof22(left,i,iadc) = xkorr/cos(theta)              tof22(left,i,iadc) = xkorr/cos(theta)
754              adcflag(ch22a(i),hb22a(i)) = 1              adcflag(ch22a(i),hb22a(i)) = 1
755           endif           endif
756           if (tof22(right,i,iadc).eq.4095) then           if ((tof22(right,tof22_i,itdc).LT.4095).AND.
757              phi   = atan(tan(THXOUT(4))/tan(THYOUT(4)))       &       (adc(ch22b(i),hb22b(i)).eq.4095)) then
758  c            theta = atan(tan(THXOUT(4))/cos(phi)              phi   = atan(tan(THYOUT(4))/tan(THXOUT(4)))
759              theta = atan(tan(THXOUT(4))/cos(phi))              theta = atan(tan(THXOUT(4))/cos(phi))
760              xkorr=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2))  c            xkorr=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2))
761              xkorr=xkorr/hepratio                          xkorr = atten(right,22,i,yhelp)
762                xkorr=xkorr/hepratio
763              tof22(right,i,iadc) = xkorr/cos(theta)              tof22(right,i,iadc) = xkorr/cos(theta)
764              adcflag(ch22b(i),hb22b(i)) = 1              adcflag(ch22b(i),hb22b(i)) = 1
765           endif           endif
# Line 723  C-----------------------------S3 ------- Line 770  C-----------------------------S3 -------
770        yhelp=yout(5)        yhelp=yout(5)
771        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
772           i = tof31_i           i = tof31_i
773           if (tof31(left,i,iadc).eq.4095) then           if ((tof31(left,tof31_i,itdc).LT.4095).AND.
774              phi   = atan(tan(THXOUT(5))/tan(THYOUT(5)))       &       (adc(ch31a(i),hb31a(i)).eq.4095)) then
775  c            theta = atan(tan(THXOUT(5))/cos(phi)              phi   = atan(tan(THYOUT(5))/tan(THXOUT(5)))
776              theta = atan(tan(THXOUT(5))/cos(phi))              theta = atan(tan(THXOUT(5))/cos(phi))
777              xkorr=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2))  c            xkorr=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2))
778              xkorr=xkorr/hepratio                          xkorr = atten(left,31,i,yhelp)
779                xkorr=xkorr/hepratio
780              tof31(left,i,iadc) = xkorr/cos(theta)              tof31(left,i,iadc) = xkorr/cos(theta)
781              adcflag(ch31a(i),hb31a(i)) = 1              adcflag(ch31a(i),hb31a(i)) = 1
782           endif           endif
783           if (tof31(right,i,iadc).eq.4095) then           if ((tof31(right,tof31_i,itdc).LT.4095).AND.
784              phi   = atan(tan(THXOUT(5))/tan(THYOUT(5)))       &       (adc(ch31b(i),hb31b(i)).eq.4095)) then
785  c            theta = atan(tan(THXOUT(5))/cos(phi)                phi   = atan(tan(THYOUT(5))/tan(THXOUT(5)))
786              theta = atan(tan(THXOUT(5))/cos(phi))              theta = atan(tan(THXOUT(5))/cos(phi))
787              xkorr=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2))  c            xkorr=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2))
788              xkorr=xkorr/hepratio                          xkorr = atten(right,31,i,yhelp)
789                xkorr=xkorr/hepratio
790              tof31(right,i,iadc) = xkorr/cos(theta)              tof31(right,i,iadc) = xkorr/cos(theta)
791              adcflag(ch31b(i),hb31b(i)) = 1              adcflag(ch31b(i),hb31b(i)) = 1
792           endif           endif
# Line 747  c            theta = atan(tan(THXOUT(5)) Line 796  c            theta = atan(tan(THXOUT(5))
796        xhelp=xout(6)        xhelp=xout(6)
797        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
798           i = tof32_i           i = tof32_i
799           if (tof32(left,i,iadc).eq.4095) then           if ((tof32(left,tof32_i,itdc).LT.4095).AND.
800              phi   = atan(tan(THXOUT(6))/tan(THYOUT(6)))       &       (adc(ch32a(i),hb32a(i)).eq.4095)) then
801  c            theta = atan(tan(THXOUT(6))/cos(phi)              phi   = atan(tan(THYOUT(6))/tan(THXOUT(6)))
802              theta = atan(tan(THXOUT(6))/cos(phi))              theta = atan(tan(THXOUT(6))/cos(phi))
803              xkorr=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2))  c            xkorr=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2))
804              xkorr=xkorr/hepratio                          xkorr = atten(left,32,i,xhelp)
805                xkorr=xkorr/hepratio
806              tof32(left,i,iadc) = xkorr/cos(theta)              tof32(left,i,iadc) = xkorr/cos(theta)
807              adcflag(ch32a(i),hb32a(i)) = 1              adcflag(ch32a(i),hb32a(i)) = 1
808           endif           endif
809           if (tof32(right,i,iadc).eq.4095) then           if ((tof32(right,tof32_i,itdc).LT.4095).AND.
810              phi   = atan(tan(THXOUT(6))/tan(THYOUT(6)))       &       (adc(ch32b(i),hb32b(i)).eq.4095)) then
811  c            theta = atan(tan(THXOUT(6))/cos(phi)              phi   = atan(tan(THYOUT(6))/tan(THXOUT(6)))
812              theta = atan(tan(THXOUT(6))/cos(phi))              theta = atan(tan(THXOUT(6))/cos(phi))
813              xkorr=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2))  c            xkorr=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2))
814              xkorr=xkorr/hepratio                          xkorr = atten(right,32,i,xhelp)
815                xkorr=xkorr/hepratio
816              tof32(right,i,iadc) = xkorr/cos(theta)              tof32(right,i,iadc) = xkorr/cos(theta)
817              adcflag(ch32b(i),hb32b(i)) = 1              adcflag(ch32b(i),hb32b(i)) = 1
818           endif           endif
# Line 775  C--------------------------------------- Line 826  C---------------------------------------
826        do i=1,3        do i=1,3
827           xtofpos(i)=100.           xtofpos(i)=100.
828           ytofpos(i)=100.           ytofpos(i)=100.
829        enddo        enddo
830  C-----------------------------S1 --------------------------------  C-----------------------------S1 --------------------------------
831          
832        IF (tof11_i.GT.none_find) THEN        IF (tof11_i.GT.none_find) THEN
833           IF ((tof11(1,tof11_i,itdc).NE.4095).AND.           IF ((tof11(1,tof11_i,itdc).NE.4095).AND.
834       &       (tof11(2,tof11_i,itdc).NE.4095)) THEN       &       (tof11(2,tof11_i,itdc).NE.4095)) THEN
# Line 794  C-----------------------------S1 ------- Line 845  C-----------------------------S1 -------
845       +        -x_coor_lin12(tof12_i,offset))/x_coor_lin12(tof12_i,slope)       +        -x_coor_lin12(tof12_i,offset))/x_coor_lin12(tof12_i,slope)
846          if (abs(xtofpos(1)).gt.31.)  xtofpos(1)=101.          if (abs(xtofpos(1)).gt.31.)  xtofpos(1)=101.
847        endif        endif
848        endif              endif
849          
850  C-----------------------------S2 --------------------------------  C-----------------------------S2 --------------------------------
851          
852        IF (tof21_i.GT.none_find) THEN        IF (tof21_i.GT.none_find) THEN
853           IF ((tof21(1,tof21_i,itdc).NE.4095).AND.           IF ((tof21(1,tof21_i,itdc).NE.4095).AND.
854       &       (tof21(2,tof21_i,itdc).NE.4095)) THEN       &       (tof21(2,tof21_i,itdc).NE.4095)) THEN
855           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.
856       +        -x_coor_lin21(tof21_i,offset))/x_coor_lin21(tof21_i,slope)       +        -x_coor_lin21(tof21_i,offset))/x_coor_lin21(tof21_i,slope)
857          if (abs(xtofpos(2)).gt.19.)  xtofpos(2)=101.          if (abs(xtofpos(2)).gt.19.)  xtofpos(2)=101.
858        endif        endif
859        endif        endif
860    
# Line 814  C-----------------------------S2 ------- Line 865  C-----------------------------S2 -------
865       +        -y_coor_lin22(tof22_i,offset))/y_coor_lin22(tof22_i,slope)       +        -y_coor_lin22(tof22_i,offset))/y_coor_lin22(tof22_i,slope)
866          if (abs(ytofpos(2)).gt.18.)  ytofpos(2)=101.          if (abs(ytofpos(2)).gt.18.)  ytofpos(2)=101.
867        endif        endif
868        endif              endif
869          
870  C-----------------------------S3 --------------------------------  C-----------------------------S3 --------------------------------
871          
872        IF (tof31_i.GT.none_find) THEN        IF (tof31_i.GT.none_find) THEN
873           IF ((tof31(1,tof31_i,itdc).NE.4095).AND.           IF ((tof31(1,tof31_i,itdc).NE.4095).AND.
874       &       (tof31(2,tof31_i,itdc).NE.4095)) THEN       &       (tof31(2,tof31_i,itdc).NE.4095)) THEN
# Line 834  C-----------------------------S3 ------- Line 885  C-----------------------------S3 -------
885       +        -x_coor_lin32(tof32_i,offset))/x_coor_lin32(tof32_i,slope)       +        -x_coor_lin32(tof32_i,offset))/x_coor_lin32(tof32_i,slope)
886          if (abs(xtofpos(3)).gt.19.)  xtofpos(3)=101.          if (abs(xtofpos(3)).gt.19.)  xtofpos(3)=101.
887        endif        endif
888        endif        endif
889          
890  c      do i=1,3  c      do i=1,3
891  c         if (abs(xtofpos(i)).gt.100.) then  c         if (abs(xtofpos(i)).gt.100.) then
892  c            xtofpos(i)=101.  c            xtofpos(i)=101.
# Line 843  c         endif Line 894  c         endif
894  c         if (abs(ytofpos(i)).gt.100.) then  c         if (abs(ytofpos(i)).gt.100.) then
895  c            ytofpos(i)=101.  c            ytofpos(i)=101.
896  c         endif  c         endif
897  c      enddo  c      enddo
898          
899    
900    
901    
# Line 852  C--------------------------------------- Line 903  C---------------------------------------
903  C--------------------Time walk correction  -------------------------  C--------------------Time walk correction  -------------------------
904  C--------------------------------------------------------------------  C--------------------------------------------------------------------
905    
906    
907        DO i=1,8        DO i=1,8
908             xhelp= 0.
909           xhelp_a = tof11(left,i,iadc)           xhelp_a = tof11(left,i,iadc)
910           xhelp_t = tof11(left,i,itdc)           xhelp_t = tof11(left,i,itdc)
911           if(xhelp_a<4095) xhelp = tw11(left,i)/sqrt(xhelp_a)  c          if (xhelp_a .eq.0) write (*,*) 'trk 11 ',i,xhelp_a
912    
913             if(xhelp_a<3786) xhelp = tw11(left,i)/sqrt(xhelp_a)
914           tof11(left,i,itdc) = xhelp_t  + xhelp           tof11(left,i,itdc) = xhelp_t  + xhelp
915           tdc_c(ch11a(i),hb11a(i))=tof11(left,i,itdc)           tdc_c(ch11a(i),hb11a(i))=tof11(left,i,itdc)
916           xhelp_a = tof11(right,i,iadc)           xhelp_a = tof11(right,i,iadc)
917           xhelp_t = tof11(right,i,itdc)           xhelp_t = tof11(right,i,itdc)
918           if(xhelp_a<4095) xhelp = tw11(right,i)/sqrt(xhelp_a)           if(xhelp_a<3786) xhelp = tw11(right,i)/sqrt(xhelp_a)
919           tof11(right,i,itdc) = xhelp_t  + xhelp           tof11(right,i,itdc) = xhelp_t  + xhelp
920           tdc_c(ch11b(i),hb11b(i))=tof11(right,i,itdc)           tdc_c(ch11b(i),hb11b(i))=tof11(right,i,itdc)
921        ENDDO        ENDDO
922    
923        DO i=1,6        DO i=1,6
924             xhelp= 0.
925           xhelp_a = tof12(left,i,iadc)           xhelp_a = tof12(left,i,iadc)
926           xhelp_t = tof12(left,i,itdc)           xhelp_t = tof12(left,i,itdc)
927           if(xhelp_a<4095) xhelp = tw12(left,i)/sqrt(xhelp_a)  c          if (xhelp_a .eq.0) write (*,*) 'trk 12 ',i,xhelp_a
928             if(xhelp_a<3786) xhelp = tw12(left,i)/sqrt(xhelp_a)
929           tof12(left,i,itdc) = xhelp_t  + xhelp           tof12(left,i,itdc) = xhelp_t  + xhelp
930           tdc_c(ch12a(i),hb12a(i))=tof12(left,i,itdc)           tdc_c(ch12a(i),hb12a(i))=tof12(left,i,itdc)
931           xhelp_a = tof12(right,i,iadc)           xhelp_a = tof12(right,i,iadc)
932           xhelp_t = tof12(right,i,itdc)           xhelp_t = tof12(right,i,itdc)
933           if(xhelp_a<4095) xhelp = tw12(right,i)/sqrt(xhelp_a)           if(xhelp_a<3786) xhelp = tw12(right,i)/sqrt(xhelp_a)
934           tof12(right,i,itdc) = xhelp_t  + xhelp           tof12(right,i,itdc) = xhelp_t  + xhelp
935           tdc_c(ch12b(i),hb12b(i))=tof12(right,i,itdc)           tdc_c(ch12b(i),hb12b(i))=tof12(right,i,itdc)
936        ENDDO        ENDDO
937  C----  C----
938        DO i=1,2        DO i=1,2
939             xhelp= 0.
940           xhelp_a = tof21(left,i,iadc)           xhelp_a = tof21(left,i,iadc)
941           xhelp_t = tof21(left,i,itdc)           xhelp_t = tof21(left,i,itdc)
942           if(xhelp_a<4095) xhelp = tw21(left,i)/sqrt(xhelp_a)  c          if (xhelp_a .eq.0) write (*,*) ' trk 21 ',i,xhelp_a
943    
944             if(xhelp_a<3786) xhelp = tw21(left,i)/sqrt(xhelp_a)
945           tof21(left,i,itdc) = xhelp_t  + xhelp           tof21(left,i,itdc) = xhelp_t  + xhelp
946           tdc_c(ch21a(i),hb21a(i))=tof21(left,i,itdc)           tdc_c(ch21a(i),hb21a(i))=tof21(left,i,itdc)
947           xhelp_a = tof21(right,i,iadc)           xhelp_a = tof21(right,i,iadc)
948           xhelp_t = tof21(right,i,itdc)           xhelp_t = tof21(right,i,itdc)
949           if(xhelp_a<4095) xhelp = tw21(right,i)/sqrt(xhelp_a)           if(xhelp_a<3786) xhelp = tw21(right,i)/sqrt(xhelp_a)
950           tof21(right,i,itdc) = xhelp_t  + xhelp           tof21(right,i,itdc) = xhelp_t  + xhelp
951           tdc_c(ch21b(i),hb21b(i))=tof21(right,i,itdc)           tdc_c(ch21b(i),hb21b(i))=tof21(right,i,itdc)
952        ENDDO        ENDDO
953    
954        DO i=1,2        DO i=1,2
955             xhelp= 0.
956           xhelp_a = tof22(left,i,iadc)           xhelp_a = tof22(left,i,iadc)
957           xhelp_t = tof22(left,i,itdc)           xhelp_t = tof22(left,i,itdc)
958           if(xhelp_a<4095) xhelp = tw22(left,i)/sqrt(xhelp_a)  c          if (xhelp_a .eq.0) write (*,*) ' trk 22 ',i,xhelp_a
959             if(xhelp_a<3786) xhelp = tw22(left,i)/sqrt(xhelp_a)
960           tof22(left,i,itdc) = xhelp_t  + xhelp           tof22(left,i,itdc) = xhelp_t  + xhelp
961           tdc_c(ch22a(i),hb22a(i))=tof22(left,i,itdc)           tdc_c(ch22a(i),hb22a(i))=tof22(left,i,itdc)
962           xhelp_a = tof22(right,i,iadc)           xhelp_a = tof22(right,i,iadc)
963           xhelp_t = tof22(right,i,itdc)           xhelp_t = tof22(right,i,itdc)
964           if(xhelp_a<4095) xhelp = tw22(right,i)/sqrt(xhelp_a)           if(xhelp_a<3786) xhelp = tw22(right,i)/sqrt(xhelp_a)
965           tof22(right,i,itdc) = xhelp_t  + xhelp           tof22(right,i,itdc) = xhelp_t  + xhelp
966           tdc_c(ch22b(i),hb22b(i))=tof22(right,i,itdc)           tdc_c(ch22b(i),hb22b(i))=tof22(right,i,itdc)
967        ENDDO        ENDDO
968  C----  C----
969    
970        DO i=1,3        DO i=1,3
971             xhelp= 0.
972           xhelp_a = tof31(left,i,iadc)           xhelp_a = tof31(left,i,iadc)
973           xhelp_t = tof31(left,i,itdc)           xhelp_t = tof31(left,i,itdc)
974           if(xhelp_a<4095) xhelp = tw31(left,i)/sqrt(xhelp_a)  c          if (xhelp_a .eq.0) write (*,*) ' trk 31 ',i,xhelp_a
975    
976             if(xhelp_a<3786) xhelp = tw31(left,i)/sqrt(xhelp_a)
977           tof31(left,i,itdc) = xhelp_t  + xhelp           tof31(left,i,itdc) = xhelp_t  + xhelp
978           tdc_c(ch31a(i),hb31a(i))=tof31(left,i,itdc)           tdc_c(ch31a(i),hb31a(i))=tof31(left,i,itdc)
979           xhelp_a = tof31(right,i,iadc)           xhelp_a = tof31(right,i,iadc)
980           xhelp_t = tof31(right,i,itdc)           xhelp_t = tof31(right,i,itdc)
981           if(xhelp_a<4095) xhelp = tw31(right,i)/sqrt(xhelp_a)           if(xhelp_a<3786) xhelp = tw31(right,i)/sqrt(xhelp_a)
982           tof31(right,i,itdc) = xhelp_t  + xhelp           tof31(right,i,itdc) = xhelp_t  + xhelp
983           tdc_c(ch31b(i),hb31b(i))=tof31(right,i,itdc)           tdc_c(ch31b(i),hb31b(i))=tof31(right,i,itdc)
984        ENDDO        ENDDO
985    
986        DO i=1,3        DO i=1,3
987             xhelp= 0.
988           xhelp_a = tof32(left,i,iadc)           xhelp_a = tof32(left,i,iadc)
989           xhelp_t = tof32(left,i,itdc)           xhelp_t = tof32(left,i,itdc)
990           if(xhelp_a<4095) xhelp = tw32(left,i)/sqrt(xhelp_a)  c          if (xhelp_a .eq.0) write (*,*) ' trk 32 ',i,xhelp_a
991    
992             if(xhelp_a<3786) xhelp = tw32(left,i)/sqrt(xhelp_a)
993           tof32(left,i,itdc) = xhelp_t  + xhelp           tof32(left,i,itdc) = xhelp_t  + xhelp
994           tdc_c(ch32a(i),hb32a(i))=tof32(left,i,itdc)           tdc_c(ch32a(i),hb32a(i))=tof32(left,i,itdc)
995           xhelp_a = tof32(right,i,iadc)           xhelp_a = tof32(right,i,iadc)
996           xhelp_t = tof32(right,i,itdc)           xhelp_t = tof32(right,i,itdc)
997           if(xhelp_a<4095) xhelp = tw32(right,i)/sqrt(xhelp_a)           if(xhelp_a<3786) xhelp = tw32(right,i)/sqrt(xhelp_a)
998           tof32(right,i,itdc) = xhelp_t  + xhelp           tof32(right,i,itdc) = xhelp_t  + xhelp
999           tdc_c(ch32b(i),hb32b(i))=tof32(right,i,itdc)           tdc_c(ch32b(i),hb32b(i))=tof32(right,i,itdc)
1000        ENDDO        ENDDO
# Line 939  C-----------------angle and ADC(x) corre Line 1007  C-----------------angle and ADC(x) corre
1007  C-----------------------------S1 -------------------------------------  C-----------------------------S1 -------------------------------------
1008    
1009        yhelp=yout(1)        yhelp=yout(1)
1010        phi   = atan(tan(THXOUT(1))/tan(THYOUT(1)))  
1011  c      theta = atan(tan(THXOUT(1))/cos(phi)        phi   = atan(tan(THYOUT(1))/tan(THXOUT(1)))
1012        theta = atan(tan(THXOUT(1))/cos(phi))        theta = atan(tan(THXOUT(1))/cos(phi))
1013    
1014        IF (tof11_i.GT.none_find.AND.yhelp.lt.100) THEN        IF (tof11_i.GT.none_find.AND.yhelp.lt.100) THEN
1015    
1016           i = tof11_i           i = tof11_i
1017            
1018           if (tof11(left,i,iadc).lt.4095) then           if (tof11(left,i,iadc).lt.3786) then
1019              tof11(left,i,iadc) = tof11(left,i,iadc)*cos(theta)  c         if (adc(ch11a(i),hb11a(i)).lt.4095) then
1020              xkorr=adcx11(left,i,1)*exp(-yhelp/adcx11(left,i,2))              tof11(left,i,iadc) = tof11(left,i,iadc)*cos(theta)
1021              xkorr=xkorr/hepratio  c            xkorr=adcx11(left,i,1)*exp(-yhelp/adcx11(left,i,2))
1022                xkorr = atten(left,11,i,yhelp)
1023                xkorr=xkorr/hepratio
1024              adc_c(ch11a(i),hb11a(i))=tof11(left,i,iadc)/xkorr              adc_c(ch11a(i),hb11a(i))=tof11(left,i,iadc)/xkorr
1025           endif           endif
1026    
1027            
1028           if (tof11(right,i,iadc).lt.4095) then           if (tof11(right,i,iadc).lt.3786) then
1029    c         if (adc(ch11b(i),hb11b(i)).lt.4095) then
1030              tof11(right,i,iadc) = tof11(right,i,iadc)*cos(theta)              tof11(right,i,iadc) = tof11(right,i,iadc)*cos(theta)
1031              xkorr=adcx11(right,i,1)*exp(yhelp/adcx11(right,i,2))  c            xkorr=adcx11(right,i,1)*exp(yhelp/adcx11(right,i,2))
1032              xkorr=xkorr/hepratio                          xkorr = atten(right,11,i,yhelp)
1033                xkorr=xkorr/hepratio
1034              adc_c(ch11b(i),hb11b(i))=tof11(right,i,iadc)/xkorr              adc_c(ch11b(i),hb11b(i))=tof11(right,i,iadc)/xkorr
1035           endif           endif
1036        ENDIF        ENDIF
1037    
1038    
1039        xhelp=xout(2)        xhelp=xout(2)
1040        phi   = atan(tan(THXOUT(2))/tan(THYOUT(2)))        phi   = atan(tan(THYOUT(2))/tan(THXOUT(2)))
 c      theta = atan(tan(THXOUT(2))/cos(phi)  
1041        theta = atan(tan(THXOUT(2))/cos(phi))        theta = atan(tan(THXOUT(2))/cos(phi))
1042    c      write(*,*) 'theta12 ',theta
1043        IF (tof12_i.GT.none_find.AND.xhelp.lt.100) THEN        IF (tof12_i.GT.none_find.AND.xhelp.lt.100) THEN
1044    
1045           i = tof12_i           i = tof12_i
1046           if (tof12(left,i,iadc).lt.4095) then           if (tof12(left,i,iadc).lt.3786) then
1047    c         if (adc(ch12a(i),hb12a(i)).lt.4095) then
1048              tof12(left,i,iadc) = tof12(left,i,iadc)*cos(theta)              tof12(left,i,iadc) = tof12(left,i,iadc)*cos(theta)
1049              xkorr=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2))  c            xkorr=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2))
1050              xkorr=xkorr/hepratio                          xkorr = atten(left,12,i,xhelp)
1051                xkorr=xkorr/hepratio
1052              adc_c(ch12a(i),hb12a(i))=tof12(left,i,iadc)/xkorr              adc_c(ch12a(i),hb12a(i))=tof12(left,i,iadc)/xkorr
1053           endif           endif
1054    
1055           if (tof12(right,i,iadc).lt.4095) then           if (tof12(right,i,iadc).lt.3786) then
1056    c         if (adc(ch12b(i),hb12b(i)).lt.4095) then
1057              tof12(right,i,iadc) = tof12(right,i,iadc)*cos(theta)              tof12(right,i,iadc) = tof12(right,i,iadc)*cos(theta)
1058              xkorr=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2))  c            xkorr=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2))
1059              xkorr=xkorr/hepratio                          xkorr = atten(right,12,i,xhelp)
1060                xkorr=xkorr/hepratio
1061              adc_c(ch12b(i),hb12b(i))=tof12(right,i,iadc)/xkorr              adc_c(ch12b(i),hb12b(i))=tof12(right,i,iadc)/xkorr
1062           endif           endif
1063        ENDIF        ENDIF
# Line 989  c      theta = atan(tan(THXOUT(2))/cos(p Line 1065  c      theta = atan(tan(THXOUT(2))/cos(p
1065  C-----------------------------S2 --------------------------------  C-----------------------------S2 --------------------------------
1066    
1067        xhelp=xout(3)        xhelp=xout(3)
1068        phi   = atan(tan(THXOUT(3))/tan(THYOUT(3)))        phi   = atan(tan(THYOUT(3))/tan(THXOUT(3)))
 c      theta = atan(tan(THXOUT(3))/cos(phi)  
1069        theta = atan(tan(THXOUT(3))/cos(phi))        theta = atan(tan(THXOUT(3))/cos(phi))
1070    c      write(*,*) 'theta21 ',theta
1071        IF (tof21_i.GT.none_find.AND.xhelp.lt.100) THEN        IF (tof21_i.GT.none_find.AND.xhelp.lt.100) THEN
1072    
1073           i = tof21_i           i = tof21_i
1074           if (tof21(left,i,iadc).lt.4095) then           if (tof21(left,i,iadc).lt.3786) then
1075    c         if (adc(ch21a(i),hb21a(i)).lt.4095) then
1076              tof21(left,i,iadc) = tof21(left,i,iadc)*cos(theta)              tof21(left,i,iadc) = tof21(left,i,iadc)*cos(theta)
1077              xkorr=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2))  c            xkorr=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2))
1078              xkorr=xkorr/hepratio                          xkorr = atten(left,21,i,xhelp)
1079                xkorr=xkorr/hepratio
1080              adc_c(ch21a(i),hb21a(i))=tof21(left,i,iadc)/xkorr              adc_c(ch21a(i),hb21a(i))=tof21(left,i,iadc)/xkorr
1081           endif           endif
1082    
1083           if (tof21(right,i,iadc).lt.4095) then           if (tof21(right,i,iadc).lt.3786) then
1084    c         if (adc(ch21b(i),hb21b(i)).lt.4095) then
1085              tof21(right,i,iadc) = tof21(right,i,iadc)*cos(theta)              tof21(right,i,iadc) = tof21(right,i,iadc)*cos(theta)
1086              xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2))  c            xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2))
1087              xkorr=xkorr/hepratio                          xkorr = atten(right,21,i,xhelp)
1088                xkorr=xkorr/hepratio
1089              adc_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr              adc_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr
1090           endif           endif
1091        ENDIF        ENDIF
1092    
1093        yhelp=yout(4)        yhelp=yout(4)
1094        phi   = atan(tan(THXOUT(4))/tan(THYOUT(4)))        phi   = atan(tan(THYOUT(4))/tan(THXOUT(4)))
 c      theta = atan(tan(THXOUT(4))/cos(phi)  
1095        theta = atan(tan(THXOUT(4))/cos(phi))        theta = atan(tan(THXOUT(4))/cos(phi))
1096    c      write(*,*) 'theta22 ',theta
1097    
1098        IF (tof22_i.GT.none_find.AND.yhelp.lt.100) THEN        IF (tof22_i.GT.none_find.AND.yhelp.lt.100) THEN
1099    
1100           i = tof22_i           i = tof22_i
1101           if (tof22(left,i,iadc).lt.4095) then           if (tof22(left,i,iadc).lt.3786) then
1102    c         if (adc(ch22a(i),hb22a(i)).lt.4095) then
1103              tof22(left,i,iadc) = tof22(left,i,iadc)*cos(theta)              tof22(left,i,iadc) = tof22(left,i,iadc)*cos(theta)
1104              xkorr=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2))  c            xkorr=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2))
1105              xkorr=xkorr/hepratio                          xkorr = atten(left,22,i,yhelp)
1106                xkorr=xkorr/hepratio
1107              adc_c(ch22a(i),hb22a(i))=tof22(left,i,iadc)/xkorr              adc_c(ch22a(i),hb22a(i))=tof22(left,i,iadc)/xkorr
1108           endif           endif
1109    
1110           if (tof22(right,i,iadc).lt.4095) then           if (tof22(right,i,iadc).lt.3786) then
1111    c         if (adc(ch22b(i),hb22b(i)).lt.4095) then
1112              tof22(right,i,iadc) = tof22(right,i,iadc)*cos(theta)              tof22(right,i,iadc) = tof22(right,i,iadc)*cos(theta)
1113              xkorr=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2))  c            xkorr=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2))
1114              xkorr=xkorr/hepratio                          xkorr = atten(right,22,i,yhelp)
1115                xkorr=xkorr/hepratio
1116              adc_c(ch22b(i),hb22b(i))=tof22(right,i,iadc)/xkorr              adc_c(ch22b(i),hb22b(i))=tof22(right,i,iadc)/xkorr
1117           endif           endif
1118        ENDIF        ENDIF
# Line 1036  c      theta = atan(tan(THXOUT(4))/cos(p Line 1120  c      theta = atan(tan(THXOUT(4))/cos(p
1120  C-----------------------------S3 --------------------------------  C-----------------------------S3 --------------------------------
1121    
1122        yhelp=yout(5)        yhelp=yout(5)
1123        phi   = atan(tan(THXOUT(5))/tan(THYOUT(5)))        phi   = atan(tan(THYOUT(5))/tan(THXOUT(5)))
 c      theta = atan(tan(THXOUT(5))/cos(phi)  
1124        theta = atan(tan(THXOUT(5))/cos(phi))        theta = atan(tan(THXOUT(5))/cos(phi))
1125          c      write(*,*) 'theta31 ',theta
1126    
1127        IF (tof31_i.GT.none_find.AND.yhelp.lt.100) THEN        IF (tof31_i.GT.none_find.AND.yhelp.lt.100) THEN
1128    
1129           i = tof31_i           i = tof31_i
1130           if (tof31(left,i,iadc).lt.4095) then           if (tof31(left,i,iadc).lt.3786) then
1131    c         if (adc(ch31a(i),hb31a(i)).lt.4095) then
1132              tof31(left,i,iadc) = tof31(left,i,iadc)*cos(theta)              tof31(left,i,iadc) = tof31(left,i,iadc)*cos(theta)
1133              xkorr=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2))  c            xkorr=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2))
1134              xkorr=xkorr/hepratio                          xkorr = atten(left,31,i,yhelp)
1135                xkorr=xkorr/hepratio
1136              adc_c(ch31a(i),hb31a(i))=tof31(left,i,iadc)/xkorr              adc_c(ch31a(i),hb31a(i))=tof31(left,i,iadc)/xkorr
1137           endif           endif
1138    
1139           if (tof31(right,i,iadc).lt.4095) then           if (tof31(right,i,iadc).lt.3786) then
1140    c         if (adc(ch31b(i),hb31b(i)).lt.4095) then
1141              tof31(right,i,iadc) = tof31(right,i,iadc)*cos(theta)              tof31(right,i,iadc) = tof31(right,i,iadc)*cos(theta)
1142              xkorr=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2))  c            xkorr=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2))
1143              xkorr=xkorr/hepratio                          xkorr = atten(right,31,i,yhelp)
1144                xkorr=xkorr/hepratio
1145              adc_c(ch31b(i),hb31b(i))=tof31(right,i,iadc)/xkorr              adc_c(ch31b(i),hb31b(i))=tof31(right,i,iadc)/xkorr
1146           endif           endif
1147        ENDIF        ENDIF
1148    
1149        xhelp=xout(6)        xhelp=xout(6)
1150        phi   = atan(tan(THXOUT(6))/tan(THYOUT(6)))        phi   = atan(tan(THYOUT(6))/tan(THXOUT(6)))
 c      theta = atan(tan(THXOUT(6))/cos(phi)  
1151        theta = atan(tan(THXOUT(6))/cos(phi))        theta = atan(tan(THXOUT(6))/cos(phi))
1152    c      write(*,*) 'theta32 ',theta
1153    
1154        IF (tof32_i.GT.none_find.AND.xhelp.lt.100) THEN        IF (tof32_i.GT.none_find.AND.xhelp.lt.100) THEN
1155    
1156           i = tof32_i           i = tof32_i
1157           if (tof32(left,i,iadc).lt.4095) then           if (tof32(left,i,iadc).lt.3786) then
1158    c         if (adc(ch32a(i),hb32a(i)).lt.4095) then
1159              tof32(left,i,iadc) = tof32(left,i,iadc)*cos(theta)              tof32(left,i,iadc) = tof32(left,i,iadc)*cos(theta)
1160              xkorr=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2))  c            xkorr=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2))
1161              xkorr=xkorr/hepratio                          xkorr = atten(left,32,i,xhelp)
1162                xkorr=xkorr/hepratio
1163              adc_c(ch32a(i),hb32a(i))=tof32(left,i,iadc)/xkorr              adc_c(ch32a(i),hb32a(i))=tof32(left,i,iadc)/xkorr
1164           endif           endif
1165    
1166           if (tof32(right,i,iadc).lt.4095) then           if (tof32(right,i,iadc).lt.3786) then
1167    c         if (adc(ch32b(i),hb32b(i)).lt.4095) then
1168              tof32(right,i,iadc) = tof32(right,i,iadc)*cos(theta)              tof32(right,i,iadc) = tof32(right,i,iadc)*cos(theta)
1169              xkorr=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2))  c            xkorr=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2))
1170              xkorr=xkorr/hepratio                          xkorr = atten(right,32,i,xhelp)
1171                xkorr=xkorr/hepratio
1172              adc_c(ch32b(i),hb32b(i))=tof32(right,i,iadc)/xkorr              adc_c(ch32b(i),hb32b(i))=tof32(right,i,iadc)/xkorr
1173           endif           endif
1174        ENDIF        ENDIF
# Line 1085  C--------------------------------------- Line 1177  C---------------------------------------
1177  C----------------------calculate Beta  ------------------------------  C----------------------calculate Beta  ------------------------------
1178  C-----------------------------------------------------------------------  C-----------------------------------------------------------------------
1179  C-------------------difference of sums  ---------------------------  C-------------------difference of sums  ---------------------------
1180  C      C
1181  C     DS = (t1+t2) - t3+t4)  C     DS = (t1+t2) - t3+t4)
1182  C     DS = c1 + c2/beta*cos(theta)  C     DS = c1 + c2/beta*cos(theta)
1183  C     c2 = 2d/c   gives c2 = 2d/(c*TDCresolution)  TDC=50ps/channel  C     c2 = 2d/c   gives c2 = 2d/(c*TDCresolution)  TDC=50ps/channel
1184  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
1185  C     since TDC resolution varies slightly c2 has to be calibrated  C     since TDC resolution varies slightly c2 has to be calibrated
1186  C     instead of cos(theta) use factor F:  C     instead of cos(theta) use factor F:
1187  C     F =  pathlength/d  C     F =  pathlength/d
1188  C     => beta = c2*F/(DS-c1))  C     => beta = c2*F/(DS-c1))
1189    
1190        dist = ZTOF(1) - ZTOF(5)        dist = ZTOF(1) - ZTOF(5)
# Line 1100  C     => beta = c2*F/(DS-c1)) Line 1192  C     => beta = c2*F/(DS-c1))
1192        DO I=1,5        DO I=1,5
1193           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1194        ENDDO        ENDDO
1195        F = dl/dist        F = dl/dist
1196    
1197  C     S11 - S31  C     S11 - S31
1198  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 1110  C      IF (tof11_i.GT.none_find.AND.tof3 Line 1202  C      IF (tof11_i.GT.none_find.AND.tof3
1202           t2 = tof11(2,tof11_i,itdc)           t2 = tof11(2,tof11_i,itdc)
1203           t3 = tof31(1,tof31_i,itdc)           t3 = tof31(1,tof31_i,itdc)
1204           t4 = tof31(2,tof31_i,itdc)           t4 = tof31(2,tof31_i,itdc)
1205           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1206       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1207              xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)              xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
1208              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1209              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1210              ihelp=(tof11_i-1)*3+tof31_i              ihelp=(tof11_i-1)*3+tof31_i
1211              c1 = k_S11S31(1,ihelp)              c1 = k_S11S31(1,ihelp)
1212              c2 = k_S11S31(2,ihelp)                      c2 = k_S11S31(2,ihelp)
1213              beta_a(1) = c2*F/(ds-c1)              beta_a(1) = c2*F/(ds-c1)
1214  C     write(*,*) 'S11-S31 ',xhelp1,xhelp2, beta_a(1)  c       write(*,*) 'S11-S31 ',c1,c2,F
1215    c       write(*,*) 'S11-S31 ',xhelp1,xhelp2, beta_a(1)
1216  C-------ToF Mask - S11 - S31  C-------ToF Mask - S11 - S31
1217    
1218              tofmask(ch11a(tof11_i),hb11a(tof11_i)) =              tofmask(ch11a(tof11_i),hb11a(tof11_i)) =
# Line 1129  C-------ToF Mask - S11 - S31 Line 1222  C-------ToF Mask - S11 - S31
1222    
1223              tofmask(ch31a(tof31_i),hb31a(tof31_i)) =              tofmask(ch31a(tof31_i),hb31a(tof31_i)) =
1224       $           tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1       $           tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1
1225              tofmask(ch31b(tof31_i),hb31b(tof31_i)) =              tofmask(ch31b(tof31_i),hb31b(tof31_i)) =
1226       $           tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1       $           tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1
1227    
1228           ENDIF           ENDIF
# Line 1140  C-------ToF Mask - S11 - S31 Line 1233  C-------ToF Mask - S11 - S31
1233        DO I=1,6        DO I=1,6
1234           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1235        ENDDO        ENDDO
1236        F = dl/dist        F = dl/dist
1237          
1238  C     S11 - S32  C     S11 - S32
1239  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
1240         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 1150  C      IF (tof11_i.GT.none_find.AND.tof3 Line 1243  C      IF (tof11_i.GT.none_find.AND.tof3
1243           t2 = tof11(2,tof11_i,itdc)           t2 = tof11(2,tof11_i,itdc)
1244           t3 = tof32(1,tof32_i,itdc)           t3 = tof32(1,tof32_i,itdc)
1245           t4 = tof32(2,tof32_i,itdc)           t4 = tof32(2,tof32_i,itdc)
1246           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1247       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1248              xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)              xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
1249              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1250              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
1251              ihelp=(tof11_i-1)*3+tof32_i              ihelp=(tof11_i-1)*3+tof32_i
1252              c1 = k_S11S32(1,ihelp)              c1 = k_S11S32(1,ihelp)
1253              c2 = k_S11S32(2,ihelp)                      c2 = k_S11S32(2,ihelp)
1254              beta_a(2) = c2*F/(ds-c1)              beta_a(2) = c2*F/(ds-c1)
1255  C     write(*,*) 'S11-S32 ',xhelp1,xhelp2, beta_a(2)  C     write(*,*) 'S11-S32 ',xhelp1,xhelp2, beta_a(2)
1256    
# Line 1170  C-------ToF Mask - S11 - S32 Line 1263  C-------ToF Mask - S11 - S32
1263    
1264              tofmask(ch32a(tof32_i),hb32a(tof32_i)) =              tofmask(ch32a(tof32_i),hb32a(tof32_i)) =
1265       $           tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1       $           tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1
1266              tofmask(ch32b(tof32_i),hb32b(tof32_i)) =              tofmask(ch32b(tof32_i),hb32b(tof32_i)) =
1267       $           tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1       $           tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1
1268    
1269  C-------  C-------
# Line 1184  C     S12 - S31 Line 1277  C     S12 - S31
1277        DO I=2,5        DO I=2,5
1278           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1279        ENDDO        ENDDO
1280        F = dl/dist        F = dl/dist
1281    
1282  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
1283         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 1193  C      IF (tof12_i.GT.none_find.AND.tof3 Line 1286  C      IF (tof12_i.GT.none_find.AND.tof3
1286           t2 = tof12(2,tof12_i,itdc)           t2 = tof12(2,tof12_i,itdc)
1287           t3 = tof31(1,tof31_i,itdc)           t3 = tof31(1,tof31_i,itdc)
1288           t4 = tof31(2,tof31_i,itdc)           t4 = tof31(2,tof31_i,itdc)
1289           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1290       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1291              xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)              xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1292              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1293              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
# Line 1213  C-------ToF Mask - S12 - S31 Line 1306  C-------ToF Mask - S12 - S31
1306    
1307              tofmask(ch31a(tof31_i),hb31a(tof31_i)) =              tofmask(ch31a(tof31_i),hb31a(tof31_i)) =
1308       $           tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1       $           tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1
1309              tofmask(ch31b(tof31_i),hb31b(tof31_i)) =              tofmask(ch31b(tof31_i),hb31b(tof31_i)) =
1310       $           tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1       $           tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1
1311    
1312  C-------  C-------
# Line 1228  C     S12 - S32 Line 1321  C     S12 - S32
1321        DO I=2,6        DO I=2,6
1322           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1323        ENDDO        ENDDO
1324        F = dl/dist        F = dl/dist
1325    
1326  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
1327         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 1237  C      IF (tof12_i.GT.none_find.AND.tof3 Line 1330  C      IF (tof12_i.GT.none_find.AND.tof3
1330           t2 = tof12(2,tof12_i,itdc)           t2 = tof12(2,tof12_i,itdc)
1331           t3 = tof32(1,tof32_i,itdc)           t3 = tof32(1,tof32_i,itdc)
1332           t4 = tof32(2,tof32_i,itdc)           t4 = tof32(2,tof32_i,itdc)
1333           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1334       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1335              xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)              xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1336              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1337              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
# Line 1257  C-------ToF Mask - S12 - S32 Line 1350  C-------ToF Mask - S12 - S32
1350    
1351              tofmask(ch32a(tof32_i),hb32a(tof32_i)) =              tofmask(ch32a(tof32_i),hb32a(tof32_i)) =
1352       $           tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1       $           tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1
1353              tofmask(ch32b(tof32_i),hb32b(tof32_i)) =              tofmask(ch32b(tof32_i),hb32b(tof32_i)) =
1354       $           tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1       $           tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1
1355    
1356  C-------  C-------
# Line 1272  C     S21 - S31 Line 1365  C     S21 - S31
1365        DO I=3,5        DO I=3,5
1366           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1367        ENDDO        ENDDO
1368        F = dl/dist        F = dl/dist
1369    
1370  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
1371         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 1281  C      IF (tof21_i.GT.none_find.AND.tof3 Line 1374  C      IF (tof21_i.GT.none_find.AND.tof3
1374           t2 = tof21(2,tof21_i,itdc)           t2 = tof21(2,tof21_i,itdc)
1375           t3 = tof31(1,tof31_i,itdc)           t3 = tof31(1,tof31_i,itdc)
1376           t4 = tof31(2,tof31_i,itdc)           t4 = tof31(2,tof31_i,itdc)
1377           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1378       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1379              xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)              xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1380              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1381              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
# Line 1300  C-------ToF Mask - S21 - S31 Line 1393  C-------ToF Mask - S21 - S31
1393    
1394              tofmask(ch31a(tof31_i),hb31a(tof31_i)) =              tofmask(ch31a(tof31_i),hb31a(tof31_i)) =
1395       $           tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1       $           tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1
1396              tofmask(ch31b(tof31_i),hb31b(tof31_i)) =              tofmask(ch31b(tof31_i),hb31b(tof31_i)) =
1397       $           tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1       $           tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1
1398    
1399  C-------  C-------
# Line 1315  C     S21 - S32 Line 1408  C     S21 - S32
1408        DO I=3,6        DO I=3,6
1409           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1410        ENDDO        ENDDO
1411        F = dl/dist        F = dl/dist
1412    
1413  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
1414         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 1324  C      IF (tof21_i.GT.none_find.AND.tof3 Line 1417  C      IF (tof21_i.GT.none_find.AND.tof3
1417           t2 = tof21(2,tof21_i,itdc)           t2 = tof21(2,tof21_i,itdc)
1418           t3 = tof32(1,tof32_i,itdc)           t3 = tof32(1,tof32_i,itdc)
1419           t4 = tof32(2,tof32_i,itdc)           t4 = tof32(2,tof32_i,itdc)
1420           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1421       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1422              xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)              xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1423              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1424              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
# Line 1343  C-------ToF Mask - S21 - S32 Line 1436  C-------ToF Mask - S21 - S32
1436    
1437              tofmask(ch32a(tof32_i),hb32a(tof32_i)) =              tofmask(ch32a(tof32_i),hb32a(tof32_i)) =
1438       $           tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1       $           tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1
1439              tofmask(ch32b(tof32_i),hb32b(tof32_i)) =              tofmask(ch32b(tof32_i),hb32b(tof32_i)) =
1440       $           tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1       $           tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1
1441    
1442  C-------  C-------
# Line 1358  C     S22 - S31 Line 1451  C     S22 - S31
1451        DO I=4,5        DO I=4,5
1452           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1453        ENDDO        ENDDO
1454        F = dl/dist        F = dl/dist
1455    
1456  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
1457         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 1367  C      IF (tof22_i.GT.none_find.AND.tof3 Line 1460  C      IF (tof22_i.GT.none_find.AND.tof3
1460           t2 = tof22(2,tof22_i,itdc)           t2 = tof22(2,tof22_i,itdc)
1461           t3 = tof31(1,tof31_i,itdc)           t3 = tof31(1,tof31_i,itdc)
1462           t4 = tof31(2,tof31_i,itdc)           t4 = tof31(2,tof31_i,itdc)
1463           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1464       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1465              xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)              xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1466              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)              xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1467              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
# Line 1386  C-------ToF Mask - S22 - S31 Line 1479  C-------ToF Mask - S22 - S31
1479    
1480              tofmask(ch31a(tof31_i),hb31a(tof31_i)) =              tofmask(ch31a(tof31_i),hb31a(tof31_i)) =
1481       $           tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1       $           tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1
1482              tofmask(ch31b(tof31_i),hb31b(tof31_i)) =              tofmask(ch31b(tof31_i),hb31b(tof31_i)) =
1483       $           tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1       $           tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1
1484    
1485  C-------  C-------
1486    
1487           ENDIF           ENDIF
1488        ENDIF        ENDIF
1489          
1490  C     S22 - S32  C     S22 - S32
1491    
1492        dist = ZTOF(4) - ZTOF(6)        dist = ZTOF(4) - ZTOF(6)
# Line 1401  C     S22 - S32 Line 1494  C     S22 - S32
1494        DO I=4,6        DO I=4,6
1495           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1496        ENDDO        ENDDO
1497        F = dl/dist        F = dl/dist
1498    
1499  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
1500         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 1410  C      IF (tof22_i.GT.none_find.AND.tof3 Line 1503  C      IF (tof22_i.GT.none_find.AND.tof3
1503           t2 = tof22(2,tof22_i,itdc)           t2 = tof22(2,tof22_i,itdc)
1504           t3 = tof32(1,tof32_i,itdc)           t3 = tof32(1,tof32_i,itdc)
1505           t4 = tof32(2,tof32_i,itdc)           t4 = tof32(2,tof32_i,itdc)
1506           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1507       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1508              xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)              xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1509              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)              xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1510              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
# Line 1429  C-------ToF Mask - S22 - S32 Line 1522  C-------ToF Mask - S22 - S32
1522    
1523              tofmask(ch32a(tof32_i),hb32a(tof32_i)) =              tofmask(ch32a(tof32_i),hb32a(tof32_i)) =
1524       $           tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1       $           tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1
1525              tofmask(ch32b(tof32_i),hb32b(tof32_i)) =              tofmask(ch32b(tof32_i),hb32b(tof32_i)) =
1526       $           tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1       $           tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1
1527    
1528  C-------  C-------
# Line 1444  C     S11 - S21 Line 1537  C     S11 - S21
1537        DO I=1,3        DO I=1,3
1538           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1539        ENDDO        ENDDO
1540        F = dl/dist        F = dl/dist
1541    
1542  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
1543         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 1453  C      IF (tof11_i.GT.none_find.AND.tof2 Line 1546  C      IF (tof11_i.GT.none_find.AND.tof2
1546           t2 = tof11(2,tof11_i,itdc)           t2 = tof11(2,tof11_i,itdc)
1547           t3 = tof21(1,tof21_i,itdc)           t3 = tof21(1,tof21_i,itdc)
1548           t4 = tof21(2,tof21_i,itdc)           t4 = tof21(2,tof21_i,itdc)
1549           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1550       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1551              xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)              xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
1552              xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)              xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1553              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
# Line 1472  C-------ToF Mask - S11 - S21 Line 1565  C-------ToF Mask - S11 - S21
1565    
1566              tofmask(ch21a(tof21_i),hb21a(tof21_i)) =              tofmask(ch21a(tof21_i),hb21a(tof21_i)) =
1567       $           tofmask(ch21a(tof21_i),hb21a(tof21_i)) + 1       $           tofmask(ch21a(tof21_i),hb21a(tof21_i)) + 1
1568              tofmask(ch21b(tof21_i),hb21b(tof21_i)) =              tofmask(ch21b(tof21_i),hb21b(tof21_i)) =
1569       $           tofmask(ch21b(tof21_i),hb21b(tof21_i)) + 1       $           tofmask(ch21b(tof21_i),hb21b(tof21_i)) + 1
1570    
1571  C-------  C-------
1572    
1573           ENDIF           ENDIF
1574        ENDIF        ENDIF
1575          
1576  C     S11 - S22  C     S11 - S22
1577    
1578        dist = ZTOF(1) - ZTOF(4)        dist = ZTOF(1) - ZTOF(4)
# Line 1487  C     S11 - S22 Line 1580  C     S11 - S22
1580        DO I=1,4        DO I=1,4
1581           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1582        ENDDO        ENDDO
1583        F = dl/dist        F = dl/dist
1584    
1585  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
1586         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 1496  C      IF (tof11_i.GT.none_find.AND.tof2 Line 1589  C      IF (tof11_i.GT.none_find.AND.tof2
1589           t2 = tof11(2,tof11_i,itdc)           t2 = tof11(2,tof11_i,itdc)
1590           t3 = tof22(1,tof22_i,itdc)           t3 = tof22(1,tof22_i,itdc)
1591           t4 = tof22(2,tof22_i,itdc)           t4 = tof22(2,tof22_i,itdc)
1592           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1593       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1594              xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)              xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
1595              xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)              xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1596              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
# Line 1515  C-------ToF Mask - S11 - S22 Line 1608  C-------ToF Mask - S11 - S22
1608    
1609              tofmask(ch22a(tof22_i),hb22a(tof22_i)) =              tofmask(ch22a(tof22_i),hb22a(tof22_i)) =
1610       $           tofmask(ch22a(tof22_i),hb22a(tof22_i)) + 1       $           tofmask(ch22a(tof22_i),hb22a(tof22_i)) + 1
1611              tofmask(ch22b(tof22_i),hb22b(tof22_i)) =              tofmask(ch22b(tof22_i),hb22b(tof22_i)) =
1612       $           tofmask(ch22b(tof22_i),hb22b(tof22_i)) + 1       $           tofmask(ch22b(tof22_i),hb22b(tof22_i)) + 1
1613    
1614  C-------  C-------
# Line 1530  C     S12 - S21 Line 1623  C     S12 - S21
1623        DO I=2,3        DO I=2,3
1624           dl = dl + TLOUT(i)           dl = dl + TLOUT(i)
1625        ENDDO        ENDDO
1626        F = dl/dist        F = dl/dist
1627    
1628  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
1629         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 1539  C      IF (tof12_i.GT.none_find.AND.tof2 Line 1632  C      IF (tof12_i.GT.none_find.AND.tof2
1632           t2 = tof12(2,tof12_i,itdc)           t2 = tof12(2,tof12_i,itdc)
1633           t3 = tof21(1,tof21_i,itdc)           t3 = tof21(1,tof21_i,itdc)
1634           t4 = tof21(2,tof21_i,itdc)           t4 = tof21(2,tof21_i,itdc)
1635           IF ((t1.lt.4095).and.(t2.lt.4095).and.           IF ((t1.lt.4095).and.(t2.lt.4095).and.
1636       &        (t3.lt.4095).and.(t4.lt.4095)) THEN       &        (t3.lt.4095).and.(t4.lt.4095)) THEN
1637              xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)              xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1638              xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)              xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1639              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
# Line 1558  C-------ToF Mask - S12 - S21 Line 1651  C-------ToF Mask - S12 - S21
1651    
1652              tofmask(ch21a(tof21_i),hb21a(tof21_i)) =              tofmask(ch21a(tof21_i),hb21a(tof21_i)) =
1653       $           tofmask(ch21a(tof21_i),hb21a(tof21_i)) + 1       $           tofmask(ch21a(tof21_i),hb21a(tof21_i)) + 1
1654              tofmask(ch21b(tof21_i),hb21b(tof21_i)) =              tofmask(ch21b(tof21_i),hb21b(tof21_i)) =
1655       $           tofmask(ch21b(tof21_i),hb21b(tof21_i)) + 1       $           tofmask(ch21b(tof21_i),hb21b(tof21_i)) + 1
1656    
1657  C-------  C-------
# Line 1573  C     S12 - S22 Line 1666  C     S12 - S22
1666        DO I=2,4        DO I=2,4
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.tof22_i.GT.none_find) THEN  C      IF (tof12_i.GT.none_find.AND.tof22_i.GT.none_find) THEN
1672         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 1582  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 = tof22(1,tof22_i,itdc)           t3 = tof22(1,tof22_i,itdc)
1677           t4 = tof22(2,tof22_i,itdc)           t4 = tof22(2,tof22_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 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)              xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1682              ds = xhelp1-xhelp2              ds = xhelp1-xhelp2
# Line 1601  C-------ToF Mask - S12 - S22 Line 1694  C-------ToF Mask - S12 - S22
1694    
1695              tofmask(ch22a(tof22_i),hb22a(tof22_i)) =              tofmask(ch22a(tof22_i),hb22a(tof22_i)) =
1696       $           tofmask(ch22a(tof22_i),hb22a(tof22_i)) + 1       $           tofmask(ch22a(tof22_i),hb22a(tof22_i)) + 1
1697              tofmask(ch22b(tof22_i),hb22b(tof22_i)) =              tofmask(ch22b(tof22_i),hb22b(tof22_i)) =
1698       $           tofmask(ch22b(tof22_i),hb22b(tof22_i)) + 1       $           tofmask(ch22b(tof22_i),hb22b(tof22_i)) + 1
1699    
1700  C-------  C-------
1701    
1702           ENDIF           ENDIF
1703        ENDIF        ENDIF
1704          
1705  C-------  C-------
1706    
1707        icount=0        icount=0
# Line 1621  C------- Line 1714  C-------
1714              icount= icount+1              icount= icount+1
1715              if (i.le.4) w_i=1./(0.13**2.)              if (i.le.4) w_i=1./(0.13**2.)
1716              if ((i.ge.5).and.(i.le.8)) w_i=1./(0.16**2.)              if ((i.ge.5).and.(i.le.8)) w_i=1./(0.16**2.)
1717              if (i.ge.9) w_i=1./(0.25**2.) ! to be checked              if (i.ge.9) w_i=1./(0.25**2.) ! to be checked
1718              sxw=sxw + beta_a(i)*w_i              sxw=sxw + beta_a(i)*w_i
1719              sw =sw + w_i              sw =sw + w_i
1720           endif           endif
1721        enddo        enddo
1722          
1723        if (icount.gt.0) beta_mean=sxw/sw        if (icount.gt.0) beta_mean=sxw/sw
1724        beta_a(13) = beta_mean        beta_a(13) = beta_mean
1725    
1726    
1727  c       IF (tof11_i.GT.none_find)  c       IF (tof11_i.GT.none_find)
1728  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)
1729  c       IF (tof12_i.GT.none_find)  c       IF (tof12_i.GT.none_find)
1730  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)
1731    
1732  c       IF (tof21_i.GT.none_find)  c       IF (tof21_i.GT.none_find)
1733  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)
1734  c       IF (tof22_i.GT.none_find)  c       IF (tof22_i.GT.none_find)
1735  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)
1736    
1737  c       IF (tof31_i.GT.none_find)  c       IF (tof31_i.GT.none_find)
1738  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)
1739  c       IF (tof32_i.GT.none_find)  c       IF (tof32_i.GT.none_find)
1740  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)
1741    
1742  c      write(*,*) xtofpos  c      write(*,*) xtofpos
1743  c      write(*,*) ytofpos  c      write(*,*) ytofpos
1744  c      write(*,*) beta_a  C      write(*,*)'toftrk beta', beta_a
1745  C      write(*,*) adcflagtof  C      write(*,*) adcflagtof
1746    C     write(*,*)'TOFTRK ',ievent,beta_a(1),beta_a(2),beta_a(3),beta_a(4)
1747    c      write(*,*) 'toftrk'
1748    c      write(*,*) xtofpos
1749    c      write(*,*) ytofpos
1750    c      write(*,*) xtr_tof
1751    c      write(*,*) ytr_tof
1752    
1753    
 C     write(*,*)'TOFTRK ',ievent,beta_a(1),beta_a(2),beta_a(3),beta_a(4)  
1754    
1755        RETURN        RETURN
1756        END        END
1757    
1758    
1759    
1760    
1761    C------------------------------------------------------------------
1762    

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.23