/[PAMELA software]/tof/ground/tofroutine.f
ViewVC logotype

Annotation of /tof/ground/tofroutine.f

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Thu Mar 9 12:31:47 2006 UTC (18 years, 9 months ago) by pam-de
Branch point for: v_tag, MAIN
Initial revision

1 pam-de 1.1 SUBROUTINE TOFROUTINE(XOUT,YOUT,ALPHA)
2    
3     C------------------------------------------------
4     C W. Menn
5     C
6     C Version 1.00 August 2005
7     C Version 1.01 7-oct-2005
8     C changed initialization values of xtofpos and ytofpos to "100."
9     C if the calculated values are unphysical (> +/- 100), then they
10     C are set to "101." to avoid problems in the attenuation calculation
11     C------------------------------------------------
12    
13    
14     include 'common_tofroutine.f'
15     include 'common_tof.f'
16    
17     c =======================================
18     c variables for tracking routine
19     c =======================================
20     parameter(NPOINT_MAX=100)
21     REAL XOUT(NPOINT_MAX),YOUT(NPOINT_MAX)
22     REAL ALPHA(5)
23    
24    
25     * ******************************************************************
26     * eventcounter
27     c write(*,*) '--- in beta.f ----'
28    
29    
30     * amplitude has to be 'secure' higher than pedestal for an adc event
31     secure = 2.
32    
33     xtop = 1000.0
34     xmid = 1000.0
35     xbot = 1000.0
36    
37     offset = 1
38     slope = 2
39     top = 1
40     mid = 2
41     bot = 3
42     left = 1
43     right = 2
44     none_ev = 0
45     none_find = 0
46     tdc_ev = 1
47     adc_ev = 1
48     itdc = 1
49     iadc = 2
50    
51     do i=1,5
52     beta_a(i) = 1000.
53     enddo
54    
55     do i=1,4
56     do j=1,12
57     adc_c(i,j) = 1000.
58     enddo
59     enddo
60    
61    
62     c the calibration files are read in the main program from xxx_tofcalib.rz
63    
64     IF (TOFfst.EQ.0) THEN
65     TOFfst = 1
66    
67     write(*,*) 'Calibration Data'
68     write(*,*) 'K1 data '
69     write(*,*) 'S11-S31'
70     DO i = 1,24
71     write(*,*) i,k1_S11S31(i)
72     ENDDO
73    
74     write(*,*) 'S12-S32'
75     DO i = 1,18
76     write (*,*) i,k1_S12S32(i)
77     ENDDO
78    
79     write(*,*) 'S21-S31'
80     DO i = 1,6
81     write(*,*) i,k1_S21S31(i)
82     ENDDO
83    
84     write(*,*) 'S22-S32'
85     DO i = 1,6
86     write (*,*) i,k1_S22S32(i)
87     ENDDO
88    
89    
90     C--- use TDC-difference to calculate incident point
91    
92     write(*,*) 'X-Y-Lin Coordinates'
93     DO i = 1, 8
94     write(*,*) i,y_coor_lin11(i,1),y_coor_lin11(i,2)
95     ENDDO
96     DO i = 1, 6
97     write(*,*) i,x_coor_lin12(i,1),x_coor_lin12(i,2)
98     ENDDO
99     DO i = 1, 2
100     write(*,*) i,x_coor_lin21(i,1),x_coor_lin21(i,2)
101     ENDDO
102     DO i = 1, 2
103     write(*,*) i,y_coor_lin22(i,1),y_coor_lin22(i,2)
104     ENDDO
105     DO i = 1, 3
106     write(*,*) i,y_coor_lin31(i,1),y_coor_lin31(i,2)
107     ENDDO
108     DO i = 1, 3
109     write(*,*) i,x_coor_lin32(i,1),x_coor_lin32(i,2)
110     ENDDO
111    
112     c---------- Time Walk
113    
114     write(*,*) 'Time Walk'
115     DO i = 1,8
116     write(*,*) i,tw11(left,i), tw11(right,i)
117     ENDDO
118     DO i = 1,6
119     write(*,*) i,tw12(left,i), tw12(right,i)
120     ENDDO
121     DO i = 1,2
122     write(*,*) i,tw21(left,i), tw21(right,i)
123     ENDDO
124     DO i = 1,2
125     write(*,*) i,tw22(left,i), tw22(right,i)
126     ENDDO
127     DO i = 1,3
128     write(*,*) i,tw31(left,i), tw31(right,i)
129     ENDDO
130     DO i = 1,3
131     write(*,*) i,tw32(left,i), tw32(right,i)
132     ENDDO
133    
134     c---------- ADC map
135     c read ADC correction file
136    
137     write(*,*) 'ADC Map'
138     write(*,*) 'ADC Map 1'
139     DO i = 1,8
140     write(*,*) (adcx11(left,i,j),j=1,2)
141     write(*,*) (adcx11(right,i,j),j=1,2)
142     ENDDO
143     DO i = 1,6
144     write(*,*) (adcx12(left,i,j),j=1,2)
145     write(*,*) (adcx12(right,i,j),j=1,2)
146     ENDDO
147    
148     write(*,*) 'ADC map 2'
149     DO i = 1,2
150     write(*,*) (adcx21(left,i,j),j=1,2)
151     write(*,*) (adcx21(right,i,j),j=1,2)
152     ENDDO
153     DO i = 1,2
154     write(*,*) (adcx22(left,i,j),j=1,2)
155     write(*,*) (adcx22(right,i,j),j=1,2)
156     ENDDO
157    
158     write(*,*) 'ADC map 3'
159     DO i = 1,3
160     write(*,*) (adcx31(left,i,j),j=1,2)
161     write(*,*) (adcx31(right,i,j),j=1,2)
162     ENDDO
163     DO i = 1,3
164     write(*,*) (adcx32(left,i,j),j=1,2)
165     write(*,*) (adcx32(right,i,j),j=1,2)
166     ENDDO
167    
168     ENDIF
169     c end of reading parameter files
170    
171     c------------------------- get ToF data --------------------------------
172    
173     c put the adc and tdc values from ntuple into tofxx(i,j,k) variables
174    
175     do j=1,8
176     tof11(1,j,2) = adc(ch11a(j),hb11a(j))
177     tof11(2,j,2) = adc(ch11b(j),hb11b(j))
178     tof11(1,j,1) = tdc(ch11a(j),hb11a(j))
179     tof11(2,j,1) = tdc(ch11b(j),hb11b(j))
180     c write(*,*) j,adc(ch11a(j),hb11a(j)),adc(ch11b(j),hb11b(j))
181     enddo
182    
183     do j=1,6
184     tof12(1,j,2) = adc(ch12a(j),hb12a(j))
185     tof12(2,j,2) = adc(ch12b(j),hb12b(j))
186     tof12(1,j,1) = tdc(ch12a(j),hb12a(j))
187     tof12(2,j,1) = tdc(ch12b(j),hb12b(j))
188     enddo
189    
190     do j=1,2
191     tof21(1,j,2) = adc(ch21a(j),hb21a(j))
192     tof21(2,j,2) = adc(ch21b(j),hb21b(j))
193     tof21(1,j,1) = tdc(ch21a(j),hb21a(j))
194     tof21(2,j,1) = tdc(ch21b(j),hb21b(j))
195     enddo
196    
197     do j=1,2
198     tof22(1,j,2) = adc(ch22a(j),hb22a(j))
199     tof22(2,j,2) = adc(ch22b(j),hb22b(j))
200     tof22(1,j,1) = tdc(ch22a(j),hb22a(j))
201     tof22(2,j,1) = tdc(ch22b(j),hb22b(j))
202     enddo
203    
204     do j=1,3
205     tof31(1,j,2) = adc(ch31a(j),hb31a(j))
206     tof31(2,j,2) = adc(ch31b(j),hb31b(j))
207     tof31(1,j,1) = tdc(ch31a(j),hb31a(j))
208     tof31(2,j,1) = tdc(ch31b(j),hb31b(j))
209     enddo
210    
211     do j=1,3
212     tof32(1,j,2) = adc(ch32a(j),hb32a(j))
213     tof32(2,j,2) = adc(ch32b(j),hb32b(j))
214     tof32(1,j,1) = tdc(ch32a(j),hb32a(j))
215     tof32(2,j,1) = tdc(ch32b(j),hb32b(j))
216     enddo
217    
218     C----------------------------------------------------------------------
219    
220     DO i = 1,8
221     if (abs(tof11(1,i,itdc)).gt.10000.) tof11(1,i,itdc)= 10000.
222     if (abs(tof11(2,i,itdc)).gt.10000.) tof11(2,i,itdc)= 10000.
223     if (abs(tof11(1,i,iadc)).gt.10000.) tof11(1,i,iadc)= 10000.
224     if (abs(tof11(2,i,iadc)).gt.10000.) tof11(2,i,iadc)= 10000.
225     ENDDO
226    
227     DO i = 1,6
228     if (abs(tof12(1,i,itdc)).gt.10000.) tof12(1,i,itdc)= 10000.
229     if (abs(tof12(2,i,itdc)).gt.10000.) tof12(2,i,itdc)= 10000.
230     if (abs(tof12(1,i,iadc)).gt.10000.) tof12(1,i,iadc)= 10000.
231     if (abs(tof12(2,i,iadc)).gt.10000.) tof12(2,i,iadc)= 10000.
232     ENDDO
233    
234    
235     DO i = 1,2
236     if (abs(tof21(1,i,itdc)).gt.10000.) tof21(1,i,itdc)= 10000.
237     if (abs(tof21(2,i,itdc)).gt.10000.) tof21(2,i,itdc)= 10000.
238     if (abs(tof21(1,i,iadc)).gt.10000.) tof21(1,i,iadc)= 10000.
239     if (abs(tof21(2,i,iadc)).gt.10000.) tof21(2,i,iadc)= 10000.
240     ENDDO
241    
242     DO i = 1,2
243     if (abs(tof22(1,i,itdc)).gt.10000.) tof22(1,i,itdc)= 10000.
244     if (abs(tof22(2,i,itdc)).gt.10000.) tof22(2,i,itdc)= 10000.
245     if (abs(tof22(1,i,iadc)).gt.10000.) tof22(1,i,iadc)= 10000.
246     if (abs(tof22(2,i,iadc)).gt.10000.) tof22(2,i,iadc)= 10000.
247     ENDDO
248    
249     DO i = 1,3
250     if (abs(tof31(1,i,itdc)).gt.10000.) tof31(1,i,itdc)= 10000.
251     if (abs(tof31(2,i,itdc)).gt.10000.) tof31(2,i,itdc)= 10000.
252     if (abs(tof31(1,i,iadc)).gt.10000.) tof31(1,i,iadc)= 10000.
253     if (abs(tof31(2,i,iadc)).gt.10000.) tof31(2,i,iadc)= 10000.
254     ENDDO
255    
256     DO i = 1,3
257     if (abs(tof32(1,i,itdc)).gt.10000.) tof32(1,i,itdc)= 10000.
258     if (abs(tof32(2,i,itdc)).gt.10000.) tof32(2,i,itdc)= 10000.
259     if (abs(tof32(1,i,iadc)).gt.10000.) tof32(1,i,iadc)= 10000.
260     if (abs(tof32(2,i,iadc)).gt.10000.) tof32(2,i,iadc)= 10000.
261     ENDDO
262    
263     C----------------------------------------------------------------
264     C------------ Check Paddles for hits -----------------------
265     C----------------------------------------------------------------
266    
267     C upper tof S11
268     DO i = 1,8
269     DO j = 1,2
270     tof11_event(j,i) = none_ev
271     IF ((tof11(j,i,itdc).LT.2000).AND.(tof11(j,i,itdc).GT.100))
272     + tof11_event(j,i) = tof11_event(j,i) + tdc_ev
273     IF ((tof11(j,i,iadc).GT.secure).AND.
274     + (tof11(j,i,iadc).LT.4095))
275     + tof11_event(j,i) = tof11_event(j,i) + adc_ev
276     ENDDO
277     ENDDO
278    
279     c find single paddle in upper tof with tdc and adc signal
280     tof11_i = none_find
281     tof11_j = none_find
282     check = .TRUE.
283     DO i = 1, 8
284     IF ((tof11_event(left,i).GE.1).AND.(tof11_event(right,i).GE.1))
285     + THEN
286     c check if an other paddle has also an event - then set flag
287     tof11_j = tof11_j + 2**(i-1)
288     IF (check.EQV..TRUE.) THEN
289     IF (tof11_i.EQ.none_find) THEN
290     tof11_i = i
291     ELSE
292     tof11_i = -1
293     check = .FALSE.
294     ENDIF
295     ENDIF
296     ENDIF
297     ENDDO
298    
299    
300     C upper tof S12
301     DO i = 1,6
302     DO j = 1,2
303     tof12_event(j,i) = none_ev
304     IF ((tof12(j,i,itdc).LT.2000).AND.(tof12(j,i,itdc).GT.100))
305     + tof12_event(j,i) = tof12_event(j,i) + tdc_ev
306     IF ((tof12(j,i,iadc).GT.secure).AND.
307     + (tof12(j,i,iadc).LT.4095))
308     + tof12_event(j,i) = tof12_event(j,i) + adc_ev
309     ENDDO
310     ENDDO
311    
312     c find single paddle in upper tof with tdc and adc signal
313     tof12_i = none_find
314     tof12_j = none_find
315     check = .TRUE.
316     DO i = 1, 6
317     IF ((tof12_event(left,i).GE.1).AND.(tof12_event(right,i).GE.1))
318     + THEN
319     c check if an other paddle has also an event - then set flag
320     tof12_j = tof12_j + 2**(i-1)
321     IF (check.EQV..TRUE.) THEN
322     IF (tof12_i.EQ.none_find) THEN
323     tof12_i = i
324     ELSE
325     tof12_i = -1
326     check = .FALSE.
327     ENDIF
328     ENDIF
329     ENDIF
330     ENDDO
331    
332    
333     C middle tof S21
334     DO i = 1,2
335     DO j = 1,2
336     tof21_event(j,i) = none_ev
337     IF ((tof21(j,i,itdc).LT.2000).AND.(tof21(j,i,itdc).GT.100))
338     + tof21_event(j,i) = tof21_event(j,i) + tdc_ev
339     IF ((tof21(j,i,iadc).GT.secure).AND.
340     + (tof21(j,i,iadc).LT.4095))
341     + tof21_event(j,i) = tof21_event(j,i) + adc_ev
342     ENDDO
343     ENDDO
344    
345     c find single paddle in upper tof with tdc and adc signal
346     tof21_i = none_find
347     tof21_j = none_find
348     check = .TRUE.
349     DO i = 1, 2
350     IF ((tof21_event(left,i).GE.1).AND.(tof21_event(right,i).GE.1))
351     + THEN
352     c check if an other paddle has also an event - then set flag
353     tof21_j = tof21_j + 2**(i-1)
354     IF (check.EQV..TRUE.) THEN
355     IF (tof21_i.EQ.none_find) THEN
356     tof21_i = i
357     ELSE
358     tof21_i = -1
359     check = .FALSE.
360     ENDIF
361     ENDIF
362     ENDIF
363     ENDDO
364    
365     C middle tof S22
366     DO i = 1,2
367     DO j = 1,2
368     tof22_event(j,i) = none_ev
369     IF ((tof22(j,i,itdc).LT.2000).AND.(tof22(j,i,itdc).GT.100))
370     + tof22_event(j,i) = tof22_event(j,i) + tdc_ev
371     IF ((tof22(j,i,iadc).GT.secure).AND.
372     + (tof22(j,i,iadc).LT.4095))
373     + tof22_event(j,i) = tof22_event(j,i) + adc_ev
374     ENDDO
375     ENDDO
376    
377     c find single paddle in upper tof with tdc and adc signal
378     tof22_i = none_find
379     tof22_j = none_find
380     check = .TRUE.
381     DO i = 1, 2
382     IF ((tof22_event(left,i).GE.1).AND.(tof22_event(right,i).GE.1))
383     + THEN
384     c check if an other paddle has also an event - then set flag
385     tof22_j = tof22_j + 2**(i-1)
386     IF (check.EQV..TRUE.) THEN
387     IF (tof22_i.EQ.none_find) THEN
388     tof22_i = i
389     ELSE
390     tof22_i = -1
391     check = .FALSE.
392     ENDIF
393     ENDIF
394     ENDIF
395     ENDDO
396    
397    
398     C bottom tof S31
399     DO i = 1,3
400     DO j = 1,2
401     tof31_event(j,i) = none_ev
402     IF ((tof31(j,i,itdc).LT.2000).AND.(tof31(j,i,itdc).GT.100))
403     + tof31_event(j,i) = tof31_event(j,i) + tdc_ev
404     IF ((tof31(j,i,iadc).GT.secure).AND.
405     + (tof31(j,i,iadc).LT.4095))
406     + tof31_event(j,i) = tof31_event(j,i) + adc_ev
407     ENDDO
408     ENDDO
409    
410     c find single paddle in upper tof with tdc and adc signal
411     tof31_i = none_find
412     tof31_j = none_find
413     check = .TRUE.
414     DO i = 1, 3
415     IF ((tof31_event(left,i).GE.1).AND.(tof31_event(right,i).GE.1))
416     + THEN
417     c check if an other paddle has also an event - then set flag
418     tof31_j = tof31_j + 2**(i-1)
419     IF (check.EQV..TRUE.) THEN
420     IF (tof31_i.EQ.none_find) THEN
421     tof31_i = i
422     ELSE
423     tof31_i = -1
424     check = .FALSE.
425     ENDIF
426     ENDIF
427     ENDIF
428     ENDDO
429    
430     C bottom tof S32
431     DO i = 1,3
432     DO j = 1,2
433     tof32_event(j,i) = none_ev
434     IF ((tof32(j,i,itdc).LT.2000).AND.(tof32(j,i,itdc).GT.100))
435     + tof32_event(j,i) = tof32_event(j,i) + tdc_ev
436     IF ((tof32(j,i,iadc).GT.secure).AND.
437     + (tof32(j,i,iadc).LT.4095))
438     + tof32_event(j,i) = tof32_event(j,i) + adc_ev
439     ENDDO
440     ENDDO
441    
442     c find single paddle in upper tof with tdc and adc signal
443     tof32_i = none_find
444     tof32_j = none_find
445     check = .TRUE.
446     DO i = 1, 3
447     IF ((tof32_event(left,i).GE.1).AND.(tof32_event(right,i).GE.1))
448     + THEN
449     c check if an other paddle has also an event - then set flag
450     tof32_j = tof32_j + 2**(i-1)
451     IF (check.EQV..TRUE.) THEN
452     IF (tof32_i.EQ.none_find) THEN
453     tof32_i = i
454     ELSE
455     tof32_i = -1
456     check = .FALSE.
457     ENDIF
458     ENDIF
459     ENDIF
460     ENDDO
461    
462     do i=1,6
463     tof_i_flag(i)=0
464     tof_j_flag(i)=0
465     enddo
466    
467     tof_i_flag(1)=tof11_i
468     tof_i_flag(2)=tof12_i
469     tof_i_flag(3)=tof21_i
470     tof_i_flag(4)=tof22_i
471     tof_i_flag(5)=tof31_i
472     tof_i_flag(6)=tof32_i
473    
474     tof_j_flag(1)=tof11_j
475     tof_j_flag(2)=tof12_j
476     tof_j_flag(3)=tof21_j
477     tof_j_flag(4)=tof22_j
478     tof_j_flag(5)=tof31_j
479     tof_j_flag(6)=tof32_j
480    
481     C--------------------------------------------------------------------
482     C-------------------- Time walk correction -------------------------
483     C--------------------------------------------------------------------
484    
485     IF (tof11_i.GT.none_find) THEN
486     tof11(left,tof11_i,itdc) = tof11(left,tof11_i,itdc) +
487     + tw11(left,tof11_i)/sqrt(tof11(left,tof11_i,iadc))
488     tof11(right,tof11_i,itdc) = tof11(right,tof11_i,itdc) +
489     + tw11(right,tof11_i)/sqrt(tof11(right,tof11_i,iadc))
490     ENDIF
491    
492    
493     IF (tof12_i.GT.none_find) THEN
494     tof12(left,tof12_i,itdc) = tof12(left,tof12_i,itdc) +
495     + tw12(left,tof12_i)/sqrt(tof12(left,tof12_i,iadc))
496     tof12(right,tof12_i,itdc) = tof12(right,tof12_i,itdc) +
497     + tw12(right,tof12_i)/sqrt(tof12(right,tof12_i,iadc))
498     ENDIF
499    
500     IF (tof21_i.GT.none_find) THEN
501     tof21(left,tof21_i,itdc) = tof21(left,tof21_i,itdc) +
502     + tw21(left,tof21_i)/sqrt(tof21(left,tof21_i,iadc))
503     tof21(right,tof21_i,itdc) = tof21(right,tof21_i,itdc) +
504     + tw21(right,tof21_i)/sqrt(tof21(right,tof21_i,iadc))
505     ENDIF
506     IF (tof22_i.GT.none_find) THEN
507     tof22(left,tof22_i,itdc) = tof22(left,tof22_i,itdc) +
508     + tw22(left,tof22_i)/sqrt(tof22(left,tof22_i,iadc))
509     tof22(right,tof22_i,itdc) = tof22(right,tof22_i,itdc) +
510     + tw22(right,tof22_i)/sqrt(tof22(right,tof22_i,iadc))
511     ENDIF
512    
513     IF (tof31_i.GT.none_find) THEN
514     tof31(left,tof31_i,itdc) = tof31(left,tof31_i,itdc) +
515     + tw31(left,tof31_i)/sqrt(tof31(left,tof31_i,iadc))
516     tof31(right,tof31_i,itdc) = tof31(right,tof31_i,itdc) +
517     + tw31(right,tof31_i)/sqrt(tof31(right,tof31_i,iadc))
518     ENDIF
519    
520     IF (tof32_i.GT.none_find) THEN
521     tof32(left,tof32_i,itdc) = tof32(left,tof32_i,itdc) +
522     + tw32(left,tof32_i)/sqrt(tof32(left,tof32_i,iadc))
523     tof32(right,tof32_i,itdc) = tof32(right,tof32_i,itdc) +
524     + tw32(right,tof32_i)/sqrt(tof32(right,tof32_i,iadc))
525     ENDIF
526    
527    
528     C------------------------------------------------------------------
529     C--- calculate track position in paddle using timing difference
530     C------------------------------------------------------------------
531    
532     do i=1,3
533     xtofpos(i)=100.
534     ytofpos(i)=100.
535     enddo
536     C----------------------------- S1 --------------------------------
537    
538     IF (tof11_i.GT.none_find) THEN
539     ytofpos(1) = ((tof11(1,tof11_i,itdc)-tof11(2,tof11_i,itdc))/2.
540     + - y_coor_lin11(tof11_i,offset))/y_coor_lin11(tof11_i,slope)
541     endif
542    
543     IF (tof12_i.GT.none_find) THEN
544     xtofpos(1) = ((tof12(1,tof12_i,itdc)-tof12(2,tof12_i,itdc))/2.
545     + - x_coor_lin12(tof12_i,offset))/x_coor_lin12(tof12_i,slope)
546     endif
547    
548    
549     C----------------------------- S2 --------------------------------
550    
551     IF (tof21_i.GT.none_find) THEN
552     xtofpos(2) = ((tof21(1,tof21_i,itdc)-tof21(2,tof21_i,itdc))/2.
553     + - x_coor_lin21(tof21_i,offset))/x_coor_lin21(tof21_i,slope)
554     endif
555    
556     IF (tof22_i.GT.none_find) THEN
557     ytofpos(2) = ((tof22(1,tof22_i,itdc)-tof22(2,tof22_i,itdc))/2.
558     + - y_coor_lin22(tof22_i,offset))/y_coor_lin22(tof22_i,slope)
559     endif
560    
561    
562     C----------------------------- S3 --------------------------------
563    
564     IF (tof31_i.GT.none_find) THEN
565     ytofpos(3) = ((tof31(1,tof31_i,itdc)-tof31(2,tof31_i,itdc))/2.
566     + - y_coor_lin31(tof31_i,offset))/y_coor_lin31(tof31_i,slope)
567     c write(*,*) '31',tof31(1,tof31_i,itdc),tof31(2,tof31_i,itdc),
568     c + y_coor_lin31(tof31_i,offset),y_coor_lin31(tof31_i,slope),
569     c + ytofpos(3)
570     endif
571    
572     IF (tof32_i.GT.none_find) THEN
573     xtofpos(3) = ((tof32(1,tof32_i,itdc)-tof32(2,tof32_i,itdc))/2.
574     + - x_coor_lin32(tof32_i,offset))/x_coor_lin32(tof32_i,slope)
575     c write(*,*) '32',tof32(1,tof32_i,itdc),tof32(2,tof32_i,itdc),
576     c + x_coor_lin32(tof32_i,offset),x_coor_lin32(tof32_i,slope),
577     c + xtofpos(3)
578     endif
579    
580    
581     do i=1,3
582     if (abs(xtofpos(i)).gt.100.) then
583     xtofpos(i)=101.
584     endif
585     if (abs(ytofpos(i)).gt.100.) then
586     ytofpos(i)=101.
587     endif
588     enddo
589    
590    
591     C----------------------------------------------------------------------
592     C-------------------- Corrections on ADC-data -------------------------
593     C--------------------- zenith angle theta ---------------------------
594     C----------------------------------------------------------------------
595    
596     C if we have a good track use tracking information
597    
598     dx=0.
599     dy=0.
600     dr=0.
601     theta13 = 0.
602    
603     if (xout(1).lt.100.) then
604     dx = xout(1)-xout(3)
605     dy = yout(1)-yout(3)
606     dr = sqrt(dx*dx+dy*dy)
607     theta13 = atan(dr/tofarm13)
608     else
609     IF ((tof12_i.GT.none_find).AND.(tof32_i.GT.none_find))
610     & dx = xtofpos(1) - xtofpos(3)
611     IF ((tof11_i.GT.none_find).AND.(tof31_i.GT.none_find))
612     & dy = ytofpos(1) - ytofpos(3)
613     dr = sqrt(dx*dx+dy*dy)
614     theta13 = atan(dr/tofarm13)
615     endif
616    
617    
618     C----------------------------------------------------------------------
619     C------------------ angle and ADC(x) correction
620     C----------------------------------------------------------------------
621     C----------------------------- S1 --------------------------------
622    
623     yhelp=1000.
624     if (yout(1).lt.100.) then
625     yhelp=yout(1)
626     else
627     yhelp=ytofpos(1)
628     endif
629    
630    
631     IF (tof11_i.GT.none_find.AND.yhelp.lt.100) THEN
632    
633     i = tof11_i
634     xdummy=tof11(left,i,iadc)
635     tof11(left,i,iadc) = tof11(left,i,iadc)*cos(theta13)
636     if (tof11(left,i,iadc).lt.1000) then
637     xkorr=adcx11(left,i,1)*exp(-yhelp/adcx11(left,i,2))
638     xkorr0=adcx11(left,i,1)
639     adc_c(ch11a(i),hb11a(i))=tof11(left,i,iadc)/xkorr
640     endif
641    
642     tof11(right,i,iadc) = tof11(right,i,iadc)*cos(theta13)
643     if (tof11(right,i,iadc).lt.1000) then
644     xkorr=adcx11(right,i,1)*exp(yhelp/adcx11(right,i,2))
645     xkorr0=adcx11(right,i,1)
646     adc_c(ch11b(i),hb11b(i))=tof11(right,i,iadc)/xkorr
647     endif
648     ENDIF
649    
650    
651     xhelp=1000.
652     if (xout(1).lt.100.) then
653     xhelp=xout(1)
654     else
655     xhelp=xtofpos(1)
656     endif
657    
658    
659     IF (tof12_i.GT.none_find.AND.xhelp.lt.100) THEN
660    
661     i = tof12_i
662     tof12(left,i,iadc) = tof12(left,i,iadc)*cos(theta13)
663     if (tof12(left,i,iadc).lt.1000) then
664     xkorr=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2))
665     xkorr0=adcx12(left,i,1)
666     adc_c(ch12a(i),hb12a(i))=tof12(left,i,iadc)/xkorr
667     endif
668    
669     tof12(right,i,iadc) = tof12(right,i,iadc)*cos(theta13)
670     if (tof12(right,i,iadc).lt.1000) then
671     xkorr=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2))
672     xkorr0=adcx12(right,i,1)
673     adc_c(ch12b(i),hb12b(i))=tof12(right,i,iadc)/xkorr
674     endif
675     ENDIF
676    
677     C----------------------------- S2 --------------------------------
678    
679     xhelp=1000.
680     if (xout(2).lt.100.) then
681     xhelp=xout(2)
682     else
683     xhelp=xtofpos(2)
684     endif
685    
686     IF (tof21_i.GT.none_find.AND.xhelp.lt.100) THEN
687    
688     i = tof21_i
689     tof21(left,i,iadc) = tof21(left,i,iadc)*cos(theta13)
690     if (tof21(left,i,iadc).lt.1000) then
691     xkorr=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2))
692     xkorr0=adcx21(left,i,1)
693     adc_c(ch21a(i),hb21a(i))=tof21(left,i,iadc)/xkorr
694     endif
695    
696     tof21(right,i,iadc) = tof21(right,i,iadc)*cos(theta13)
697     if (tof21(right,i,iadc).lt.1000) then
698     xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2))
699     xkorr0=adcx21(right,i,1)
700     adc_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr
701     endif
702     ENDIF
703    
704     yhelp=1000.
705     if (yout(2).lt.100.) then
706     yhelp=yout(2)
707     else
708     yhelp=ytofpos(2)
709     endif
710    
711     IF (tof22_i.GT.none_find.AND.yhelp.lt.100) THEN
712    
713     i = tof22_i
714     tof22(left,i,iadc) = tof22(left,i,iadc)*cos(theta13)
715     if (tof22(left,i,iadc).lt.1000) then
716     xkorr=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2))
717     xkorr0=adcx22(left,i,1)
718     adc_c(ch22a(i),hb22a(i))=tof22(left,i,iadc)/xkorr
719     endif
720    
721     tof22(right,i,iadc) = tof22(right,i,iadc)*cos(theta13)
722     if (tof22(right,i,iadc).lt.1000) then
723     xkorr=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2))
724     xkorr0=adcx22(right,i,1)
725     adc_c(ch22b(i),hb22b(i))=tof22(right,i,iadc)/xkorr
726     endif
727     ENDIF
728    
729     C----------------------------- S3 --------------------------------
730    
731     yhelp=1000.
732     if (yout(3).lt.100.) then
733     yhelp=yout(3)
734     else
735     yhelp=ytofpos(3)
736     endif
737    
738     IF (tof31_i.GT.none_find.AND.yhelp.lt.100) THEN
739    
740     i = tof31_i
741     tof31(left,i,iadc) = tof31(left,i,iadc)*cos(theta13)
742     if (tof31(left,i,iadc).lt.1000) then
743     xkorr=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2))
744     xkorr0=adcx31(left,i,1)
745     adc_c(ch31a(i),hb31a(i))=tof31(left,i,iadc)/xkorr
746     endif
747    
748     tof31(right,i,iadc) = tof31(right,i,iadc)*cos(theta13)
749     if (tof31(right,i,iadc).lt.1000) then
750     xkorr=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2))
751     xkorr0=adcx31(right,i,1)
752     adc_c(ch31b(i),hb31b(i))=tof31(right,i,iadc)/xkorr
753     endif
754     ENDIF
755    
756     xhelp=1000.
757     if (xout(3).lt.100.) then
758     xhelp=xout(3)
759     else
760     xhelp=xtofpos(3)
761     endif
762    
763     IF (tof32_i.GT.none_find.AND.xhelp.lt.100) THEN
764    
765     i = tof32_i
766     tof32(left,i,iadc) = tof32(left,i,iadc)*cos(theta13)
767     if (tof32(left,i,iadc).lt.1000) then
768     xkorr=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2))
769     xkorr0=adcx32(left,i,1)
770     adc_c(ch32a(i),hb32a(i))=tof32(left,i,iadc)/xkorr
771     endif
772    
773     tof32(right,i,iadc) = tof32(right,i,iadc)*cos(theta13)
774     if (tof32(right,i,iadc).lt.1000) then
775     xkorr=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2))
776     xkorr0=adcx32(right,i,1)
777     adc_c(ch32b(i),hb32b(i))=tof32(right,i,iadc)/xkorr
778     endif
779     ENDIF
780    
781     C-----------------------------------------------------------------------
782     C---------------------- calculate Beta ------------------------------
783     C-----------------------------------------------------------------------
784     C------------------- difference of sums ---------------------------
785     C
786     C DS = (t1+t2) - t3+t4)
787     C DS = c1 + c2/beta*cos(theta)
788     C c2 = 2d/c gives c2 = 2d/(c*TDCresolution) TDC=50ps/channel
789     C => c2_23 = 60 for 0.45 m c2_13 = 109 for 0.81 m
790    
791     C S11 - S31
792     IF (tof11_i.GT.none_find.AND.tof31_i.GT.none_find) THEN
793     xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
794     xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
795     ds = xhelp1-xhelp2
796     ihelp=(tof11_i-1)*3+tof31_i
797     c1 = k1_S11S31(ihelp)
798     beta_a(1) = c2_13/(cos(theta13)*(ds-c1))
799     ENDIF
800    
801     C S12 - S32
802     IF (tof12_i.GT.none_find.AND.tof32_i.GT.none_find) THEN
803     xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
804     xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
805     ds = xhelp1-xhelp2
806     ihelp=(tof12_i-1)*3+tof32_i
807     c1 = k1_S12S32(ihelp)
808     beta_a(2) = c2_13/(cos(theta13)*(ds-c1))
809     ENDIF
810    
811    
812     C S21 - S31
813     IF (tof21_i.GT.none_find.AND.tof31_i.GT.none_find) THEN
814     xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
815     xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
816     ds = xhelp1-xhelp2
817     ihelp=(tof21_i-1)*3+tof31_i
818     c1 = k1_S21S31(ihelp)
819     beta_a(3) = c2_23/(cos(theta13)*(ds-c1))
820     ENDIF
821    
822     C S22 - S32
823     IF (tof22_i.GT.none_find.AND.tof32_i.GT.none_find) THEN
824     xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
825     xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
826     ds = xhelp1-xhelp2
827     ihelp=(tof22_i-1)*3+tof32_i
828     c1 = k1_S22S32(ihelp)
829     beta_a(4) = c2_23/(cos(theta13)*(ds-c1))
830     ENDIF
831    
832     C-------
833    
834     icount=0
835     sw=0.
836     sxw=0.
837     beta_mean=100.
838    
839     do i=1,4
840     if ((beta_a(i).gt.0.4).and.(beta_a(i).lt.1.5)) then
841     icount= icount+1
842     if (i.le.2) w_i=1./(0.13**2.)
843     if (i.ge.3) w_i=1./(0.16**2.)
844     sxw=sxw + beta_a(i)*w_i
845     sw =sw + w_i
846     endif
847     enddo
848     if (icount.eq.4) beta_mean=sxw/sw
849     beta_a(5) = beta_mean
850    
851    
852     c ERROR MESSAGES
853     100 continue
854     *
855     RETURN
856     END
857    

  ViewVC Help
Powered by ViewVC 1.1.23