- Timestamp:
- 07/24/02 15:36:10 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/ReflectorII/geometry.c
r923 r1431 8 8 9 9 extern char line[]; /* parsing buf. (init) */ 10 extern char axisdev_filename[256], reflectivity_filename[256]; 11 12 float mean_refl; /* Mirror mean reflectivity 270-610 nm. 13 * AM June 2002. 14 */ 10 15 11 16 float ct_Focal_mean; /* focal dist. (mean) (cm) */ 12 float ct_Focal_std; /* focal dist. (std) (cm) */13 17 float ct_PSpread_mean; /* pt. spread fn. (mean) (cm) */ 14 float ct_PSpread_std; /* pt. spread fn. (std) (cm) */15 float ct_Adjustment_std; /* adjustment dev. (std) (cm) */16 18 float ct_BlackSpot_rad; /* black spot radius (cm) */ 17 19 float ct_RMirror; /* rad. of single mirror (cm) */ … … 43 45 Log(MIRR_ALLOC_LOG, ct_NMirrors); 44 46 Log(MIRR_TABLE_LOG); 45 if (ct_BinaryData) 46 { Log(BINF_OPEN__LOG, ct_BinaryName); 47 fread(ct_data, sizeof(mirror), ct_NMirrors, ct_BinaryData); 48 fclose(ct_BinaryData); } 49 else 50 { /* read ASCII data */ 51 Log(READ_ASCII_LOG); 52 for (i=0; i<ct_NMirrors; i++) 53 { if (12 != fscanf(geofile, "%d %f %f %f %f %f %f %f %f %f %f %f", 54 &ct_data[i].i, &ct_data[i].f, 55 &ct_data[i].sx, &ct_data[i].sy, 56 &ct_data[i].x, &ct_data[i].y, &ct_data[i].z, 57 &ct_data[i].theta, &ct_data[i].phi, 58 &ct_data[i].xn, &ct_data[i].yn, &ct_data[i].zn)) 59 break; 60 Log("[%d]", ct_data[i].i); } 61 Log("%c", '\n'); 62 if (i < ct_NMirrors) 63 FatalError(MIRR_FEW___FTL, i); 64 /* Data Ok: save binary data for next time */ 65 if ((ct_BinaryData=fopen(ct_BinaryName, "w"))==NULL) 66 Log(BINF_ERROR_LOG, ct_BinaryName); 67 else 68 { Log(BINF_WRITE_LOG, ct_BinaryName); 69 fwrite(ct_data, sizeof(mirror), ct_NMirrors, ct_BinaryData); 70 fclose(ct_BinaryData); } 71 } /* end of if: reading ASCII data */ 47 48 Log(READ_ASCII_LOG); 49 for (i=0; i<ct_NMirrors; i++) 50 { 51 if (12 != fscanf(geofile, "%d %f %f %f %f %f %f %f %f %f %f %f", 52 &ct_data[i].i, &ct_data[i].f, 53 &ct_data[i].sx, &ct_data[i].sy, 54 &ct_data[i].x, &ct_data[i].y, &ct_data[i].z, 55 &ct_data[i].theta, &ct_data[i].phi, 56 &ct_data[i].xn, &ct_data[i].yn, &ct_data[i].zn)) 57 break; 58 } 59 if (i < ct_NMirrors) 60 FatalError(MIRR_FEW___FTL, i); 61 72 62 } /* end of ReadMirrorTable */ 73 63 74 64 static void ReadReflectivity(char *datname) 75 { FILE *datfile = fopen(datname, "r"); 65 { 66 FILE *datfile = fopen(datname, "r"); 76 67 int current = 0; 68 69 mean_refl = 0.; 77 70 78 71 if (datfile == NULL) 79 72 FatalError(RFLF_ERROR_FTL, datname); 73 else 74 printf("Reading file %s\n", datname); 75 80 76 while (fgets(line, LINE_MAX_LENGTH, datfile)) 81 { if (line[0] == '#') continue; 82 if (nReflectivity == 0) 83 { nReflectivity = atoi(line); 84 if (nReflectivity) 85 { if ((Reflectivity[0] = 86 (float *) malloc(sizeof(float) * nReflectivity)) == NULL 87 || (Reflectivity[1] = 88 (float *) malloc(sizeof(float) * nReflectivity)) == NULL) 89 FatalError(REFL_ALLOC_FTL, nReflectivity); }} 90 else if (2 == sscanf(line, "%f %f", 91 &Reflectivity[0][current], &Reflectivity[1][current])); 92 { current++; 93 if (current >= nReflectivity) break; }} 77 { 78 if (line[0] == '#') continue; 79 80 if (nReflectivity == 0) 81 { 82 nReflectivity = atoi(line); 83 if (nReflectivity) 84 { 85 if ((Reflectivity[0] = 86 (float *) malloc(sizeof(float) * nReflectivity)) == NULL || 87 (Reflectivity[1] = 88 (float *) malloc(sizeof(float) * nReflectivity)) == NULL) 89 FatalError(REFL_ALLOC_FTL, nReflectivity); 90 } 91 } 92 else if (2 == sscanf(line, "%f %f", &Reflectivity[0][current], 93 &Reflectivity[1][current])) 94 { 95 // Added June 2002, AM: 96 mean_refl += Reflectivity[1][current]; 97 current++; 98 if (current >= nReflectivity) break; 99 } 100 } 94 101 fclose(datfile); 95 102 96 103 nReflectivity = current; 104 if (current > 0) 105 mean_refl /= (float) current; 106 97 107 } /* end of ReadReflectivity */ 98 108 … … 103 113 if (datfile == NULL) 104 114 FatalError(AXIS_ERROR_FTL, datname); 115 else 116 printf("Reading file %s\n", axisdev_filename); 117 105 118 if ((AxisDeviation[0]= 106 119 (float *) malloc(sizeof(float) * ct_NMirrors)) == NULL … … 149 162 break; 150 163 case focal_distance: 151 Log(LOG__FLOAT_LOG, "focal distance (average )",164 Log(LOG__FLOAT_LOG, "focal distance (average, cm)", 152 165 ct_Focal_mean = (float) atof(value_ptr)); 153 166 break; 154 case focal_std: 155 Log(LOG__FLOAT_LOG, "focal distance (std. dev.)", 156 ct_Focal_std = (float) atof(value_ptr)); 167 case focal_std: /* not implemented. */ 157 168 break; 158 169 case point_spread: 159 Log(LOG__FLOAT_LOG, "point spread fn. (average)",170 Log(LOG__FLOAT_LOG, "point spread fn. sigma (average, cm)", 160 171 ct_PSpread_mean = (float) atof(value_ptr)); 161 172 break; 162 case point_std: 163 Log(LOG__FLOAT_LOG, "point spread fn. (std. dev.)", 164 ct_PSpread_std = (float) atof(value_ptr)); 165 break; 166 case adjustment_dev: 167 Log(LOG__FLOAT_LOG, "adjustment dev. (std. dev.)", 168 ct_Adjustment_std = (float) atof(value_ptr)); 173 case point_std: /* not implemented */ 174 break; 175 case adjustment_dev: /* not implemented */ 169 176 break; 170 177 case black_spot: … … 172 179 ct_BlackSpot_rad = (float) atof(value_ptr)); 173 180 break; 181 case n_mirrors: 182 Log(LOG__INT___LOG, "number of mirrors", 183 ct_NMirrors = atoi(value_ptr)); 184 break; 174 185 case r_mirror: 175 186 Log(LOG__FLOAT_LOG, "single mirror radius (cm)", 176 187 ct_RMirror = (float) atof(value_ptr)); 177 188 break; 178 case n_mirrors:179 Log(LOG__INT___LOG, "number of mirrors",180 ct_NMirrors = atoi(value_ptr));181 break;182 189 case camera_width: 183 Log(LOG__FLOAT_LOG, "camera width(cm)",190 Log(LOG__FLOAT_LOG, "camera radius (cm)", 184 191 ct_CameraWidth = (float) atof(value_ptr)); 185 192 break; … … 191 198 Log(LOG__FLOAT_LOG, "pixel width (cm)", 192 199 ct_PixelWidth = (float) atof(value_ptr)); 200 break; 201 case n_centralpixels: 202 /* this parameter is for camera, not for reflector */ 203 break; 204 case n_gappixels: 205 /* this parameter is for camera, not for reflector */ 193 206 break; 194 207 case refl_file: … … 208 221 fclose(geofile); 209 222 210 if (Reflectivity[0] == NULL) ReadReflectivity(REFLECTIVITY_FILE); 211 if (AxisDeviation[0]== NULL) ReadAxisDev(AXISDEVIATION_FILE); 223 if (strlen(reflectivity_filename) == 0) 224 strcpy(reflectivity_filename, REFLECTIVITY_FILE); 225 if (Reflectivity[0] == NULL) ReadReflectivity(reflectivity_filename); 226 227 if (strlen(axisdev_filename) == 0) 228 strcpy(axisdev_filename, AXISDEVIATION_FILE); 229 if (AxisDeviation[0]== NULL) ReadAxisDev(axisdev_filename); 230 231 212 232 ReadFocals(); 213 233 } /* end of GeometrySwitch */ 234
Note:
See TracChangeset
for help on using the changeset viewer.