From e23debac321cd1994ba8146631f2fcfd397913b8 Mon Sep 17 00:00:00 2001 From: jml985 <44065529+jml985@users.noreply.github.com> Date: Thu, 27 Jun 2024 21:37:47 -0400 Subject: [PATCH] updates to reader --- mainly to fix iTPC fee_words=0 problem (#688) --- StRoot/RTS/src/DAQ_TPC23/itpc23.cxx | 51 ++++++++++++++---- StRoot/RTS/src/DAQ_TPC23/tpc23_base.cxx | 14 +++++ StRoot/RTS/src/DAQ_TPC23/tpc23_base.h | 5 ++ StRoot/RTS/src/DAQ_TPC23/tpx23.cxx | 70 ++++++++++++++++++++++++- StRoot/RTS/src/DAQ_TPC23/tpx23.h | 6 ++- StRoot/RTS/src/DAQ_TPX/tpxGain.cxx | 4 +- StRoot/RTS/src/TRG_FCS/fcs_trg_base.cxx | 3 +- 7 files changed, 136 insertions(+), 17 deletions(-) diff --git a/StRoot/RTS/src/DAQ_TPC23/itpc23.cxx b/StRoot/RTS/src/DAQ_TPC23/itpc23.cxx index 11920eac5ee..abad19accb9 100644 --- a/StRoot/RTS/src/DAQ_TPC23/itpc23.cxx +++ b/StRoot/RTS/src/DAQ_TPC23/itpc23.cxx @@ -374,7 +374,8 @@ u_int *itpc23::ch_scan(u_int *start) 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, + LOG(ERR,"%d: T %d: ch_scan %d:%d:%d: pkt %d, sampa %d:%d, words10 %d [0x%08X: 0x%08X 0x%08X], err 0x%X", + rdo1,token,fee_ix,lane_ix, ch_ix, pkt,sampa_id,sampa_ch,words10, d[0],d[-1],d[1],err) ; @@ -417,7 +418,7 @@ u_int *itpc23::ch_scan(u_int *start) 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) ; + LOG(ERR,"%d: T %d: ch_scan %d:%d:%d bx %d, expect %d",rdo1,token,fee_ix,lane_ix,ch_ix,bx,bx_count) ; } } } @@ -529,7 +530,7 @@ u_int *itpc23::ch_scan(u_int *start) seq[seq_ix].t_hi = tb_start + tb_cou - 1 ; seq[seq_ix].dta_p = (dd-d_start) ; // where is this sequence... seq[seq_ix].blob_id = 0 ; - seq_ix++ ; + //seq_ix++ ; //dd += tb_cou ; // this doesn't sound correct!!! @@ -538,6 +539,10 @@ u_int *itpc23::ch_scan(u_int *start) if(unlikely(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) ; + + seq[seq_ix].t_lo = 400 ; + seq[seq_ix].t_hi = 401 ; + } @@ -546,9 +551,12 @@ u_int *itpc23::ch_scan(u_int *start) if(unlikely(tb_last>500)) { 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) ; - } + seq[seq_ix].t_lo = 400 ; + seq[seq_ix].t_hi = 401 ; + } + seq_ix++ ; ix = 2 ; break ; @@ -670,7 +678,7 @@ u_int *itpc23::lane_scan(u_int *start) // should be at start of lane 0xB.... if((d[0]&0xF0000000)!=0xB0000000) { // start of lane 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]) ; + LOG(ERR,"%d: T %d: lane_scan %d:%d: unknown start 0x%08X [0x%08X 0x%08X]",rdo1,token,fee_ix,lane_ix,d[0],d[-1],d[1]) ; } if(d[0]==d[-1]) { @@ -703,7 +711,7 @@ u_int *itpc23::lane_scan(u_int *start) if((d[0]&0xF0000000)!=0x70000000) { // end of lane 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]) ; + if((online && run_errors<20)|| mode) LOG(ERR,"%d: T %d: lane_scan %d:%d: unknown end 0x%08X",rdo1,token,fee_ix,lane_ix,d[0]) ; } d++ ; // skip 0x7... @@ -718,7 +726,7 @@ u_int *itpc23::fee_non_trgd(u_int *start) int fee_words = 0 ; if(fee_evt_type != 0x02) { // no clue - if(online || mode) LOG(ERR,"%d: fee_non_trgd %d: evt_type 0x%02X",rdo1,fee_ix,fee_evt_type) ; + if(online || mode) LOG(ERR,"%d: T %d: fee_non_trgd %d: evt_type 0x%02X",rdo1,token,fee_ix,fee_evt_type) ; while(d=trl) break ; } @@ -1371,6 +1398,8 @@ itpc23::itpc23() fmt = 0 ; + fee_words = 0 ; + } diff --git a/StRoot/RTS/src/DAQ_TPC23/tpc23_base.cxx b/StRoot/RTS/src/DAQ_TPC23/tpc23_base.cxx index cb3f90594d1..e480136d9e3 100644 --- a/StRoot/RTS/src/DAQ_TPC23/tpc23_base.cxx +++ b/StRoot/RTS/src/DAQ_TPC23/tpc23_base.cxx @@ -1355,6 +1355,8 @@ int tpc23_base::run_start() run_errors = 0 ; // fee_errs = 0 ; + memset(&f_stat,0,sizeof(f_stat)) ; + return 0 ; } @@ -1364,6 +1366,16 @@ int tpc23_base::run_start() int tpc23_base::run_stop() { // LOG(TERR,"%d: run_stop: %d/%d events, run_errors %d",id,evt_trgd,evt,run_errors) ; + + if(online || mode) { + for(int i=0;i<10;i++) { + f_stat.tm[i] /= f_stat.evt_cou ; + } + + LOG(NOTE,"id %d: evts %d, means %f %f %f %f %f %f",id,f_stat.evt_cou, + f_stat.tm[0],f_stat.tm[1],f_stat.tm[2],f_stat.tm[3],f_stat.tm[4], + f_stat.tm[5]) ; + } return 0 ; } @@ -1414,6 +1426,8 @@ tpc23_base::tpc23_base() data_c = 0 ; + store_track_id = 0 ; + token = 1 ; // for ease of simulation } diff --git a/StRoot/RTS/src/DAQ_TPC23/tpc23_base.h b/StRoot/RTS/src/DAQ_TPC23/tpc23_base.h index 0959eefa492..078a3923229 100644 --- a/StRoot/RTS/src/DAQ_TPC23/tpc23_base.h +++ b/StRoot/RTS/src/DAQ_TPC23/tpc23_base.h @@ -112,6 +112,11 @@ class tpc23_base { // called from daq_itpc int init(daq_dta *gain) ; + struct f_stat_t { + int evt_cou ; + double tm[10] ; + } f_stat ; + //private: diff --git a/StRoot/RTS/src/DAQ_TPC23/tpx23.cxx b/StRoot/RTS/src/DAQ_TPC23/tpx23.cxx index d46919a79fa..ff1b9b33af0 100644 --- a/StRoot/RTS/src/DAQ_TPC23/tpx23.cxx +++ b/StRoot/RTS/src/DAQ_TPC23/tpx23.cxx @@ -4,6 +4,7 @@ #include #include #include +#include #include @@ -35,6 +36,21 @@ #include "tpx23.h" +static double mark(void) +{ + struct timeval tmval ; + + gettimeofday(&tmval,0) ; + + return ((double)tmval.tv_sec*1000000.0 + (double)tmval.tv_usec) ; +} + +static double delta(double v) +{ + return mark() - v ; +} + + tpxPed *tpx23::peds ; tpc23_base::row_pad_t (*tpx23::rp_gain_tpx)[ROW_MAX+1][PAD_MAX+1] ; @@ -62,6 +78,7 @@ int tpx23::fee_scan() int ch_pre = -1 ; int s_cou ; char retry ; +// double s_tmx = mark() ; get_token((char *)d_start,words) ; @@ -93,10 +110,16 @@ int tpx23::fee_scan() u_int *h_to_continue ; retry = 0 ; + + f_stat.evt_cou++ ; + // NOTE: ALTRO scans from the end!!! while(h>(d_start+2)) { u_int hi, lo ; +// double tmx ; +// tmx=mark() ; + lo = *h-- ; hi = *h-- ; @@ -225,6 +248,9 @@ int tpx23::fee_scan() while(wc%4) wc++ ; + +// f_stat.tm[0] += delta(tmx) ; + // if this is a physics run: skip pads which have flags // hmm... is this right? if(flags && run_type==3) { @@ -261,6 +287,8 @@ int tpx23::fee_scan() //TLOGX(row) ; +// tmx = mark() ; + for(int i=0;i=0;i--) { + int t_len = sseq[i].t_hi - sseq[i].t_lo + 1 ; + + int ii = 0 ; + for(int j=(t_len-1);j>=0;j--) { + int adc = sseq[i].d[j] ; + altro[altro_cou].adc[aix] = adc ; + altro[altro_cou].tb[aix] = sseq[i].t_lo + ii ; + altro[altro_cou].count++ ; + ii++ ; + aix++ ; + } + } + + altro_cou++ ; + } else if(tpx_d) { tpx_d->sector = sector1 ; tpx_d->rdo = rdo1 ; @@ -411,7 +468,7 @@ int tpx23::fee_scan() tpx_d->pad = pad ; tpx_d->altro = id ; - //LOG(TERR,"%d:%d %d:%d %d:%d",sector1,rdo1,row,pad,id,ch) ; + LOG(NOTE,"%d:%d %d:%d %d:%d",sector1,rdo1,row,pad,id,ch) ; tpx_d->ch_start(ch) ; // sets tpx_d->ch within @@ -441,6 +498,7 @@ int tpx23::fee_scan() +// f_stat.tm[2] += delta(tmx) ; //LOG(TERR,"Here 2") ; @@ -450,6 +508,9 @@ int tpx23::fee_scan() // printf("row %d, pad %d: seq_ix %d\n",row,pad,seq_ix) ; + +// tmx = mark() ; + for(int i=(seq_ix-1);i>=0;i--) { seq[s_cou].t_lo = sseq[i].t_lo; seq[s_cou].t_hi = sseq[i].t_hi ; @@ -499,6 +560,9 @@ int tpx23::fee_scan() id_pre = id ; ch_pre = ch ; + +// f_stat.tm[3] += delta(tmx) ; + end_loop:; } @@ -506,6 +570,8 @@ int tpx23::fee_scan() done:; +// f_stat.tm[4] += delta(s_tmx) ; + TLOG() ; return err ; @@ -1113,6 +1179,8 @@ tpx23::tpx23() memset(fpga_usercode,0,sizeof(fpga_usercode)) ; + altro = 0 ; + tpx_d = 0 ; } diff --git a/StRoot/RTS/src/DAQ_TPC23/tpx23.h b/StRoot/RTS/src/DAQ_TPC23/tpx23.h index 5b4a622351b..c1cd99d266e 100644 --- a/StRoot/RTS/src/DAQ_TPC23/tpx23.h +++ b/StRoot/RTS/src/DAQ_TPC23/tpx23.h @@ -8,7 +8,7 @@ class tpxPed ; struct daq_dta ; - +struct tpx_altro_struct ; class tpx23Data { public: @@ -76,6 +76,10 @@ class tpx23 : public tpc23_base { u_char rhic_clock ; class tpx23Data *tpx_d ; + + tpx_altro_struct *altro ; + int altro_cou ; + private: int fee_scan() ; diff --git a/StRoot/RTS/src/DAQ_TPX/tpxGain.cxx b/StRoot/RTS/src/DAQ_TPX/tpxGain.cxx index 7447f90ee1c..e8b722060f0 100644 --- a/StRoot/RTS/src/DAQ_TPX/tpxGain.cxx +++ b/StRoot/RTS/src/DAQ_TPX/tpxGain.cxx @@ -269,7 +269,7 @@ void tpxGain::accum(char *evbuff, int bytes) t = tpx_get_start(evbuff, bytes/4, &rdo, 0) ; - LOG(NOTE,"RDO %d: %d bytes,token %d",rdo.rdo,bytes,t) ; +// LOG(WARN,"RDO %d: %d bytes,token %d %d",rdo.rdo,bytes,t,rdo.token) ; if(t <= 0) return ; // non data event... @@ -1054,7 +1054,7 @@ int tpxGain::to_file(const char *fname) s_start,s_stop, c_run, c_date, c_time) ; - fprintf(f,"# $Id: tpxGain.cxx,v 1.37 2022/09/23 19:55:47 jml Exp $\n") ; // CVS id! + fprintf(f,"# $Id: tpxGain.cxx,v 1.38 2024/04/10 12:01:00 tonko Exp $\n") ; // CVS id! fprintf(f,"# Run %u\n",c_run) ; for(s=s_start;s<=s_stop;s++) { diff --git a/StRoot/RTS/src/TRG_FCS/fcs_trg_base.cxx b/StRoot/RTS/src/TRG_FCS/fcs_trg_base.cxx index a22ada155c5..c777c46d601 100644 --- a/StRoot/RTS/src/TRG_FCS/fcs_trg_base.cxx +++ b/StRoot/RTS/src/TRG_FCS/fcs_trg_base.cxx @@ -540,8 +540,6 @@ int fcs_trg_base::end_event() verify_event_io() ; // verify interconnectivity - //int dsmout = 0; moved to .h file - self_trigger = 0 ; s3_to_dsm = d_in[trg_xing].s3.dsm_out.d[0] ; @@ -1274,6 +1272,7 @@ u_int fcs_trg_base::run_event_sim(int xing, int type) return d_out.s3.dsm_out + ((int)(d_out.s2[0].s2_to_dsm & 0xFF) << 16) + ((int)(d_out.s2[1].s2_to_dsm & 0xFF) << 24); + }