Skip to content
Snippets Groups Projects
Commit f83ac216 authored by zhang's avatar zhang
Browse files

08/04/2011

Add the interface to read .fe and .fe files, and also to read parameters for orbit corrections.
parent 2550c435
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
Read_Lattice() Read_Lattice()
Comments: Comments:
Jianfeng Zhang 03/2011 soleil Written by Jianfeng Zhang 03/2011 soleil
****************************************************************************/ ****************************************************************************/
...@@ -32,14 +32,29 @@ ...@@ -32,14 +32,29 @@
char twiss_file[max_str]; char twiss_file[max_str];
// cod file // cod file
char cod_file[max_str]; char cod_file[max_str];
// girder file
char girder_file[max_str];
//chamber file //chamber file
char chamber_file[max_str];
// multipole files // multipole files
char multipole_file[max_str]; char multipole_file[max_str];
// multipole file for soleil lattice // multipole file for soleil lattice
char fic_hcorr[max_str],fic_vcorr[max_str], fic_skew[max_str]; char fic_hcorr[max_str],fic_vcorr[max_str], fic_skew[max_str];
//errors
//char fe_file[max_str]; //the same as multipole_file[max_str]????
/* COD correction */
int nwh = 56, nwv = 56; //number of singular values for SVD correction
//correction
char hcorr_file[max_str], vcorr_file[max_str]; //files with the status of hcorr/vcorr status,
//to choose which correctors are used for orbit correction
//default name of special elements in lattice
char hcorr_name[max_str] = "", vcorr_name[max_str] = "";
char skew_quad_name[max_str] = "", bpm_name[max_str] = "";
char gs_name[max_str] = "", ge_name[max_str] = "";
#define OLD_LATTICE #define OLD_LATTICE
/* Read script */ /* Read script */
...@@ -112,9 +127,7 @@ void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCom ...@@ -112,9 +127,7 @@ void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCom
//find the bool flag whose last 4 character are 'Flag' //find the bool flag whose last 4 character are 'Flag'
if(strcmp(EndName,"Flag")==0) if(strcmp(EndName,"Flag")==0)
CommNo++; CommNo++;
/*read file names................. */ /*read file names................. */
/* set file directory*/ /* set file directory*/
...@@ -138,45 +151,75 @@ void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCom ...@@ -138,45 +151,75 @@ void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCom
*/ */
#endif #endif
} }
}
/* other file names.....*/
/* chamber file */
else if (strcmp("chamber_file", name) == 0){
sscanf(line, "%*s %s", str);
sprintf(chamber_file,"%s%s", in_dir, str); /* add file directory of the chamber file*/
} }
/* other file names.....*/
else if (strcmp("multipole_file", name) == 0){ else if (strcmp("multipole_file", name) == 0){
sscanf(line, "%*s %s", str); sscanf(line, "%*s %s", str);
sprintf(multipole_file,"%s%s", in_dir, str); /* add file directory of the multipole file*/ sprintf(multipole_file,"%s%s", in_dir, str); /* add file directory of the multipole file*/
} }
/* read in bool flags */ /* read in bool flags */
//print twiss parameters flag else if (strcmp("QuadFringeOnFlag", name) == 0){
else if (strcmp("PrintTwissFlag", name) == 0){
sscanf(line, "%*s %s", twiss_file);
strcpy(UserCommandFlag[CommNo].CommandStr,name); strcpy(UserCommandFlag[CommNo].CommandStr,name);
} }
//print close orbit(COD) flag else if (strcmp("RFvoltageFlag", name) == 0){
else if (strcmp("PrintCODFlag", name) == 0){ sscanf(line, "%*s %lf", &(UserCommandFlag[CommNo].RFvolt));
sscanf(line, "%*s %s", cod_file);
strcpy(UserCommandFlag[CommNo].CommandStr,name); strcpy(UserCommandFlag[CommNo].CommandStr,name);
} }
//read chamber file flat //read chamber file flat
else if (strcmp("ReadChamberFlag", name) == 0){ else if (strcmp("ReadChamberFlag", name) == 0){
strcpy(UserCommandFlag[CommNo].CommandStr,name); sscanf(line, "%*s %s", str);
sprintf(UserCommandFlag[CommNo].chamber_file,"%s%s", in_dir, str);
strcpy(UserCommandFlag[CommNo].CommandStr,name);
} }
//read field error, GENERIC command
else if (strcmp("QuadFringeOnFlag", name) == 0){ else if (strcmp("ReadfefileFlag", name) == 0){
sscanf(line, "%*s %s", str);
sprintf(UserCommandFlag[CommNo].fe_file,"%s%s", in_dir, str);
strcpy(UserCommandFlag[CommNo].CommandStr,name); strcpy(UserCommandFlag[CommNo].CommandStr,name);
} }
//read misalignment error, then do orbit correction
else if (strcmp("ReadaefileFlag", name) == 0){
sscanf(line, "%*s %s", str);
sprintf(UserCommandFlag[CommNo].ae_file,"%s%s", in_dir, str);
strcpy(UserCommandFlag[CommNo].CommandStr,name);
}
else if (strcmp("RFvoltageFlag", name) == 0){ //read multipole errors; specific for SOLEIL lattice
sscanf(line, "%*s %lf", &(UserCommandFlag[CommNo].RFvolt)); else if (strcmp("ReadMultipoleFlag", name) == 0){
strcpy(UserCommandFlag[CommNo].CommandStr,name);
}else if (strcmp("fic_hcorr", name) == 0){// read of h-correctors for multipoles
sscanf(line, "%*s %s", str);
sprintf(fic_hcorr,"%s%s", in_dir, str);
}else if (strcmp("fic_vcorr", name) == 0){// read of v-correctors for multipoles
sscanf(line, "%*s %s", str);
sprintf(fic_vcorr,"%s%s", in_dir, str);
}else if (strcmp("fic_skew", name) == 0){// read of skew quads for multipoles
sscanf(line, "%*s %s", str);
sprintf(fic_skew,"%s%s", in_dir, str);
}
//print twiss parameters flag
else if (strcmp("PrintTwissFlag", name) == 0){
sscanf(line, "%*s %s", twiss_file);
strcpy(UserCommandFlag[CommNo].CommandStr,name); strcpy(UserCommandFlag[CommNo].CommandStr,name);
}
//print close orbit(COD) flag
else if (strcmp("PrintCODFlag", name) == 0){
sscanf(line, "%*s %s", cod_file);
strcpy(UserCommandFlag[CommNo].CommandStr,name);
}
//print close orbit(COD) flag
else if (strcmp("PrintGirderFlag", name) == 0){
sscanf(line, "%*s %s", girder_file);
strcpy(UserCommandFlag[CommNo].CommandStr,name);
} }
else if (strcmp("TuneTracFlag", name) == 0){ else if (strcmp("TuneTracFlag", name) == 0){
strcpy(UserCommandFlag[CommNo].CommandStr,name); strcpy(UserCommandFlag[CommNo].CommandStr,name);
} }
...@@ -276,23 +319,7 @@ void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCom ...@@ -276,23 +319,7 @@ void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCom
); );
strcpy(UserCommandFlag[CommNo].CommandStr,name); strcpy(UserCommandFlag[CommNo].CommandStr,name);
} }
else if (strcmp("ReadMultipoleFlag", name) == 0){
strcpy(UserCommandFlag[CommNo].CommandStr,name);
}
else if (strcmp("fic_hcorr", name) == 0){// read of h-correctors for multipoles
sscanf(line, "%*s %s", str);
sprintf(fic_hcorr,"%s%s", in_dir, str);
}
else if (strcmp("fic_vcorr", name) == 0){// read of v-correctors for multipoles
sscanf(line, "%*s %s", str);
sprintf(fic_vcorr,"%s%s", in_dir, str);
}
else if (strcmp("fic_skew", name) == 0){// read of skew quads for multipoles
sscanf(line, "%*s %s", str);
sprintf(fic_skew,"%s%s", in_dir, str);
}
// generic one, fit for 1 family of quadrupoles // generic one, fit for 1 family of quadrupoles
else if (strcmp("FitTuneFlag", name) == 0){ else if (strcmp("FitTuneFlag", name) == 0){
sscanf(line, "%*s %s %s %lf %lf",UserCommandFlag[CommNo].qf,UserCommandFlag[CommNo].qd, sscanf(line, "%*s %s %s %lf %lf",UserCommandFlag[CommNo].qf,UserCommandFlag[CommNo].qd,
...@@ -369,8 +396,52 @@ void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCom ...@@ -369,8 +396,52 @@ void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCom
else if (strcmp("TousTrackFlag", name) == 0){ else if (strcmp("TousTrackFlag", name) == 0){
strcpy(UserCommandFlag[CommNo].CommandStr,name); strcpy(UserCommandFlag[CommNo].CommandStr,name);
} }
else { //correctors for COD correction
else if (strcmp("hcorr_file", name) == 0){
sscanf(line, "%*s %s", str);
sprintf(hcorr_file,"%s%s", in_dir, str); /* add file directory of the multipole file*/
}
else if (strcmp("vcorr_file", name) == 0){
sscanf(line, "%*s %s", str);
sprintf(vcorr_file,"%s%s", in_dir, str); /* add file directory of the multipole file*/
}
else if (strcmp("bpm_name", name) == 0){
sscanf(line, "%*s %s", bpm_name); /* the name of bpm */
}
else if (strcmp("h_corr", name) == 0){
sscanf(line, "%*s %s", hcorr_name); /* the name of H corrector used for COD correction*/
}
else if (strcmp("v_corr", name) == 0){
sscanf(line, "%*s %s", vcorr_name); /* the name of V corrector used for COD correction*/
}
else if (strcmp("qt", name) == 0){
sscanf(line, "%*s %s", skew_quad_name); /* name of skew quadrupoles */
}
else if (strcmp("gs", name) == 0){
sscanf(line, "%*s %s", gs_name); /* name of start of the girder */
}
else if (strcmp("ge", name) == 0){
sscanf(line, "%*s %s", ge_name); /* name of end of the girder */
}
//set parameters for COD correction
else if (strcmp("n_orbit", name) == 0){
sscanf(line, "%*s %d", &n_orbit);
}
else if (strcmp("n_scale", name) == 0){
sscanf(line, "%*s %d", &n_scale);
}
else if (strcmp("n_stat", name) == 0){
sscanf(line, "%*s %d", &n_stat);
}
else if (strcmp("nwh", name) == 0){
sscanf(line, "%*s %d", &nwh);
}
else if (strcmp("nwv", name) == 0){
sscanf(line, "%*s %d", &nwv);
}
else{
printf("bad line in file %s, line %ld \n", full_param_file_name, LineNum); printf("bad line in file %s, line %ld \n", full_param_file_name, LineNum);
exit_(1); exit_(1);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment