# FullTxHead.txt contains parameter values for a specific source and geometry
# in this example, a 6 MV Siemens Oncor x-ray beam.
#
# The parameters settings in this file override parameter settings in the files in the
# includeFile statement below and in LinacDefaults.txt.
#
# Use this parameter control file to set field and patient specific parameters. 
# See Main.txt for additional documentation.
#
# Reference for geometry: Jabbari et al, J Med Signal Sens 3(3):172-179
# References for electron source incident on x-ray target: 
#   Sawkey and Faddegon, Med Phys 36(3):698-707 (2009)
#   Sawkey and Faddegon, Med Phys 36(12):5622-32 (2009)
# The beam angular divergence from the 36(3) reference is for the manufacture specified 
# water cooling channel thickness.

###################### Key Parameters In FullTxHeadField.txt ##########################
# Parameters marked with "^" are set to be changeable in the TOPAS GUI
# Source parameters, including...
# BeamEnergySpread: Standard deviation of energy spread in percent 
# NumberOfHistoriesInRun: Total number of source particles to run for simulation
# ShowHistoryCountAtInterval: Number of histories between report of histories run
#
# Geometry parameters for one field, including...
# SAD: Source axis distance (distance from nominal source position to isocenter)
# ^IEC_G/RotY_G: IEC gantry rotation angle
# ^IEC_B/RotZ_B: IEC secondary collimator (jaw and MLC) rotation angle
# ^IEC_S/RotZ_S: IEC Patient Couch rotation angle
# Jaw/RotZ: Jaw orientation, dependent on direction of jaw travel along IEC_B
# MLC/RotZ: MLC orientation, dependent on direction of leaf travel along IEC_B
# ^Pos: Distance along beam axis Zg from nominal target position (SAD from isocenter)
# TransZ: Position of center of object along Zg
# JawTravelAxis: Direction of jaw travel, along IEC_B axis Xb or Yb
# LeafTravelAxis: Direction of leaf travel, along IEC_B axis Xb or Yb
# ^NegativeFieldSetting: Jaw or MLC leaf position on negative side (IEC X1), projected to isocenter
# ^PositiveFieldSetting: Jaw or MLC leaf position on positive side (IEC X2), projected to isocenter
# LeafWidths: Width of each leaf as projected to isocenter, same width on opposing bank
######################################################################################

######################################################################################
# Source at exit window and fixed treatment head components follow...

includeFile = Target.txt PrimaryCollimator.txt Flattener6MV.txt Monitor.txt 

# Graphics
# Use Gr/Enable to show geometry for a few histories, otherwise set "False" 
b:Gr/Enable                                  = "True"
#b:Gr/Enable                                 = "False"
# Use Ts/UseQT to start TOPAS GUI for a few histories, otherwise set "False" 
b:Ts/UseQT                                   = "True"
#b:Ts/UseQT                                  = "False"

# Random number seed for simulation of this field
i:Ts/Seed                                    = 10

# Linac geometry fixed components
# SAD: Source axis distance (nominal distance from x-ray target to gantry rotation axis)
d:Ge/SAD				     = 100. cm

# Source at exit window
# Parent is the gantry with coordinates IEC_G (see Main.txt)
s:Ge/BeamPosition/Parent                     = "IEC_G"
dc:Ge/BeamPosition/Pos                       = -1.0 cm #In vacuum
d:Ge/BeamPosition/TransZ                     = Ge/SAD - Ge/BeamPosition/Pos cm

s:So/ElectronSource/Type                     = "Beam"
s:So/ElectronSource/Component                = "BeamPosition"
s:So/ElectronSource/BeamParticle             = "e-"
d:So/ElectronSource/BeamEnergy               = 6.51 MeV
u:So/ElectronSource/BeamEnergySpread         = 4.2        #10% FWHM
s:So/ElectronSource/BeamPositionDistribution = "Gaussian"
s:So/ElectronSource/BeamPositionCutoffShape  = "Ellipse"
d:So/ElectronSource/BeamPositionCutoffX      = 1.2 mm     #2 standard deviations
d:So/ElectronSource/BeamPositionCutoffY      = 1.2 mm
d:So/ElectronSource/BeamPositionSpreadX      = 0.6 mm     #1.5 mm FWHM
d:So/ElectronSource/BeamPositionSpreadY      = 0.6 mm     #1.5 mm FWHM
s:So/ElectronSource/BeamAngularDistribution  = "None"

# Number of histories in run
ic:So/ElectronSource/NumberOfHistoriesInRun  = 1 * Ts/ShowHistoryCountAtInterval
i:Ts/ShowHistoryCountAtInterval              = 1

######################################################################################
# Field-dependent angles (gantry, collimator) and components follow...

includeFile = Jaws.txt MLC.txt WaterBox.txt

# Linac geometry field-dependent components
# IEC gantry rotation angle (in the opposite sense of RotY)
dc:Ge/IEC_G/RotY_G                           = 0. deg
d:Ge/IEC_G/RotY                              = -1 * Ge/IEC_G/RotY_G deg

# IEC collimator rotation angle (in the opposite sense of RotZ)
dc:Ge/IEC_B/RotZ_B                           = 0. deg
d:Ge/IEC_B/RotZ                              = -1 * Ge/IEC_B/RotZ_B deg 

# Asymmetric jaw field settings along IEC coordinates X or Y, projected to isocenter
# Default 20 cm wide field at plane of isocenter (at SAD)
dc:Ge/Jaw/NegativeFieldSetting  = -10 cm #Field setting along negative IEC_B axis
dc:Ge/Jaw/PositiveFieldSetting  = 10 cm #Field setting along positive IEC_B axis
d:Ge/Jaw/RotZ = Ge/Jaw/JawRotZforTravelAlongIECX deg # Set to JawRotZforTravelAlongIECX or JawRotZforTravelAlongIECY

# MLC orientation, leaf widths and positions, projected to isocenter
# Default 20 cm wide, 50 cm long field at plane of isocenter (at SAD) with all leaves open
d:Ge/MLC/RotZ = Ge/MLC/MLCRotZforTravelAlongIECY deg # Set to MLCRotZforTravelAlongIECX or MLCRotZforTravelAlongIECY
# MLC orientation, leaf widths and positions, projected to isocenter for 20 cm x 50 cm field
# IEC leaf number depends on direction of leaf motion: For Xb leaf 1 is first, Yb leaf 1 is last
dv:Ge/MLC/LeafWidths           = 42 5. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 1. 5. cm
dv:Ge/MLC/NegativeFieldSetting = 42 -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. -10. cm
dv:Ge/MLC/PositiveFieldSetting = 42 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. 10. cm

# Patient and couch field-dependent components
# IEC couch rotation angle (in the opposite sense of RotZ)
dc:Ge/IEC_S/RotZ_S                           = 0.0 deg
d:Ge/IEC_S/RotZ                              = -1 * Ge/IEC_S/RotZ_S deg

