From edeb538a768c24aa9e49c1cb6f12fcda7672dcd7 Mon Sep 17 00:00:00 2001 From: jml985 <44065529+jml985@users.noreply.github.com> Date: Wed, 10 Apr 2024 13:00:41 -0400 Subject: [PATCH] reader updates (#674) Co-authored-by: Dmitri Smirnov --- StRoot/RTS/src/DAQ_FCS/fcs_data_c.cxx | 2 + StRoot/RTS/src/DAQ_FCS/fcs_data_c.h | 2 + StRoot/RTS/src/DAQ_ITPC/daq_itpc.cxx | 9 +- StRoot/RTS/src/DAQ_ITPC/daq_itpc.h | 1 + StRoot/RTS/src/DAQ_ITPC/itpcFCF.cxx | 12 +- StRoot/RTS/src/DAQ_STGC/stgc_data_c.cxx | 14 ++ StRoot/RTS/src/DAQ_TPC23/itpc23.cxx | 181 ++++++++++++++++------- StRoot/RTS/src/DAQ_TPC23/tpc23_base.cxx | 3 +- StRoot/RTS/src/DAQ_TPC23/tpc23_base.h | 5 +- StRoot/RTS/src/DAQ_TPC23/tpx23.cxx | 126 +++++++++++++--- StRoot/RTS/src/DAQ_TPX/Makefile | 2 + StRoot/RTS/src/DAQ_TPX/daq_tpx.cxx | 4 + StRoot/RTS/src/DAQ_TPX/daq_tpx.h | 4 + StRoot/RTS/src/RTS_EXAMPLE/rts_example.C | 8 +- 14 files changed, 284 insertions(+), 89 deletions(-) diff --git a/StRoot/RTS/src/DAQ_FCS/fcs_data_c.cxx b/StRoot/RTS/src/DAQ_FCS/fcs_data_c.cxx index 6ce48b1ee93..3b4f6b45365 100644 --- a/StRoot/RTS/src/DAQ_FCS/fcs_data_c.cxx +++ b/StRoot/RTS/src/DAQ_FCS/fcs_data_c.cxx @@ -39,6 +39,7 @@ u_int fcs_data_c::run_type ; // for ZS float fcs_data_c::n_sigma ; +float fcs_data_c::n_sigma_hcal ; float fcs_data_c::n_sigma_epd ; short fcs_data_c::n_pre ; short fcs_data_c::n_post ; @@ -267,6 +268,7 @@ int fcs_data_c::zs_start(u_short *buff) float sigma ; if(hdr_det==2) sigma = n_sigma_epd ; + else if(hdr_det==1) sigma = n_sigma_hcal ; else sigma = n_sigma ; // trigger channels are special so figure this out diff --git a/StRoot/RTS/src/DAQ_FCS/fcs_data_c.h b/StRoot/RTS/src/DAQ_FCS/fcs_data_c.h index a48833c8fc1..5c80194279b 100644 --- a/StRoot/RTS/src/DAQ_FCS/fcs_data_c.h +++ b/StRoot/RTS/src/DAQ_FCS/fcs_data_c.h @@ -36,6 +36,7 @@ class fcs_data_c { run_number = 0 ; n_sigma = 4.0 ; + n_sigma_hcal = 4.0 ; n_sigma_epd = 4.0 ; n_pre = 8 ; n_post = 8 ; @@ -235,6 +236,7 @@ class fcs_data_c { // for ZS static float n_sigma ; static float n_sigma_epd ; + static float n_sigma_hcal ; static short n_pre ; static short n_post ; static short n_cou ; diff --git a/StRoot/RTS/src/DAQ_ITPC/daq_itpc.cxx b/StRoot/RTS/src/DAQ_ITPC/daq_itpc.cxx index 53ac60448bb..54633601947 100644 --- a/StRoot/RTS/src/DAQ_ITPC/daq_itpc.cxx +++ b/StRoot/RTS/src/DAQ_ITPC/daq_itpc.cxx @@ -76,10 +76,8 @@ daq_itpc::daq_itpc(daqReader *rts_caller) it23 = 0 ; // assume we won't use it online = 0 ; + mode = 0 ; -// it23 = new itpc23 ; -// it23->no_cld = 1 ; -// it23->log_level = 2 ; memset(fcf,0,sizeof(fcf)) ; fcf_det_type = 1 ; // ITPC @@ -535,6 +533,7 @@ daq_dta *daq_itpc::handle_sampa(int sec, int rdo, int in_adc) it23->run_type = 3 ; // NO CLUSTER FINDER PLEASE it23->no_cld = 1 ; it23->log_level = 0 ; + it23->mode = mode ; } it23->data_c = &sampa_c ; @@ -559,6 +558,10 @@ daq_dta *daq_itpc::handle_sampa(int sec, int rdo, int in_adc) //LOG(WARN,"S%02d:%d: rdo_fmt %d -- scan will fail",s,r,rdo_fmt) ; it23->set_rdo(s,r) ; ret = it23->rdo_scan((char *)dta,words) ; + + if((it23->err || ret) && mode) { + LOG(ERR,"S%02d:%d: rdo_scan 0x%X, err 0x%X, words %d",s,r,ret,it23->err,words) ; + } } else { ret = it->rdo_scan_top(dta,words) ; diff --git a/StRoot/RTS/src/DAQ_ITPC/daq_itpc.h b/StRoot/RTS/src/DAQ_ITPC/daq_itpc.h index 5175a3a1907..7e79d096337 100644 --- a/StRoot/RTS/src/DAQ_ITPC/daq_itpc.h +++ b/StRoot/RTS/src/DAQ_ITPC/daq_itpc.h @@ -74,6 +74,7 @@ class daq_itpc : public daq_det { static int no_sw16 ; int online ; + int mode ; int rdo_fmt ; } ; diff --git a/StRoot/RTS/src/DAQ_ITPC/itpcFCF.cxx b/StRoot/RTS/src/DAQ_ITPC/itpcFCF.cxx index 3816e7e305f..8dde24ef71f 100644 --- a/StRoot/RTS/src/DAQ_ITPC/itpcFCF.cxx +++ b/StRoot/RTS/src/DAQ_ITPC/itpcFCF.cxx @@ -1250,7 +1250,7 @@ int itpc_fcf_c::do_blobs_stage2(int row) int b_ix = blob_ix[ix] ; - LOG(TERR," using bix %d %d",ix,b_ix) ; + //LOG(TERR," using bix %d %d",ix,b_ix) ; if(b_ix != ix) { LOG(WARN,"Can't be: %d %d, RP %d:%d",b_ix,ix,row,p) ; } @@ -1347,7 +1347,7 @@ int itpc_fcf_c::do_blobs_stage2(int row) -#if 1 +#if 0 LOG(TERR,"Blobs OK %d/%d in row %d",blob_ok,blob_cou,row) ; for(int i=0;i>29 ; +#if 0 + if(rdo1==2) { + switch(feb_id) { + case 1 : + case 3 : + case 5 : + LOG(WARN,"%d: FEB %d\n",rdo1,feb_id) ; + break ; + } + } +#endif + datum_ix++ ; @@ -732,6 +744,8 @@ int stgc_data_c::event() } else { +// printf("%d: ROD %d, FEB %d\n",rdo1,rod_id,feb_id) ; + vmm.feb_vmm = ((feb_id-1)<<2)|(vmm_id-4) ; vmm.ch = channel ; vmm.adc = pdo ; diff --git a/StRoot/RTS/src/DAQ_TPC23/itpc23.cxx b/StRoot/RTS/src/DAQ_TPC23/itpc23.cxx index 66ebfc5e071..11920eac5ee 100644 --- a/StRoot/RTS/src/DAQ_TPC23/itpc23.cxx +++ b/StRoot/RTS/src/DAQ_TPC23/itpc23.cxx @@ -94,7 +94,9 @@ int itpc23::from22to23(char *c_dta, int words) if((data[0]&0xFFFF000F) != 0x98000004) { run_errors++ ; - if(run_errors<5 && online) LOG(ERR,"start 0 0x98 = 0x%08X",data[0]) ; + if(mode || (online && run_errors<10)) { + LOG(ERR,"start 0 0x98 = 0x%08X",data[0]) ; + } err |= 0x10000000 ; } @@ -141,7 +143,7 @@ int itpc23::from22to23(char *c_dta, int words) if(!found) { run_errors++ ; err |= 0x20000000 ; - if(run_errors<5) LOG(ERR,"%d: can't find data_end!",rdo1) ; + if(mode || (online && run_errors<10)) LOG(ERR,"%d: can't find data_end!",rdo1) ; } #endif @@ -162,7 +164,9 @@ int itpc23::from22to23(char *c_dta, int words) if(!found) { run_errors++ ; err |= 0x20000000 ; - if(run_errors<5) LOG(ERR,"%d: data_end 0x98 not found = 0x%08X",rdo1,data_end[0]) ; + if(mode || (online && (run_errors<10))) { + LOG(ERR,"%d: data_end 0x98 not found = 0x%08X",rdo1,data_end[0]) ; + } } n_words = data_end - data ; @@ -198,7 +202,7 @@ int itpc23::from22to23(char *c_dta, int words) if(l_fee_mask != fee_mask) { err |= 0x40000000 ; run_errors++ ; - if(run_errors<5) LOG(ERR,"%d: FEE mask 0x%X, expect 0x%X, words %d/%d",rdo1,l_fee_mask,fee_mask,words,n_words) ; + if(online && run_errors<10) LOG(ERR,"%d: FEE mask 0x%X, expect 0x%X, words %d/%d",rdo1,l_fee_mask,fee_mask,words,n_words) ; free(d_use) ; return 0 ; } @@ -254,7 +258,7 @@ int itpc23::from22to23(char *c_dta, int words) if(ix>(n_words)) { run_errors++ ; err |= 0x80000000 ; - if(run_errors<5) LOG(ERR,"%d: words %d, ix %d",rdo1,n_words,ix) ; + if(mode || (online && run_errors<10)) LOG(ERR,"%d: words %d, ix %d",rdo1,n_words,ix) ; free(d_use) ; return 0 ; } @@ -268,7 +272,7 @@ int itpc23::from22to23(char *c_dta, int words) if(ix>(n_words)) { run_errors++ ; - if(run_errors<5) LOG(ERR,"%d: words %d, ix %d",rdo1,n_words,ix) ; + if(mode || (online && run_errors<10)) LOG(ERR,"%d: words %d, ix %d",rdo1,n_words,ix) ; err |= 0x80000000 ; free(d_use) ; return 0 ; @@ -277,7 +281,7 @@ int itpc23::from22to23(char *c_dta, int words) if(n_words<12) { run_errors++ ; - if(run_errors<5) LOG(ERR,"%d: n_words %d",rdo1,n_words) ; + if(mode || (online && run_errors<10)) LOG(ERR,"%d: n_words %d",rdo1,n_words) ; err |= 0x80000000 ; free(d_use) ; return 0 ; @@ -329,14 +333,17 @@ int itpc23::init(daq_dta *gain) return 9 ; } - +// We are at the SAMPA(fee_ix):channel header u_int *itpc23::ch_scan(u_int *start) { u_short w[6] ; u_int *d = start ; int row, pad ; + int is_error = 0 ; // we are at the SAMPA header + retry_fix:; + w[0] = (d[0]>>20)&0x3FF ; w[1] = (d[0]>>10)&0x3FF ; w[2] = (d[0]>>00)&0x3FF ; @@ -356,7 +363,7 @@ u_int *itpc23::ch_scan(u_int *start) if(unlikely(words10==1023)) { // channel skipped because of prog-full! prog_fulls++ ; - if(online) LOG(ERR,"%d: ch_scan %d:%d: SAMPA%d:%d -- prog-full",rdo1,fee_ix,ch_ix,sampa_id,sampa_ch) ; + if(mode || (online && run_errors<10)) LOG(ERR,"%d: ch_scan %d:%d: SAMPA%d:%d -- prog-full",rdo1,fee_ix,ch_ix,sampa_id,sampa_ch) ; words10 = 0 ; } @@ -364,10 +371,39 @@ u_int *itpc23::ch_scan(u_int *start) if(unlikely(pkt!=4 || sampa_ch>31 || words10>512)) { err |= 0x1000000 ; - fee_errs++ ; - if(fee_errs<10) LOG(ERR,"%d: ch_scan %d:%d: pkt %d, sampa_ch %2d, words10 %d [0x%08X]",rdo1,fee_ix,ch_ix, - pkt,sampa_ch,words10, - d[0]) ; + is_error = 1 ; + run_errors++ ; + if(mode || (online && run_errors<20)) { + LOG(ERR,"%d: ch_scan %d:%d:%d: pkt %d, sampa %d:%d, words10 %d [0x%08X: 0x%08X 0x%08X], err 0x%X",rdo1,fee_ix,lane_ix, + ch_ix, + pkt,sampa_id,sampa_ch,words10, + d[0],d[-1],d[1],err) ; + +// LOG(ERR,"err 0x%08X",err) ; + + //int ppk[2] ; + + //ppk[0] = (((d[-1]>>20)&0x3FF)>>7)&0x7 ; + //ppk[1] = (((d[1]>>20)&0x3FF)>>7)&0x7 ; + + //LOG(ERR,"%d %d",ppk[0],ppk[1]) ; + //d++ ; + //goto retry_fix ; + + } + if(d>9)&1) ; @@ -377,9 +413,13 @@ u_int *itpc23::ch_scan(u_int *start) } else { if(unlikely(bx != bx_count)) { - err |= 0x2000000 ; - fee_errs++ ; - if(fee_errs<10) LOG(ERR,"%d: ch_scan %d:%d: bx %d, expect %d",rdo1,fee_ix,ch_ix,bx,bx_count) ; + if(abs(bx-bx_count)>1) { + err |= 0x2000000 ; + run_errors++ ; + if(mode || (online && run_errors<10)) { + LOG(ERR,"%d: ch_scan %d:%d: bx %d, expect %d",rdo1,fee_ix,ch_ix,bx,bx_count) ; + } + } } } @@ -440,9 +480,11 @@ u_int *itpc23::ch_scan(u_int *start) // tb_cou, tb_start, adc, adc, adc x tb_cou times // from low tb_start to high if(unlikely(d[i]&0xC0000000)) { - fee_errs++ ; - if(fee_errs<10) LOG(ERR,"%d: ch_scan %d:%d: SAMPA %d:%d: bad word 0x%08X",rdo1,fee_ix,ch_ix, - sampa_id,sampa_ch,d[i]) ; + run_errors++ ; + if(mode || (online && run_errors<10)) { + LOG(ERR,"%d: ch_scan %d:%d: SAMPA %d:%d: bad word 0x%08X",rdo1,fee_ix,ch_ix, + sampa_id,sampa_ch,d[i]) ; + } } if(log_level>=2) LOG(TERR,"FEE %d:%d -- %d = 0x%08X",fee_ix,ch_ix,i,d[i]) ; @@ -462,8 +504,10 @@ u_int *itpc23::ch_scan(u_int *start) if(log_level>=100) LOG(TERR," tb_cou %d",tb_cou) ; if(unlikely(tb_cou>500)) { - fee_errs++ ; - if(fee_errs<10) LOG(ERR,"%d: rp %d:%d: tb_cou %d [0x%08X,%d]",rdo1,row,pad,tb_cou,d[i],i) ; + run_errors++ ; + if(mode || (online && run_errors<10)) { + LOG(ERR,"%d: rp %d:%d: tb_cou %d [0x%08X,%d]",rdo1,row,pad,tb_cou,d[i],i) ; + } } ix = 1 ; break ; @@ -472,7 +516,7 @@ u_int *itpc23::ch_scan(u_int *start) *dd++ = tb_start ; if(seq_ix>=(SEQ_MAX-1)) { - if(online) LOG(ERR,"too many seqs %d",seq_ix) ; + if(mode || online) LOG(ERR,"too many seqs %d",seq_ix) ; goto done_ch ; } @@ -492,16 +536,16 @@ u_int *itpc23::ch_scan(u_int *start) if(unlikely(log_level>=100)) LOG(TERR," tb_start %d",tb_start) ; if(unlikely(tb_start<=tb_last)) { - fee_errs++ ; - if(fee_errs<10) LOG(ERR,"%d: rp %d:%d: tb_start %d, tb_last %d",rdo1,row,pad,tb_start,tb_last) ; + run_errors++ ; + if(mode || (online && run_errors<10))LOG(ERR,"%d: rp %d:%d: tb_start %d, tb_last %d",rdo1,row,pad,tb_start,tb_last) ; } tb_last = tb_start + tb_cou ; if(unlikely(tb_last>500)) { - fee_errs++ ; - if(fee_errs<10) LOG(ERR,"%d: rp %d:%d: tb_last %d [0x%08X,%d]",rdo1,row,pad,tb_last,d[i],i) ; + run_errors++ ; + if(mode || (online && run_errors<10)) LOG(ERR,"%d: rp %d:%d: tb_last %d [0x%08X,%d]",rdo1,row,pad,tb_last,d[i],i) ; } @@ -619,16 +663,31 @@ u_int *itpc23::lane_scan(u_int *start) { u_int *d = start ; + retry_fix:; + if(log_level>=1) LOG(TERR,"%d: lane scan %d: 0x%08X",rdo1,lane_ix,d[0]) ; // should be at start of lane 0xB.... if((d[0]&0xF0000000)!=0xB0000000) { // start of lane - err |= 0x100000 ; - if(online) LOG(ERR,"%d: lane_scan %d:%d: unknown start 0x%08X",rdo1,fee_ix,lane_ix,d[0]) ; + if((online && run_errors<10) || mode) { + LOG(ERR,"%d: lane_scan %d:%d: unknown start 0x%08X [0x%08X 0x%08X]",rdo1,fee_ix,lane_ix,d[0],d[-1],d[1]) ; + } + + if(d[0]==d[-1]) { + if(mode || (online && run_errors<10)) { + LOG(WARN,"%d: lane_scan %d:%d: retrying fix",rdo1,fee_ix,lane_ix) ; + } + d++ ; + goto retry_fix ; + } + else { + err |= 0x100000 ; + } + } else if((d[0]>>26)&0x3) { // SAMPA FIFOs overwritten! err |= 0x200000 ; - if(online) LOG(ERR,"%d: lane_scan %d:%d: SAMPA FIFO overwritten 0x%08X",rdo1,fee_ix,lane_ix,d[0]) ; + if(online || mode) LOG(ERR,"%d: lane_scan %d:%d: SAMPA FIFO overwritten 0x%08X",rdo1,fee_ix,lane_ix,d[0]) ; } d++ ; // skip 0xB.... @@ -642,8 +701,9 @@ u_int *itpc23::lane_scan(u_int *start) // should be at end of lane 0x7.... if((d[0]&0xF0000000)!=0x70000000) { // end of lane - err |= 0x400000 ; - if(online) LOG(ERR,"%d: lane_scan %d:%d: unknown end 0x%08X",rdo1,fee_ix,lane_ix,d[0]) ; + err |= 0x400000 ; + run_errors++ ; + if((online && run_errors<20)|| mode) LOG(ERR,"%d: lane_scan %d:%d: unknown end 0x%08X",rdo1,fee_ix,lane_ix,d[0]) ; } d++ ; // skip 0x7... @@ -658,7 +718,7 @@ u_int *itpc23::fee_non_trgd(u_int *start) int fee_words = 0 ; if(fee_evt_type != 0x02) { // no clue - if(online) LOG(ERR,"%d: fee_non_trgd %d: evt_type 0x%02X",rdo1,fee_ix,fee_evt_type) ; + if(online || mode) LOG(ERR,"%d: fee_non_trgd %d: evt_type 0x%02X",rdo1,fee_ix,fee_evt_type) ; while(d=1) LOG(TERR,"%d: T %d(%d,%d)",rdo1,token,trg_cmd,daq_cmd) ; if(log_level>=10) { - for(int i=0;i<8;i++) { - LOG(TERR,"rdo_scan %d/%d = 0x%08X",i,words,d[i]) ; - } + for(int i=0;i<8;i++) { + LOG(TERR,"rdo_scan %d/%d = 0x%08X",i,words,d[i]) ; + } } u_int mhz_start = d[3] ; @@ -893,7 +959,6 @@ int itpc23::rdo_scan(char *c_addr, int iwords) u_int fee_xoff = d[5]>>16 ; // actually prog_full u_int rdo_stuff = d[5]&0xFFFF ; u_int fee_empty = d[6]&0xFFFF ; -// u_int sig = d[7] ; l_fee_mask = 0 ; @@ -923,13 +988,17 @@ int itpc23::rdo_scan(char *c_addr, int iwords) // fee_mask,fee_synced,fee_overrun,fee_xoff,rdo_stuff,fee_empty,sig) ; if((fee_synced&fee_mask)!=fee_mask) { - if(online) LOG(ERR,"%d: evt %d: fee sync error 0x%04X, expect 0x%04X",rdo1,evt,fee_synced,fee_mask) ; + if(mode || (online)) LOG(ERR,"%d: evt %d: fee sync error 0x%04X, expect 0x%04X",rdo1,evt,fee_synced,fee_mask) ; // STOP: auto-recovery err |= 0x10 ; } if(fee_overrun&fee_mask) { - if(online) LOG(ERR,"%d: %d: RDOs fee FIFO overrun 0x%04X",rdo1,evt,fee_overrun&fee_mask) ; + if(mode || online) { + LOG(ERR,"%d: %d: RDOs fee FIFO overrun 0x%04X: words %d: 0x%04X 0x%04X 0x%04X 0x%04X", + rdo1,evt,fee_overrun&fee_mask,words, + fee_mask,l_fee_mask,fee_xoff,fee_empty) ; + } // STOP: auto-recovery err |= 0x10 ; } @@ -965,10 +1034,14 @@ int itpc23::rdo_scan(char *c_addr, int iwords) } if(got_it != 3) { - if(online) LOG(ERR,"%d: %d: no trailer (0x%08X), %d",rdo1,evt,trl[0],got_it) ; + if(mode || online) { + LOG(ERR,"%d: evt %d: no trailer (0x%08X), %d, words %d",rdo1,evt,trl[0],got_it,words) ; +// LOG(ERR," 0x%X 0x%X 0x%X",trl[1],trl[2],trl[3]) ; + } // STOP: auto-recovery err |= 0x2 ; -// for(int i=0;i>28)!=0xF)||((*d&0xFFFF)!=fee_mask)) { - if(online) LOG(ERR,"%d: evt %d: Bad FEE_START 0x%08X, expect 0x%08X",rdo1,evt,*d,0xF0000000|fee_mask) ; + if(mode || (online && run_errors<10)) LOG(ERR,"%d: evt %d: Bad FEE_START 0x%08X, expect 0x%08X",rdo1,evt,*d,0xF0000000|fee_mask) ; err |= 0x20 ; goto done ; } @@ -1089,7 +1162,7 @@ int itpc23::rdo_scan(char *c_addr, int iwords) if(err||prog_fulls) { - if(online) LOG(ERR,"%d: evt %d/%d: T %d,%d,%d: error 0x%08X, prog_fulls %d: words %d, %d us",rdo1,evt_trgd,evt, + if(online || mode) LOG(ERR,"%d: evt %d/%d: T %d,%d,%d: error 0x%08X, prog_fulls %d: words %d, %d us",rdo1,evt_trgd,evt, token,trg_cmd,daq_cmd, err, prog_fulls, @@ -1296,8 +1369,6 @@ itpc23::itpc23() data_c = 0 ; - fee_errs = 0 ; // just in case - fmt = 0 ; } diff --git a/StRoot/RTS/src/DAQ_TPC23/tpc23_base.cxx b/StRoot/RTS/src/DAQ_TPC23/tpc23_base.cxx index 2e857ee015a..cb3f90594d1 100644 --- a/StRoot/RTS/src/DAQ_TPC23/tpc23_base.cxx +++ b/StRoot/RTS/src/DAQ_TPC23/tpc23_base.cxx @@ -1353,7 +1353,7 @@ int tpc23_base::run_start() evt_trgd = 0 ; run_errors = 0 ; - fee_errs = 0 ; +// fee_errs = 0 ; return 0 ; @@ -1384,6 +1384,7 @@ tpc23_base::tpc23_base() s2_words = 0 ; no_cld = 0 ; + mode = 0 ; // rp_gain_tpx = 0 ; // rp_gain_itpc = 0 ; diff --git a/StRoot/RTS/src/DAQ_TPC23/tpc23_base.h b/StRoot/RTS/src/DAQ_TPC23/tpc23_base.h index 61862750698..0959eefa492 100644 --- a/StRoot/RTS/src/DAQ_TPC23/tpc23_base.h +++ b/StRoot/RTS/src/DAQ_TPC23/tpc23_base.h @@ -25,7 +25,7 @@ class tpc23_base { virtual int rdo_scan(char *mem, int words) ; virtual int from22to23(char *dta, int words) ; // rewrite the old FY22 raw data foramt to FY23 - int fee_errs ; +// int fee_errs ; u_char rts_id ; // tpx, itpc u_char fmt ; // 22: old data format, 23: FY23 data format @@ -49,6 +49,9 @@ class tpc23_base { u_char no_cld ; + + u_char mode ; // for various debugging steering + u_int last_ix ; int sequence_cou ; diff --git a/StRoot/RTS/src/DAQ_TPC23/tpx23.cxx b/StRoot/RTS/src/DAQ_TPC23/tpx23.cxx index 61c46c559b4..d46919a79fa 100644 --- a/StRoot/RTS/src/DAQ_TPC23/tpx23.cxx +++ b/StRoot/RTS/src/DAQ_TPC23/tpx23.cxx @@ -58,10 +58,11 @@ int tpx23::fee_scan() { u_int *h ; err = 0 ; // in class + int id_pre = -1 ; + int ch_pre = -1 ; + int s_cou ; + char retry ; -// u_char altro_present[256][16] ; - - get_token((char *)d_start,words) ; TLOG() ; @@ -85,16 +86,12 @@ int tpx23::fee_scan() // last valid FEE word is at d_end h = d_end ; - -// memset(altro_present,0,sizeof(altro_present)) ; - if(hdr_version) { - - - } - TLOGX(rdo1) ; - if(log_level>0) LOG(TERR,"%d: fee_scan",rdo1) ; + if(log_level>0) LOG(TERR,"%d: fee_scan",rdo1) ; + + u_int *h_to_continue ; + retry = 0 ; // NOTE: ALTRO scans from the end!!! while(h>(d_start+2)) { @@ -108,13 +105,85 @@ int tpx23::fee_scan() hi &= 0xFFFFF ; int wc = ((hi&0x3F)<<4)|((lo&0xF0000)>>16) ; // altro's word count - if(wc==0) continue ; + int id = (lo&0xFF0) >> 4 ; // altro id int ch = lo & 0xF ; + // sanity checks: 0xAAA & 0xA + u_int aaa = hi>>6 ; + u_int a = (lo>>12)&0xF ; + + + if((aaa!= 0x2AAA)||(a!=0xA)||(wc>437)) { + run_errors++ ; + if(run_errors<20) { + if((online || mode) && retry==0) { + LOG(ERR,"S%02d:%d: aid %d:%d, %d:%d: aaa 0x%X, a 0x%X, wc %d, %d", + sector1,rdo1,id,ch,id_pre,ch_pre,aaa,a,wc,d_end-h) ; + } + } + if(1) { + h++ ; + //LOG(ERR,"Retry aaa") ; + retry = 1 ; + continue ; + } + } + + if(wc==0) { + id_pre = id ; + ch_pre = ch ; + continue ; + } + + TLOGX(id) ; + +// if(mode & 3) { // debugging! + u_int aa = ((h[1]&0xFFFFF)>>10) ; + + //LOG(TERR,"aid %d:%d: 0x%X 0x%X",id,ch,h[0]&0xFFFFF,h[1]&0xFFFFF) ; + + if(aa != 0x2AA) { + run_errors++ ; + if(run_errors<20) { + if((online || mode) && retry==0) { + LOG(ERR,"S%02d:%d: aid %d:%d, %d:%d: aaa 0x%X, a 0x%X, aa 0x%X, wc %d", + sector1,rdo1,id,ch,id_pre,ch_pre,aaa,a,aa,wc) ; + } + } + + if(1) { + h++ ; + //LOG(ERR,"Retry aa") ; + retry = 1 ; + continue ; + } + } + else { + //LOG(WARN,"S%02d:%d: aid %d:%d, %d:%d: aaa 0x%X, a 0x%X, aa 0x%X, wc %d", + // sector1,rdo1,id,ch,id_pre,ch_pre,aaa,a,aa,wc) ; + + + } + +// } + + if(retry) { + if(online || mode) { + if(run_errors<20) { + LOG(WARN,"S%02d:%d: aid %d:%d, %d:%d: aaa 0x%X, a 0x%X, wc %d, %d -- OK", + sector1,rdo1,id,ch,id_pre,ch_pre,aaa,a,wc,d_end-h) ; + } + } + } + + retry = 0 ; + + h_to_continue = h ; // h+1 + for(int i=0;i437) { // garbage in the event... and now what??? run_errors++ ; if(run_errors<10) { - if(online) LOG(ERR,"S%02d:%d: rp %d:%d (aid %d:%d) : wc %d",sector1,rdo1,row,pad,id,ch,wc) ; + if(online) LOG(ERR,"S%02d:%d: rp %d:%d (aid %d:%d, %d:%d) : wc %d",sector1,rdo1,row,pad, + id,ch,id_pre,ch_pre, wc) ; } //err |= 0x10000 ; // signal an error because I am breaking out break ; } +#endif while(wc%4) wc++ ; @@ -260,12 +332,19 @@ int tpx23::fee_scan() if(t_len>440 || t_hi>440 || t_lo>440) { run_errors++ ; if(run_errors<20) { - if(online) LOG(ERR,"S%02d:%d: rp %d:%d (aid %d:%d), t_len %d, t_lo %d, t_hi %d",sector1,rdo1,row,pad, - id,ch, - t_len,t_lo,t_hi) ; + if(online||mode) LOG(ERR,"S%02d:%d: rp %d:%d (aid %d:%d, %d:%d), t_len %d, t_lo %d, t_hi %d; wc %d, ix %d, seq %d, %d", + sector1,rdo1,row,pad, + id,ch,id_pre,ch_pre, + t_len,t_lo,t_hi,wc,ix,seq_ix,d_end-h) ; } - if(t_len>510 || t_hi>510 || t_lo>510) { + if(t_len>440 || t_hi>440 || t_lo>440) { //err |= 0x20000 ; + if(1) { + //LOG(ERR,"Retry rp") ; + h = h_to_continue ; + retry = 1 ; + goto end_loop ; + } break ; } @@ -365,7 +444,7 @@ int tpx23::fee_scan() //LOG(TERR,"Here 2") ; - int s_cou = 0 ; + s_cou = 0 ; dd = d ; seq = s1[row][pad].seq ; @@ -417,8 +496,10 @@ int tpx23::fee_scan() } #endif - + id_pre = id ; + ch_pre = ch ; + end_loop:; } @@ -797,7 +878,7 @@ int tpx23::log_dump(char *c_addr, int wds) if(strstr(tmpbuff+st,"FEE power BAD")) { //err_status |= DET_ERR_OPER_PS ; - LOG(ERR,"---> [S%d:%d LOG] FEE power BAD -- powercycle (ignored)",s_real,r_real) ; + //LOG(ERR,"---> [S%d:%d LOG] FEE power BAD -- powercycle (ignored)",s_real,r_real) ; //err = -1 ; } } @@ -843,6 +924,7 @@ int tpx23::log_dump(char *c_addr, int wds) if(strstr(tmpbuff+st,"altro error")) { err = -1 ; + err_status |= 3 ; LOG(ERR,"---> [%d LOG] altro error -- restart run",rdo) ; } @@ -852,7 +934,9 @@ int tpx23::log_dump(char *c_addr, int wds) //LOG(WARN,"---> [%d LOG] ERR ALTRO -- CHECK THIS",rdo) ; } - + if(strstr(tmpbuff+st,"ERR: expired")) { + err = -1 ; + } if(err<0) { diff --git a/StRoot/RTS/src/DAQ_TPX/Makefile b/StRoot/RTS/src/DAQ_TPX/Makefile index 47ee919ace2..e77d0c8c11c 100644 --- a/StRoot/RTS/src/DAQ_TPX/Makefile +++ b/StRoot/RTS/src/DAQ_TPX/Makefile @@ -69,6 +69,8 @@ daq_tpx.o: tpxFCF_flags.h daq_tpx.o: tpxFCF_2D.h daq_tpx.o: ../DAQ_TPX/tpxFCF.h daq_tpx.o: tpxStat.h +daq_tpx.o: ../DAQ_TPC23/tpx23.h +daq_tpx.o: ../DAQ_TPC23/tpc23_base.h tpxCore.o: ../../../../StRoot/RTS/include/rtsLog.h tpxCore.o: ../../../../StRoot/RTS/include/TPX/tpx_altro_to_pad.h tpxCore.o: ../../../../StRoot/RTS/include/DAQ1000/ddl_struct.h diff --git a/StRoot/RTS/src/DAQ_TPX/daq_tpx.cxx b/StRoot/RTS/src/DAQ_TPX/daq_tpx.cxx index 77028f52d96..eaf2cf34655 100644 --- a/StRoot/RTS/src/DAQ_TPX/daq_tpx.cxx +++ b/StRoot/RTS/src/DAQ_TPX/daq_tpx.cxx @@ -89,6 +89,8 @@ daq_tpx::daq_tpx(daqReader *rts_caller) sfs_name = "tpx" ; caller = rts_caller ; + mode = 0 ; + if(caller) caller->insert(this, rts_id) ; // create now! @@ -973,6 +975,8 @@ daq_dta *daq_tpx::handle_adc(int sec, int rdo) t23->no_cld = 1 ; t23->log_level = 0 ; + t23->mode = mode ; + t23->data_c = 0 ; // &altro_c ; t23->tpx_d = 0 ; } diff --git a/StRoot/RTS/src/DAQ_TPX/daq_tpx.h b/StRoot/RTS/src/DAQ_TPX/daq_tpx.h index c0376570886..ad596ac44ca 100644 --- a/StRoot/RTS/src/DAQ_TPX/daq_tpx.h +++ b/StRoot/RTS/src/DAQ_TPX/daq_tpx.h @@ -79,6 +79,8 @@ class daq_tpx : public daq_det { tpx23 *t23 ; + + protected: public: @@ -91,6 +93,8 @@ class daq_tpx : public daq_det { char fcf_run_compatibility ; char fcf_do_cuts ; + u_char mode ; + // for use by simulation int sim_row_count ; unsigned char *sim_tpx_rowlen ; diff --git a/StRoot/RTS/src/RTS_EXAMPLE/rts_example.C b/StRoot/RTS/src/RTS_EXAMPLE/rts_example.C index 5c5572597ac..6b60b037afc 100644 --- a/StRoot/RTS/src/RTS_EXAMPLE/rts_example.C +++ b/StRoot/RTS/src/RTS_EXAMPLE/rts_example.C @@ -1874,10 +1874,14 @@ static int tinfo_doer(daqReader *rdr, const char *do_print) bx64 = (bx64 << 32) + bx_low; float bx_sec = bx64/9.3e6; int bx7 = bx64 % 120; - + + int addBits = swap16(evtDesc->addBits); + int trg_tkn = swap16(evtDesc->TrgToken) ; - printf("tinfo: token %d, pre %d, post %d\n",trg_tkn,pre,post) ; + if(addBits != 0) { + printf("tinfo: token %d, pre %d, post %d, 0x%016llx 0x%04x\n",trg_tkn,pre,post, rdr->daqbits64, addBits) ; + } int crate_sz[MAX_CONF_NUM]; int crate_internal_usec[MAX_CONF_NUM];