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

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

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

revision 1.3 by mocchiut, Thu Aug 10 06:32:04 2006 UTC revision 1.4 by mocchiut, Mon Jan 22 10:45:25 2007 UTC
# Line 1  Line 1 
1  *****************************************************************************  ******************************************************************************
2    *
3    *  08-12-06 WM: adc_c-bug :  The raw ADc value was multiplied with cos(theta)
4    *  and AFTER that there was an if statement "if tof32(right,i,iadc) < 4095"
5    *
6    *  jan-07 GF: ADCflags(4,12) inserted to flag artificial ADC values
7    *  jan-07 WM: artificial ADC values created using attenuation calibration
8    *  jan-07 WM: modified xtofpos flag "101". xtofpos must be inside physical
9    *             dimension of the paddle +/- 10 cm
10    *  jan-07 WM: if xtofpos=101 then this paddle is not used for beta
11    *             calculation
12    *  jan-07 WM: the definition for a "hit" is changed: Now we must have a
13    *             valid TDC signal on both sides
14    *  jan-07 WM: flag for PMTs #10 and #35 added, TDC=819 due to bit-shift
15    ******************************************************************************
16    
17        INTEGER FUNCTION TOFL2COM()        INTEGER FUNCTION TOFL2COM()
18  c      c    
19        IMPLICIT NONE        IMPLICIT NONE
# Line 17  C     Line 32  C    
32        REAL xhelp_a,xhelp_t        REAL xhelp_a,xhelp_t
33    
34        REAL dx,dy,dr,ds        REAL dx,dy,dr,ds
35        REAL yhelp,xdummy,xkorr0,xhelp,xhelp1,xhelp2        REAL yhelp,xhelp,xhelp1,xhelp2
36        REAL c1,c2,sw,sxw,w_i        REAL c1,c2,sw,sxw,w_i
37        INTEGER icount        INTEGER icount
38    
39    c      REAL xdummy
40    
41        INTEGER tof11_j,tof21_j,tof31_j        INTEGER tof11_j,tof21_j,tof31_j
42        INTEGER tof12_j,tof22_j,tof32_j        INTEGER tof12_j,tof22_j,tof32_j
43    
44    
45        REAL beta_mean        REAL beta_mean
46    
47    
# Line 35  c     second index : 1... number of padd Line 53  c     second index : 1... number of padd
53        INTEGER tof31_event(2,3),tof32_event(2,3)        INTEGER tof31_event(2,3),tof32_event(2,3)
54    
55                
56        REAL theta12,theta13,theta23        REAL theta13
57  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
58        REAL tofarm12        REAL tofarm12
59        PARAMETER (tofarm12 = 29.70) ! from 53.39 to 23.69        PARAMETER (tofarm12 = 29.70) ! from 53.39 to 23.69
# Line 43  C--   DATA ZTOF/53.74,53.04,23.94,23.44, Line 61  C--   DATA ZTOF/53.74,53.04,23.94,23.44,
61        PARAMETER (tofarm23 = 47.61)  ! from 23.69 to -23.92        PARAMETER (tofarm23 = 47.61)  ! from 23.69 to -23.92
62        REAL tofarm13        REAL tofarm13
63        PARAMETER (tofarm13 = 77.31)  ! from 53.39 to -23.92        PARAMETER (tofarm13 = 77.31)  ! from 53.39 to -23.92
64          
65          REAL hepratio      
66    
67        INTEGER ihelp        INTEGER ihelp
68        REAL xkorr        REAL xkorr
# Line 63  C     Line 82  C    
82  *     amplitude has to be 'secure' higher than pedestal for an adc event  *     amplitude has to be 'secure' higher than pedestal for an adc event
83        secure = 2.        secure = 2.
84    
85    C     ratio between helium and proton ca. 4
86          hepratio = 4.5  !
87        offset = 1        offset = 1
88        slope = 2        slope = 2
89        left = 1        left = 1
# Line 99  C     Line 120  C    
120        enddo        enddo
121    
122    
123    c gf adc falg:
124          do i=1,4
125             do j=1,12
126                adcflagtof(i,j) = 0
127             enddo
128          enddo
129    
130    c gf tdc falg:
131          do i=1,4
132             do j=1,12
133                tdcflagtof(i,j) = 0
134             enddo
135          enddo
136    
137  c the calibration files are read in the main program from xxx_tofcalib.rz  c the calibration files are read in the main program from xxx_tofcalib.rz
138    
139    
# Line 195  C--------------------------------------- Line 230  C---------------------------------------
230           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.
231        ENDDO        ENDDO
232    
233    C----------------------------------------------------------------------
234    C------------------  set ADC & TDC flag = 0    ------------------------
235    C----------------------------------------------------------------------
236    
237          do j=1,8
238          if (adc(ch11a(j),hb11a(j)).LT.4096)adcflagtof(ch11a(j),hb11a(j))=0
239          if (adc(ch11b(j),hb11b(j)).LT.4096)adcflagtof(ch11b(j),hb11b(j))=0
240          if (tdc(ch11a(j),hb11a(j)).LT.4096)tdcflagtof(ch11a(j),hb11a(j))=0
241          if (tdc(ch11b(j),hb11b(j)).LT.4096)tdcflagtof(ch11b(j),hb11b(j))=0
242          enddo
243          do j=1,6
244          if (adc(ch12a(j),hb12a(j)).LT.4096)adcflagtof(ch12a(j),hb12a(j))=0
245          if (adc(ch12b(j),hb12b(j)).LT.4096)adcflagtof(ch12b(j),hb12b(j))=0
246          if (tdc(ch12a(j),hb12a(j)).LT.4096)tdcflagtof(ch12a(j),hb12a(j))=0
247          if (tdc(ch12b(j),hb12b(j)).LT.4096)tdcflagtof(ch12b(j),hb12b(j))=0
248          enddo
249          do j=1,2
250          if (adc(ch21a(j),hb21a(j)).LT.4096)adcflagtof(ch21a(j),hb21a(j))=0
251          if (adc(ch21b(j),hb21b(j)).LT.4096)adcflagtof(ch21b(j),hb21b(j))=0
252          if (tdc(ch21a(j),hb21a(j)).LT.4096)tdcflagtof(ch21a(j),hb21a(j))=0
253          if (tdc(ch21b(j),hb21b(j)).LT.4096)tdcflagtof(ch21b(j),hb21b(j))=0
254          enddo
255          do j=1,2
256          if (adc(ch22a(j),hb22a(j)).LT.4096)adcflagtof(ch22a(j),hb22a(j))=0
257          if (adc(ch22b(j),hb22b(j)).LT.4096)adcflagtof(ch22b(j),hb22b(j))=0
258          if (tdc(ch22a(j),hb22a(j)).LT.4096)tdcflagtof(ch22a(j),hb22a(j))=0
259          if (tdc(ch22b(j),hb22b(j)).LT.4096)tdcflagtof(ch22b(j),hb22b(j))=0
260          enddo
261          do j=1,3
262          if (adc(ch31a(j),hb31a(j)).LT.4096)adcflagtof(ch31a(j),hb31a(j))=0
263          if (adc(ch31b(j),hb31b(j)).LT.4096)adcflagtof(ch31b(j),hb31b(j))=0
264          if (tdc(ch31a(j),hb31a(j)).LT.4096)tdcflagtof(ch31a(j),hb31a(j))=0
265          if (tdc(ch31b(j),hb31b(j)).LT.4096)tdcflagtof(ch31b(j),hb31b(j))=0
266          enddo
267          do j=1,3
268          if (adc(ch32a(j),hb32a(j)).LT.4096)adcflagtof(ch32a(j),hb32a(j))=0
269          if (adc(ch32b(j),hb32b(j)).LT.4096)adcflagtof(ch32b(j),hb32b(j))=0
270          if (tdc(ch32a(j),hb32a(j)).LT.4096)tdcflagtof(ch32a(j),hb32a(j))=0
271          if (tdc(ch32b(j),hb32b(j)).LT.4096)tdcflagtof(ch32b(j),hb32b(j))=0
272          enddo
273    
274  C----------------------------------------------------------------  C----------------------------------------------------------------
275  C------------Check Paddles for hits  -----------------------  C---------- Check PMTs 10 and 35 for strange TDC values----------
276    C----------------------------------------------------------------
277    
278    C---- S116A TDC=819
279           if (tof11(1,6,1).EQ.819) then
280                 tof11(1,6,1) = 4095
281                 tdcflagtof(ch11a(6),hb11a(6))=2
282           endif
283      
284    C---- S222B TDC=819
285           if (tof22(2,2,1).EQ.819) then
286                 tof22(2,2,1) = 4095
287                 tdcflagtof(ch22b(2),hb22b(2))=2
288           endif
289    
290    
291    C----------------------------------------------------------------
292    C------------   Check Paddles for hits    -----------------------
293    C------  a "hit" means TDC values<4095 on both sides ------------
294  C----------------------------------------------------------------  C----------------------------------------------------------------
295    
296  C     upper tof  S11  C     upper tof  S11
# Line 206  C     upper tof  S11 Line 300  C     upper tof  S11
300              tof11_event(j,i) = none_ev              tof11_event(j,i) = none_ev
301              IF ((tof11(j,i,itdc).LT.2000).AND.(tof11(j,i,itdc).GT.100))              IF ((tof11(j,i,itdc).LT.2000).AND.(tof11(j,i,itdc).GT.100))
302       +           tof11_event(j,i) = tof11_event(j,i) + tdc_ev       +           tof11_event(j,i) = tof11_event(j,i) + tdc_ev
             IF ((tof11(j,i,iadc).GT.secure).AND.  
      +           (tof11(j,i,iadc).LT.4095))  
      +           tof11_event(j,i) = tof11_event(j,i) + adc_ev  
303           ENDDO           ENDDO
304        ENDDO        ENDDO
305    
# Line 239  C     upper tof  S12 Line 330  C     upper tof  S12
330              tof12_event(j,i) = none_ev              tof12_event(j,i) = none_ev
331              IF ((tof12(j,i,itdc).LT.2000).AND.(tof12(j,i,itdc).GT.100))              IF ((tof12(j,i,itdc).LT.2000).AND.(tof12(j,i,itdc).GT.100))
332       +           tof12_event(j,i) = tof12_event(j,i) + tdc_ev       +           tof12_event(j,i) = tof12_event(j,i) + tdc_ev
             IF ((tof12(j,i,iadc).GT.secure).AND.  
      +           (tof12(j,i,iadc).LT.4095))  
      +           tof12_event(j,i) = tof12_event(j,i) + adc_ev  
333           ENDDO           ENDDO
334        ENDDO        ENDDO
335    
# Line 272  C     middle tof  S21 Line 360  C     middle tof  S21
360              tof21_event(j,i) = none_ev              tof21_event(j,i) = none_ev
361              IF ((tof21(j,i,itdc).LT.2000).AND.(tof21(j,i,itdc).GT.100))              IF ((tof21(j,i,itdc).LT.2000).AND.(tof21(j,i,itdc).GT.100))
362       +           tof21_event(j,i) = tof21_event(j,i) + tdc_ev       +           tof21_event(j,i) = tof21_event(j,i) + tdc_ev
             IF ((tof21(j,i,iadc).GT.secure).AND.  
      +           (tof21(j,i,iadc).LT.4095))  
      +           tof21_event(j,i) = tof21_event(j,i) + adc_ev  
363           ENDDO           ENDDO
364        ENDDO        ENDDO
365    
# Line 304  C     middle tof  S22 Line 389  C     middle tof  S22
389              tof22_event(j,i) = none_ev              tof22_event(j,i) = none_ev
390              IF ((tof22(j,i,itdc).LT.2000).AND.(tof22(j,i,itdc).GT.100))              IF ((tof22(j,i,itdc).LT.2000).AND.(tof22(j,i,itdc).GT.100))
391       +           tof22_event(j,i) = tof22_event(j,i) + tdc_ev       +           tof22_event(j,i) = tof22_event(j,i) + tdc_ev
             IF ((tof22(j,i,iadc).GT.secure).AND.  
      +           (tof22(j,i,iadc).LT.4095))  
      +           tof22_event(j,i) = tof22_event(j,i) + adc_ev  
392           ENDDO           ENDDO
393        ENDDO        ENDDO
394    
# Line 337  C     bottom tof  S31 Line 419  C     bottom tof  S31
419              tof31_event(j,i) = none_ev              tof31_event(j,i) = none_ev
420              IF ((tof31(j,i,itdc).LT.2000).AND.(tof31(j,i,itdc).GT.100))              IF ((tof31(j,i,itdc).LT.2000).AND.(tof31(j,i,itdc).GT.100))
421       +           tof31_event(j,i) = tof31_event(j,i) + tdc_ev       +           tof31_event(j,i) = tof31_event(j,i) + tdc_ev
             IF ((tof31(j,i,iadc).GT.secure).AND.  
      +           (tof31(j,i,iadc).LT.4095))  
      +           tof31_event(j,i) = tof31_event(j,i) + adc_ev  
422           ENDDO           ENDDO
423        ENDDO        ENDDO
424    
# Line 369  C     bottom tof  S32 Line 448  C     bottom tof  S32
448              tof32_event(j,i) = none_ev              tof32_event(j,i) = none_ev
449              IF ((tof32(j,i,itdc).LT.2000).AND.(tof32(j,i,itdc).GT.100))              IF ((tof32(j,i,itdc).LT.2000).AND.(tof32(j,i,itdc).GT.100))
450       +           tof32_event(j,i) = tof32_event(j,i) + tdc_ev       +           tof32_event(j,i) = tof32_event(j,i) + tdc_ev
             IF ((tof32(j,i,iadc).GT.secure).AND.  
      +           (tof32(j,i,iadc).LT.4095))  
      +           tof32_event(j,i) = tof32_event(j,i) + adc_ev  
451           ENDDO           ENDDO
452        ENDDO        ENDDO
453    
# Line 414  c     check if an other paddle has also Line 490  c     check if an other paddle has also
490        tof_j_flag(5)=tof31_j        tof_j_flag(5)=tof31_j
491        tof_j_flag(6)=tof32_j        tof_j_flag(6)=tof32_j
492    
493            
494    C------------------------------------------------------------------
495    C---  calculate track position in paddle using timing difference
496    C------------------------------------------------------------------
497    
498          do i=1,3
499             xtofpos(i)=100.
500             ytofpos(i)=100.
501          enddo
502    C-----------------------------S1 --------------------------------
503    
504          IF (tof11_i.GT.none_find) THEN
505             ytofpos(1)  = ((tof11(1,tof11_i,itdc)-tof11(2,tof11_i,itdc))/2.
506         +        -y_coor_lin11(tof11_i,offset))/y_coor_lin11(tof11_i,slope)
507          endif
508    
509          IF (tof12_i.GT.none_find) THEN
510             xtofpos(1)  = ((tof12(1,tof12_i,itdc)-tof12(2,tof12_i,itdc))/2.
511         +        -x_coor_lin12(tof12_i,offset))/x_coor_lin12(tof12_i,slope)
512          endif
513    
514    
515    C-----------------------------S2 --------------------------------
516    
517          IF (tof21_i.GT.none_find) THEN
518             xtofpos(2) = ((tof21(1,tof21_i,itdc)-tof21(2,tof21_i,itdc))/2.
519         +        -x_coor_lin21(tof21_i,offset))/x_coor_lin21(tof21_i,slope)
520          endif
521    
522          IF (tof22_i.GT.none_find) THEN
523             ytofpos(2) = ((tof22(1,tof22_i,itdc)-tof22(2,tof22_i,itdc))/2.
524         +        -y_coor_lin22(tof22_i,offset))/y_coor_lin22(tof22_i,slope)
525          endif
526          
527    
528    C-----------------------------S3 --------------------------------
529    
530          IF (tof31_i.GT.none_find) THEN
531             ytofpos(3)  = ((tof31(1,tof31_i,itdc)-tof31(2,tof31_i,itdc))/2.
532         +        -y_coor_lin31(tof31_i,offset))/y_coor_lin31(tof31_i,slope)
533          endif
534    
535          IF (tof32_i.GT.none_find) THEN
536             xtofpos(3)  = ((tof32(1,tof32_i,itdc)-tof32(2,tof32_i,itdc))/2.
537         +        -x_coor_lin32(tof32_i,offset))/x_coor_lin32(tof32_i,slope)
538          endif
539    
540    
541    c      do i=1,3
542    c         if (abs(xtofpos(i)).gt.100.) then
543    c            xtofpos(i)=101.
544    c         endif
545    c         if (abs(ytofpos(i)).gt.100.) then
546    c            ytofpos(i)=101.
547    c         endif
548    c      enddo
549    
550    C--  restrict TDC measurements to physical paddle dimensions +/- 10 cm
551    C--  this cut is now stronger than in the old versions
552    
553            if (abs(xtofpos(1)).gt.31.)  xtofpos(1)=101.
554            if (abs(xtofpos(2)).gt.19.)  xtofpos(2)=101.
555            if (abs(xtofpos(3)).gt.19.)  xtofpos(3)=101.
556    
557            if (abs(ytofpos(1)).gt.26.)  ytofpos(1)=101.
558            if (abs(ytofpos(2)).gt.18.)  ytofpos(2)=101.
559            if (abs(ytofpos(3)).gt.18.)  ytofpos(3)=101.
560    
561    
562    C----------------------------------------------------------------------
563    C---------------------  zenith angle theta  ---------------------------
564    C----------------------------------------------------------------------
565    
566          dx=0.
567          dy=0.
568          dr=0.
569          theta13 = 0.
570    
571             IF ((tof12_i.GT.none_find).AND.(tof32_i.GT.none_find))
572         &        dx  = xtofpos(1) - xtofpos(3)
573             IF ((tof11_i.GT.none_find).AND.(tof31_i.GT.none_find))
574         &        dy  = ytofpos(1) - ytofpos(3)
575             dr = sqrt(dx*dx+dy*dy)
576             theta13 = atan(dr/tofarm13)
577    
578    C------------------------------------------------------------------
579    c      dx=0.
580    c      dy=0.
581    c      dr=0.
582    c      theta12 = 0.
583    c
584    c         IF ((tof12_i.GT.none_find).AND.(tof21_i.GT.none_find))
585    c     &        dx  = xtofpos(1) - xtofpos(2)
586    c         IF ((tof11_i.GT.none_find).AND.(tof22_i.GT.none_find))
587    c     &        dy  = ytofpos(1) - ytofpos(2)
588    c         dr = sqrt(dx*dx+dy*dy)
589    c         theta12 = atan(dr/tofarm12)
590    c        
591    c      dx=0.
592    c      dy=0.
593    c      dr=0.
594    c      theta23 = 0.
595    c
596    c         IF ((tof21_i.GT.none_find).AND.(tof32_i.GT.none_find))
597    c     &        dx  = xtofpos(2) - xtofpos(3)
598    c         IF ((tof22_i.GT.none_find).AND.(tof31_i.GT.none_find))
599    c     &        dy  = ytofpos(2) - ytofpos(3)
600    c         dr = sqrt(dx*dx+dy*dy)
601    c         theta23 = atan(dr/tofarm23)
602    c        
603    C---------------------------------------------------------------------
604    
605    
606    C--------------------------------------------------------------------
607    C---- if TDCleft.and.TDCright and NO ADC insert artificial ADC
608    C---- values
609    C--------------------------------------------------------------------
610    c middle y (or x) position of the upper and middle ToF-Paddle
611    c       DATA tof11_x/ -17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85/
612    c       DATA tof12_y/ -13.75,-8.25,-2.75,2.75,8.25,13.75/
613    c       DATA tof21_y/  3.75,-3.75/     ! paddles in different order
614    c       DATA tof22_x/ -4.5,4.5/
615    c       DATA tof31_x/ -6.0,0.,6.0/
616    c       DATA tof32_y/ -5.0,0.0,5.0/
617    
618    
619    C----------------------------  S1 -------------------------------------
620    
621           yhelp=0.
622           if (tof12_i.GT.none_find) yhelp=tof12_y(tof12_i)
623           if (ytofpos(1).lt.100)  yhelp=ytofpos(1)
624    
625           IF (tof11_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
626             i = tof11_i
627             if (tof11(left,i,iadc).eq.4095) then
628                xkorr=adcx11(left,i,1)*exp(-yhelp/adcx11(left,i,2))
629                xkorr=xkorr/hepratio
630                tof11(left,i,iadc)=xkorr/cos(theta13)
631    c            write(*,*) 'tofl2 left ',i, tof11(left,i,iadc)
632                adcflagtof(ch11a(i),hb11a(i)) = 1
633             endif
634             if (tof11(right,i,iadc).eq.4095) then
635                xkorr=adcx11(right,i,1)*exp(yhelp/adcx11(right,i,2))
636                xkorr=xkorr/hepratio
637                tof11(right,i,iadc)=xkorr/cos(theta13)
638    c            write(*,*) 'tofl2 right ',i, tof11(right,i,iadc)
639                adcflagtof(ch11b(i),hb11b(i)) = 1
640             endif
641           ENDIF
642    
643           xhelp=0.
644           if (tof11_i.GT.none_find) xhelp=tof11_x(tof11_i)
645           if (xtofpos(1).lt.100)  xhelp=xtofpos(1)
646    
647           IF (tof12_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
648             i = tof12_i
649             if (tof12(left,i,iadc).eq.4095) then
650                xkorr=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2))
651                xkorr=xkorr/hepratio
652                tof12(left,i,iadc) = xkorr/cos(theta13)
653                adcflagtof(ch12a(i),hb12a(i)) = 1
654             endif
655             if (tof12(right,i,iadc).eq.4095) then
656                xkorr=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2))
657                xkorr=xkorr/hepratio
658                tof12(right,i,iadc) = xkorr/cos(theta13)
659                adcflagtof(ch12b(i),hb12b(i)) = 1
660             endif
661           ENDIF
662    
663    C-----------------------------S2 --------------------------------
664    
665           xhelp=0.
666           if (tof22_i.GT.none_find) xhelp=tof22_x(tof22_i)
667           if (xtofpos(2).lt.100)  xhelp=xtofpos(2)
668    
669           IF (tof21_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
670             i = tof21_i
671             if (tof21(left,i,iadc).eq.4095) then
672                xkorr=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2))
673                xkorr=xkorr/hepratio
674                tof21(left,i,iadc) = xkorr/cos(theta13)
675                adcflagtof(ch21a(i),hb21a(i)) = 1
676             endif
677             if (tof21(right,i,iadc).eq.4095) then
678                xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2))
679                xkorr=xkorr/hepratio
680                tof21(right,i,iadc) = xkorr/cos(theta13)
681                adcflagtof(ch21b(i),hb21b(i)) = 1
682             endif
683           ENDIF
684    
685    
686           yhelp=0.
687           if (tof21_i.GT.none_find) yhelp=tof21_y(tof21_i)
688           if (ytofpos(2).lt.100)  yhelp=ytofpos(2)
689    
690           IF (tof22_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
691             i = tof22_i
692             if (tof22(left,i,iadc).eq.4095) then
693                xkorr=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2))
694                xkorr=xkorr/hepratio
695                tof22(left,i,iadc) = xkorr/cos(theta13)
696                adcflagtof(ch22a(i),hb22a(i)) = 1
697             endif
698             if (tof22(right,i,iadc).eq.4095) then
699                xkorr=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2))
700                xkorr=xkorr/hepratio
701                tof22(right,i,iadc) = xkorr/cos(theta13)
702                adcflagtof(ch22b(i),hb22b(i)) = 1
703             endif
704           ENDIF
705    
706    C-----------------------------S3 --------------------------------
707    
708           yhelp=0.
709           if (tof32_i.GT.none_find) yhelp=tof32_y(tof32_i)
710           if (ytofpos(3).lt.100)  yhelp=ytofpos(3)
711    
712           IF (tof31_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
713             i = tof31_i
714             if (tof31(left,i,iadc).eq.4095) then
715                xkorr=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2))
716                xkorr=xkorr/hepratio
717                tof31(left,i,iadc) = xkorr/cos(theta13)
718                adcflagtof(ch31a(i),hb31a(i)) = 1
719             endif
720             if (tof31(right,i,iadc).eq.4095) then
721                xkorr=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2))
722                xkorr=xkorr/hepratio
723                tof31(right,i,iadc) = xkorr/cos(theta13)
724                adcflagtof(ch31b(i),hb31b(i)) = 1
725             endif
726           ENDIF
727    
728           xhelp=0.
729           if (tof31_i.GT.none_find) xhelp=tof31_x(tof31_i)
730           if (xtofpos(3).lt.100)  xhelp=xtofpos(3)
731    
732           IF (tof32_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
733             i = tof32_i
734             if (tof32(left,i,iadc).eq.4095) then
735                xkorr=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2))
736                xkorr=xkorr/hepratio
737                tof32(left,i,iadc) = xkorr/cos(theta13)
738                adcflagtof(ch32a(i),hb32a(i)) = 1
739             endif
740             if (tof32(right,i,iadc).eq.4095) then
741                xkorr=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2))
742                xkorr=xkorr/hepratio
743                tof32(right,i,iadc) = xkorr/cos(theta13)
744                adcflagtof(ch32b(i),hb32b(i)) = 1
745             endif
746           ENDIF
747    
748    
749  C--------------------------------------------------------------------  C--------------------------------------------------------------------
750  C--------------------Time walk correction  -------------------------  C--------------------Time walk correction  -------------------------
# Line 422  C--------------------------------------- Line 753  C---------------------------------------
753        DO i=1,8        DO i=1,8
754         xhelp_a = tof11(left,i,iadc)         xhelp_a = tof11(left,i,iadc)
755         xhelp_t = tof11(left,i,itdc)         xhelp_t = tof11(left,i,itdc)
756         if(xhelp_a>0) xhelp = tw11(left,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw11(left,i)/sqrt(xhelp_a)
757         tof11(left,i,itdc) = xhelp_t  + xhelp         tof11(left,i,itdc) = xhelp_t  + xhelp
758         tdc_c(ch11a(i),hb11a(i))=tof11(left,i,itdc)         tdc_c(ch11a(i),hb11a(i))=tof11(left,i,itdc)
759         xhelp_a = tof11(right,i,iadc)         xhelp_a = tof11(right,i,iadc)
760         xhelp_t = tof11(right,i,itdc)         xhelp_t = tof11(right,i,itdc)
761         if(xhelp_a>0) xhelp = tw11(right,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw11(right,i)/sqrt(xhelp_a)
762         tof11(right,i,itdc) = xhelp_t  + xhelp         tof11(right,i,itdc) = xhelp_t  + xhelp
763         tdc_c(ch11b(i),hb11b(i))=tof11(right,i,itdc)         tdc_c(ch11b(i),hb11b(i))=tof11(right,i,itdc)
764        ENDDO        ENDDO
# Line 435  C--------------------------------------- Line 766  C---------------------------------------
766        DO i=1,6        DO i=1,6
767         xhelp_a = tof12(left,i,iadc)         xhelp_a = tof12(left,i,iadc)
768         xhelp_t = tof12(left,i,itdc)         xhelp_t = tof12(left,i,itdc)
769         if(xhelp_a>0) xhelp = tw12(left,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw12(left,i)/sqrt(xhelp_a)
770         tof12(left,i,itdc) = xhelp_t  + xhelp         tof12(left,i,itdc) = xhelp_t  + xhelp
771         tdc_c(ch12a(i),hb12a(i))=tof12(left,i,itdc)         tdc_c(ch12a(i),hb12a(i))=tof12(left,i,itdc)
772         xhelp_a = tof12(right,i,iadc)         xhelp_a = tof12(right,i,iadc)
773         xhelp_t = tof12(right,i,itdc)         xhelp_t = tof12(right,i,itdc)
774         if(xhelp_a>0) xhelp = tw12(right,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw12(right,i)/sqrt(xhelp_a)
775         tof12(right,i,itdc) = xhelp_t  + xhelp         tof12(right,i,itdc) = xhelp_t  + xhelp
776         tdc_c(ch12b(i),hb12b(i))=tof12(right,i,itdc)         tdc_c(ch12b(i),hb12b(i))=tof12(right,i,itdc)
777        ENDDO        ENDDO
# Line 448  C---- Line 779  C----
779        DO i=1,2        DO i=1,2
780         xhelp_a = tof21(left,i,iadc)         xhelp_a = tof21(left,i,iadc)
781         xhelp_t = tof21(left,i,itdc)         xhelp_t = tof21(left,i,itdc)
782         if(xhelp_a>0) xhelp = tw21(left,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw21(left,i)/sqrt(xhelp_a)
783         tof21(left,i,itdc) = xhelp_t  + xhelp         tof21(left,i,itdc) = xhelp_t  + xhelp
784         tdc_c(ch21a(i),hb21a(i))=tof21(left,i,itdc)         tdc_c(ch21a(i),hb21a(i))=tof21(left,i,itdc)
785         xhelp_a = tof21(right,i,iadc)         xhelp_a = tof21(right,i,iadc)
786         xhelp_t = tof21(right,i,itdc)         xhelp_t = tof21(right,i,itdc)
787         if(xhelp_a>0) xhelp = tw21(right,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw21(right,i)/sqrt(xhelp_a)
788         tof21(right,i,itdc) = xhelp_t  + xhelp         tof21(right,i,itdc) = xhelp_t  + xhelp
789         tdc_c(ch21b(i),hb21b(i))=tof21(right,i,itdc)         tdc_c(ch21b(i),hb21b(i))=tof21(right,i,itdc)
790        ENDDO        ENDDO
# Line 461  C---- Line 792  C----
792        DO i=1,2        DO i=1,2
793         xhelp_a = tof22(left,i,iadc)         xhelp_a = tof22(left,i,iadc)
794         xhelp_t = tof22(left,i,itdc)         xhelp_t = tof22(left,i,itdc)
795         if(xhelp_a>0) xhelp = tw22(left,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw22(left,i)/sqrt(xhelp_a)
796         tof22(left,i,itdc) = xhelp_t  + xhelp         tof22(left,i,itdc) = xhelp_t  + xhelp
797         tdc_c(ch22a(i),hb22a(i))=tof22(left,i,itdc)         tdc_c(ch22a(i),hb22a(i))=tof22(left,i,itdc)
798         xhelp_a = tof22(right,i,iadc)         xhelp_a = tof22(right,i,iadc)
799         xhelp_t = tof22(right,i,itdc)         xhelp_t = tof22(right,i,itdc)
800         if(xhelp_a>0) xhelp = tw22(right,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw22(right,i)/sqrt(xhelp_a)
801         tof22(right,i,itdc) = xhelp_t  + xhelp         tof22(right,i,itdc) = xhelp_t  + xhelp
802         tdc_c(ch22b(i),hb22b(i))=tof22(right,i,itdc)         tdc_c(ch22b(i),hb22b(i))=tof22(right,i,itdc)
803        ENDDO        ENDDO
# Line 475  C---- Line 806  C----
806        DO i=1,3        DO i=1,3
807         xhelp_a = tof31(left,i,iadc)         xhelp_a = tof31(left,i,iadc)
808         xhelp_t = tof31(left,i,itdc)         xhelp_t = tof31(left,i,itdc)
809         if(xhelp_a>0) xhelp = tw31(left,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw31(left,i)/sqrt(xhelp_a)
810         tof31(left,i,itdc) = xhelp_t  + xhelp         tof31(left,i,itdc) = xhelp_t  + xhelp
811         tdc_c(ch31a(i),hb31a(i))=tof31(left,i,itdc)         tdc_c(ch31a(i),hb31a(i))=tof31(left,i,itdc)
812         xhelp_a = tof31(right,i,iadc)         xhelp_a = tof31(right,i,iadc)
813         xhelp_t = tof31(right,i,itdc)         xhelp_t = tof31(right,i,itdc)
814         if(xhelp_a>0) xhelp = tw31(right,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw31(right,i)/sqrt(xhelp_a)
815         tof31(right,i,itdc) = xhelp_t  + xhelp         tof31(right,i,itdc) = xhelp_t  + xhelp
816         tdc_c(ch31b(i),hb31b(i))=tof31(right,i,itdc)         tdc_c(ch31b(i),hb31b(i))=tof31(right,i,itdc)
817        ENDDO        ENDDO
# Line 488  C---- Line 819  C----
819        DO i=1,3        DO i=1,3
820         xhelp_a = tof32(left,i,iadc)         xhelp_a = tof32(left,i,iadc)
821         xhelp_t = tof32(left,i,itdc)         xhelp_t = tof32(left,i,itdc)
822         if(xhelp_a>0) xhelp = tw32(left,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw32(left,i)/sqrt(xhelp_a)
823         tof32(left,i,itdc) = xhelp_t  + xhelp         tof32(left,i,itdc) = xhelp_t  + xhelp
824         tdc_c(ch32a(i),hb32a(i))=tof32(left,i,itdc)         tdc_c(ch32a(i),hb32a(i))=tof32(left,i,itdc)
825         xhelp_a = tof32(right,i,iadc)         xhelp_a = tof32(right,i,iadc)
826         xhelp_t = tof32(right,i,itdc)         xhelp_t = tof32(right,i,itdc)
827         if(xhelp_a>0) xhelp = tw32(right,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw32(right,i)/sqrt(xhelp_a)
828         tof32(right,i,itdc) = xhelp_t  + xhelp         tof32(right,i,itdc) = xhelp_t  + xhelp
829         tdc_c(ch32b(i),hb32b(i))=tof32(right,i,itdc)         tdc_c(ch32b(i),hb32b(i))=tof32(right,i,itdc)
830        ENDDO        ENDDO
 C----  
   
 C------------------------------------------------------------------  
 C---  calculate track position in paddle using timing difference  
 C------------------------------------------------------------------  
   
       do i=1,3  
          xtofpos(i)=100.  
          ytofpos(i)=100.  
       enddo  
 C-----------------------------S1 --------------------------------  
   
       IF (tof11_i.GT.none_find) THEN  
          ytofpos(1)  = ((tof11(1,tof11_i,itdc)-tof11(2,tof11_i,itdc))/2.  
      +        -y_coor_lin11(tof11_i,offset))/y_coor_lin11(tof11_i,slope)  
       endif  
   
       IF (tof12_i.GT.none_find) THEN  
          xtofpos(1)  = ((tof12(1,tof12_i,itdc)-tof12(2,tof12_i,itdc))/2.  
      +        -x_coor_lin12(tof12_i,offset))/x_coor_lin12(tof12_i,slope)  
       endif  
   
   
 C-----------------------------S2 --------------------------------  
   
       IF (tof21_i.GT.none_find) THEN  
          xtofpos(2) = ((tof21(1,tof21_i,itdc)-tof21(2,tof21_i,itdc))/2.  
      +        -x_coor_lin21(tof21_i,offset))/x_coor_lin21(tof21_i,slope)  
       endif  
   
       IF (tof22_i.GT.none_find) THEN  
          ytofpos(2) = ((tof22(1,tof22_i,itdc)-tof22(2,tof22_i,itdc))/2.  
      +        -y_coor_lin22(tof22_i,offset))/y_coor_lin22(tof22_i,slope)  
       endif  
         
   
 C-----------------------------S3 --------------------------------  
   
       IF (tof31_i.GT.none_find) THEN  
          ytofpos(3)  = ((tof31(1,tof31_i,itdc)-tof31(2,tof31_i,itdc))/2.  
      +        -y_coor_lin31(tof31_i,offset))/y_coor_lin31(tof31_i,slope)  
       endif  
   
       IF (tof32_i.GT.none_find) THEN  
          xtofpos(3)  = ((tof32(1,tof32_i,itdc)-tof32(2,tof32_i,itdc))/2.  
      +        -x_coor_lin32(tof32_i,offset))/x_coor_lin32(tof32_i,slope)  
       endif  
   
   
       do i=1,3  
          if (abs(xtofpos(i)).gt.100.) then  
             xtofpos(i)=101.  
          endif  
          if (abs(ytofpos(i)).gt.100.) then  
             ytofpos(i)=101.  
          endif  
       enddo  
831    
832  C----------------------------------------------------------------------  C----------------------------------------------------------------------
 C--------------------Corrections on ADC-data -------------------------  
 C---------------------zenith angle theta  ---------------------------  
 C----------------------------------------------------------------------  
   
       dx=0.  
       dy=0.  
       dr=0.  
       theta13 = 0.  
   
          IF ((tof12_i.GT.none_find).AND.(tof32_i.GT.none_find))  
      &        dx  = xtofpos(1) - xtofpos(3)  
          IF ((tof11_i.GT.none_find).AND.(tof31_i.GT.none_find))  
      &        dy  = ytofpos(1) - ytofpos(3)  
          dr = sqrt(dx*dx+dy*dy)  
          theta13 = atan(dr/tofarm13)  
   
       dx=0.  
       dy=0.  
       dr=0.  
       theta12 = 0.  
   
          IF ((tof12_i.GT.none_find).AND.(tof21_i.GT.none_find))  
      &        dx  = xtofpos(1) - xtofpos(2)  
          IF ((tof11_i.GT.none_find).AND.(tof22_i.GT.none_find))  
      &        dy  = ytofpos(1) - ytofpos(2)  
          dr = sqrt(dx*dx+dy*dy)  
          theta12 = atan(dr/tofarm12)  
           
       dx=0.  
       dy=0.  
       dr=0.  
       theta23 = 0.  
   
          IF ((tof21_i.GT.none_find).AND.(tof32_i.GT.none_find))  
      &        dx  = xtofpos(2) - xtofpos(3)  
          IF ((tof22_i.GT.none_find).AND.(tof31_i.GT.none_find))  
      &        dy  = ytofpos(2) - ytofpos(3)  
          dr = sqrt(dx*dx+dy*dy)  
          theta23 = atan(dr/tofarm23)  
           
           
 C----------------------------------------------------------------------  
833  C------------------angle and ADC(x) correction  C------------------angle and ADC(x) correction
834  C----------------------------------------------------------------------  C----------------------------------------------------------------------
835  C-----------------------------S1 --------------------------------  C-----------------------------S1 --------------------------------
836  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
837  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/
838  c       DATA tof12_y/ -13.75,-8.25,-2.75,2.75,8.25,13.75/  c       DATA tof12_y/ -13.75,-8.25,-2.75,2.75,8.25,13.75/
839  c       DATA tof21_y/ -3.75,3.75/  c       DATA tof21_y/  3.75,-3.75/     ! paddles in different order
840  c       DATA tof22_x/ -4.5,4.5/  c       DATA tof22_x/ -4.5,4.5/
841  c       DATA tof31_x/ -6.0,0.,6.0/  c       DATA tof31_x/ -6.0,0.,6.0/
842  c       DATA tof32_y/ -5.0,0.0,5.0/  c       DATA tof32_y/ -5.0,0.0,5.0/
# Line 616  c       DATA tof32_y/ -5.0,0.0,5.0/ Line 848  c       DATA tof32_y/ -5.0,0.0,5.0/
848        IF (tof11_i.GT.none_find.AND.abs(yhelp).lt.100) THEN        IF (tof11_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
849    
850           i = tof11_i           i = tof11_i
          xdummy=tof11(left,i,iadc)  
          tof11(left,i,iadc) = tof11(left,i,iadc)*cos(theta13)  
851           if (tof11(left,i,iadc).lt.4095) then           if (tof11(left,i,iadc).lt.4095) then
852                tof11(left,i,iadc) = tof11(left,i,iadc)*cos(theta13)
853              xkorr=adcx11(left,i,1)*exp(-yhelp/adcx11(left,i,2))              xkorr=adcx11(left,i,1)*exp(-yhelp/adcx11(left,i,2))
854              xkorr0=adcx11(left,i,1)              xkorr=xkorr/hepratio
855              adctof_c(ch11a(i),hb11a(i))=tof11(left,i,iadc)/xkorr              adctof_c(ch11a(i),hb11a(i))=tof11(left,i,iadc)/xkorr
856           endif           endif
857    
          tof11(right,i,iadc) = tof11(right,i,iadc)*cos(theta13)  
858           if (tof11(right,i,iadc).lt.4095) then           if (tof11(right,i,iadc).lt.4095) then
859                tof11(right,i,iadc) = tof11(right,i,iadc)*cos(theta13)
860              xkorr=adcx11(right,i,1)*exp(yhelp/adcx11(right,i,2))              xkorr=adcx11(right,i,1)*exp(yhelp/adcx11(right,i,2))
861              xkorr0=adcx11(right,i,1)              xkorr=xkorr/hepratio
862              adctof_c(ch11b(i),hb11b(i))=tof11(right,i,iadc)/xkorr              adctof_c(ch11b(i),hb11b(i))=tof11(right,i,iadc)/xkorr
863           endif           endif
864        ENDIF        ENDIF
# Line 639  c       DATA tof32_y/ -5.0,0.0,5.0/ Line 870  c       DATA tof32_y/ -5.0,0.0,5.0/
870        IF (tof12_i.GT.none_find.AND.abs(xhelp).lt.100) THEN        IF (tof12_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
871    
872           i = tof12_i           i = tof12_i
          tof12(left,i,iadc) = tof12(left,i,iadc)*cos(theta13)  
873           if (tof12(left,i,iadc).lt.4095) then           if (tof12(left,i,iadc).lt.4095) then
874                tof12(left,i,iadc) = tof12(left,i,iadc)*cos(theta13)
875              xkorr=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2))              xkorr=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2))
876              xkorr0=adcx12(left,i,1)              xkorr=xkorr/hepratio
877              adctof_c(ch12a(i),hb12a(i))=tof12(left,i,iadc)/xkorr              adctof_c(ch12a(i),hb12a(i))=tof12(left,i,iadc)/xkorr
878           endif           endif
879    
          tof12(right,i,iadc) = tof12(right,i,iadc)*cos(theta13)  
880           if (tof12(right,i,iadc).lt.4095) then           if (tof12(right,i,iadc).lt.4095) then
881                tof12(right,i,iadc) = tof12(right,i,iadc)*cos(theta13)
882              xkorr=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2))              xkorr=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2))
883              xkorr0=adcx12(right,i,1)              xkorr=xkorr/hepratio
884              adctof_c(ch12b(i),hb12b(i))=tof12(right,i,iadc)/xkorr              adctof_c(ch12b(i),hb12b(i))=tof12(right,i,iadc)/xkorr
885           endif           endif
886        ENDIF        ENDIF
# Line 663  C-----------------------------S2 ------- Line 894  C-----------------------------S2 -------
894        IF (tof21_i.GT.none_find.AND.abs(xhelp).lt.100) THEN        IF (tof21_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
895    
896           i = tof21_i           i = tof21_i
          tof21(left,i,iadc) = tof21(left,i,iadc)*cos(theta13)  
897           if (tof21(left,i,iadc).lt.4095) then           if (tof21(left,i,iadc).lt.4095) then
898                tof21(left,i,iadc) = tof21(left,i,iadc)*cos(theta13)
899              xkorr=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2))              xkorr=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2))
900              xkorr0=adcx21(left,i,1)              xkorr=xkorr/hepratio
901              adctof_c(ch21a(i),hb21a(i))=tof21(left,i,iadc)/xkorr              adctof_c(ch21a(i),hb21a(i))=tof21(left,i,iadc)/xkorr
902           endif           endif
903    
          tof21(right,i,iadc) = tof21(right,i,iadc)*cos(theta13)  
904           if (tof21(right,i,iadc).lt.4095) then           if (tof21(right,i,iadc).lt.4095) then
905                tof21(right,i,iadc) = tof21(right,i,iadc)*cos(theta13)
906              xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2))              xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2))
907              xkorr0=adcx21(right,i,1)              xkorr=xkorr/hepratio
908              adctof_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr              adctof_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr
909           endif           endif
910        ENDIF        ENDIF
# Line 686  C-----------------------------S2 ------- Line 917  C-----------------------------S2 -------
917        IF (tof22_i.GT.none_find.AND.abs(yhelp).lt.100) THEN        IF (tof22_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
918    
919           i = tof22_i           i = tof22_i
          tof22(left,i,iadc) = tof22(left,i,iadc)*cos(theta13)  
920           if (tof22(left,i,iadc).lt.4095) then           if (tof22(left,i,iadc).lt.4095) then
921                tof22(left,i,iadc) = tof22(left,i,iadc)*cos(theta13)
922              xkorr=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2))              xkorr=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2))
923              xkorr0=adcx22(left,i,1)              xkorr=xkorr/hepratio
924              adctof_c(ch22a(i),hb22a(i))=tof22(left,i,iadc)/xkorr              adctof_c(ch22a(i),hb22a(i))=tof22(left,i,iadc)/xkorr
925           endif           endif
926    
          tof22(right,i,iadc) = tof22(right,i,iadc)*cos(theta13)  
