/[PAMELA software]/tof/ground/toftrack_101.tar
ViewVC logotype

Contents of /tof/ground/toftrack_101.tar

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (as text) (vendor branch)
Thu Mar 9 12:31:47 2006 UTC (18 years, 8 months ago) by pam-de
Branch: v_tag, MAIN
CVS Tags: r_tag, HEAD
Changes since 1.1: +0 -0 lines
File MIME type: application/x-tar
Initial Release

1 Makefile0000640000076500001440000000156710314237651011406 0ustar mennusers# Fortran flags
2 FC=g77
3 FFLAGS=-fvxt -fno-automatic -Wall -Wno-globals -fbounds-check
4 # C flags
5 CC=gcc
6 CFLAGS=-Wall -O2
7 CFLADJ=-c
8
9 # used libraries
10 #LIBS=-L/cern/pro/lib -lkernlib -lpacklib -lgraflib -lmathlib -lnsl
11 LIBS= `cernlib kernlib packlib graflib mathlib`
12
13 template.exe: template-static
14
15 # this directive links static libraries
16 template-static: template.f trk_level2.f
17 $(FC) $(FFLAGS) template.f -o template.exe $(TRK_GRND)/lib/libtrk.a $(LIBS)
18
19 # the next directive link dinamyc library (.so)
20 # NB! in order to link dynamically it must be added the library path to
21 # LD_LIBRARY_PATH (in the ./bashrc)
22 template-dynamic: template.f trk_level2.f
23 $(FC) $(FFLAGS) -o template.exe template.f $(LIBS) -L$(TRK_GRND)/lib -ltrk
24
25 toftrack: toftrack.f trk_level2.f
26 $(FC) $(FFLAGS) toftrack.f -o toftrack.exe $(TRK_GRND)/lib/libtrk.a $(LIBS)
27
28 clean:
29 rm -f *.o
30 rm -f *.exe
31 rm -f *~
32
33 README0000664000076500001440000001724410314477647010646 0ustar mennusers
34 1) The ToF software uses the Tracking software V2.00
35 It is assumed that you have created all the directories and the compiling
36 of the three executables "level0.exe", "level1.exe" and "level2.exe"
37 was succesful.
38
39 2) Copy the file toftrack.tar to the "utilities/template" directory (where
40 the program template.f is located), untar the file toftrack.tar.
41
42 The following files will be extracted:
43 Makefile (the old Makefile will be overwritten)
44 run-test.sh
45 tofcalib.rz
46 toftrack.f
47 common_tof.f
48 tofroutine.f
49 trk_level2.f (the old trk_level2.f was not correct)
50 common_tofroutine.f
51
52 3)Create the executable toftrack.exe doing
53 # make toftrack
54
55 4) The "level*.exe" programs in your working directory were run by doing
56
57 #./run-test.sh some_filename.txt level0/1/2 &
58
59 Copy the new "run-test.sh" from the template directory to the working
60 directory. Copy toftrack.exe to the working directory
61 After you have done step 5 (see below) you can run the toftrack software
62 analogue to the command for the level0/1/2 software:
63
64 #./run-test.sh some_filename.txt toftrack &
65
66 In the file good_files.tar.gz there is a list of good files from the Roma
67 tests.
68
69 5) Untar the file tofcalib.tar in your rz-data directory (where the level2
70 and tof rz-files are located). This will create a standard "tofcalib.rz"
71 file plus the calibration files for the Roma data
72 "DW_******_***_tofcalib.rz"
73
74
75 ---------------------------------------------------------------------------
76
77 "tracktof" will read the appropriate level2, tof, and tofcalib file. If
78 there is no tofcalib file for this data run, the standard calibration is
79 used (There will be a message saying "Could not find.... Will use the
80 standard calibration")
81
82
83 "tracktof" will create a new rz file DW_******_**_toftrack.rz" combining
84 the level2 data, the (raw) tof data, plus the variables calculated in the
85 tofroutine.
86
87 The structure looks like this:
88
89
90 ******************************************************************
91 * Ntuple ID = 2 Entries = 1185 TOF
92 ******************************************************************
93 * Var numb * Type * Packing * Range * Block * Name *
94 ******************************************************************
95 * 1 * L*4 * 1 * * EVENT * GOOD
96 * 2 * I*4 * * * EVENT * NEV_TRK
97 * 1 * I*4 * * * CPU * PKT_TYPE
98 * 2 * I*4 * * * CPU * PKT_NUM
99 * 3 * I*4 * * * CPU * OBT
100 * 4 * I*4 * * * CPU * WHICH_CALIB
101 * 1 * I*4 * * * TOF * TDCID(12)
102 * 2 * I*4 * * * TOF * EVCOUNT(12)
103 * 3 * I*4 * * * TOF * TDCMASK(12)
104 * 4 * I*4 * * * TOF * ADC(4,12)
105 * 5 * I*4 * * * TOF * TDC(4,12)
106 * 6 * I*4 * * * TOF * TEMP1(12)
107 * 7 * I*4 * * * TOF * TEMP2(12)
108 * 8 * R*4 * * * TOF * BETA(5)
109 * 9 * R*4 * * * TOF * XTOF(3)
110 * 10 * R*4 * * * TOF * YTOF(3)
111 * 11 * R*4 * * * TOF * ADC_C(4,12)
112 * 12 * I*4 * * * TOF * IFLAG(6)
113 * 13 * I*4 * * * TOF * JFLAG(6)
114 * 14 * R*4 * * * TOF * XOUT(3)
115 * 15 * R*4 * * * TOF * YOUT(3)
116 * 1 * I*4 * * * TRIGGER * TRIG_EVCOUNT
117 * 2 * I*4 * * * TRIGGER * PMTPL(3)
118 * 3 * I*4 * * * TRIGGER * TRIGRATE(6)
119 * 4 * I*4 * * * TRIGGER * DLTIME(2)
120 * 5 * I*4 * * * TRIGGER * S4CALCOUNT(2)
121 * 6 * I*4 * * * TRIGGER * PMTCOUNT1(24)
122 * 7 * I*4 * * * TRIGGER * PMTCOUNT2(24)
123 * 8 * I*4 * * * TRIGGER * PATTERNBUSY(3)
124 * 9 * I*4 * * * TRIGGER * PATTERNTRIG(6)
125 * 10 * I*4 * * * TRIGGER * TRIGCONF
126 * 1 * I*4 * * [0,50] * TRACKS * NTRK
127 * 2 * U*4 * 6 * [0,50] * TRACKS * IMAGE(NTRK)
128 * 3 * R*4 * * * TRACKS * XM(6,NTRK)
129 * 4 * R*4 * * * TRACKS * YM(6,NTRK)
130 * 5 * R*4 * * * TRACKS * ZM(6,NTRK)
131 * 6 * R*4 * * * TRACKS * RESX(6,NTRK)
132 * 7 * R*4 * * * TRACKS * RESY(6,NTRK)
133 * 8 * R*4 * * * TRACKS * AL(5,NTRK)
134 * 9 * R*4 * * * TRACKS * COVAL(5,5,NTRK)
135 * 10 * R*4 * * * TRACKS * CHI2(NTRK)
136 * 11 * U*4 * 1 * [0,1] * TRACKS * XGOOD(6,NTRK)
137 * 12 * U*4 * 1 * [0,1] * TRACKS * YGOOD(6,NTRK)
138 * 13 * R*4 * * * TRACKS * XV(6,NTRK)
139 * 14 * R*4 * * * TRACKS * YV(6,NTRK)
140 * 15 * R*4 * * * TRACKS * ZV(6,NTRK)
141 * 16 * R*4 * * * TRACKS * AXV(6,NTRK)
142 * 17 * R*4 * * * TRACKS * AYV(6,NTRK)
143 * 18 * R*4 * * * TRACKS * DEDXP(6,NTRK)
144 * 1 * I*4 * * * SINGLETS * NCLSX(6)
145 * 2 * I*4 * * * SINGLETS * NCLSY(6)
146 ******************************************************************
147 * Block * Entries * Unpacked * Packed * Packing Factor *
148 ******************************************************************
149 * EVENT * 1185 * 8 * 5 * 1.600 *
150 * CPU * 1185 * 16 * 16 * 1.000 *
151 * TOF * 1185 * 932 * 932 * 1.000 *
152 * TRIGGER * 1185 * 288 * 288 * 1.000 *
153 * TRACKS * 1185 * 22004 * Var. * Variable *
154 * SINGLETS * 1185 * 48 * 48 * 1.000 *
155 * Total * --- * 23296 * Var. * Variable *
156 ******************************************************************
157 * Blocks = 6 Variables = 51 Max. Columns = 5824 *
158 ******************************************************************
159
160
161
162 The variables calculated in "TOFROUTINE" are the last ones in the block
163 "TOF":
164
165
166 BETA(5): four values (1-4) for beta from S11-S31, S12-S32, S21-S31
167 and S22-S32.
168 if there is no valid signal beta is set to "100".
169 if there are four values for beta, the weighted mean is
170 calculated and put into beta(5). So it is possible for
171 the user to calculate his own mean value by using the
172 single values.
173
174 XTOF(3): The x-position in the 3 different layers using the ToF
175 timing (So, for the x-coordinate we use S12, S21,S32).
176 If we cannot find a valid timing the value is set to "1000"
177
178 YTOF(3): The same for y-position using S11, S22,S31
179
180 ADC_C(4,12): normalized ADC values, the value in the middle of the
181 paddle is set to "1", using the (sometimes poor) attenuation
182 fit curves. The ADC_C matrix is analog to the ADC matrix
183 for the raw data, so one can use the same channel map.
184
185 IFLAG(6): 6 values for the six layers:
186 "0" if no hit in this layer
187 "-1" if more than one hit
188 otherwise the number of the hitted paddle ("hit" = good
189 TDC values on both sides)
190
191 JFLAG(6): 6 values for the six layers: coded value to see which
192 strips have valid hits:
193 for i=1 to (number of strips) do
194 if (paddle "i" = hit) then jflag = jflag + 2**(i-1)
195
196
197
198
199 common_tof.f0000664000076500001440000000125410314004226012242 0ustar mennusers integer tdcid(12),evcount(12)
200 integer tdcmask(12),adc(4,12),tdc(4,12)
201 integer temp1(12),temp2(12)
202 COMMON / tofvar /tdcid,evcount,tdcmask,adc,tdc,temp1,temp2
203
204 integer*4 trig_evcount
205 integer pmtpl(3), trigrate(6), dltime(2), s4calcount(2)
206 integer pmtcount1(24), pmtcount2(24)
207 integer*4 patternbusy(3)
208 integer patterntrig(6), trigconf
209 COMMON / trig / trig_evcount, pmtpl, trigrate, dltime,
210 & s4calcount, pmtcount1, pmtcount2,
211 & patternbusy, patterntrig, trigconf
212
213
214 parameter (ntp_tof=17)
215 parameter (ntp_tofcalib=60)
216
217 logical good
218 integer nev_trk
219 common / event_tof /good,nev_trk
220 common_tofroutine.f0000664000076500001440000001107510314004226013652 0ustar mennusers* DATA ZTOF/55.,25.,-23/
221 *
222 * TOF data
223 * first index : 1 = A, 2 = B
224 * second index : 1.. number of paddle
225 * third index : 1 = TDC, 2 = ADC
226
227 c INTEGER tof11(2,8,2),tof12(2,6,2)
228 c INTEGER tof21(2,2,2),tof22(2,2,2)
229 c INTEGER tof31(2,3,2),tof32(2,3,2)
230 REAL tof11(2,8,2),tof12(2,6,2)
231 REAL tof21(2,2,2),tof22(2,2,2)
232 REAL tof31(2,3,2),tof32(2,3,2)
233
234 c Normalized ADC value
235 REAL adc_c(4,12)
236
237 c k1 constans for calculation of beta
238 REAL k1_s11s31(24),k1_s12s32(18),k1_S21S31(6),k1_S22S32(6)
239
240 c middle y (or x) position of the upper and middle ToF-Paddle
241 c to calculate theta-angle without track information
242 REAL tof11_x(8), tof21_y(2), tof31_x(3)
243 REAL tof12_y(6), tof22_x(2), tof32_y(3)
244
245 c relation of time differences in a tof paddle and the location of the
246 c passage of the particle
247 c first index : 1... number of paddle
248 c second index : 1 = offset, 2 = slope
249 REAL y_coor_lin11(8,2),x_coor_lin12(6,2)
250 REAL x_coor_lin21(2,2),y_coor_lin22(2,2)
251 REAL y_coor_lin31(3,2),x_coor_lin32(3,2)
252
253 c ADC(x) - correction
254 c first index : 1 = left, 2 = right
255 c second index : 1..8 number of paddle
256 c third index: parameter as follows
257 c left: xkorr=par(1)*exp(-x/par(2))
258 c right:xkorr=par(1)*exp(x/par(2))
259 c then:adc(x,right/left)=adc(x,right/left)/xkorr
260 c normalize to x=0 (middle of paddle)
261 REAL adcx11(2,8,2),adcx12(2,6,2)
262 REAL adcx21(2,2,2),adcx22(2,2,2)
263 REAL adcx31(2,3,2),adcx32(2,3,2)
264
265
266 c Time Walk - correction
267 c first index : 1 = left, 2 = right
268 c second index : 1..8 number of paddle
269 REAL tw11(2,8),tw12(2,6)
270 REAL tw21(2,2),tw22(2,2)
271 REAL tw31(2,3),tw32(2,3)
272
273
274 c value for status of each PM-data
275 c first index : 1 = left, 2 = right
276 c second index : 1... number of paddle
277 INTEGER tof11_event(2,8),tof12_event(2,6)
278 INTEGER tof21_event(2,2),tof22_event(2,2)
279 INTEGER tof31_event(2,3),tof32_event(2,3)
280
281 C----
282
283 INTEGER left,right,top,bot,mid,itdc,iadc
284 INTEGER tdc_ev, adc_ev, none_ev, none_find
285 INTEGER offset, slope
286 INTEGER tof11_i,tof21_i,tof31_i,tof11_j,tof21_j,tof31_j
287 INTEGER tof12_i,tof22_i,tof32_i,tof12_j,tof22_j,tof32_j
288 * REAL adcoff(4,2,52),a,b
289 c REAL delta_x12,delta_y12,delta_x23,delta_y23,delta_x13,delta_y13
290 REAL xtofpos(3),ytofpos(3)
291 REAL xkorr, secure
292 INTEGER i, j, ihelp
293 LOGICAL check
294 REAL theta12,theta13,theta23
295
296 REAL beta_a(5)
297
298 INTEGER tof_i_flag(6),tof_j_flag(6)
299
300
301 DATA TOFfst / 0/
302
303 PARAMETER (tofarm23 = 45.)
304 PARAMETER (tofarm13 = 81.)
305 PARAMETER (c2_13=108.) ! = 2.*tofarm13*0.01/(3.E08*50.E-12)
306 PARAMETER (c2_23=60.) ! = 2.*tofarm23*0.01/(3.E08*50.E-12)
307
308
309 * S11 8 paddles 33.0 x 5.1 cm
310 * S12 6 paddles 40.8 x 5.5 cm
311 * S21 2 paddles 18.0 x 7.5 cm
312 * S22 2 paddles 15.0 x 9.0 cm
313 * S31 3 paddles 15.0 x 6.0 cm
314 * S32 3 paddles 18.0 x 5.0 cm
315
316 DATA tof11_x/ -17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85/
317 DATA tof12_y/ -13.75,-8.25,-2.75,2.75,8.25,13.75/
318 DATA tof21_y/ -3.75,3.75/
319 DATA tof22_x/ -4.5,4.5/
320 DATA tof31_x/ -6.0,0.,6.0/
321 DATA tof32_y/ -5.0,0.0,5.0/
322
323 integer ch11a(8),hb11a(8),ch11b(8),hb11b(8)
324 integer ch12a(6),hb12a(6),ch12b(6),hb12b(6)
325 integer ch21a(2),hb21a(2),ch21b(2),hb21b(2)
326 integer ch22a(2),hb22a(2),ch22b(2),hb22b(2)
327 integer ch31a(3),hb31a(3),ch31b(3),hb31b(3)
328 integer ch32a(3),hb32a(3),ch32b(3),hb32b(3)
329
330
331 data ch11a / 4, 4, 4, 4, 1, 1, 2, 2/
332 data hb11a / 1, 3, 5, 7, 10, 12, 2, 4/
333 data ch11b / 2, 2, 2, 2, 1, 1, 1, 1/
334 data hb11b / 6, 8, 12, 10, 8, 6, 4, 2/
335
336 data ch12a / 3, 3, 3, 3, 3, 3/
337 data hb12a / 2, 4, 6, 8, 10, 12/
338 data ch12b / 4, 4, 4, 4, 4, 4/
339 data hb12b / 12, 10, 8, 6, 4, 2/
340
341 data ch21a / 1, 1/
342 data hb21a / 1, 5/
343 data ch21b / 2, 1/
344 data hb21b / 9, 7/
345
346 data ch22a / 1, 1/
347 data hb22a / 3, 9/
348 data ch22b / 2, 1/
349 data hb22b / 11, 11/
350
351 data ch31a / 2, 3, 3/
352 data hb31a / 7, 9, 11/
353 data ch31b / 2, 2, 2/
354 data hb31b / 5, 3, 1/
355
356 data ch32a / 3, 3, 4/
357 data hb32a / 1, 5, 9/
358 data ch32b / 3, 3, 4/
359 data hb32b / 3, 7, 11/
360
361 common / tofcalc /k1_s11s31,k1_s12s32,k1_S21S31,
362 & k1_S22S32,beta_a,
363 & adcx11,adcx12,adcx21,adcx22,adcx31,adcx32,
364 & tw11,tw12,tw21,tw22,tw31,tw32,
365 & y_coor_lin11,x_coor_lin12,x_coor_lin21,
366 & y_coor_lin22,y_coor_lin31,x_coor_lin32,
367 & xtofpos,ytofpos,adc_c,tof_i_flag,tof_j_flag
368 good_files.tar.gz0000744000076500001440000000325310314506262013203 0ustar mennusers‹ MCí]AŽ7 ܳ_á8)QêyM°N€À—p$ÈëÝ#v«Ö>l CõvW]¶³3³[¨&E‘R²¤iyþáË__ž…$)Õ’žÒŠVëö³ôŸ’Ÿ$©iN%I[_/µÉÓûô°oôüþåùóû÷Oûõ—O¯¼îÏO?þ9â…"uýLéönöW!& ë{¨ýÿÑÿ²š}ø?å»ÿ-Óÿ!pýWÿ·wƒ. ·A%
369 ¨‚æN%­¿& 
370 úâ…O›cÀ™ëÿTÛîÿܪuÿ—LÿG ë/°¬À²ËJ·ì F÷ž®é!òÿÚJK¥ˆçÿ•þÀðt¥§¯ˆ®>Dþ_ï™@ÊÕóÿDÿGÀõGüψÿñ¿à/(ß¾À@+h]@Ym8\‘Éñ_ëæɹ%ÿôºþ{[÷ôìoEDÁýÿq®ÿ}ýïþ/=þ·Äú_†é üo ´.|@œ]Óz”õ¿¨•-þ7ú?®ÿ³¿
371 1®ÿÜø¿zÿMT»ÿ«ÑÿþßÖôkúŠ¬ aÐðÚƵ›‡ 99þ[qÿk*j™õÿ@ #¿pºVÐF§Ÿ.ïäõÿ–ÿ¯þ¯÷…÷¿Òÿöæšþ’pý:FþßýoŒÿèú/Hï¤÷ – „ ¬àÍÃ…<LþŸ[+^ÿ§ÿC0Œ¼ÀÓÞô+7<ný©0û»ÿ?\ôÃäÿ%Iåþ †½YÈ»$ÜÿsóÿÑÿ£Ùªçÿ÷eý€áÿ‚HÏöþëÀEÿ êþO¯¬ÿŶý[W½þ׌ù†é=ÿWLï)¦÷Ó{šÆ³¢S/¨°ƒàmÂ… èÿÅÿ{üo¥$“mþ—õÿ ÷¾02G®}²ÿ·þßVîÀÍÿœÿ Á0½·÷ª"þ+â¿"è+g‚k:Ùÿ[ýõ¿X)îæÿ!èúcþO1ÿ§˜ÿë”Gvœ.ï\ÿïó¿Ýÿ"<ÿ'ÃÞ§Wк€ú¡b*X1¬˜
372 î´€(—+°ÿÿšÿsÚü¿¦"ûù…þ@×ó¿*h- ZA(› ß
373 Üÿûÿ¯åÿEà+œÿ ÄnÙíx¿Nñ(6ýœ®ôÜøÿbþw] lý¿ÜÿÁîte#ï%áú&þK®<ÿ/Ãÿ·ô3RÌ=ý“£+]?h{tÿÏ+ýZ¶þ•d~þocþ׫wLú+&ýµ¡€YaŬ°bVXÛ·o¶€ÞÝW «6ïŸ&Üxx \ÿÉûˆÿ©jóó¿YÿÁðÿfC¢•Sç‡?e'ÏÿŒþ?½§ìÿD×C¿ºÐô—‚‹>ùþ½ÿgÍÿ“ŸÿÃø„aúž½ç4®qª |*œ.ïdÿïõ½ŸûßÏÿ4åþºþÊé«Âõ?Äý_÷ý¿b­ŸÿiÆùŸtý3‚~FÐÏ{¥Ï©²{ï4èš–ƒø_ššÏÿ›1ÿ맆GÁhtÊŠüiàš%ÿOÍ2×ÿ‘žfÿÏ%ÑõŸ|ÿÇØÿ—’sõû„õÿ¸þúA¿"èW$KŠ²áè pº€ÞõM§ø4Á§ >MðiÂiãâþ_–Ùõ¿1ÿ+­úùf<ÿ/]ÿ1ôïTA3(“þ3Âåìÿ½ÿ§Z.µ²þˆaï§/ ¼§÷äèJçÉù*»ÿKÍ~þ·ðüŸ¸þˆÿ¨ÿãþo§Ô@+hÝž ï[ð¾åû÷ý?¸2\†ƒôÿ­þo©¹ÿÙÿ‚áHƒ9¹½w¸èsó±áñþŸBÿ‡ ëM?Á¦Ÿ`Ó„gÜ
374 žq+xÞnô6èVô?W`ö_K|çëË­Šlõ¿Âú_ºþ¨ÿã*à,œÿ¹\éCÔÿ»ÿ“¯ÿïÇ€ÒÿØœ.{œnx4<
375 xÓ÷YáòNÎÿýþÕÿVE óÿ@ {8Ý@·LÁSaÁSaÁ¯-<ümÂÕ;Jü·ÖÔûÿ*óÿ ÷nN¿Áé78ž.ïdÿ{ý¿û¿zýMèÿ {8ü:¸‹rÿ׿©ÿ—Z›Ÿÿk•ý?!pýGÐÇ¥—þe\ú—qéŸÓ
376 ê[ŠcTðÂþCÂÅ9Lü¯m;ÿËXÿ Á0§Á§Üÿ¿ºè“û_ÔÿZj™õ¿@¸þˆÞèÿÅ­`WeE+ ® ÊÊSÞ(\½CÌÿ[ºEèçsÿ?»{·‰<Üé•q§WÆ^y»Ókö×&‚ ‚ ‚ þ#¾A¥´àÈrun-test.sh0000751000076500001440000001003310314240675012052 0ustar mennusers#################################################################
377 # Shell script to run the tracker reduction programs
378 #################################################################
379 #
380 #
381 #
382 #----------------------------------------------------------------
383 #local variables:
384 rawdata_dir='raw-data/'
385 rzdata_dir='rz-test/'
386
387 if [ -n "$1" -a -n "$2" ] ;then
388
389 lines=$(grep -n -c $ $1)
390 list=`more $1`
391
392 #################################################################
393 # ------------------------- LEVEL0 ------------------------------
394 #
395 # This part of the script creates the input to level0.exe and run it,
396 # starting from a txt list of file IDs (format: YYMMDD_XXX).
397 #
398 # Tipical input of level0.exe is as follows:
399 # ../level0.exe << EOF
400 # 5 # N. of downlink to process
401 # raw-data/ # raw-data directory
402 # 050323_011 # 1^ file id
403 # 050324_001 # 2^
404 # 050324_002 # ....
405 # 050324_003 #
406 # 050324_004 #
407 # rz-test/ # output rz directory
408 # 100000 # maximum number of events to be processed
409 # EOF
410 #################################################################
411 if [ $2 = 'level0' ]; then
412 echo $lines > input
413 echo $rawdata_dir >> input
414 for dnlk in $list
415 do
416 echo $dnlk >> input
417 done
418 echo $rzdata_dir >> input
419 echo '100000' >> input
420 ./level0.exe < input > $1-level0
421 # rm -f input
422
423 #################################################################
424 # ------------------------- LEVEL1 ------------------------------
425 #
426 # This script creates the input to level1.exe and run it
427 # starting from a txt list of file IDs (format: YYMMDD_XXX).
428 #
429 # Tipical input of level1.exe is as follows:
430 # ../level1.exe << EOF
431 # raw-data/ # raw-data directory
432 # 050323_011 # file id
433 # rz-test/ # input/output rz directory
434 # 100000 # maximum number of events to be processed
435 # EOF
436 #################################################################
437 elif [ $2 = 'level1' ]; then
438 if [ -f $1-level1 ];then
439 rm $1-level1
440 fi
441 touch $1-level1
442 for dnlk in $list
443 do
444 ./level1.exe >> $1-level1 <<EOF
445 $rzdata_dir
446 $dnlk
447 100000
448 EOF
449 done
450 #################################################################
451 # ------------------------- LEVEL2 ------------------------------
452 #
453 # This script creates the input to level2.exe and run it
454 # starting from a txt list of file IDs (format: YYMMDD_XXX).
455 #
456 # Tipical input of level1.exe is as follows:
457 # ../level2.exe << EOF
458 # raw-data/ # raw-data directory
459 # 050323_011 # file id
460 # rz-test/ # input/output rz directory
461 # 100000 # maximum number of events to be processed
462 # F # (debug flag)
463 # EOF
464 #################################################################
465 elif [ $2 = 'level2' ]; then
466 if [ -f $1-level2 ];then
467 rm $1-level2
468 fi
469 touch $1-level2
470 for dnlk in $list
471 do
472 ./level2.exe >> $1-level2 <<EOF
473 $rzdata_dir
474 $dnlk
475 100000
476 COG2
477 F
478 EOF
479 done
480 #################################################################
481 # --------------------- TOFTRACK -----------------------------
482 #
483 # This script creates the input to tofsoft.exe and run it
484 # starting from a txt list of file IDs (format: YYMMDD_XXX).
485 #
486 # Typical input of toftrack.exe is as follows:
487 # ../toftrack.exe << EOF
488 # raw-data/ # raw-data directory
489 # 050323_011 # file id
490 # rz-test/ # input/output rz directory
491 # 100000 # maximum number of events to be processed
492 # F # (debug flag)
493 # EOF
494 #################################################################
495 elif [ $2 = 'toftrack' ]; then
496 if [ -f $1-toftrack ];then
497 rm $1-toftrack
498 fi
499 touch $1-toftrack
500 for dnlk in $list
501 do
502 ./toftrack.exe <<EOF
503 $rzdata_dir
504 $dnlk
505 1
506 100000
507 EOF
508 done
509 fi
510 else
511 echo ""
512 echo "USAGE:"
513 echo "./run-test.sh downlink-list-file-name level0/1/2/tofsoft"
514 echo "( ex: ./run-test.sh 050323.txt level0 & )"
515 echo "( ex: ./run-test.sh 050323.txt level1 & )"
516 echo "( ex: ./run-test.sh 050323.txt level2 & )"
517 echo "( ex: ./run-test.sh 050323.txt toftrack & )"
518 echo ""
519 fi
520
521 tofcalib.rz0000644000076500001440000044000010314241134012066 0ustar mennusersUC—S-- ¡.å¡.åýèx7 8D&(`¥<ðˆ™‹% VÀð¡.åþý<'ù<'õ<'ñ<'í<'é<'å<'á<'Ý<'Ù<'Õ<'Ñ<'Í<'É<'Å<'Á<' ½<'!¹<'"µ<'#±<'$­<'%©<'&¥< ¡.å7¡.å¡.å¡.å ¡.å¡.å¡.å¡.å ¡.å¡.å¡.å¡.å ¡.å¡.å¡.å¡.å ¡.å¡.å¡.å¡.å ¡.å¡.å¡.åû Câ Cá GÜ Gó GòHCONñB
522 \B~õÃB,{ÁÛ…@@Á<£×Án¸RA„£×?ï\)ÂDG®Á„õÃÁø(ö¼ÌÍÂz{›W
523 †aHÂë…ÂQ\AQÂB*ë…Aï33ÁƒÂA͸ÁDzáû ?ç ?æ Cá Gó GñHCONñÂÈšÂ[¸RÂ×
524 à ³3¤ǮÂΣ×ÃÅŸÂÂÅÂÂi\)À…p¤ÁÄ{Â(…A5™šÀθRÁžzáBáHÀä(öû ;ì ;ë ?æ Gó GðHCONñAθRBb\B(ÌÍÁS×
525 AÂ@AG®û 7ñ 7ð ;ë Gó GïHCONñÂQìA«×
526 @áHÂä=qÂhzáÂœ33û 3ö 3õ 7ð Gó GîHCONñÁ˜ÌÍÁ×
527 ÁÎQìÁR¸RÁ÷®Á©
528 =Á9™šÁ\QìÀffÀzáÀë…À£×À£×À(QìÀ*áHÀ%Âû /û /ú 3õ Gó GíHCONñAK…A„õÃ@ÁG®Á²(öÁ×
529 Átõÿê=qÀ(ö¿ü(öÀ¸À¸R¿ü(öû , +ÿ /ú Gó GìHCONñA­33AF=q¿Ã×
530 ¿Â\û ( ( +ÿ Gó GëHCONñÁÕë…Â7®¿ìÌÍ¿ÁG®û $
531 $ ( Gó Gê HCONñÁ³33Â&p¤ÂÌÍÀ[…Àz=qÀ`£×û   $  Gó Gé
532 HCONñ?Ë…@j=qÁ°záÀVffÀn{ÀhQìû    Gó Gè HCONñû    Gó Gç HCONñû    Gó Gæ HCONñû # "  Gó GåHCONñû ( ' " Gó GäHCONñû - , ' Gó GãHCONñû 2 1 , Gó GâHCONñB…úáBgzáBA®Bg=qB—p¤Bx£×BŒk…B€\)Bz{Bˆ¸B¨Ç®B33B¢¸BCG®B.£×A“33A%G®A2\A%p¤A'…Ap¤AzáA A ÌÍA ®A4A{@èA(ö@ÐõÃA G®@µp¤û 7 6 1 Gó GáHCONñBõÃB33BÂA홚BHBv¸RAù™šBM¸B<B®B ÌÍBÂA33A£×A=qAffARáHA0õÃADzáA\(öA+33A™šAXQìA”\û ü< ü; 6 Gó GàHCONñB²ffB«W
533 B6(öB‘£×AÌÌÍAË™šBpë…A«…û øA ø@ ü; Gó GßHCONñBH{B@QìBŒ€Bƒ³3Eª&A½×
534 A»G®AÊÌÍû ôF ôE ø@ Gó GÞHCONñBñ³3BÀ#×B¹k…B£uÃB‘(öB¾{@Æff@ᙚ@´ÌÍ@­¸@ºáH@¾ffû ðK ðJ ôE Gó GÝHCONñB”Š=B¥=qBªáHBÉ€BÈõÃBœ¸RA
535 áH@ºáH@¸Qì@ÝÂ@êáH@θR. WÁ ãN ïV H‰ H¢ I- IF IÑ Iê Ju JŽ K K2 K½ KÖ La Lz M M M© M NM Nf Nñ O
536 O• O® P9 PR PÝ Pö Q Qš R% R> RÉ Râ Sm S† T T* Tµ TÎ UY Ur Uý Wî ðK H HHNAM€" /,-ü£ê ôF I4 I3HNAM€" -)-ü£ö øA IØ I×HNAM€" +
537 &-ü¤ ü< J| J{HNAM€" )
538 #-ü¤
539  7 K KHNAM€" ' -ü¤ 2 KÄ KÃHNAM€" %"-ü¤* - Lh LgHNAM€" $-ü£¶ ( M M HNAM€" #-ü£¾ # M° M¯HNAM€" "-ü£Æ  NT NSHNAM€" ! -ü£Ê  Nø N÷HNAM€"   -ü£Î  Oœ O›HNAM€"  -ü£Ú  P@ P?HNAM€" 
540 -ü¤J $
541 Pä PãHNAM€"   -ü¤R ( Qˆ Q‡HNAM€"  -ü¤Z , R, R+HNAM€"  -ü¤^ /û RÐ RÏHNAM€" -ü¤b 3ö St SsHNAM€" -ü¤n 7ñ T THNAM€B
542 -ü¤~ ;ì T¼ T»HNAM€B -ü¤† ?ç U` U_HNAM€B -ü¤Ž Câ W¢ W¡HNAM€B -ü¤¢¥ ãQ WÁ I4HBLK  TOFADC32¥ ãÝ H WÁ IØHBLK  TOFADC31¥ äi I4 WÁ J|HBLK  TOFADC22¥ äõ IØ WÁ K HBLK  TOFADC21¥ å J| WÁ KÄHBLK  TOFADC12¥ æ K WÁ LhHBLK  TOFADC11¥ æ™ KÄ WÁ M HBLK  TOFTW32 ¥ ç% Lh WÁ M°HBLK  TOFTW31 ¥ ç± M WÁ NTHBLK  TOFTW22 ¥ è= M° WÁ Nø HBLK  TOFTW21 ¥ èÉ NT WÁ Oœ HBLK  TOFTW12 ¥ éU Nø WÁ P@ HBLK  TOFTW11 ¥ éá Oœ WÁ Pä
543 HBLK  TOFLIN32¥ êm P@ WÁ Qˆ HBLK  TOFLIN31¥ êù Pä WÁ R,HBLK  TOFLIN22¥ ë… Qˆ WÁ RÐHBLK  TOFLIN21¥ ì R, WÁ StHBLK  TOFLIN12¥ ì RÐ WÁ THBLK  TOFLIN11¥ í) St WÁ T¼HBLK  TOFK1D ¥ íµ T WÁ U`HBLK  TOFK1C ¥ îA T¼ WÁ W¢HBLK  TOFK1B  WÁ W½HREA€ WÁ W¾HINT€ÿÿÿèÿÿÿîÿÿÿúÿÿÿúÿÿÿøÿÿÿþÿÿÿúÿÿÿþÿÿÿþÿÿÿþÿÿÿþÿÿÿþÿÿÿýÿÿÿþÿÿÿýÿÿÿþÿÿÿþÿÿÿøÿÿÿþÿÿÿúÿÿÿþÿÿÿþÿÿÿþÿÿÿþÿÿÿþÿÿÿýÿÿÿþÿÿÿýÿÿÿþÿÿÿøÿÿÿþÿÿÿþÿÿÿúÿÿÿþÿÿÿþÿÿÿþÿÿÿþÿÿÿþÿÿÿþÿÿÿþÿÿÿþÿÿÿýÿÿÿþÿÿÿþÿÿÿýÿÿÿþ WÁ W¿HCHA€K1_S11S31 K1_S12S32 K1_S21S31 K1_S22S32 X_COOR_LIN11Y_COOR_LIN12Y_COOR_LIN21X_COOR_LIN22Y_COOR_LIN31X_COOR_LIN32TW11TW12TW21TW22TW31TW32ADCX11 ADCX12 ADCX21 ADCX22 ADCX31 ADCX32 ¥ îÍ U` WÁ WÀHBLK  TOFK1A ¥ H Uþ Vˆ W W¢ \ \<HIDT $ñ1/"< //Wntuple TOF CALIB HNAM€" /,-ü£ê ôF I4 I3HNAM€" -)-ü£ö øA IØ I×HNAM€" +
544 &-ü¤ ü< J| J{HNAM€" )
545 #-ü¤
546  7 K KHNAM€" ' -ü¤ 2 KÄ KÃHNAM€" %"-ü¤* - Lh LgHNAM€" $-ü£¶ ( M M HNAM€" #-ü£¾ # M° M¯HNAM€" "-ü£Æ  NT NSHNAM€" ! -ü£Ê  Nø N÷HNAM€"   -ü£Î  Oœ O›HNAM€"  -ü£Ú  P@ P?HNAM€" 
547 -ü¤J $
548 Pä PãHNAM€"   -ü¤R ( Qˆ Q‡HNAM€"  -ü¤Ztofroutine.f0000664000076500001440000006721310321442276012320 0ustar mennusers SUBROUTINE TOFROUTINE(XOUT,YOUT,ALPHA)
549
550 C------------------------------------------------
551 C W. Menn
552 C
553 C Version 1.00 August 2005
554 C Version 1.01 7-oct-2005
555 C changed initialization values of xtofpos and ytofpos to "100."
556 C if the calculated values are unphysical (> +/- 100), then they
557 C are set to "101." to avoid problems in the attenuation calculation
558 C------------------------------------------------
559
560
561 include 'common_tofroutine.f'
562 include 'common_tof.f'
563
564 c =======================================
565 c variables for tracking routine
566 c =======================================
567 parameter(NPOINT_MAX=100)
568 REAL XOUT(NPOINT_MAX),YOUT(NPOINT_MAX)
569 REAL ALPHA(5)
570
571
572 * ******************************************************************
573 * eventcounter
574 c write(*,*) '--- in beta.f ----'
575
576
577 * amplitude has to be 'secure' higher than pedestal for an adc event
578 secure = 2.
579
580 xtop = 1000.0
581 xmid = 1000.0
582 xbot = 1000.0
583
584 offset = 1
585 slope = 2
586 top = 1
587 mid = 2
588 bot = 3
589 left = 1
590 right = 2
591 none_ev = 0
592 none_find = 0
593 tdc_ev = 1
594 adc_ev = 1
595 itdc = 1
596 iadc = 2
597
598 do i=1,5
599 beta_a(i) = 1000.
600 enddo
601
602 do i=1,4
603 do j=1,12
604 adc_c(i,j) = 1000.
605 enddo
606 enddo
607
608
609 c the calibration files are read in the main program from xxx_tofcalib.rz
610
611 IF (TOFfst.EQ.0) THEN
612 TOFfst = 1
613
614 write(*,*) 'Calibration Data'
615 write(*,*) 'K1 data '
616 write(*,*) 'S11-S31'
617 DO i = 1,24
618 write(*,*) i,k1_S11S31(i)
619 ENDDO
620
621 write(*,*) 'S12-S32'
622 DO i = 1,18
623 write (*,*) i,k1_S12S32(i)
624 ENDDO
625
626 write(*,*) 'S21-S31'
627 DO i = 1,6
628 write(*,*) i,k1_S21S31(i)
629 ENDDO
630
631 write(*,*) 'S22-S32'
632 DO i = 1,6
633 write (*,*) i,k1_S22S32(i)
634 ENDDO
635
636
637 C--- use TDC-difference to calculate incident point
638
639 write(*,*) 'X-Y-Lin Coordinates'
640 DO i = 1, 8
641 write(*,*) i,y_coor_lin11(i,1),y_coor_lin11(i,2)
642 ENDDO
643 DO i = 1, 6
644 write(*,*) i,x_coor_lin12(i,1),x_coor_lin12(i,2)
645 ENDDO
646 DO i = 1, 2
647 write(*,*) i,x_coor_lin21(i,1),x_coor_lin21(i,2)
648 ENDDO
649 DO i = 1, 2
650 write(*,*) i,y_coor_lin22(i,1),y_coor_lin22(i,2)
651 ENDDO
652 DO i = 1, 3
653 write(*,*) i,y_coor_lin31(i,1),y_coor_lin31(i,2)
654 ENDDO
655 DO i = 1, 3
656 write(*,*) i,x_coor_lin32(i,1),x_coor_lin32(i,2)
657 ENDDO
658
659 c---------- Time Walk
660
661 write(*,*) 'Time Walk'
662 DO i = 1,8
663 write(*,*) i,tw11(left,i), tw11(right,i)
664 ENDDO
665 DO i = 1,6
666 write(*,*) i,tw12(left,i), tw12(right,i)
667 ENDDO
668 DO i = 1,2
669 write(*,*) i,tw21(left,i), tw21(right,i)
670 ENDDO
671 DO i = 1,2
672 write(*,*) i,tw22(left,i), tw22(right,i)
673 ENDDO
674 DO i = 1,3
675 write(*,*) i,tw31(left,i), tw31(right,i)
676 ENDDO
677 DO i = 1,3
678 write(*,*) i,tw32(left,i), tw32(right,i)
679 ENDDO
680
681 c---------- ADC map
682 c read ADC correction file
683
684 write(*,*) 'ADC Map'
685 write(*,*) 'ADC Map 1'
686 DO i = 1,8
687 write(*,*) (adcx11(left,i,j),j=1,2)
688 write(*,*) (adcx11(right,i,j),j=1,2)
689 ENDDO
690 DO i = 1,6
691 write(*,*) (adcx12(left,i,j),j=1,2)
692 write(*,*) (adcx12(right,i,j),j=1,2)
693 ENDDO
694
695 write(*,*) 'ADC map 2'
696 DO i = 1,2
697 write(*,*) (adcx21(left,i,j),j=1,2)
698 write(*,*) (adcx21(right,i,j),j=1,2)
699 ENDDO
700 DO i = 1,2
701 write(*,*) (adcx22(left,i,j),j=1,2)
702 write(*,*) (adcx22(right,i,j),j=1,2)
703 ENDDO
704
705 write(*,*) 'ADC map 3'
706 DO i = 1,3
707 write(*,*) (adcx31(left,i,j),j=1,2)
708 write(*,*) (adcx31(right,i,j),j=1,2)
709 ENDDO
710 DO i = 1,3
711 write(*,*) (adcx32(left,i,j),j=1,2)
712 write(*,*) (adcx32(right,i,j),j=1,2)
713 ENDDO
714
715 ENDIF
716 c end of reading parameter files
717
718 c------------------------- get ToF data --------------------------------
719
720 c put the adc and tdc values from ntuple into tofxx(i,j,k) variables
721
722 do j=1,8
723 tof11(1,j,2) = adc(ch11a(j),hb11a(j))
724 tof11(2,j,2) = adc(ch11b(j),hb11b(j))
725 tof11(1,j,1) = tdc(ch11a(j),hb11a(j))
726 tof11(2,j,1) = tdc(ch11b(j),hb11b(j))
727 c write(*,*) j,adc(ch11a(j),hb11a(j)),adc(ch11b(j),hb11b(j))
728 enddo
729
730 do j=1,6
731 tof12(1,j,2) = adc(ch12a(j),hb12a(j))
732 tof12(2,j,2) = adc(ch12b(j),hb12b(j))
733 tof12(1,j,1) = tdc(ch12a(j),hb12a(j))
734 tof12(2,j,1) = tdc(ch12b(j),hb12b(j))
735 enddo
736
737 do j=1,2
738 tof21(1,j,2) = adc(ch21a(j),hb21a(j))
739 tof21(2,j,2) = adc(ch21b(j),hb21b(j))
740 tof21(1,j,1) = tdc(ch21a(j),hb21a(j))
741 tof21(2,j,1) = tdc(ch21b(j),hb21b(j))
742 enddo
743
744 do j=1,2
745 tof22(1,j,2) = adc(ch22a(j),hb22a(j))
746 tof22(2,j,2) = adc(ch22b(j),hb22b(j))
747 tof22(1,j,1) = tdc(ch22a(j),hb22a(j))
748 tof22(2,j,1) = tdc(ch22b(j),hb22b(j))
749 enddo
750
751 do j=1,3
752 tof31(1,j,2) = adc(ch31a(j),hb31a(j))
753 tof31(2,j,2) = adc(ch31b(j),hb31b(j))
754 tof31(1,j,1) = tdc(ch31a(j),hb31a(j))
755 tof31(2,j,1) = tdc(ch31b(j),hb31b(j))
756 enddo
757
758 do j=1,3
759 tof32(1,j,2) = adc(ch32a(j),hb32a(j))
760 tof32(2,j,2) = adc(ch32b(j),hb32b(j))
761 tof32(1,j,1) = tdc(ch32a(j),hb32a(j))
762 tof32(2,j,1) = tdc(ch32b(j),hb32b(j))
763 enddo
764
765 C----------------------------------------------------------------------
766
767 DO i = 1,8
768 if (abs(tof11(1,i,itdc)).gt.10000.) tof11(1,i,itdc)= 10000.
769 if (abs(tof11(2,i,itdc)).gt.10000.) tof11(2,i,itdc)= 10000.
770 if (abs(tof11(1,i,iadc)).gt.10000.) tof11(1,i,iadc)= 10000.
771 if (abs(tof11(2,i,iadc)).gt.10000.) tof11(2,i,iadc)= 10000.
772 ENDDO
773
774 DO i = 1,6
775 if (abs(tof12(1,i,itdc)).gt.10000.) tof12(1,i,itdc)= 10000.
776 if (abs(tof12(2,i,itdc)).gt.10000.) tof12(2,i,itdc)= 10000.
777 if (abs(tof12(1,i,iadc)).gt.10000.) tof12(1,i,iadc)= 10000.
778 if (abs(tof12(2,i,iadc)).gt.10000.) tof12(2,i,iadc)= 10000.
779 ENDDO
780
781
782 DO i = 1,2
783 if (abs(tof21(1,i,itdc)).gt.10000.) tof21(1,i,itdc)= 10000.
784 if (abs(tof21(2,i,itdc)).gt.10000.) tof21(2,i,itdc)= 10000.
785 if (abs(tof21(1,i,iadc)).gt.10000.) tof21(1,i,iadc)= 10000.
786 if (abs(tof21(2,i,iadc)).gt.10000.) tof21(2,i,iadc)= 10000.
787 ENDDO
788
789 DO i = 1,2
790 if (abs(tof22(1,i,itdc)).gt.10000.) tof22(1,i,itdc)= 10000.
791 if (abs(tof22(2,i,itdc)).gt.10000.) tof22(2,i,itdc)= 10000.
792 if (abs(tof22(1,i,iadc)).gt.10000.) tof22(1,i,iadc)= 10000.
793 if (abs(tof22(2,i,iadc)).gt.10000.) tof22(2,i,iadc)= 10000.
794 ENDDO
795
796 DO i = 1,3
797 if (abs(tof31(1,i,itdc)).gt.10000.) tof31(1,i,itdc)= 10000.
798 if (abs(tof31(2,i,itdc)).gt.10000.) tof31(2,i,itdc)= 10000.
799 if (abs(tof31(1,i,iadc)).gt.10000.) tof31(1,i,iadc)= 10000.
800 if (abs(tof31(2,i,iadc)).gt.10000.) tof31(2,i,iadc)= 10000.
801 ENDDO
802
803 DO i = 1,3
804 if (abs(tof32(1,i,itdc)).gt.10000.) tof32(1,i,itdc)= 10000.
805 if (abs(tof32(2,i,itdc)).gt.10000.) tof32(2,i,itdc)= 10000.
806 if (abs(tof32(1,i,iadc)).gt.10000.) tof32(1,i,iadc)= 10000.
807 if (abs(tof32(2,i,iadc)).gt.10000.) tof32(2,i,iadc)= 10000.
808 ENDDO
809
810 C----------------------------------------------------------------
811 C------------ Check Paddles for hits -----------------------
812 C----------------------------------------------------------------
813
814 C upper tof S11
815 DO i = 1,8
816 DO j = 1,2
817 tof11_event(j,i) = none_ev
818 IF ((tof11(j,i,itdc).LT.2000).AND.(tof11(j,i,itdc).GT.100))
819 + tof11_event(j,i) = tof11_event(j,i) + tdc_ev
820 IF ((tof11(j,i,iadc).GT.secure).AND.
821 + (tof11(j,i,iadc).LT.4095))
822 + tof11_event(j,i) = tof11_event(j,i) + adc_ev
823 ENDDO
824 ENDDO
825
826 c find single paddle in upper tof with tdc and adc signal
827 tof11_i = none_find
828 tof11_j = none_find
829 check = .TRUE.
830 DO i = 1, 8
831 IF ((tof11_event(left,i).GE.1).AND.(tof11_event(right,i).GE.1))
832 + THEN
833 c check if an other paddle has also an event - then set flag
834 tof11_j = tof11_j + 2**(i-1)
835 IF (check.EQV..TRUE.) THEN
836 IF (tof11_i.EQ.none_find) THEN
837 tof11_i = i
838 ELSE
839 tof11_i = -1
840 check = .FALSE.
841 ENDIF
842 ENDIF
843 ENDIF
844 ENDDO
845
846
847 C upper tof S12
848 DO i = 1,6
849 DO j = 1,2
850 tof12_event(j,i) = none_ev
851 IF ((tof12(j,i,itdc).LT.2000).AND.(tof12(j,i,itdc).GT.100))
852 + tof12_event(j,i) = tof12_event(j,i) + tdc_ev
853 IF ((tof12(j,i,iadc).GT.secure).AND.
854 + (tof12(j,i,iadc).LT.4095))
855 + tof12_event(j,i) = tof12_event(j,i) + adc_ev
856 ENDDO
857 ENDDO
858
859 c find single paddle in upper tof with tdc and adc signal
860 tof12_i = none_find
861 tof12_j = none_find
862 check = .TRUE.
863 DO i = 1, 6
864 IF ((tof12_event(left,i).GE.1).AND.(tof12_event(right,i).GE.1))
865 + THEN
866 c check if an other paddle has also an event - then set flag
867 tof12_j = tof12_j + 2**(i-1)
868 IF (check.EQV..TRUE.) THEN
869 IF (tof12_i.EQ.none_find) THEN
870 tof12_i = i
871 ELSE
872 tof12_i = -1
873 check = .FALSE.
874 ENDIF
875 ENDIF
876 ENDIF
877 ENDDO
878
879
880 C middle tof S21
881 DO i = 1,2
882 DO j = 1,2
883 tof21_event(j,i) = none_ev
884 IF ((tof21(j,i,itdc).LT.2000).AND.(tof21(j,i,itdc).GT.100))
885 + tof21_event(j,i) = tof21_event(j,i) + tdc_ev
886 IF ((tof21(j,i,iadc).GT.secure).AND.
887 + (tof21(j,i,iadc).LT.4095))
888 + tof21_event(j,i) = tof21_event(j,i) + adc_ev
889 ENDDO
890 ENDDO
891
892 c find single paddle in upper tof with tdc and adc signal
893 tof21_i = none_find
894 tof21_j = none_find
895 check = .TRUE.
896 DO i = 1, 2
897 IF ((tof21_event(left,i).GE.1).AND.(tof21_event(right,i).GE.1))
898 + THEN
899 c check if an other paddle has also an event - then set flag
900 tof21_j = tof21_j + 2**(i-1)
901 IF (check.EQV..TRUE.) THEN
902 IF (tof21_i.EQ.none_find) THEN
903 tof21_i = i
904 ELSE
905 tof21_i = -1
906 check = .FALSE.
907 ENDIF
908 ENDIF
909 ENDIF
910 ENDDO
911
912 C middle tof S22
913 DO i = 1,2
914 DO j = 1,2
915 tof22_event(j,i) = none_ev
916 IF ((tof22(j,i,itdc).LT.2000).AND.(tof22(j,i,itdc).GT.100))
917 + tof22_event(j,i) = tof22_event(j,i) + tdc_ev
918 IF ((tof22(j,i,iadc).GT.secure).AND.
919 + (tof22(j,i,iadc).LT.4095))
920 + tof22_event(j,i) = tof22_event(j,i) + adc_ev
921 ENDDO
922 ENDDO
923
924 c find single paddle in upper tof with tdc and adc signal
925 tof22_i = none_find
926 tof22_j = none_find
927 check = .TRUE.
928 DO i = 1, 2
929 IF ((tof22_event(left,i).GE.1).AND.(tof22_event(right,i).GE.1))
930 + THEN
931 c check if an other paddle has also an event - then set flag
932 tof22_j = tof22_j + 2**(i-1)
933 IF (check.EQV..TRUE.) THEN
934 IF (tof22_i.EQ.none_find) THEN
935 tof22_i = i
936 ELSE
937 tof22_i = -1
938 check = .FALSE.
939 ENDIF
940 ENDIF
941 ENDIF
942 ENDDO
943
944
945 C bottom tof S31
946 DO i = 1,3
947 DO j = 1,2
948 tof31_event(j,i) = none_ev
949 IF ((tof31(j,i,itdc).LT.2000).AND.(tof31(j,i,itdc).GT.100))
950 + tof31_event(j,i) = tof31_event(j,i) + tdc_ev
951 IF ((tof31(j,i,iadc).GT.secure).AND.
952 + (tof31(j,i,iadc).LT.4095))
953 + tof31_event(j,i) = tof31_event(j,i) + adc_ev
954 ENDDO
955 ENDDO
956
957 c find single paddle in upper tof with tdc and adc signal
958 tof31_i = none_find
959 tof31_j = none_find
960 check = .TRUE.
961 DO i = 1, 3
962 IF ((tof31_event(left,i).GE.1).AND.(tof31_event(right,i).GE.1))
963 + THEN
964 c check if an other paddle has also an event - then set flag
965 tof31_j = tof31_j + 2**(i-1)
966 IF (check.EQV..TRUE.) THEN
967 IF (tof31_i.EQ.none_find) THEN
968 tof31_i = i
969 ELSE
970 tof31_i = -1
971 check = .FALSE.
972 ENDIF
973 ENDIF
974 ENDIF
975 ENDDO
976
977 C bottom tof S32
978 DO i = 1,3
979 DO j = 1,2
980 tof32_event(j,i) = none_ev
981 IF ((tof32(j,i,itdc).LT.2000).AND.(tof32(j,i,itdc).GT.100))
982 + tof32_event(j,i) = tof32_event(j,i) + tdc_ev
983 IF ((tof32(j,i,iadc).GT.secure).AND.
984 + (tof32(j,i,iadc).LT.4095))
985 + tof32_event(j,i) = tof32_event(j,i) + adc_ev
986 ENDDO
987 ENDDO
988
989 c find single paddle in upper tof with tdc and adc signal
990 tof32_i = none_find
991 tof32_j = none_find
992 check = .TRUE.
993 DO i = 1, 3
994 IF ((tof32_event(left,i).GE.1).AND.(tof32_event(right,i).GE.1))
995 + THEN
996 c check if an other paddle has also an event - then set flag
997 tof32_j = tof32_j + 2**(i-1)
998 IF (check.EQV..TRUE.) THEN
999 IF (tof32_i.EQ.none_find) THEN
1000 tof32_i = i
1001 ELSE
1002 tof32_i = -1
1003 check = .FALSE.
1004 ENDIF
1005 ENDIF
1006 ENDIF
1007 ENDDO
1008
1009 do i=1,6
1010 tof_i_flag(i)=0
1011 tof_j_flag(i)=0
1012 enddo
1013
1014 tof_i_flag(1)=tof11_i
1015 tof_i_flag(2)=tof12_i
1016 tof_i_flag(3)=tof21_i
1017 tof_i_flag(4)=tof22_i
1018 tof_i_flag(5)=tof31_i
1019 tof_i_flag(6)=tof32_i
1020
1021 tof_j_flag(1)=tof11_j
1022 tof_j_flag(2)=tof12_j
1023 tof_j_flag(3)=tof21_j
1024 tof_j_flag(4)=tof22_j
1025 tof_j_flag(5)=tof31_j
1026 tof_j_flag(6)=tof32_j
1027
1028 C--------------------------------------------------------------------
1029 C-------------------- Time walk correction -------------------------
1030 C--------------------------------------------------------------------
1031
1032 IF (tof11_i.GT.none_find) THEN
1033 tof11(left,tof11_i,itdc) = tof11(left,tof11_i,itdc) +
1034 + tw11(left,tof11_i)/sqrt(tof11(left,tof11_i,iadc))
1035 tof11(right,tof11_i,itdc) = tof11(right,tof11_i,itdc) +
1036 + tw11(right,tof11_i)/sqrt(tof11(right,tof11_i,iadc))
1037 ENDIF
1038
1039
1040 IF (tof12_i.GT.none_find) THEN
1041 tof12(left,tof12_i,itdc) = tof12(left,tof12_i,itdc) +
1042 + tw12(left,tof12_i)/sqrt(tof12(left,tof12_i,iadc))
1043 tof12(right,tof12_i,itdc) = tof12(right,tof12_i,itdc) +
1044 + tw12(right,tof12_i)/sqrt(tof12(right,tof12_i,iadc))
1045 ENDIF
1046
1047 IF (tof21_i.GT.none_find) THEN
1048 tof21(left,tof21_i,itdc) = tof21(left,tof21_i,itdc) +
1049 + tw21(left,tof21_i)/sqrt(tof21(left,tof21_i,iadc))
1050 tof21(right,tof21_i,itdc) = tof21(right,tof21_i,itdc) +
1051 + tw21(right,tof21_i)/sqrt(tof21(right,tof21_i,iadc))
1052 ENDIF
1053 IF (tof22_i.GT.none_find) THEN
1054 tof22(left,tof22_i,itdc) = tof22(left,tof22_i,itdc) +
1055 + tw22(left,tof22_i)/sqrt(tof22(left,tof22_i,iadc))
1056 tof22(right,tof22_i,itdc) = tof22(right,tof22_i,itdc) +
1057 + tw22(right,tof22_i)/sqrt(tof22(right,tof22_i,iadc))
1058 ENDIF
1059
1060 IF (tof31_i.GT.none_find) THEN
1061 tof31(left,tof31_i,itdc) = tof31(left,tof31_i,itdc) +
1062 + tw31(left,tof31_i)/sqrt(tof31(left,tof31_i,iadc))
1063 tof31(right,tof31_i,itdc) = tof31(right,tof31_i,itdc) +
1064 + tw31(right,tof31_i)/sqrt(tof31(right,tof31_i,iadc))
1065 ENDIF
1066
1067 IF (tof32_i.GT.none_find) THEN
1068 tof32(left,tof32_i,itdc) = tof32(left,tof32_i,itdc) +
1069 + tw32(left,tof32_i)/sqrt(tof32(left,tof32_i,iadc))
1070 tof32(right,tof32_i,itdc) = tof32(right,tof32_i,itdc) +
1071 + tw32(right,tof32_i)/sqrt(tof32(right,tof32_i,iadc))
1072 ENDIF
1073
1074
1075 C------------------------------------------------------------------
1076 C--- calculate track position in paddle using timing difference
1077 C------------------------------------------------------------------
1078
1079 do i=1,3
1080 xtofpos(i)=100.
1081 ytofpos(i)=100.
1082 enddo
1083 C----------------------------- S1 --------------------------------
1084
1085 IF (tof11_i.GT.none_find) THEN
1086 ytofpos(1) = ((tof11(1,tof11_i,itdc)-tof11(2,tof11_i,itdc))/2.
1087 + - y_coor_lin11(tof11_i,offset))/y_coor_lin11(tof11_i,slope)
1088 endif
1089
1090 IF (tof12_i.GT.none_find) THEN
1091 xtofpos(1) = ((tof12(1,tof12_i,itdc)-tof12(2,tof12_i,itdc))/2.
1092 + - x_coor_lin12(tof12_i,offset))/x_coor_lin12(tof12_i,slope)
1093 endif
1094
1095
1096 C----------------------------- S2 --------------------------------
1097
1098 IF (tof21_i.GT.none_find) THEN
1099 xtofpos(2) = ((tof21(1,tof21_i,itdc)-tof21(2,tof21_i,itdc))/2.
1100 + - x_coor_lin21(tof21_i,offset))/x_coor_lin21(tof21_i,slope)
1101 endif
1102
1103 IF (tof22_i.GT.none_find) THEN
1104 ytofpos(2) = ((tof22(1,tof22_i,itdc)-tof22(2,tof22_i,itdc))/2.
1105 + - y_coor_lin22(tof22_i,offset))/y_coor_lin22(tof22_i,slope)
1106 endif
1107
1108
1109 C----------------------------- S3 --------------------------------
1110
1111 IF (tof31_i.GT.none_find) THEN
1112 ytofpos(3) = ((tof31(1,tof31_i,itdc)-tof31(2,tof31_i,itdc))/2.
1113 + - y_coor_lin31(tof31_i,offset))/y_coor_lin31(tof31_i,slope)
1114 c write(*,*) '31',tof31(1,tof31_i,itdc),tof31(2,tof31_i,itdc),
1115 c + y_coor_lin31(tof31_i,offset),y_coor_lin31(tof31_i,slope),
1116 c + ytofpos(3)
1117 endif
1118
1119 IF (tof32_i.GT.none_find) THEN
1120 xtofpos(3) = ((tof32(1,tof32_i,itdc)-tof32(2,tof32_i,itdc))/2.
1121 + - x_coor_lin32(tof32_i,offset))/x_coor_lin32(tof32_i,slope)
1122 c write(*,*) '32',tof32(1,tof32_i,itdc),tof32(2,tof32_i,itdc),
1123 c + x_coor_lin32(tof32_i,offset),x_coor_lin32(tof32_i,slope),
1124 c + xtofpos(3)
1125 endif
1126
1127
1128 do i=1,3
1129 if (abs(xtofpos(i)).gt.100.) then
1130 xtofpos(i)=101.
1131 endif
1132 if (abs(ytofpos(i)).gt.100.) then
1133 ytofpos(i)=101.
1134 endif
1135 enddo
1136
1137
1138 C----------------------------------------------------------------------
1139 C-------------------- Corrections on ADC-data -------------------------
1140 C--------------------- zenith angle theta ---------------------------
1141 C----------------------------------------------------------------------
1142
1143 C if we have a good track use tracking information
1144
1145 dx=0.
1146 dy=0.
1147 dr=0.
1148 theta13 = 0.
1149
1150 if (xout(1).lt.100.) then
1151 dx = xout(1)-xout(3)
1152 dy = yout(1)-yout(3)
1153 dr = sqrt(dx*dx+dy*dy)
1154 theta13 = atan(dr/tofarm13)
1155 else
1156 IF ((tof12_i.GT.none_find).AND.(tof32_i.GT.none_find))
1157 & dx = xtofpos(1) - xtofpos(3)
1158 IF ((tof11_i.GT.none_find).AND.(tof31_i.GT.none_find))
1159 & dy = ytofpos(1) - ytofpos(3)
1160 dr = sqrt(dx*dx+dy*dy)
1161 theta13 = atan(dr/tofarm13)
1162 endif
1163
1164
1165 C----------------------------------------------------------------------
1166 C------------------ angle and ADC(x) correction
1167 C----------------------------------------------------------------------
1168 C----------------------------- S1 --------------------------------
1169
1170 yhelp=1000.
1171 if (yout(1).lt.100.) then
1172 yhelp=yout(1)
1173 else
1174 yhelp=ytofpos(1)
1175 endif
1176
1177
1178 IF (tof11_i.GT.none_find.AND.yhelp.lt.100) THEN
1179
1180 i = tof11_i
1181 xdummy=tof11(left,i,iadc)
1182 tof11(left,i,iadc) = tof11(left,i,iadc)*cos(theta13)
1183 if (tof11(left,i,iadc).lt.1000) then
1184 xkorr=adcx11(left,i,1)*exp(-yhelp/adcx11(left,i,2))
1185 xkorr0=adcx11(left,i,1)
1186 adc_c(ch11a(i),hb11a(i))=tof11(left,i,iadc)/xkorr
1187 endif
1188
1189 tof11(right,i,iadc) = tof11(right,i,iadc)*cos(theta13)
1190 if (tof11(right,i,iadc).lt.1000) then
1191 xkorr=adcx11(right,i,1)*exp(yhelp/adcx11(right,i,2))
1192 xkorr0=adcx11(right,i,1)
1193 adc_c(ch11b(i),hb11b(i))=tof11(right,i,iadc)/xkorr
1194 endif
1195 ENDIF
1196
1197
1198 xhelp=1000.
1199 if (xout(1).lt.100.) then
1200 xhelp=xout(1)
1201 else
1202 xhelp=xtofpos(1)
1203 endif
1204
1205
1206 IF (tof12_i.GT.none_find.AND.xhelp.lt.100) THEN
1207
1208 i = tof12_i
1209 tof12(left,i,iadc) = tof12(left,i,iadc)*cos(theta13)
1210 if (tof12(left,i,iadc).lt.1000) then
1211 xkorr=adcx12(left,i,1)*exp(-xhelp/adcx12(left,i,2))
1212 xkorr0=adcx12(left,i,1)
1213 adc_c(ch12a(i),hb12a(i))=tof12(left,i,iadc)/xkorr
1214 endif
1215
1216 tof12(right,i,iadc) = tof12(right,i,iadc)*cos(theta13)
1217 if (tof12(right,i,iadc).lt.1000) then
1218 xkorr=adcx12(right,i,1)*exp(xhelp/adcx12(right,i,2))
1219 xkorr0=adcx12(right,i,1)
1220 adc_c(ch12b(i),hb12b(i))=tof12(right,i,iadc)/xkorr
1221 endif
1222 ENDIF
1223
1224 C----------------------------- S2 --------------------------------
1225
1226 xhelp=1000.
1227 if (xout(2).lt.100.) then
1228 xhelp=xout(2)
1229 else
1230 xhelp=xtofpos(2)
1231 endif
1232
1233 IF (tof21_i.GT.none_find.AND.xhelp.lt.100) THEN
1234
1235 i = tof21_i
1236 tof21(left,i,iadc) = tof21(left,i,iadc)*cos(theta13)
1237 if (tof21(left,i,iadc).lt.1000) then
1238 xkorr=adcx21(left,i,1)*exp(-xhelp/adcx21(left,i,2))
1239 xkorr0=adcx21(left,i,1)
1240 adc_c(ch21a(i),hb21a(i))=tof21(left,i,iadc)/xkorr
1241 endif
1242
1243 tof21(right,i,iadc) = tof21(right,i,iadc)*cos(theta13)
1244 if (tof21(right,i,iadc).lt.1000) then
1245 xkorr=adcx21(right,i,1)*exp(xhelp/adcx21(right,i,2))
1246 xkorr0=adcx21(right,i,1)
1247 adc_c(ch21b(i),hb21b(i))=tof21(right,i,iadc)/xkorr
1248 endif
1249 ENDIF
1250
1251 yhelp=1000.
1252 if (yout(2).lt.100.) then
1253 yhelp=yout(2)
1254 else
1255 yhelp=ytofpos(2)
1256 endif
1257
1258 IF (tof22_i.GT.none_find.AND.yhelp.lt.100) THEN
1259
1260 i = tof22_i
1261 tof22(left,i,iadc) = tof22(left,i,iadc)*cos(theta13)
1262 if (tof22(left,i,iadc).lt.1000) then
1263 xkorr=adcx22(left,i,1)*exp(-yhelp/adcx22(left,i,2))
1264 xkorr0=adcx22(left,i,1)
1265 adc_c(ch22a(i),hb22a(i))=tof22(left,i,iadc)/xkorr
1266 endif
1267
1268 tof22(right,i,iadc) = tof22(right,i,iadc)*cos(theta13)
1269 if (tof22(right,i,iadc).lt.1000) then
1270 xkorr=adcx22(right,i,1)*exp(yhelp/adcx22(right,i,2))
1271 xkorr0=adcx22(right,i,1)
1272 adc_c(ch22b(i),hb22b(i))=tof22(right,i,iadc)/xkorr
1273 endif
1274 ENDIF
1275
1276 C----------------------------- S3 --------------------------------
1277
1278 yhelp=1000.
1279 if (yout(3).lt.100.) then
1280 yhelp=yout(3)
1281 else
1282 yhelp=ytofpos(3)
1283 endif
1284
1285 IF (tof31_i.GT.none_find.AND.yhelp.lt.100) THEN
1286
1287 i = tof31_i
1288 tof31(left,i,iadc) = tof31(left,i,iadc)*cos(theta13)
1289 if (tof31(left,i,iadc).lt.1000) then
1290 xkorr=adcx31(left,i,1)*exp(-yhelp/adcx31(left,i,2))
1291 xkorr0=adcx31(left,i,1)
1292 adc_c(ch31a(i),hb31a(i))=tof31(left,i,iadc)/xkorr
1293 endif
1294
1295 tof31(right,i,iadc) = tof31(right,i,iadc)*cos(theta13)
1296 if (tof31(right,i,iadc).lt.1000) then
1297 xkorr=adcx31(right,i,1)*exp(yhelp/adcx31(right,i,2))
1298 xkorr0=adcx31(right,i,1)
1299 adc_c(ch31b(i),hb31b(i))=tof31(right,i,iadc)/xkorr
1300 endif
1301 ENDIF
1302
1303 xhelp=1000.
1304 if (xout(3).lt.100.) then
1305 xhelp=xout(3)
1306 else
1307 xhelp=xtofpos(3)
1308 endif
1309
1310 IF (tof32_i.GT.none_find.AND.xhelp.lt.100) THEN
1311
1312 i = tof32_i
1313 tof32(left,i,iadc) = tof32(left,i,iadc)*cos(theta13)
1314 if (tof32(left,i,iadc).lt.1000) then
1315 xkorr=adcx32(left,i,1)*exp(-xhelp/adcx32(left,i,2))
1316 xkorr0=adcx32(left,i,1)
1317 adc_c(ch32a(i),hb32a(i))=tof32(left,i,iadc)/xkorr
1318 endif
1319
1320 tof32(right,i,iadc) = tof32(right,i,iadc)*cos(theta13)
1321 if (tof32(right,i,iadc).lt.1000) then
1322 xkorr=adcx32(right,i,1)*exp(xhelp/adcx32(right,i,2))
1323 xkorr0=adcx32(right,i,1)
1324 adc_c(ch32b(i),hb32b(i))=tof32(right,i,iadc)/xkorr
1325 endif
1326 ENDIF
1327
1328 C-----------------------------------------------------------------------
1329 C---------------------- calculate Beta ------------------------------
1330 C-----------------------------------------------------------------------
1331 C------------------- difference of sums ---------------------------
1332 C
1333 C DS = (t1+t2) - t3+t4)
1334 C DS = c1 + c2/beta*cos(theta)
1335 C c2 = 2d/c gives c2 = 2d/(c*TDCresolution) TDC=50ps/channel
1336 C => c2_23 = 60 for 0.45 m c2_13 = 109 for 0.81 m
1337
1338 C S11 - S31
1339 IF (tof11_i.GT.none_find.AND.tof31_i.GT.none_find) THEN
1340 xhelp1 = tof11(1,tof11_i,itdc)+tof11(2,tof11_i,itdc)
1341 xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1342 ds = xhelp1-xhelp2
1343 ihelp=(tof11_i-1)*3+tof31_i
1344 c1 = k1_S11S31(ihelp)
1345 beta_a(1) = c2_13/(cos(theta13)*(ds-c1))
1346 ENDIF
1347
1348 C S12 - S32
1349 IF (tof12_i.GT.none_find.AND.tof32_i.GT.none_find) THEN
1350 xhelp1 = tof12(1,tof12_i,itdc)+tof12(2,tof12_i,itdc)
1351 xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1352 ds = xhelp1-xhelp2
1353 ihelp=(tof12_i-1)*3+tof32_i
1354 c1 = k1_S12S32(ihelp)
1355 beta_a(2) = c2_13/(cos(theta13)*(ds-c1))
1356 ENDIF
1357
1358
1359 C S21 - S31
1360 IF (tof21_i.GT.none_find.AND.tof31_i.GT.none_find) THEN
1361 xhelp1 = tof21(1,tof21_i,itdc)+tof21(2,tof21_i,itdc)
1362 xhelp2 = tof31(1,tof31_i,itdc)+tof31(2,tof31_i,itdc)
1363 ds = xhelp1-xhelp2
1364 ihelp=(tof21_i-1)*3+tof31_i
1365 c1 = k1_S21S31(ihelp)
1366 beta_a(3) = c2_23/(cos(theta13)*(ds-c1))
1367 ENDIF
1368
1369 C S22 - S32
1370 IF (tof22_i.GT.none_find.AND.tof32_i.GT.none_find) THEN
1371 xhelp1 = tof22(1,tof22_i,itdc)+tof22(2,tof22_i,itdc)
1372 xhelp2 = tof32(1,tof32_i,itdc)+tof32(2,tof32_i,itdc)
1373 ds = xhelp1-xhelp2
1374 ihelp=(tof22_i-1)*3+tof32_i
1375 c1 = k1_S22S32(ihelp)
1376 beta_a(4) = c2_23/(cos(theta13)*(ds-c1))
1377 ENDIF
1378
1379 C-------
1380
1381 icount=0
1382 sw=0.
1383 sxw=0.
1384 beta_mean=100.
1385
1386 do i=1,4
1387 if ((beta_a(i).gt.0.4).and.(beta_a(i).lt.1.5)) then
1388 icount= icount+1
1389 if (i.le.2) w_i=1./(0.13**2.)
1390 if (i.ge.3) w_i=1./(0.16**2.)
1391 sxw=sxw + beta_a(i)*w_i
1392 sw =sw + w_i
1393 endif
1394 enddo
1395 if (icount.eq.4) beta_mean=sxw/sw
1396 beta_a(5) = beta_mean
1397
1398
1399 c ERROR MESSAGES
1400 100 continue
1401 *
1402 RETURN
1403 END
1404
1405 toftrack.f0000775000076500001440000004000510321444754011733 0ustar mennusersC------------------------------------------------
1406 PROGRAM TOFTRACK
1407 C------------------------------------------------
1408 C W. Menn
1409 C
1410 C Based on the "template" progran from Elena Vannuccini
1411 C
1412 C Version 1.00 August 2005
1413 C Version 1.01 07-oct-2005: Some bugs found
1414 C - new rz file must be named "***_toftrack.rz'
1415 C - booking of the EVENT and CPU blocks changed according
1416 C to Elena's "book_level2" routine
1417 C
1418 C------------------------------------------------
1419
1420 include 'trk_level2.f'
1421 include 'common_tofroutine.f'
1422 include 'common_tof.f'
1423
1424 c----- HBOOK
1425 INTEGER HMEM
1426 parameter (NWPAWC=8500000)
1427 common/PAWC/HMEM(NWPAWC)
1428
1429 parameter (ntp_level2=22)
1430 parameter (ntp_new=2)
1431
1432 c------------------------------------------------------------------------
1433 c local variables
1434 c------------------------------------------------------------------------
1435 character*74 data_file !data file name
1436 character*74 tof_file !tofdata file name
1437 character*74 data_dir !data directory
1438 character*74 data_file_level2
1439 character*74 data_file_tof
1440 character*74 data_file_tofcalib
1441 character*74 data_file_new
1442
1443 parameter (lun_data_level2=72) !data file id number
1444
1445 c------------------------------------------------------------------
1446 COMMON/QUEST/IQUEST(100)
1447
1448 C------------------------------------------------------------------
1449 c =======================================
1450 c variables for tracking routine
1451 c =======================================
1452 parameter(NPOINT_MAX=100)
1453 DOUBLE PRECISION ZIN(NPOINT_MAX)
1454 DOUBLE PRECISION XOUT1(NPOINT_MAX),YOUT1(NPOINT_MAX)
1455 REAL XOUT(NPOINT_MAX),YOUT(NPOINT_MAX)
1456 DOUBLE PRECISION AL_P(5)
1457 REAL XFIT(6),YFIT(6),ZFIT(6),ALPHA(5),XGOOD1(6),YGOOD1(6)
1458 c =======================================
1459
1460 c define TOF Z-coordinates
1461 parameter (NPTOF=3)
1462 REAL ZTOF(NPTOF)
1463 c DATA ZTOF/55.,25.,-23/ !NB!!! from TOP to BOTTOM
1464 DATA ZTOF/53.4,23.9,-23.4/ !Stockholm 29.9.2005
1465
1466 c------------------------------------------------------------------------
1467 C
1468 CHARACTER*100 name
1469 C
1470
1471 INTEGER lrec, openntuple
1472 INTEGER istat, ierr, icycle
1473 PARAMETER (lrec=4096)
1474
1475
1476 integer patterntrig1(6)
1477 real chi
1478
1479 character*35 block1,block2
1480
1481 C-------------------------------------------------------------------------
1482 c
1483 c HBOOK initialization
1484 c
1485 c------------------------------------------------------------------------
1486
1487 call HLIMIT(NWPAWC)
1488
1489 C HERE A PATH where you can write!
1490 C
1491 c print *
1492 c print *,'File saved in: ',name
1493 C
1494 C CHANGE here (hbname and hbnt if you want another ntuple id number
1495 C
1496
1497 111 format(a)
1498 print*,'data dir:'
1499 read(*,111)data_dir
1500 c read(*,*)data_dir
1501 print*,data_dir
1502 print*,'tof file?'
1503 print*,'(without estention: output_YYMMDD_XXX )'
1504 read(*,*)tof_file
1505
1506 print*,tof_file
1507 print*,' '
1508
1509 print*,'first event:'
1510 read(*,*) minevent
1511 print*,minevent
1512 c print*,' '
1513
1514 print*,'number of events to be analysed'
1515 read(*,*) ntotev
1516 print*,ntotev
1517
1518
1519 c------------------------------------------------------------------------
1520 c--------------- open ToF rz file
1521 c------------------------------------------------------------------------
1522
1523 print*,
1524 $ data_dir(1:LNBLNK(data_dir))//tof_file(1:LNBLNK(tof_file))
1525
1526
1527 505 format(a,'DW_',a,'_tof.rz')
1528 write(data_file_tof,505)
1529 $ data_dir(1:LNBLNK(data_dir))
1530 $ ,tof_file(1:LNBLNK(tof_file))
1531 print*,'__________ opening TOF rz file __________'
1532 print*,data_file_tof
1533
1534
1535 call HROPEN(59,
1536 $ 'EVENT',data_file_tof,'QP',4096,istat) !opens rz
1537
1538
1539 if(istat.ne.0) stop
1540 print*,' '
1541 print*,'reading TOF n-tuple...'
1542 call HRIN(ntp_tof,9999,0)
1543 CALL HBNAME(ntp_tof,' ',0,'$CLEAR')
1544 CALL HBNAME(ntp_tof,'EVENT',good,'$SET')
1545 CALL HBNAME(ntp_tof,'TRIGGER',trig_evcount,'$SET')
1546 CALL HBNAME(ntp_tof,'TOF',tdcid,'$SET')
1547 call HPRNTU(ntp_tof)
1548 call HNOENT(ntp_tof,iemax0)
1549 write(*,*) 'Number of events ToF ',iemax0
1550
1551
1552 c------------------------------------------------------------------------
1553 c--------------- open ToF calib rz file
1554 c------------------------------------------------------------------------
1555
1556 print*,
1557 $ data_dir(1:LNBLNK(data_dir))//tof_file(1:LNBLNK(tof_file))
1558
1559 506 format(a,'DW_',a,'_tofcalib.rz')
1560 write(data_file_tofcalib,506)
1561 $ data_dir(1:LNBLNK(data_dir))
1562 $ ,tof_file(1:LNBLNK(tof_file))
1563 print*,'__________ opening TOF calib rz file __________'
1564 print*,data_file_tofcalib
1565
1566 CALL HROPEN(59,'TOF K1A',data_file_tofcalib,'QP',4096,istat)
1567
1568 if (istat.ne.0) then ! check if HROPEN was OK
1569 write(*,*) 'Can''t open correct ToF calibration File !!!'
1570 write(*,*) 'Will use standard file tofcalib.rz !!!'
1571 507 format(a,'tofcalib.rz')
1572 write(data_file_tofcalib,507)
1573 $ data_dir(1:LNBLNK(data_dir))
1574 print*,'__________ opening TOF calib rz file __________'
1575 print*,data_file_tofcalib
1576
1577 CALL HROPEN(59,'TOF K1A',data_file_tofcalib,'QP',4096,istat)
1578 endif
1579
1580 print*,' reading TOF CALIB n-tuple...'
1581
1582 call HRIN(ntp_tofcalib,9999,0)
1583
1584 call HBNAME(ntp_tofcalib,' ',0,'$CLEAR')
1585
1586 call HBNAME(ntp_tofcalib,'TOFK1A',k1_s11s31,'$SET')
1587 call HBNAME(ntp_tofcalib,'TOFK1B',k1_s12s32,'$SET')
1588 call HBNAME(ntp_tofcalib,'TOFK1C',k1_s21s31,'$SET')
1589 call HBNAME(ntp_tofcalib,'TOFK1D',k1_s22s32,'$SET')
1590
1591 call HBNAME(ntp_tofcalib,'TOFLIN11',y_coor_lin11,'$SET')
1592 call HBNAME(ntp_tofcalib,'TOFLIN12',x_coor_lin12,'$SET')
1593 call HBNAME(ntp_tofcalib,'TOFLIN21',x_coor_lin21,'$SET')
1594 call HBNAME(ntp_tofcalib,'TOFLIN22',y_coor_lin22,'$SET')
1595 call HBNAME(ntp_tofcalib,'TOFLIN31',y_coor_lin31,'$SET')
1596 call HBNAME(ntp_tofcalib,'TOFLIN32',x_coor_lin32,'$SET')
1597
1598 call HBNAME(ntp_tofcalib,'TOFTW11',tw11,'$SET')
1599 call HBNAME(ntp_tofcalib,'TOFTW12',tw12,'$SET')
1600 call HBNAME(ntp_tofcalib,'TOFTW21',tw21,'$SET')
1601 call HBNAME(ntp_tofcalib,'TOFTW22',tw22,'$SET')
1602 call HBNAME(ntp_tofcalib,'TOFTW31',tw31,'$SET')
1603 call HBNAME(ntp_tofcalib,'TOFTW32',tw32,'$SET')
1604
1605 call HBNAME(ntp_tofcalib,'TOFADC11',adcx11,'$SET')
1606 call HBNAME(ntp_tofcalib,'TOFADC12',adcx12,'$SET')
1607 call HBNAME(ntp_tofcalib,'TOFADC21',adcx21,'$SET')
1608 call HBNAME(ntp_tofcalib,'TOFADC22',adcx22,'$SET')
1609 call HBNAME(ntp_tofcalib,'TOFADC31',adcx31,'$SET')
1610 call HBNAME(ntp_tofcalib,'TOFADC32',adcx32,'$SET')
1611
1612 call HPRNTU(ntp_tofcalib)
1613
1614 call HNOENT(ntp_tofcalib,iemax_cal)
1615 c write(*,*) 'Number of Events CALIB ',iemax_cal
1616
1617 do iev=1,iemax_cal
1618 call HGNT(ntp_tofcalib,iev,ierr) !reads an event
1619 enddo
1620
1621 call hrout(ntp_tofcalib,icycle,' ')
1622 call hrend('TOF K1A')
1623 close(0)
1624
1625
1626
1627 c------------------------------------------------------------------------
1628 c--------------- open Track Level2 rz file
1629 c------------------------------------------------------------------------
1630
1631 data_file=tof_file
1632 print*,'data dir:'
1633 c read(*,111)data_dir
1634 print*,data_dir
1635 c print*,'data file?'
1636 c print*,'(without estention: output_YYMMDD_XXX )'
1637 c read(*,*)data_file
1638
1639 print*,'data_file:'
1640 print*,data_file
1641 print*,' '
1642
1643 print*,
1644 $ data_dir(1:LNBLNK(data_dir))//data_file(1:LNBLNK(data_file))
1645
1646 c------------------------------------------------------------------------
1647 504 format(a,'DW_',a,'_level2.rz')
1648 write(data_file_level2,504)
1649 $ data_dir(1:LNBLNK(data_dir))
1650 $ ,data_file(1:LNBLNK(data_file))
1651 print*,'__________ opening LEVEL2 rz file __________'
1652 print*,data_file_level2
1653 print*,'__________ opening LEVEL2 rz file __________'
1654 print*,data_file_level2
1655 IQUEST(10)=65000
1656 call HROPEN(lun_data_level2,
1657 $ 'LEVEL2',data_file_level2,'QP',4096,istat) !opens rz
1658 if(istat.ne.0) goto 19
1659 print*,'reading LEVEL2 n-tuple...'
1660 call HRIN(ntp_level2,9999,0)
1661
1662 * -----------------------------------------------
1663 CALL HBNAME(ntp_level2,' ',0,'$CLEAR')
1664 CALL HBNAME(ntp_level2,'EVENT',GOOD2,'$SET')
1665 CALL HBNAME(ntp_level2,'CPU',pkt_type,'$SET')
1666 CALL HBNAME(ntp_level2,'TRACKS',ntrk,'$SET')
1667 CALL HBNAME(ntp_level2,'SINGLETS',nclsx,'$SET')
1668 * -----------------------------------------------
1669
1670 call HPRNTU(ntp_level2)
1671 call HNOENT(ntp_level2,iemax2)
1672
1673 write(*,*) 'Number of events LEVEL2 ',iemax2
1674 print*,'ok'
1675 print*,' '
1676
1677
1678
1679 c------------------------------------------------------------------------
1680 c read magnetic field map
1681 c------------------------------------------------------------------------
1682 c
1683 c =======================
1684
1685
1686 c read magnetic field map
1687 c =======================
1688 c
1689 c------------------------------------------------------------------------
1690 print*,'- read magnetic field map'
1691 print*,' '
1692 call read_B
1693 print*,' '
1694
1695 c print*,' '
1696 c print*,'- read magnetic field map'
1697 c print*,' '
1698 c call read_B_2maps
1699 c
1700
1701
1702 c------------------------------------------------------------------------
1703 c open new RZ file
1704 c------------------------------------------------------------------------
1705
1706 503 format(a,'DW_',a,'_toftrack.rz')
1707 write(data_file_new,503)
1708 $ data_dir(1:LNBLNK(data_dir))
1709 $ ,data_file(1:LNBLNK(data_file))
1710 print*,'__________ opening NEW rz file __________'
1711 print*,data_file_new
1712
1713
1714 call HROPEN(10,'TEST',data_file_new,'NP',4096,istat) !opens rz
1715
1716 call HBNT(ntp_new,'TOF',' ')
1717
1718
1719 c call HBNAME(ntp_new,'EVENT',good,'GOOD:L,NEV_TRK:I')
1720
1721 call HBNAME(ntp_new,'EVENT',good2,'GOOD2:L,NEV2:I')
1722
1723
1724 c call HBNAME(ntp_new,'CPU',pkt_type
1725 c $ ,'PKT_TYPE:I
1726 c $ ,PKT_NUM:I
1727 c $ ,OBT:I
1728 c $ ,WHICH_CALIB:I')
1729
1730 call HBNAME(ntp_new,'CPU',pkt_type
1731 $ ,'PKT_TYPE:I::[0,50]
1732 $ ,PKT_NUM:I
1733 $ ,OBT:I
1734 $ ,WHICH_CALIB:I::[0,50]')
1735
1736
1737
1738 call HBNAME(ntp_new,'TOF',tdcid
1739 $ ,'TDCID(12):I
1740 $ ,EVCOUNT(12):I
1741 $ ,TDCMASK(12):I
1742 $ ,ADC(4,12):I
1743 $ ,TDC(4,12):I
1744 $ ,TEMP1(12):I
1745 $ ,TEMP2(12):I')
1746
1747 call HBNAME(ntp_new,'TOF',beta_a,'BETA(5)')
1748 call HBNAME(ntp_new,'TOF',xtofpos,'XTOF(3)')
1749 call HBNAME(ntp_new,'TOF',ytofpos,'YTOF(3)')
1750 call HBNAME(ntp_new,'TOF',adc_c,'ADC_C(4,12)')
1751 call HBNAME(ntp_new,'TOF',tof_i_flag,'IFLAG(6)')
1752 call HBNAME(ntp_new,'TOF',tof_j_flag,'JFLAG(6)')
1753
1754 call HBNAME(ntp_new,'TOF',xout,'XOUT(3)')
1755 call HBNAME(ntp_new,'TOF',yout,'YOUT(3)')
1756
1757
1758 call HBNAME(ntp_new,'TRIGGER',trig_evcount
1759 $ ,'TRIG_EVCOUNT:I
1760 $ ,PMTPL(3):I
1761 $ ,TRIGRATE(6):I
1762 $ ,DLTIME(2):I
1763 $ ,S4CALCOUNT(2):I
1764 $ ,PMTCOUNT1(24):I
1765 $ ,PMTCOUNT2(24):I
1766 $ ,PATTERNBUSY(3):I
1767 $ ,PATTERNTRIG(6):I
1768 $ ,TRIGCONF:I')
1769
1770
1771 417 format('NTRK:I::[0,',I4,']')
1772 418 format(',IMAGE(NTRK):I::[0,',I4,']')
1773 write(block1,417)NTRKMAX
1774 write(block2,418)NTRKMAX
1775 call HBNAME(ntp_new,'TRACKS',NTRK,
1776 $ block1//
1777 $ block2//'
1778 $ ,XM(6,NTRK):R
1779 $ ,YM(6,NTRK):R
1780 $ ,ZM(6,NTRK):R
1781 $ ,RESX(6,NTRK):R
1782 $ ,RESY(6,NTRK):R
1783 $ ,AL(5,NTRK):R
1784 $ ,COVAL(5,5,NTRK):R
1785 $ ,CHI2(NTRK):R
1786 $ ,XGOOD(6,NTRK):I::[0,1]
1787 $ ,YGOOD(6,NTRK):I::[0,1]
1788 $ ,XV(6,NTRK):R
1789 $ ,YV(6,NTRK):R
1790 $ ,ZV(6,NTRK):R
1791 $ ,AXV(6,NTRK):R
1792 $ ,AYV(6,NTRK):R
1793 $ ,DEDXP(6,NTRK):R
1794 $ ')
1795 call HBNAME(ntp_new,'SINGLETS',nclsx,
1796 $ 'NCLSX(6):I,NCLSY(6):I')
1797
1798
1799 call HPRNTU(ntp_new)
1800
1801 c------------------------------------------------------------------------
1802
1803 call HCDIR('//LEVEL2',' ')
1804
1805 c------------------------------------------------------------------------
1806 c start loop on events
1807 c------------------------------------------------------------------------
1808
1809 maxevent=minevent+ntotev
1810 igoodevent=0
1811
1812 c do iev = 1,iemax0
1813 do iev = minevent,MIN(iemax0,maxevent) !loop on events
1814 Call Hcdir('//EVENT',' ')
1815 Call Hgnt(ntp_tof,iev,Ierr)
1816
1817 do i=1,6
1818 patterntrig1(i) = patterntrig(i)
1819 enddo
1820
1821 * ----------------------------------------------
1822 Call Hcdir('//LEVEL2',' ')
1823 call HGNT(ntp_level2,iev,ierr) !reads an event
1824
1825 if(ierr.ne.0) goto 21
1826 * ----------------------------------------------
1827
1828 do i=1,nptof
1829 xout(i)=1000.
1830 yout(i)=1000.
1831 enddo
1832 do i=1,5
1833 ALPHA(i) = 1000.
1834 enddo
1835 do i=1,6
1836 XFIT(i) = 1000.
1837 YFIT(i) = 1000.
1838 ZFIT(i) = 1000.
1839 XGOOD1(i) = 1000.
1840 YGOOD1(i) = 1000.
1841 enddo
1842
1843 chi = 1000.
1844
1845 *=======> INSTERT HERE YOUR CODE
1846
1847 * ---- example ----
1848 * write(*,*) 'GOOD2 ',good2
1849 * if(GOOD2)then
1850 if(NTRK.ne.0)then
1851 print*,'Event ',iev,' # tracks ',ntrk
1852 if(ntrk.eq.1)then
1853
1854 chi = CHI2(1)
1855 do i=1,5
1856 ALPHA(i) = AL(i,1)
1857 enddo
1858 do i=1,6
1859 XFIT(i) = XV(i,1)
1860 YFIT(i) = YV(i,1)
1861 ZFIT(i) = ZV(i,1)
1862 XGOOD1(i)=XGOOD(i,1)
1863 YGOOD1(i)=YGOOD(i,1)
1864 enddo
1865
1866 igoodevent = igoodevent+1
1867 * assigned input parameters for track routine
1868 * 1) Z-coordinates where the trajectory is evaluated
1869 do itof=1,NPTOF
1870 ZIN(itof) = ZTOF(itof)
1871 enddo
1872 * 2) track status vector
1873 do i=1,5
1874 AL_P(i) = AL(i,1)
1875 enddo
1876 * -------- *** tracking routine *** --------
1877 call track(NPTOF,ZIN,XOUT1,YOUT1,AL_P,IFAIL)
1878 * ------------------------------------------
1879 do itof=1,NPTOF
1880 XOUT(itof)=XOUT1(itof)
1881 YOUT(itof)=YOUT1(itof)
1882 enddo
1883
1884 do itof=1,NPTOF
1885 c print*,' ',itof,ZIN(itof),XOUT(itof),YOUT(itof)
1886 enddo
1887 endif
1888 else
1889 print*,'Event ',iev,' *** BAD ***'
1890 endif
1891
1892
1893 call tofroutine(xout,yout,alpha)
1894
1895
1896 c--------------------- fill new rz file -----------------------------
1897
1898 call HFNT(2)
1899
1900 enddo !end loop on events
1901 GOTO 9000 !got to end
1902
1903 c------------------------------------------------------------------------
1904 c
1905 c data file opening error
1906 c
1907 c------------------------------------------------------------------------
1908 19 continue
1909
1910 print*,' '
1911 print*,'ERROR OPENING DATA FILE: ',data_file
1912 print*,' '
1913 print*,' '
1914
1915 goto 9000 !the end
1916
1917 c------------------------------------------------------------------------
1918 c
1919 c level2 ntuple event reading error
1920 c
1921 c------------------------------------------------------------------------
1922
1923 21 continue
1924
1925 print*,' '
1926 print*,'ERROR WHILE READING LEVEL2 NTUPLE, AT EVENT
1927 $ : ',iev
1928 print*,' '
1929 print*,' '
1930
1931 goto 9000 !the end
1932
1933 c------------------------------------------------------------------------
1934 c
1935 c closes files and exits
1936 c
1937 c------------------------------------------------------------------------
1938
1939 9000 continue
1940
1941 write(*,*) 'Good Events ',igoodevent
1942
1943
1944 c--------------------------------------------------------------
1945
1946 call HCDIR('//EVENT',' ')
1947 CALL HROUT(0,icycle,' ')
1948 call HREND('EVENT')
1949 close(0)
1950
1951 call HCDIR('//LEVEL2',' ')
1952 call HREND('level2')
1953 close(lun_data_level2)
1954
1955
1956 call HPRNTU(2)
1957 call HCDIR('//TEST',' ')
1958 CALL HROUT(0,icycle,' ')
1959 call HREND('TEST')
1960 close(0)
1961
1962 STOP
1963 END
1964
1965
1966 include 'tofroutine.f'
1967
1968 trk_level2.f0000644000076500001440000000607310314004227012156 0ustar mennusers*************************************************************************
1969 *
1970 * Common level2.f
1971 *
1972 * contains LEVEL2 ntuple variables definitions
1973 *
1974 *
1975 *************************************************************************
1976
1977 PARAMETER (NTRKMAX=50) !ncloyz_max*ncloxz_max)
1978
1979 c EVENT block:
1980 * -----------------------------------------------------------
1981 logical good2 !flag to mark good or noise events
1982 integer nev2 !level2 event number
1983 common/level2/good2,nev2
1984
1985 c CPU block (only for ground data):
1986 * -----------------------------------------------------------
1987 integer pkt_type !CPU packet type identifier. see http://people.roma2.infn.it/~cpu/HB_list.txt
1988 c 0x12 --> calibration board 0
1989 c 0x13 --> calibration board 1
1990 c 0x10 --> event
1991 c 0x30 --> full event for calib special
1992 c 0x83 --> tracker ALARM (control register)
1993 integer pkt_num !CPU packet number
1994 integer obt !CPU on-board time
1995 integer which_calib !calibration file identifier. see DW_DATE_NUM_calib.txt file
1996 common/level2_cpu/pkt_type,pkt_num,obt,which_calib
1997
1998
1999 * -----------------------------------------------------------
2000 * Common to store TRACK info
2001 * All the variables have a dimention equal to the number of
2002 * found tracks
2003 * -----------------------------------------------------------
2004 c TRACK PARAMETERS
2005 integer ntrk !# identified tracks
2006 integer image !flag to tag track-images
2007 real al !track state vector
2008 integer xgood !mask of used planes
2009 integer ygood !*
2010 real xm !me asured points
2011 real ym !*
2012 real zm !*
2013 real resx !spatial resolution
2014 real resy !*
2015 real chi2 !chi2
2016 real xv !calculated points
2017 real yv !*
2018 real zv !*
2019 real axv !calculated angles (deg)
2020 real ayv !*
2021 real dedxp
2022 common/level2_tracks/
2023 $ ntrk
2024 $ ,image(NTRKMAX)
2025 $ ,xm(6,NTRKMAX)
2026 $ ,ym(6,NTRKMAX)
2027 $ ,zm(6,NTRKMAX)
2028 $ ,resx(6,NTRKMAX)
2029 $ ,resy(6,NTRKMAX)
2030 $ ,al(5,NTRKMAX)
2031 $ ,chi2(NTRKMAX)
2032 $ ,xgood(6,NTRKMAX)
2033 $ ,ygood(6,NTRKMAX)
2034 $ ,xv(6,NTRKMAX)
2035 $ ,yv(6,NTRKMAX)
2036 $ ,zv(6,NTRKMAX)
2037 $ ,axv(6,NTRKMAX)
2038 $ ,ayv(6,NTRKMAX)
2039 $ ,dedxp(6,NTRKMAX)
2040 * -----------------------------------------------------------
2041 * Common to store SINGLET info
2042 * (clusters not associated with any track)
2043 * -----------------------------------------------------------
2044 integer nclsx !# unassociated clusters per plane X views
2045 integer nclsy ! " " " " Y views
2046 common/level2_singlets/
2047 $ nclsx(6),nclsy(6)
2048
2049

  ViewVC Help
Powered by ViewVC 1.1.23