/[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.2 by mocchiut, Thu Jul 6 09:03:28 2006 UTC revision 1.5 by mocchiut, Wed Feb 7 08:17:17 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    *  jan-07 WM: bug removed: in some cases tdc_tw was calculated due to a
16    *             leftover "xhelp" value
17    ******************************************************************************
18    
19        INTEGER FUNCTION TOFL2COM()        INTEGER FUNCTION TOFL2COM()
20  c      c    
21        IMPLICIT NONE        IMPLICIT NONE
# Line 17  C     Line 34  C    
34        REAL xhelp_a,xhelp_t        REAL xhelp_a,xhelp_t
35    
36        REAL dx,dy,dr,ds        REAL dx,dy,dr,ds
37        REAL yhelp,xdummy,xkorr0,xhelp,xhelp1,xhelp2        REAL yhelp,xhelp,xhelp1,xhelp2
38        REAL c1,c2,sw,sxw,w_i        REAL c1,c2,sw,sxw,w_i
39        INTEGER icount        INTEGER icount
40    
41    c      REAL xdummy
42    
43        INTEGER tof11_j,tof21_j,tof31_j        INTEGER tof11_j,tof21_j,tof31_j
44        INTEGER tof12_j,tof22_j,tof32_j        INTEGER tof12_j,tof22_j,tof32_j
45    
46    
47        REAL beta_mean        REAL beta_mean
48    
49    
# Line 35  c     second index : 1... number of padd Line 55  c     second index : 1... number of padd
55        INTEGER tof31_event(2,3),tof32_event(2,3)        INTEGER tof31_event(2,3),tof32_event(2,3)
56    
57                
58        REAL theta12,theta13,theta23        REAL theta13
59  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
60        REAL tofarm12        REAL tofarm12
61        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 63  C--   DATA ZTOF/53.74,53.04,23.94,23.44,
63        PARAMETER (tofarm23 = 47.61)  ! from 23.69 to -23.92        PARAMETER (tofarm23 = 47.61)  ! from 23.69 to -23.92
64        REAL tofarm13        REAL tofarm13
65        PARAMETER (tofarm13 = 77.31)  ! from 53.39 to -23.92        PARAMETER (tofarm13 = 77.31)  ! from 53.39 to -23.92
66          
67          REAL hepratio      
68    
69        INTEGER ihelp        INTEGER ihelp
70        REAL xkorr        REAL xkorr
# Line 63  C     Line 84  C    
84  *     amplitude has to be 'secure' higher than pedestal for an adc event  *     amplitude has to be 'secure' higher than pedestal for an adc event
85        secure = 2.        secure = 2.
86    
87    C     ratio between helium and proton ca. 4
88          hepratio = 4.5  !
89        offset = 1        offset = 1
90        slope = 2        slope = 2
91        left = 1        left = 1
# Line 99  C     Line 122  C    
122        enddo        enddo
123    
124    
125    c gf adc falg:
126          do i=1,4
127             do j=1,12
128                adcflagtof(i,j) = 0
129             enddo
130          enddo
131    
132    c gf tdc falg:
133          do i=1,4
134             do j=1,12
135                tdcflagtof(i,j) = 0
136             enddo
137          enddo
138    
139  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
140    
141    
# Line 195  C--------------------------------------- Line 232  C---------------------------------------
232           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.
233        ENDDO        ENDDO
234    
235    C----------------------------------------------------------------------
236    C------------------  set ADC & TDC flag = 0    ------------------------
237    C----------------------------------------------------------------------
238    
239          do j=1,8
240          if (adc(ch11a(j),hb11a(j)).LT.4096)adcflagtof(ch11a(j),hb11a(j))=0
241          if (adc(ch11b(j),hb11b(j)).LT.4096)adcflagtof(ch11b(j),hb11b(j))=0
242          if (tdc(ch11a(j),hb11a(j)).LT.4096)tdcflagtof(ch11a(j),hb11a(j))=0
243          if (tdc(ch11b(j),hb11b(j)).LT.4096)tdcflagtof(ch11b(j),hb11b(j))=0
244          enddo
245          do j=1,6
246          if (adc(ch12a(j),hb12a(j)).LT.4096)adcflagtof(ch12a(j),hb12a(j))=0
247          if (adc(ch12b(j),hb12b(j)).LT.4096)adcflagtof(ch12b(j),hb12b(j))=0
248          if (tdc(ch12a(j),hb12a(j)).LT.4096)tdcflagtof(ch12a(j),hb12a(j))=0
249          if (tdc(ch12b(j),hb12b(j)).LT.4096)tdcflagtof(ch12b(j),hb12b(j))=0
250          enddo
251          do j=1,2
252          if (adc(ch21a(j),hb21a(j)).LT.4096)adcflagtof(ch21a(j),hb21a(j))=0
253          if (adc(ch21b(j),hb21b(j)).LT.4096)adcflagtof(ch21b(j),hb21b(j))=0
254          if (tdc(ch21a(j),hb21a(j)).LT.4096)tdcflagtof(ch21a(j),hb21a(j))=0
255          if (tdc(ch21b(j),hb21b(j)).LT.4096)tdcflagtof(ch21b(j),hb21b(j))=0
256          enddo
257          do j=1,2
258          if (adc(ch22a(j),hb22a(j)).LT.4096)adcflagtof(ch22a(j),hb22a(j))=0
259          if (adc(ch22b(j),hb22b(j)).LT.4096)adcflagtof(ch22b(j),hb22b(j))=0
260          if (tdc(ch22a(j),hb22a(j)).LT.4096)tdcflagtof(ch22a(j),hb22a(j))=0
261          if (tdc(ch22b(j),hb22b(j)).LT.4096)tdcflagtof(ch22b(j),hb22b(j))=0
262          enddo
263          do j=1,3
264          if (adc(ch31a(j),hb31a(j)).LT.4096)adcflagtof(ch31a(j),hb31a(j))=0
265          if (adc(ch31b(j),hb31b(j)).LT.4096)adcflagtof(ch31b(j),hb31b(j))=0
266          if (tdc(ch31a(j),hb31a(j)).LT.4096)tdcflagtof(ch31a(j),hb31a(j))=0
267          if (tdc(ch31b(j),hb31b(j)).LT.4096)tdcflagtof(ch31b(j),hb31b(j))=0
268          enddo
269          do j=1,3
270          if (adc(ch32a(j),hb32a(j)).LT.4096)adcflagtof(ch32a(j),hb32a(j))=0
271          if (adc(ch32b(j),hb32b(j)).LT.4096)adcflagtof(ch32b(j),hb32b(j))=0
272          if (tdc(ch32a(j),hb32a(j)).LT.4096)tdcflagtof(ch32a(j),hb32a(j))=0
273          if (tdc(ch32b(j),hb32b(j)).LT.4096)tdcflagtof(ch32b(j),hb32b(j))=0
274          enddo
275    
276  C----------------------------------------------------------------  C----------------------------------------------------------------
277  C------------Check Paddles for hits  -----------------------  C---------- Check PMTs 10 and 35 for strange TDC values----------
278    C----------------------------------------------------------------
279    
280    C---- S116A TDC=819
281           if (tof11(1,6,1).EQ.819) then
282                 tof11(1,6,1) = 4095
283                 tdcflagtof(ch11a(6),hb11a(6))=2
284           endif
285      
286    C---- S222B TDC=819
287           if (tof22(2,2,1).EQ.819) then
288                 tof22(2,2,1) = 4095
289                 tdcflagtof(ch22b(2),hb22b(2))=2
290           endif
291    
292    
293    C----------------------------------------------------------------
294    C------------   Check Paddles for hits    -----------------------
295    C------  a "hit" means TDC values<4095 on both sides ------------
296  C----------------------------------------------------------------  C----------------------------------------------------------------
297    
298  C     upper tof  S11  C     upper tof  S11
# Line 206  C     upper tof  S11 Line 302  C     upper tof  S11
302              tof11_event(j,i) = none_ev              tof11_event(j,i) = none_ev
303              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))
304       +           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  
305           ENDDO           ENDDO
306        ENDDO        ENDDO
307    
# Line 239  C     upper tof  S12 Line 332  C     upper tof  S12
332              tof12_event(j,i) = none_ev              tof12_event(j,i) = none_ev
333              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))
334       +           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  
335           ENDDO           ENDDO
336        ENDDO        ENDDO
337    
# Line 272  C     middle tof  S21 Line 362  C     middle tof  S21
362              tof21_event(j,i) = none_ev              tof21_event(j,i) = none_ev
363              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))
364       +           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  
365           ENDDO           ENDDO
366        ENDDO        ENDDO
367    
# Line 304  C     middle tof  S22 Line 391  C     middle tof  S22
391              tof22_event(j,i) = none_ev              tof22_event(j,i) = none_ev
392              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))
393       +           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  
394           ENDDO           ENDDO
395        ENDDO        ENDDO
396    
# Line 337  C     bottom tof  S31 Line 421  C     bottom tof  S31
421              tof31_event(j,i) = none_ev              tof31_event(j,i) = none_ev
422              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))
423       +           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  
424           ENDDO           ENDDO
425        ENDDO        ENDDO
426    
# Line 369  C     bottom tof  S32 Line 450  C     bottom tof  S32
450              tof32_event(j,i) = none_ev              tof32_event(j,i) = none_ev
451              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))
452       +           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  
453           ENDDO           ENDDO
454        ENDDO        ENDDO
455    
# Line 414  c     check if an other paddle has also Line 492  c     check if an other paddle has also
492        tof_j_flag(5)=tof31_j        tof_j_flag(5)=tof31_j
493        tof_j_flag(6)=tof32_j        tof_j_flag(6)=tof32_j
494    
495            
496    C------------------------------------------------------------------
497    C---  calculate track position in paddle using timing difference
498    C------------------------------------------------------------------
499    
500          do i=1,3
501             xtofpos(i)=100.
502             ytofpos(i)=100.
503          enddo
504    C-----------------------------S1 --------------------------------
505    
506          IF (tof11_i.GT.none_find) THEN
507             ytofpos(1)  = ((tof11(1,tof11_i,itdc)-tof11(2,tof11_i,itdc))/2.
508         +        -y_coor_lin11(tof11_i,offset))/y_coor_lin11(tof11_i,slope)
509          endif
510    
511          IF (tof12_i.GT.none_find) THEN
512             xtofpos(1)  = ((tof12(1,tof12_i,itdc)-tof12(2,tof12_i,itdc))/2.
513         +        -x_coor_lin12(tof12_i,offset))/x_coor_lin12(tof12_i,slope)
514          endif
515    
516    
517    C-----------------------------S2 --------------------------------
518    
519          IF (tof21_i.GT.none_find) THEN
520             xtofpos(2) = ((tof21(1,tof21_i,itdc)-tof21(2,tof21_i,itdc))/2.
521         +        -x_coor_lin21(tof21_i,offset))/x_coor_lin21(tof21_i,slope)
522          endif
523    
524          IF (tof22_i.GT.none_find) THEN
525             ytofpos(2) = ((tof22(1,tof22_i,itdc)-tof22(2,tof22_i,itdc))/2.
526         +        -y_coor_lin22(tof22_i,offset))/y_coor_lin22(tof22_i,slope)
527          endif
528          
529    
530    C-----------------------------S3 --------------------------------
531    
532          IF (tof31_i.GT.none_find) THEN
533             ytofpos(3)  = ((tof31(1,tof31_i,itdc)-tof31(2,tof31_i,itdc))/2.
534         +        -y_coor_lin31(tof31_i,offset))/y_coor_lin31(tof31_i,slope)
535          endif
536    
537          IF (tof32_i.GT.none_find) THEN
538             xtofpos(3)  = ((tof32(1,tof32_i,itdc)-tof32(2,tof32_i,itdc))/2.
539         +        -x_coor_lin32(tof32_i,offset))/x_coor_lin32(tof32_i,slope)
540          endif
541    
542    
543    c      do i=1,3
544    c         if (abs(xtofpos(i)).gt.100.) then
545    c            xtofpos(i)=101.
546    c         endif
547    c         if (abs(ytofpos(i)).gt.100.) then
548    c            ytofpos(i)=101.
549    c         endif
550    c      enddo
551    
552    C--  restrict TDC measurements to physical paddle dimensions +/- 10 cm
553    C--  this cut is now stronger than in the old versions
554    
555            if (abs(xtofpos(1)).gt.31.)  xtofpos(1)=101.
556            if (abs(xtofpos(2)).gt.19.)  xtofpos(2)=101.
557            if (abs(xtofpos(3)).gt.19.)  xtofpos(3)=101.
558    
559            if (abs(ytofpos(1)).gt.26.)  ytofpos(1)=101.
560            if (abs(ytofpos(2)).gt.18.)  ytofpos(2)=101.
561            if (abs(ytofpos(3)).gt.18.)  ytofpos(3)=101.
562    
563    
564    C----------------------------------------------------------------------
565    C---------------------  zenith angle theta  ---------------------------
566    C----------------------------------------------------------------------
567    
568          dx=0.
569          dy=0.
570          dr=0.
571          theta13 = 0.
572    
573             IF ((tof12_i.GT.none_find).AND.(tof32_i.GT.none_find))
574         &        dx  = xtofpos(1) - xtofpos(3)
575             IF ((tof11_i.GT.none_find).AND.(tof31_i.GT.none_find))
576         &        dy  = ytofpos(1) - ytofpos(3)
577             dr = sqrt(dx*dx+dy*dy)
578             theta13 = atan(dr/tofarm13)
579    
580    C------------------------------------------------------------------
581    c      dx=0.
582    c      dy=0.
583    c      dr=0.
584    c      theta12 = 0.
585    c
586    c         IF ((tof12_i.GT.none_find).AND.(tof21_i.GT.none_find))
587    c     &        dx  = xtofpos(1) - xtofpos(2)
588    c         IF ((tof11_i.GT.none_find).AND.(tof22_i.GT.none_find))
589    c     &        dy  = ytofpos(1) - ytofpos(2)
590    c         dr = sqrt(dx*dx+dy*dy)
591    c         theta12 = atan(dr/tofarm12)
592    c        
593    c      dx=0.
594    c      dy=0.
595    c      dr=0.
596    c      theta23 = 0.
597    c
598    c         IF ((tof21_i.GT.none_find).AND.(tof32_i.GT.none_find))
599    c     &        dx  = xtofpos(2) - xtofpos(3)
600    c         IF ((tof22_i.GT.none_find).AND.(tof31_i.GT.none_find))
601    c     &        dy  = ytofpos(2) - ytofpos(3)
602    c         dr = sqrt(dx*dx+dy*dy)
603    c         theta23 = atan(dr/tofarm23)
604    c        
605    C---------------------------------------------------------------------
606    
607    
608    C--------------------------------------------------------------------
609    C---- if TDCleft.and.TDCright and NO ADC insert artificial ADC
610    C---- values
611    C--------------------------------------------------------------------
612    c middle y (or x) position of the upper and middle ToF-Paddle
613    c       DATA tof11_x/ -17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85/
614    c       DATA tof12_y/ -13.75,-8.25,-2.75,2.75,8.25,13.75/
615    c       DATA tof21_y/  3.75,-3.75/     ! paddles in different order
616    c       DATA tof22_x/ -4.5,4.5/
617    c       DATA tof31_x/ -6.0,0.,6.0/
618    c       DATA tof32_y/ -5.0,0.0,5.0/
619    
620    
621    C----------------------------  S1 -------------------------------------
622    
623           yhelp=0.
624           if (tof12_i.GT.none_find) yhelp=tof12_y(tof12_i)
625           if (ytofpos(1).lt.100)  yhelp=ytofpos(1)
626    
627           IF (tof11_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
628             i = tof11_i
629             if (tof11(left,i,iadc).eq.4095) then
630                xkorr=adcx11(left,i,1)*exp(-yhelp/adcx11(left,i,2))
631                xkorr=xkorr/hepratio
632                tof11(left,i,iadc)=xkorr/cos(theta13)
633    c            write(*,*) 'tofl2 left ',i, tof11(left,i,iadc)
634                adcflagtof(ch11a(i),hb11a(i)) = 1
635             endif
636             if (tof11(right,i,iadc).eq.4095) then
637                xkorr=adcx11(right,i,1)*exp(yhelp/adcx11(right,i,2))
638                xkorr=xkorr/hepratio
639                tof11(right,i,iadc)=xkorr/cos(theta13)
640    c            write(*,*) 'tofl2 right ',i, tof11(right,i,iadc)
641                adcflagtof(ch11b(i),hb11b(i)) = 1
642             endif
643           ENDIF
644    
645           xhelp=0.
646           if (tof11_i.GT.none_find) xhelp=tof11_x(tof11_i)
647           if (xtofpos(1).lt.100)  xhelp=xtofpos(1)
648    
649           IF (tof12_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
650             i = tof12_i
651             if (tof12(left,i,iadc).eq.4095) then
652                xkorr=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2))
653                xkorr=xkorr/hepratio
654                tof12(left,i,iadc) = xkorr/cos(theta13)
655                adcflagtof(ch12a(i),hb12a(i)) = 1
656             endif
657             if (tof12(right,i,iadc).eq.4095) then
658                xkorr=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2))
659                xkorr=xkorr/hepratio
660                tof12(right,i,iadc) = xkorr/cos(theta13)
661                adcflagtof(ch12b(i),hb12b(i)) = 1
662             endif
663           ENDIF
664    
665    C-----------------------------S2 --------------------------------
666    
667           xhelp=0.
668           if (tof22_i.GT.none_find) xhelp=tof22_x(tof22_i)
669           if (xtofpos(2).lt.100)  xhelp=xtofpos(2)
670    
671           IF (tof21_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
672             i = tof21_i
673             if (tof21(left,i,iadc).eq.4095) then
674                xkorr=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2))
675                xkorr=xkorr/hepratio
676                tof21(left,i,iadc) = xkorr/cos(theta13)
677                adcflagtof(ch21a(i),hb21a(i)) = 1
678             endif
679             if (tof21(right,i,iadc).eq.4095) then
680                xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2))
681                xkorr=xkorr/hepratio
682                tof21(right,i,iadc) = xkorr/cos(theta13)
683                adcflagtof(ch21b(i),hb21b(i)) = 1
684             endif
685           ENDIF
686    
687    
688           yhelp=0.
689           if (tof21_i.GT.none_find) yhelp=tof21_y(tof21_i)
690           if (ytofpos(2).lt.100)  yhelp=ytofpos(2)
691    
692           IF (tof22_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
693             i = tof22_i
694             if (tof22(left,i,iadc).eq.4095) then
695                xkorr=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2))
696                xkorr=xkorr/hepratio
697                tof22(left,i,iadc) = xkorr/cos(theta13)
698                adcflagtof(ch22a(i),hb22a(i)) = 1
699             endif
700             if (tof22(right,i,iadc).eq.4095) then
701                xkorr=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2))
702                xkorr=xkorr/hepratio
703                tof22(right,i,iadc) = xkorr/cos(theta13)
704                adcflagtof(ch22b(i),hb22b(i)) = 1
705             endif
706           ENDIF
707    
708    C-----------------------------S3 --------------------------------
709    
710           yhelp=0.
711           if (tof32_i.GT.none_find) yhelp=tof32_y(tof32_i)
712           if (ytofpos(3).lt.100)  yhelp=ytofpos(3)
713    
714           IF (tof31_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
715             i = tof31_i
716             if (tof31(left,i,iadc).eq.4095) then
717                xkorr=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2))
718                xkorr=xkorr/hepratio
719                tof31(left,i,iadc) = xkorr/cos(theta13)
720                adcflagtof(ch31a(i),hb31a(i)) = 1
721             endif
722             if (tof31(right,i,iadc).eq.4095) then
723                xkorr=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2))
724                xkorr=xkorr/hepratio
725                tof31(right,i,iadc) = xkorr/cos(theta13)
726                adcflagtof(ch31b(i),hb31b(i)) = 1
727             endif
728           ENDIF
729    
730           xhelp=0.
731           if (tof31_i.GT.none_find) xhelp=tof31_x(tof31_i)
732           if (xtofpos(3).lt.100)  xhelp=xtofpos(3)
733    
734           IF (tof32_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
735             i = tof32_i
736             if (tof32(left,i,iadc).eq.4095) then
737                xkorr=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2))
738                xkorr=xkorr/hepratio
739                tof32(left,i,iadc) = xkorr/cos(theta13)
740                adcflagtof(ch32a(i),hb32a(i)) = 1
741             endif
742             if (tof32(right,i,iadc).eq.4095) then
743                xkorr=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2))
744                xkorr=xkorr/hepratio
745                tof32(right,i,iadc) = xkorr/cos(theta13)
746                adcflagtof(ch32b(i),hb32b(i)) = 1
747             endif
748           ENDIF
749    
750    
751  C--------------------------------------------------------------------  C--------------------------------------------------------------------
752  C--------------------Time walk correction  -------------------------  C--------------------Time walk correction  -------------------------
753  C--------------------------------------------------------------------  C--------------------------------------------------------------------
754    
755        DO i=1,8        DO i=1,8
756           xhelp= 0.
757         xhelp_a = tof11(left,i,iadc)         xhelp_a = tof11(left,i,iadc)
758         xhelp_t = tof11(left,i,itdc)         xhelp_t = tof11(left,i,itdc)
759         if(xhelp_a>0) xhelp = tw11(left,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw11(left,i)/sqrt(xhelp_a)
760         tof11(left,i,itdc) = xhelp_t  + xhelp         tof11(left,i,itdc) = xhelp_t  + xhelp
761         tdc_c(ch11a(i),hb11a(i))=tof11(left,i,itdc)         tdc_c(ch11a(i),hb11a(i))=tof11(left,i,itdc)
762         xhelp_a = tof11(right,i,iadc)         xhelp_a = tof11(right,i,iadc)
763         xhelp_t = tof11(right,i,itdc)         xhelp_t = tof11(right,i,itdc)
764         if(xhelp_a>0) xhelp = tw11(right,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw11(right,i)/sqrt(xhelp_a)
765         tof11(right,i,itdc) = xhelp_t  + xhelp         tof11(right,i,itdc) = xhelp_t  + xhelp
766         tdc_c(ch11b(i),hb11b(i))=tof11(right,i,itdc)         tdc_c(ch11b(i),hb11b(i))=tof11(right,i,itdc)
767        ENDDO        ENDDO
768    
769        DO i=1,6        DO i=1,6
770           xhelp= 0.
771         xhelp_a = tof12(left,i,iadc)         xhelp_a = tof12(left,i,iadc)
772         xhelp_t = tof12(left,i,itdc)         xhelp_t = tof12(left,i,itdc)
773         if(xhelp_a>0) xhelp = tw12(left,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw12(left,i)/sqrt(xhelp_a)
774         tof12(left,i,itdc) = xhelp_t  + xhelp         tof12(left,i,itdc) = xhelp_t  + xhelp
775         tdc_c(ch12a(i),hb12a(i))=tof12(left,i,itdc)         tdc_c(ch12a(i),hb12a(i))=tof12(left,i,itdc)
776         xhelp_a = tof12(right,i,iadc)         xhelp_a = tof12(right,i,iadc)
777         xhelp_t = tof12(right,i,itdc)         xhelp_t = tof12(right,i,itdc)
778         if(xhelp_a>0) xhelp = tw12(right,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw12(right,i)/sqrt(xhelp_a)
779         tof12(right,i,itdc) = xhelp_t  + xhelp         tof12(right,i,itdc) = xhelp_t  + xhelp
780         tdc_c(ch12b(i),hb12b(i))=tof12(right,i,itdc)         tdc_c(ch12b(i),hb12b(i))=tof12(right,i,itdc)
781        ENDDO        ENDDO
782  C----  C----
783        DO i=1,2        DO i=1,2
784           xhelp= 0.
785         xhelp_a = tof21(left,i,iadc)         xhelp_a = tof21(left,i,iadc)
786         xhelp_t = tof21(left,i,itdc)         xhelp_t = tof21(left,i,itdc)
787         if(xhelp_a>0) xhelp = tw21(left,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw21(left,i)/sqrt(xhelp_a)
788         tof21(left,i,itdc) = xhelp_t  + xhelp         tof21(left,i,itdc) = xhelp_t  + xhelp
789         tdc_c(ch21a(i),hb21a(i))=tof21(left,i,itdc)         tdc_c(ch21a(i),hb21a(i))=tof21(left,i,itdc)
790         xhelp_a = tof21(right,i,iadc)         xhelp_a = tof21(right,i,iadc)
791         xhelp_t = tof21(right,i,itdc)         xhelp_t = tof21(right,i,itdc)
792         if(xhelp_a>0) xhelp = tw21(right,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw21(right,i)/sqrt(xhelp_a)
793         tof21(right,i,itdc) = xhelp_t  + xhelp         tof21(right,i,itdc) = xhelp_t  + xhelp
794         tdc_c(ch21b(i),hb21b(i))=tof21(right,i,itdc)         tdc_c(ch21b(i),hb21b(i))=tof21(right,i,itdc)
795        ENDDO        ENDDO
796    
797        DO i=1,2        DO i=1,2
798           xhelp= 0.
799         xhelp_a = tof22(left,i,iadc)         xhelp_a = tof22(left,i,iadc)
800         xhelp_t = tof22(left,i,itdc)         xhelp_t = tof22(left,i,itdc)
801         if(xhelp_a>0) xhelp = tw22(left,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw22(left,i)/sqrt(xhelp_a)
802         tof22(left,i,itdc) = xhelp_t  + xhelp         tof22(left,i,itdc) = xhelp_t  + xhelp
803         tdc_c(ch22a(i),hb22a(i))=tof22(left,i,itdc)         tdc_c(ch22a(i),hb22a(i))=tof22(left,i,itdc)
804         xhelp_a = tof22(right,i,iadc)         xhelp_a = tof22(right,i,iadc)
805         xhelp_t = tof22(right,i,itdc)         xhelp_t = tof22(right,i,itdc)
806         if(xhelp_a>0) xhelp = tw22(right,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw22(right,i)/sqrt(xhelp_a)
807         tof22(right,i,itdc) = xhelp_t  + xhelp         tof22(right,i,itdc) = xhelp_t  + xhelp
808         tdc_c(ch22b(i),hb22b(i))=tof22(right,i,itdc)         tdc_c(ch22b(i),hb22b(i))=tof22(right,i,itdc)
809        ENDDO        ENDDO
810  C----  C----
811    
812        DO i=1,3        DO i=1,3
813           xhelp= 0.
814         xhelp_a = tof31(left,i,iadc)         xhelp_a = tof31(left,i,iadc)
815         xhelp_t = tof31(left,i,itdc)         xhelp_t = tof31(left,i,itdc)
816         if(xhelp_a>0) xhelp = tw31(left,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw31(left,i)/sqrt(xhelp_a)
817         tof31(left,i,itdc) = xhelp_t  + xhelp         tof31(left,i,itdc) = xhelp_t  + xhelp
818         tdc_c(ch31a(i),hb31a(i))=tof31(left,i,itdc)         tdc_c(ch31a(i),hb31a(i))=tof31(left,i,itdc)
819         xhelp_a = tof31(right,i,iadc)         xhelp_a = tof31(right,i,iadc)
820         xhelp_t = tof31(right,i,itdc)         xhelp_t = tof31(right,i,itdc)
821         if(xhelp_a>0) xhelp = tw31(right,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw31(right,i)/sqrt(xhelp_a)
822         tof31(right,i,itdc) = xhelp_t  + xhelp         tof31(right,i,itdc) = xhelp_t  + xhelp
823         tdc_c(ch31b(i),hb31b(i))=tof31(right,i,itdc)         tdc_c(ch31b(i),hb31b(i))=tof31(right,i,itdc)
824        ENDDO        ENDDO
825    
826        DO i=1,3        DO i=1,3
827           xhelp= 0.
828         xhelp_a = tof32(left,i,iadc)         xhelp_a = tof32(left,i,iadc)
829         xhelp_t = tof32(left,i,itdc)         xhelp_t = tof32(left,i,itdc)
830         if(xhelp_a>0) xhelp = tw32(left,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw32(left,i)/sqrt(xhelp_a)
831         tof32(left,i,itdc) = xhelp_t  + xhelp         tof32(left,i,itdc) = xhelp_t  + xhelp
832         tdc_c(ch32a(i),hb32a(i))=tof32(left,i,itdc)         tdc_c(ch32a(i),hb32a(i))=tof32(left,i,itdc)
833         xhelp_a = tof32(right,i,iadc)         xhelp_a = tof32(right,i,iadc)
834         xhelp_t = tof32(right,i,itdc)         xhelp_t = tof32(right,i,itdc)
835         if(xhelp_a>0) xhelp = tw32(right,i)/sqrt(xhelp_a)         if(xhelp_a<4095) xhelp = tw32(right,i)/sqrt(xhelp_a)
836         tof32(right,i,itdc) = xhelp_t  + xhelp         tof32(right,i,itdc) = xhelp_t  + xhelp
837         tdc_c(ch32b(i),hb32b(i))=tof32(right,i,itdc)         tdc_c(ch32b(i),hb32b(i))=tof32(right,i,itdc)
838        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  
839    
840  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----------------------------------------------------------------------  
841  C------------------angle and ADC(x) correction  C------------------angle and ADC(x) correction
842  C----------------------------------------------------------------------  C----------------------------------------------------------------------
843  C-----------------------------S1 --------------------------------  C-----------------------------S1 --------------------------------
844  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
845  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/
846  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/
847  c       DATA tof21_y/ -3.75,3.75/  c       DATA tof21_y/  3.75,-3.75/     ! paddles in different order
848  c       DATA tof22_x/ -4.5,4.5/  c       DATA tof22_x/ -4.5,4.5/
849  c       DATA tof31_x/ -6.0,0.,6.0/  c       DATA tof31_x/ -6.0,0.,6.0/
850  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 856  c       DATA tof32_y/ -5.0,0.0,5.0/
856        IF (tof11_i.GT.none_find.AND.abs(yhelp).lt.100) THEN        IF (tof11_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
857    
858           i = tof11_i           i = tof11_i
859           xdummy=tof11(left,i,iadc)           if (tof11(left,i,iadc).lt.4095) then
860           tof11(left,i,iadc) = tof11(left,i,iadc)*cos(theta13)              tof11(left,i,iadc) = tof11(left,i,iadc)*cos(theta13)
          if (tof11(left,i,iadc).lt.1000) then  
861              xkorr=adcx11(left,i,1)*exp(-yhelp/adcx11(left,i,2))              xkorr=adcx11(left,i,1)*exp(-yhelp/adcx11(left,i,2))
862              xkorr0=adcx11(left,i,1)              xkorr=xkorr/hepratio
863              adctof_c(ch11a(i),hb11a(i))=tof11(left,i,iadc)/xkorr              adctof_c(ch11a(i),hb11a(i))=tof11(left,i,iadc)/xkorr
864           endif           endif
865    
866           tof11(right,i,iadc) = tof11(right,i,iadc)*cos(theta13)           if (tof11(right,i,iadc).lt.4095) then
867           if (tof11(right,i,iadc).lt.1000) then              tof11(right,i,iadc) = tof11(right,i,iadc)*cos(theta13)
868              xkorr=adcx11(right,i,1)*exp(yhelp/adcx11(right,i,2))              xkorr=adcx11(right,i,1)*exp(yhelp/adcx11(right,i,2))
869              xkorr0=adcx11(right,i,1)              xkorr=xkorr/hepratio
870              adctof_c(ch11b(i),hb11b(i))=tof11(right,i,iadc)/xkorr              adctof_c(ch11b(i),hb11b(i))=tof11(right,i,iadc)/xkorr
871           endif           endif
872        ENDIF        ENDIF
# Line 639  c       DATA tof32_y/ -5.0,0.0,5.0/ Line 878  c       DATA tof32_y/ -5.0,0.0,5.0/
878        IF (tof12_i.GT.none_find.AND.abs(xhelp).lt.100) THEN        IF (tof12_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
879    
880           i = tof12_i           i = tof12_i
881           tof12(left,i,iadc) = tof12(left,i,iadc)*cos(theta13)           if (tof12(left,i,iadc).lt.4095) then
882           if (tof12(left,i,iadc).lt.1000) then              tof12(left,i,iadc) = tof12(left,i,iadc)*cos(theta13)
883              xkorr=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2))              xkorr=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2))
884              xkorr0=adcx12(left,i,1)              xkorr=xkorr/hepratio
885              adctof_c(ch12a(i),hb12a(i))=tof12(left,i,iadc)/xkorr              adctof_c(ch12a(i),hb12a(i))=tof12(left,i,iadc)/xkorr
886           endif           endif
887    
888           tof12(right,i,iadc) = tof12(right,i,iadc)*cos(theta13)           if (tof12(right,i,iadc).lt.4095) then
889           if (tof12(right,i,iadc).lt.1000) then              tof12(right,i,iadc) = tof12(right,i,iadc)*cos(theta13)
890              xkorr=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2))              xkorr=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2))
891              xkorr0=adcx12(right,i,1)              xkorr=xkorr/hepratio
892              adctof_c(ch12b(i),hb12b(i))=tof12(right,i,iadc)/xkorr              adctof_c(ch12b(i),hb12b(i))=tof12(right,i,iadc)/xkorr
893           endif           endif
894        ENDIF        ENDIF
# Line 663  C-----------------------------S2 ------- Line 902  C-----------------------------S2 -------
902        IF (tof21_i.GT.none_find.AND.abs(xhelp).lt.100) THEN        IF (tof21_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
903    
904           i = tof21_i           i = tof21_i
905           tof21(left,i,iadc) = tof21(left,i,iadc)*cos(theta13)           if (tof21(left,i,iadc).lt.4095) then
906           if (tof21(left,i,iadc).lt.1000) then              tof21(left,i,iadc) = tof21(left,i,iadc)*cos(theta13)
907              xkorr=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2))              xkorr=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2))
908              xkorr0=adcx21(left,i,1)              xkorr=xkorr/hepratio
909              adctof_c(ch21a(i),hb21a(i))=tof21(left,i,iadc)/xkorr              adctof_c(ch21a(i),hb21a(i))=tof21(left,i,iadc)/xkorr
910           endif           endif
911    
912           tof21(right,i,iadc) = tof21(right,i,iadc)*cos(theta13)           if (tof21(right,i,iadc).lt.4095) then
913           if (tof21(right,i,iadc).lt.1000) then              tof21(right,i,iadc) = tof21(right,i,iadc)*cos(theta13)
914              xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2))              xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2))
915              xkorr0=adcx21(right,i,1)              xkorr=xkorr/hepratio
916              adctof_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr              adctof_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr
917           endif           endif
918        ENDIF        ENDIF
# Line 686  C-----------------------------S2 ------- Line 925  C-----------------------------S2 -------
925        IF (tof22_i.GT.none_find.AND.abs(yhelp).lt.100) THEN        IF (tof22_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
926    
927           i = tof22_i           i = tof22_i
928           tof22(left,i,iadc) = tof22(left,i,iadc)*cos(theta13)           if (tof22(left,i,iadc).lt.4095) then
929           if (tof22(left,i,iadc).lt.1000) then              tof22(left,i,iadc) = tof22(left,i,iadc)*cos(theta13)
930              xkorr=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2))              xkorr=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2))
931              xkorr0=adcx22(left,i,1)              xkorr=xkorr/hepratio
932              adctof_c(ch22a(i),hb22a(i))=tof22(left,i,iadc)/xkorr              adctof_c(ch22a(i),hb22a(i))=tof22(left,i,iadc)/xkorr
933           endif           endif
934    
935           tof22(right,i,iadc) = tof22(right,i,iadc)*cos(theta13)           if (tof22(right,i,iadc).lt.4095) then
936           if (tof22(right,i,iadc).lt.1000) then              tof22(right,i,iadc) = tof22(right,i,iadc)*cos(theta13)
937              xkorr=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2))              xkorr=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2))
938              xkorr0=adcx22(right,i,1)              xkorr=xkorr/hepratio
939              adctof_c(ch22b(i),hb22b(i))=tof22(right,i,iadc)/xkorr              adctof_c(ch22b(i),hb22b(i))=tof22(right,i,iadc)/xkorr
940           endif           endif
941        ENDIF        ENDIF
# Line 710  C-----------------------------S3 ------- Line 949  C-----------------------------S3 -------
949        IF (tof31_i.GT.none_find.AND.abs(yhelp).lt.100) THEN        IF (tof31_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
950    
951           i = tof31_i           i = tof31_i
952           tof31(left,i,iadc) = tof31(left,i,iadc)*cos(theta13)           if (tof31(left,i,iadc).lt.4095) then
953           if (tof31(left,i,iadc).lt.1000) then              tof31(left,i,iadc) = tof31(left,i,iadc)*cos(theta13)
954              xkorr=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2))              xkorr=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2))
955              xkorr0=adcx31(left,i,1)              xkorr=xkorr/hepratio
956              adctof_c(ch31a(i),hb31a(i))=tof31(left,i,iadc)/xkorr              adctof_c(ch31a(i),hb31a(i))=tof31(left,i,iadc)/xkorr
957           endif           endif
958    
959           tof31(right,i,iadc) = tof31(right,i,iadc)*cos(theta13)           if (tof31(right,i,iadc).lt.4095) then
960           if (tof31(right,i,iadc).lt.1000) then              tof31(right,i,iadc) = tof31(right,i,iadc)*cos(theta13)
961              xkorr=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2))              xkorr=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2))
962              xkorr0=adcx31(right,i,1)              xkorr=xkorr/hepratio
963              adctof_c(ch31b(i),hb31b(i))=tof31(right,i,iadc)/xkorr              adctof_c(ch31b(i),hb31b(i))=tof31(right,i,iadc)/xkorr
964           endif           endif
965        ENDIF        ENDIF
# Line 732  C-----------------------------S3 ------- Line 971  C-----------------------------S3 -------
971        IF (tof32_i.GT.none_find.AND.abs(xhelp).lt.100) THEN        IF (tof32_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
972    
973           i = tof32_i           i = tof32_i
974           tof32(left,i,iadc) = tof32(left,i,iadc)*cos(theta13)           if (tof32(left,i,iadc).lt.4095) then
975           if (tof32(left,i,iadc).lt.1000) then              tof32(left,i,iadc) = tof32(left,i,iadc)*cos(theta13)
976              xkorr=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2))              xkorr=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2))
977              xkorr0=adcx32(left,i,1)              xkorr=xkorr/hepratio
978              adctof_c(ch32a(i),hb32a(i))=tof32(left,i,iadc)/xkorr              adctof_c(ch32a(i),hb32a(i))=tof32(left,i,iadc)/xkorr
979           endif           endif
980    
981           tof32(right,i,iadc) = tof32(right,i,iadc)*cos(theta13)           if (tof32(right,i,iadc).lt.4095) then
982           if (tof32(right,i,iadc).lt.1000) then              tof32(right,i,iadc) = tof32(right,i,iadc)*cos(theta13)
983              xkorr=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2))              xkorr=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2))
984              xkorr0=adcx32(right,i,1)              xkorr=xkorr/hepratio
985              adctof_c(ch32b(i),hb32b(i))=tof32(right,i,iadc)/xkorr              adctof_c(ch32b(i),hb32b(i))=tof32(right,i,iadc)/xkorr
986           endif           endif
987        ENDIF        ENDIF
988    
989  C-----------------------------------------------------------------------  
990    C--------------------------------------------------------------------
991  C----------------------calculate Beta  ------------------------------  C----------------------calculate Beta  ------------------------------
992  C-----------------------------------------------------------------------  C--------------------------------------------------------------------
993  C-------------------difference of sums  ---------------------------  C-------------------difference of sums  -----------------------------
994  C  C
995  C     DS = (t1+t2) - t3+t4)  C     DS = (t1+t2) - t3+t4)
996  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 999  C     =>  c2 =  ca.60 for  0.45 m    c2
999  C     since TDC resolution varies slightly c2 has to be calibrated  C     since TDC resolution varies slightly c2 has to be calibrated
1000    
1001  C     S11 - S31  C     S11 - S31
1002        IF (tof11_i.GT.none_find.AND.tof31_i.GT.none_find) THEN  
1003           IF ((tof11_i.GT.none_find).AND.(tof31_i.GT.none_find).AND.
1004         &    (ytofpos(1).NE.101.).AND.(ytofpos(3).NE.101.)) THEN
1005           xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)           xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
1006           xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)           xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1007           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 785  C------- Line 1027  C-------
1027        ENDIF        ENDIF
1028                
1029  C     S11 - S32  C     S11 - S32
1030        IF (tof11_i.GT.none_find.AND.tof32_i.GT.none_find) THEN  
1031           IF ((tof11_i.GT.none_find).AND.(tof32_i.GT.none_find).AND.
1032         &    (ytofpos(1).NE.101.).AND.(xtofpos(3).NE.101.)) THEN
1033           xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)           xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
1034           xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)           xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1035           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 811  C------- Line 1055  C-------
1055        ENDIF        ENDIF
1056                
1057  C     S12 - S31  C     S12 - S31
1058        IF (tof12_i.GT.none_find.AND.tof31_i.GT.none_find) THEN  
1059           IF ((tof12_i.GT.none_find).AND.(tof31_i.GT.none_find).AND.
1060         &    (xtofpos(1).NE.101.).AND.(ytofpos(3).NE.101.)) THEN
1061           xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)           xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1062           xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)           xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1063           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 837  C------- Line 1083  C-------
1083        ENDIF        ENDIF
1084                            
1085  C     S12 - S32  C     S12 - S32
1086        IF (tof12_i.GT.none_find.AND.tof32_i.GT.none_find) THEN  
1087           IF ((tof12_i.GT.none_find).AND.(tof32_i.GT.none_find).AND.
1088         &    (xtofpos(1).NE.101.).AND.(xtofpos(3).NE.101.)) THEN
1089           xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)           xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1090           xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)           xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1091           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 863  C------- Line 1111  C-------
1111        ENDIF        ENDIF
1112    
1113  C     S21 - S31  C     S21 - S31
1114        IF (tof21_i.GT.none_find.AND.tof31_i.GT.none_find) THEN  
1115           IF ((tof21_i.GT.none_find).AND.(tof31_i.GT.none_find).AND.
1116         &    (xtofpos(2).NE.101.).AND.(ytofpos(3).NE.101.)) THEN
1117           xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)           xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1118           xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)           xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1119           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
1120           ihelp=(tof21_i-1)*3+tof31_i           ihelp=(tof21_i-1)*3+tof31_i
1121           c1 = k_S21S31(1,ihelp)           c1 = k_S21S31(1,ihelp)
1122           c2 = k_S21S31(2,ihelp)           c2 = k_S21S31(2,ihelp)
1123           betatof_a(5) = c2/(cos(theta23)*(ds-c1))           betatof_a(5) = c2/(cos(theta13)*(ds-c1))
1124    
1125  C------- ToF Mask - S21 - S31  C------- ToF Mask - S21 - S31
1126    
# Line 889  C------- Line 1139  C-------
1139        ENDIF        ENDIF
1140    
1141  C     S21 - S32  C     S21 - S32
1142        IF (tof21_i.GT.none_find.AND.tof32_i.GT.none_find) THEN  
1143           IF ((tof21_i.GT.none_find).AND.(tof32_i.GT.none_find).AND.
1144         &    (xtofpos(2).NE.101.).AND.(xtofpos(3).NE.101.)) THEN
1145           xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)           xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1146           xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)           xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1147           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
1148           ihelp=(tof21_i-1)*3+tof32_i           ihelp=(tof21_i-1)*3+tof32_i
1149           c1 = k_S21S32(1,ihelp)           c1 = k_S21S32(1,ihelp)
1150           c2 = k_S21S32(2,ihelp)           c2 = k_S21S32(2,ihelp)
1151           betatof_a(6) = c2/(cos(theta23)*(ds-c1))           betatof_a(6) = c2/(cos(theta13)*(ds-c1))
1152                                        
1153  C------- ToF Mask - S21 - S32  C------- ToF Mask - S21 - S32
1154    
# Line 915  C------- Line 1167  C-------
1167        ENDIF        ENDIF
1168    
1169  C     S22 - S31  C     S22 - S31
1170        IF (tof22_i.GT.none_find.AND.tof31_i.GT.none_find) THEN  
1171           IF ((tof22_i.GT.none_find).AND.(tof31_i.GT.none_find).AND.
1172         &    (ytofpos(2).NE.101.).AND.(ytofpos(3).NE.101.)) THEN
1173           xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)           xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1174           xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)           xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1175           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 941  C-------           Line 1195  C-------          
1195        ENDIF        ENDIF
1196                
1197  C     S22 - S32  C     S22 - S32
1198        IF (tof22_i.GT.none_find.AND.tof32_i.GT.none_find) THEN  
1199           IF ((tof22_i.GT.none_find).AND.(tof32_i.GT.none_find).AND.
1200         &    (ytofpos(2).NE.101.).AND.(xtofpos(3).NE.101.)) THEN
1201           xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)           xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1202           xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)           xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1203           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 967  C-------   Line 1223  C-------  
1223        ENDIF        ENDIF
1224    
1225  C     S11 - S21  C     S11 - S21
1226        IF (tof11_i.GT.none_find.AND.tof21_i.GT.none_find) THEN  
1227           IF ((tof11_i.GT.none_find).AND.(tof21_i.GT.none_find).AND.
1228         &    (ytofpos(1).NE.101.).AND.(xtofpos(2).NE.101.)) THEN
1229           xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)           xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
1230           xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)           xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1231           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 993  C-------   Line 1251  C-------  
1251        ENDIF        ENDIF
1252                
1253  C     S11 - S22  C     S11 - S22
1254        IF (tof11_i.GT.none_find.AND.tof22_i.GT.none_find) THEN  
1255           IF ((tof11_i.GT.none_find).AND.(tof22_i.GT.none_find).AND.
1256         &    (ytofpos(1).NE.101.).AND.(ytofpos(2).NE.101.)) THEN
1257           xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)           xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
1258           xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)           xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1259           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 1019  C-------   Line 1279  C-------  
1279        ENDIF        ENDIF
1280    
1281  C     S12 - S21  C     S12 - S21
1282        IF (tof12_i.GT.none_find.AND.tof21_i.GT.none_find) THEN  
1283           IF ((tof12_i.GT.none_find).AND.(tof21_i.GT.none_find).AND.
1284         &    (xtofpos(1).NE.101.).AND.(xtofpos(2).NE.101.)) THEN
1285           xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)           xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1286           xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)           xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1287           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 1045  C-------   Line 1307  C-------  
1307        ENDIF        ENDIF
1308    
1309  C     S12 - S22  C     S12 - S22
1310        IF (tof12_i.GT.none_find.AND.tof22_i.GT.none_find) THEN  
1311           IF ((tof12_i.GT.none_find).AND.(tof22_i.GT.none_find).AND.
1312         &    (xtofpos(1).NE.101.).AND.(ytofpos(2).NE.101.)) THEN
1313           xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)           xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1314           xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)           xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1315           ds = xhelp1-xhelp2           ds = xhelp1-xhelp2
# Line 1091  C--------------------------------------- Line 1355  C---------------------------------------
1355        if (icount.gt.0) beta_mean=sxw/sw        if (icount.gt.0) beta_mean=sxw/sw
1356        betatof_a(13) = beta_mean        betatof_a(13) = beta_mean
1357    
1358    c      write(*,*) xtofpos
1359    c      write(*,*) ytofpos
1360    c      write(*,*) betatof_a
1361    C      write(*,*) adcflagtof
1362    
1363    
1364   100  continue   100  continue
1365    
1366  C  C
1367        RETURN        RETURN
1368        END        END
1369    

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.23