1 | // global params |
---|
2 | |
---|
3 | extern char in_dir[]; |
---|
4 | |
---|
5 | extern bool DA_bare, freq_map, tune_shift; |
---|
6 | extern int n_aper, n_track, n_orbit, n_scale; |
---|
7 | |
---|
8 | extern bool bba; |
---|
9 | extern int n_lin, |
---|
10 | SQ_per_scell, BPM_per_scell, HCM_per_scell, VCM_per_scell; |
---|
11 | extern double kick; |
---|
12 | extern int n_stat; |
---|
13 | |
---|
14 | extern double VDweight, HVweight, VHweight; |
---|
15 | |
---|
16 | extern int n_x, n_y, n_dp, n_tr; |
---|
17 | extern double x_max_FMA, y_max_FMA, delta_FMA; |
---|
18 | |
---|
19 | extern double delta_DA_; |
---|
20 | |
---|
21 | extern char ae_file[max_str], fe_file[max_str], ap_file[max_str]; |
---|
22 | |
---|
23 | //For ID correction |
---|
24 | extern const int N_Fam_max; //number of quadrupoles for ID correction |
---|
25 | extern int N_calls, N_steps, N_Fam, Q_Fam[]; |
---|
26 | extern double scl_nux,scl_nuy, scl_dbetax,scl_dbetay, scl_dnux,scl_dnuy, ID_step; |
---|
27 | |
---|
28 | |
---|
29 | extern double disp_wave_y; |
---|
30 | extern Vector2 beta_ref; |
---|
31 | |
---|
32 | extern ss_vect<tps> map; |
---|
33 | extern MNF_struct MNF; |
---|
34 | |
---|
35 | void lwr_case(char str[]); |
---|
36 | |
---|
37 | void upr_case(char str[]); |
---|
38 | |
---|
39 | //void prt_trace (void); |
---|
40 | |
---|
41 | void file_rd(ifstream &inf, const char file_name[]); |
---|
42 | |
---|
43 | void file_wr(ofstream &outf, const char file_name[]); |
---|
44 | |
---|
45 | FILE* file_read(const char file_name[]); |
---|
46 | |
---|
47 | FILE* file_write(const char file_name[]); |
---|
48 | |
---|
49 | void chk_cod(const bool cod, const char *proc_name); |
---|
50 | |
---|
51 | void no_sxt(void); |
---|
52 | |
---|
53 | void get_map(void); |
---|
54 | |
---|
55 | tps get_h(void); |
---|
56 | |
---|
57 | void get_m2(const ss_vect<tps> &ps, tps m2[]); |
---|
58 | |
---|
59 | ss_vect<tps> get_S(const int n_DOF); |
---|
60 | |
---|
61 | ss_vect<tps> tp_S(const int n_DOF, const ss_vect<tps> &A); |
---|
62 | |
---|
63 | void get_dnu(const ss_vect<tps> &A, double dnu[]); |
---|
64 | |
---|
65 | ss_vect<tps> get_A_CS(const ss_vect<tps> &A, double dnu[]); |
---|
66 | |
---|
67 | void get_twoJ(const int n_DOF, const ss_vect<double> &ps, |
---|
68 | const ss_vect<tps> &A, double twoJ[]); |
---|
69 | |
---|
70 | double get_curly_H(const double alpha_x, const double beta_x, |
---|
71 | const double eta_x, const double etap_x); |
---|
72 | |
---|
73 | double get_eps_x(void); |
---|
74 | |
---|
75 | void GetEmittance(const int Fnum, const bool prt); |
---|
76 | |
---|
77 | void prt_lat(const char *fname, const int Fnum, const bool all); |
---|
78 | |
---|
79 | void prt_chrom_lat(void); |
---|
80 | |
---|
81 | void prt_cod(const char *file_name, const int Fnum, const bool all); |
---|
82 | |
---|
83 | void prt_beampos(const char *file_name); |
---|
84 | |
---|
85 | void CheckAlignTol(const char *OutputFile); |
---|
86 | |
---|
87 | void misalign_rms_elem(const int Fnum, const int Knum, |
---|
88 | const double dx_rms, const double dy_rms, |
---|
89 | const double dr_rms, const bool new_rnd); |
---|
90 | |
---|
91 | void misalign_sys_elem(const int Fnum, const int Knum, |
---|
92 | const double dx_sys, const double dy_sys, |
---|
93 | const double dr_sys); |
---|
94 | |
---|
95 | void misalign_rms_fam(const int Fnum, |
---|
96 | const double dx_rms, const double dy_rms, |
---|
97 | const double dr_rms, const bool new_rnd); |
---|
98 | |
---|
99 | void misalign_sys_fam(const int Fnum, |
---|
100 | const double dx_sys, const double dy_sys, |
---|
101 | const double dr_sys); |
---|
102 | |
---|
103 | void misalign_rms_type(const int type, |
---|
104 | const double dx_rms, const double dy_rms, |
---|
105 | const double dr_rms, const bool new_rnd); |
---|
106 | |
---|
107 | void misalign_sys_type(const int type, |
---|
108 | const double dx_sys, const double dy_sys, |
---|
109 | const double dr_sys); |
---|
110 | |
---|
111 | void misalign_rms_girders(const int gs, const int ge, |
---|
112 | const double dx_rms, const double dy_rms, |
---|
113 | const double dr_rms, const bool new_rnd); |
---|
114 | |
---|
115 | void misalign_sys_girders(const int gs, const int ge, |
---|
116 | const double dx_sys, const double dy_sys, |
---|
117 | const double dr_sys); |
---|
118 | |
---|
119 | void LoadAlignTol(const char *AlignFile, const bool Scale_it, |
---|
120 | const double Scale, const bool new_rnd, const int k); |
---|
121 | |
---|
122 | void set_aper_elem(const int Fnum, const int Knum, |
---|
123 | const double Dxmin, const double Dxmax, |
---|
124 | const double Dymin, const double Dymax); |
---|
125 | |
---|
126 | void set_aper_fam(const int Fnum, |
---|
127 | const double Dxmin, const double Dxmax, |
---|
128 | const double Dymin, const double Dymax); |
---|
129 | |
---|
130 | void set_aper_type(const int type, const double Dxmin, const double Dxmax, |
---|
131 | const double Dymin, const double Dymax); |
---|
132 | |
---|
133 | void LoadApers(const char *AperFile, const double scl_x, const double scl_y); |
---|
134 | |
---|
135 | double get_L(const int Fnum, const int Knum); |
---|
136 | |
---|
137 | void set_L(const int Fnum, const int Knum, const double L); |
---|
138 | |
---|
139 | void set_L(const int Fnum, const double L); |
---|
140 | |
---|
141 | void set_dL(const int Fnum, const int Knum, const double dL); |
---|
142 | |
---|
143 | void get_bn_design_elem(const int Fnum, const int Knum, |
---|
144 | const int n, double &bn, double &an); |
---|
145 | |
---|
146 | void get_bnL_design_elem(const int Fnum, const int Knum, |
---|
147 | const int n, double &bnL, double &anL); |
---|
148 | |
---|
149 | void set_bn_design_elem(const int Fnum, const int Knum, |
---|
150 | const int n, const double bn, const double an); |
---|
151 | |
---|
152 | void set_dbn_design_elem(const int Fnum, const int Knum, |
---|
153 | const int n, const double dbn, const double dan); |
---|
154 | |
---|
155 | void set_bn_design_fam(const int Fnum, |
---|
156 | const int n, const double bn, const double an); |
---|
157 | |
---|
158 | void set_dbn_design_fam(const int Fnum, |
---|
159 | const int n, const double dbn, const double dan); |
---|
160 | |
---|
161 | void set_bnL_design_elem(const int Fnum, const int Knum, |
---|
162 | const int n, const double bnL, const double anL); |
---|
163 | |
---|
164 | void set_dbnL_design_elem(const int Fnum, const int Knum, |
---|
165 | const int n, const double dbnL, const double danL); |
---|
166 | |
---|
167 | void set_bnL_design_fam(const int Fnum, |
---|
168 | const int n, const double bnL, const double anL); |
---|
169 | |
---|
170 | void set_dbnL_design_fam(const int Fnum, |
---|
171 | const int n, const double dbnL, const double danL); |
---|
172 | |
---|
173 | void set_bnL_design_type(const int type, |
---|
174 | const int n, const double bnL, const double anL); |
---|
175 | |
---|
176 | void set_bnL_sys_elem(const int Fnum, const int Knum, |
---|
177 | const int n, const double bnL, const double anL); |
---|
178 | |
---|
179 | void set_bnL_sys_fam(const int Fnum, |
---|
180 | const int n, const double bnL, const double anL); |
---|
181 | |
---|
182 | void set_bnL_sys_type(const int type, |
---|
183 | const int n, const double bnL, const double anL); |
---|
184 | |
---|
185 | void set_bnL_rms_elem(const int Fnum, const int Knum, |
---|
186 | const int n, const double bnL, const double anL, |
---|
187 | const bool new_rnd); |
---|
188 | |
---|
189 | void set_bnL_rms_fam(const int Fnum, |
---|
190 | const int n, const double bnL, const double anL, |
---|
191 | const bool new_rnd); |
---|
192 | |
---|
193 | void set_bnL_rms_type(const int type, |
---|
194 | const int n, const double bnL, const double anL, |
---|
195 | const bool new_rnd); |
---|
196 | |
---|
197 | void set_bnr_sys_elem(const int Fnum, const int Knum, |
---|
198 | const int n, const double bnr, const double anr); |
---|
199 | |
---|
200 | void set_bnr_sys_fam(const int Fnum, |
---|
201 | const int n, const double bnr, const double anr); |
---|
202 | |
---|
203 | void set_bnr_sys_type(const int type, |
---|
204 | const int n, const double bnr, const double anr); |
---|
205 | |
---|
206 | void set_bnr_rms_elem(const int Fnum, const int Knum, |
---|
207 | const int n, const double bnr, const double anr, |
---|
208 | const bool new_rnd); |
---|
209 | |
---|
210 | void set_bnr_rms_fam(const int Fnum, |
---|
211 | const int n, const double bnr, const double anr, |
---|
212 | const bool new_rnd); |
---|
213 | |
---|
214 | void set_bnr_rms_type(const int type, |
---|
215 | const int n, const double bnr, const double anr, |
---|
216 | const bool new_rnd); |
---|
217 | |
---|
218 | double get_Wiggler_BoBrho(const int Fnum, const int Knum); |
---|
219 | |
---|
220 | void set_Wiggler_BoBrho(const int Fnum, const int Knum, const double BoBrhoV); |
---|
221 | |
---|
222 | void set_Wiggler_BoBrho(const int Fnum, const double BoBrhoV); |
---|
223 | |
---|
224 | void set_ID_scl(const int Fnum, const int Knum, const double scl); |
---|
225 | |
---|
226 | void SetFieldValues_fam(const int Fnum, const bool rms, const double r0, |
---|
227 | const int n, const double Bn, const double An, |
---|
228 | const bool new_rnd); |
---|
229 | |
---|
230 | void SetFieldValues_type(const int N, const bool rms, const double r0, |
---|
231 | const int n, const double Bn, const double An, |
---|
232 | const bool new_rnd); |
---|
233 | |
---|
234 | void SetFieldErrors(const char *name, const bool rms, const double r0, |
---|
235 | const int n, const double Bn, const double An, |
---|
236 | const bool new_rnd); |
---|
237 | |
---|
238 | char* get_prm(void); |
---|
239 | |
---|
240 | void LoadFieldErr(const char *FieldErrorFile, const bool Scale_it, |
---|
241 | const double Scale, const bool new_rnd); |
---|
242 | |
---|
243 | bool CorrectCOD(int n_orbit); |
---|
244 | |
---|
245 | void Align_BPMs(const int n); |
---|
246 | |
---|
247 | void get_bare(); |
---|
248 | |
---|
249 | void get_dbeta_dnu(double m_dbeta[], double s_dbeta[], |
---|
250 | double m_dnu[], double s_dnu[]); |
---|
251 | |
---|
252 | bool CorrectCOD_N(const char *ae_file, const int n_orbit, |
---|
253 | const int n, const int k); |
---|
254 | |
---|
255 | void ini_skew_cor(const double deta_y_max); |
---|
256 | |
---|
257 | void corr_eps_y(void); |
---|
258 | |
---|
259 | void get_IDs(void); |
---|
260 | |
---|
261 | void set_IDs(const double scl); |
---|
262 | |
---|
263 | void reset_quads(void); |
---|
264 | |
---|
265 | void ini_ID_corr(void); |
---|
266 | |
---|
267 | // From Taiwan light source |
---|
268 | bool ID_corr0(void); |
---|
269 | |
---|
270 | bool ID_corr(const int N_calls, const int N_steps); |
---|
271 | |
---|
272 | void get_param(const char *param_file); |
---|
273 | |
---|
274 | void error_and_correction(const char *param_file, bool rd_lat); |
---|
275 | |
---|
276 | void prt_codcor_lat(void); |
---|
277 | |
---|
278 | void prt_beamsizes(); |
---|
279 | |
---|
280 | double Touschek(const double Qb, const double delta_RF, |
---|
281 | const double eps_x, const double eps_y, |
---|
282 | const double sigma_delta, const double sigma_s); |
---|
283 | |
---|
284 | double Touschek(const double Qb, const double delta_RF,const bool consistent, |
---|
285 | const double eps_x, const double eps_y, |
---|
286 | const double sigma_delta, double sigma_s, |
---|
287 | const int n_turn, const bool aper_on, |
---|
288 | double sum_delta[][2], double sum2_delta[][2]); |
---|
289 | |
---|
290 | void IBS(const double Qb, |
---|
291 | const double eps_SR[], double eps[], |
---|
292 | const double alpha_z, const double beta_z); |
---|
293 | |
---|
294 | void rm_space(char *name); |
---|
295 | |
---|
296 | void get_bn(char file_name[], int n, const bool prt); |
---|
297 | |
---|
298 | double get_dynap(const double delta); |
---|
299 | |
---|
300 | double get_chi2(long int n, double x[], double y[], long int m, Vector b); |
---|
301 | |
---|
302 | void pol_fit(int n, double x[], double y[], int order, Vector &b, |
---|
303 | double &sigma); |
---|
304 | |
---|
305 | void get_ksi2(const double d_delta); |
---|
306 | |
---|
307 | bool get_nu(const double Ax, const double Ay, const double delta, |
---|
308 | double &nu_x, double &nu_y); |
---|
309 | |
---|
310 | void dnu_dA(const double Ax_max, const double Ay_max, const double delta); |
---|
311 | |
---|
312 | bool orb_corr(const int n_orbit); |
---|
313 | |
---|
314 | double get_code(CellType &Cell); |
---|
315 | |
---|
316 | void get_alphac(void); |
---|
317 | |
---|
318 | void get_alphac2(void); |
---|
319 | |
---|
320 | void bend_cal_Fam(const int Fnum); |
---|
321 | |
---|
322 | void bend_cal(void); |
---|
323 | |
---|
324 | double h_ijklm(const tps &h, const int i, const int j, const int k, |
---|
325 | const int l, const int m); |
---|
326 | |
---|
327 | ss_vect<tps> get_A(const double alpha[], const double beta[], |
---|
328 | const double eta[], const double etap[]); |
---|
329 | |
---|
330 | |
---|
331 | void get_ab(const ss_vect<tps> &A, |
---|
332 | double alpha[], double beta[], double eta[], double etap[]); |
---|
333 | |
---|
334 | void set_tune(const char file_name1[], const char file_name2[], const int n); |
---|
335 | |
---|
336 | void prt_H_long(const int n, const double phi_max, const double delta_max, |
---|
337 | const double U0); |
---|