source: TRACY3/trunk/tracy/tracy/src/read_script.cc @ 32

Last change on this file since 32 was 32, checked in by zhangj, 10 years ago

active the transport of the twiss functions and orbits of the transfer line.

  • Property svn:executable set to *
File size: 23.3 KB
Line 
1/****************************************************************************/
2/* void read_script(const char *param_file_name, bool rd_lat)
3
4   Purpose:
5       read script written by the user.
6       1) User can specify lattice file name, vacuum chamber name, and bool flags such as tune
7          tracking flag, tune shift with energy flag, etc.
8       2) In this function, Lattice is read, bool flags are set.
9
10   Input:
11       param_file_name  user script name
12
13   Output:
14       none
15
16   Return:
17       global values and global bool flags
18
19   Global variables:
20       bool flags
21
22   specific functions:
23       Read_Lattice()
24
25   Comments:
26       Written by Jianfeng Zhang 03/2011 soleil
27       
28       (1) 15/10/2013 by Jianfeng Zhang @ LAL
29           Fix the bugs of fgets():
30              to read lines with arbritracy length,
31              to read the empty space at the end of the line.
32             
33           Remove the rontine to move the address of "line" if the
34           contents of "line" is empty space; otherwise free() can't
35           find the orignial address of "line".
36           
37
38****************************************************************************/
39
40/* files */ 
41
42char    lat_file[max_str]="voidlattice";
43// girder file
44char girder_file[max_str];
45
46
47
48 // multipole files; for soleil lattice
49char multipole_file[max_str];
50  // multipole file for soleil lattice
51char fic_hcorr[max_str],fic_vcorr[max_str], fic_skew[max_str];
52 // files to set sources of coupling; for SOLEIL lattice
53char virtualskewquad_file[max_str];
54
55//errors
56//char fe_file[max_str]; //the same as multipole_file[max_str]????
57
58/* COD correction */
59int nwh = 56, nwv = 56; //number of singular values for SVD correction
60
61/* ID compensation */ 
62char   IDCq_name[max_str][11];
63
64
65//multipole field error correction (SOLEIL based)
66char hcorr_file[max_str], vcorr_file[max_str]; //files with the status of hcorr/vcorr status,
67                                                  //to choose which correctors are used for orbit correction
68//default name of special elements in lattice
69char hcorr_name[max_str] = "", vcorr_name[max_str] = "";
70char skew_quad_name[max_str] = "", bpm_name[max_str] = "";
71char gs_name[max_str] = "", ge_name[max_str] = "";
72                                                 
73#define OLD_LATTICE
74
75/*  Read script   */
76void read_script(const char *param_file_name, bool rd_lat, long& CommNo, UserCommand UserCommandFlag[])
77 {
78 
79 
80  char    str[max_str]="", dummy[max_str]="",dummy2[max_str]="", nextpara[max_str]="";
81  char    in[max_str]="";  //temporary line with preceding white space
82  char    *line = NULL; //line to store the command without preceding white space
83  size_t   len = 0;
84  ssize_t  read;
85  char    name[max_str]=""; //initialize with empty character array.
86 // char    lat_file[max_str]="voidlattice";
87  char    EndName[5]="";
88
89  FILE    *inf;
90  const bool  prt = false; // for debugging printout each line of input file
91  long int    LineNum=0L;
92  long int    NameLen=0L;
93  int idummy=0;
94  char full_param_file_name[max_str]="";
95  char lat_FileName[max_str]="";
96 //bool TuneTracFlag;
97  char *pch;
98 
99   
100  // Manipulation of the parameter file
101  strcpy(dummy, param_file_name);
102
103  sprintf(full_param_file_name,"%s",dummy);
104  if (!prt) printf("\n reading in script file: %s\n",full_param_file_name);
105
106  //
107  inf = file_read(full_param_file_name);
108   if(inf == NULL){
109     printf("read_script(): Error! Read File %s Failure!\n",full_param_file_name);
110     exit_(1); 
111  }
112 
113  // read parameter file, line by line
114   while ((read = getline(&line, &len, inf)) != -1) {
115     
116     LineNum++;
117     if(!prt){
118       printf("Line # %ld \n",LineNum);
119       printf("Retrieved line of length %zu : \n",read);
120       cout << line << endl;
121     }
122               
123     
124           
125    /* read the end of line symbol '\n','\r' or '\r\n' at different operation system*/
126    if (strstr(line, "#") == NULL && line[0] != '\n' &&
127        line[0] != '\r' && strcmp(line, "\r\n") != 0 ){
128   
129       
130      // get initial command token
131      sscanf(line, "%s", name); 
132      //initialize the nextpara for each new command line
133      strcpy(nextpara,"voidpara");
134     
135     
136      //find the sequence of the bool flag in user input script
137      NameLen = strlen(name);
138      if(NameLen >= 4 ){
139        EndName[0] = name[NameLen-4];
140        EndName[1] = name[NameLen-3];
141        EndName[2] = name[NameLen-2];
142        EndName[3] = name[NameLen-1];         
143      }
144      //find the bool flag whose last 4 character are 'Flag'
145      if(strcmp(EndName,"Flag")==0)
146           CommNo++;
147       
148         
149      /*read file names................. */
150      /* set file directory*/
151      if (strcmp("in_dir", name) == 0)
152        sscanf(line, "%*s %s", in_dir);
153      /* lattice file......*/
154      else if (strcmp("lat_file", name) == 0){ 
155        sscanf(line, "%*s %s", lat_file);
156        sprintf(lat_FileName, "%s%s", in_dir, lat_file); 
157        if(rd_lat) {
158         #ifdef OLD_LATTICE
159            fprintf(stderr, "Reading lattice");
160            Read_Lattice(lat_FileName);
161         #else
162 /*           fprintf(stderr, "Reading lattice with new parser\n");
163            sprintf(lat_FileName, "%s%s.lat", in_dir, lat_file);
164            parse_lattice_flat(lat_FileName, "new.flat");
165            fprintf(stderr, "Parse the lattice into new.flat\n");
166            rdmfile("new.flat");
167            sprintf(lat_FileName, "%s%s", in_dir, lat_file);
168*/
169         #endif
170        } 
171     
172      } 
173     
174      /* other file names.....*/ 
175      else if (strcmp("multipole_file", name) == 0){ 
176        sscanf(line, "%*s %s", str);
177        sprintf(multipole_file,"%s%s", in_dir, str); /* add file directory of the multipole file*/
178      } //virtual skew quadrupole file; for soleil lattice
179        else if (strcmp("virtualskewquad_file", name) == 0){ 
180        sscanf(line, "%*s %s", str);
181        sprintf(virtualskewquad_file,"%s%s", in_dir, str); /* add file directory of the multipole file*/
182      } 
183     
184      /* read in bool flags */
185        else if (strcmp("QuadFringeOnFlag", name) == 0){
186          strcpy(UserCommandFlag[CommNo].CommandStr,name);
187      } 
188        else if (strcmp("QuadFringeOffFlag", name) == 0){
189          strcpy(UserCommandFlag[CommNo].CommandStr,name);
190      } 
191        else if (strcmp("RFvoltageFlag", name) == 0){
192          sscanf(line, "%*s %lf", &(UserCommandFlag[CommNo].RFvolt));
193          strcpy(UserCommandFlag[CommNo].CommandStr,name);
194      }
195       
196      //read chamber file flat
197      else if (strcmp("ReadChamberFlag", name) == 0){
198          sscanf(line, "%*s %s", str);
199          sprintf(UserCommandFlag[CommNo].chamber_file,"%s%s", in_dir, str);
200          strcpy(UserCommandFlag[CommNo].CommandStr,name);
201       } 
202       //read field error, GENERIC command
203      else if (strcmp("ReadfefileFlag", name) == 0){
204          sscanf(line, "%*s %s", str);
205          sprintf(UserCommandFlag[CommNo].fe_file,"%s%s", in_dir, str);
206          strcpy(UserCommandFlag[CommNo].CommandStr,name);
207       }     
208       //read misalignment error, then do orbit correction
209      else if (strcmp("ReadaefileFlag", name) == 0){
210          sscanf(line, "%*s %s", str);
211          sprintf(UserCommandFlag[CommNo].ae_file,"%s%s", in_dir, str);
212          strcpy(UserCommandFlag[CommNo].CommandStr,name);
213       } 
214      //read multipole errors; specific for SOLEIL lattice
215      else if (strcmp("ReadMultipoleFlag", name) == 0){
216            strcpy(UserCommandFlag[CommNo].CommandStr,name);
217      }else if (strcmp("fic_hcorr", name) == 0){// read of h-correctors for multipoles
218        sscanf(line, "%*s %s", str);
219        sprintf(fic_hcorr,"%s%s", in_dir, str);
220      }else if (strcmp("fic_vcorr", name) == 0){// read of v-correctors for multipoles
221        sscanf(line, "%*s %s", str);
222        sprintf(fic_vcorr,"%s%s", in_dir, str);
223      }else if (strcmp("fic_skew", name) == 0){// read of skew quads for multipoles
224        sscanf(line, "%*s %s", str);
225        sprintf(fic_skew,"%s%s", in_dir, str);
226      }
227      // for soleil lattice
228      else if (strcmp("ReadVirtualSkewquadFlag", name) == 0){
229            strcpy(UserCommandFlag[CommNo].CommandStr,name); 
230      }
231       //print twiss parameters flag
232      else if (strcmp("PrintTwissFlag", name) == 0){
233         sscanf(line, "%*s %s",nextpara);
234         
235          if(strcmp(nextpara,"voidpara")!=0)
236            sscanf(line, "%*s %s", UserCommandFlag[CommNo]._PrintTwiss_twiss_file);
237           
238          strcpy(UserCommandFlag[CommNo].CommandStr,name);
239      } 
240       //print close orbit(COD) flag
241      else if (strcmp("PrintCODFlag", name) == 0){
242        sscanf(line, "%*s %s",nextpara);
243         
244        if(strcmp(nextpara,"voidpara")!=0)
245           sscanf(line, "%*s %s", UserCommandFlag[CommNo]._PrintCOD_cod_file);
246         
247        strcpy(UserCommandFlag[CommNo].CommandStr,name); 
248      }
249      //print the cooridinates using tracking at each element
250      else if (strcmp("PrintTrackFlag", name) == 0){
251          sscanf(line, "%*s %s",nextpara);
252         
253          if(strcmp(nextpara,"voidpara")!=0)
254            sscanf(line, "%*s %s %lf %lf %lf %lf %lf %lf %ld", 
255                        UserCommandFlag[CommNo]._PrintTrack_track_file,
256                        &(UserCommandFlag[CommNo]._PrintTrack_x), 
257                        &(UserCommandFlag[CommNo]._PrintTrack_px),
258                        &(UserCommandFlag[CommNo]._PrintTrack_y), 
259                        &(UserCommandFlag[CommNo]._PrintTrack_py), 
260                        &(UserCommandFlag[CommNo]._PrintTrack_delta), 
261                        &(UserCommandFlag[CommNo]._PrintTrack_ctau),
262                        &(UserCommandFlag[CommNo]._PrintTrack_nmax));
263          strcpy(UserCommandFlag[CommNo].CommandStr,name);
264      } 
265      //print the cooridinates using tracking at each element
266      else if (strcmp("PrintTrackElemFlag", name) == 0){
267          sscanf(line, "%*s %s",nextpara);
268         
269          if(strcmp(nextpara,"voidpara")!=0)
270            sscanf(line, "%*s %s %lf %lf %lf %lf %lf %lf %ld %ld", 
271                        UserCommandFlag[CommNo]._PrintTrackElem_track_file,
272                        &(UserCommandFlag[CommNo]._PrintTrackElem_x), 
273                        &(UserCommandFlag[CommNo]._PrintTrackElem_px),
274                        &(UserCommandFlag[CommNo]._PrintTrackElem_y), 
275                        &(UserCommandFlag[CommNo]._PrintTrackElem_py), 
276                        &(UserCommandFlag[CommNo]._PrintTrackElem_delta), 
277                        &(UserCommandFlag[CommNo]._PrintTrackElem_ctau),
278                        &(UserCommandFlag[CommNo]._PrintTrackElem_nelem1),
279                        &(UserCommandFlag[CommNo]._PrintTrackElem_nelem2));
280          strcpy(UserCommandFlag[CommNo].CommandStr,name);
281      } 
282      //print close orbit(COD) flag
283      else if (strcmp("PrintGirderFlag", name) == 0){
284          sscanf(line, "%*s %s", girder_file);
285          strcpy(UserCommandFlag[CommNo].CommandStr,name); 
286      }
287     
288     
289      else if (strcmp("TuneTracFlag", name) == 0){
290         strcpy(UserCommandFlag[CommNo].CommandStr,name);
291      }
292      else if (strcmp("ChromTracFlag", name) == 0){
293           strcpy(UserCommandFlag[CommNo].CommandStr,name);
294      }
295      // FMA
296      else if (strcmp("FmapFlag", name) == 0){       
297          strcpy(dummy, "");
298          strcpy(dummy2,"");
299          sscanf(line, "%*s %s",nextpara);
300         
301          //if no definition of loss flag in the lattice file, then "dummy2" is empty string.
302          if(strcmp(nextpara,"voidpara")!=0)
303            sscanf(line, "%*s %s %ld %ld %ld %lf %lf %lf %s %s", 
304                          UserCommandFlag[CommNo]._FmapFlag_fmap_file,
305                          &(UserCommandFlag[CommNo]._FmapFlag_nxpoint), 
306                          &(UserCommandFlag[CommNo]._FmapFlag_nypoint),
307                          &(UserCommandFlag[CommNo]._FmapFlag_nturn), 
308                          &(UserCommandFlag[CommNo]._FmapFlag_xmax), 
309                          &(UserCommandFlag[CommNo]._FmapFlag_ymax),
310                          &(UserCommandFlag[CommNo]._FmapFlag_delta), 
311                          dummy,dummy2);
312         
313        if(strcmp(dummy, "true") == 0)
314          UserCommandFlag[CommNo]._FmapFlag_diffusion = true;
315        else if(strcmp(dummy, "false") == 0)
316          UserCommandFlag[CommNo]._FmapFlag_diffusion = false;
317       
318        if(strcmp(dummy2, "true") == 0)
319          UserCommandFlag[CommNo]._FmapFlag_printloss = true;
320        else if(strcmp(dummy2, "false") == 0)
321          UserCommandFlag[CommNo]._FmapFlag_printloss = false;
322        else
323          UserCommandFlag[CommNo]._FmapFlag_printloss = false;
324       
325       
326        //cout << "debug:      " << line << endl;
327        //cout << "dummy2 =  " << dummy2 << "     lossflag =  " << UserCommandFlag[CommNo]._FmapFlag_printloss << endl;
328       
329       // FmapFlag = true;
330         strcpy(UserCommandFlag[CommNo].CommandStr,name);
331      }
332      // FMA dp
333      else if (strcmp("FmapdpFlag", name) == 0){         
334          strcpy(dummy, "");
335          strcpy(dummy2,"");
336          sscanf(line, "%*s %s",nextpara);
337         
338          if(strcmp(nextpara,"voidpara")!=0)
339            sscanf(line, "%*s %s %ld %ld %ld %lf %lf %lf %s %s", 
340                        UserCommandFlag[CommNo]._FmapdpFlag_fmapdp_file,
341                        &(UserCommandFlag[CommNo]._FmapdpFlag_nxpoint),
342                        &(UserCommandFlag[CommNo]._FmapdpFlag_nepoint),
343                        &(UserCommandFlag[CommNo]._FmapdpFlag_nturn), 
344                        &(UserCommandFlag[CommNo]._FmapdpFlag_xmax), 
345                        &(UserCommandFlag[CommNo]._FmapdpFlag_emax),
346                        &(UserCommandFlag[CommNo]._FmapdpFlag_z), 
347                        dummy,dummy2);
348         
349        if(strcmp(dummy, "true") == 0)
350          UserCommandFlag[CommNo]._FmapdpFlag_diffusion = true;
351        else if(strcmp(dummy, "false") == 0)
352          UserCommandFlag[CommNo]._FmapdpFlag_diffusion = false;
353
354        if(strcmp(dummy2, "true") == 0)
355          UserCommandFlag[CommNo]._FmapdpFlag_printloss = true;
356        else if(strcmp(dummy2, "false") == 0)
357          UserCommandFlag[CommNo]._FmapdpFlag_printloss = false;
358        else
359          UserCommandFlag[CommNo]._FmapdpFlag_printloss = false;
360       
361       
362        cout << "debug:      " << line << endl;
363        cout << "dummy2 =  " << dummy2 << "     lossflag =  " << UserCommandFlag[CommNo]._FmapdpFlag_printloss << endl;
364       
365          //  FmapdpFlag = true;
366         strcpy(UserCommandFlag[CommNo].CommandStr,name);
367      }
368      else if (strcmp("AmplitudeTuneShiftFlag", name) == 0){
369        sscanf(line, "%*s %s",nextpara);
370         
371        if(strcmp(nextpara,"voidpara")!=0)   
372          sscanf(line, "%*s %s %s %ld %ld %ld %lf %lf %lf", 
373                  UserCommandFlag[CommNo]._AmplitudeTuneShift_nudx_file,
374                  UserCommandFlag[CommNo]._AmplitudeTuneShift_nudz_file,
375                 &(UserCommandFlag[CommNo]._AmplitudeTuneShift_nxpoint),
376                 &(UserCommandFlag[CommNo]._AmplitudeTuneShift_nypoint), 
377                 &(UserCommandFlag[CommNo]._AmplitudeTuneShift_nturn),
378                 &(UserCommandFlag[CommNo]._AmplitudeTuneShift_xmax),
379                 &(UserCommandFlag[CommNo]._AmplitudeTuneShift_ymax),
380                 &(UserCommandFlag[CommNo]._AmplitudeTuneShift_delta));
381       
382       strcpy(UserCommandFlag[CommNo].CommandStr,name);   
383      }
384      else if (strcmp("EnergyTuneShiftFlag", name) == 0){
385        sscanf(line, "%*s %s",nextpara);
386         
387         if(strcmp(nextpara,"voidpara")!=0)
388           sscanf(line, "%*s %s %ld %ld %lf", 
389                  UserCommandFlag[CommNo]._EnergyTuneShift_nudp_file,
390                 &(UserCommandFlag[CommNo]._EnergyTuneShift_npoint),
391                 &(UserCommandFlag[CommNo]._EnergyTuneShift_nturn), 
392                 &(UserCommandFlag[CommNo]._EnergyTuneShift_deltamax));
393       
394        strcpy(UserCommandFlag[CommNo].CommandStr,name);
395           
396      }
397      else if (strcmp("ErrorCouplingFlag", name) == 0){
398        sscanf(line, "%*s  %ld %lf",&(UserCommandFlag[CommNo].err_seed),&(UserCommandFlag[CommNo].err_rms));
399        strcpy(UserCommandFlag[CommNo].CommandStr,name);
400     
401      }
402        else if (strcmp("ErrorCoupling2Flag", name) == 0){
403        sscanf(line, "%*s  %ld %lf",&(UserCommandFlag[CommNo].err_seed),&(UserCommandFlag[CommNo].err_rms));
404        strcpy(UserCommandFlag[CommNo].CommandStr,name);
405       
406      }
407      else if (strcmp("CouplingFlag", name) == 0){
408        strcpy(UserCommandFlag[CommNo].CommandStr,name);
409       
410      }//momentum compact factor
411       else if (strcmp("MomentumAccFlag", name) == 0){
412         sscanf(line, "%*s %s",nextpara);
413         
414         if(strcmp(nextpara,"voidpara")!=0){   
415           sscanf(line, "%*s  %s %s %ld %ld %lf %lf %ld %lf %lf %ld %ld %lf",
416                      UserCommandFlag[CommNo]._MomentumAccFlag_momacc_file,
417                      UserCommandFlag[CommNo]._MomentumAccFlag_TrackDim,
418                      &(UserCommandFlag[CommNo]._MomentumAccFlag_istart),
419                      &(UserCommandFlag[CommNo]._MomentumAccFlag_istop),
420                      &(UserCommandFlag[CommNo]._MomentumAccFlag_deltaminp),
421                      &(UserCommandFlag[CommNo]._MomentumAccFlag_deltamaxp),
422                      &(UserCommandFlag[CommNo]._MomentumAccFlag_nstepp),
423                      &(UserCommandFlag[CommNo]._MomentumAccFlag_deltaminn),
424                      &(UserCommandFlag[CommNo]._MomentumAccFlag_deltamaxn),
425                      &(UserCommandFlag[CommNo]._MomentumAccFlag_nstepn),
426                      &(UserCommandFlag[CommNo]._MomentumAccFlag_nturn),
427                      &(UserCommandFlag[CommNo]._MomentumAccFlag_zmax));
428         } 
429         strcpy(UserCommandFlag[CommNo].CommandStr,name);   
430      }
431   
432//       generic one, fit for 1 family of quadrupoles
433      else if (strcmp("FitTuneFlag", name) == 0){
434        sscanf(line, "%*s %s %s %lf %lf",UserCommandFlag[CommNo].qf,UserCommandFlag[CommNo].qd,
435        &(UserCommandFlag[CommNo].targetnux),&(UserCommandFlag[CommNo].targetnuz));
436       strcpy(UserCommandFlag[CommNo].CommandStr,name);
437      }
438      // fit for 2 families,specific for the soleil lattice in which the quadrupole is cut into 2 parts
439       else if (strcmp("FitTune4Flag", name) == 0){
440        sscanf(line, "%*s %s %s %s %s %lf %lf",UserCommandFlag[CommNo].qf1,UserCommandFlag[CommNo].qf2,
441        UserCommandFlag[CommNo].qd1,UserCommandFlag[CommNo].qd2,
442        &(UserCommandFlag[CommNo].targetnux),&(UserCommandFlag[CommNo].targetnuz));
443        strcpy(UserCommandFlag[CommNo].CommandStr,name);
444      }
445       else if (strcmp("FitChromFlag", name) == 0){
446        sscanf(line, "%*s  %s %s %lf %lf",UserCommandFlag[CommNo].sxm1,UserCommandFlag[CommNo].sxm2,
447        &(UserCommandFlag[CommNo].targetksix),&(UserCommandFlag[CommNo].targetksiz));
448        strcpy(UserCommandFlag[CommNo].CommandStr,name);
449      }
450//       else if (strcmp("GirderErrorFlag", name) == 0){
451//        strcpy(UserCommand[CommandNo-1],name);
452//          // GirderErrorFlag = true;
453//       
454//       }
455//        else if (strcmp("SigmaFlag", name) == 0){
456//         strcpy(UserCommand[CommandNo-1],name);
457//          // SigmaFlag = true;
458//         
459//       }
460//        else if (strcmp("PX2Flag", name) == 0){
461//        strcpy(UserCommand[CommandNo-1],name);
462//          // PX2Flag = true;
463//         
464//       }
465       else if (strcmp("InducedAmplitudeFlag", name) == 0){
466        strcpy(UserCommandFlag[CommNo].CommandStr,name); 
467      }
468//        else if (strcmp("CodeComparaisonFlag", name) == 0){
469//        strcpy(UserCommand[CommandNo-1],name);
470//         //  CodeComparaisonFlag = true;
471//       
472//       }
473       else if (strcmp("EtaFlag", name) == 0){
474         strcpy(UserCommandFlag[CommNo].CommandStr,name); 
475      }//phase space
476       else if (strcmp("PhaseSpaceFlag", name) == 0) {
477         sscanf(line, "%*s %s",nextpara);
478         //if the next para is not empty, then use the user set value, otherwise use default value
479         if(strcmp(nextpara,"voidpara") != 0){
480           sscanf(line, "%*s %s %s %lf %lf %lf %lf %lf %lf %ld %s", 
481                       UserCommandFlag[CommNo]._Phase_phase_file,
482                       UserCommandFlag[CommNo]._Phase_Dim,
483                       &(UserCommandFlag[CommNo]._Phase_X), 
484                       &(UserCommandFlag[CommNo]._Phase_Px), 
485                       &(UserCommandFlag[CommNo]._Phase_Y), 
486                       &(UserCommandFlag[CommNo]._Phase_Py), 
487                       &(UserCommandFlag[CommNo]._Phase_delta),
488                       &(UserCommandFlag[CommNo]._Phase_ctau), 
489                       &(UserCommandFlag[CommNo]._Phase_nturn), 
490                       str);
491         }
492         //radiation damping
493          if (strcmp(str, "true") == 0)
494            UserCommandFlag[CommNo]._Phase_Damping = true;
495          else if (strcmp(str, "false") == 0)
496            UserCommandFlag[CommNo]._Phase_Damping = false;
497       
498         strcpy(UserCommandFlag[CommNo].CommandStr,name); 
499      }
500      //calculate Touschek lifetime
501       else if (strcmp("TouschekFlag", name) == 0){
502          strcpy(UserCommandFlag[CommNo].CommandStr,name); 
503       
504      }//intra beam scattering
505       else if (strcmp("IBSFlag", name) == 0){
506        strcpy(UserCommandFlag[CommNo].CommandStr,name); 
507      }//momentum acceptance is got by tracking, then cal touschek lifetime
508       else if (strcmp("TousTrackFlag", name) == 0){
509        strcpy(UserCommandFlag[CommNo].CommandStr,name); 
510      }
511      //bpms and h/v correctors used for orbit correction
512      else if (strcmp("bpm_name", name) == 0){ 
513        sscanf(line, "%*s %s", bpm_name); /* the name of bpm */
514      }
515      else if (strcmp("h_corr", name) == 0){ 
516        sscanf(line, "%*s %s", hcorr_name); /* the name of H corrector used for COD correction*/
517      }
518      else if (strcmp("v_corr", name) == 0){ 
519        sscanf(line, "%*s %s", vcorr_name); /* the name of V corrector used for COD correction*/
520      }
521      else if (strcmp("qt", name) == 0){ 
522        sscanf(line, "%*s %s", skew_quad_name); /* name of skew quadrupoles */
523      }
524      else if (strcmp("gs", name) == 0){ 
525        sscanf(line, "%*s %s", gs_name); /* name of start of the girder */
526      }
527      else if (strcmp("ge", name) == 0){ 
528        sscanf(line, "%*s %s", ge_name); /* name of end of the girder */
529      }
530      else if (strcmp("normalcut", name) == 0){
531        sscanf(line, "%*s %d", &idummy);
532        fprintf(stdout,"User value for cutting at n sigma-s the normal distributions\n");
533        setrancut(idummy); /* set normal cut for computation: random data are n sigma-s*/
534      }
535      //flag to do orbit correction
536      else if (strcmp("CODCorrectFlag", name) == 0){
537        strcpy(UserCommandFlag[CommNo].CommandStr,name);
538      } 
539      //set parameters for COD correction
540      else if (strcmp("n_orbit", name) == 0){
541        sscanf(line, "%*s %d", &n_orbit);
542      }
543      else if (strcmp("nwh", name) == 0){
544        sscanf(line, "%*s %d", &nwh);
545      }
546      else if (strcmp("nwv", name) == 0){
547        sscanf(line, "%*s %d", &nwv);
548      }
549       else if (strcmp("hcorr_file", name) == 0){ 
550        sscanf(line, "%*s %s", str);
551        sprintf(hcorr_file,"%s%s", in_dir, str); /* add file directory*/
552      }
553       else if (strcmp("vcorr_file", name) == 0){ 
554        sscanf(line, "%*s %s", str);
555        sprintf(vcorr_file,"%s%s", in_dir, str); /* add file directory*/
556      }
557      //ID correction
558      else if (strcmp("IDCorrFlag", name) == 0)
559        strcpy(UserCommandFlag[CommNo].CommandStr,name); 
560      else if (strcmp("scl_dbetax", name) == 0)//scaling of dbetax, for ID correction
561        sscanf(line, "%*s %lf", &scl_dbetax); 
562      else if (strcmp("scl_dbetay", name) == 0)//scaling of dbetay, for ID correction
563        sscanf(line, "%*s %lf", &scl_dbetay); 
564      else if (strcmp("scl_dnux", name) == 0)//scaling of dnux, for ID correction
565        sscanf(line, "%*s %lf", &scl_dnux); 
566      else if (strcmp("scl_dnuy", name) == 0)//scaling of dnuy, for ID correction
567        sscanf(line, "%*s %lf", &scl_dnuy); 
568      else if (strcmp("scl_nux", name) == 0) //scaling of nux, for ID correction
569        sscanf(line, "%*s %lf", &scl_nux); 
570      else if (strcmp("scl_nuy", name) == 0) //scaling of nuy, for ID correction
571        sscanf(line, "%*s %lf", &scl_nuy); 
572      else if (strcmp("ID_step", name) == 0)//ID steps, for ID correction
573        sscanf(line, "%*s %lf", &ID_step); 
574      else if (strcmp("N_calls", name) == 0) // ID correction parameters
575        sscanf(line, "%*s %d", &N_calls);
576      else if (strcmp("N_steps", name) == 0)
577        sscanf(line, "%*s %d", &N_steps);
578      else if (strcmp("N_Fam", name) == 0)
579        sscanf(line, "%*s %d", &N_Fam);
580      else if (strcmp("IDCquads", name) == 0) {
581        sscanf(line, "%*s %s %s %s %s %s %s %s %s %s %s %s",
582               IDCq_name[0], IDCq_name[1], IDCq_name[2], IDCq_name[3],
583               IDCq_name[4], IDCq_name[5], IDCq_name[6], IDCq_name[7],
584               IDCq_name[8], IDCq_name[9], IDCq_name[10]);
585      }
586      else{
587        printf("bad line in file %s, line %ld \n", full_param_file_name, LineNum);
588        exit_(1);
589      }
590  }
591    /* continue read in the line */ 
592    else
593     continue;
594  }//end of while loop
595 
596  free(line);
597 
598  fclose(inf);
599} 
600 
Note: See TracBrowser for help on using the repository browser.