927           if (tof22(right,i,iadc).lt.4095) then           if (tof22(right,i,iadc).lt.4095) then
928                tof22(right,i,iadc) = tof22(right,i,iadc)*cos(theta13)
929              xkorr=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2))              xkorr=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2))
930              xkorr0=adcx22(right,i,1)              xkorr=xkorr/hepratio
931              adctof_c(ch22b(i),hb22b(i))=tof22(right,i,iadc)/xkorr              adctof_c(ch22b(i),hb22b(i))=tof22(right,i,iadc)/xkorr
932           endif           endif
933        ENDIF        ENDIF
# Line 710  C-----------------------------S3 ------- Line 941  C-----------------------------S3 -------
941        IF (tof31_i.GT.none_find.AND.abs(yhelp).lt.100) THEN        IF (tof31_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
942    
943           i = tof31_i           i = tof31_i
          tof31(left,i,iadc) = tof31(left,i,iadc)*cos(theta13)  
944           if (tof31(left,i,iadc).lt.4095) then           if (tof31(left,i,iadc).lt.4095) then
945                tof31(left,i,iadc) = tof31(left,i,iadc)*cos(theta13)
946              xkorr=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2))              xkorr=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2))
947              xkorr0=adcx31(left,i,1)              xkorr=xkorr/hepratio
948              adctof_c(ch31a(i),hb31a(i))=tof31(left,i,iadc)/xkorr              adctof_c(ch31a(i),hb31a(i))=tof31(left,i,iadc)/xkorr
949           endif           endif
950    
          tof31(right,i,iadc) = tof31(right,i,iadc)*cos(theta13)  
