| 5 |
c include '../commonyoda/trk_calib_parameters.f' |
c include '../commonyoda/trk_calib_parameters.f' |
| 6 |
include '../commonyoda/level0.f' |
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 |
integer ndummy |
| 15 |
data ndummy/1000/ |
data ndummy/1000/ |
| 16 |
integer lun_pkt |
|
|
parameter (lun_pkt=10) |
|
| 17 |
integer runerror !readevent error flag |
integer runerror !readevent error flag |
| 18 |
integer ffd_pkt !pkt file descriptor |
integer ffd_pkt !pkt file descriptor |
| 19 |
!(file temporaneo) |
!(file temporaneo) |
| 20 |
character*60 event_file_name !nome file |
character*60 event_file_name !nome file |
| 21 |
c print*,' lun_pkt-----',int(lun_pkt); |
|
| 22 |
|
integer lun_pkt |
| 23 |
|
data lun_pkt/10/ |
| 24 |
|
|
| 25 |
|
|
| 26 |
open(unit=lun_pkt, |
open(unit=lun_pkt, |
| 27 |
$ name=EVENT_FILE_NAME(1:lnblnk(EVENT_FILE_NAME)), |
$ name=EVENT_FILE_NAME(1:lnblnk(EVENT_FILE_NAME)), |
| 28 |
$ status='old', |
$ status='old', |
| 39 |
c if(runerror.eq.-1) goto 24 |
c if(runerror.eq.-1) goto 24 |
| 40 |
if(runerror.eq.-1) goto 2222 |
if(runerror.eq.-1) goto 2222 |
| 41 |
if(runerror.eq.1) then |
if(runerror.eq.1) then |
| 42 |
print*,' ' |
c print*,' ' |
| 43 |
print*,'readraw: END OF CPU PACKET ' |
c print*,'readraw: END OF CPU PACKET ' |
| 44 |
print*,'______________________________________ ' |
c print*,'______________________________________ ' |
| 45 |
c goto 9900 !end loop on files |
c goto 9900 !end loop on files |
| 46 |
c goto 8800 !end loop on views (DSP pkt) |
c goto 8800 !end loop on views (DSP pkt) |
| 47 |
goto 2222 |
goto 2222 |
| 48 |
endif |
endif |
| 49 |
|
|
| 50 |
if(checkheader.ne.2) then |
if(checkheader.ne.2) then |
| 51 |
print*,'>>>> ERROR <<<< (trkeventpkt)' |
c print*,'>>>> ERROR <<<< (trkeventpkt)' |
| 52 |
print*,'>>>> CPU packet type ',!pkt_type, |
c print*,'>>>> CPU packet type ',!pkt_type, |
| 53 |
$ ' does not match DSP type ',checkheader |
c $ ' does not match DSP type ',checkheader |
| 54 |
c goto 9909 ! next event (==> search another CPU header) |
c goto 9909 ! next event (==> search another CPU header) |
| 55 |
DAQmode_temp = ishft(iand(header(1),z'03f0'),-4) |
DAQmode_temp = ishft(iand(header(1),z'03f0'),-4) |
| 56 |
DSPnumber_temp = iand(header(1),z'000f') |
DSPnumber_temp = iand(header(1),z'000f') |
| 57 |
print*,' -----------------------------------' |
c print*,' -----------------------------------' |
| 58 |
$ ,iview |
c $ ,iview |
| 59 |
print*,' DSP number-----',int(DSPnumber_temp) |
c print*,' DSP number-----',int(DSPnumber_temp) |
| 60 |
print*,' DAQ mode-------',int(DAQmode_temp) |
c print*,' DAQ mode-------',int(DAQmode_temp) |
| 61 |
print*,' -----------------------------------' |
c print*,' -----------------------------------' |
| 62 |
goto 2525 !next view (==> search another DSP header) |
goto 2525 !next view (==> search another DSP header) |
| 63 |
endif |
endif |
| 64 |
|
|
| 67 |
if(runerror.eq.-1) goto 2222 |
if(runerror.eq.-1) goto 2222 |
| 68 |
c if(runerror.eq.1) goto 23 |
c if(runerror.eq.1) goto 23 |
| 69 |
if(runerror.eq.1) goto 2222 |
if(runerror.eq.1) goto 2222 |
| 70 |
|
|
| 71 |
print*,' ' |
if(DEBUG)then |
| 72 |
print*,' -----------------------------------',iview |
print*,' ' |
| 73 |
print*,' DSP number-----',DSPnumber_dat |
print*,' -----------------------------------',iview |
| 74 |
print*,' DAQ mode-------',DAQmode_dat |
print*,' DSP number-----',DSPnumber_dat |
| 75 |
print*,' event number ',eventn_dat |
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 |
trk_DSP_ok(DSPnumber_dat)=1 |
| 99 |
|
|
| 100 |
call fillview(iview) |
call fillview(iview) |
| 125 |
!(file temporaneo) |
!(file temporaneo) |
| 126 |
character*60 event_file_name !nome file |
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, |
open(unit=lun_pkt, |
| 139 |
$ name=EVENT_FILE_NAME(1:lnblnk(EVENT_FILE_NAME)), |
$ name=EVENT_FILE_NAME(1:lnblnk(EVENT_FILE_NAME)), |
| 140 |
$ status='old', |
$ status='old', |
| 141 |
$ form='unformatted' |
$ form='unformatted' |
| 142 |
$ ) |
$ ) |
| 143 |
ffd_pkt = FNum(lun_pkt) !reads unix file descriptor |
ffd_pkt = FNum(lun_pkt) !reads unix file descriptor |
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
do iview=1,ndummy !loop on views (DSP pkt) |
do iview=1,ndummy !loop on views (DSP pkt) |
| 149 |
c if(runerror.eq.-1) goto 24 |
c if(runerror.eq.-1) goto 24 |
| 150 |
if(runerror.eq.-1) goto 2222 |
if(runerror.eq.-1) goto 2222 |
| 151 |
if(runerror.eq.1) then |
if(runerror.eq.1) then |
| 152 |
print*,' ' |
c print*,' ' |
| 153 |
print*,'readraw: END OF CPU PACKET ' |
c print*,'readraw: END OF CPU PACKET ' |
| 154 |
print*,'______________________________________ ' |
c print*,'______________________________________ ' |
| 155 |
goto 2222 !end loop on views (DSP pkt) |
goto 2222 !end loop on views (DSP pkt) |
| 156 |
endif |
endif |
| 157 |
if(checkheader.ne.3) then |
if(checkheader.ne.3) then |
| 158 |
print*,'>>>> ERROR <<<< (trkcalibpkt)' |
c print*,'>>>> ERROR <<<< (trkcalibpkt)' |
| 159 |
print*,'>>>> CPU packet type ',!pkt_type, |
c print*,'>>>> CPU packet type ',!pkt_type, |
| 160 |
$ ' does not match DSP type ',checkheader |
c $ ' does not match DSP type ',checkheader |
| 161 |
DAQmode_temp = ishft(iand(header(1),z'03f0'),-4) |
DAQmode_temp = ishft(iand(header(1),z'03f0'),-4) |
| 162 |
DSPnumber_temp = iand(header(1),z'000f') |
DSPnumber_temp = iand(header(1),z'000f') |
| 163 |
print*,' -----------------------------------' |
c print*,' -----------------------------------' |
| 164 |
$ ,iview |
c $ ,iview |
| 165 |
print*,' DSP number-----',int(DSPnumber_temp) |
c print*,' DSP number-----',int(DSPnumber_temp) |
| 166 |
print*,' DAQ mode-------',int(DAQmode_temp) |
c print*,' DAQ mode-------',int(DAQmode_temp) |
| 167 |
print*,' -----------------------------------' |
c print*,' -----------------------------------' |
| 168 |
goto 2424 !next view (==> search another DSP header) |
goto 2424 !next view (==> search another DSP header) |
| 169 |
endif |
endif |
| 170 |
|
|
| 174 |
c if(runerror.eq.1) goto 23 |
c if(runerror.eq.1) goto 23 |
| 175 |
if(runerror.eq.1) goto 2222 |
if(runerror.eq.1) goto 2222 |
| 176 |
|
|
| 177 |
|
if(DEBUG)then |
|
print*,'Calibration packet ==> ',iview |
|
|
|
|
|
print*,'---- Calibration packet ',iview,' ----' |
|
|
print*,' DSP number ',DSPnumber_cal |
|
|
print*,' DAQ mode ',DAQmode_cal |
|
|
print*,' calibration run ',calibrationnumber |
|
|
print*,' n. event used ',nused_event |
|
|
print*,' <PED> ladder 1 ',ped_1 |
|
|
print*,' <PED> ladder 2 ',ped_2 |
|
|
print*,' <PED> ladder 3 ',ped_3 |
|
|
print*,' <SIG> ladder 1 ',sig_1 |
|
|
print*,' <SIG> ladder 2 ',sig_2 |
|
|
print*,' <SIG> ladder 3 ',sig_3 |
|
|
print*,' n.BAD ladder 1 ',nbad_1 |
|
|
print*,' n.BAD ladder 2 ',nbad_2 |
|
|
print*,' n.BAD ladder 3 ',nbad_3 |
|
|
print*,' error flag ',ff |
|
|
if(nused_event.ne.0.or.ff.ne.0)then |
|
|
print*,'*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*' |
|
|
print*,'* !!! CALIBRATION FAILURE !!! *' |
|
|
print*,'*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*.*' |
|
|
endif |
|
| 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 |
DAQmode(iview)=DAQmode_cal |
| 204 |
DSPnumber(iview)=DSPnumber_cal |
DSPnumber(iview)=DSPnumber_cal |
| 503 |
c hence the XOR between the two halfs |
c hence the XOR between the two halfs |
| 504 |
C---------------------------------------------------------- |
C---------------------------------------------------------- |
| 505 |
runerror=0 |
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) |
call dunpacker(l_tra,b_tra,runerror,ffd) |
| 512 |
nqualcosa = (real(l_tra))/13*16 |
nqualcosa = (real(l_tra))/13*16 |
| 513 |
xx = b_tra(nqualcosa) |
xx = b_tra(nqualcosa) |
| 514 |
if (xx.eq.0) nqualcosa=nqualcosa -1 |
if (xx.eq.0) nqualcosa=nqualcosa -1 |
| 515 |
datalength_dat= nqualcosa |
|
| 516 |
|
18 datalength_dat= nqualcosa |
| 517 |
|
|
| 518 |
c$$$ TOTDATAlength = TOTDATAlength + datalength_dat |
c$$$ TOTDATAlength = TOTDATAlength + datalength_dat |
| 519 |
c$$$ do i=1,datalength_dat |
c$$$ do i=1,datalength_dat |
| 520 |
c$$$ id = id + 1 |
c$$$ id = id + 1 |
| 554 |
bid_dat = bid_dat_sum/7 |
bid_dat = bid_dat_sum/7 |
| 555 |
|
|
| 556 |
if (bid_dat.ne.1.and.bid_dat.ne.2) then |
if (bid_dat.ne.1.and.bid_dat.ne.2) then |
| 557 |
write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
c write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
| 558 |
write (*,*) 'unpack_data: TRAILER PACKET CORRUPTED' |
c write (*,*) 'unpack_data: TRAILER PACKET CORRUPTED - BID ' |
| 559 |
write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
c $ ,bid_dat |
| 560 |
|
c write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
| 561 |
endif |
endif |
| 562 |
if (mod(bid_dat_sum,7).ne.0) then |
if (mod(bid_dat_sum,7).ne.0) then |
| 563 |
bid_dat = 0 |
bid_dat = 0 |
| 564 |
write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
c write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
| 565 |
write (*,*) 'unpack_data: TRAILER PACKET CORRUPTED' |
c write (*,*) 'unpack_data: TRAILER PACKET CORRUPTED - BID ' |
| 566 |
write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
c $ ,bid_dat |
| 567 |
|
c write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
| 568 |
endif |
endif |
| 569 |
|
|
| 570 |
if (alarm_dat.eq.3) then |
if (alarm_dat.eq.3) then |
| 571 |
write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
c write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
| 572 |
write(*,*) 'unpack_data: AQUISITION ALARM' |
c write(*,*) 'unpack_data: AQUISITION ALARM' |
| 573 |
write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
c write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
| 574 |
|
|
| 575 |
endif |
endif |
| 576 |
|
|
| 577 |
if (alarm_dat.ne.3.and.alarm_dat.ne.0) then |
if (alarm_dat.ne.3.and.alarm_dat.ne.0) then |
| 578 |
write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
c write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
| 579 |
write(*,*) 'unpack_data: TRAILER PACKET CORRUPTED' |
c write(*,*) 'unpack_data: TRAILER PACKET CORRUPTED - ALARM ' |
| 580 |
write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
c $ ,alarm_dat |
| 581 |
|
c write(*,*) '*** *** *** *** *** *** *** *** *** ***' |
| 582 |
|
|
| 583 |
endif |
endif |
| 584 |
|
|
| 650 |
include '../commonyoda/level0.f' |
include '../commonyoda/level0.f' |
| 651 |
include '../commonyoda/dataformat.f' |
include '../commonyoda/dataformat.f' |
| 652 |
|
|
| 653 |
|
logical DEBUG |
| 654 |
|
common/DEBUGflag/DEBUG |
| 655 |
|
|
| 656 |
|
|
| 657 |
DAQmode(i) = DAQmode_dat |
DAQmode(i) = DAQmode_dat |
| 658 |
DSPnumber(i) = DSPnumber_dat |
DSPnumber(i) = DSPnumber_dat |
| 659 |
eventn(i) = eventn_dat |
eventn(i) = eventn_dat |
| 687 |
alarm(i)= alarm_dat |
alarm(i)= alarm_dat |
| 688 |
aswr(i) = aswr_dat |
aswr(i) = aswr_dat |
| 689 |
|
|
| 690 |
print*,'*-*-*-*-*-*-TRAILER-*-*-*-*-*-*' |
if(DEBUG)then |
| 691 |
print*,'* PNUM (periferal num) ',pnum_dat |
|
| 692 |
print*,'* CMDNUM (command) ',cmdnum_dat |
print*,'*-*-*-*-*-*-TRAILER-*-*-*-*-*-*' |
| 693 |
print*,'* BID (board id) ',bid_dat |
print*,'* PNUM (periferal num) ',pnum_dat |
| 694 |
print*,'* ALARM ',alarm_dat |
print*,'* CMDNUM (command) ',cmdnum_dat |
| 695 |
print*,'*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*' |
print*,'* BID (board id) ',bid_dat |
| 696 |
|
print*,'* ALARM ',alarm_dat |
| 697 |
|
print*,'*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*' |
| 698 |
|
|
| 699 |
|
endif |
| 700 |
|
|
| 701 |
do idat=1,datalength_dat |
do idat=1,datalength_dat |
| 702 |
id = TOTDATAlength + idat |
id = TOTDATAlength + idat |
| 704 |
enddo |
enddo |
| 705 |
TOTDATAlength = TOTDATAlength + datalength_dat |
TOTDATAlength = TOTDATAlength + datalength_dat |
| 706 |
|
|
| 707 |
|
c print*,'TOTDATALENGTH ',TOTDATAlength |
| 708 |
|
|
| 709 |
|
|
| 710 |
return |
return |
| 711 |
end |
end |
| 712 |
|
|