1 |
subroutine trkeventpkt(runerror,event_file_name) |
2 |
|
3 |
include '../commonyoda/commontracker.f' |
4 |
include '../commonyoda/dataformat.f' |
5 |
c include '../commonyoda/trk_calib_parameters.f' |
6 |
include '../commonyoda/level0.f' |
7 |
|
8 |
logical DEBUG |
9 |
common/DEBUGflag/DEBUG |
10 |
c data DEBUG/.true./ |
11 |
data DEBUG/.false./ |
12 |
|
13 |
|
14 |
integer ndummy |
15 |
data ndummy/1000/ |
16 |
|
17 |
integer runerror !readevent error flag |
18 |
integer ffd_pkt !pkt file descriptor |
19 |
!(file temporaneo) |
20 |
character*60 event_file_name !nome file |
21 |
|
22 |
integer lun_pkt |
23 |
data lun_pkt/10/ |
24 |
|
25 |
|
26 |
open(unit=lun_pkt, |
27 |
$ name=EVENT_FILE_NAME(1:lnblnk(EVENT_FILE_NAME)), |
28 |
$ status='old', |
29 |
$ form='unformatted' |
30 |
$ ) |
31 |
ffd_pkt = FNum(lun_pkt) !reads unix file descriptor |
32 |
|
33 |
|
34 |
call initlevel0 |
35 |
|
36 |
TOTDATAlength = 0. !total length of data buffer |
37 |
do iview=1,ndummy !loop on views |
38 |
call searchtrkheader(runerror,ffd_pkt) |
39 |
c if(runerror.eq.-1) goto 24 |
40 |
if(runerror.eq.-1) goto 2222 |
41 |
if(runerror.eq.1) then |
42 |
c print*,' ' |
43 |
c print*,'readraw: END OF CPU PACKET ' |
44 |
c print*,'______________________________________ ' |
45 |
c goto 9900 !end loop on files |
46 |
c goto 8800 !end loop on views (DSP pkt) |
47 |
goto 2222 |
48 |
endif |
49 |
|
50 |
if(checkheader.ne.2) then |
51 |
c print*,'>>>> ERROR <<<< (trkeventpkt)' |
52 |
c print*,'>>>> CPU packet type ',!pkt_type, |
53 |
c $ ' does not match DSP type ',checkheader |
54 |
c goto 9909 ! next event (==> search another CPU header) |
55 |
DAQmode_temp = ishft(iand(header(1),z'03f0'),-4) |
56 |
DSPnumber_temp = iand(header(1),z'000f') |
57 |
c print*,' -----------------------------------' |
58 |
c $ ,iview |
59 |
c print*,' DSP number-----',int(DSPnumber_temp) |
60 |
c print*,' DAQ mode-------',int(DAQmode_temp) |
61 |
c print*,' -----------------------------------' |
62 |
goto 2525 !next view (==> search another DSP header) |
63 |
endif |
64 |
|
65 |
call unpackdata(runerror,ffd_pkt) |
66 |
c if(runerror.eq.-1) goto 24 |
67 |
if(runerror.eq.-1) goto 2222 |
68 |
c if(runerror.eq.1) goto 23 |
69 |
if(runerror.eq.1) goto 2222 |
70 |
|
71 |
if(DEBUG)then |
72 |
print*,' ' |
73 |
print*,' -----------------------------------',iview |
74 |
print*,' DSP number-----',DSPnumber_dat |
75 |
print*,' DAQ mode-------',DAQmode_dat |
76 |
print*,' event number ',eventn_dat |
77 |
print*,' datalength (13-bit w) ---- ',datalength_dat |
78 |
c print*,' NCLUST---',nclust_dat |
79 |
c print*,' CUTC-----',cutc_dat |
80 |
c print*,' CUTCL----',cutcl_dat |
81 |
print*,' L-1 addr---',addrcluster_dat(1) |
82 |
print*,' signal-',signcluster_dat(1) |
83 |
print*,' L-2 addr---',addrcluster_dat(2) |
84 |
print*,' signal-',signcluster_dat(2) |
85 |
print*,' L-3 addr---',addrcluster_dat(3) |
86 |
print*,' signal-',signcluster_dat(3) |
87 |
print*,' FC------',fc_dat |
88 |
print*,' compression time ',compressiontime_dat |
89 |
print*,' FL1--',fl1_dat |
90 |
print*,' FL2--',fl2_dat |
91 |
print*,' FL3--',fl3_dat |
92 |
print*,' FL4--',fl4_dat |
93 |
print*,' FL5--',fl5_dat |
94 |
print*,' FL6--',fl6_dat |
95 |
c print*,' checksum-',checksum_dat |
96 |
endif |
97 |
|
98 |
trk_DSP_ok(DSPnumber_dat)=1 |
99 |
|
100 |
call fillview(iview) |
101 |
|
102 |
2525 continue |
103 |
enddo !end loop on views |
104 |
|
105 |
2222 continue |
106 |
|
107 |
close (lun_pkt) |
108 |
return |
109 |
end |
110 |
|
111 |
* ********************************************** |
112 |
|
113 |
c subroutine trk_calib_pkt(runerror,ffd_pkt) |
114 |
subroutine trkcalibpkt(runerror,event_file_name) |
115 |
|
116 |
include '../commonyoda/commontracker.f' |
117 |
include '../commonyoda/dataformat.f' |
118 |
include '../commonyoda/trk_calib_parameters.f' |
119 |
|
120 |
integer ndummy |
121 |
data ndummy/1000/ |
122 |
|
123 |
integer runerror !readevent error flag |
124 |
integer ffd_pkt !pkt file descriptor |
125 |
!(file temporaneo) |
126 |
character*60 event_file_name !nome file |
127 |
|
128 |
logical DEBUG |
129 |
c data DEBUG/.true./ |
130 |
data DEBUG/.false./ |
131 |
ccc common/DEBUGflag/DEBUG |
132 |
|
133 |
|
134 |
integer lun_pkt |
135 |
data lun_pkt/10/ |
136 |
|
137 |
|
138 |
open(unit=lun_pkt, |
139 |
$ name=EVENT_FILE_NAME(1:lnblnk(EVENT_FILE_NAME)), |
140 |
$ status='old', |
141 |
$ form='unformatted' |
142 |
$ ) |
143 |
ffd_pkt = FNum(lun_pkt) !reads unix file descriptor |
144 |
|
145 |
|
146 |
|
147 |
do iview=1,ndummy !loop on views (DSP pkt) |
148 |
call searchtrkheader(runerror,ffd_pkt) |
149 |
c if(runerror.eq.-1) goto 24 |
150 |
if(runerror.eq.-1) goto 2222 |
151 |
if(runerror.eq.1) then |
152 |
c print*,' ' |
153 |
c print*,'readraw: END OF CPU PACKET ' |
154 |
c print*,'______________________________________ ' |
155 |
goto 2222 !end loop on views (DSP pkt) |
156 |
endif |
157 |
if(checkheader.ne.3) then |
158 |
c print*,'>>>> ERROR <<<< (trkcalibpkt)' |
159 |
c print*,'>>>> CPU packet type ',!pkt_type, |
160 |
c $ ' does not match DSP type ',checkheader |
161 |
DAQmode_temp = ishft(iand(header(1),z'03f0'),-4) |
162 |
DSPnumber_temp = iand(header(1),z'000f') |
163 |
c print*,' -----------------------------------' |
164 |
c $ ,iview |
165 |
c print*,' DSP number-----',int(DSPnumber_temp) |
166 |
c print*,' DAQ mode-------',int(DAQmode_temp) |
167 |
c print*,' -----------------------------------' |
168 |
goto 2424 !next view (==> search another DSP header) |
169 |
endif |
170 |
|
171 |
call unpackcalibration(runerror,ffd_pkt) |
172 |
c if(runerror.eq.-1) goto 24 |
173 |
if(runerror.eq.-1) goto 2222 |
174 |
c if(runerror.eq.1) goto 23 |
175 |
if(runerror.eq.1) goto 2222 |
176 |
|
177 |
if(DEBUG)then |
178 |
|
179 |
print*,'Calibration packet ==> ',iview |
180 |
|
181 |
print*,'---- Calibration packet ',iview,' ----' |
182 |
print*,' DSP number ',DSPnumber_cal |
183 |
print*,' DAQ mode ',DAQmode_cal |
184 |
print*,' calibration run ',calibrationnumber |
185 |
print*,' n. event used ',nused_event |
186 |
print*,' <PED> ladder 1 ',ped_1 |
187 |
print*,' <PED> ladder 2 ',ped_2 |
188 |
print*,' <PED> ladder 3 ',ped_3 |
189 |
print*,' <SIG> ladder 1 ',sig_1 |
190 |
print*,' <SIG> ladder 2 ',sig_2 |
191 |
print*,' <SIG> ladder 3 ',sig_3 |
192 |
print*,' n.BAD ladder 1 ',nbad_1 |
193 |
print*,' n.BAD ladder 2 ',nbad_2 |
194 |
print*,' n.BAD ladder 3 ',nbad_3 |
195 |
print*,' error flag ',ff |
196 |
if(nused_event.ne.0.or.ff.ne.0)then |
197 |
print*,'*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*' |
198 |
print*,'* !!! CALIBRATION FAILURE !!! *' |
199 |
print*,'*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*' |
200 |
endif |
201 |
endif |
202 |
|
203 |
DAQmode(iview)=DAQmode_cal |
204 |
DSPnumber(iview)=DSPnumber_cal |
205 |
calibnumber(iview)=calibrationnumber |
206 |
ncalib_event(iview)=nused_event |
207 |
ped_l1(iview)=ped_1 |
208 |
ped_l2(iview)=ped_2 |
209 |
ped_l3(iview)=ped_3 |
210 |
sig_l1(iview)=sig_1 |
211 |
sig_l2(iview)=sig_2 |
212 |
sig_l3(iview)=sig_3 |
213 |
nbad_l1(iview)=nbad_1 |
214 |
nbad_l2(iview)=nbad_2 |
215 |
nbad_l3(iview)=nbad_3 |
216 |
cal_flag(iview)=ff |
217 |
|
218 |
do is=1,nstrips_view |
219 |
DSPbad_par(iview,is)=DSPbad_o(DSPnumber_cal,is) |
220 |
DSPped_par(iview,is)=DSPped_o(DSPnumber_cal,is) |
221 |
DSPsig_par(iview,is)=DSPsig_o(DSPnumber_cal,is) |
222 |
enddo |
223 |
c |
224 |
trk_DSP_ok(DSPnumber_cal)=1 |
225 |
c---------------------------------------------------------- |
226 |
c NVIEWS calibration packets should have been found |
227 |
c---------------------------------------------------------- |
228 |
c if(n_cal_pkt.eq.nviews)then |
229 |
c found_cal_pkt = .true. |
230 |
c n_cal_pkt = 0 |
231 |
c endif |
232 |
2424 continue |
233 |
enddo ! end loop on views (calibration pkt) |
234 |
2222 continue |
235 |
|
236 |
close (lun_pkt) |
237 |
|
238 |
return |
239 |
end |
240 |
|
241 |
***...***...***...***...***...***...***...***...***...***...***...***...***...***...***...*** |
242 |
* |
243 |
* |
244 |
* |
245 |
* |
246 |
* |
247 |
* |
248 |
* |
249 |
* |
250 |
***...***...***...***...***...***...***...***...***...***...***...***...***...***...***...*** |
251 |
|
252 |
subroutine searchtrkheader(runerror,ffd) |
253 |
C............................................................. |
254 |
C Search for a valid tracker DSP header (=>one view) |
255 |
C and return the type of header |
256 |
C............................................................. |
257 |
|
258 |
include '../commonyoda/commontracker.f' |
259 |
include '../commonyoda/dataformat.f' |
260 |
|
261 |
integer ffd !input file descriptor |
262 |
integer runerror !readevent error flag |
263 |
|
264 |
c-------------------------------------------------- |
265 |
c N.B.13 bit packing is done for each DSP header+datablock, |
266 |
C so each DSP 13 bit |
267 |
c first word starts at the beginnig of a 16 bit word |
268 |
c-------------------------------------------------- |
269 |
9100 continue |
270 |
runerror=0 !error flag initialization |
271 |
checkheader=0 |
272 |
|
273 |
c-------------------------------------------------- |
274 |
c looks for a DSP header beginning |
275 |
C (a word beginning with 1110) |
276 |
c-------------------------------------------------- |
277 |
call findstart(runerror,ffd) |
278 |
|
279 |
if(runerror.eq.1) goto 200 |
280 |
if(runerror.eq.-1)then |
281 |
runerror=1 !in this case I dont want the |
282 |
!the program to crash |
283 |
goto 200 |
284 |
endif |
285 |
c-------------------------------------------------- |
286 |
c the first word could be a DSP header first word: |
287 |
C reads 13 8-bit words and |
288 |
c writes them in 16 13-bit words to check for all |
289 |
C DSP header features |
290 |
c-------------------------------------------------- |
291 |
runerror=0 |
292 |
|
293 |
call hunpacker(header,runerror,ffd) |
294 |
|
295 |
if(runerror.eq.1) goto 200 |
296 |
c if(runerror.eq.-1) goto 200 |
297 |
if(runerror.eq.-1)then |
298 |
runerror=1 !in this case I dont want the |
299 |
!the program to crash |
300 |
goto 200 |
301 |
endif |
302 |
c-------------------------------------------------- |
303 |
c extracts and controls header: |
304 |
c-------------------------------------------------- |
305 |
C last header word must be: |
306 |
c |0001|1100|0000|0000| for acquisition |
307 |
c |0001|1111|1111|1111| for calibration |
308 |
c-------------------------------------------------- |
309 |
if(iand(header(16),z'ffff').eq.z'1c00') then !last header |
310 |
checkheader=2 ! event |
311 |
elseif(iand(header(16),z'ffff').eq.z'1fff') then !last header |
312 |
checkheader=3 ! calibration packet |
313 |
else |
314 |
checkheader=1 ! not a valid DSP header |
315 |
endif |
316 |
c-------------------------------------------------- |
317 |
c first header word must be: |
318 |
c |0001|110x|xxxx|xxxx| |
319 |
c-------------------------------------------------- |
320 |
if(iand(header(1),z'fe00').ne.z'1c00') |
321 |
$ checkheader=1 !not a valid DSP header |
322 |
c-------------------------------------------------- |
323 |
c intermediate header words must be: |
324 |
c |0001|010x|xxxx|xxxx| |
325 |
c-------------------------------------------------- |
326 |
do i=2,15 |
327 |
if(iand(header(i),z'fc00').ne.z'1400') |
328 |
$ checkheader=1 !not a valid DSP header |
329 |
enddo |
330 |
c-------------------------------------------------- |
331 |
c if checkheader = 1 |
332 |
c then this is not a DSP header (or some |
333 |
c noise lurks around) so go a word ahead and |
334 |
c try again |
335 |
c-------------------------------------------------- |
336 |
if(checkheader.eq.1) then |
337 |
call skipbyte(ffd) |
338 |
goto 9100 |
339 |
endif |
340 |
200 continue |
341 |
end |
342 |
|
343 |
*............................................................. |
344 |
|
345 |
|
346 |
*............................................................. |
347 |
|
348 |
subroutine unpackcalibration(runerror,ffd) |
349 |
*............................................................. |
350 |
* decode calibration data |
351 |
* header + data(PED SIG BAD) + trailer |
352 |
*............................................................ |
353 |
include '../commonyoda/commontracker.f' |
354 |
include '../commonyoda/dataformat.f' |
355 |
|
356 |
integer ffd !input file descriptor |
357 |
integer runerror !readevent error flag |
358 |
c buffer temporanei |
359 |
integer*2 templ(nstrips_ladder) |
360 |
real*4 tempf(nstrips_ladder) |
361 |
|
362 |
|
363 |
12 format(z4) |
364 |
|
365 |
*----------------------------------------------------------- |
366 |
* HEADER |
367 |
* (N.B. during test 2003 the header of calibration packets |
368 |
* was only partially filled) |
369 |
* |
370 |
* the following is the final calibration header |
371 |
*----------------------------------------------------------- |
372 |
DAQmode_cal = ishft(iand(header(1),z'03f0'),-4) |
373 |
DSPnumber_cal = iand(header(1),z'000f') |
374 |
dataword = ior(ishft(iand(header(2),z'03ff') |
375 |
$ ,10),iand(header(3),z'03ff')) |
376 |
c calibrationnumber = ior(ishft(iand(header(4) |
377 |
c $ ,z'03ff'),10),iand(header(5),z'03ff')) |
378 |
calibrationnumber = iand(header(4),z'03ff') |
379 |
nused_event = iand(header(5),z'03ff') |
380 |
ped_1 = iand(header(6),z'03ff') |
381 |
ped_2 = iand(header(7),z'03ff') |
382 |
ped_3 = iand(header(8),z'03ff') |
383 |
ped_1 = ped_1 * 4 |
384 |
ped_2 = ped_2 * 4 |
385 |
ped_3 = ped_3 * 4 |
386 |
sig_1 = iand(header(9),z'03ff') |
387 |
sig_2 = iand(header(10),z'03ff') |
388 |
sig_3 = iand(header(11),z'03ff') |
389 |
nbad_1 = iand(header(12),z'03ff') |
390 |
nbad_2 = iand(header(13),z'03ff') |
391 |
nbad_3 = iand(header(14),z'03ff') |
392 |
ff = ishft(iand(header(15),z'0300'),-8) |
393 |
checksum_cal = iand(header(15),z'00ff') |
394 |
|
395 |
runerror=0 |
396 |
call readtrailer(trailer,runerror,ffd) |
397 |
c$$$ do i=1,3 |
398 |
c$$$ write(*,12)trailer(i) |
399 |
c$$$ enddo |
400 |
c----------------------------------------------------------- |
401 |
c the checksum is a 8-bit word calculated as the |
402 |
c XOR of the 16-bit data words, |
403 |
c hence the XOR between the two halfs |
404 |
C---------------------------------------------------------- |
405 |
do il=1,3 !loop on ladders |
406 |
|
407 |
call readped(tempf,runerror,ffd) |
408 |
do is=1,nstrips_ladder |
409 |
iss=is+nstrips_ladder*(il-1) |
410 |
DSPped_o(DSPnumber_cal,iss)=tempf(is) |
411 |
c print*,il,iss,DSPped_o(DSPnumber,iss) |
412 |
c print *,DSPnumber_cal,iss,tempf(is) |
413 |
|
414 |
enddo |
415 |
|
416 |
call readsig(tempf,runerror,ffd) |
417 |
do is=1,nstrips_ladder |
418 |
iss=is+nstrips_ladder*(il-1) |
419 |
DSPsig_o(DSPnumber_cal,iss)=tempf(is) |
420 |
c print*,DSPsig_o(DSPnumber,iss) |
421 |
enddo |
422 |
|
423 |
call readbad(templ,runerror,ffd) |
424 |
do is=1,nstrips_ladder |
425 |
iss=is+nstrips_ladder*(il-1) |
426 |
DSPbad_o(DSPnumber_cal,iss)=templ(is) |
427 |
c print*,il,is,iss,DSPbad_o(DSPnumber,iss) |
428 |
enddo |
429 |
|
430 |
C//// CAPIRE PERCHE` NON C'E` LA PAROLA DI FINE LADDER \\\\ |
431 |
c call readeol(word,runerror,ffd) |
432 |
11 format(i1,' ',z4) |
433 |
c write(*,11)il,word |
434 |
call readtrailer(trailer,runerror,ffd) |
435 |
c$$$ do i=1,3 |
436 |
c$$$ write(*,12)trailer(i) |
437 |
c$$$ enddo |
438 |
|
439 |
c print*,'fine ladder' !??? |
440 |
|
441 |
enddo !end loop on ladders |
442 |
|
443 |
return |
444 |
end |
445 |
*............................................................. |
446 |
|
447 |
|
448 |
subroutine unpackdata(runerror,ffd) |
449 |
*............................................................. |
450 |
* decode event data |
451 |
* header + data + trailer |
452 |
*............................................................ |
453 |
include '../commonyoda/commontracker.f' |
454 |
include '../commonyoda/dataformat.f' |
455 |
include '../commonyoda/level0.f' |
456 |
|
457 |
integer ffd !input file descriptor |
458 |
integer runerror !readevent error flag |
459 |
integer l_tra |
460 |
|
461 |
|
462 |
12 format(z4) |
463 |
|
464 |
*----------------------------------------------------------- |
465 |
* HEADER |
466 |
*----------------------------------------------------------- |
467 |
|
468 |
DAQmode_dat = ishft(iand(header(1),z'03f0'),-4) |
469 |
DSPnumber_dat = iand(header(1),z'000f') |
470 |
C ------------------------------------------------------ |
471 |
c words 2 and 3 give tshe number of transmitted 16-bit |
472 |
c words ( 13 header words + data ) |
473 |
c NB: data are packed from 13-bit to 16-bit words, |
474 |
c so the stream is complited with zeros in order to have |
475 |
c a number of bits multiple of 16 |
476 |
l_tra = ior(ishft(iand(header(2),z'03ff') |
477 |
$ ,10),iand(header(3),z'03ff')) |
478 |
l_tra=l_tra-13 |
479 |
C ------------------------------------------------------ |
480 |
eventn_dat = ior(ishft(iand(header(4),z'03ff') |
481 |
$ ,10),iand(header(5),z'03ff')) |
482 |
nclust_dat = ishft(iand(header(6),z'0380'),-7) |
483 |
cutc_dat = ishft(iand(header(6),z'0070'),-4) |
484 |
cutcl_dat = iand(header(6),z'000f') |
485 |
addrcluster_dat(1) = iand(header(7),z'03ff') |
486 |
signcluster_dat(1) = iand(header(8),z'03ff') |
487 |
addrcluster_dat(2) = iand(header(9),z'03ff') |
488 |
signcluster_dat(2) = iand(header(10),z'03ff') |
489 |
addrcluster_dat(3) = iand(header(11),z'03ff') |
490 |
signcluster_dat(3) = iand(header(12),z'03ff') |
491 |
fc_dat = ishft(iand(header(13),z'0300'),-8) |
492 |
compressiontime_dat = iand(header(13),z'00ff') |
493 |
fl5_dat = ishft(iand(header(14),z'0300'),-8) |
494 |
fl4_dat = ishft(iand(header(14),z'0300'),-6) |
495 |
fl3_dat = ishft(iand(header(14),z'0300'),-4) |
496 |
fl2_dat = ishft(iand(header(14),z'0300'),-2) |
497 |
fl1_dat = iand(header(14),z'0300') |
498 |
fl6_dat = ishft(iand(header(15),z'0300'),-8) |
499 |
checksum_dat = iand(header(15),z'00ff') |
500 |
c----------------------------------------------------------- |
501 |
c the cheacksum is a 8-bit word calculated as the |
502 |
c XOR of the 16-bit data words, |
503 |
c hence the XOR between the two halfs |
504 |
C---------------------------------------------------------- |
505 |
runerror=0 |
506 |
nqualcosa=0 |
507 |
if(l_tra.eq.0)then |
508 |
c call skipbyte(ffd) |
509 |
goto 18 !empty buffer |
510 |
endif |
511 |
call dunpacker(l_tra,b_tra,runerror,ffd) |
512 |
nqualcosa = (real(l_tra))/13*16 |
513 |
xx = b_tra(nqualcosa) |
514 |
if (xx.eq.0) nqualcosa=nqualcosa -1 |
515 |
|
516 |
18 datalength_dat= nqualcosa |
517 |
|
518 |
c$$$ TOTDATAlength = TOTDATAlength + datalength_dat |
519 |
c$$$ do i=1,datalength_dat |
520 |
c$$$ id = id + 1 |
521 |
c$$$ datatracker(id) = b_tra(i) |
522 |
c$$$ enddo |
523 |
|
524 |
|
525 |
|
526 |
11 format(i1,' ',z4) |
527 |
c write(*,11)il,word |
528 |
call readtrailer(trailer,runerror,ffd) |
529 |
c$$$ do i=1,3 |
530 |
c$$$ write(*,12)trailer(i) |
531 |
c$$$ enddo |
532 |
|
533 |
*************************************************************** |
534 |
* TRAILER * |
535 |
*************************************************************** |
536 |
|
537 |
pnum_dat=ishft(iand(trailer(1),z'f000'),-12) |
538 |
cmdnum_dat=ishft(iand(trailer(1),z'0f00'),-8) |
539 |
bid1_dat=ishft(iand(trailer(1),z'00c0'),-6) |
540 |
bid2_dat=ishft(iand(trailer(1),z'0030'),-4) |
541 |
bid3_dat=ishft(iand(trailer(1),z'000c'),-2) |
542 |
bid4_dat=iand(trailer(1),z'0003') |
543 |
bid5_dat=ishft(iand(trailer(2),z'c000'),-14) |
544 |
bid6_dat=ishft(iand(trailer(2),z'3000'),-12) |
545 |
bid7_dat=ishft(iand(trailer(2),z'0c00'),-10) |
546 |
alarm_dat=ishft(iand(trailer(2),z'0300'),-8) |
547 |
aswr_dat=ior(ishft(iand(trailer(2),z'00ff'),8) |
548 |
$ ,ishft(iand(trailer(3),z'ff00'),-8)) |
549 |
crc_dat=iand(trailer(3),z'00ff') |
550 |
|
551 |
bid_dat_sum = (bid1_dat + bid2_dat + bid3_dat + bid4_dat + |
552 |
& bid5_dat + bid6_dat + bid7_dat) |
553 |
|
554 |
bid_dat = bid_dat_sum/7 |
555 |
|
556 |
if (bid_dat.ne.1.and.bid_dat.ne.2) then |
557 |
write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
558 |
write (*,*) 'unpack_data: TRAILER PACKET CORRUPTED - BID ' |
559 |
$ ,bid_dat |
560 |
write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
561 |
endif |
562 |
if (mod(bid_dat_sum,7).ne.0) then |
563 |
bid_dat = 0 |
564 |
write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
565 |
write (*,*) 'unpack_data: TRAILER PACKET CORRUPTED - BID ' |
566 |
$ ,bid_dat |
567 |
write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
568 |
endif |
569 |
|
570 |
if (alarm_dat.eq.3) then |
571 |
write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
572 |
write(*,*) 'unpack_data: AQUISITION ALARM' |
573 |
write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
574 |
|
575 |
endif |
576 |
|
577 |
if (alarm_dat.ne.3.and.alarm_dat.ne.0) then |
578 |
write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
579 |
write(*,*) 'unpack_data: TRAILER PACKET CORRUPTED - ALARM ' |
580 |
$ ,alarm_dat |
581 |
write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
582 |
|
583 |
endif |
584 |
|
585 |
|
586 |
return |
587 |
end |
588 |
|
589 |
|
590 |
*............................................................................. |
591 |
subroutine initlevel0 |
592 |
|
593 |
include '../commonyoda/level0.f' |
594 |
|
595 |
|
596 |
do i=1, nviews |
597 |
|
598 |
DAQmode(i) = 0 |
599 |
DSPnumber(i) = 0 |
600 |
eventn(i) = 0 |
601 |
nclust(i) = 0 |
602 |
cutc(i) = 0 |
603 |
cutcl(i) = 0 |
604 |
addrcluster(i,1) = 0 |
605 |
signcluster(i,1) = 0 |
606 |
addrcluster(i,2) = 0 |
607 |
signcluster(i,2) = 0 |
608 |
addrcluster(i,3) = 0 |
609 |
signcluster(i,3) = 0 |
610 |
fc(i) = 0 |
611 |
compressiontime(i) = 0 |
612 |
fl5(i) = 0 |
613 |
fl4(i) = 0 |
614 |
fl3(i) = 0 |
615 |
fl2(i) = 0 |
616 |
fl1(i) = 0 |
617 |
fl6(i) = 0 |
618 |
checksum(i) = 0 |
619 |
DATAlength(i) = 0 |
620 |
pnum(i)= 0 |
621 |
cmdnum(i)= 0 |
622 |
bid(i) = 1 |
623 |
alarm(i)= 0 |
624 |
aswr(i) = 0 |
625 |
enddo |
626 |
|
627 |
TOTDATAlength = 0 |
628 |
good0=.true. |
629 |
|
630 |
return |
631 |
end |
632 |
|
633 |
|
634 |
* *** *** *** *** *** *** *** *** *** |
635 |
* |
636 |
* |
637 |
* |
638 |
* |
639 |
* |
640 |
* |
641 |
* *** *** *** *** *** *** *** *** *** |
642 |
subroutine fillview(i) |
643 |
c ----------------------------------------------------- |
644 |
c fill variables related to view i |
645 |
c which will be stored in the level0 nt-ple |
646 |
c at the end of loop on views |
647 |
c ---------------------------------------------------- |
648 |
|
649 |
include '../commonyoda/commontracker.f' |
650 |
include '../commonyoda/level0.f' |
651 |
include '../commonyoda/dataformat.f' |
652 |
|
653 |
logical DEBUG |
654 |
common/DEBUGflag/DEBUG |
655 |
|
656 |
|
657 |
DAQmode(i) = DAQmode_dat |
658 |
DSPnumber(i) = DSPnumber_dat |
659 |
eventn(i) = eventn_dat |
660 |
nclust(i) = nclust_dat |
661 |
cutc(i) = cutc_dat |
662 |
cutcl(i) = cutcl_dat |
663 |
addrcluster(i,1) = addrcluster_dat(1) |
664 |
signcluster(i,1) = signcluster_dat(1) |
665 |
addrcluster(i,2) = addrcluster_dat(2) |
666 |
signcluster(i,2) = signcluster_dat(2) |
667 |
addrcluster(i,3) = addrcluster_dat(3) |
668 |
signcluster(i,3) = signcluster_dat(3) |
669 |
fc(i) = fc_dat |
670 |
compressiontime(i) = compressiontime_dat |
671 |
fl5(i) = fl5_dat |
672 |
fl4(i) = fl4_dat |
673 |
fl3(i) = fl3_dat |
674 |
fl2(i) = fl2_dat |
675 |
fl1(i) = fl1_dat |
676 |
fl6(i) = fl6_dat |
677 |
checksum(i) = checksum_dat |
678 |
DATAlength(i) = datalength_dat |
679 |
|
680 |
c ----------------------------------------------------------------------- |
681 |
c filling TRAILER variables |
682 |
c ---------------------------------------------------------------------- |
683 |
|
684 |
pnum(i)= pnum_dat |
685 |
cmdnum(i)= cmdnum_dat |
686 |
bid(i) = bid_dat |
687 |
alarm(i)= alarm_dat |
688 |
aswr(i) = aswr_dat |
689 |
|
690 |
if(DEBUG)then |
691 |
|
692 |
print*,'*-*-*-*-*-*-TRAILER-*-*-*-*-*-*' |
693 |
print*,'* PNUM (periferal num) ',pnum_dat |
694 |
print*,'* CMDNUM (command) ',cmdnum_dat |
695 |
print*,'* BID (board id) ',bid_dat |
696 |
print*,'* ALARM ',alarm_dat |
697 |
print*,'*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*' |
698 |
|
699 |
endif |
700 |
|
701 |
do idat=1,datalength_dat |
702 |
id = TOTDATAlength + idat |
703 |
datatracker(id) = b_tra(idat) |
704 |
enddo |
705 |
TOTDATAlength = TOTDATAlength + datalength_dat |
706 |
|
707 |
c print*,'TOTDATALENGTH ',TOTDATAlength |
708 |
|
709 |
|
710 |
return |
711 |
end |
712 |
|