# Field.txt contains specific source and geometry parameters.
# 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 Field.txt ###############################
# Parameters marked with "^" are set to be changeable in the TOPAS GUI
# Geometry parameters for one field, including...
# SAD: Source axis distance (distance from nominal source position to isocenter)
# ^Pos: Distance along beam axis Zg from nominal target position (SAD from isocenter)
# TransZ: Position of center of object along Zg
#
# 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
# Uniform bremsstrahlung splitting used for variance reduction - see user manual
######################################################################################

# Linac treatment head components
includeFile = Target.txt PrimaryCollimator.txt Monitor.txt 

#Choose one flattening filter, commment out the others (choose appropriate ElectronSource)
includeFile = Flattener6MV.txt #6MV flattening filter
#includeFile = Flattener18MV.txt #18 MV flattening filter

# For scoring, choose one of the following, comment out the others: 
# 1. Phase-space, 2. spatial distribution of energy fluence, or 3. energy spectrum
includeFile = ScorePhaseSpace.txt
#includeFile = ScoreEnergyFluence.txt
#includeFile = ScoreEnergySpectrum.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

# 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-"

#Choose either the 6 MV or 18 MV parameter value to match the flattening filter chosen
d:So/ElectronSource/BeamEnergy                       = 6.51 MeV #6 MV Oncor
#d:So/ElectronSource/BeamEnergy                       = 13.94 MeV #18 MV Oncor
u:So/ElectronSource/BeamEnergySpread                 = 4.2 #10% FWHM 6 MV Oncor
#u:So/ElectronSource/BeamEnergySpread                 = 3.0 #7% FWHM 18 MV Oncor

#The following ElectronSource parameter values are the same for the 6 MV and 18 MV beams
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          = 10 * Ts/ShowHistoryCountAtInterval
i:Ts/ShowHistoryCountAtInterval                      = 10000

# Variance reduction with uniform bremsstrahlung splitting
b:Vr/UseVarianceReduction                            = "True"
b:Vr/ParticleSplit/Active                            = "True"
s:Vr/ParticleSplit/Type                              = "secondarybiasing"
sv:Vr/ParTicleSplit/ForRegion/target/processesNamed  = 1 "eBrem"
uv:Vr/ParticleSplit/ForRegion/target/SplitNumber     = 1  100.0
dv:Vr/ParticleSplit/ForRegion/target/MaximumEnergies = 1  So/ElectronSource/BeamEnergy MeV 
