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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Mon Jan 22 10:45:25 2007 UTC (17 years, 10 months ago) by mocchiut
Branch: MAIN
CVS Tags: v3r00
Changes since 1.3: +440 -177 lines
ToF routines updated

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()
18 c
19 IMPLICIT NONE
20 C
21 include 'input_tof.txt'
22 include 'output_tof.txt'
23 include 'tofcomm.txt'
24
25 INTEGER icounter
26 DATA icounter / 0/
27
28 LOGICAL check
29 REAL secure
30
31 INTEGER j
32 REAL xhelp_a,xhelp_t
33
34 REAL dx,dy,dr,ds
35 REAL yhelp,xhelp,xhelp1,xhelp2
36 REAL c1,c2,sw,sxw,w_i
37 INTEGER icount
38
39 c REAL xdummy
40
41 INTEGER tof11_j,tof21_j,tof31_j
42 INTEGER tof12_j,tof22_j,tof32_j
43
44
45 REAL beta_mean
46
47
48 c value for status of each PM-data
49 c first index : 1 = left, 2 = right
50 c second index : 1... number of paddle
51 INTEGER tof11_event(2,8),tof12_event(2,6)
52 INTEGER tof21_event(2,2),tof22_event(2,2)
53 INTEGER tof31_event(2,3),tof32_event(2,3)
54
55
56 REAL theta13
57 C-- DATA ZTOF/53.74,53.04,23.94,23.44,-23.49,-24.34/ !Sergio 9.05.2006
58 REAL tofarm12
59 PARAMETER (tofarm12 = 29.70) ! from 53.39 to 23.69
60 REAL tofarm23
61 PARAMETER (tofarm23 = 47.61) ! from 23.69 to -23.92
62 REAL tofarm13
63 PARAMETER (tofarm13 = 77.31) ! from 53.39 to -23.92
64
65 REAL hepratio
66
67 INTEGER ihelp
68 REAL xkorr
69
70 C---------------------------------------
71 C
72 C Begin !
73 C
74 TOFL2COM = 0
75 C
76 C CALCULATE COMMON VARIABLES
77 C
78
79 *******************************************************************
80 icounter = icounter + 1
81
82 * amplitude has to be 'secure' higher than pedestal for an adc event
83 secure = 2.
84
85 C ratio between helium and proton ca. 4
86 hepratio = 4.5 !
87 offset = 1
88 slope = 2
89 left = 1
90 right = 2
91 none_ev = 0
92 none_find = 0
93 tdc_ev = 1
94 adc_ev = 1
95 itdc = 1
96 iadc = 2
97
98 do i=1,13
99 betatof_a(i) = 100. ! As in "troftrk.for"
100 enddo
101
102 do i=1,4
103 do j=1,12
104 adctof_c(i,j) = 1000.
105 enddo
106 enddo
107
108
109 do i=1,4
110 do j=1,12
111 tdc_c(i,j) = 4095.
112 enddo
113 enddo
114
115
116 do i=1,12
117 do j=1,4
118 tofmask(j,i) = 0
119 enddo
120 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
138
139
140 c-------------------------get ToF data --------------------------------
141
142 c put the adc and tdc values from ntuple into tofxx(i,j,k) variables
143
144
145 do j=1,8
146 tof11(1,j,2) = adc(ch11a(j),hb11a(j))
147 tof11(2,j,2) = adc(ch11b(j),hb11b(j))
148 tof11(1,j,1) = tdc(ch11a(j),hb11a(j))
149 tof11(2,j,1) = tdc(ch11b(j),hb11b(j))
150 enddo
151
152
153 do j=1,6
154 tof12(1,j,2) = adc(ch12a(j),hb12a(j))
155 tof12(2,j,2) = adc(ch12b(j),hb12b(j))
156 tof12(1,j,1) = tdc(ch12a(j),hb12a(j))
157 tof12(2,j,1) = tdc(ch12b(j),hb12b(j))
158 enddo
159
160 do j=1,2
161 tof21(1,j,2) = adc(ch21a(j),hb21a(j))
162 tof21(2,j,2) = adc(ch21b(j),hb21b(j))
163 tof21(1,j,1) = tdc(ch21a(j),hb21a(j))
164 tof21(2,j,1) = tdc(ch21b(j),hb21b(j))
165 enddo
166
167 do j=1,2
168 tof22(1,j,2) = adc(ch22a(j),hb22a(j))
169 tof22(2,j,2) = adc(ch22b(j),hb22b(j))
170 tof22(1,j,1) = tdc(ch22a(j),hb22a(j))
171 tof22(2,j,1) = tdc(ch22b(j),hb22b(j))
172 enddo
173
174 do j=1,3
175 tof31(1,j,2) = adc(ch31a(j),hb31a(j))
176 tof31(2,j,2) = adc(ch31b(j),hb31b(j))
177 tof31(1,j,1) = tdc(ch31a(j),hb31a(j))
178 tof31(2,j,1) = tdc(ch31b(j),hb31b(j))
179 enddo
180
181 do j=1,3
182 tof32(1,j,2) = adc(ch32a(j),hb32a(j))
183 tof32(2,j,2) = adc(ch32b(j),hb32b(j))
184 tof32(1,j,1) = tdc(ch32a(j),hb32a(j))
185 tof32(2,j,1) = tdc(ch32b(j),hb32b(j))
186 enddo
187
188 C----------------------------------------------------------------------
189
190 DO i = 1,8
191 if (abs(tof11(1,i,itdc)).gt.10000.) tof11(1,i,itdc)= 10000.
192 if (abs(tof11(2,i,itdc)).gt.10000.) tof11(2,i,itdc)= 10000.
193 if (abs(tof11(1,i,iadc)).gt.10000.) tof11(1,i,iadc)= 10000.
194 if (abs(tof11(2,i,iadc)).gt.10000.) tof11(2,i,iadc)= 10000.
195 ENDDO
196
197 DO i = 1,6
198 if (abs(tof12(1,i,itdc)).gt.10000.) tof12(1,i,itdc)= 10000.
199 if (abs(tof12(2,i,itdc)).gt.10000.) tof12(2,i,itdc)= 10000.
200 if (abs(tof12(1,i,iadc)).gt.10000.) tof12(1,i,iadc)= 10000.
201 if (abs(tof12(2,i,iadc)).gt.10000.) tof12(2,i,iadc)= 10000.
202 ENDDO
203
204
205 DO i = 1,2
206 if (abs(tof21(1,i,itdc)).gt.10000.) tof21(1,i,itdc)= 10000.
207 if (abs(tof21(2,i,itdc)).gt.10000.) tof21(2,i,itdc)= 10000.
208 if (abs(tof21(1,i,iadc)).gt.10000.) tof21(1,i,iadc)= 10000.
209 if (abs(tof21(2,i,iadc)).gt.10000.) tof21(2,i,iadc)= 10000.
210 ENDDO
211
212 DO i = 1,2
213 if (abs(tof22(1,i,itdc)).gt.10000.) tof22(1,i,itdc)= 10000.
214 if (abs(tof22(2,i,itdc)).gt.10000.) tof22(2,i,itdc)= 10000.
215 if (abs(tof22(1,i,iadc)).gt.10000.) tof22(1,i,iadc)= 10000.
216 if (abs(tof22(2,i,iadc)).gt.10000.) tof22(2,i,iadc)= 10000.
217 ENDDO
218
219 DO i = 1,3
220 if (abs(tof31(1,i,itdc)).gt.10000.) tof31(1,i,itdc)= 10000.
221 if (abs(tof31(2,i,itdc)).gt.10000.) tof31(2,i,itdc)= 10000.
222 if (abs(tof31(1,i,iadc)).gt.10000.) tof31(1,i,iadc)= 10000.
223 if (abs(tof31(2,i,iadc)).gt.10000.) tof31(2,i,iadc)= 10000.
224 ENDDO
225
226 DO i = 1,3
227 if (abs(tof32(1,i,itdc)).gt.10000.) tof32(1,i,itdc)= 10000.
228 if (abs(tof32(2,i,itdc)).gt.10000.) tof32(2,i,itdc)= 10000.
229 if (abs(tof32(1,i,iadc)).gt.10000.) tof32(1,i,iadc)= 10000.
230 if (abs(tof32(2,i,iadc)).gt.10000.) tof32(2,i,iadc)= 10000.
231 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----------------------------------------------------------------
275 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----------------------------------------------------------------
295
296 C upper tof S11
297 DO i = 1,8
298
299 DO j = 1,2
300 tof11_event(j,i) = none_ev
301 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
303 ENDDO
304 ENDDO
305
306 c find single paddle in upper tof with tdc and adc signal
307 tof11_i = none_find
308 tof11_j = none_find
309 check = .TRUE.
310 DO i = 1, 8
311 IF ((tof11_event(left,i).GE.1).AND.(tof11_event(right,i).GE.1))
312 + THEN
313 c check if an other paddle has also an event - then set flag
314 tof11_j = tof11_j + 2**(i-1)
315 IF (check.EQV..TRUE.) THEN
316 IF (tof11_i.EQ.none_find) THEN
317 tof11_i = i
318 ELSE
319 tof11_i = -1
320 check = .FALSE.
321 ENDIF
322 ENDIF
323 ENDIF
324 ENDDO
325
326
327 C upper tof S12
328 DO i = 1,6
329 DO j = 1,2
330 tof12_event(j,i) = none_ev
331 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
333 ENDDO
334 ENDDO
335
336 c find single paddle in upper tof with tdc and adc signal
337 tof12_i = none_find
338 tof12_j = none_find
339 check = .TRUE.
340 DO i = 1, 6
341 IF ((tof12_event(left,i).GE.1).AND.(tof12_event(right,i).GE.1))
342 + THEN
343 c check if an other paddle has also an event - then set flag
344 tof12_j = tof12_j + 2**(i-1)
345 IF (check.EQV..TRUE.) THEN
346 IF (tof12_i.EQ.none_find) THEN
347 tof12_i = i
348 ELSE
349 tof12_i = -1
350 check = .FALSE.
351 ENDIF
352 ENDIF
353 ENDIF
354 ENDDO
355
356
357 C middle tof S21
358 DO i = 1,2
359 DO j = 1,2
360 tof21_event(j,i) = none_ev
361 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
363 ENDDO
364 ENDDO
365
366 c find single paddle in upper tof with tdc and adc signal
367 tof21_i = none_find
368 tof21_j = none_find
369 check = .TRUE.
370 DO i = 1, 2
371 IF ((tof21_event(left,i).GE.1).AND.(tof21_event(right,i).GE.1))
372 + THEN
373 c check if an other paddle has also an event - then set flag
374 tof21_j = tof21_j + 2**(i-1)
375 IF (check.EQV..TRUE.) THEN
376 IF (tof21_i.EQ.none_find) THEN
377 tof21_i = i
378 ELSE
379 tof21_i = -1
380 check = .FALSE.
381 ENDIF
382 ENDIF
383 ENDIF
384 ENDDO
385
386 C middle tof S22
387 DO i = 1,2
388 DO j = 1,2
389 tof22_event(j,i) = none_ev
390 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
392 ENDDO
393 ENDDO
394
395 c find single paddle in upper tof with tdc and adc signal
396 tof22_i = none_find
397 tof22_j = none_find
398 check = .TRUE.
399 DO i = 1, 2
400 IF ((tof22_event(left,i).GE.1).AND.(tof22_event(right,i).GE.1))
401 + THEN
402 c check if an other paddle has also an event - then set flag
403 tof22_j = tof22_j + 2**(i-1)
404 IF (check.EQV..TRUE.) THEN
405 IF (tof22_i.EQ.none_find) THEN
406 tof22_i = i
407 ELSE
408 tof22_i = -1
409 check = .FALSE.
410 ENDIF
411 ENDIF
412 ENDIF
413 ENDDO
414
415
416 C bottom tof S31
417 DO i = 1,3
418 DO j = 1,2
419 tof31_event(j,i) = none_ev
420 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
422 ENDDO
423 ENDDO
424
425 c find single paddle in upper tof with tdc and adc signal
426 tof31_i = none_find
427 tof31_j = none_find
428 check = .TRUE.
429 DO i = 1, 3
430 IF ((tof31_event(left,i).GE.1).AND.(tof31_event(right,i).GE.1))
431 + THEN
432 c check if an other paddle has also an event - then set flag
433 tof31_j = tof31_j + 2**(i-1)
434 IF (check.EQV..TRUE.) THEN
435 IF (tof31_i.EQ.none_find) THEN
436 tof31_i = i
437 ELSE
438 tof31_i = -1
439 check = .FALSE.
440 ENDIF
441 ENDIF
442 ENDIF
443 ENDDO
444
445 C bottom tof S32
446 DO i = 1,3
447 DO j = 1,2
448 tof32_event(j,i) = none_ev
449 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
451 ENDDO
452 ENDDO
453
454 c find single paddle in upper tof with tdc and adc signal
455 tof32_i = none_find
456 tof32_j = none_find
457 check = .TRUE.
458 DO i = 1, 3
459 IF ((tof32_event(left,i).GE.1).AND.(tof32_event(right,i).GE.1))
460 + THEN
461 c check if an other paddle has also an event - then set flag
462 tof32_j = tof32_j + 2**(i-1)
463 IF (check.EQV..TRUE.) THEN
464 IF (tof32_i.EQ.none_find) THEN
465 tof32_i = i
466 ELSE
467 tof32_i = -1
468 check = .FALSE.
469 ENDIF
470 ENDIF
471 ENDIF
472 ENDDO
473
474 do i=1,6
475 tof_i_flag(i)=0
476 tof_j_flag(i)=0
477 enddo
478
479 tof_i_flag(1)=tof11_i
480 tof_i_flag(2)=tof12_i
481 tof_i_flag(3)=tof21_i
482 tof_i_flag(4)=tof22_i
483 tof_i_flag(5)=tof31_i
484 tof_i_flag(6)=tof32_i
485
486 tof_j_flag(1)=tof11_j
487 tof_j_flag(2)=tof12_j
488 tof_j_flag(3)=tof21_j
489 tof_j_flag(4)=tof22_j
490 tof_j_flag(5)=tof31_j
491 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--------------------------------------------------------------------
750 C--------------------Time walk correction -------------------------
751 C--------------------------------------------------------------------
752
753 DO i=1,8
754 xhelp_a = tof11(left,i,iadc)
755 xhelp_t = tof11(left,i,itdc)
756 if(xhelp_a<4095) xhelp = tw11(left,i)/sqrt(xhelp_a)
757 tof11(left,i,itdc) = xhelp_t + xhelp
758 tdc_c(ch11a(i),hb11a(i))=tof11(left,i,itdc)
759 xhelp_a = tof11(right,i,iadc)
760 xhelp_t = tof11(right,i,itdc)
761 if(xhelp_a<4095) xhelp = tw11(right,i)/sqrt(xhelp_a)
762 tof11(right,i,itdc) = xhelp_t + xhelp
763 tdc_c(ch11b(i),hb11b(i))=tof11(right,i,itdc)
764 ENDDO
765
766 DO i=1,6
767 xhelp_a = tof12(left,i,iadc)
768 xhelp_t = tof12(left,i,itdc)
769 if(xhelp_a<4095) xhelp = tw12(left,i)/sqrt(xhelp_a)
770 tof12(left,i,itdc) = xhelp_t + xhelp
771 tdc_c(ch12a(i),hb12a(i))=tof12(left,i,itdc)
772 xhelp_a = tof12(right,i,iadc)
773 xhelp_t = tof12(right,i,itdc)
774 if(xhelp_a<4095) xhelp = tw12(right,i)/sqrt(xhelp_a)
775 tof12(right,i,itdc) = xhelp_t + xhelp
776 tdc_c(ch12b(i),hb12b(i))=tof12(right,i,itdc)
777 ENDDO
778 C----
779 DO i=1,2
780 xhelp_a = tof21(left,i,iadc)
781 xhelp_t = tof21(left,i,itdc)
782 if(xhelp_a<4095) xhelp = tw21(left,i)/sqrt(xhelp_a)
783 tof21(left,i,itdc) = xhelp_t + xhelp
784 tdc_c(ch21a(i),hb21a(i))=tof21(left,i,itdc)
785 xhelp_a = tof21(right,i,iadc)
786 xhelp_t = tof21(right,i,itdc)
787 if(xhelp_a<4095) xhelp = tw21(right,i)/sqrt(xhelp_a)
788 tof21(right,i,itdc) = xhelp_t + xhelp
789 tdc_c(ch21b(i),hb21b(i))=tof21(right,i,itdc)
790 ENDDO
791
792 DO i=1,2
793 xhelp_a = tof22(left,i,iadc)
794 xhelp_t = tof22(left,i,itdc)
795 if(xhelp_a<4095) xhelp = tw22(left,i)/sqrt(xhelp_a)
796 tof22(left,i,itdc) = xhelp_t + xhelp
797 tdc_c(ch22a(i),hb22a(i))=tof22(left,i,itdc)
798 xhelp_a = tof22(right,i,iadc)
799 xhelp_t = tof22(right,i,itdc)
800 if(xhelp_a<4095) xhelp = tw22(right,i)/sqrt(xhelp_a)
801 tof22(right,i,itdc) = xhelp_t + xhelp
802 tdc_c(ch22b(i),hb22b(i))=tof22(right,i,itdc)
803 ENDDO
804 C----
805
806 DO i=1,3
807 xhelp_a = tof31(left,i,iadc)
808 xhelp_t = tof31(left,i,itdc)
809 if(xhelp_a<4095) xhelp = tw31(left,i)/sqrt(xhelp_a)
810 tof31(left,i,itdc) = xhelp_t + xhelp
811 tdc_c(ch31a(i),hb31a(i))=tof31(left,i,itdc)
812 xhelp_a = tof31(right,i,iadc)
813 xhelp_t = tof31(right,i,itdc)
814 if(xhelp_a<4095) xhelp = tw31(right,i)/sqrt(xhelp_a)
815 tof31(right,i,itdc) = xhelp_t + xhelp
816 tdc_c(ch31b(i),hb31b(i))=tof31(right,i,itdc)
817 ENDDO
818
819 DO i=1,3
820 xhelp_a = tof32(left,i,iadc)
821 xhelp_t = tof32(left,i,itdc)
822 if(xhelp_a<4095) xhelp = tw32(left,i)/sqrt(xhelp_a)
823 tof32(left,i,itdc) = xhelp_t + xhelp
824 tdc_c(ch32a(i),hb32a(i))=tof32(left,i,itdc)
825 xhelp_a = tof32(right,i,iadc)
826 xhelp_t = tof32(right,i,itdc)
827 if(xhelp_a<4095) xhelp = tw32(right,i)/sqrt(xhelp_a)
828 tof32(right,i,itdc) = xhelp_t + xhelp
829 tdc_c(ch32b(i),hb32b(i))=tof32(right,i,itdc)
830 ENDDO
831
832 C----------------------------------------------------------------------
833 C------------------angle and ADC(x) correction
834 C----------------------------------------------------------------------
835 C-----------------------------S1 --------------------------------
836 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/
838 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/ ! paddles in different order
840 c DATA tof22_x/ -4.5,4.5/
841 c DATA tof31_x/ -6.0,0.,6.0/
842 c DATA tof32_y/ -5.0,0.0,5.0/
843
844 yhelp=0.
845 if (tof12_i.GT.none_find) yhelp=tof12_y(tof12_i)
846 if (ytofpos(1).lt.100) yhelp=ytofpos(1)
847
848 IF (tof11_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
849
850 i = tof11_i
851 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))
854 xkorr=xkorr/hepratio
855 adctof_c(ch11a(i),hb11a(i))=tof11(left,i,iadc)/xkorr
856 endif
857
858 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))
861 xkorr=xkorr/hepratio
862 adctof_c(ch11b(i),hb11b(i))=tof11(right,i,iadc)/xkorr
863 endif
864 ENDIF
865
866 xhelp=0.
867 if (tof11_i.GT.none_find) xhelp=tof11_x(tof11_i)
868 if (xtofpos(1).lt.100) xhelp=xtofpos(1)
869
870 IF (tof12_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
871
872 i = tof12_i
873 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))
876 xkorr=xkorr/hepratio
877 adctof_c(ch12a(i),hb12a(i))=tof12(left,i,iadc)/xkorr
878 endif
879
880 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))
883 xkorr=xkorr/hepratio
884 adctof_c(ch12b(i),hb12b(i))=tof12(right,i,iadc)/xkorr
885 endif
886 ENDIF
887
888 C-----------------------------S2 --------------------------------
889
890 xhelp=0.
891 if (tof22_i.GT.none_find) xhelp=tof22_x(tof22_i)
892 if (xtofpos(2).lt.100) xhelp=xtofpos(2)
893
894 IF (tof21_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
895
896 i = tof21_i
897 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))
900 xkorr=xkorr/hepratio
901 adctof_c(ch21a(i),hb21a(i))=tof21(left,i,iadc)/xkorr
902 endif
903
904 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))
907 xkorr=xkorr/hepratio
908 adctof_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr
909 endif
910 ENDIF
911
912
913 yhelp=0.
914 if (tof21_i.GT.none_find) yhelp=tof21_y(tof21_i)
915 if (ytofpos(2).lt.100) yhelp=ytofpos(2)
916
917 IF (tof22_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
918
919 i = tof22_i
920 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))
923 xkorr=xkorr/hepratio
924 adctof_c(ch22a(i),hb22a(i))=tof22(left,i,iadc)/xkorr
925 endif
926
927 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))
930 xkorr=xkorr/hepratio
931 adctof_c(ch22b(i),hb22b(i))=tof22(right,i,iadc)/xkorr
932 endif
933 ENDIF
934
935 C-----------------------------S3 --------------------------------
936
937 yhelp=0.
938 if (tof32_i.GT.none_find) yhelp=tof32_y(tof32_i)
939 if (ytofpos(3).lt.100) yhelp=ytofpos(3)
940
941 IF (tof31_i.GT.none_find.AND.abs(yhelp).lt.100) THEN
942
943 i = tof31_i
944 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))
947 xkorr=xkorr/hepratio
948 adctof_c(ch31a(i),hb31a(i))=tof31(left,i,iadc)/xkorr
949 endif
950
951 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))
954 xkorr=xkorr/hepratio
955 adctof_c(ch31b(i),hb31b(i))=tof31(right,i,iadc)/xkorr
956 endif
957 ENDIF
958
959 xhelp=0.
960 if (tof31_i.GT.none_find) xhelp=tof31_x(tof31_i)
961 if (xtofpos(3).lt.100) xhelp=xtofpos(3)
962
963 IF (tof32_i.GT.none_find.AND.abs(xhelp).lt.100) THEN
964
965 i = tof32_i
966 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))
969 xkorr=xkorr/hepratio
970 adctof_c(ch32a(i),hb32a(i))=tof32(left,i,iadc)/xkorr
971 endif
972
973 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))
976 xkorr=xkorr/hepratio
977 adctof_c(ch32b(i),hb32b(i))=tof32(right,i,iadc)/xkorr
978 endif
979 ENDIF
980
981
982 C--------------------------------------------------------------------
983 C----------------------calculate Beta ------------------------------
984 C--------------------------------------------------------------------
985 C-------------------difference of sums -----------------------------
986 C
987 C DS = (t1+t2) - t3+t4)
988 C DS = c1 + c2/beta*cos(theta)
989 C c2 = 2d/c gives c2 = 2d/(c*TDCresolution) TDC=50ps/channel
990 C => c2 = ca.60 for 0.45 m c2 = ca.109 for 0.81 m
991 C since TDC resolution varies slightly c2 has to be calibrated
992
993 C S11 - S31
994
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)
998 xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
999 ds = xhelp1-xhelp2
1000 ihelp=(tof11_i-1)*3+tof31_i
1001 c1 = k_S11S31(1,ihelp)
1002 c2 = k_S11S31(2,ihelp)
1003 betatof_a(1) = c2/(cos(theta13)*(ds-c1))
1004
1005 C------- ToF Mask - S11 - S31
1006
1007 tofmask(ch11a(tof11_i),hb11a(tof11_i)) =
1008 $ tofmask(ch11a(tof11_i),hb11a(tof11_i)) + 1
1009 tofmask(ch11b(tof11_i),hb11b(tof11_i)) =
1010 $ tofmask(ch11b(tof11_i),hb11b(tof11_i)) + 1
1011
1012 tofmask(ch31a(tof31_i),hb31a(tof31_i)) =
1013 $ tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1
1014 tofmask(ch31b(tof31_i),hb31b(tof31_i)) =
1015 $ tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1
1016
1017 C-------
1018
1019 ENDIF
1020
1021 C S11 - S32
1022
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)
1026 xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1027 ds = xhelp1-xhelp2
1028 ihelp=(tof11_i-1)*3+tof32_i
1029 c1 = k_S11S32(1,ihelp)
1030 c2 = k_S11S32(2,ihelp)
1031 betatof_a(2) = c2/(cos(theta13)*(ds-c1))
1032
1033 C------- ToF Mask - S11 - S32
1034
1035 tofmask(ch11a(tof11_i),hb11a(tof11_i)) =
1036 $ tofmask(ch11a(tof11_i),hb11a(tof11_i)) + 1
1037 tofmask(ch11b(tof11_i),hb11b(tof11_i)) =
1038 $ tofmask(ch11b(tof11_i),hb11b(tof11_i)) + 1
1039
1040 tofmask(ch32a(tof32_i),hb32a(tof32_i)) =
1041 $ tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1
1042 tofmask(ch32b(tof32_i),hb32b(tof32_i)) =
1043 $ tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1
1044
1045 C-------
1046
1047 ENDIF
1048
1049 C S12 - S31
1050
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)
1054 xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1055 ds = xhelp1-xhelp2
1056 ihelp=(tof12_i-1)*3+tof31_i
1057 c1 = k_S12S31(1,ihelp)
1058 c2 = k_S12S31(2,ihelp)
1059 betatof_a(3) = c2/(cos(theta13)*(ds-c1))
1060
1061 C------- ToF Mask - S12 - S31
1062
1063 tofmask(ch12a(tof12_i),hb12a(tof12_i)) =
1064 $ tofmask(ch12a(tof12_i),hb12a(tof12_i)) + 1
1065 tofmask(ch12b(tof12_i),hb12b(tof12_i)) =
1066 $ tofmask(ch12b(tof12_i),hb12b(tof12_i)) + 1
1067
1068 tofmask(ch31a(tof31_i),hb31a(tof31_i)) =
1069 $ tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1
1070 tofmask(ch31b(tof31_i),hb31b(tof31_i)) =
1071 $ tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1
1072
1073 C-------
1074
1075 ENDIF
1076
1077 C S12 - S32
1078
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)
1082 xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1083 ds = xhelp1-xhelp2
1084 ihelp=(tof12_i-1)*3+tof32_i
1085 c1 = k_S12S32(1,ihelp)
1086 c2 = k_S12S32(2,ihelp)
1087 betatof_a(4) = c2/(cos(theta13)*(ds-c1))
1088
1089 C------- ToF Mask - S12 - S32
1090
1091 tofmask(ch12a(tof12_i),hb12a(tof12_i)) =
1092 $ tofmask(ch12a(tof12_i),hb12a(tof12_i)) + 1
1093 tofmask(ch12b(tof12_i),hb12b(tof12_i)) =
1094 $ tofmask(ch12b(tof12_i),hb12b(tof12_i)) + 1
1095
1096 tofmask(ch32a(tof32_i),hb32a(tof32_i)) =
1097 $ tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1
1098 tofmask(ch32b(tof32_i),hb32b(tof32_i)) =
1099 $ tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1
1100
1101 C-------
1102
1103 ENDIF
1104
1105 C S21 - S31
1106
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)
1110 xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1111 ds = xhelp1-xhelp2
1112 ihelp=(tof21_i-1)*3+tof31_i
1113 c1 = k_S21S31(1,ihelp)
1114 c2 = k_S21S31(2,ihelp)
1115 betatof_a(5) = c2/(cos(theta13)*(ds-c1))
1116
1117 C------- ToF Mask - S21 - S31
1118
1119 tofmask(ch21a(tof21_i),hb21a(tof21_i)) =
1120 $ tofmask(ch21a(tof21_i),hb21a(tof21_i)) + 1
1121 tofmask(ch21b(tof21_i),hb21b(tof21_i)) =
1122 $ tofmask(ch21b(tof21_i),hb21b(tof21_i)) + 1
1123
1124 tofmask(ch31a(tof31_i),hb31a(tof31_i)) =
1125 $ tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1
1126 tofmask(ch31b(tof31_i),hb31b(tof31_i)) =
1127 $ tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1
1128
1129 C-------
1130
1131 ENDIF
1132
1133 C S21 - S32
1134
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)
1138 xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1139 ds = xhelp1-xhelp2
1140 ihelp=(tof21_i-1)*3+tof32_i
1141 c1 = k_S21S32(1,ihelp)
1142 c2 = k_S21S32(2,ihelp)
1143 betatof_a(6) = c2/(cos(theta13)*(ds-c1))
1144
1145 C------- ToF Mask - S21 - S32
1146
1147 tofmask(ch21a(tof21_i),hb21a(tof21_i)) =
1148 $ tofmask(ch21a(tof21_i),hb21a(tof21_i)) + 1
1149 tofmask(ch21b(tof21_i),hb21b(tof21_i)) =
1150 $ tofmask(ch21b(tof21_i),hb21b(tof21_i)) + 1
1151
1152 tofmask(ch32a(tof32_i),hb32a(tof32_i)) =
1153 $ tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1
1154 tofmask(ch32b(tof32_i),hb32b(tof32_i)) =
1155 $ tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1
1156
1157 C-------
1158
1159 ENDIF
1160
1161 C S22 - S31
1162
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)
1166 xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1167 ds = xhelp1-xhelp2
1168 ihelp=(tof22_i-1)*3+tof31_i
1169 c1 = k_S22S31(1,ihelp)
1170 c2 = k_S22S31(2,ihelp)
1171 betatof_a(7) = c2/(cos(theta13)*(ds-c1))
1172
1173 C------- ToF Mask - S22 - S31
1174
1175 tofmask(ch22a(tof22_i),hb22a(tof22_i)) =
1176 $ tofmask(ch22a(tof22_i),hb22a(tof22_i)) + 1
1177 tofmask(ch22b(tof22_i),hb22b(tof22_i)) =
1178 $ tofmask(ch22b(tof22_i),hb22b(tof22_i)) + 1
1179
1180 tofmask(ch31a(tof31_i),hb31a(tof31_i)) =
1181 $ tofmask(ch31a(tof31_i),hb31a(tof31_i)) + 1
1182 tofmask(ch31b(tof31_i),hb31b(tof31_i)) =
1183 $ tofmask(ch31b(tof31_i),hb31b(tof31_i)) + 1
1184
1185 C-------
1186
1187 ENDIF
1188
1189 C S22 - S32
1190
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)
1194 xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1195 ds = xhelp1-xhelp2
1196 ihelp=(tof22_i-1)*3+tof32_i
1197 c1 = k_S22S32(1,ihelp)
1198 c2 = k_S22S32(2,ihelp)
1199 betatof_a(8) = c2/(cos(theta13)*(ds-c1))
1200
1201 C------- ToF Mask - S22 - S32
1202
1203 tofmask(ch22a(tof22_i),hb22a(tof22_i)) =
1204 $ tofmask(ch22a(tof22_i),hb22a(tof22_i)) + 1
1205 tofmask(ch22b(tof22_i),hb22b(tof22_i)) =
1206 $ tofmask(ch22b(tof22_i),hb22b(tof22_i)) + 1
1207
1208 tofmask(ch32a(tof32_i),hb32a(tof32_i)) =
1209 $ tofmask(ch32a(tof32_i),hb32a(tof32_i)) + 1
1210 tofmask(ch32b(tof32_i),hb32b(tof32_i)) =
1211 $ tofmask(ch32b(tof32_i),hb32b(tof32_i)) + 1
1212
1213 C-------
1214
1215 ENDIF
1216
1217 C S11 - S21
1218
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)
1222 xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1223 ds = xhelp1-xhelp2
1224 ihelp=(tof11_i-1)*2+tof21_i
1225 c1 = k_S11S21(1,ihelp)
1226 c2 = k_S11S21(2,ihelp)
1227 betatof_a(9) = c2/(cos(theta13)*(ds-c1))
1228
1229 C------- ToF Mask - S11 - S21
1230
1231 tofmask(ch11a(tof11_i),hb11a(tof11_i)) =
1232 $ tofmask(ch11a(tof11_i),hb11a(tof11_i)) + 1
1233 tofmask(ch11b(tof11_i),hb11b(tof11_i)) =
1234 $ tofmask(ch11b(tof11_i),hb11b(tof11_i)) + 1
1235
1236 tofmask(ch21a(tof21_i),hb21a(tof21_i)) =
1237 $ tofmask(ch21a(tof21_i),hb21a(tof21_i)) + 1
1238 tofmask(ch21b(tof21_i),hb21b(tof21_i)) =
1239 $ tofmask(ch21b(tof21_i),hb21b(tof21_i)) + 1
1240
1241 C-------
1242
1243 ENDIF
1244
1245 C S11 - S22
1246
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)
1250 xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1251 ds = xhelp1-xhelp2
1252 ihelp=(tof11_i-1)*2+tof22_i
1253 c1 = k_S11S22(1,ihelp)
1254 c2 = k_S11S22(2,ihelp)
1255 betatof_a(10) = c2/(cos(theta13)*(ds-c1))
1256
1257 C------- ToF Mask - S11 - S22
1258
1259 tofmask(ch11a(tof11_i),hb11a(tof11_i)) =
1260 $ tofmask(ch11a(tof11_i),hb11a(tof11_i)) + 1
1261 tofmask(ch11b(tof11_i),hb11b(tof11_i)) =
1262 $ tofmask(ch11b(tof11_i),hb11b(tof11_i)) + 1
1263
1264 tofmask(ch22a(tof22_i),hb22a(tof22_i)) =
1265 $ tofmask(ch22a(tof22_i),hb22a(tof22_i)) + 1
1266 tofmask(ch22b(tof22_i),hb22b(tof22_i)) =
1267 $ tofmask(ch22b(tof22_i),hb22b(tof22_i)) + 1
1268
1269 C-------
1270
1271 ENDIF
1272
1273 C S12 - S21
1274
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)
1278 xhelp2 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1279 ds = xhelp1-xhelp2
1280 ihelp=(tof12_i-1)*2+tof21_i
1281 c1 = k_S12S21(1,ihelp)
1282 c2 = k_S12S21(2,ihelp)
1283 betatof_a(11) = c2/(cos(theta13)*(ds-c1))
1284
1285 C------- ToF Mask - S12 - S21
1286
1287 tofmask(ch12a(tof12_i),hb12a(tof12_i)) =
1288 $ tofmask(ch12a(tof12_i),hb12a(tof12_i)) + 1
1289 tofmask(ch12b(tof12_i),hb12b(tof12_i)) =
1290 $ tofmask(ch12b(tof12_i),hb12b(tof12_i)) + 1
1291
1292 tofmask(ch21a(tof21_i),hb21a(tof21_i)) =
1293 $ tofmask(ch21a(tof21_i),hb21a(tof21_i)) + 1
1294 tofmask(ch21b(tof21_i),hb21b(tof21_i)) =
1295 $ tofmask(ch21b(tof21_i),hb21b(tof21_i)) + 1
1296
1297 C-------
1298
1299 ENDIF
1300
1301 C S12 - S22
1302
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)
1306 xhelp2 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1307 ds = xhelp1-xhelp2
1308 ihelp=(tof12_i-1)*2+tof22_i
1309 c1 = k_S12S22(1,ihelp)
1310 c2 = k_S12S22(2,ihelp)
1311 betatof_a(12) = c2/(cos(theta13)*(ds-c1))
1312
1313 C------- ToF Mask - S12 - S22
1314
1315 tofmask(ch12a(tof12_i),hb12a(tof12_i)) =
1316 $ tofmask(ch12a(tof12_i),hb12a(tof12_i)) + 1
1317 tofmask(ch12b(tof12_i),hb12b(tof12_i)) =
1318 $ tofmask(ch12b(tof12_i),hb12b(tof12_i)) + 1
1319
1320 tofmask(ch22a(tof22_i),hb22a(tof22_i)) =
1321 $ tofmask(ch22a(tof22_i),hb22a(tof22_i)) + 1
1322 tofmask(ch22b(tof22_i),hb22b(tof22_i)) =
1323 $ tofmask(ch22b(tof22_i),hb22b(tof22_i)) + 1
1324
1325 C-------
1326
1327 ENDIF
1328
1329 C---------------------------------------------------------
1330
1331 icount=0
1332 sw=0.
1333 sxw=0.
1334 beta_mean=100.
1335
1336 do i=1,12
1337 if ((betatof_a(i).gt.-1.5).and.(betatof_a(i).lt.1.5)) then
1338 icount= icount+1
1339 if (i.le.4) w_i=1./(0.13**2.)
1340 if ((i.ge.5).and.(i.le.8)) w_i=1./(0.16**2.)
1341 if (i.ge.9) w_i=1./(0.25**2.) ! to be checked
1342 sxw=sxw + betatof_a(i)*w_i
1343 sw =sw + w_i
1344 endif
1345 enddo
1346
1347 if (icount.gt.0) beta_mean=sxw/sw
1348 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
1357
1358 C
1359 RETURN
1360 END
1361

  ViewVC Help
Powered by ViewVC 1.1.23