&input
! <lat_file_name> :character string -  BMAD format lattice file
  lat_file_name = 'bmad_short_kickers.'
! <nturns> :integer - Number of turns to track
  nturns   = 50           
! The next several lines refer to the intial muon phase space distribution
! <nmuons> :integer - Number of muons to track
  nmuons = 10000
! <create_new_distribution> :logical - Create a new distribution
  create_new_distribution = T
! <seed>: integer - ! Random number seed. If seed =0 then random number set to system clock. If seed > 0 then it will be used to set list of random numbers. Default=1
  seed =0 
! <new_file> :character string - If you choose to create a new distribution it will be saved in new_file. If the name is '' or 'empty', the distribution is not saved
  new_file  = 'empty'           
! <muon_file> : If you choose to read an existing distribution, here is where the name is written. 
  muon_file = 'VDstop_DS_436_12000.dat'       ! read the phase space distribution off the target from this file. If blank, use freshly created distribution
  !muon_file = ''       ! read the phase space distribution off the target from this file. If blank, use freshly created distribution
! <tdistr> : Time distribution of the muons, choices are "flat", "gaus", "e821", "e989"
  tdistr    = "e989"                                         
! <tlength> : Width in time of distribution : (doesn't apply to tdistr="e821")
  tlength   = 10.0e-9                                       
! <tsigma> : standard deviation (width) of time distribution if it is gaussian, (sigma for tdistr="gaus", doesn't apply to tdistr={"uniform","e821","e989"})
  tsigma    =   70.e-9
! <pzdistr> : momentum distribution: "flat", "gaus"                                         
  pzdistr   = "gaus" 
! <pz> : cutoff of longitudinal momentum distribution, (fractional energy offset with respect to reference)
  pz        = 0.01
! <pzsigma> : sigma for pzdistr="gaus"  
  !pzsigma   = 0.0000112                                         
  pzsigma   = 0.002112                                         
! <epsdistr> : emittance distribution at production target: "delta", "flat", "gaus"
  epsdistr  = "gaus"                                         
! <epsx> : horizontal emittance at inflector assuming no losses in injection channel (m-rad)
  epsx      = 14.e-6                                        
! <epsy> : vertical emittance at inflector assuming no losses in injection channel (m-rad)
  epsy      = 14.e-6                                         

! <twiss> :12-real - betax, betay, alphax, alphay, etax, etapx, etay, etapy, phix, phiy, gammax, gammay at inflector 
  twiss     = 2.0, 10.0, 0., 0.0, 0.0, 0., 0., 0., 0.7, 0.7, 0., 0.  
! <twiss_ref> : Reference point within inflector for twiss parameters specified in previous line. 'end' = at inflector exit. 'center' = halfway through inflector
  twiss_ref = 'end' 
!<start_tracking_at_inflector_exit>: logical - if true then start tracking the distribution at the inflector exit, if false, start tracking at end of M5 line
  start_tracking_at_inflector_exit = F 
!<twiss_file>: logical - if true, write twiss parameters every cm to "twiss_file.dat", and write transfer matrices for all of the elements
  twiss_file = F                                        ! true => write twiss parameters every cm to "twiss_file.dat"
!<ring_twiss>: character - if <ring_twiss> = 'open' then use input twiss parameters as starting point for propagation around the ring in 'twiss_file.dat' 
!                          if <ring_twiss> = 'closed' then use closed ring twiss parameters as starting point for propagation around the ring in 'twiss_file.dat' 
 ring_twiss = 'closed'
! <inf_aperture> :character string - inflector aperture: "none", "rect" (rectangular), "e821"('D' shaped aperture of 821 inflector), "e989" (36mm X 56mm ellipse)
  inf_aperture = "e821"
! <inflector_width> :real - defines offset of axis of inflector from magic radius. If inflector_width = 0.009, central axis of inflector is 0.009 m from magic radius            
  inflector_width = 0.009
! <inf_end_us> :logical - if true include scattering at  upstream  end of inflector (E821 coils)
  inf_end_us   = T                                    
! <inf_end_ds> :logical - if true include scattering at  downstream  end of inflector (E821 coils)
  inf_end_ds   = T                                     
! <enerloss> :logical - if true include energy loss with scattering in inflector(E821 coils)!
  enerloss = T
! <inflector_angle> :real - angle of inflector axis with respect to tangent line. The rotation axis is the downstream end of the inflector. 
!       If angle < 0 the inflector is rotated clockwise about its downstream end                                         
  inflector_angle = -0.002
! <inflector_field> :6 reals - multiplier of Bmagic. If inflector_field = 1. then the inflector field = -Bmagic. Note that 1.012747 * Bmagic = B_wuzeng
  inflector_field = 1.012747                                 ! multiplier of Bmagic. 1.012747 * Bmagic = B_wuzeng

! <initial_offsets> :real - x, y, z, x-angle, y-angle, deltaE/E 
!   - offset of beam at entrance into the hole in the ring iron, with respect to the tangent through the center of the inflector 
    initial_offsets = -4.7671E-02  0. 0. 2.2134E-02 0. 0.
 !   initial_offsets = 0.  0. 0. 0. 0. 0.
! <opt_incident> :logical - if true, the initial_offsets so that the trajectory emerges from the inflector on its axis are determined 
  opt_incident = F
!<inj_matrix_tracking> :logical - true: use matrices to propagate through injeciton channel, false: track using field mapsxs
  inj_matrix_tracking = T                               ! if true, propagate trajectories through injection channel useing matrices, otherwise step through field map

!<ring_theta> :real - Rotation of ring elements with respect to inflector exit
  ring_theta      = 0.                                     

!<kickerPlates> :integer - 989-curved plates, 821-flat plates, 1-uniform vertical field
  kickerPlates    = 989                                      ! Controls shape of B-field: 1=uniform, 821, 989
!<kickerCurcuit> :integer - Controls shape of pulse: 1=square kick, 821=RLC, 989=Blumlein
  kickerCircuit   = 20150328                                        ! Controls shape of pulse: 1=square kick, 821=RLC, 989=Blumlein, 20150328 = custom 127cm kicker - no tail, 20150331 = custom 60cm, 20150507 = custom 127cm with tail
!<kickerFieldType> :integer -  Controls B-field calculation: 1=analytic, 2=mapped
  kickerFieldType = 2                                       ! Controls B-field calculation: 1=analytic, 2=mapped
!<kicker_params%kicker_field> : 3 reals - Bfield (T) for the three kicker mangets
    kicker_params%kicker_field      =   235.7e-4   220.e-4   173.3e-4 ! Kick strength (Tesla) for 989 kick 1.76m kickers
    kicker_params%kicker_field      =   326.6e-4   304.8e-4  240.2e-4 ! Kick strength (Tesla) for 989 kick 1.27m kickers
 !   kicker_params%kicker_field      =   0.   0.  0. ! Kick strength (Tesla) for 989 kick 1.27m kickers
!<kicker_params%dtRise> : 3 reals - Rise time (seconds) of the flat top of the 3 kicker pulses
  kicker_params%dtRise   = 20.e-9 20.e-9 20.e-9 ! Kick  rise  (s) 
!<kicker_params%dtFall> : 3 reals - Fall time (seconds) of the flat top of the 3 kicker pulses
  kicker_params%dtFall   = 20.e-9 20.e-9 20.e-9 ! Kick fall (s)
!<kicker_params%kick_width> : 3 reals - width of flat top of  3 kicker pulses
  kicker_params%kick_width =   50.e-9   50.e-9   50.e-9   ! Kick width (seconds) -- doesn't apply to kickerCircuit=821
!<kicker_tStart> : 3 reals - kicker start times, if kicker_tStart = -1 then automatically calculate kicker start time
  kicker_tStart            =   2.0e-9   2.0e-9   2.0e-9   ! good choice for 127 cm kicker
!  kicker_tStart            =   10.0e-9   10.0e-9   10.0e-9   ! good choice for 60 cm kicker

!<quad_plate> : logical - if true then include scattering in Q1 quad plates
  quad_plate    = F                                    ! include scatter in Q1 quad plates
!<quadPlates> : integer -  821 or 989 (displaced Q1 outer plate)  -- controls shape of E-field for Q1_Long, 1 
  quadPlates    = 1                                        ! 821, 989 -- controls shape of E-field for Q1_Long
  quadCircuit   = 1                                          ! 0=off at injection, ramped up with tauRC=5us; 1=storage potential at injection; todo:2=scraping at inj.
!<quadFieldType>: integer,  1=analytic, 2=mapped
  quadFieldType = 1
!<quad_params>: 4 reals - sets voltage on quads corresponding approximately to 'field_index'  (old way)
!  quad_params   = 0.185 0.185 0.185 0.185                    ! field_index(4)  (For the time being quads 2,3 and 4 all have the value assigne to 2
! <quad_params%long_quad_field_index>: 4 reals - sets voltage on long quads corresponding to 'field_index' (new way)
  quad_params%long_quad_field_index   = 0.185 0.185 0.185 0.185                    ! long_quad_field_index(4) 
! <quad_params%short_quad_field_index>: 4 reals - sets voltage on shor quads corresponding to 'field_index'  (new way)
  quad_params%short_quad_field_index   = 0.185 0.185 0.185 0.185                    ! short_quad_field_index(4)

!<vparam_id>: integer - Determines parameter to be varied.
!                         0-nothing,  1-betax, 2-betay, 3-eta, 4-kick, 5-kick_width, 6-initial position offset, 7-initial angle offset
!                         8-kicker rise time, 9-kicker fall time, 10-inflector field (1.0=-B_magic), 11-initial energy offset, 12-etapx, 13-alphax
!                         14-kicker_tStart
  vparam_id = 0      ! 0-nothing,  1-betax, 2-betay, 3-eta, 4-kick, 5-kick_width, 6-initial position offset, 7-initial angle offset is the parameter to vary, etc.
!<vparam_min> : real - minimum value of parameter to be varied
  vparam_min  = -60.e-9
!<vparam_max> : real - maximum value of parameter to be varied
  vparam_max  = 100.e-9					     ! maximum of parameter to vary
!<delta_vparam>: real - change in value of parameter in each step
  delta_vparam = 20.e-9 				     ! parameter step 
!<loop>: logical - if true vary parameter (vparam_id) accoring to - vparam_min,vparam_max,delta_vparam.  If false then do not vary parameter
  loop = F


!<fringe_file>: field_file_struct 
!               character_string - name of file with magnetic field map of fringe field in injection channel. 
!               real - grid_spacing
!               integer - type, type of read format = 1,2 (3 D map), 3 (extend 2D map to 3 dimensions) or 4 (uniform field)
!               integer - flag (miscellaneous)
! possibilities include -  'injec_fld.dat'  0.5 0. 1 0,  or 'ring_inject_bfield3d_wuzheng_extended.dat'  0.5 0. 2  0                
  fringe_file = 'ring_inject_bfield3d_wuzheng_extended.dat'  0.5 0. 2  0                    !field map for fringe field, grid spacing, gradient, type = type of read format, flag
!<inflector_file>: field_file_struct 
!               character_string - name of file with magnetic field map of inflector field.
!               real - grid_spacing
!               integer - type, type of read format = 1,2 (3 D map), 3 (extend 2D map to 3 dimensions) or 4 (uniform field)
!               integer - flag (miscellaneous)
! possibilities include -  'inf_field_alone.dat'  0.5 0.  1 0, 'uniform' 0.5 0. 4 0
  inflector_file = 'inf_field_alone.dat' 0.5 0. 2 0             !field map for inflector field, grid spacing, gradient, type, flag

!<spin_tracking_on>: logical - if true then include spin tracking of muons. Default = true
 spin_tracking_on = F
!<muon_decay>: logical - if true then include muon decay. Default = true
 muon_decay_on = F
!<make_movie>: logical - if true save trajectory and spin every 5cm and layout of quads and kicker. Create png files for movie using floor.gnu
make_movie = F
!<gnu_input_only>: logical - if true then write gnu_input.dat and stop. Default = false
!<record_fiber_data>: logical - if true write out hits to fiber harps 
record_fiber_data=F
!<use_lattice_twiss>: logical - if true use twiss parameters defined in lattice file to propagate through injection line
use_lattice_twiss = F
!<write_phase_space>: logical - if true write phase space coordinates of each muon to a file at each element on first turn 
write_phase_space_file = T
!<save_element_by_element_info> - if true allocate array muon_ele(:,:) to save distribution at each element. To reduce memory requirements - false
save_element_by_element_info = T
!<rf_quad(1:4)> freq_h,freq_v,amp_h,amp_v,phi_h,phi_v
rf_quad(1) = 0. 0. 0.01 0.001 1.7 0.
/