951           if (tof31(right,i,iadc).lt.4095) then           if (tof31(right,i,iadc).lt.4095) then
952                tof31(right,i,iadc) = tof31(right,i,iadc)*cos(theta13)
953              xkorr=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2))              xkorr=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2))
954              xkorr0=adcx31(right,i,1)              xkorr=xkorr/hepratio
955              adctof_c(ch31b(i),hb31b(i))=tof31(right,i,iadc)/xkorr              adctof_c(ch31b(i),hb31b(i))=tof31(right,i,iadc)/xkorr
956           endif           endif
957        ENDIF        ENDIF
# Line 732  C-----------------------------S3 ------- Line 963  C-----------------------------S3 -------
963        IF (tof32_i.GT.none_find.AND.abs(xhelp).lt.100) THEN        IF (tof32_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
964    
965           i = tof32_i           i = tof32_i
          tof32(left,i,iadc) = tof32(left,i,iadc)*cos(theta13)  
966           if (tof32(left,i,iadc).lt.4095) then           if (tof32(left,i,iadc).lt.4095) then
967                tof32(left,i,iadc) = tof32(left,i,iadc)*cos(theta13)
968              xkorr=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2))              xkorr=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2))
969              xkorr0=adcx32(left,i,1)              xkorr=xkorr/hepratio
970              adctof_c(ch32a(i),hb32a(i))=tof32(left,i,iadc)/xkorr              adctof_c(ch32a(i),hb32a(i))=tof32(left,i,iadc)/xkorr
971           endif           endif
972    
          tof32(right,i,iadc) = tof32(right,i,iadc)*cos(theta13)  
