- Timestamp:
- 09/16/04 16:16:34 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/Camera/creadparam.cxx
r2965 r5072 19 19 //= 20 20 //= $RCSfile: creadparam.cxx,v $ 21 //= $Revision: 1.2 6$22 //= $Author: blanch$23 //= $Date: 2004-0 1-30 09:58:39$21 //= $Revision: 1.27 $ 22 //= $Author: moralejo $ 23 //= $Date: 2004-09-16 15:16:34 $ 24 24 //= 25 25 //=////////////////////////////////////////////////////////////////////// … … 54 54 55 55 #include "creadparam.h" 56 #include "camera.h" // Needed for MAX_NUMBER_OF_CTS 56 57 57 58 //!@} … … 68 69 //!@{ 69 70 70 static char Input_filename[100][PATH_MAX_LENGTH]; //@< input filename71 static char **Input_filename; //@< input filename 71 72 static char Starfield_filename[PATH_MAX_LENGTH]; //@< starfield input filename 72 73 static int Starfield_center[6]={0,0,0,0,0,0}; //@< center of the starfield FOV … … 75 76 static char ROOT_filename[PATH_MAX_LENGTH]; //@< data filename 76 77 static char Loop_filename[PATH_MAX_LENGTH]; //@< special data filename 77 static int CT_geometry = 0; //@< CT camera geometry78 static char CT_geom_string[256]; //@< Contains geometry ids of CTs 78 79 static int CT_number = 1; //@< Number of CT 79 static char QE_filename[100][PATH_MAX_LENGTH];//@< name of the qe file80 static char **QE_filename; //@< name of the qe file 80 81 static char NSB_directory[PATH_MAX_LENGTH]; //@< database for NSB 81 82 static char NSB_outer_directory[PATH_MAX_LENGTH]; //@< database for NSB … … 83 84 static int ElecNoise = TRUE; //@< Will we add ElecNoise? 84 85 static float FADC_pedestal = 10.0; //@< Value for FADC Pedestal 85 static float FADC_Noise = 2.0; //@< Value for FADC ElecNoise 86 static float FADC_Noise_inner = 2.0; //@< Value for FADC ElecNoise 87 static float FADC_Noise_outer = 2.0; //@< Value for FADC ElecNoise 86 88 static float Digital_Noise = 1.0; //@< Value for FADC digital Noise 87 89 static float Trig_Noise = 0.3; //@< Factor for Trigger ElecNoise … … 89 91 static float meanNSB; //@< NSB mean value (per pixel) 90 92 static int nphe2NSB=0; //@< Number of phe from shower to do NSB simulation 91 static float qThreshold[100][CAMERA_PIXELS];//@< Threshold values93 static float **qThreshold; //@< Threshold values 92 94 static int Individual_Thres = FALSE; 93 95 static float RiseDisc = -1.0; … … 112 114 static float Trigger_response_ampl = 1.0; 113 115 static float Trigger_response_fwhm = 2.0; 114 static float Trigger_threshold[ 100];115 static int Trigger_multiplicity[ 100];116 static int Trigger_topology[ 100];116 static float Trigger_threshold[MAX_NUMBER_OF_CTS]; 117 static int Trigger_multiplicity[MAX_NUMBER_OF_CTS]; 118 static int Trigger_topology[MAX_NUMBER_OF_CTS]; 117 119 static float Trigger_loop_lthres = 3.0; 118 120 static float Trigger_loop_uthres = 10.0; … … 122 124 static int Trigger_loop_ltop = 0; 123 125 static int Trigger_loop_utop = 2; 126 static int FADC_shape = 0; 124 127 static float FADC_response_ampl = MFADC_RESPONSE_INTEGRAL; 125 128 static float FADC_response_fwhm = MFADC_RESPONSE_FWHM; 129 static int FADC_shape_out = 0; 126 130 static float FADC_resp_ampl_out = MFADC_RESPONSE_INTEGRAL; 127 131 static float FADC_resp_fwhm_out = MFADC_RESPONSE_FWHM; 128 132 static float High_to_Low = 10.0; //@< Low gain channel respct to High 129 static float Source_offset_th=0.; //@< Displacement in Theta of the 130 //@< source from the center 131 static float Source_offset_ph=0.; //@< Displacement in Phi of the 132 //@< source from the center 133 134 static float sigma_spot = -1.; // Sigma in x and y for additional 135 // gaussian spread of the mirror spot. 133 134 static float sigma_x_spot = 0.; // Sigma in x and y (cm) for additional 135 static float sigma_y_spot = 0.; // gaussian spread of the mirror spot. 136 137 static float misp_x = 0.; // Mispointing in x 138 static float misp_y = 0.; // Mispointing in y 136 139 137 140 static float trig_delay = 25.; // Delay in ns between beginning of FADC 138 141 // time window and the trigger instant. 139 142 143 static float CTcoor[MAX_NUMBER_OF_CTS][3]; 144 145 static float m_fraction[MAX_NUMBER_OF_CTS]; 146 147 // Coordinates of CT locations, in centimeters, in the Corsika system. 140 148 141 149 //!@} … … 162 170 char token[ITEM_MAX_LENGTH]; //@< a single token 163 171 int i, j, k; //@< dummy counters 164 float aux, aux 2; //@< auxiliar variable172 float aux, aux1, aux2; //@< auxiliar variable 165 173 int aux3, aux4; //@< auxiliar variable 166 174 ifstream ifile; 167 175 char filename_tmp[PATH_MAX_LENGTH]; 176 177 178 memset((char*)CT_geom_string, 0, sizeof(CT_geom_string)); 179 180 Input_filename = new char *[MAX_NUMBER_OF_CTS]; 181 QE_filename = new char *[MAX_NUMBER_OF_CTS]; 182 qThreshold = new float *[MAX_NUMBER_OF_CTS]; 183 184 for (int i = 0; i < MAX_NUMBER_OF_CTS; i++) 185 { 186 Input_filename[i] = new char[PATH_MAX_LENGTH]; 187 QE_filename[i] = new char[PATH_MAX_LENGTH]; 188 qThreshold[i] = new float[CAMERA_PIXELS]; 189 CTcoor[i][0] = 0.; CTcoor[i][1] = 0.; CTcoor[i][2] = 0.; 190 m_fraction[i] = 1.; 191 } 192 168 193 // use cin or ifile (reading from STDIN or from parameters file? 169 194 if ( filename != NULL ) … … 259 284 break; 260 285 261 case ct_num: //@< n ame of the telescope file286 case ct_num: //@< number of telescopes 262 287 263 288 // get the name of the ct_file from the line … … 269 294 270 295 // get the name of the ct_file from the line 271 sscanf(line, "%s %i", token, &CT_geometry); 296 sscanf(line, "%s %s", token, CT_geom_string); 297 if ( strlen(CT_geom_string) > MAX_NUMBER_OF_CTS ) 298 { 299 printf("\nError: ct_geom option read from input card wrong:\n"); 300 printf("Number of digits (%d) is larger than maximum number\n",strlen(CT_geom_string) ); 301 printf("of allowed telescopes (%d). Exiting.\n\n", MAX_NUMBER_OF_CTS); 302 exit(1); 303 } 272 304 273 305 break; … … 285 317 // we will not add electronic noise for FADC and Trigger channels. 286 318 ElecNoise = FALSE; 287 FADC_Noise = 0.0; 319 FADC_Noise_inner = 0.0; 320 FADC_Noise_outer = 0.0; 288 321 Trig_Noise =0.0; 289 322 290 323 break; 291 324 292 case fadc_pedestal: //@< FADC ElecNoise325 case fadc_pedestal: //@< FADC pedestal 293 326 294 327 // value for FADC Pedestal … … 311 344 break; 312 345 313 case high_to_low: //@< FADC ElecNoise346 case high_to_low: //@< High to Low gain ratio 314 347 315 348 // Value for the Low Gain channel respect to the High gain … … 321 354 322 355 // value for FADC Elec Noise 323 sscanf(line, "%s %f %f", token, &FADC_Noise, &Digital_Noise); 356 sscanf(line, "%s %f %f %f", token, 357 &FADC_Noise_inner, &FADC_Noise_outer, 358 &Digital_Noise); 324 359 325 360 ElecNoise = TRUE; … … 479 514 480 515 // Get parameters for the fadc response for one phe 481 sscanf(line, "%s % f %f", token, &FADC_response_ampl,&FADC_response_fwhm);516 sscanf(line, "%s %i %f %f", token, &FADC_shape, &FADC_response_ampl,&FADC_response_fwhm); 482 517 483 518 break; … … 486 521 487 522 // Get parameters for the fadc response for one phe 488 sscanf(line, "%s % f %f", token, &FADC_resp_ampl_out,&FADC_resp_fwhm_out);523 sscanf(line, "%s %i %f %f", token, &FADC_shape_out, &FADC_resp_ampl_out,&FADC_resp_fwhm_out); 489 524 490 525 break; … … 545 580 break; 546 581 547 case source_offset:548 549 // Get offset of source550 sscanf(line, "%s %f %f", token, &Source_offset_th, &Source_offset_ph);551 552 break;553 554 582 case Trigger_Loop_Output_Only_Specialists: 555 583 … … 563 591 break; 564 592 593 case trigger_delay: 594 595 sscanf(line, "%s %f", token, &trig_delay); 596 break; 597 598 565 599 case sigma_xy_cm_spot: 566 600 567 sscanf(line, "%s %f", token, &sigma_spot); 568 break; 569 570 case trigger_delay: 571 572 sscanf(line, "%s %f", token, &trig_delay); 573 break; 601 sscanf(line, "%s %f", token, &sigma_x_spot); 602 sigma_y_spot=sigma_x_spot; 603 break; 604 605 case sigma_x_cm_spot: 606 607 sscanf(line, "%s %f", token, &sigma_x_spot); 608 break; 609 610 case sigma_y_cm_spot: 611 612 sscanf(line, "%s %f", token, &sigma_y_spot); 613 break; 614 615 case misspoint_deg: 616 617 sscanf(line, "%s %f %f", token, &misp_x, &misp_y); 618 break; 619 620 case telescope_location_cm: 621 622 if ( 5 != sscanf(line, "%s %d %f %f %f", token, &j, &aux, &aux1, &aux2) ) 623 { 624 printf("\nError: wrong number of arguments for command telescope_location_cm.\n"); 625 printf("Usage: telescope_location_cm ct_id x y z\n"); 626 printf("Coordinates must be written in centimeters."); 627 printf("Exiting.\n\n"); 628 exit(1); 629 } 630 631 if (j >= MAX_NUMBER_OF_CTS) 632 { 633 printf("\nError: coordinates were supplied for a telescope index (%d)\n", j); 634 printf("larger than allowed. Valid telescope ids range from 0 to %d. Exiting.\n\n", MAX_NUMBER_OF_CTS-1); 635 exit(1); 636 } 637 CTcoor[j][0] = aux; 638 CTcoor[j][1] = aux1; 639 CTcoor[j][2] = aux2; 640 641 break; 642 643 case mirror_fraction: 644 645 sscanf(line, "%s %d %f", token, &j, &aux); 646 m_fraction[j] = aux; 647 648 break; 574 649 575 650 case end_file: //@< end of the parameters file … … 761 836 //!@{ 762 837 int 763 get_ct_geometry(void) 764 { 765 return (CT_geometry); 838 get_ct_geometry(int ict) 839 { 840 char dummy[2]; 841 strncpy(dummy, &(CT_geom_string[ict]), 1); 842 dummy[1] = '\0'; 843 844 return ((int)atoi(dummy)); 766 845 } 767 846 //!@} … … 839 918 //!@{ 840 919 int 841 add_elec_noise(float *fadc, float *digi, float *trig) 842 { 843 *fadc = FADC_Noise; 920 add_elec_noise(float *fadcinner, float*fadcouter, float *digi, float *trig) 921 { 922 *fadcinner = FADC_Noise_inner; 923 *fadcouter = FADC_Noise_outer; 924 844 925 *digi = Digital_Noise; 845 926 *trig = Trig_Noise; … … 1174 1255 //!@{ 1175 1256 void 1176 get_FADC_properties(float *ra, float *rf, float *rao, float *rfo) 1177 { 1257 get_FADC_properties(int *shape,float *ra, float *rf, 1258 int *shapeo, float *rao, float *rfo) 1259 { 1260 *shape=FADC_shape; 1178 1261 *ra=FADC_response_ampl; 1179 1262 *rf=FADC_response_fwhm; 1263 *shapeo=FADC_shape_out; 1180 1264 *rao=FADC_resp_ampl_out; 1181 1265 *rfo=FADC_resp_fwhm_out; … … 1241 1325 get_Trigger_Single(float **t, int *m, int *g) 1242 1326 { 1243 for(int j=0;j< 100;j++){1327 for(int j=0;j<MAX_NUMBER_OF_CTS;j++){ 1244 1328 for(int i=0;i<CAMERA_PIXELS;i++) 1245 1329 t[j][i]=qThreshold[j][i]; … … 1251 1335 1252 1336 //!----------------------------------------------------------- 1253 // @name get_source_off1254 //1255 // @desc give the offset of the source to the center of the camera1256 //1257 //------------------------------------------------------------1258 // @function1259 1260 //!@{1261 void get_source_off(float *th, float *p){1262 *th=Source_offset_th;1263 *p=Source_offset_ph;1264 }1265 //!@}1266 1267 //!-----------------------------------------------------------1268 1337 // @name get_FADC_pedesta 1269 1338 // … … 1300 1369 } 1301 1370 1302 float get_sigma_xy_cm_spot(void){ 1303 1304 return sigma_spot; 1371 int get_misspointing(float *x, float *y){ 1372 1373 *x=misp_x; 1374 *y=misp_y; 1375 1376 if (misp_x == 0.0 && misp_y==0.0) 1377 return 0; 1378 else 1379 return 1; 1380 1381 } 1382 1383 float get_sigma_xy_cm_spot(float *x, float *y){ 1384 1385 *x=sigma_x_spot; 1386 *y=sigma_y_spot; 1387 1388 if (sigma_x_spot > 0.0 || sigma_y_spot >0.0) 1389 return 1.0; 1390 else 1391 return -1.0; 1305 1392 1306 1393 } … … 1311 1398 1312 1399 } 1400 1401 float get_telescope_location_cm(int j, int icoor){ 1402 1403 return CTcoor[j][icoor]; 1404 1405 } 1406 1407 float get_mirror_fraction(int j){ 1408 return m_fraction[j]; 1409 } 1410 1411 1313 1412 1314 1413 //!@} … … 1319 1418 // 1320 1419 // $Log: not supported by cvs2svn $ 1420 // 1421 // Revision 1.27 2004/05/12 A. Moralejo 1422 // 1423 // Changed fadc_noise command: now the two first numbers are respectively 1424 // the analogic electronic noise for inner (small) and outer (big) pixels 1425 // respectively. Last number is still the FADC digital noise which affects 1426 // equallly inner and outer pixels (as well as high and low gain). 1427 // 1428 // Revision 1.26 2004/01/30 09:58:39 blanch 1429 // [Changes done mainly by A. Moralejo] 1430 // 1431 // Two new commands of the input card have been added: 1432 // 1433 // sigma_xy_cm_spot: to enlarge the point spread function. 1434 // trigger_delay: to center the FADC signal 1435 // 1436 // There is also a check that the Pedestal is an integer, otherwise it 1437 // becames complex to get a reasonable rms for events without electronic noise. 1438 // 1321 1439 // Revision 1.25 2003/10/26 19:45:38 blanch 1322 1440 // The write_all_data input card command has been removed.
Note:
See TracChangeset
for help on using the changeset viewer.