3 |
* 10/9/2005 modified by david fedele to read buffer-data |
* 10/9/2005 modified by david fedele to read buffer-data |
4 |
* instead raw-data-file |
* instead raw-data-file |
5 |
* 29/11/2005 modified by david fedele to include crc control |
* 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 |
subroutine trkeventpkt(YODAflag,buffer,length_buffer,curpos) |
|
$ ) |
|
11 |
|
|
12 |
include '../common/commontracker.f' |
include '../common/commontracker.f' |
13 |
include '../common/common_readraw.f' |
include '../common/common_readraw.f' |
14 |
include '../common/level0.f' |
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 |
* the general flag YODAflag contains information |
24 |
* about the integrity of the DSP packets. |
* about the integrity of the DSP packets. |
26 |
* If some packets are missing or the crc check fails, |
* If some packets are missing or the crc check fails, |
27 |
* YODAflag is asserted |
* YODAflag is asserted |
28 |
* --------------------------------------------------- |
* --------------------------------------------------- |
|
|
|
|
integer YODAflag |
|
|
|
|
|
|
|
|
logical ALARMS |
|
|
|
|
|
|
|
|
integer runerror !readevent error flag |
|
|
|
|
|
parameter (MAXBUFFLEN=z'172c8') |
|
|
integer*4 length_buffer |
|
|
integer*1 buffer(MAXBUFFLEN) |
|
|
integer curpos !current position in buffer |
|
|
integer startcrc |
|
|
integer stopcrc |
|
|
integer*1 crctemp |
|
|
|
|
|
* ------------------- |
|
|
* initializations |
|
29 |
YODAflag=1 !bad by default |
YODAflag=1 !bad by default |
30 |
call initlevel0 |
call initlevel0 |
31 |
ALARMS=.false. |
ALARMS=.false. |
35 |
crctemp=0 |
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 |
do iview=1,nviews !loop on DSPs |
48 |
call searchtrkheader(runerror,buffer,length_buffer,curpos, |
call searchtrkheader(runerror,buffer,length_buffer,curpos, |
49 |
$ startcrc) |
$ startcrc) |
71 |
call unpackdata(runerror,buffer,length_buffer,curpos, |
call unpackdata(runerror,buffer,length_buffer,curpos, |
72 |
$ startcrc,stopcrc,crctemp) |
$ startcrc,stopcrc,crctemp) |
73 |
if(runerror.eq.-1.or.runerror.eq.1)then |
if(runerror.eq.-1.or.runerror.eq.1)then |
74 |
goto 2222 !go to end |
goto 2222 !go to end |
75 |
|
else if(runerror.eq.2) then |
76 |
|
crc_dat=2 !flag for corrupted packet |
77 |
endif |
endif |
78 |
|
|
79 |
npkt = npkt + 1 |
npkt = npkt + 1 |
80 |
call fillview(iview) |
call fillview(iview) |
81 |
*-------- CRC check |
*--------CRC check |
82 |
if(crc(iview).eq.0) then !OK |
if(crc(iview).eq.0.or.crc(iview).eq.2) then !OK |
83 |
*----------- ALARMS |
*----------- ALARMS |
84 |
if( |
if( |
85 |
$ fl1(iview).ne.0.or. |
$ fl1(iview).ne.0.or. |
86 |
$ fl2(iview).ne.0.or. |
$ fl2(iview).ne.0.or. |
87 |
$ fl3(iview).ne.0.or. |
$ fl3(iview).ne.0.or. |
88 |
$ fl4(iview).ne.0.or. |
$ fl4(iview).ne.0.or. |
89 |
$ fl5(iview).ne.0.or. |
$ fl5(iview).ne.0.or. |
90 |
$ fl6(iview).ne.0.or. |
$ fl6(iview).ne.0.or. |
91 |
$ fc(iview).ne.0.or. |
$ fc(iview).ne.0.or. |
92 |
$ DATAlength(iview).eq.0.or. |
$ DATAlength(iview).eq.0.or. |
93 |
$ .false.)ALARMS=.true. |
$ .false.)ALARMS=.true. |
94 |
endif |
endif |
95 |
|
|
96 |
2525 continue |
2525 continue |
97 |
enddo !end loop on views |
enddo !end loop on views |
98 |
|
|
118 |
include '../common/commontracker.f' |
include '../common/commontracker.f' |
119 |
include '../common/common_readraw.f' |
include '../common/common_readraw.f' |
120 |
include '../common/trk_calib_parameters.f' |
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 |
* the general flag YODAflag contains information |
130 |
* about the integrity of the DSP packets. |
* about the integrity of the DSP packets. |
132 |
* If some packets are missing or the crc check fails, |
* If some packets are missing or the crc check fails, |
133 |
* YODAflag is asserted |
* YODAflag is asserted |
134 |
* --------------------------------------------------- |
* --------------------------------------------------- |
|
|
|
|
integer YODAflag |
|
|
|
|
|
logical ALARMs |
|
|
|
|
|
integer runerror !readevent error flag |
|
|
parameter (MAXBUFFLEN=z'172c8') |
|
|
integer*4 length_buffer |
|
|
integer*1 buffer(MAXBUFFLEN) |
|
|
integer curpos !current position in buffer |
|
|
integer startcrc |
|
|
integer stopcrc |
|
|
integer*1 crctemp |
|
|
|
|
|
* ------------------- |
|
|
* initializations |
|
135 |
YODAflag = 1 !bad by default |
YODAflag = 1 !bad by default |
136 |
call initcalib |
call initcalib |
137 |
ALARMS=.false. |
ALARMS=.false. |
141 |
crctemp=0 |
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) |
do iview=1,nplanes !loop on views (DSP pkt) |
|
|
|
153 |
call searchtrkheader(runerror,buffer,length_buffer,curpos, |
call searchtrkheader(runerror,buffer,length_buffer,curpos, |
154 |
$ startcrc) |
$ startcrc) |
155 |
|
|
195 |
2424 continue |
2424 continue |
196 |
enddo ! end loop on views (calibration pkt) |
enddo ! end loop on views (calibration pkt) |
197 |
|
|
198 |
|
2222 continue |
199 |
|
|
200 |
if(npkt.eq.nplanes)YODAflag=0 |
if(npkt.eq.nplanes)YODAflag=0 |
201 |
if(YODAflag.eq.0.and.(ALARMS.eqv..false.))good0=1 |
if(YODAflag.eq.0.and.(ALARMS.eqv..false.))good0=1 |
202 |
|
|
|
2222 continue |
|
|
|
|
203 |
return |
return |
204 |
end |
end |
205 |
|
|
221 |
include '../common/commontracker.f' |
include '../common/commontracker.f' |
222 |
include '../common/common_readraw.f' |
include '../common/common_readraw.f' |
223 |
|
|
|
parameter (MAXBUFFLEN=z'172c8') |
|
|
integer*4 length_buffer |
|
|
integer*1 buffer(MAXBUFFLEN) |
|
|
integer curpos !current position in buffer |
|
|
integer startcrc |
|
|
|
|
224 |
integer runerror !readevent error flag |
integer runerror !readevent error flag |
225 |
|
|
226 |
c-------------------------------------------------- |
c-------------------------------------------------- |
314 |
include '../common/commontracker.f' |
include '../common/commontracker.f' |
315 |
include '../common/common_readraw.f' |
include '../common/common_readraw.f' |
316 |
|
|
|
parameter (MAXBUFFLEN=z'172c8') |
|
|
integer*4 length_buffer |
|
|
integer*1 buffer(MAXBUFFLEN) |
|
|
integer curpos !current position in buffer |
|
|
integer startcrc |
|
|
integer stopcrc |
|
317 |
integer*1 crctemp |
integer*1 crctemp |
318 |
integer*1 crc_trail |
integer*1 crc_trail |
319 |
|
|
436 |
include '../common/common_readraw.f' |
include '../common/common_readraw.f' |
437 |
include '../common/level0.f' |
include '../common/level0.f' |
438 |
|
|
|
parameter (MAXBUFFLEN=z'172c8') |
|
|
integer*4 length_buffer |
|
|
integer*1 buffer(MAXBUFFLEN) |
|
|
integer curpos !current position in buffer |
|
|
integer startcrc |
|
|
integer stopcrc |
|
439 |
integer*1 crctemp |
integer*1 crctemp |
440 |
integer*1 crcdat |
integer*1 crcdat |
441 |
|
|
442 |
integer runerror !readevent error flag |
integer runerror !readevent error flag |
443 |
integer l_tra |
c integer l_tra |
444 |
|
|
445 |
integer bid1_dat,bid2_dat,bid3_dat,bid4_dat,bid5_dat,bid6_dat |
integer bid1_dat,bid2_dat,bid3_dat,bid4_dat,bid5_dat,bid6_dat |
446 |
$ ,bid7_dat,bid_dat_sum |
$ ,bid7_dat,bid_dat_sum |
499 |
C---------------------------------------------------------- |
C---------------------------------------------------------- |
500 |
runerror=0 |
runerror=0 |
501 |
nqualcosa=0 |
nqualcosa=0 |
502 |
if(l_tra.eq.0)then |
c if(l_tra.eq.0)then |
503 |
|
if(l_tra.le.0)then |
504 |
goto 18 !empty buffer |
goto 18 !empty buffer |
505 |
endif |
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) |
call dunpacker(l_tra,b_tra,runerror,buffer,length_buffer,curpos) |
517 |
if(runerror.eq.1.or.runerror.eq.-1) then |
if(runerror.eq.1.or.runerror.eq.-1) then |
518 |
goto 50 !go to end |
goto 50 !go to end |
519 |
endif |
endif |
520 |
|
|