Changeset 1431 for trunk/MagicSoft/Simulation/Detector/ReflectorII/parms.c
- Timestamp:
- 07/24/02 15:36:10 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Simulation/Detector/ReflectorII/parms.c
r923 r1431 10 10 extern char line[]; /* parsing buf. (init) */ 11 11 12 char axisdev_filename[256], reflectivity_filename[256]; 13 12 14 /* Prototypes */ 13 15 extern void setall(long iseed1,long iseed2); /* rnds */ … … 15 17 16 18 static void ReadCerfiles(FILE *parfile) 17 { char *value_ptr = NULL; 18 extern FILE *GetNextFile(char *cername); 19 { char *value_ptr = NULL; /* ptr at parm value */ 20 extern FILE *GetNextFile(char *cername); /* in main.c */ 19 21 20 22 filelist = parfile; … … 22 24 if (fgets(line, LINE_MAX_LENGTH, filelist) == NULL || 23 25 (value_ptr=strtok(line, whites)) == NULL) 24 26 FatalError(FLST_NSPEC_FTL); 25 27 else if (value_ptr[0] == '@') 26 { fclose(filelist);28 { fclose(filelist); 27 29 if ((filelist=fopen(value_ptr+1, "r")) == NULL) 28 30 FatalError(FLST_NFND__FTL, value_ptr+1); 29 31 else if (fgets(line, LINE_MAX_LENGTH, filelist) == NULL) 30 32 FatalError(FLST_NSPEC_FTL); 31 33 value_ptr = strtok(line, whites); } 32 34 … … 34 36 strcpy(cername, value_ptr); 35 37 if ((value_ptr=strtok(NULL, whites)) == NULL) 36 { first_Event = 0;38 { first_Event = 0; 37 39 last_Event = 1000000; } 38 40 else 39 { first_Event = atol(value_ptr);41 { first_Event = atol(value_ptr); 40 42 value_ptr = strtok(NULL, whites); 41 43 last_Event = value_ptr ? atol(value_ptr) : 1000000; } … … 44 46 45 47 if ((cerfile=fopen(cername, "r")) == NULL) 46 { Message(CERF_NFND__MSG, cername);47 cerfile=GetNextFile(cername); }48 { Message(CERF_NFND__MSG, cername); 49 cerfile=GetNextFile(cername); } 48 50 49 51 /* If no valid cerfile is found then exit */ 50 52 if (cerfile == NULL) 51 53 FatalError(CERF_NSPEC_FTL); 52 54 53 55 /* Check boundaries */ 54 56 if (first_Event > last_Event) 55 { Error(EVTN_WRONG_ERR, first_Event, last_Event, cername);57 { Error(EVTN_WRONG_ERR, first_Event, last_Event, cername); 56 58 first_Event = 0; 57 59 last_Event = 1000000; } 58 60 59 }/* end of ReadCerfiles */61 } /* end of ReadCerfiles */ 60 62 61 63 void ParmsSwitch(FILE *parfile) … … 63 65 int switch_end = FALSE; /* bool to exit loop */ 64 66 extern FILE *geofile; /* geo file (init) */ 65 extern void SetVerbose(int vlevel); 66 extern void SetAtmModel(char *model); 67 extern int ParseLine(FILE *parfile, 68 const char *token_list[], 69 int tokens, 70 char **value_ptr); 67 extern void SetVerbose(int vlevel); /* from diag.c */ 68 extern void SetAtmModel(char *model); /* from atm.c */ 69 extern int ParseLine(FILE *parfile, /* FILE with parms */ 70 const char *token_list[], /* array w/tokens */ 71 int tokens, /* nr of tokens */ 72 char **value_ptr); /* ptr->parm val. */ 71 73 72 74 do 73 { switch(ParseLine(parfile, parms, ARRAY_SZ(parms), &value_ptr)) 74 { case output_file: 75 if ((rflfile=fopen(value_ptr, "w+")) == NULL) 76 FatalError(OUTF_ERROR_FTL, value_ptr); 77 Message(OUTF_OPEN__MSG, value_ptr); 78 break; 79 case ct_file: 80 if ((geofile=fopen(value_ptr, "r")) == NULL) 81 FatalError(GEOF_ERROR_FTL, value_ptr); 82 Message(GEOF_OPEN__MSG, value_ptr); 83 strcat(strcpy(ct_BinaryName, value_ptr), ".mirr"); 84 ct_BinaryData = fopen(ct_BinaryName, "r"); 85 break; 86 case atm_model: 87 SetAtmModel(value_ptr); 88 break; 89 case verbose_level: 90 SetVerbose(atoi(value_ptr)); 91 break; 92 case fixed_target: 93 is_Fixed_Target = TRUE; 94 fixed_Theta = (float) atof(value_ptr); 95 value_ptr = strtok(NULL, whites); 96 if (value_ptr == NULL) 97 { Error(FIXD_TARGT_ERR); 98 is_Fixed_Target = FALSE; } 99 else 100 { fixed_Phi = (float) atof(value_ptr); 101 Message(FIXD_ENABL_MSG, fixed_Theta, fixed_Phi); 102 fixed_Theta *= (float) (M_PI/180.); 103 fixed_Phi *= (float) (M_PI/180.); } 104 break; 105 case max_events: 106 Message(MAX__EVTS__MSG, max_Events=atol(value_ptr)); 107 break; 108 case energy_cuts: 109 low_Ecut = (float) atof(value_ptr); 110 value_ptr = strtok(NULL, whites); 111 if (value_ptr == NULL) 112 { Error(ENRG_LIMIT_ERR); 113 low_Ecut = 0.; } 114 else 115 { high_Ecut = (float) atof(value_ptr); 116 Message(ENRG_CUTS__MSG, low_Ecut, high_Ecut); } 117 break; 118 case seeds: 119 Seeds[0] = atol(value_ptr); 120 value_ptr = strtok(NULL, whites); 121 if (value_ptr) Seeds[1] = atol(value_ptr); 122 else 123 { Error(SEED_ERROR_ERR); 124 Seeds[0] = 3141592L; } 125 break; 126 case random_pointing: 127 case repeat_random: 128 /********************************/ 129 break; 75 { switch(ParseLine(parfile, parms, ARRAY_SZ(parms), &value_ptr)) 76 { case output_file: 77 if ((rflfile=fopen(value_ptr, "w+")) == NULL) 78 FatalError(OUTF_ERROR_FTL, value_ptr); 79 Message(OUTF_OPEN__MSG, value_ptr); 80 break; 81 case ct_file: 82 if ((geofile=fopen(value_ptr, "r")) == NULL) 83 FatalError(GEOF_ERROR_FTL, value_ptr); 84 Message(GEOF_OPEN__MSG, value_ptr); 85 strcat(strcpy(ct_BinaryName, value_ptr), ".mirr"); 86 ct_BinaryData = fopen(ct_BinaryName, "r"); 87 break; 88 case axisdev_file: 89 strcpy(axisdev_filename, value_ptr); 90 break; 91 case reflectivity_file: 92 strcpy(reflectivity_filename, value_ptr); 93 break; 94 case atm_model: 95 SetAtmModel(value_ptr); 96 break; 97 case verbose_level: 98 SetVerbose(atoi(value_ptr)); 99 break; 100 case fixed_target: 101 is_Fixed_Target = TRUE; 102 fixed_Theta = (float) atof(value_ptr); 103 value_ptr = strtok(NULL, whites); 104 if (value_ptr == NULL) 105 { Error(FIXD_TARGT_ERR); 106 is_Fixed_Target = FALSE; } 107 else 108 { fixed_Phi = (float) atof(value_ptr); 109 Message(FIXD_ENABL_MSG, fixed_Theta, fixed_Phi); 110 fixed_Theta *= (float) (M_PI/180.); 111 fixed_Phi *= (float) (M_PI/180.); } 112 break; 130 113 131 case cer_files: 132 ReadCerfiles(parfile); 133 switch_end = TRUE; 134 default: switch_end = TRUE; 135 break; }} 114 /* Added May 2002, AM: */ 115 case telescope_position: 116 Telescope_x = (float) atof(value_ptr); 117 value_ptr = strtok(NULL, whites); 118 if (value_ptr == NULL) 119 { Error(TEL_POS_ERR); 120 exit(-1);} 121 else 122 { Telescope_y = (float) atof(value_ptr); 123 Message(TEL_POS_MSG, Telescope_x, Telescope_y);} 124 break; 125 126 case max_events: 127 Message(MAX__EVTS__MSG, max_Events=atol(value_ptr)); 128 break; 129 case energy_cuts: 130 low_Ecut = (float) atof(value_ptr); 131 value_ptr = strtok(NULL, whites); 132 if (value_ptr == NULL) 133 { Error(ENRG_LIMIT_ERR); 134 low_Ecut = 0.; } 135 else 136 { high_Ecut = (float) atof(value_ptr); 137 Message(ENRG_CUTS__MSG, low_Ecut, high_Ecut); } 138 break; 139 case seeds: 140 Seeds[0] = atol(value_ptr); 141 value_ptr = strtok(NULL, whites); 142 if (value_ptr) Seeds[1] = atol(value_ptr); 143 else 144 { Error(SEED_ERROR_ERR); 145 Seeds[0] = 3141592L; } 146 break; 147 case cer_files: 148 ReadCerfiles(parfile); 149 switch_end = TRUE; 150 default: switch_end = TRUE; 151 break; }} 136 152 while (!switch_end); 137 153 138 154 if (filelist == NULL) 139 155 FatalError(FLST_NSPEC_FTL); 140 156 141 157 /* Set random seeds */ … … 143 159 Message(SEED_SET___MSG, Seeds[0], Seeds[1]); 144 160 145 }/* end of ParmsSwitch */161 } /* end of ParmsSwitch */
Note:
See TracChangeset
for help on using the changeset viewer.