#include #include #include //#include #include #include //#include "conf_utils.h" #if 0 int main(){ // char* roc_name = "roccdc2"; // char* filename = "/home/somov/conf/conf_examp.cnf"; int rc; // strcpy(filename, "/home/somov/conf/conf_examp.cnf"); strcpy(filename, "/home/somov/conf/tagm_pulser.cnf"); strcpy(roc_name, "rocps2"); memset(fa250, 0, sizeof(fa250)); memset(fa125, 0, sizeof(fa125)); memset(&ti_bd, 0, sizeof(ti_bd)); memset(&dsc, 0, sizeof(dsc)); memset(&caen1290, 0, sizeof(caen1290)); memset(&f1, 0, sizeof(f1)); memset(&ctp, 0, sizeof(ctp)); memset(&ssp, 0, sizeof(ssp)); memset(>p_eq, 0, sizeof(gtp_eq)); memset(>p_trig, 0, sizeof(gtp_trig)); rc = read_conf_global(filename,roc_name); if(rc != 0) return 0; rc = read_conf_common(roc_name); if(rc == 0) read_conf_user(roc_name); print_ts_conf(); print_ssp_conf(); print_gtp_conf(); // print_fadc250_conf(3); // print_fadc250_conf(4); // print_fadc250_conf(5); // print_fadc250_conf(6); // print_fadc250_conf(7); // print_fadc250_conf(4); // print_ti_conf(); // printf(" Board type for crate %s = %s \n", roc_name, get_board_type_name("rocbcal8")); // FADC250_CONF fa250_test; // fa250_test = get_conf_fadc250(3); // printf(" get_conf_fadc250: group = %d, Serial number %s \n", fa250_test.group, fa250_test.SerNum); // FADC125_CONF fa125_test; // fa125_test = get_conf_fadc125(3); // printf(" get_conf_fadc125: group = %d, Serial number %s \n", fa125_test.group, fa125_test.SerNum); // print_fadc125_conf(3); // print_fadc125_conf(4); // print_ts_conf(); // print_ti_conf(); // print_le_conf(); // print_caen1290_conf(); // print_f1_conf(); return 0; } #endif FADC125_CONF get_conf_fadc125(int slot){ FADC125_CONF fa125_tmp; fa125_tmp = fa125[slot]; return fa125_tmp; } FADC250_CONF get_conf_fadc250(int slot){ FADC250_CONF fa250_tmp; fa250_tmp = fa250[slot]; return fa250_tmp; } det_type get_det_type(char* crate){ det_type det; if(strncmp(crate, "rocfcal", 7) == 0) det = fcal; if(strncmp(crate, "rocbcal", 7) == 0) det = bcal; if(strncmp(crate, "roccdc", 6) == 0) det = cdc; if(strncmp(crate, "rocfdc", 6) == 0) det = fdc; if(strncmp(crate, "roctof", 6) == 0) det = tof; if(strcmp(crate, "rocps1") == 0) det = ps; if(strcmp(crate, "rocps2") == 0) det = psc; if(strcmp(crate, "rocst") == 0) det = st; if(strncmp(crate, "rocstpsc", 8) == 0) // Joint crates with LEs and F1TDCs belong to the ST det = st; if(strncmp(crate, "roctagm", 7) == 0) // Joint crate with F1 tdc belongs to the microscope det = tagm; if(strncmp(crate, "roctagh", 7) == 0) det = tagh; if(strcmp(crate, "roctrig3") == 0) det = trigger; return det; } bd_type get_board_type(char* crate){ bd_type board; /* FCAL */ if(strncmp(crate, "rocfcal", 7) == 0) board = fadc250; /* BCAL */ if( strcmp(crate, "rocbcal3") == 0 || strcmp(crate, "rocbcal6") == 0 || strcmp(crate, "rocbcal9") == 0 || strcmp(crate, "rocbcal12") == 0 ) board = f1tdc; else if( strcmp(crate, "rocbcal13") == 0 || strcmp(crate, "rocbcal14") == 0 || strcmp(crate, "rocbcal15") == 0 || strcmp(crate, "rocbcal16") == 0 ) board = dsc2; else if(strncmp(crate, "rocbcal", 7) == 0 ) board = fadc250; /* CDC */ if(strncmp(crate, "roccdc", 6) == 0) board = fadc125; /* FDC */ if( strcmp(crate, "rocfdc1") == 0 || strcmp(crate, "rocfdc4") == 0 || strcmp(crate, "rocfdc13") == 0 || strcmp(crate, "rocfdc14") == 0 ){ board = f1tdc; } else if( strncmp(crate, "rocfdc",6) == 0 ) board = fadc125; /* TOF */ if(strcmp(crate, "roctof1") == 0) board = fadc250; if(strcmp(crate, "roctof2") == 0) board = tdc1290; if(strncmp(crate, "roctof3", 7) == 0) board = dsc2; /* ST */ if(strcmp(crate, "rocst") == 0) board = fadc250; if(strcmp(crate, "rocstpsc1") == 0) board = f1tdc; if(strcmp(crate, "rocstpsc2") == 0) board = dsc2; /* PS */ if(strncmp(crate, "rocps", 5) == 0 ) board = fadc250; /* TAGH */ if(strcmp(crate, "roctagh1") == 0) board = fadc250; if(strcmp(crate, "roctagh2") == 0) board = dsc2; /* TAGM */ if(strcmp(crate, "roctagm1") == 0) board = fadc250; if(strcmp(crate, "roctagm2") == 0) board = dsc2; if(strcmp(crate, "roctagmh") == 0) board = f1tdc; /* Secondary Trigger Supervisor */ if(strcmp(crate, "roctrig3") == 0) board = tss; return board; } char *get_board_type_name(char* crate){ char *bd_type; /* FCAL */ if(strncmp(crate, "rocfcal", 7) == 0) bd_type = "fadc250"; /* BCAL */ if( strcmp(crate, "rocbcal3") == 0 || strcmp(crate, "rocbcal6") == 0 || strcmp(crate, "rocbcal9") == 0 || strcmp(crate, "rocbcal12") == 0 ) bd_type = "f1tdc"; else if( strcmp(crate, "rocbcal13") == 0 || strcmp(crate, "rocbcal14") == 0 || strcmp(crate, "rocbcal15") == 0 || strcmp(crate, "rocbcal16") == 0 ) bd_type = "dsc2"; else if(strncmp(crate, "rocbcal", 7) == 0 ) bd_type = "fadc250"; /* CDC */ if(strncmp(crate, "roccdc", 6) == 0) bd_type = "fadc125"; /* FDC */ if( strcmp(crate, "rocfdc1") == 0 || strcmp(crate, "rocfdc4") == 0 || strcmp(crate, "rocfdc13") == 0 || strcmp(crate, "rocfdc14") == 0 ) bd_type = "f1tdc"; else if( strncmp(crate, "rocfdc",6) == 0 ) bd_type = "fadc125"; /* TOF */ if(strcmp(crate, "roctof1") == 0) bd_type = "fadc250"; if(strcmp(crate, "roctof2") == 0) bd_type = "tdc1290"; if(strncmp(crate, "roctof3", 7) == 0) bd_type = "dsc2"; /* ST */ if(strcmp(crate, "rocst") == 0) bd_type = "fadc250"; if(strcmp(crate, "rocstpsc1") == 0) bd_type = "f1tdc"; if(strcmp(crate, "rocstpsc2") == 0) bd_type = "dsc2"; /* PS */ if(strncmp(crate, "rocps", 5) == 0 ) bd_type = "fadc250"; /* TAGH */ if(strcmp(crate, "roctagh1") == 0) bd_type = "fadc250"; if(strcmp(crate, "roctagh2") == 0) bd_type = "dsc2"; /* TAGM */ if(strcmp(crate, "roctagm1") == 0) bd_type = "fadc250"; if(strcmp(crate, "roctagm2") == 0) bd_type = "dsc2"; if(strcmp(crate, "roctagmh") == 0) bd_type = "f1tdc"; /* Secondary Trigger Supervisor */ if(strcmp(crate, "roctrig3") == 0) bd_type = "tss"; return bd_type; } int read_conf_global(char *filename, char *crate){ int debug = 0; FILE *pFile; int ch; int ii = 0, jj; int val; int args_assigned = -1, args = -1; float fval; char str_tmp[STRLEN]; char keyword[ROCLEN]; char str[STRLEN]; char str_val[80]; int msk[16]; char eq_msk_type[20]; char trg_msk_type[20]; int eq_msk[3]; int trg_msk[7]; int soft_trig[4]; int ti_fiber[8]; int val_ssp[3]; int gtp_pres[2]; int ti_master_trig = 0; int ti_master = 0; int fiber_latency = 0; int i1 = 0, i2 = 0; int SL_MIN = 0; int SL_MAX = 0; int SL_HR = 17; int ngtp_eq = 0; int ngtp_trg = 0; init_all(); memset(soft_trig,0,sizeof(soft_trig)); memset(ti_fiber,0,sizeof(ti_fiber)); det_type det_comp = det_unknown; det_type crate_det = get_det_type(crate); if(crate_det == det_unknown) { printf(BOLDRED "\n FATAL: Read_conf_global: Unknown detector type for crate %s \n" RESET, crate); return(-2); } bd_type crate_board = get_board_type(crate); if(crate_board == bd_unknown) { printf(BOLDRED "\n FATAL: Read_conf_global: Unknown board type for crate %s \n" RESET, crate); return(-2); } /* Open Global Configuration File */ pFile = fopen(filename, "r"); if(pFile == NULL) { printf(BOLDRED "\n FATAL: Read_conf_global: Cannot open config file %s \n" RESET, filename); return(-2); } printf(BOLDBLUE "\n Reading Global Configuration File %s \n" RESET, filename); printf(BOLDBLUE " Crate = %s, Board Type = %d, Detector = %d \n" RESET, crate, crate_board, crate_det); while ((ch = getc(pFile)) != EOF) { if ( ch == '#' || ch == '#' || ch == '=' ) { while (getc(pFile) != '\n') {} } else if( ch == '\n' ) {} else { ungetc(ch,pFile); if(fgets(str_tmp, sizeof(str_tmp), pFile)){ if(debug) printf(" STR_TMP READ FROM FILE: %s \n",str_tmp); memset(str,0,sizeof(str)); memset(keyword,0,sizeof(keyword)); args_assigned = sscanf(str_tmp,"%s",str); if(args_assigned != 1) memset(str,0,sizeof(str)); if(debug) printf("args_assigned: %d %d STRING: %s \n", args_assigned, det_comp, str); /* Read configuration for sub-detectors */ if(args_assigned == 1){ if(strncmp(str, "TRIGGER", 7) == 0){ printf(" TRIGGER config found \n"); det_comp = trigger; } if(strncmp(str, "GLOBAL", 6) == 0){ printf(" GLOBAL config found \n"); det_comp = global; } if(strncmp(str, "FCAL", 4) == 0){ printf(" FCAL config found \n"); det_comp = fcal; } if(strncmp(str, "BCAL", 4) == 0){ printf(" BCAL config found \n"); det_comp = bcal; } if(strncmp(str, "CDC", 3) == 0){ printf(" CDC config found \n"); det_comp = cdc; } if(strncmp(str, "FDC", 3) == 0){ printf(" FDC config found \n"); det_comp = fdc; } if(strncmp(str, "TOF", 3) == 0){ printf(" TOF config found \n"); det_comp = tof; } if(strncmp(str, "ST", 2) == 0){ printf(" ST config found \n"); det_comp = st; } if(strcmp(str, "PS") == 0){ printf(" PS config found \n"); det_comp = ps; } if(strcmp(str, "PSC") == 0){ printf(" PSC config found \n"); det_comp = psc; } if(strncmp(str, "TAGM", 4) == 0){ printf(" TAGM config found \n"); det_comp = tagm; } if(strncmp(str, "TAGH", 4) == 0){ printf(" TAGH config found \n"); det_comp = tagh; } } /* ========== Trigger Settings ========== */ if(det_comp == trigger){ args = sscanf (str_tmp, "%s %s", keyword, str); if(debug){ printf("\n"); printf(" STRTMP %s \n", str_tmp); printf(" KEYWORD %s \n", keyword); printf(" STR %s \n", str); printf("\n"); } #ifdef SHM_BUF if(strcmp("CALIBRATION",keyword) == 0){ sscanf (str_tmp, "%*s %d", &CALIBRATION_FLAG); } printf("det_comp=%d keyword=%s CALIBRATION_FLAG=%d \n",det_comp,keyword,CALIBRATION_FLAG); #endif if(strcmp("TS_TRIG_TYPE",keyword) == 0){ sscanf (str_tmp, "%*s %d", &ts_bd.trig_type); } SCAN_TS_GTP_PRES("TS_GTP_PRES", ts_bd.gtp_pres); if(strcmp("BLOCKLEVEL",keyword) == 0){ sscanf (str_tmp, "%*s %d", &ts_bd.blocklevel); } if(strcmp("BUFFERLEVEL",keyword) == 0){ sscanf (str_tmp, "%*s %d", &ts_bd.bufferlevel); } SCAN_SOFT_TRIG("TS_SOFT_TRIG",ts_bd.ts_soft_trig); SCAN_TD_SLOTS("TS_TD_SLOTS",ts_bd.ts_td_slots); SCAN_FP_INPUTS("TS_FP_INPUTS",ts_bd.ts_fp_inputs); if(strcmp("TI_MASTER_TRIG",keyword) == 0){ sscanf (str_tmp, "%*s %d", &ti_master_trig); ti_bd.ti_master_trig = ti_master_trig; } if(strcmp("TI_MASTER",keyword) == 0){ sscanf (str_tmp, "%*s %d", &ti_master); ti_bd.ti_master = ti_master; } SCAN_SOFT_TRIG("TI_SOFT_TRIG",ti_bd.ti_soft_trig); SCAN_FP_INPUTS("TI_FP_INPUTS",ti_bd.ti_fp_inputs); SCAN_TI_FIBER("TI_FIBER_EN",ti_bd.ti_fiber_en); if(strcmp("TI_FIBER_LATENCY_OFFSET",keyword) == 0){ sscanf (str_tmp, "%*s %x", &fiber_latency); ti_bd.fiber_latency = fiber_latency; } if(strcmp("TRIG_DELAY",keyword) == 0){ sscanf (str_tmp, "%*s %d", &trig_delay); } if(strcmp("DAC_CALIB",keyword) == 0){ sscanf (str_tmp, "%*s %d", &dac_calib); } SCAN_SSP("SSP_SLOT",ssp); SCAN_EQ("TRIG_EQ",gtp_eq); SCAN_TRIG("TRIG_TYPE",gtp_trig); } /* ========== End Trigger ========== */ /* ========== Global Settings ========== */ if(det_comp == global){ args = sscanf (str_tmp, "%s %s", keyword, str); #ifdef SHM_BUF if(strcmp("CALIBRATION",keyword) == 0){ sscanf (str_tmp, "%*s %d", &CALIBRATION_FLAG); } printf("det_comp=%d keyword=%s CALIBRATION_FLAG=%d \n",det_comp,keyword,CALIBRATION_FLAG); #endif if(strcmp("DAC_CALIB",keyword) == 0){ sscanf (str_tmp, "%*s %d", &dac_calib); } if (crate_board == f1tdc){ SL_MIN = 3; SL_MAX = NBD_F1TDC; SCAN_B_FSETS("F1TDC_BIN_SIZE", f1[jj].bin_size,SL_MIN,SL_MAX); for(jj = SL_MIN; jj < SL_MAX; jj++) f1[jj].global = 1; } } /* ========== End Global ========== */ /* ========== FADC250 for FCAL, BCAL, TOF, and ST ========== */ if( ((det_comp == fcal) && (crate_board == fadc250) && (crate_det == fcal)) || ((det_comp == bcal) && (crate_board == fadc250) && (crate_det == bcal)) || ((det_comp == tof) && (crate_board == fadc250) && (crate_det == tof)) || ((det_comp == st) && (crate_board == fadc250) && (crate_det == st)) || ((det_comp == ps) && (crate_board == fadc250) && (crate_det == ps)) || ((det_comp == ps) && (crate_board == fadc250) && (crate_det == psc)) || ((det_comp == psc) && (crate_board == fadc250) && (crate_det == psc)) || ((det_comp == tagm) && (crate_board == fadc250) && (crate_det == tagm)) || ((det_comp == tagh) && (crate_board == fadc250) && (crate_det == tagh)) ){ SL_MIN = 3; SL_MAX = NBD_FADC250; if( (det_comp == ps) && (crate_det == psc) ){ SL_MIN = 3; SL_MAX = 6; } if( (det_comp == psc) && (crate_det == psc) ){ SL_MIN = 6; SL_MAX = 7; } args = sscanf (str_tmp, "%s %s", keyword, str); SCAN_B_SETS("FADC250_MODE", fa250[jj].mode,SL_MIN,SL_MAX); SCAN_B_SETS("FADC250_W_OFFSET", fa250[jj].winOffset,SL_MIN,SL_MAX); SCAN_B_SETS("FADC250_W_WIDTH", fa250[jj].winWidth,SL_MIN,SL_MAX); SCAN_B_SETS("FADC250_NSB", fa250[jj].nsb,SL_MIN,SL_MAX); SCAN_B_SETS("FADC250_NSA", fa250[jj].nsa,SL_MIN,SL_MAX); SCAN_B_SETS("FADC250_NPEAK", fa250[jj].npeak,SL_MIN,SL_MAX); SCAN_B_SETS("FADC250_TRIG_THR", fa250[jj].trig_thr,SL_MIN,SL_MAX); SCAN_B_SETS("FADC250_TRIG_NSB", fa250[jj].trig_nsb,SL_MIN,SL_MAX); SCAN_B_SETS("FADC250_TRIG_NSA", fa250[jj].trig_nsa,SL_MIN,SL_MAX); SCAN_B_XSETS("FADC250_F_REV", fa250[jj].f_rev,SL_MIN,SL_MAX); SCAN_B_XSETS("FADC250_B_REV", fa250[jj].b_rev,SL_MIN,SL_MAX); SCAN_B_XSETS("FADC250_TYPE", fa250[jj].b_ID,SL_MIN,SL_MAX); SCAN_TDP("FADC250_TRIG_BL",fa250[jj].trig_bl,SL_MIN,SL_MAX); SCAN_TDP("FADC250_READ_THR",fa250[jj].read_thr,SL_MIN,SL_MAX); SCAN_B_SSETS("FADC250_COM_DIR", fa250[jj].conf_common_dir); SCAN_B_SSETS("FADC250_COM_VER", fa250[jj].conf_common_ver); SCAN_B_SSETS("FADC250_USER_DIR", fa250[jj].conf_user_dir); SCAN_B_SSETS("FADC250_USER_VER", fa250[jj].conf_user_ver); if(strcmp("CTP_BCAL_THR",keyword) == 0) sscanf (str_tmp, "%*s %d", &ctp.BCALThreshold); if(strcmp("CTP_BCAL_WID",keyword) == 0) sscanf (str_tmp, "%*s %d", &ctp.BCALWindowWidth); if(strcmp("CTP_THR",keyword) == 0) sscanf (str_tmp, "%*s %d", &ctp.FinalSumThreshold); if(strcmp("CTP_HIT_WID",keyword) == 0) sscanf (str_tmp, "%*s %d", &ctp.HitWindowWidth); if(strcmp("CTP_USE",keyword) == 0) sscanf (str_tmp, "%*s %d", &ctp.used); } // FADC250 /* ========== FADC125 for CDC and FDC ========== */ if( ((det_comp == cdc) && (crate_board == fadc125) && (crate_det == cdc)) || ((det_comp == fdc) && (crate_board == fadc125) && (crate_det == fdc)) ){ SL_MIN = 3; SL_MAX = NBD_FADC250; args = sscanf (str_tmp, "%s %s", keyword, str); SCAN_B_SETS("FADC125_MODE", fa125[jj].mode,SL_MIN,SL_MAX); SCAN_B_SETS("FADC125_W_OFFSET", fa125[jj].winOffset,SL_MIN,SL_MAX); SCAN_B_SETS("FADC125_W_WIDTH", fa125[jj].winWidth,SL_MIN,SL_MAX); SCAN_B_SETS("FADC125_NSB", fa125[jj].nsb,SL_MIN,SL_MAX); SCAN_B_SETS("FADC125_NSA", fa125[jj].nsa,SL_MIN,SL_MAX); SCAN_B_SETS("FADC125_NPEAK", fa125[jj].npeak,SL_MIN,SL_MAX); SCAN_B_XSETS("FADC125_F_REV", fa125[jj].f_rev,SL_MIN,SL_MAX); SCAN_B_XSETS("FADC125_B_REV", fa125[jj].b_rev,SL_MIN,SL_MAX); SCAN_B_XSETS("FADC125_P_REV", fa125[jj].p_rev,SL_MIN,SL_MAX); SCAN_B_XSETS("FADC125_TYPE", fa125[jj].b_ID,SL_MIN,SL_MAX); SCAN_B_FSETS("FADC125_THR_FACT", fa125[jj].thr_fact ,SL_MIN,SL_MAX); SCAN_TDP_125("FADC125_THR",fa125[jj].read_thr); SCAN_TDP_125("FADC125_DAC",fa125[jj].dac); SCAN_B_SSETS("FADC125_COM_DIR", fa125[jj].conf_common_dir); SCAN_B_SSETS("FADC125_COM_VER", fa125[jj].conf_common_ver); SCAN_B_SSETS("FADC125_USER_DIR", fa125[jj].conf_user_dir); SCAN_B_SSETS("FADC125_USER_VER", fa125[jj].conf_user_ver); } // End CDC and FDC /* ========== DSC2 for BCAL, TOF, ST, and PSC ========== */ if( ((det_comp == tof) && (crate_board == dsc2) && (crate_det == tof)) || ((det_comp == psc) && (crate_board == dsc2) && (crate_det == st)) || //PSC settings; rocstpsc2 belongs to PS ((det_comp == st) && (crate_board == dsc2) && (crate_det == st)) || ((det_comp == tagm) && (crate_board == dsc2) && (crate_det == tagm)) || ((det_comp == tagh) && (crate_board == dsc2) && (crate_det == tagh)) || ((det_comp == bcal) && (crate_board == dsc2) && (crate_det == bcal))){ SL_MIN = 3; SL_MAX = NBD_DSC2; if( (det_comp == psc) && (crate_det == st) ){ SL_MIN = 6; SL_MAX = 7; } if( (det_comp == st) && (crate_det == st) ){ SL_MIN = 4; SL_MAX = 6; } args = sscanf (str_tmp, "%s %s", keyword, str); if(strcmp(keyword,"DSC2_THRESHOLD") == 0){ sscanf (str_tmp, "%*s %d %d", &i1, &i2); for(ii = SL_MIN; ii < SL_MAX; ii++) for(jj = 0; jj < MAX_DSC2_CH; jj++){ dsc[ii].TDCThreshold[jj] = i1; dsc[ii].TRGThreshold[jj] = i2; } } if(strcmp(keyword,"DSC2_WIDTH") == 0) { sscanf (str_tmp, "%*s %d %d", &i1, &i2); for(ii = SL_MIN; ii < SL_MAX; ii++){ dsc[ii].TDCWidth = i1; dsc[ii].TRGWidth = i2; } } } // TOF DSC2 /* ========== F1TDC for BCAL, ST, PSC, TAGM, and TAGH ========== */ if( ((det_comp == bcal) && (crate_board == f1tdc) && (crate_det == bcal)) || ((det_comp == psc) && (crate_board == f1tdc) && (crate_det == st)) || ((det_comp == st) && (crate_board == f1tdc) && (crate_det == st)) || ((det_comp == tagm) && (crate_board == f1tdc) && (crate_det == tagm)) || ((det_comp == tagh) && (crate_board == f1tdc) && (crate_det == tagm)) ){ printf(" I AM HERE \n"); // High-resolution, synchronous for(ii = 3; ii < NBD_F1TDC; ii++) f1[ii].version = 2; SL_MIN = 3; SL_MAX = NBD_F1TDC; if( (det_comp == psc) && (crate_det == st) ){ SL_MIN = 4; SL_MAX = 5; } if( (det_comp == st) && (crate_det == st) ){ SL_MIN = 3; SL_MAX = 4; } if( (det_comp == tagm) && (crate_det == tagm) ){ SL_MIN = 3; SL_MAX = 7; } if( (det_comp == tagh) && (crate_det == tagm) ){ SL_MIN = 7; SL_MAX = 17; } args = sscanf (str_tmp, "%s %s", keyword, str); SCAN_B_FSETS("F1TDC_BIN_SIZE", f1[jj].bin_size,SL_MIN,SL_MAX); // Rewrite Global bin size for F1TDC if(strcmp(keyword,"F1TDC_BIN_SIZE") == 0){ for(jj = SL_MIN; jj < SL_MAX; jj++) f1[jj].global = 0; } SCAN_B_FSETS("F1TDC_LATENCY", f1[jj].latency,SL_MIN,SL_MAX); SCAN_B_FSETS("F1TDC_WINDOW", f1[jj].window,SL_MIN,SL_MAX); SCAN_B_SETS("F1TDC_CLOCK", f1[jj].clock,SL_MIN,SL_MAX); } // High-Resolution F1TDCs /* ========== F1TDC for FDC ========== */ if( (det_comp == fdc) && (crate_board == f1tdc) && (crate_det == fdc)){ // Maximum F1 slot 16, high-resolution board in slot 17 of rocfdc1 SL_MIN = 3; SL_MAX = 17; // Low-resolution, synchronous for(ii = 3; ii < 17; ii++) f1[ii].version = 3; sscanf (str_tmp, "%s %s", keyword, str); SCAN_B_FSETS("F1TDC_BIN_SIZE", f1[jj].bin_size,SL_MIN,SL_MAX); SCAN_B_FSETS("F1TDC_LATENCY", f1[jj].latency,SL_MIN,SL_MAX); SCAN_B_FSETS("F1TDC_WINDOW", f1[jj].window,SL_MIN,SL_MAX); SCAN_B_SETS("F1TDC_CLOCK", f1[jj].clock,SL_MIN,SL_MAX); // Rewrite Global bin size for F1TDC if(strcmp(keyword,"F1TDC_BIN_SIZE") == 0){ for(jj = SL_MIN; jj < SL_MAX; jj++) f1[jj].global = 0; } // High-resolution board SCAN_B_FSETS("F1TDC_HR_BIN_SIZE", f1[SL_HR].bin_size, SL_HR, SL_HR + 1); SCAN_B_FSETS("F1TDC_HR_LATENCY", f1[SL_HR].latency, SL_HR, SL_HR + 1); SCAN_B_FSETS("F1TDC_HR_WINDOW", f1[SL_HR].window, SL_HR, SL_HR + 1); // Rewrite Global bin size for F1TDC if(strcmp(keyword,"F1TDC_BIN_SIZE") == 0){ for(jj = SL_HR; jj < SL_HR + 1; jj++) f1[jj].global = 0; } f1[SL_HR].version = 2; } // Low-Resolution F1TDCs /* ========== TOF CAEN1290 TDC ========== */ if( (det_comp == tof) && (crate_board == tdc1290) && (crate_det == tof) ){ SL_MIN = 3; SL_MAX = NBD_FADC250; sscanf (str_tmp, "%s %s", keyword, str); SCAN_B_SETS("TDC1290_W_WIDTH", caen1290[jj].window_width,SL_MIN,SL_MAX); SCAN_B_SETS("TDC1290_W_OFFSET", caen1290[jj].window_offset,SL_MIN,SL_MAX); SCAN_B_SETS("TDC1290_W_EXTRA", caen1290[jj].window_extra,SL_MIN,SL_MAX); SCAN_B_SETS("TDC1290_W_REJECT", caen1290[jj].window_reject,SL_MIN,SL_MAX); SCAN_B_SETS("TDC1290_BLT_EVENTS", caen1290[jj].blt_Events,SL_MIN,SL_MAX); SCAN_B_SETS("TDC1290_N_HITS", caen1290[jj].n_Hits,SL_MIN,SL_MAX); SCAN_B_SETS("TDC1290_ALMOSTFULL", caen1290[jj].almostFullLevel,SL_MIN,SL_MAX); SCAN_B_SETS("TDC1290_OUT_PROG", caen1290[jj].outProgControl,SL_MIN,SL_MAX); SCAN_B_SETS("TDC1290_A24_A32", caen1290[jj].a24_a32,SL_MIN,SL_MAX); SCAN_B_SETS("TDC1290_SNGL_BLT", caen1290[jj].sngl_blt_mblt,SL_MIN,SL_MAX); SCAN_B_SETS("TDC1290_SST_RATE", caen1290[jj].sst_rate,SL_MIN,SL_MAX); SCAN_B_SETS("TDC1290_BERR_FIFO", caen1290[jj].berr_fifo,SL_MIN,SL_MAX); SCAN_B_SETS("TDC1290_EDGE", caen1290[jj].edge,SL_MIN,SL_MAX); } // TOF CAEN1290 TDC } } } fclose(pFile); return 0; } int read_conf_common(char *crate){ int debug = 0; FILE *pFile; int ch; int ii = 0, jj; int val; int args, msk[16], msk1[18]; int ch_dis_mask[3]; float mskf[18]; int slot = -1; int first = -1, last = -1; char sn[NBD_FADC250][12]; char str[STRLEN], str2[STRLEN], str_tmp[STRLEN]; char keyword[ROCLEN]; int line = 0; int SL_MIN = 0; int SL_MAX = 0; det_type crate_det = get_det_type(crate ); if(crate_det == det_unknown) { printf(BOLDRED "\n FATAL: Read_conf_common: Unknown detector type for crate %s \n" RESET, crate); return(-2); } bd_type crate_board = get_board_type(crate ); if(crate_board == bd_unknown) { printf(BOLDRED "\n FATAL: Read_conf_common: Unknown board type for crate %s \n" RESET, crate); return(-2); } /* Take user configuration file name from the flobal config file */ char myfile[STRLEN]=""; switch(crate_board){ case fadc250: if(debug){ printf(" STRING LENGTH = %d %s \n", strlen(fa250[3].conf_common_dir), fa250[3].conf_common_dir); printf(" STRING LENGTH = %d %s \n", strlen(fa250[3].conf_common_ver), fa250[3].conf_common_ver); } if((strlen(fa250[3].conf_common_dir) != 0) && (strlen(fa250[3].conf_common_ver) != 0) ) sprintf(myfile,"%s/%s_fadc250_%s.cnf", fa250[3].conf_common_dir,crate,fa250[3].conf_common_ver); else { printf(BOLDRED "\n FATAL: Have to set FADC250_COM_DIR and FADC250_COM_VER in the global configuration file %s %s \n" RESET, fa250[3].conf_common_dir, fa250[3].conf_common_ver ); return(-2); } break; case fadc125: if(debug){ printf(" STRING LENGTH = %d %s \n", strlen(fa125[3].conf_common_dir), fa125[3].conf_common_dir); printf(" STRING LENGTH = %d %s \n", strlen(fa125[3].conf_common_ver), fa125[3].conf_common_ver); } if((strlen(fa125[3].conf_common_dir) != 0) && (strlen(fa125[3].conf_common_ver) != 0) ) sprintf(myfile,"%s/%s_fadc125_%s.cnf", fa125[3].conf_common_dir,crate,fa125[3].conf_common_ver); else { printf(BOLDRED "\n FATAL: Have to set FADC125_COM_DIR and FADC125_COM_VER in the global configuration file %s %s \n" RESET, fa125[3].conf_common_dir, fa125[3].conf_common_ver ); return(-2); } break; case tdc1290: return(0); break; case dsc2: return(0); break; case f1tdc: return(0); break; default: break; } /* Open Global Configuration File */ pFile = fopen(myfile, "r"); if(pFile == NULL) { printf(BOLDRED "\n FATAL: Read_conf_common: Cannot open config file %s \n" RESET, myfile); return(-2); } printf(BOLDBLUE "\n Reading Common Parameters from %s \n" RESET, myfile); while ((ch = getc(pFile)) != EOF) { if(debug) printf(" %d %d %d \n",ch,' ','='); if ( ch == '#' || ch == '#' || ch == '=' ) { while (getc(pFile) != '\n') {} } else if( ch == '\n' ) {} else { ungetc(ch,pFile); if(fgets(str_tmp, sizeof(str_tmp), pFile)){ memset(str,0,sizeof(str)); memset(keyword,0,sizeof(keyword)); switch(crate_board){ case fadc250: sscanf (str_tmp, "%s %s", keyword, str); if(strcmp(keyword,"CRATE") == 0){ if(strcmp(crate, str) != 0){ printf(BOLDRED "\nRead_config_common: Wrong crate name in config file, %s\n" RESET, str); return(-2); } } SL_MIN = 3; SL_MAX = NBD_FADC250; SCAN_TDP("FADC250_DAC",fa250[jj].dac,SL_MIN,SL_MAX); SCAN_SLOT("FADC250_SLOTS",fa250[slot].group); if( (slot >= 3) && (slot != 11) && (slot != 12) && (slot < 21)){ SCAN_TDP("FADC250_DAC",fa250[slot].dac,SL_MIN,SL_MAX); SCAN_TDP_ALLCH("FADC250_ALLCH_DAC",fa250[slot].dac); } if(strcmp(keyword,"FADC250_ALLSN") == 0) { args = sscanf (str_tmp, "%*s %s %s %s %s %s %s %s %s %s %s \ %s %s %s %s %s %s %s %s %s %s %s", &sn[ 1][0], &sn[ 2][0], &sn[ 3][0], &sn[ 4][0], &sn[ 5][0], &sn[ 6][0], &sn[ 7][0], &sn[ 8][0], &sn[ 9][0], &sn[10][0], &sn[11][0], &sn[12][0], &sn[13][0], &sn[14][0], &sn[15][0], &sn[16][0], &sn[17][0], &sn[18][0], &sn[19][0], &sn[20][0], &sn[21][0]); if(args != 21) { printf(BOLDRED "\n Read_conf_common: Wrong number of SNs = %d, should be 21 \n\n" RESET, args); printf(" Read string: %s \n",str_tmp); return(-2); } for(ii = 1; ii < NBD_FADC250; ii++) sprintf((char *)fa250[ii].SerNum, "%s", sn[ii]); } break; case fadc125: sscanf (str_tmp, "%s %s", keyword, str); if(strcmp(keyword,"CRATE") == 0){ if(strcmp(crate, str) != 0){ printf(BOLDRED "\nRead_config_common: Wrong crate name in config file, %s\n" RESET, str); return(-2); } } if(strcmp(keyword,"FADC125_ALLSN") == 0) { args = sscanf (str_tmp, "%*s %s %s %s %s %s %s %s %s %s %s \ %s %s %s %s %s %s %s %s %s %s %s", &sn[ 1][0], &sn[ 2][0], &sn[ 3][0], &sn[ 4][0], &sn[ 5][0], &sn[ 6][0], &sn[ 7][0], &sn[ 8][0], &sn[ 9][0], &sn[10][0], &sn[11][0], &sn[12][0], &sn[13][0], &sn[14][0], &sn[15][0], &sn[16][0], &sn[17][0], &sn[18][0], &sn[19][0], &sn[20][0], &sn[21][0]); if(args != 21) { printf("\n Read_conf_common: Wrong number of SNs %d, should be 21 :: %s\n\n",args,str_tmp); return(-5); } for(ii = 1; ii < NBD_FADC125; ii++) sprintf((char *)fa125[ii].SerNum, "%s", sn[ii]); } SCAN_SLOT("FADC125_SLOTS", fa125[slot].group); // printf("AA %s BB %s \n",keyword, str); SCAN_FA125_MASK("FADC125_CH_DIS",fa125[slot].ch_disable); SCAN_FA125_DAC_THR("FADC125_DAC_CH_", fa125[slot].dac); SCAN_TDP_125("FADC125_DAC",fa125[slot].dac); SCAN_FA125_DAC_THR("FADC125_THR_CH_", fa125[slot].read_thr); SCAN_TDP_125("FADC125_THR",fa125[slot].read_thr); SCAN_FA125_SIG("FADC125_SIG_CH_", fa125[slot].sig); SCAN_FA125_BL("FADC125_BL_CH_", fa125[slot].bl); break; default: printf(BOLDRED "read_conf_common: Unknown board type %d. Exit" RESET, crate_board); return(-3); break; } } } } fclose(pFile); return 0; } int read_conf_user(char *crate){ int debug = 1; FILE *pFile; int ch; int jj; int args, msk[16], msk1[18]; int ch_dis_mask[3]; int slot = -1; int first = -1, last = -1; unsigned int ui1; char str_tmp[STRLEN]; char keyword[ROCLEN]; char str[150], str2[STRLEN]; int line = 0; det_type crate_det = get_det_type(crate ); if(crate_det == det_unknown) { printf(BOLDRED "\n FATAL: Read_conf_user: Unknown detector type for crate %s \n" RESET, crate); return(-2); } bd_type crate_board = get_board_type(crate ); if(crate_board == bd_unknown) { printf(BOLDRED "\n FATAL: Read_conf_user: Unknown board type for crate %s \n" RESET, crate); return(-2); } /* Take user configuration file name from the flobal config file */ char myfile[STRLEN]="";; switch(crate_board){ case fadc250: if(debug){ printf(" STRING LENGTH = %d %s \n", strlen(fa250[3].conf_user_dir), fa250[3].conf_user_dir); printf(" STRING LENGTH = %d %s \n", strlen(fa250[3].conf_user_ver), fa250[3].conf_user_ver); } if((strlen(fa250[3].conf_user_dir) != 0) && (strlen(fa250[3].conf_user_ver) != 0) ) sprintf(myfile,"%s/%s_%s.cnf", fa250[3].conf_user_dir,crate,fa250[3].conf_user_ver); break; case fadc125: if(debug){ printf(" STRING LENGTH = %d %s \n", strlen(fa125[3].conf_user_dir), fa125[3].conf_user_dir); printf(" STRING LENGTH = %d %s \n", strlen(fa125[3].conf_user_ver), fa125[3].conf_user_ver); } if((strlen(fa125[3].conf_user_dir) != 0) && (strlen(fa125[3].conf_user_ver) != 0) ) sprintf(myfile,"%s/%s_%s.cnf", fa125[3].conf_user_dir,crate,fa125[3].conf_user_ver); break; default: break; } if(strlen(myfile) == 0){ printf(BOLDBLUE "\n No user configuration file is used \n" RESET ); return 0; } /* Open Global Configuration File */ pFile = fopen(myfile, "r"); if(pFile == NULL) { printf(BOLDRED "\n No user configuration file found for crate %s. Proceed with the default configuration \n" RESET, crate); return(0); } printf(BOLDMAGENTA "\n Read User Configuration file %s \n" RESET, myfile); printf(BOLDMAGENTA " Crate = %s Board type = %d, Detector = %d \n" RESET, crate, crate_board, crate_det); while ((ch = getc(pFile)) != EOF) { if(debug) printf(" %d %d %d \n",ch,' ','='); if ( ch == '#' || ch == '#' || ch == '=' ) { while (getc(pFile) != '\n') {} line++; } else if( ch == '\n' ) {line++;} else { ungetc(ch,pFile); if(fgets(str_tmp, sizeof(str_tmp), pFile)){ line++; if(debug) printf(" Board type = %d \n", crate_board); memset(str,0,sizeof(str)); memset(keyword,0,sizeof(keyword)); switch(crate_board){ case fadc250: args = sscanf (str_tmp, "%s %s", keyword, str); if(args != 2) break; if(strcmp(keyword,"FADC250_NOT_USED") == 0) { slot = -1; SCAN_MSK; if(debug) printf("\nReadConfigFile: args = %d \n",args); for(jj=0; jj20) { printf("\n Read_conf_user: Wrong slot number %d, %s\n",slot,str_tmp); continue; } fa250[slot].group = 0; } slot = -1; } SCAN_SLOT("FADC250_SLOTS", fa250[slot].group); if( (slot >= 3) && (slot != 11) && (slot != 12) && (slot < 21)){ SCAN_B_MSKS("FADC250_ADC_MASK", fa250[slot].chDisMask); SCAN_B_MSKS("FADC250_TRG_MASK", fa250[slot].trigMask); debug = 1; if(debug){ printf(" CHECK CHANNEL DISABLE MASK NEW = %d %x \n", slot, fa250[slot].chDisMask ); printf(" TRIGGER MASK = %d %x \n", slot, fa250[slot].trigMask ); } debug = 0; } break; case fadc125: args = sscanf (str_tmp, "%s %s", keyword, str); if(args != 2) break; if(strcmp(keyword,"FADC125_NOT_USED") == 0) { slot = -1; SCAN_MSK; if(debug) printf("\nReadConfigFile: args = %d %s \n",args, str_tmp); for(jj = 0; jj < args; jj++) { slot = msk[jj]; if(slot<3 || slot==11 || slot==12 || slot>20) { printf("\n Read_conf_user: Wrong slot number %d, %s\n",slot,str_tmp); continue; } fa125[slot].group = 0; } slot = -1; } if(strcmp(keyword,"FADC125_SLOTS") == 0) { slot = -1; SCAN_MSK; if(args == 1){ /* Don't allow groups. Each Slot should have an entry in the file */ slot = msk[0]; if(slot < 3 || slot == 11 || slot == 12 || slot > 20){ printf(BOLDRED "\nRead_conf: Wrong slot number %d, %s\n" RESET, slot,str_tmp); return(-2); } } else { printf(BOLDRED "\n Read_conf: Wrong number of slots in FADC_SLOTS %d. Only one slot is allowed. Exit \n" RESET, args); return(-2); } } SCAN_FA125_DAC_THR("FADC125_DAC_CH_", fa125[slot].dac); SCAN_FA125_DAC_THR("FADC125_THR_CH_", fa125[slot].read_thr); SCAN_FA125_MASK("FADC125_CH_DIS",fa125[slot].ch_disable); if(strncmp(keyword,"FADC125_MASK_",12) == 0){ SCAN_MSK1; ui1 = 0; for(jj = 0; jj < 18; jj++) { if((msk1[jj] < 0) || (msk1[jj] > 1)) { printf("\nReadConfigFile: Wrong mask bit value, %d\n\n",msk1[jj]); return(-9); } ui1 |= (msk1[jj]< 3) { printf("ERROR: mask jj = %d, must be between 0 and 3\n",jj); return(-9); } fa125[slot].mask[jj] = ui1; } break; default: break; } } } } fclose(pFile); return 0; } int get_nbd_fadc250(int print){ int bd; int nbd = 0; for(bd = 3; bd < NBD_FADC250; bd++){ if(fa250[bd].group > 0) nbd++; if(print ) printf(" Group for board in slot %d = %d \n", bd, fa250[bd].group); } return nbd; } int get_nbd_fadc125(int print){ int bd; int nbd = 0; for(bd = 3; bd < NBD_FADC125; bd++){ if(fa125[bd].group > 0) nbd++; if(print ) printf(" Group for board in slot %d = %d \n", bd, fa125[bd].group); } return nbd; } void print_fadc250_conf(int slot){ int ch; if(fa250[slot].group <= 0) printf(" print_fadc250_conf: FADC250 in slot %d is not used in the configuration \n", slot); printf("\n===================================================\n"); printf("Slot = %d \n", slot); printf("Used = %d \n", fa250[slot].group); printf("Processing firmware = 0x%x \n", fa250[slot].f_rev); printf("Control firmware = 0x%x \n", fa250[slot].b_rev); printf(" FADC250_TYPE = 0x%x \n", fa250[slot].b_ID); printf(" FADC250_SN = %s \n", fa250[slot].SerNum); printf(" FADC250_MODE = %d \n", fa250[slot].mode); printf(" FADC250_W_OFFSET = %d \n", fa250[slot].winOffset); printf(" FADC250_W_WIDTH = %d \n", fa250[slot].winWidth); printf(" FADC250_NSB = %d \n", fa250[slot].nsb); printf(" FADC250_NSA = %d \n", fa250[slot].nsa); printf(" FADC250_NPEAK = %d \n", fa250[slot].npeak); printf(" FADC250_ADC_MASK = 0x%x \n", fa250[slot].chDisMask); printf(" FADC250_DAC = "); for(ch = 0; ch < MAX_FADC250_CH; ch++) printf(" %d", fa250[slot].dac[ch]); printf("\n"); printf(" FADC250_READ_THR = "); for(ch = 0; ch < MAX_FADC250_CH; ch++) printf(" %d", fa250[slot].read_thr[ch]); printf("\n"); printf("\n"); printf(" FADC250_TRIG_THR = %d \n", fa250[slot].trig_thr); printf(" FADC250_TRIG_NSB = %d \n", fa250[slot].trig_nsb); printf(" FADC250_TRIG_NSA = %d \n", fa250[slot].trig_nsa); printf(" FADC250_TRIG_MASK = 0x%x \n", fa250[slot].trigMask); printf(" FADC250_TRIG_BL = "); for(ch = 0; ch < MAX_FADC250_CH; ch++) printf(" %d", fa250[slot].trig_bl[ch]); printf("\n"); printf("\n"); printf(" FADC250_COM_DIR = %s \n", fa250[slot].conf_common_dir); printf(" FADC250_COM_VER = %s \n", fa250[slot].conf_common_dir); printf(" FADC250_USER_DIR = %s \n", fa250[slot].conf_user_dir); printf(" FADC250_USER_VER = %s \n", fa250[slot].conf_user_ver); } void print_fadc125_conf(int slot){ int ch; if(fa125[slot].group <= 0){ printf("\n"); printf(" print_fadc125_conf: FADC125 in slot %d is not used in the configuration \n", slot); } printf("========================================================================\n"); printf("Slot = %d \n", slot); printf("Used = %d \n", fa125[slot].group); printf("Firmware version = 0x%x \n", fa125[slot].f_rev); printf("FrontEnd version = 0x%x \n", fa125[slot].b_rev); printf("Processing version = 0x%x \n", fa125[slot].b_rev); printf(" FADC125_TYPE = 0x%x \n", fa125[slot].b_ID); printf(" FADC125_SN = %s \n", fa125[slot].SerNum); printf(" FADC125_MODE = %d \n", fa125[slot].mode); printf(" FADC125_W_OFFSET = %d \n", fa125[slot].winOffset); printf(" FADC125_W_WIDTH = %d \n", fa125[slot].winWidth); printf(" FADC125_NSB = %d \n", fa125[slot].nsb); printf(" FADC125_NSA = %d \n", fa125[slot].nsa); printf(" FADC125_NPEAK = %d \n", fa125[slot].npeak); printf("\n"); printf(" FADC125_THR_FACT = %f \n", fa125[slot].thr_fact); printf("\n"); printf("\n FADC125_DAC_CH_00_17 "); for(ch = 0; ch < 18; ch++) printf(" %d ", fa125[slot].dac[ch]); printf("\n FADC125_DAC_CH_18_35 "); for(ch = 18; ch < 36; ch++) printf(" %d ", fa125[slot].dac[ch]); printf("\n FADC125_DAC_CH_36_53 "); for(ch = 36; ch < 54; ch++) printf(" %d ", fa125[slot].dac[ch]); printf("\n FADC125_DAC_CH_54_71 "); for(ch = 54; ch < 72; ch++) printf(" %d ", fa125[slot].dac[ch]); printf("\n"); printf("\n"); printf(" FADC125_THR_CH_00_17 "); for(ch = 0; ch < 18; ch++) printf(" %d ", fa125[slot].read_thr[ch]); printf("\n FADC125_THR_CH_18_35 "); for(ch = 18; ch < 36; ch++) printf(" %d ", fa125[slot].read_thr[ch]); printf("\n FADC125_THR_CH_36_53 "); for(ch = 36; ch < 54; ch++) printf(" %d ", fa125[slot].read_thr[ch]); printf("\n FADC125_THR_CH_54_71 "); for(ch = 54; ch < 72; ch++) printf(" %d ", fa125[slot].read_thr[ch]); printf("\n"); printf("\n"); printf(" FADC125_BL_CH_00_17 "); for(ch = 0; ch < 18; ch++) printf(" %.1f ", fa125[slot].bl[ch]); printf("\n FADC125_BL_CH_18_35 "); for(ch = 18; ch < 36; ch++) printf(" %.1f ", fa125[slot].bl[ch]); printf("\n FADC125_BL_CH_36_53 "); for(ch = 36; ch < 54; ch++) printf(" %.1f ", fa125[slot].bl[ch]); printf("\n FADC125_BL_CH_54_71 "); for(ch = 54; ch < 72; ch++) printf(" %.1f ", fa125[slot].bl[ch]); printf("\n"); printf("\n"); printf(" FADC125_SIG_CH_00_17 "); for(ch = 0; ch < 18; ch++) printf(" %5.1f ", fa125[slot].sig[ch]); printf("\n FADC125_SIG_CH_18_35 "); for(ch = 18; ch < 36; ch++) printf(" %5.1f ", fa125[slot].sig[ch]); printf("\n FADC125_SIG_CH_36_53 "); for(ch = 36; ch < 54; ch++) printf(" %5.1f ", fa125[slot].sig[ch]); printf("\n FADC125_SIG_CH_54_71 "); for(ch = 54; ch < 72; ch++) printf(" %5.1f ", fa125[slot].sig[ch]); printf("\n"); printf("\n FADC125_MASK_00_17 "); for(ch = 0; ch < 18; ch++) if( (fa125[slot].mask[0] & (1 << ch)) == 0) printf(" 0"); else printf(" 1"); printf("\n FADC125_MASK_18_35 "); for(ch = 0; ch < 18; ch++) if( (fa125[slot].mask[1] & (1 << ch)) == 0) printf(" 0"); else printf(" 1"); printf("\n FADC125_MASK_36_53 "); for(ch = 0; ch < 18; ch++) if( (fa125[slot].mask[2] & (1 << ch)) == 0) printf(" 0"); else printf(" 1"); printf("\n FADC125_MASK_54_71 "); for(ch = 0; ch < 18; ch++) if( (fa125[slot].mask[3] & (1 << ch)) == 0) printf(" 0"); else printf(" 1"); printf("\n"); printf("\n"); printf(" FADC125_CH_DIS: 0x%x 0x%x 0x%x \n", fa125[slot].ch_disable[0], fa125[slot].ch_disable[1], fa125[slot].ch_disable[2]); printf(" FADC125_COM_DIR = %s \n", fa125[slot].conf_common_dir); printf(" FADC125_COM_VER = %s \n", fa125[slot].conf_common_ver); printf(" FADC125_USER_DIR = %s \n", fa125[slot].conf_user_dir); printf(" FADC125_USER_VER = %s \n", fa125[slot].conf_user_ver); } void print_ti_conf(){ int opt_port, port; printf("\n========================================================================\n"); printf("================== TI CONFIGURATION ==============================\n"); printf("========================================================================\n\n"); printf("TI_MASTER: %d \n", ti_bd.ti_master ); printf("\n"); printf("TI_MASTER_TRIG: %d \n", ti_bd.ti_master_trig ); printf("\n"); printf(" TI_SOFT_TRIG: \n"); printf(" Trigger type (type 1 or 2 for playback): %d \n", ti_bd.ti_soft_trig[0] ); printf(" Number of events to trigger: %d \n", ti_bd.ti_soft_trig[1] ); printf(" Period multiplier (depends on range 0-0x7FFF): %d \n", ti_bd.ti_soft_trig[2] ); printf(" Range: %d \n", ti_bd.ti_soft_trig[3] ); printf("\n"); printf("TI_FP_INPUTS = "); for(port = 0; port < 16; port++){ if( ti_bd.ti_fp_inputs & (1 << port)) printf(" %d", port+1); } printf("\n"); printf(" 0x%x \n",ti_bd.ti_fp_inputs); printf("TI_FIBER_EN: \n"); for(opt_port = 2; opt_port < 7; opt_port++) if(ti_bd.ti_fiber_en & (1 << (opt_port - 1))) printf(" %d ", opt_port); printf("\n"); printf("\n"); printf("TI_FIBER_LATENCY_OFFSET: 0x%x \n", ti_bd.fiber_latency); } void print_ts_conf(){ int slot; int port, lane; printf("\n========================================================================\n"); printf("================== TS CONFIGURATION ==============================\n"); printf("========================================================================\n\n"); printf("TS_TD_SLOTS = "); for(slot = 3; slot < 21; slot++){ if( ts_bd.ts_td_slots & (1 << slot)) printf(" %d", slot); } printf("\n"); printf(" 0x%x \n",ts_bd.ts_td_slots); printf("\n"); printf("TS_FP_INPUTS = "); for(port = 0; port < 16; port++){ if( ts_bd.ts_fp_inputs & (1 << port)) printf(" %d", port+1); } printf("\n"); printf(" 0x%x \n",ts_bd.ts_fp_inputs); printf("TRIG_TYPE = %d\n", ts_bd.trig_type); printf("BLOCKLEVEL = %d\n", ts_bd.blocklevel); printf("BUFFERLEVEL = %d\n", ts_bd.bufferlevel); printf("TS_SOFT_TRIG: \n"); printf(" Trigger type (type 1 or 2 for playback): %d \n", ts_bd.ts_soft_trig[0] ); printf(" Number of events to trigger: %d \n", ts_bd.ts_soft_trig[1] ); printf(" Period multiplier (depends on range 0-0x7FFF): %d \n", ts_bd.ts_soft_trig[2] ); printf(" Range: %d \n", ts_bd.ts_soft_trig[3] ); printf("\n"); printf("TS_GTP_PRES: \n"); for(lane = 0; lane < 32; lane++){ if(ts_bd.gtp_pres[lane] > 0){ printf("Lane: %d Factor: %d \n", lane, ts_bd.gtp_pres[lane] ); } } } void print_le_conf(){ int slot, ch; printf("\n========================================================================\n"); printf("================== LE CONFIGURATION ==============================\n"); printf("========================================================================\n\n"); for(slot = 3; slot < NBD_DSC2; slot++){ printf(" Slot = %d \n",slot); printf(" TDCWidth = %d TRGWidth = %d \n", dsc[slot].TDCWidth, dsc[slot].TRGWidth); printf(" TDCThreshold = "); for(ch = 0; ch < MAX_DSC2_CH; ch++){ printf(" %d", dsc[slot].TDCThreshold[ch]); } printf(" \n"); printf(" TRGThreshold = "); for(ch = 0; ch < MAX_DSC2_CH; ch++){ printf(" %d", dsc[slot].TRGThreshold[ch]); } printf(" \n"); printf(" \n"); } } void print_caen1290_conf(){ int slot; printf("\n========================================================================\n"); printf("================== CAEN 1290 TDC CONFIGURATION ==============================\n"); printf("========================================================================\n\n"); for(slot = 3; slot < NBD_TDC1290; slot++){ printf(" Slot = %d \n",slot); printf(" TDC1290_W_WIDTH = %d \n", caen1290[slot].window_width); printf(" TDC1290_W_OFFSET = %d \n", caen1290[slot].window_offset); printf(" TDC1290_W_EXTRA = %d \n", caen1290[slot].window_extra); printf(" TDC1290_W_REJECT = %d \n", caen1290[slot].window_reject); printf("\n"); printf(" TDC1290_BLT_EVENTS = %d \n", caen1290[slot].blt_Events); printf(" TDC1290_N_HITS = %d \n", caen1290[slot].n_Hits); printf(" TDC1290_ALMOSTFULL = %d \n", caen1290[slot].almostFullLevel); printf(" TDC1290_OUT_PROG = %d \n", caen1290[slot].outProgControl); printf("\n"); printf(" TDC1290_A24_A32 = %d \n", caen1290[slot].a24_a32); printf(" TDC1290_SNGL_BLT = %d \n", caen1290[slot].sngl_blt_mblt); printf(" TDC1290_SST_RATE = %d \n", caen1290[slot].sst_rate); printf(" TDC1290_BERR_FIFO = %d \n", caen1290[slot].berr_fifo); printf(" TDC1290_EDGE = %d \n", caen1290[slot].edge); printf(" \n"); } } void print_f1_conf(){ int slot; printf("\n========================================================================\n"); printf("================== F1TDC CONFIGURATION ==============================\n"); printf("========================================================================\n\n"); for(slot = 3; slot < NBD_F1TDC; slot++){ printf(" Slot = %d \n",slot); printf(" F1TDC_VERSION = %d \n", f1[slot].version); printf(" F1TDC_CLOCK = %d \n", f1[slot].clock); printf("\n"); printf(" F1TDC_WINDOW = %f \n", f1[slot].window); printf(" F1TDC_BIN_SIZE = %f \n", f1[slot].bin_size); printf(" F1TDC_LATENCY = %f \n", f1[slot].latency); printf(" Global Init = %d \n", f1[slot].global); printf("\n"); } } void init_all(){ int bd_slot, bd_ch, range, ntr, lane; // FADC250 for(bd_slot = 3; bd_slot < NBD_FADC250; bd_slot++){ fa250[bd_slot].group = -1; fa250[bd_slot].mode = 1; fa250[bd_slot].winOffset = 500; fa250[bd_slot].winOffset = 10; fa250[bd_slot].nsb = 3; fa250[bd_slot].nsa = 5; fa250[bd_slot].npeak = 1; fa250[bd_slot].trig_thr = 4095; fa250[bd_slot].trig_nsb = 3; fa250[bd_slot].trig_nsa = 5; fa250[bd_slot].trigMask = 0; fa250[bd_slot].chDisMask = 0; for(bd_ch = 0; bd_ch < MAX_FADC250_CH; bd_ch++){ fa250[bd_slot].dac[bd_ch] = 3200; fa250[bd_slot].read_thr[bd_ch] = 4095; fa250[bd_slot].trig_bl[bd_ch] = 4095; } } // DSC for(bd_slot = 3; bd_slot < NBD_DSC2; bd_slot++){ dsc[bd_slot].TDCChMask = 0; dsc[bd_slot].TRGChMask = 0; dsc[bd_slot].TDCWidth = 40; dsc[bd_slot].TRGWidth = 40; for(bd_ch = 0; bd_ch < MAX_DSC2_CH; bd_ch++){ dsc[bd_slot].TDCThreshold[bd_ch] = 1023; dsc[bd_slot].TRGThreshold[bd_ch] = 1023; } } // FADC125 for(bd_slot = 3; bd_slot < NBD_FADC125; bd_slot++){ fa125[bd_slot].mode = 1; fa125[bd_slot].winOffset = 500; fa125[bd_slot].winWidth = 25; fa125[bd_slot].nsb = 3; fa125[bd_slot].nsa = 7; fa125[bd_slot].npeak = 1; fa125[bd_slot].thr_fact = 0; for(range = 0; range < 3; range++) fa125[bd_slot].ch_disable[range] = 0; for(bd_ch = 0; bd_ch < MAX_FADC125_CH; bd_ch++){ fa125[bd_slot].dac[bd_ch] = 0x9000; fa125[bd_slot].read_thr[bd_ch] = 0xFFFF; fa125[bd_slot].sig[bd_ch] = 0; fa125[bd_slot].bl[bd_ch] = 0; } } // F1TDC for(bd_slot = 3; bd_slot < NBD_F1TDC; bd_slot++){ f1[bd_slot].bin_size = 0.056; f1[bd_slot].latency = 900; f1[bd_slot].window = 100; f1[bd_slot].version = 2; f1[bd_slot].global = -1; } // CAEN1290 TDC for(bd_slot = 3; bd_slot < NBD_TDC1290; bd_slot++){ caen1290[bd_slot].window_width = 100; caen1290[bd_slot].window_offset = 2000; caen1290[bd_slot].window_extra = 25; caen1290[bd_slot].window_reject = 50; caen1290[bd_slot].blt_Events = 1; caen1290[bd_slot].n_Hits = 64; caen1290[bd_slot].almostFullLevel = 16384; caen1290[bd_slot].outProgControl = 2; caen1290[bd_slot].a24_a32 = 2; caen1290[bd_slot].sngl_blt_mblt = 3; caen1290[bd_slot].sst_rate = 0; caen1290[bd_slot].berr_fifo = 1; caen1290[bd_slot].edge = 2; } // CTP ctp.BCALThreshold = 0; ctp.BCALWindowWidth = 0; ctp.FinalSumThreshold = 0; ctp.HitWindowWidth = 0; ctp.used = 1; // SSP for(bd_slot = 3; bd_slot < NBD_SSP; bd_slot++){ ssp[bd_slot].slot = 0; ssp[bd_slot].fiber_en = 0; ssp[bd_slot].sum_enable = 0; } // GTP EQ for(ntr = 0; ntr < MAX_EQ; ntr++){ gtp_eq[ntr].enable = 0; gtp_eq[ntr].delay = 0; gtp_eq[ntr].int_width = 0; } // GTP TRIG for(ntr = 0; ntr < MAX_TRIG; ntr++){ gtp_trig[ntr].gtp_lane = -1; gtp_trig[ntr].fcal_en = 0; gtp_trig[ntr].bcal_en = 0; gtp_trig[ntr].en_thr = 0; gtp_trig[ntr].latency = 0; gtp_trig[ntr].nhit = 0; gtp_trig[ntr].width = 0; } // TS for(lane = 0; lane < 32; lane++){ ts_bd.gtp_pres[lane] = 0; } } void print_ctp_conf(){ printf("\n========================================================================\n"); printf("================== CTP CONFIGURATION ==============================\n"); printf("========================================================================\n\n"); printf("\n"); printf(" CTP_BCAL_THR = %d \n ", ctp.BCALThreshold); printf("\n"); printf(" CTP_THR = %d \n ", ctp.FinalSumThreshold); printf("\n"); printf(" CTP_BCAL_WID = %d \n ", ctp.BCALWindowWidth); printf("\n"); printf(" CTP_HIT_WID = %d \n ", ctp.HitWindowWidth); printf("\n"); } void print_ssp_conf(){ int slot; printf("\n========================================================================\n"); printf("================== SSP CONFIGURATION ==============================\n"); printf("========================================================================\n\n"); printf(" SLOT FIBER_ENABLED SUM_ENABLE \n"); printf(" \n "); for(slot = 3; slot < NBD_SSP; slot++) if(ssp[slot].slot > 0) printf("%d 0x%02x %d \n ",ssp[slot].slot, ssp[slot].fiber_en, ssp[slot].sum_enable); printf("\n"); printf("\n"); } void print_gtp_conf(){ int ii; printf("\n========================================================================\n"); printf("================== GTP CONFIGURATION =============================\n"); printf("========================================================================\n\n"); int ntrig = 0; printf(" \n "); printf("GTP EQUATIONS \n"); printf(" \n "); printf("Number TYPE DELAY INT_WIDTH ENABLE \n"); printf(" \n "); for(ii = 0; ii < MAX_EQ; ii++) { if(gtp_eq[ii].enable == 1){ ntrig++; printf("%2d %7s %3d %4d %2d \n ",ntrig, gtp_eq[ii].type, gtp_eq[ii].delay, gtp_eq[ii].int_width, gtp_eq[ii].enable ); } } printf("\n"); printf("\n"); ntrig = 0; printf("Number TYPE LATENCY WIDTH FCAL_E BCAL_E EN_THR NHIT LANE \n"); printf(" \n "); for(ii = 0; ii < MAX_TRIG; ii++) { if(gtp_trig[ii].gtp_lane >= 0){ ntrig++; printf("%2d %7s %4d %3d %5d %5d %5d %2d %2d \n ",ntrig, gtp_trig[ii].type, gtp_trig[ii].latency, gtp_trig[ii].width, gtp_trig[ii].fcal_en, gtp_trig[ii].bcal_en, gtp_trig[ii].en_thr,gtp_trig[ii].nhit, gtp_trig[ii].gtp_lane); } } printf("\n"); printf("\n"); }