BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
optionsBase.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2022.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#include "optionsBase.h"
20
21#include <iostream>
22
23using namespace GMAD;
24
25OptionsBase::OptionsBase()
26{
27 // Default Values for Options
28
29 // executable options
30 inputFileName = "optics.mad";
34 geant4PhysicsMacroFileNameFromExecOptions = false;
35 visDebug = false;
36 outputFileName = "output";
37 outputFormat = "rootevent";
38#ifdef __ROOTDOUBLE__
40#else
42#endif
44 survey = false;
45 surveyFileName = "survey.dat";
46 batch = false;
47
48 verbose = false;
49
51
52 verboseEventBDSIM = false;
56
58
64
65 verboseImportanceSampling = 0;
66
67 circular = false;
68 seed = -1;
69 randomEngine = "hepjames";
70 nGenerate = 1;
71 recreate = false;
74 writeSeedState = false;
75 useASCIISeedState = false;
78 exportGeometry = false;
79 exportType = "gdml";
80 exportFileName = "geometry";
81 bdsimPath = "";
82
83 // very important options
84 physicsList = ""; //default - only transportation
85 physicsVerbose = false;
86 physicsVerbosity = 1;
87 physicsEnergyLimitLow = 0;
88 physicsEnergyLimitHigh = 0;
89 g4PhysicsUseBDSIMRangeCuts = true;
90 g4PhysicsUseBDSIMCutsAndLimits = true;
91
92 eventOffset = 0;
93 recreateSeedState = true;
94
95 elossHistoBinWidth = 1.0; // m
96
97 ffact = 1.0;
98
99 // beam line offset and rotation
100 beamlineX = 0;
101 beamlineY = 0;
102 beamlineZ = 0;
103 beamlinePhi = 0;
104 beamlineTheta = 0;
105 beamlinePsi = 0;
106 beamlineAxisX = 0;
107 beamlineAxisY = 0;
108 beamlineAxisZ = 0;
109 beamlineAngle = 0;
110 beamlineAxisAngle = false;
111 beamlineS = 0;
112
113 eventNumberOffset = 0;
114
115 // general geometrical parameters
116 checkOverlaps = false;
117 xsize=0.0, ysize=0.0;
118
119 // magnet geometry
120 magnetGeometryType = "polessquare";
121 outerMaterialName = "iron";
122 horizontalWidth = 0.6;
123 thinElementLength = 1e-7;
124 hStyle = false; // vhRatio < 0 as signal to use geometry factory default
125 vhRatio = -1;
126 coilWidthFraction = -1;
127 coilHeightFraction = -1;
128 ignoreLocalMagnetGeometry = false;
129 buildPoleFaceGeometry = true;
130
131 preprocessGDML = true;
132 preprocessGDMLSchema = true;
133
134 // geometry debugging
135 // always split sbends into smaller chunks by default
136 dontSplitSBends = false;
137 includeFringeFields = true;
138 includeFringeFieldsCavities = true;
139
140 yokeFields = true;
141 yokeFieldsMatchLHCGeometry = true;
142 useOldMultipoleOuterFields = false;
143 scalingFieldOuter = 1.0;
144
145 // beam pipe / aperture
146 beampipeThickness = 0.0025;
147 apertureType = "circular";
148 aper1 = 0.025; // also beampipeRadius
149 aper2 = 0.025;
150 aper3 = 0.025;
151 aper4 = 0.025;
152 beampipeMaterial = "StainlessSteel";
153 ignoreLocalAperture = false;
154
155 vacMaterial = "Vacuum";
156 emptyMaterial = "G4_Galactic";
157 worldMaterial = "G4_AIR";
158 worldGeometryFile = "";
159 autoColourWorldGeometryFile = true;
160 importanceWorldGeometryFile = "";
161 importanceVolumeMap = "";
162 worldVolumeMargin = 5; //m
163
164 vacuumPressure = 1e-12;
165
166 // tunnel options
167 buildTunnel = false;
168 buildTunnelStraight = false;
169 tunnelType = "circular";
170 tunnelThickness = 0.1;
172 tunnelMaterial = "concrete";
173 soilMaterial = "soil";
174 buildTunnelFloor = true;
175 tunnelFloorOffset = 1.0; // m
176 tunnelAper1 = 2.0; // m
177 tunnelAper2 = 2.0; // m
178 tunnelVisible = true;
179 tunnelOffsetX = 0;
180 tunnelOffsetY = 0;
181 tunnelMaxSegmentLength = 50.0; // m
182
183 removeTemporaryFiles = true;
184 temporaryDirectory = "";
185
186 // samplers
187 samplerDiameter = 5; // m
188
189 // physics processes
191 turnOnMieScattering = true;
194 scintYieldFactor = 1.0;
200 minimumRange = 0;
202 defaultRangeCut = 1e-3;
203 prodCutPhotons = 1e-3;
204 prodCutElectrons = 1e-3;
205 prodCutPositrons = 1e-3;
206 prodCutProtons = 1e-3;
207 neutronTimeLimit = 1e-6;
209 useLENDGammaNuclear = false;
210 useElectroNuclear = true; // defaults to match g4 em extra physics defaults
211 useMuonNuclear = true;
212 useGammaToMuMu = false;
213 usePositronToMuMu = false;
214 usePositronToHadrons = false;
224
225 // biasing options
226 defaultBiasVacuum = "";
227 defaultBiasMaterial = "";
228 biasForWorldVolume = "";
229 biasForWorldContents = "";
230 biasForWorldVacuum = "";
231 worldVacuumVolumeNames = "";
232
233 // tracking options
234 integratorSet = "bdsimmatrix";
235 lengthSafety = 1e-9; // be very careful adjusting this as it affects all the geometry
236 lengthSafetyLarge = 1e-6; // be very careful adjusting this as it affects all the geometry
237 maximumTrackingTime = -1; // s, nonsensical - used for testing
238 maximumStepLength = 20; // m, quite big
239 maximumTrackLength = 1e90; // m, no limit but smaller than DBL_MAX for safe *CLHEP::m
240 chordStepMinimum = 1e-9; // m // minimum step in a field for an integrator
241 chordStepMinimumYoke = 1e-6;
242 deltaIntersection = 1e-8; // m - should be greater than lengthSafety!
243 sampleElementsWithPoleface = false; // affects dipole tracking in certain integrator sets when true
244 nominalMatrixRelativeMomCut = 0.05; // be careful adjusting this as it affects dipolequadrupole tracking
246 dEThresholdForScattering = 1e-11; // GeV
247 backupStepperMomLimit = 0.1; // fraction of unit momentum
248
249 // default value in Geant4, old value 0 - error must be greater than this
250 minimumEpsilonStep = 5e-25;
251 maximumEpsilonStep = 1e-7; // default value in Geant4, old value 1e-7
252 deltaOneStep = 1e-6; // maximum allowed spatial error in position (1um)
253 stopSecondaries = false;
254 killNeutrinos = false;
255 killedParticlesMassAddedToEloss = false;
256 minimumRadiusOfCurvature = 0.05; // 5cm - typical aperture
257
258 // hit generation
259 sensitiveOuter = true;
260 sensitiveBeamPipe = true;
261
262 // output / analysis options
263 numberOfEventsPerNtuple = 0;
264
265 storeMinimalData = false;
266
267 storeApertureImpacts = true;
268 storeApertureImpactsHistograms = true;
269 storeApertureImpactsIons = false;
270 storeApertureImpactsAll = false;
271 apertureImpactsMinimumKE = 0;
272 storeCollimatorInfo = false;
273 storeCollimatorHits = false;
274 storeCollimatorHitsLinks = false;
275 storeCollimatorHitsIons = false;
276 storeCollimatorHitsAll = false;
277 collimatorHitsMinimumKE = 0;
278 storeEloss = true;
279 storeElossHistograms = true;
280 storeElossVacuum = false;
281 storeElossVacuumHistograms = false;
282 storeElossTunnel = false;
283 storeElossTunnelHistograms = false;
284 storeElossWorld = false;
285 storeElossWorldContents = false;
286 storeElossTurn = false;
287 storeElossLinks = false;
288 storeElossLocal = false;
289 storeElossGlobal = false;
290 storeElossTime = false;
291 storeElossStepLength = false;
292 storeElossPreStepKineticEnergy = false;
293 storeElossModelID = false;
294 storeElossPhysicsProcesses = false;
295 storeParticleData = true;
296 storePrimaries = true;
297 storePrimaryHistograms = true;
298
299 storeTrajectory = false;
300
301 storeTrajectoryDepth = 0;
302 storeTrajectoryStepPoints = 0;
303 storeTrajectoryStepPointLast = false;
304 storeTrajectoryParticle = "";
305 storeTrajectoryParticleID = "";
306 storeTrajectoryEnergyThreshold = -1.0;
307 storeTrajectorySamplerID = "";
308 storeTrajectoryELossSRange = "";
309
310 storeTrajectoryTransportationSteps = true;
311 trajNoTransportation = false;
312 storeTrajectoryKineticEnergy = true;
313 storeTrajectoryMomentumVector = false;
314 storeTrajectoryProcesses = false;
315 storeTrajectoryTime = false;
316 storeTrajectoryLocal = false;
317 storeTrajectoryLinks = false;
318 storeTrajectoryIon = false;
319 storeTrajectoryMaterial = false;
320 storeTrajectoryAllVariables = false;
321
322 trajectoryFilterLogicAND = false;
323
324 storeSamplerAll = false;
325 storeSamplerPolarCoords = false;
326 storeSamplerCharge = false;
327 storeSamplerKineticEnergy = false;
328 storeSamplerMass = false;
329 storeSamplerRigidity = false;
330 storeSamplerIon = false;
331
332 trajCutGTZ = 1e99; // minimum z position, so large default value
333 trajCutLTR = 0.0; // maximum radius in mm, so small default value
334 trajConnect = false; // connect disconnected trajectory trees
335
336 storeModel = true;
337
338 samplersSplitLevel = 0;
339
340 // circular options
341 nturns = 1;
342 ptcOneTurnMapFileName = "";
343
344 printFractionEvents = 0.1;
345 printFractionTurns = 0.2;
346 printPhysicsProcesses = false;
347
348 // visualisation
350
351 // scoring map
352 nbinsx = 1;
353 nbinsy = 1;
354 nbinsz = 1;
355 nbinse = 1;
356 xmin = -0.5;
357 xmax = 0.5;
358 ymin = -0.5;
359 ymax = 0.5;
360 zmin = 0;
361 zmax = 1;
362 emin = 1e-12;
363 emax = 1e4;
364 useScoringMap = false;
365}
366
367
369{
370 std::cout<<"Options " << std::endl;
371 std::cout<<"n particles : " << nGenerate << std::endl;
372 std::cout<<"BV sign : " << ffact << std::endl;
373 std::cout<<"Optical absorption on : " << turnOnOpticalAbsorption << std::endl;
374 std::cout<<"Mie scattering on : " << turnOnMieScattering << std::endl;
375 std::cout<<"Rayleigh scattering on : " << turnOnRayleighScattering << std::endl;
376 std::cout<<"Optical surface on : " << turnOnOpticalSurface << std::endl;
377}
378
std::string bdsimPath
Definition: optionsBase.h:110
std::string seedStateFileName
Seed state file path.
Definition: optionsBase.h:97
std::string magnetGeometryType
default magnet geometry parameters
Definition: optionsBase.h:152
double beamlineZ
Initial beam line transform w.r.t. the world coordinate frame.
Definition: optionsBase.h:132
int nGenerate
The number of primary events to simulate.
Definition: optionsBase.h:91
std::string physicsList
list of physics processes
Definition: optionsBase.h:113
double muonSplittingThresholdParentEk2
physics parameters
Definition: optionsBase.h:261
double beamlineAngle
Initial beam line transform w.r.t. the world coordinate frame.
Definition: optionsBase.h:139
double beamlineS
Initial beam line transform w.r.t. the world coordinate frame.
Definition: optionsBase.h:141
bool survey
Parameter for survey.
Definition: optionsBase.h:55
double minimumRange
physics parameters
Definition: optionsBase.h:240
std::string outputFileName
Parameter for output format.
Definition: optionsBase.h:48
int muonSplittingFactor
physics parameters
Definition: optionsBase.h:258
double tunnelSoilThickness
tunnel geometry parameters
Definition: optionsBase.h:207
double minimumRadiusOfCurvature
Minimum allowed radius of curvature.
Definition: optionsBase.h:290
std::string outputFormat
Parameter for output format.
Definition: optionsBase.h:49
int verboseSteppingEventContinueFor
Stepping level verbosity.
Definition: optionsBase.h:82
bool beamlineAxisAngle
Initial beam line transform w.r.t. the world coordinate frame.
Definition: optionsBase.h:140
std::string exportFileName
Parameter for controlling geometry export.
Definition: optionsBase.h:105
int seed
The seed value for the random number generator.
Definition: optionsBase.h:89
double tunnelOffsetY
tunnel geometry parameters
Definition: optionsBase.h:216
double tunnelFloorOffset
tunnel geometry parameters
Definition: optionsBase.h:211
int verboseEventContinueFor
Event level verbosity.
Definition: optionsBase.h:73
bool hStyle
H Style dipoles (if not, C Style).
Definition: optionsBase.h:156
double xsize
for element specification
Definition: optionsBase.h:149
std::string particlesToExcludeFromCuts
physics parameters
Definition: optionsBase.h:241
double ffact
magnetic field flip (+1 default, -1: flip sign)
Definition: optionsBase.h:127
double tunnelMaxSegmentLength
tunnel geometry parameters
Definition: optionsBase.h:217
double muonSplittingThresholdParentEk
physics parameters
Definition: optionsBase.h:259
int verboseEventStart
Event level verbosity.
Definition: optionsBase.h:72
bool useLENDGammaNuclear
physics parameters
Definition: optionsBase.h:249
double maximumTrackingTime
Maximum tracking time per track [s].
Definition: optionsBase.h:278
bool dontSplitSBends
geometry debug, don't split bends into multiple segments
Definition: optionsBase.h:168
std::string tunnelMaterial
tunnel geometry parameters
Definition: optionsBase.h:208
bool useASCIISeedState
Whether to use the seed state from an ASCII file.
Definition: optionsBase.h:96
bool tunnelIsInfiniteAbsorber
physics parameters
Definition: optionsBase.h:257
bool verboseSteppingPrimaryOnly
Stepping level verbosity.
Definition: optionsBase.h:83
double muonSplittingExclusionWeight
physics parameters
Definition: optionsBase.h:263
bool collimatorsAreInfiniteAbsorbers
physics parameters
Definition: optionsBase.h:256
int verboseRunLevel
Run level verbosity.
Definition: optionsBase.h:67
bool turnOnOpticalSurface
Physics processes.
Definition: optionsBase.h:230
double prodCutProtons
physics parameters
Definition: optionsBase.h:246
int nSegmentsPerCircle
Number of facets per 2pi in visualisation.
Definition: optionsBase.h:390
std::string soilMaterial
tunnel geometry parameters
Definition: optionsBase.h:209
bool preprocessGDML
geometry control
Definition: optionsBase.h:164
int maximumBetaChangePerStep
physics parameters
Definition: optionsBase.h:236
bool batch
Flag for batch / interactive mode.
Definition: optionsBase.h:59
double minimumKineticEnergy
physics parameters
Definition: optionsBase.h:238
int eventOffset
Event number to start from when recreating from a root file.
Definition: optionsBase.h:121
int verboseTrackingLevel
Tracking verbosity.
Definition: optionsBase.h:76
bool circular
Flag for circular machine.
Definition: optionsBase.h:88
bool checkOverlaps
bdsim options
Definition: optionsBase.h:147
double neutronKineticEnergyLimit
physics parameters
Definition: optionsBase.h:248
double aper1
default beampipe parameters
Definition: optionsBase.h:181
double maximumTrackLength
Maximum permitted track length [m].
Definition: optionsBase.h:280
int verboseEventLevel
Event level verbosity.
Definition: optionsBase.h:71
bool turnOnOpticalAbsorption
Physics processes.
Definition: optionsBase.h:227
bool buildTunnelStraight
tunnel geometry parameters
Definition: optionsBase.h:204
std::string inputFileName
Input filename.
Definition: optionsBase.h:40
long maximumTracksPerEvent
physics parameters
Definition: optionsBase.h:237
double backupStepperMomLimit
Fractional momentum limit for reverting to backup steppers.
Definition: optionsBase.h:295
double aper2
default beampipe parameters
Definition: optionsBase.h:182
int outputCompressionLevel
Parameter for output format.
Definition: optionsBase.h:51
double beamlinePhi
Initial beam line transform w.r.t. the world coordinate frame.
Definition: optionsBase.h:133
double maximumStepLength
Maximum permitted step length in any volume.
Definition: optionsBase.h:279
std::string exportType
Parameter for controlling geometry export.
Definition: optionsBase.h:104
double neutronTimeLimit
physics parameters
Definition: optionsBase.h:247
bool recreateSeedState
Load seed state when recreating events.
Definition: optionsBase.h:122
std::string vacMaterial
vacuum material
Definition: optionsBase.h:189
bool verbose
General verbosity.
Definition: optionsBase.h:64
std::string recreateFileName
The file path to recreate a run from.
Definition: optionsBase.h:93
bool teleporterFullTransform
Whether to use the new Transform3D method for the teleporter.
Definition: optionsBase.h:293
bool buildTunnelFloor
tunnel geometry parameters
Definition: optionsBase.h:210
int startFromEvent
Event to start from when recreating.
Definition: optionsBase.h:94
std::string emptyMaterial
material in container volumes
Definition: optionsBase.h:190
bool muonSplittingExcludeWeight1Particles
physics parameters
Definition: optionsBase.h:262
double prodCutPhotons
physics parameters
Definition: optionsBase.h:243
bool generatePrimariesOnly
Whether to only generate primary coordinates and quit, or not.
Definition: optionsBase.h:100
double defaultRangeCut
physics parameters
Definition: optionsBase.h:242
double beamlineAxisY
Initial beam line transform w.r.t. the world coordinate frame.
Definition: optionsBase.h:137
double prodCutElectrons
physics parameters
Definition: optionsBase.h:244
double tunnelAper1
tunnel geometry parameters
Definition: optionsBase.h:212
bool verboseEventBDSIM
Event level verbosity.
Definition: optionsBase.h:70
int maximumPhotonsPerStep
physics parameters
Definition: optionsBase.h:235
std::string beampipeMaterial
default beampipe parameters
Definition: optionsBase.h:185
bool exportGeometry
Parameter for controlling geometry export.
Definition: optionsBase.h:103
int verboseSteppingLevel
Stepping level verbosity.
Definition: optionsBase.h:80
double beampipeThickness
default beampipe parameters
Definition: optionsBase.h:179
bool turnOnRayleighScattering
Physics processes.
Definition: optionsBase.h:229
std::string geant4PhysicsMacroFileName
Geant4 physics macro.
Definition: optionsBase.h:43
void print() const
print some properties
Definition: optionsBase.cc:368
std::string visMacroFileName
Visualisation filename.
Definition: optionsBase.h:41
double scintYieldFactor
physics parameters
Definition: optionsBase.h:234
bool beamPipeIsInfiniteAbsorber
physics parameters
Definition: optionsBase.h:255
double beamlineX
Initial beam line transform w.r.t. the world coordinate frame.
Definition: optionsBase.h:130
std::string apertureType
default beampipe parameters
Definition: optionsBase.h:180
bool verboseSteppingBDSIM
Stepping level verbosity.
Definition: optionsBase.h:79
bool useMuonNuclear
physics parameters
Definition: optionsBase.h:251
bool useElectroNuclear
physics parameters
Definition: optionsBase.h:250
int verboseSteppingEventStart
Stepping level verbosity.
Definition: optionsBase.h:81
std::string surveyFileName
Parameter for survey.
Definition: optionsBase.h:56
bool recreate
Whether to recreate from a file or not.
Definition: optionsBase.h:92
double tunnelAper2
tunnel geometry parameters
Definition: optionsBase.h:213
bool turnOnMieScattering
Physics processes.
Definition: optionsBase.h:228
double beamlineY
Initial beam line transform w.r.t. the world coordinate frame.
Definition: optionsBase.h:131
double beamlineAxisX
Initial beam line transform w.r.t. the world coordinate frame.
Definition: optionsBase.h:136
double tunnelThickness
tunnel geometry parameters
Definition: optionsBase.h:206
std::string randomEngine
Name of random engine to use.
Definition: optionsBase.h:90
double prodCutPositrons
physics parameters
Definition: optionsBase.h:245
bool buildTunnel
tunnel geometry parameters
Definition: optionsBase.h:203
bool outputDoublePrecision
Parameter for output format.
Definition: optionsBase.h:50
bool writeSeedState
Write the seed state each event to a text file.
Definition: optionsBase.h:95
bool visDebug
Flag for visualisation debug.
Definition: optionsBase.h:45
bool useGammaToMuMu
physics parameters
Definition: optionsBase.h:252
double aper4
default beampipe parameters
Definition: optionsBase.h:184
double aper3
default beampipe parameters
Definition: optionsBase.h:183
double minimumKineticEnergyTunnel
physics parameters
Definition: optionsBase.h:239
double tunnelOffsetX
tunnel geometry parameters
Definition: optionsBase.h:215
bool usePositronToMuMu
physics parameters
Definition: optionsBase.h:253
std::string tunnelType
tunnel geometry parameters
Definition: optionsBase.h:205
double beamlineAxisZ
Initial beam line transform w.r.t. the world coordinate frame.
Definition: optionsBase.h:138
double beamlinePsi
Initial beam line transform w.r.t. the world coordinate frame.
Definition: optionsBase.h:135
std::string geant4MacroFileName
Geant4 macro to run.
Definition: optionsBase.h:42
bool trajNoTransportation
kept only for backwards compatibility.
Definition: optionsBase.h:351
bool usePositronToHadrons
physics parameters
Definition: optionsBase.h:254
bool tunnelVisible
tunnel geometry parameters
Definition: optionsBase.h:214
int muonSplittingFactor2
physics parameters
Definition: optionsBase.h:260
double worldVolumeMargin
Padding margin for world volume size.
Definition: optionsBase.h:198
double nominalMatrixRelativeMomCut
Momentum threshold for nominal dipole matrix tracking.
Definition: optionsBase.h:292
double beamlineTheta
Initial beam line transform w.r.t. the world coordinate frame.
Definition: optionsBase.h:134
bool ignoreLocalAperture
default beampipe parameters
Definition: optionsBase.h:186
Parser namespace for GMAD language. Combination of Geant4 and MAD.