include # columns.h -- Column definitions for the output table. define ROOT_COLUMN_NAME "ROOTNAME" define ROOT 1 define MEAN_COLUMN_NAME "MEAN" define MEAN 2 define SIGMA_COLUMN_NAME "SIGMA" define SIGMA 3 define MAX_COLUMN_NAME "MAX" define MAX 4 define DNUM_COLUMN_NAME "SELECT_DIODE" define DNUM 5 define DIODE_COLUMN_NAME "EVENT_DIODES" define DIODE 6 define EVENT_COLUMN_NAME "EVENT_RATE" define EVENT 7 define ANTI_COLUMN_NAME "ANTI_COIN" define ANTI 8 define BACK_COLUMN_NAME "BACKGROUND" define BACK 9 define RAD_COLUMN_NAME "RADIATION" define RAD 10 define MAX_COLUMNS 10 #--------------------------------------------------------------------------- .help table May 92 hrs .ih NAME dst_stat_open -- Open the statistics tables. dst_stat_write -- Write the statistics to the specified table. .endhelp #--------------------------------------------------------------------------- procedure dst_stat_open (table_name, table, row) char table_name[ARB] # I: Name of table to open. pointer table # O: The table descriptor. int row # O: The current row of the table. # Declarations. int ip # Generic index. pointer sp # Stack pointer. pointer tmp # Temporary string. include "stat_table.com" # Function prototypes. int access(), strlen(), tbpsta(), tbtacc() pointer tbtopn() begin # If no name was specified, don't open anything. if (strlen (table_name) == 0) { table = NULL } else { call smark(sp) call salloc (tmp, SZ_LINE, TY_CHAR) # Iniitalize the column names. call strcpy (ROOT_COLUMN_NAME, col_names[1,ROOT], SZ_COLNAME) call strcpy (MEAN_COLUMN_NAME, col_names[1,MEAN], SZ_COLNAME) call strcpy (SIGMA_COLUMN_NAME, col_names[1,SIGMA], SZ_COLNAME) call strcpy (MAX_COLUMN_NAME, col_names[1,MAX], SZ_COLNAME) call strcpy (DNUM_COLUMN_NAME, col_names[1,DNUM], SZ_COLNAME) call strcpy (DIODE_COLUMN_NAME, col_names[1,DIODE], SZ_COLNAME) call strcpy (EVENT_COLUMN_NAME, col_names[1,EVENT], SZ_COLNAME) call strcpy (ANTI_COLUMN_NAME, col_names[1,ANTI], SZ_COLNAME) call strcpy (BACK_COLUMN_NAME, col_names[1,BACK], SZ_COLNAME) call strcpy (RAD_COLUMN_NAME, col_names[1,RAD], SZ_COLNAME) if (access (table_name, 0, 0) == YES) { if (tbtacc (table_name) == YES) { table = tbtopn (table_name, READ_WRITE, 0) call tbcfnd (table, col_names, columns, MAX_COLUMNS) # Check to make sure all the columns exist. If one #doesn't die off. for (ip= 1; ip <= MAX_COLUMNS; ip = ip + 1) if (columns[ip] == NULL) { call sprintf (Memc[tmp], SZ_LINE, "column %s doesn't exist in table %s") call pargstr (col_names[1,ip]) call pargstr (table_name) call error (1, Memc[tmp]) } # Determine the next row to append. row = tbpsta (table, TBL_NROWS) + 1 } else { call sprintf (Memc[tmp], SZ_LINE, "file %s exists but isn't a table") call pargstr (table_name) call error (1, Memc[tmp]) } } else { table = tbtopn (table_name, NEW_FILE, 0) call tbcdef (table, columns[ROOT], col_names[1,ROOT], "", "%20s", -20, 1, 1) call tbcdef (table, columns[MEAN], col_names[1,MEAN], "COUNT RATE", "%6.6g", TY_DOUBLE, 1, 1) call tbcdef (table, columns[SIGMA], col_names[1,SIGMA], "COUNT RATE", "%6.6g", TY_DOUBLE, 1, 1) call tbcdef (table, columns[MAX], col_names[1,MAX], "COUNT RATE", "%6.6g", TY_DOUBLE, 1, 1) call tbcdef (table, columns[DNUM], col_names[1,DNUM], "COUNT RATE", "%6.6g", TY_DOUBLE, 1, 1) call tbcdef (table, columns[DIODE], col_names[1,DIODE], "", "%6d", TY_INT, 1, 1) call tbcdef (table, columns[EVENT], col_names[1,EVENT], "COUNT RATE", "%6.6g", TY_DOUBLE, 1, 1) call tbcdef (table, columns[ANTI], col_names[1,ANTI], "", "%6.6g", TY_DOUBLE, 1, 1) call tbcdef (table, columns[BACK], col_names[1,BACK], "COUNT RATE", "%6.6g", TY_DOUBLE, 1, 1) call tbcdef (table, columns[RAD], col_names[1,RAD], "COUNT RATE", "%6.6g", TY_DOUBLE, 1, 1) call tbtcre (table) row = 1 } call sfree(sp) } end #--------------------------------------------------------------------------- # End of dst_open_table #--------------------------------------------------------------------------- # dst_stat_write -- Write the statistics to the table. procedure dst_stat_write (table, root, mean, sigma, maximum, n_event_diodes, total_event_rate, arate, brate, rrate, dnum_value, row) pointer table # I: Table descriptor. char root[ARB] # I: Root name. double mean # I: The average. double sigma # I: The deviation. double maximum # I: The maximum. int n_event_diodes # I: Number of diodes in all events. double total_event_rate # I: Total count rate for all events. double arate # I: Anticoincidence rate. double brate # I: Background rate. double rrate # I: Radiation rate. double dnum_value # I: Isolated diode value. int row # IO: The current row of the table. # Declarations. include "stat_table.com" # Function prototypes. int strlen() begin if (table != NULL) { call tbrptt (table, columns[ROOT], root, strlen (root), 1, row) call tbrptd (table, columns[MEAN], mean, 1, row) call tbrptd (table, columns[SIGMA], sigma, 1, row) call tbrptd (table, columns[MAX], maximum, 1, row) call tbrpti (table, columns[DIODE], n_event_diodes, 1, row) call tbrptd (table, columns[EVENT], total_event_rate, 1, row) call tbrptd (table, columns[ANTI], arate, 1, row) call tbrptd (table, columns[BACK], brate, 1, row) call tbrptd (table, columns[RAD], rrate, 1, row) call tbrptd (table, columns[DNUM], dnum_value, 1, row) row = row + 1 } end #--------------------------------------------------------------------------- # End of dst_write_table #---------------------------------------------------------------------------