| 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 |
|
|
| 154 |
call searchtrkheader(runerror,buffer,length_buffer,curpos, |
call searchtrkheader(runerror,buffer,length_buffer,curpos, |
| 196 |
2424 continue |
2424 continue |
| 197 |
enddo ! end loop on views (calibration pkt) |
enddo ! end loop on views (calibration pkt) |
| 198 |
|
|
| 199 |
|
2222 continue |
| 200 |
|
|
| 201 |
if(npkt.eq.nplanes)YODAflag=0 |
if(npkt.eq.nplanes)YODAflag=0 |
| 202 |
if(YODAflag.eq.0.and.(ALARMS.eqv..false.))good0=1 |
if(YODAflag.eq.0.and.(ALARMS.eqv..false.))good0=1 |
| 203 |
|
|
|
2222 continue |
|
|
|
|
| 204 |
return |
return |
| 205 |
end |
end |
| 206 |
|
|
| 222 |
include '../common/commontracker.f' |
include '../common/commontracker.f' |
| 223 |
include '../common/common_readraw.f' |
include '../common/common_readraw.f' |
| 224 |
|
|
|
parameter (MAXBUFFLEN=z'172c8') |
|
|
integer*4 length_buffer |
|
|
integer*1 buffer(MAXBUFFLEN) |
|
|
integer curpos !current position in buffer |
|
|
integer startcrc |
|
|
|
|
| 225 |
integer runerror !readevent error flag |
integer runerror !readevent error flag |
| 226 |
|
|
| 227 |
c-------------------------------------------------- |
c-------------------------------------------------- |
| 315 |
include '../common/commontracker.f' |
include '../common/commontracker.f' |
| 316 |
include '../common/common_readraw.f' |
include '../common/common_readraw.f' |
| 317 |
|
|
|
parameter (MAXBUFFLEN=z'172c8') |
|
|
integer*4 length_buffer |
|
|
integer*1 buffer(MAXBUFFLEN) |
|
|
integer curpos !current position in buffer |
|
|
integer startcrc |
|
|
integer stopcrc |
|
| 318 |
integer*1 crctemp |
integer*1 crctemp |
| 319 |
integer*1 crc_trail |
integer*1 crc_trail |
| 320 |
|
|
| 437 |
include '../common/common_readraw.f' |
include '../common/common_readraw.f' |
| 438 |
include '../common/level0.f' |
include '../common/level0.f' |
| 439 |
|
|
|
parameter (MAXBUFFLEN=z'172c8') |
|
|
integer*4 length_buffer |
|
|
integer*1 buffer(MAXBUFFLEN) |
|
|
integer curpos !current position in buffer |
|
|
integer startcrc |
|
|
integer stopcrc |
|
| 440 |
integer*1 crctemp |
integer*1 crctemp |
| 441 |
integer*1 crcdat |
integer*1 crcdat |
| 442 |
|
|
| 443 |
integer runerror !readevent error flag |
integer runerror !readevent error flag |
| 444 |
integer l_tra |
c integer l_tra |
| 445 |
|
|
| 446 |
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 |
| 447 |
$ ,bid7_dat,bid_dat_sum |
$ ,bid7_dat,bid_dat_sum |
| 479 |
signcluster_dat(3) = iand(header(12),z'03ff') |
signcluster_dat(3) = iand(header(12),z'03ff') |
| 480 |
fc_dat = ishft(iand(header(13),z'0300'),-8) |
fc_dat = ishft(iand(header(13),z'0300'),-8) |
| 481 |
compressiontime_dat = iand(header(13),z'00ff') |
compressiontime_dat = iand(header(13),z'00ff') |
| 482 |
fl5_dat = ishft(iand(header(14),z'0300'),-8) |
c fl5_dat = ishft(iand(header(14),z'0300'),-8) |
| 483 |
fl4_dat = ishft(iand(header(14),z'0300'),-6) |
c fl4_dat = ishft(iand(header(14),z'0300'),-6) |
| 484 |
fl3_dat = ishft(iand(header(14),z'0300'),-4) |
c fl3_dat = ishft(iand(header(14),z'0300'),-4) |
| 485 |
fl2_dat = ishft(iand(header(14),z'0300'),-2) |
c fl2_dat = ishft(iand(header(14),z'0300'),-2) |
| 486 |
fl1_dat = iand(header(14),z'0300') |
c fl1_dat = iand(header(14),z'0300') |
| 487 |
fl6_dat = ishft(iand(header(15),z'0300'),-8) |
c fl6_dat = ishft(iand(header(15),z'0300'),-8) |
| 488 |
|
fl5_dat = iand(ishft(header(14),-8),z'0003') |
| 489 |
|
fl4_dat = iand(ishft(header(14),-6),z'0003') |
| 490 |
|
fl3_dat = iand(ishft(header(14),-4),z'0003') |
| 491 |
|
fl2_dat = iand(ishft(header(14),-2),z'0003') |
| 492 |
|
fl1_dat = iand(header(14),z'0003') |
| 493 |
|
fl6_dat = iand(ishft(header(15),-8),z'0003') |
| 494 |
checksum_dat = iand(header(15),z'00ff') |
checksum_dat = iand(header(15),z'00ff') |
| 495 |
|
|
| 496 |
c----------------------------------------------------------- |
c----------------------------------------------------------- |
| 500 |
C---------------------------------------------------------- |
C---------------------------------------------------------- |
| 501 |
runerror=0 |
runerror=0 |
| 502 |
nqualcosa=0 |
nqualcosa=0 |
| 503 |
if(l_tra.eq.0)then |
c if(l_tra.eq.0)then |
| 504 |
|
if(l_tra.le.0)then |
| 505 |
goto 18 !empty buffer |
goto 18 !empty buffer |
| 506 |
endif |
endif |
| 507 |
|
|
| 508 |
|
if(l_tra.gt.MAXBUFFLEN .or.(curpos+l_tra-1).ge.MAXBUFFLEN )then |
| 509 |
|
c print*,'unpackdata: ' |
| 510 |
|
c $ ,'tracker buffer length l_tra ',l_tra |
| 511 |
|
c $ ,' exceeds tracker buffer dimensions ' |
| 512 |
|
c print*,'(packet corrupted)' |
| 513 |
|
cc runerror=1 |
| 514 |
|
runerror=2 |
| 515 |
|
goto 50 |
| 516 |
|
endif |
| 517 |
call dunpacker(l_tra,b_tra,runerror,buffer,length_buffer,curpos) |
call dunpacker(l_tra,b_tra,runerror,buffer,length_buffer,curpos) |
| 518 |
if(runerror.eq.1.or.runerror.eq.-1) then |
if(runerror.eq.1.or.runerror.eq.-1) then |
| 519 |
goto 50 !go to end |
goto 50 !go to end |
| 520 |
endif |
endif |
| 521 |
|
|