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