/* This program loops over the 16 possible values of the Jet_Phi_Distance_Min Global DSP Tool Parameter (1:16) and produces as its output a table showing: the Jet_Phi_Distance_min, the Jet_Search_Mask in binary, and the Jet_Search_Mask in unsigned hex. This program asks for the name of a file to write as input At each value of Jet_Phi_Distance_Min: Calculate the binary version of the Jet_Search_Mask and then calculate the hex version of this mask. There are two functions. dig_bin - You tell it the digit of interest, d0 through d31, and you tell it the Jet_Phi_Distance_Min value, 1:16, and it returns a 1 or a 0 showing the value of the binary digit in the Jet_Search_Mask. hex_dig - You tell it the highest digit_number of a set of 4 digits and it returns the value 0:f of these 4 digits. It also needs a pointer to the digit_value array. Revision Date 18-DEC-1995 */ #include /* I/O definitions */ #define MAXLINE 80 #define Min_Phi_Dist_Min 1 #define Max_Phi_Dist_Min 16 main() { FILE *fpout; char filename[MAXLINE]; int phi_dist ; int digit_value[31] ; int digit_number ; int hex_value = 3 ; int dig_bin( int digit_number, int jet_phi_dist_min) ; int hex_dig( int digit_number, int digit_value[] ) ; /* Get the filename of the output file */ printf("Enter the filename of the output text file: "); scanf("%s", filename); if ((fpout = fopen(filename, "w", "rat=cr", "rfm=var")) == NULL) { printf("\nERROR: Can't open output file %s\n", filename); exit (1); } /* Print a header to go at the top of the output file. */ fprintf(fpout, "\n "); fprintf(fpout, "\n Phi "); fprintf(fpout, "\n Distance Jet "); fprintf(fpout, "\n Minimum Jet Search Mask Search "); fprintf(fpout, "\nParameter MSB BINARY LSB Mask "); fprintf(fpout, "\n Value D31 D0 HEX "); fprintf(fpout, "\n--------- --------------------------------------- --------- "); /* Loop over the values of Jet_Phi_Distance_Min typically 1:16 */ for (phi_dist = Min_Phi_Dist_Min; phi_dist <= Max_Phi_Dist_Min; ++phi_dist) { for (digit_number = 0; digit_number <= 31; ++digit_number) { digit_value[digit_number] = dig_bin(digit_number, phi_dist) ; } fprintf(fpout, "\n %4d ", phi_dist ); for (digit_number = 31; digit_number >= 0; --digit_number) { fprintf(fpout, "%1d", digit_value[digit_number] ) ; if ((digit_number % 4) == 0 ) fprintf(fpout, " ") ; } fprintf(fpout, " ") ; for (digit_number = 31; digit_number >= 0; digit_number -= 4 ) { hex_value = hex_dig( digit_number, digit_value ) ; fprintf(fpout, "%1X", hex_value ) ; if ( digit_number == 19 ) fprintf(fpout, " ") ; } } fprintf(fpout, "\n "); } int hex_dig( int digit_number, int digit_value[]) { int value = 0; if (digit_value[digit_number - 0] == 1) value = value + 8 ; if (digit_value[digit_number - 1] == 1) value = value + 4 ; if (digit_value[digit_number - 2] == 1) value = value + 2 ; if (digit_value[digit_number - 3] == 1) value = value + 1 ; return (value) ; } int dig_bin( int loc_dig_num, int loc_phi_dist ) { int value = 0; if (loc_dig_num == 31) { value = 1 ; } if (loc_dig_num == 15 && loc_phi_dist <= 16) { value = 1 ; } if (loc_dig_num == 16 && loc_phi_dist <= 15) { value = 1 ; } if (loc_dig_num == 14 && loc_phi_dist <= 15) { value = 1 ; } if (loc_dig_num == 17 && loc_phi_dist <= 14) { value = 1 ; } if (loc_dig_num == 13 && loc_phi_dist <= 14) { value = 1 ; } if (loc_dig_num == 18 && loc_phi_dist <= 13) { value = 1 ; } if (loc_dig_num == 12 && loc_phi_dist <= 13) { value = 1 ; } if (loc_dig_num == 19 && loc_phi_dist <= 12) { value = 1 ; } if (loc_dig_num == 11 && loc_phi_dist <= 12) { value = 1 ; } if (loc_dig_num == 20 && loc_phi_dist <= 11) { value = 1 ; } if (loc_dig_num == 10 && loc_phi_dist <= 11) { value = 1 ; } if (loc_dig_num == 21 && loc_phi_dist <= 10) { value = 1 ; } if (loc_dig_num == 9 && loc_phi_dist <= 10) { value = 1 ; } if (loc_dig_num == 22 && loc_phi_dist <= 9) { value = 1 ; } if (loc_dig_num == 8 && loc_phi_dist <= 9) { value = 1 ; } if (loc_dig_num == 23 && loc_phi_dist <= 8) { value = 1 ; } if (loc_dig_num == 7 && loc_phi_dist <= 8) { value = 1 ; } if (loc_dig_num == 24 && loc_phi_dist <= 7) { value = 1 ; } if (loc_dig_num == 6 && loc_phi_dist <= 7) { value = 1 ; } if (loc_dig_num == 25 && loc_phi_dist <= 6) { value = 1 ; } if (loc_dig_num == 5 && loc_phi_dist <= 6) { value = 1 ; } if (loc_dig_num == 26 && loc_phi_dist <= 5) { value = 1 ; } if (loc_dig_num == 4 && loc_phi_dist <= 5) { value = 1 ; } if (loc_dig_num == 27 && loc_phi_dist <= 4) { value = 1 ; } if (loc_dig_num == 3 && loc_phi_dist <= 4) { value = 1 ; } if (loc_dig_num == 28 && loc_phi_dist <= 3) { value = 1 ; } if (loc_dig_num == 2 && loc_phi_dist <= 3) { value = 1 ; } if (loc_dig_num == 29 && loc_phi_dist <= 2) { value = 1 ; } if (loc_dig_num == 1 && loc_phi_dist <= 2) { value = 1 ; } if (loc_dig_num == 30 && loc_phi_dist <= 1) { value = 1 ; } if (loc_dig_num == 0 && loc_phi_dist <= 1) { value = 1 ; } return (value) ; }