#*******************************************************************
# 15 March 2010
# File for checking TRacy is running well
#
# input script to set the file and bool flag
#
#  comments:
# 1) Blank line and line starting with "#" (comment) are ignored
# 2) Obligatory parameter: lat_file,
#     lat file name is without the extension of .lat
# 3) All the other parameters are optional, and all the default 
#      values for flags are false
# 4) Default FMAP values are: 
#      _FmapFlag_nxpoint=31, _FmapFlag_nypoint=21,
#      _FmapFlag_nturn=516; _FmapFlag_xmax=0.025, 
#      _FmapFlag_ymax=0.005, _FmapFlag_delta=0.0;
#      _FmapFlag_diffusion = true;
# 5) Default values of FMAPdp are the same as FMAP.
#
#
#  Test verison for the development of Tracy 3, always the nearest
#        input file verison.
#
#                     03/2011    Jianfeng Zhang 
#
#******************************************************************

#******files********
# relative directory of the files in the script
 in_dir /home/zhang/codes/TracyIII/lattice/

# lattice file must be wihout .lat extension
  lat_file soleil_120cor  

# H-corrector name in lattice file
  h_corr        HCM    
#V-corrector name in lattice file
  v_corr        VCM    
#girder start symbol
  gs            GS     
#girder end symbol
  ge            GE   
# BPM name in lattice file  
  bpm_name      BPM    
# skew quadrupole in the lattice file
  qt            QT

#turn on the quadrupole fringe field
  QuadFringeOnFlag 


# vacuum chamber file
  chamber_file example_Chamber.dat    

# multipole error file
  multipole_file multipole_error.dat

# files for looking for the multipole of corrector (Machine current based)
  fic_hcorr corh.txt
  fic_vcorr corv.txt
  fic_skew  corqt.txt

  
#####################
# Read the field error, and replacement the corresponding components
# in the element.
#  Generic features
####################

ReadfefileFlag   dip.fe

##############################
#specific for soleil lattice
##############################
#  multipole_file    multipole_error_fullquad.dat
#  fic_hcorr corh.txt
#  fic_vcorr corv.txt
#  fic_skew  corqt.txt

#ReadMultipoleFlag


#  FitTune4Flag     qp7a qp7b  qp9a qp9b  18.202 10.317
#  FitChromFlag   sx9 sx10  2.0    2.0




#PrintGirderFlag testgirder.out



######################
# alignment error file, after read the misalignment, the orbit is corrected
#####################
ReadaefileFlag    soleil1.ae
#####################
#  orbit correction
#####################

  hcorr_file  hcorr_56nom.state
  vcorr_file  vcorr_56nom.state


#number of statistics (seeds) --> N flat-files
 n_stat        2    
#number of times to scale the errors
n_scale       1     
#number of iterations for orb. cors 
n_orbit       0     
#number of singular values in H-plane, must be the same as the correctors used for orbit correction
nwh           60    
#number of singular values in V-plane, must be the same as the correctors used for orbit correction
nwv           60    


#*******boolean flag***********

#print the twiss paramters to a file
PrintTwissFlag     twisstest.out

#print close orbit to a file
PrintCODFlag testcod.out

#print coordinates tracking around COD at each element
PrintTrackFlag  track.out  0.001 0.000  0.0  0.0  0.0  0.0   50


# VACCUUM CHAMBER PART
# read vacuum chamber from chamber_file
  ReadChamberFlag  


# GLOBAL PARAMETER PART
# Activate quadrupole Fringefield
  QuadFringeOnFlag 

# set RF voltage, if false, then use the definition value
# of RF cavity in the lattice
# name, flag, RF voltage [V]
 RFvoltageFlag   4000000

# tune obtained by tracking
  TuneTracFlag    
# chromaticity obtained by tracking
  ChromTracFlag   

# TUNESHIFT WITH AMPLITUDE

# tune shift with amplitude and energy
#    AmplitudeTuneShiftFlag flag Nbx Nby TurnNumber xmax(m) ymax(m) delta
#    Nbx and Nby Number of amplitude values in H et V planes
#    TurnNumber number of turns for tracking  
#    xmax ymax maximum amplitude value (sqrt law)
#    delta energy offset

# AmplitudeTuneShiftFlag  50 30 516 0.035 0.02 0.0

# EnergyTuneShiftFlag flag Nb TurnNumber emax
#    Nb point number
#    TurnNumber number of turn for tracking  
#    emax maximum energy for tracking
 EnergyTuneShiftFlag   31 1026 0.06 




# FMA calculate frequency map 
#    Nbx Nby number of point in h and v planes
#    TurnNumber Number of turns for tracking
#    xmax, ymax maximum amplitude
#    energyoffset 
#    diffusionflag to compute tunediffusion 
 FmapFlag  31 21 516 0.025 0.005 0.0 true





#  FMA dp calculate frequency map
#     Nbx:  number of point in h planes
#     Nbe: number of point for the energy
#     TurnNumber: Number of turns for tracking
#     xmax: maximum amplitude in the horizontal plane
#     emax: maximum  energyoffset
#        y: vertical amplitude 
#     diffusionflag to compute tunediffusion 
  FmapdpFlag  101 121 1026 25e-3 0.06 0.3e-3 true

# error coupling
# add random rotation error to the two half quadrupoles
#delicated for soleil lattice
#    flag, random seed number, RMS value of the rotation angle 
#    of the quadrupole
  ErrorCoupling2Flag   0  0.0007

# coupling flag
#    calcualte the coupling factor in the lattice 
  CouplingFlag  

# calculate momentum acceptance for Touscheck lifetime
#   Dim  istart istop eminp emaxp nstepp eminn emaxn nstepn nturns
#   Dim: 4D/6D tracking, default value is 6D
  MomentumAccFlag  6D 1 209  0.01 0.05 100 -0.01 -0.05 100  1026


#### MULTIPOLE FACTORY
 # read multipole error from a file

 ReadMultipoleFlag 

#******to be obsoleted************************
# include multipole error into the lattice, the mutipole error
#     of Horizontal and vertical correctors, and skew quadrupole
#      is read from the files, the name of which are set at the 
#       beginning of this script. 
  # MultipoleFlag 
# set multipole with thin or thick lens model,
# MultipoleFlag must be true  if ThinsextFlag is true 
  #  ThinsextFlag  
#**************************************************

###
### FITTING FACTORY
###
# fit tune
# name, flag, tuned quadrople,tuned quadrople,targetnudx    targetnudz
  FitTune4Flag     qp7a qp7b  qp9a qp9b  18.202 10.317

# fit chromaticity
# name,flag, tuned sextupole, tuned sextupole, targetksix    targetksiz
  FitChromFlag   sx9 sx10  2.0    2.6


###
### Touschek lifetime
###
# calculate Touschek lifetime
# name, flag
  TouschekFlag 
# Intra Beam Scattering
  IBSFlag  
# Track momentum acceptance and then get Touschek lifetime
  TousTrackFlag 

### OTHER

# calculate induced amplitude
  InducedAmplitudeFlag  

# specific for test
  CodeComparaisonFlag  

# calculate Eta function
  EtaFlag  

# calculate phase space  
# parameters are:  
# 4D/6D dimension to track the phase space; 
# x[m],x',y[m],y',delta,c*tau, Number of turns, flag to turn on/off
# damping during the tracking
  PhaseSpaceFlag 6D 1e-6 0.0 1e-6 0.0 0.012 0.0 1000 false