973           if (tof32(right,i,iadc).lt.4095) then           if (tof32(right,i,iadc).lt.4095) then
974                tof32(right,i,iadc) = tof32(right,i,iadc)*cos(theta13)
975              xkorr=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2))              xkorr=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2))
976              xkorr0=adcx32(right,i,1)              xkorr=xkorr/hepratio
977              adctof_c(ch32b(i),hb32b(i))=tof32(right,i,iadc)/xkorr              adctof_c(ch32b(i),hb32b(i))=tof32(right,i,iadc)/xkorr
978           endif           endif
979        ENDIF        ENDIF
980    
981  C-----------------------------------------------------------------------  
982    C--------------------------------------------------------------------
983  C----------------------calculate Beta  ------------------------------  C----------------------calculate Beta  ------------------------------
984  C-----------------------------------------------------------------------  C--------------------------------------------------------------------
985  C-------------------difference of sums  ---------------------------  C-------------------difference of sums  -----------------------------
986  C  C
987  C     DS = (t1+t2) - t3+t4)  C     DS = (t1+t2) - t3+t4)
988  C     DS = c1 + c2/beta*cos(theta)  C     DS = c1 + c2/beta*cos(theta)
# Line 759  C     =>  c2 =  ca.60 for  0.45 m    c2 Line 991  C     =>  c2 =  ca.60 for  0.45 m    c2
991  C     since TDC resolution varies slightly c2 has to be calibrated  C     since TDC resolution varies slightly c2 has to be calibrated
992    
993  C     S11 - S31  C     S11 - S31
994        IF (tof11_i.GT.none_find.AND.tof31_i.GT.none_find) THEN  
995           IF ((tof11_i.GT.none_find).AND.(tof31_i.GT.none_find).AND.
996         &    (ytofpos(1).NE.101.).AND.(ytofpos(3).NE.101.)) THEN
997           xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)           xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
998           xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)           xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
999           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 785  C------- Line 1019  C-------
1019        ENDIF        ENDIF
1020                
1021  C     S11 - S32  C     S11 - S32
1022        IF (tof11_i.GT.none_find.AND.tof32_i.GT.none_find) THEN  
1023           IF ((tof11_i.GT.none_find).AND.(tof32_i.GT.none_find).AND.
1024         &    (ytofpos(1).NE.101.).AND.(xtofpos(3).NE.101.)) THEN
1025           xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)           xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
1026           xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)           xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1027           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 811  C------- Line 1047  C-------
1047        ENDIF        ENDIF
1048                
1049  C     S12 - S31  C     S12 - S31
1050        IF (tof12_i.GT.none_find.AND.tof31_i.GT.none_find) THEN  
1051           IF ((tof12_i.GT.none_find).AND.(tof31_i.GT.none_find).AND.
1052         &    (xtofpos(1).NE.101.).AND.(ytofpos(3).NE.101.)) THEN
1053           xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)           xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1054           xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)           xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1055           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 837  C------- Line 1075  C-------
1075        ENDIF        ENDIF
1076                            
1077  C     S12 - S32  C     S12 - S32
1078        IF (tof12_i.GT.none_find.AND.tof32_i.GT.none_find) THEN  
1079           IF ((tof12_i.GT.none_find).AND.(tof32_i.GT.none_find).AND.
1080         &    (xtofpos(1).NE.101.).AND.(xtofpos(3).NE.101.)) THEN
1081           xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)           xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1082           xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)           xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1083           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 863  C------- Line 1103  C-------
1103        ENDIF        ENDIF
1104    
1105  C     S21 - S31  C     S21 - S31
1106        IF (tof21_i.GT.none_find.AND.tof31_i.GT.none_find) THEN  
1107           IF ((tof21_i.GT.none_find).AND.(tof31_i.GT.none_find).AND.
1108         &    (xtofpos(2).NE.101.).AND.(ytofpos(3).NE.101.)) THEN
1109           xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)           xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1110           xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)           xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1111           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
1112           ihelp=(tof21_i-1)*3+tof31_i           ihelp=(tof21_i-1)*3+tof31_i
1113           c1 = k_S21S31(1,ihelp)           c1 = k_S21S31(1,ihelp)
1114           c2 = k_S21S31(2,ihelp)           c2 = k_S21S31(2,ihelp)
1115           betatof_a(5) = c2/(cos(theta23)*(ds-c1))           betatof_a(5) = c2/(cos(theta13)*(ds-c1))
1116    
1117  C------- ToF Mask - S21 - S31  C------- ToF Mask - S21 - S31
1118    
# Line 889  C------- Line 1131  C-------
1131        ENDIF        ENDIF
1132    
1133  C     S21 - S32  C     S21 - S32
1134        IF (tof21_i.GT.none_find.AND.tof32_i.GT.none_find) THEN  
1135           IF ((tof21_i.GT.none_find).AND.(tof32_i.GT.none_find).AND.
1136         &    (xtofpos(2).NE.101.).AND.(xtofpos(3).NE.101.)) THEN
1137           xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)           xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1138           xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)           xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1139           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
1140           ihelp=(tof21_i-1)*3+tof32_i           ihelp=(tof21_i-1)*3+tof32_i
1141           c1 = k_S21S32(1,ihelp)           c1 = k_S21S32(1,ihelp)
1142           c2 = k_S21S32(2,ihelp)           c2 = k_S21S32(2,ihelp)
1143           betatof_a(6) = c2/(cos(theta23)*(ds-c1))           betatof_a(6) = c2/(cos(theta13)*(ds-c1))
1144                                        
1145  C------- ToF Mask - S21 - S32  C------- ToF Mask - S21 - S32
1146    
# Line 915  C------- Line 1159  C-------
1159        ENDIF        ENDIF
1160    
1161  C     S22 - S31  C     S22 - S31
1162        IF (tof22_i.GT.none_find.AND.tof31_i.GT.none_find) THEN  
1163           IF ((tof22_i.GT.none_find).AND.(tof31_i.GT.none_find).AND.
1164         &    (ytofpos(2).NE.101.).AND.(ytofpos(3).NE.101.)) THEN
1165           xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)           xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1166           xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)           xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1167           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 941  C-------           Line 1187  C-------          
1187        ENDIF        ENDIF
1188                
1189  C     S22 - S32  C     S22 - S32
1190        IF (tof22_i.GT.none_find.AND.tof32_i.GT.none_find) THEN  
1191           IF ((tof22_i.GT.none_find).AND.(tof32_i.GT.none_find).AND.
1192         &    (ytofpos(2).NE.101.).AND.(xtofpos(3).NE.101.)) THEN
1193           xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)           xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1194           xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)           xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1195           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 967  C-------   Line 1215  C-------  
1215        ENDIF        ENDIF
1216    
1217  C     S11 - S21  C     S11 - S21
1218        IF (tof11_i.GT.none_find.AND.tof21_i.GT.none_find) THEN  
1219           IF ((tof11_i.GT.none_find).AND.(tof21_i.GT.none_find).AND.
1220         &    (ytofpos(1).NE.101.).AND.(xtofpos(2).NE.101.)) THEN
1221           xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)           xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
1222           xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)           xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1223           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 993  C-------   Line 1243  C-------  
1243        ENDIF        ENDIF
1244                
1245  C     S11 - S22  C     S11 - S22
1246        IF (tof11_i.GT.none_find.AND.tof22_i.GT.none_find) THEN  
1247           IF ((tof11_i.GT.none_find).AND.(tof22_i.GT.none_find).AND.
1248         &    (ytofpos(1).NE.101.).AND.(ytofpos(2).NE.101.)) THEN
1249           xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)           xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
1250           xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)           xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1251           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 1019  C-------   Line 1271  C-------  
1271        ENDIF        ENDIF
1272    
1273  C     S12 - S21  C     S12 - S21
1274        IF (tof12_i.GT.none_find.AND.tof21_i.GT.none_find) THEN  
1275           IF ((tof12_i.GT.none_find).AND.(tof21_i.GT.none_find).AND.
1276         &    (xtofpos(1).NE.101.).AND.(xtofpos(2).NE.101.)) THEN
1277           xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)           xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1278           xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)           xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1279           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 1045  C-------   Line 1299  C-------  
1299        ENDIF        ENDIF
1300    
1301  C     S12 - S22  C     S12 - S22
1302        IF (tof12_i.GT.none_find.AND.tof22_i.GT.none_find) THEN  
1303           IF ((tof12_i.GT.none_find).AND.(tof22_i.GT.none_find).AND.
1304         &    (xtofpos(1).NE.101.).AND.(ytofpos(2).NE.101.)) THEN
1305           xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)           xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1306           xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)           xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1307           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 1091  C--------------------------------------- Line 1347  C---------------------------------------
1347        if (icount.gt.0) beta_mean=sxw/sw        if (icount.gt.0) beta_mean=sxw/sw
1348        betatof_a(13) = beta_mean        betatof_a(13) = beta_mean
1349    
1350    c      write(*,*) xtofpos
1351    c      write(*,*) ytofpos
1352    c      write(*,*) betatof_a
1353    C      write(*,*) adcflagtof
1354    
1355    
1356   100  continue   100  continue
1357    
1358  C  C
1359        RETURN        RETURN
1360        END        END
1361    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.23