Skip to content

Commit

Permalink
updates to daq readers in prep for run 22 (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
jml985 committed Dec 7, 2021
1 parent fb9cff3 commit 17dd3c9
Show file tree
Hide file tree
Showing 41 changed files with 1,928 additions and 116 deletions.
2 changes: 1 addition & 1 deletion StRoot/RTS/src/DAQ_BSMD/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bsmd_reader.o: ../../../../StRoot/RTS/include/rtsLog.h
bsmd_reader.o: ../../../../StRoot/RTS/include/rtsSystems.h
bsmd_reader.o: ../../../../StRoot/RTS/include/daqFormats.h
bsmd_reader.o: ../../../../StRoot/RTS/include/SECTOR/sector.h
bsmd_reader.o: ../../trg/include/trgDataDefs_46.h
bsmd_reader.o: ../../trg/include/trgDataDefs_47.h
bsmd_reader.o: ../../../../StRoot/RTS/include/L3/L3Formats.h
bsmd_reader.o: ../../../../StRoot/RTS/include/rts.h
bsmd_reader.o: ../DAQ_READER/daq_det.h
Expand Down
5 changes: 3 additions & 2 deletions StRoot/RTS/src/DAQ_EMC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ emc_reader.o: ../../../../StRoot/RTS/include/rtsSystems.h
emc_reader.o: ../../../../StRoot/RTS/include/rts.h
emc_reader.o: ../../../../StRoot/RTS/include/daqFormats.h
emc_reader.o: ../../../../StRoot/RTS/include/SECTOR/sector.h
emc_reader.o: ../../trg/include/trgStructures_32.h
emc_reader.o: ../../trg/include/trgDataDefs_47.h
emc_reader.o: ../../../../StRoot/RTS/include/L3/L3Formats.h
emc_reader.o: ../../trg/include/trgStructures.h
emc_reader.o: ../../trg/include/trgStructures_32.h
emc_reader.o: daq_emc.h
emc_reader.o: ../DAQ_READER/daq_det.h
emcReader.o: ../DAQ_READER/daqReader.h
Expand All @@ -64,7 +65,7 @@ emc_single_reader.o: ../../../../StRoot/RTS/include/rtsLog.h
emc_single_reader.o: ../../../../StRoot/RTS/include/rtsSystems.h
emc_single_reader.o: ../../../../StRoot/RTS/include/daqFormats.h
emc_single_reader.o: ../../../../StRoot/RTS/include/SECTOR/sector.h
emc_single_reader.o: ../../trg/include/trgStructures_32.h
emc_single_reader.o: ../../trg/include/trgDataDefs_47.h
emc_single_reader.o: ../../../../StRoot/RTS/include/L3/L3Formats.h
emc_single_reader.o: ../../../../StRoot/RTS/include/rts.h
emc_single_reader.o: ../DAQ_READER/daq_det.h
Expand Down
2 changes: 1 addition & 1 deletion StRoot/RTS/src/DAQ_ETOF/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ daq_etof.o: ../../../../StRoot/RTS/include/rtsLog.h
daq_etof.o: ../../../../StRoot/RTS/include/rtsSystems.h
daq_etof.o: ../../../../StRoot/RTS/include/daqFormats.h
daq_etof.o: ../../../../StRoot/RTS/include/SECTOR/sector.h
daq_etof.o: ../../trg/include/trgDataDefs_46.h
daq_etof.o: ../../trg/include/trgDataDefs_47.h
daq_etof.o: ../../../../StRoot/RTS/include/L3/L3Formats.h
daq_etof.o: ../SFS/sfs_index.h
daq_etof.o: ../SFS/fs_index.h
Expand Down
2 changes: 1 addition & 1 deletion StRoot/RTS/src/DAQ_FCS/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ daq_fcs.o: ../../../../StRoot/RTS/include/rtsLog.h
daq_fcs.o: ../../../../StRoot/RTS/include/rtsSystems.h
daq_fcs.o: ../../../../StRoot/RTS/include/daqFormats.h
daq_fcs.o: ../../../../StRoot/RTS/include/SECTOR/sector.h
daq_fcs.o: ../../trg/include/trgDataDefs_46.h
daq_fcs.o: ../../trg/include/trgDataDefs_47.h
daq_fcs.o: ../../../../StRoot/RTS/include/L3/L3Formats.h
daq_fcs.o: ../SFS/sfs_index.h
daq_fcs.o: ../SFS/fs_index.h
Expand Down
102 changes: 100 additions & 2 deletions StRoot/RTS/src/DAQ_FCS/fcs_data_c.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ pthread_mutex_t fcs_data_c::ped_mutex ;

fcs_data_c::statistics_t fcs_data_c::statistics[8] ;

int fcs_data_c::stage_params_txt[32] ;


long fcs_data_c::dep_to_char(int det, int ns, int dep)
{
long ret ;
Expand Down Expand Up @@ -89,6 +92,95 @@ long fcs_data_c::dep_to_char(int det, int ns, int dep)

}

const char *fcs_data_c::stage_labels[] = {
"FCS_HAD-HERATIO-THR", //
"FCS_EM-HERATIO-THR", //
"FCS_HADTHR1", //
"FCS_HADTHR2", //
"FCS_HADTHR3",
"FCS_EMTHR1", //
"FCS_EMTHR2", //
"FCS_EMTHR3",
"FCS_JETTHR1",
"FCS_JETTHR2",
"FCS_ETOTTHR", //
"FCS_HTOTTHR", // 11 //

"FCS_EHTTHR", // 12 //
"FCS_HHTTHR", // 13 //
"FCS_PHTTHR" // 14 //
} ;

int fcs_data_c::load_stage_params(int sec1, const char *fname)
{
if(fname==0) {
fname="/RTS/conf/fcs/stage_params.txt" ;
}

FILE *f = fopen(fname,"r") ;
if(f==0) {
LOG(ERR,"sector %2d: %s: [%s]",sec1,fname,strerror(errno)) ;
return -1 ;
}

LOG(INFO,"sector %2d: stage_params %s opened",sec1,fname) ;

int max_i = 0 ;

while(!feof(f)) {
char buff[128] ;
char name[64] ;
int val ;
int ix ;
int dummy ;

if(fgets(buff,sizeof(buff),f)==0) continue ;

if(buff[0]=='#') continue ;
if(buff[0]=='\n') continue ;

name[0] = '?' ;
name[1] = 0 ;
val = -1 ;

int ret = sscanf(buff,"%d %d %d %s %d",&dummy,&dummy,&ix,name,&val) ;
if(ret != 5) continue ;

// LOG(TERR,"ret %d: [%s]=%d",ret,name,val) ;

char got_it = -1 ;
for(u_int i=0;i<sizeof(stage_labels)/sizeof(stage_labels[0]);i++) {
if(stage_labels[i]==0) continue ;

if(strcasecmp(stage_labels[i],name)==0) {
stage_params_txt[i] = val ;
got_it = i ;
max_i = i ;
break ;
}
}

if(sec1==11) { // LOG only from this one
if(got_it<0) {
LOG(ERR,"stage_param_txt [%s]=%d NOT coded locally",name,val) ;
}
else {
LOG(INFO,"stage_param_txt [%s]=%d, index %d, ix %d",name,val,got_it,ix) ;
}
}
}

if(sec1==11) { // LOG from this one only
for(int i=0;i<max_i;i++) {
LOG(TERR,"stage_params_txt: %d/%d = %d",i,max_i,stage_params_txt[i]) ;
}
}

fclose(f) ;
return 0 ;
}



int fcs_data_c::zs_start(u_short *buff)
{
Expand Down Expand Up @@ -1128,8 +1220,14 @@ int fcs_data_c::ana_ch()
int errs = 0 ;
for(int tb=0;tb<tb_cou;tb++) {
int r=rdo-5 ;
int d = adc[tb] & 0xFF ;

if(expect[r][ch] != (adc[tb]&0xFF)) {
if(ch==36) {
if(d && (expect[r][ch] != d)) {
errs++ ;
}
}
else if(expect[r][ch] != d) {
errs++ ;
}
}
Expand Down Expand Up @@ -1549,7 +1647,7 @@ int fcs_data_c::gain_from_cache(const char *fname)

FILE *f = fopen(ff,"r") ;
if(f==0) {
LOG(WARN,"gain_from_cache: %s [%s]",ff,strerror(errno)) ;
LOG(ERR,"gain_from_cache: %s [%s] (perhaps not an error)",ff,strerror(errno)) ;
if(!is_dir) goto read_done ;
continue ;
}
Expand Down
4 changes: 4 additions & 0 deletions StRoot/RTS/src/DAQ_FCS/fcs_data_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ class fcs_data_c {

static int load_bad_ch(const char *fname=0, int sector=0) ;

static const char *stage_labels[32] ;
static int stage_params_txt[32] ; // from the params_xx file below
static int load_stage_params(int sec1, const char *fname=0) ;

// mutex for pedestals but also for statistics
static struct statistics_t {
float temperature ;
Expand Down
14 changes: 13 additions & 1 deletion StRoot/RTS/src/DAQ_FGT/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DEFINES += -DRTS_LOG_COLORED



OBJS := daq_fgt.o fgtPed.o
OBJS := daq_fgt.o fgtPed.o fstPed.o

LIBS = libfgt.a
BINS =
Expand Down Expand Up @@ -47,6 +47,18 @@ fgtPed.o: ../DAQ_READER/daq_dta_structs.h
fgtPed.o: fgtPed.h
fgtPed.o: daq_fgt.h
fgtPed.o: ../DAQ_READER/daq_det.h
fstPed.o: ../../../../StRoot/RTS/include/rtsLog.h
fstPed.o: ../../../../StRoot/RTS/include/daqModes.h
fstPed.o: ../../../../StRoot/RTS/include/rtsSystems.h
fstPed.o: ../DAQ_READER/daq_dta.h
fstPed.o: ../../../../StRoot/RTS/include/rts.h
fstPed.o: ../DAQ_READER/daq_dta_structs.h
fstPed.o: fgtPed.h
fstPed.o: daq_fgt.h
fstPed.o: ../DAQ_READER/daq_det.h
fstPed.o: fstPed.h
daq_fgt.o: ../DAQ_READER/daq_det.h
fgtPed.o: daq_fgt.h
fgtPed.o: ../DAQ_READER/daq_det.h
fstPed.o: daq_fgt.h
fstPed.o: ../DAQ_READER/daq_det.h
24 changes: 21 additions & 3 deletions StRoot/RTS/src/DAQ_FGT/daq_fgt.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ daq_dta *daq_fgt::handle_zs(int sec, int rdo, char *rdobuff, int inbytes)
for(int i=0;i<tb_cou;i++) {
fgt_d[cou].ch = ch ;
fgt_d[cou].tb = i ;
fgt_d[cou].adc = d[ix] ;
fgt_d[cou].adc = d[ix] & 0xFFF ; // new: 13 bits
fgt_d[cou].flags = d[ix]>>12 ; // new: upper 3 are flags
cou++ ;

//printf("ZS: %d %d %d %d %d = %d\n",arc,arm,apv,ch,i,d[ix]) ;
Expand Down Expand Up @@ -736,6 +737,7 @@ daq_dta *daq_fgt::handle_adc(int sec, int rdo, char *rdobuff)
fgt_d[cou].ch = rch ;
fgt_d[cou].tb = tb ;
fgt_d[cou].adc = adc ;
fgt_d[cou].flags = 0 ;
cou++ ;
}
}
Expand Down Expand Up @@ -805,8 +807,17 @@ daq_dta *daq_fgt::handle_ped(int sec, int rdo)
LOG(ERR,"Bad pedestal version") ;
}

if(d[1] != 1 ) {
LOG(ERR,"Bad pedestal version") ;
int is_fst = 0 ;

switch(d[1]) {
case 1 : // old, non FST
break ;
case 2 :
is_fst = 1 ;
break ;
default :
LOG(ERR,"Bad pedestal version 0x%X",d[1]) ;
break ;
}

// int arm_cou = d[2] ;
Expand Down Expand Up @@ -834,11 +845,18 @@ daq_dta *daq_fgt::handle_ped(int sec, int rdo)
for(int t=0;t<tb_cou;t++) {
u_short ped = d[ix++] ;
u_short rms = d[ix++] ;
u_short cmn_rms ;

if(is_fst) { // SPECIAL
cmn_rms = d[ix++] ;
}
else cmn_rms = 0 ;

f_ped[cou].ch = ch ;
f_ped[cou].tb = t ;
f_ped[cou].ped = ((float)ped) / 16.0 ;
f_ped[cou].rms = ((float)rms) / 16.0 ;
f_ped[cou].cmn_rms = ((float)cmn_rms) / 16.0 ;
cou++ ;
}
}
Expand Down
6 changes: 6 additions & 0 deletions StRoot/RTS/src/DAQ_FGT/daq_fgt.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#define FGT_CH_COU 128 // from 0..127
#define FGT_TB_COU 31 // from 0..30

#define FST_ARM_COU 3
#define FST_TB_COU 9

/*
#define FGT_CH_STAT_SHOULD 0x01 // exists in hardware
#define FGT_CH_STAT_NO_CONFIG 0x02 // killed in RC or config file
Expand All @@ -24,6 +27,7 @@
struct fgt_adc_t {
unsigned short ch ;
unsigned char tb ;
unsigned char flags ; // FST specific
short adc ;
} ;

Expand All @@ -33,6 +37,8 @@ struct fgt_pedrms_t {
unsigned char tb ;
float ped ;
float rms ;

float cmn_rms ; // FST specific
} ;

struct apv_meta_t {
Expand Down
3 changes: 3 additions & 0 deletions StRoot/RTS/src/DAQ_FGT/fgtPed.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ class fgtPed {
// allocated per RDO



struct peds_t {
// float cmn_rms[FGT_ARM_COU][FGT_APV_COU][FGT_CH_COU][FGT_TB_COU] ; // common noise stuff for FST

float ped[FGT_ARM_COU][FGT_APV_COU][FGT_CH_COU][FGT_TB_COU] ;
float rms[FGT_ARM_COU][FGT_APV_COU][FGT_CH_COU][FGT_TB_COU] ;
u_short thr[FGT_ARM_COU][FGT_APV_COU][FGT_CH_COU] ;
Expand Down
Loading

0 comments on commit 17dd3c9

Please sign in to comment.