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