BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
BDSIMClass.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 "BDSIMClass.hh"
20
21#include "BDSExecOptions.hh" // executable command line options
22#include "BDSGlobalConstants.hh" // global parameters
23
24#include <algorithm>
25#include <csignal>
26#include <cstdlib>
27#include <cstdio>
28
29#include "G4EventManager.hh" // Geant4 includes
30#include "G4GenericBiasingPhysics.hh"
31#include "G4GeometryManager.hh"
32#include "G4GeometryTolerance.hh"
33#include "G4PhysicsListHelper.hh"
34#include "G4ParallelWorldPhysics.hh"
35#include "G4ParticleDefinition.hh"
36#include "G4SteppingManager.hh"
37#include "G4TrackingManager.hh"
38#include "G4Version.hh"
39#include "G4VModularPhysicsList.hh"
40
41#include "CLHEP/Units/SystemOfUnits.h"
42
43#include "BDSAcceleratorModel.hh"
44#include "BDSAperturePointsLoader.hh"
45#include "BDSBeamPipeFactory.hh"
46#include "BDSBunch.hh"
47#include "BDSBunchFactory.hh"
48#include "BDSCavityFactory.hh"
49#include "BDSColours.hh"
50#include "BDSComponentFactoryUser.hh"
51#include "BDSDebug.hh"
52#include "BDSDetectorConstruction.hh"
53#include "BDSEventAction.hh"
54#include "BDSException.hh"
55#include "BDSFieldFactory.hh"
56#include "BDSFieldLoader.hh"
57#include "BDSGeometryFactory.hh"
58#include "BDSGeometryFactorySQL.hh"
59#include "BDSGeometryWriter.hh"
60#include "BDSIonDefinition.hh"
61#include "BDSMaterials.hh"
62#include "BDSOutput.hh"
63#include "BDSOutputFactory.hh"
64#include "BDSParallelWorldUtilities.hh"
65#include "BDSParser.hh" // Parser
66#include "BDSParticleDefinition.hh"
67#include "BDSPhysicsMuonSplitting.hh"
68#include "BDSPhysicsUtilities.hh"
69#include "BDSPrimaryGeneratorAction.hh"
70#include "BDSRandom.hh" // for random number generator from CLHEP
71#include "BDSRunAction.hh"
72#include "BDSRunManager.hh"
73#include "BDSSamplerRegistry.hh"
74#include "BDSSDManager.hh"
75#include "BDSSteppingAction.hh"
76#include "BDSStackingAction.hh"
77#include "BDSTemporaryFiles.hh"
78#include "BDSTrackingAction.hh"
79#include "BDSUtilities.hh"
80#include "BDSVisManager.hh"
81#include "BDSWarning.hh"
82
84 ignoreSIGINT(false),
85 usualPrintOut(true),
86 initialised(false),
87 initialisationResult(1),
88 argcCache(0),
89 argvCache(nullptr),
90 parser(nullptr),
91 bdsOutput(nullptr),
92 bdsBunch(nullptr),
93 runManager(nullptr),
94 userComponentFactory(nullptr),
95 userPhysicsList(nullptr),
96 realWorld(nullptr)
97{;}
98
99BDSIM::BDSIM(int argc, char** argv, bool usualPrintOutIn):
100 ignoreSIGINT(false),
101 usualPrintOut(usualPrintOutIn),
102 initialised(false),
103 initialisationResult(1),
104 argcCache(argc),
105 argvCache(argv),
106 parser(nullptr),
107 bdsOutput(nullptr),
108 bdsBunch(nullptr),
109 runManager(nullptr),
110 userComponentFactory(nullptr),
111 userPhysicsList(nullptr),
112 realWorld(nullptr)
113{
115}
116
117int BDSIM::Initialise(int argc, char** argv, bool usualPrintOutIn)
118{
119 argcCache = argc;
120 argvCache = argv;
121 usualPrintOut = usualPrintOutIn;
124}
125
127{
129 const BDSExecOptions* execOptions = new BDSExecOptions(argcCache,argvCache);
130 if (usualPrintOut)
131 {execOptions->Print();}
132 ignoreSIGINT = execOptions->IgnoreSIGINT(); // different sig catching for cmake
133
134 execOptions->PrintCopyright();
135#ifdef BDSDEBUG
136 G4cout << __METHOD_NAME__ << "DEBUG mode is on." << G4endl;
137#endif
138
140 parser = BDSParser::Instance(execOptions->InputFileName());
142 parser->AmalgamateOptions(execOptions->Options());
143 parser->AmalgamateBeam(execOptions->Beam(), execOptions->Options().recreate);
146
149
151 delete execOptions;
152
157
159 BDSRandom::CreateRandomNumberGenerator(globals->RandomEngine());
160 BDSRandom::SetSeed(); // set the seed from options
161
163 bdsOutput = BDSOutputFactory::CreateOutput(globals->OutputFormat(),
164 globals->OutputFileName());
165
168 {
169 G4cerr << "No Geant4 environmental variables found - please source geant4.sh environment" << G4endl;
170 G4cout << "A common fault is the wrong Geant4 environment as compared to the one BDSIM was compiled with." << G4endl;
171 return 1;
172 }
173
177
180
182 auto parallelWorldsRequiringPhysics = BDS::ConstructAndRegisterParallelWorlds(realWorld,
184 realWorld->BuildPlacementFieldsWorld());
185 runManager->SetUserInitialization(realWorld);
186
189#ifdef BDSDEBUG
190 G4cout << __METHOD_NAME__ << "> Constructing physics processes" << G4endl;
191#endif
192 G4String physicsListName = parser->GetOptions().physicsList;
193
194#if G4VERSION_NUMBER > 1049
195 // from 10.5 onwards they have a looping particle killer that warnings and kills particles
196 // deemed to be looping that are <100 MeV. This is unrelated to the primary energy so troublesome.
197 // set to the 'low' limits here ~10keV. This must be done before any physics is created as the
198 // parameters are copied into the transportation physics process for each particle and it's very
199 // hard to sift through and fix afterwards
200 G4PhysicsListHelper::GetPhysicsListHelper()->UseLowLooperThresholds();
201#endif
202 // sampler physics process for parallel world tracking must be instantiated BEFORE
203 // regular physics.
204 // Note, we purposively don't create a parallel world process for the curvilinear
205 // world as we don't need the track information from it - unreliable that way. We
206 // query the geometry directly using our BDSAuxiliaryNavigator class.
207 auto parallelWorldPhysics = BDS::ConstructParallelWorldPhysics(parallelWorldsRequiringPhysics);
208 G4int physicsVerbosity = globals->PhysicsVerbosity();
209 G4VModularPhysicsList* physList;
210 if (userPhysicsList)
211 {
212 G4cout << "Using externally registered user defined physics list" << G4endl;
213 physList = userPhysicsList;
214 }
215 else
216 {physList = BDS::BuildPhysics(physicsListName, physicsVerbosity);}
217
218 // create geometry sampler and register importance sampling biasing. Has to be here
219 // before physicsList is "initialised" in run manager.
220 if (BDSGlobalConstants::Instance()->UseImportanceSampling())
221 {BDS::RegisterImportanceBiasing(parallelWorldsRequiringPhysics,physList);}
222
223 // Construction of the physics lists defines the necessary particles and therefore
224 // we can calculate the beam rigidity for the particle the beam is designed w.r.t. This
225 // must happen before the geometry is constructed (which is called by
226 // runManager->Initialize()).
227 BDSParticleDefinition* designParticle = nullptr;
228 BDSParticleDefinition* beamParticle = nullptr;
229 G4bool beamDifferentFromDesignParticle = false;
231 globals->FFact(),
232 designParticle,
233 beamParticle,
234 beamDifferentFromDesignParticle);
235 G4double minEK = globals->MinimumKineticEnergy();
236 if (beamParticle->KineticEnergy() < minEK && BDS::IsFinite(minEK))
237 {throw BDSException("option, minimumKineticEnergy is higher than kinetic energy of the beam - all primary particles wil be killed!");}
238 if (usualPrintOut)
239 {
240 G4cout << "Design particle properties: " << G4endl << *designParticle;
241 if (beamDifferentFromDesignParticle)
242 {G4cout << "Beam particle properties: " << G4endl << *beamParticle;}
243 }
244 // update rigidity where needed
245 realWorld->SetDesignParticle(designParticle);
247 BDSGeometryFactorySQL::SetDefaultRigidity(designParticle->BRho()); // used for sql field loading
248
249 // Muon splitting - optional - should be done *after* biasing to work with it
250 G4int muonSplittingFactor = globals->MuonSplittingFactor();
251 if (muonSplittingFactor > 1)
252 {
253 G4int muonSplittingFactor2 = globals->MuonSplittingFactor2();
254 G4double muonSplittingThresholdParentEk = globals->MuonSplittingThresholdParentEk();
255 G4double muonSplittingThresholdParentEk2 = globals->MuonSplittingThresholdParentEk2();
256 G4cout << "BDSPhysicsMuonSplitting -> using muon splitting wrapper -> factor of: " << muonSplittingFactor << G4endl;
257 if (muonSplittingThresholdParentEk > 0)
258 {G4cout << "BDSPhysicsMuonSplitting -> minimum parent kinetic energy: " << muonSplittingThresholdParentEk / CLHEP::GeV << " GeV" << G4endl;}
259 if (muonSplittingFactor2 > 1)
260 {
261 G4cout << "BDSPhysicsMuonSplitting -> factor #2: " << muonSplittingFactor2 << " for muons above "
262 << muonSplittingThresholdParentEk / CLHEP::GeV << " GeV" << G4endl;
263 }
264 G4bool excludeW1P = globals->MuonSplittingExcludeWeight1Particles();
265 physList->RegisterPhysics(new BDSPhysicsMuonSplitting(muonSplittingFactor, muonSplittingThresholdParentEk,
266 muonSplittingFactor2, muonSplittingThresholdParentEk2,
267 excludeW1P, globals->MuonSplittingExclusionWeight()));
268 }
269
270 BDS::RegisterSamplerPhysics(parallelWorldPhysics, physList);
271 auto biasPhysics = BDS::BuildAndAttachBiasWrapper(parser->GetBiasing());
272 if (biasPhysics)//could be nullptr and can't be passed to geant4 like this
273 {physList->RegisterPhysics(biasPhysics);}
274 runManager->SetUserInitialization(physList);
275
278 parser->GetBeam(),
279 globals->BeamlineTransform(),
280 globals->BeamlineS(),
281 globals->GeneratePrimariesOnly());
282 G4cout << "Bunch distribution: " << bdsBunch->Name() << G4endl;
285 delete beamParticle;
289
293 if (globals->GeneratePrimariesOnly())
294 {
295 // output creation is duplicated below but with this if loop, we exit so ok.
297 const G4int nToGenerate = globals->NGenerate();
298 const G4int printModulo = globals->PrintModuloEvents();
299 bdsBunch->BeginOfRunAction(nToGenerate);
300 auto flagsCache(G4cout.flags());
301 for (G4int i = 0; i < nToGenerate; i++)
302 {
303 if (i%printModulo == 0)
304 {G4cout << "\r Primary> " << std::fixed << i << " of " << nToGenerate << G4endl;}
306 // always pull particle definition in case it's updated
308 bdsOutput->FillEventPrimaryOnly(coords, pDef);
309 }
310 G4cout.flags(flagsCache); // restore cout flags
311 // Write options now the file is open
314
315 // Write beam
317 bdsOutput->FillBeam(bb);
318
320 return 0;
321 }
322
324 G4GeometryTolerance* theGeometryTolerance = G4GeometryTolerance::GetInstance();
325 if (usualPrintOut)
326 {
327 G4cout << __METHOD_NAME__ << "Geometry Tolerances: " << G4endl;
328 G4cout << __METHOD_NAME__ << std::setw(12) << "Surface: " << std::setw(7) << theGeometryTolerance->GetSurfaceTolerance() << " mm" << G4endl;
329 G4cout << __METHOD_NAME__ << std::setw(12) << "Angular: " << std::setw(7) << theGeometryTolerance->GetAngularTolerance() << " rad" << G4endl;
330 G4cout << __METHOD_NAME__ << std::setw(12) << "Radial: " << std::setw(7) << theGeometryTolerance->GetRadialTolerance() << " mm" << G4endl;
331 }
333#ifdef BDSDEBUG
334 G4cout << __METHOD_NAME__ << "Registering user action - Event Action" << G4endl;
335#endif
336 BDSEventAction* eventAction = new BDSEventAction(bdsOutput);
337 runManager->SetUserAction(eventAction);
338
339#ifdef BDSDEBUG
340 G4cout << __METHOD_NAME__ << "Registering user action - Run Action"<<G4endl;
341#endif
342 runManager->SetUserAction(new BDSRunAction(bdsOutput,
343 bdsBunch,
345 eventAction,
346 globals->StoreTrajectorySamplerID()));
347
348#ifdef BDSDEBUG
349 G4cout << __METHOD_NAME__ << "Registering user action - Stepping Action"<<G4endl;
350#endif
351 // Only add steppingaction if it is actually used, so do check here (for performance reasons)
352 G4int verboseSteppingEventStart = globals->VerboseSteppingEventStart();
353 G4int verboseSteppingEventStop = BDS::VerboseEventStop(verboseSteppingEventStart,
354 globals->VerboseSteppingEventContinueFor());
355 if (globals->VerboseSteppingBDSIM())
356 {
357 runManager->SetUserAction(new BDSSteppingAction(true,
358 verboseSteppingEventStart,
359 verboseSteppingEventStop));
360 }
361
362#ifdef BDSDEBUG
363 G4cout << __METHOD_NAME__ << "Registering user action - Tracking Action"<<G4endl;
364#endif
365 runManager->SetUserAction(new BDSTrackingAction(globals->Batch(),
366 globals->StoreTrajectory(),
367 globals->StoreTrajectoryOptions(),
368 eventAction,
369 verboseSteppingEventStart,
370 verboseSteppingEventStop,
371 globals->VerboseSteppingPrimaryOnly(),
372 globals->VerboseSteppingLevel()));
373
374#ifdef BDSDEBUG
375 G4cout << __METHOD_NAME__ << "Registering user action - Stacking Action"<<G4endl;
376#endif
377 runManager->SetUserAction(new BDSStackingAction(globals));
378
379#ifdef BDSDEBUG
380 G4cout << __METHOD_NAME__ << "Registering user action - Primary Generator"<<G4endl;
381#endif
382 auto primaryGeneratorAction = new BDSPrimaryGeneratorAction(bdsBunch, parser->GetBeam());
383 runManager->SetUserAction(primaryGeneratorAction);
384 BDSFieldFactory::SetPrimaryGeneratorAction(primaryGeneratorAction);
385
388
390 if (globals->UseImportanceSampling())
391 {BDS::AddIStore(parallelWorldsRequiringPhysics);}
392
395
396 if (usualPrintOut && globals->PhysicsVerbose())
397 {
400 }
401
405 runManager->SetVerboseLevel(std::min(globals->VerboseRunLevel(), globals->PhysicsVerbosity()));
406 G4EventManager::GetEventManager()->SetVerboseLevel(globals->VerboseEventLevel());
407 G4EventManager::GetEventManager()->GetTrackingManager()->SetVerboseLevel(globals->VerboseTrackingLevel());
408
410 G4bool bCloseGeometry = G4GeometryManager::GetInstance()->CloseGeometry();
411 if (!bCloseGeometry)
412 {
413 G4cerr << __METHOD_NAME__ << "error - geometry not closed." << G4endl;
414 return 1;
415 }
416
417 if (globals->ExportGeometry())
418 {
419 BDSGeometryWriter geometrywriter;
420 geometrywriter.ExportGeometry(globals->ExportType(),
421 globals->ExportFileName());
422 }
423
424 initialised = true;
425 return 0;
426}
427
428void BDSIM::BeamOn(int nGenerate)
429{
431 {return;} // a mode where we don't do anything
432
433 G4cout.precision(10);
435 struct sigaction act;
436 act.sa_handler = &BDS::HandleAborts;
437 sigemptyset(&act.sa_mask);
438 act.sa_flags = 0;
439 if (!ignoreSIGINT)
440 {sigaction(SIGINT, &act, nullptr);}
441 sigaction(SIGABRT, &act, nullptr);
442 sigaction(SIGTERM, &act, nullptr);
443 sigaction(SIGSEGV, &act, nullptr);
444
446 try
447 {
448 if (!BDSGlobalConstants::Instance()->Batch()) // Interactive mode
449 {
450 BDSVisManager visManager = BDSVisManager(BDSGlobalConstants::Instance()->VisMacroFileName(),
451 BDSGlobalConstants::Instance()->Geant4MacroFileName(),
452 realWorld);
453 visManager.StartSession(argcCache, argvCache);
454 }
455 else
456 {// batch mode
457 if (nGenerate < 0)
459 else
460 {runManager->BeamOn(nGenerate);}
461 }
462 }
463 catch (const BDSException& exception)
464 {
465 // don't do this for now in case it's dangerous and we try tracking with open geometry
466 //G4GeometryManager::GetInstance()->OpenGeometry();
467 throw exception;
468 }
469}
470
472{
474 G4GeometryManager::GetInstance()->OpenGeometry();
475
476#ifdef BDSDEBUG
477 G4cout << __METHOD_NAME__ << "deleting..." << G4endl;
478#endif
479 delete bdsOutput;
480
481 try
482 {
483 // order important here because of singletons relying on each other
484 delete BDSSDManager::Instance();
488 delete BDSAcceleratorModel::Instance();
490 delete BDSFieldFactory::Instance(); // this uses BDSGlobalConstants which uses BDSMaterials
492 delete BDSMaterials::Instance();
493
494 // instances not used in this file, but no other good location for deletion
495 if (initialisationResult < 2)
496 {
497 delete BDSColours::Instance();
501 }
502 }
503 catch (...)
504 {;} // ignore any exception as this is a destructor
505
506 delete runManager;
507 delete bdsBunch;
508 delete parser;
509
510 if (usualPrintOut)
511 {G4cout << __METHOD_NAME__ << "End of Run. Thank you for using BDSIM!" << G4endl;}
512}
513
514void BDSIM::RegisterUserComponent(const G4String& componentTypeName,
515 BDSComponentConstructor* componentConstructor)
516{
517 if (initialised)
518 {BDS::Warning(__METHOD_NAME__, "BDSIM kernel already initialised - this component will not be available");}
521
522 userComponentFactory->RegisterComponent(componentTypeName,
523 componentConstructor);
524}
static BDSAperturePointsCache * Instance()
Access the singleton instance.
void ClearCachedFiles()
Delete all cached points from memory and clear the map of files loaded.
static BDSBeamPipeFactory * Instance()
Singleton accessor.
static BDSBunch * CreateBunch(const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, const G4Transform3D &beamlineTransform=G4Transform3D::Identity, G4double beamlineS=0, G4bool generatePrimariesOnlyIn=false)
factory method
virtual G4bool ExpectChangingParticleType() const
A hint of whether we expect to require and extended particle set (ie pions, kaons,...
Definition: BDSBunch.hh:80
virtual const BDSParticleDefinition * ParticleDefinition() const
Access the beam particle definition.
Definition: BDSBunch.hh:95
virtual void BeginOfRunAction(G4int numberOfEvents)
Definition: BDSBunch.cc:252
virtual BDSParticleCoordsFullGlobal GetNextParticleValid(G4int maxTries=100)
Definition: BDSBunch.cc:206
static BDSCavityFactory * Instance()
Singleton accessor.
static BDSColours * Instance()
singleton pattern
Definition: BDSColours.cc:33
Interface class the developer should derive to construct their element.
Factory for user specified accelerator components.
void RegisterComponent(const G4String &componentTypeName, BDSComponentConstructor *componentConstructor)
Register a constructor instance by a given name.
Class that constructs a Geant4 model of an accelerator.
void SetDesignParticle(const BDSParticleDefinition *defIn)
Set the design particle definition.
Process information at the event level.
General exception with possible name of object and message.
Definition: BDSException.hh:35
Executable option processing for BDSIM.
const GMAD::Options & Options() const
Accessor for options generated by command line parsing.
void Print() const
Print out the commands and their set values.
G4bool IgnoreSIGINT() const
Accessor.
const GMAD::Beam & Beam() const
Accessor for beam options generate by command line parsing.
void PrintCopyright() const
Print out the copyright information (no exit).
G4String InputFileName() const
Acessor for convenience for the one thing that's needed before the parser options.
static void SetDesignParticle(const BDSParticleDefinition *designParticleIn)
Update the internal cache of the rigidity.
static void SetPrimaryGeneratorAction(BDSPrimaryGeneratorAction *pgaIn)
Update the internal cache of the primary generator action.
static BDSFieldFactory * Instance()
Public accessor method for singleton pattern.
static BDSFieldLoader * Instance()
Singleton accessor.
static BDSGeometryFactory * Instance()
Singleton accessor.
A class for writing fully constructed geometry from BDSIM out to other formats.
void ExportGeometry(G4String geometryType, G4String geometryFileName)
A class that holds global options and constants.
static BDSGlobalConstants * Instance()
Access method.
BDS::TrajectoryOptions StoreTrajectoryOptions() const
options that require some implementation.
G4bool UseImportanceSampling() const
Is importance sampling being used.
BDSRunManager * runManager
Cache of main objects in BDSIM.
Definition: BDSIMClass.hh:100
BDSOutput * bdsOutput
Cache of main objects in BDSIM.
Definition: BDSIMClass.hh:98
void RegisterUserComponent(const G4String &componentTypeName, BDSComponentConstructor *componentConstructor)
Definition: BDSIMClass.cc:514
void BeamOn(int nGenerate=-1)
Definition: BDSIMClass.cc:428
BDSIM()
Definition: BDSIMClass.cc:83
int Initialise()
The main function where everything is constructed.
Definition: BDSIMClass.cc:126
~BDSIM()
The destructor opens the geometry in Geant4 and deletes everything.
Definition: BDSIMClass.cc:471
BDSComponentFactoryUser * userComponentFactory
Optional user registered component factory.
Definition: BDSIMClass.hh:101
BDSBunch * bdsBunch
Cache of main objects in BDSIM.
Definition: BDSIMClass.hh:99
bool ignoreSIGINT
For cmake testing.
Definition: BDSIMClass.hh:89
BDSDetectorConstruction * realWorld
Cache of main objects in BDSIM.
Definition: BDSIMClass.hh:103
int initialisationResult
Possible to not finish initialisation but have completed ok - flag for this.
Definition: BDSIMClass.hh:92
G4VModularPhysicsList * userPhysicsList
Optional user registered physics list.
Definition: BDSIMClass.hh:102
int argcCache
Cache of argc.
Definition: BDSIMClass.hh:93
char ** argvCache
Cache of argv.
Definition: BDSIMClass.hh:94
bool usualPrintOut
Whether to allow the usual cout output.
Definition: BDSIMClass.hh:90
BDSParser * parser
Cache of main objects in BDSIM.
Definition: BDSIMClass.hh:97
bool initialised
Whether initialisation was completed safely.
Definition: BDSIMClass.hh:91
static BDSMaterials * Instance()
Singleton pattern access.
Definition: BDSMaterials.cc:38
void PrepareRequiredMaterials(G4bool verbose=false)
converts parser material list
static BDSOutput * CreateOutput(BDSOutputType format, const G4String &fileName, G4int fileNumberOffset=-1, G4int compressionLevel=-1)
factory method
virtual void NewFile()=0
Open a new file. This should call WriteHeader() in it.
void FillEventPrimaryOnly(const BDSParticleCoordsFullGlobal &coords, const BDSParticleDefinition *particle)
Definition: BDSOutput.cc:263
void FillBeam(const GMAD::BeamBase *beam)
Definition: BDSOutput.cc:204
void FillOptions(const GMAD::OptionsBase *options)
Definition: BDSOutput.cc:211
virtual void CloseFile()=0
void AmalgamateBeam(const GMAD::Beam &beamIn, bool recreate)
Amalgamate the input beam definition with the ones stored in teh parser.
Definition: BDSParser.cc:65
const GMAD::OptionsBase * GetOptionsBase() const
Return bare options base class.
Definition: BDSParser.hh:53
void CheckOptions()
Check options for consistency. This also checks the beam options.
Definition: BDSParser.cc:84
static BDSParser * Instance()
Access method.
Definition: BDSParser.cc:28
const GMAD::Beam & GetBeam() const
Return beam.
Definition: BDSParser.hh:56
const GMAD::Options & GetOptions() const
Return options.
Definition: BDSParser.hh:50
void AmalgamateOptions(const GMAD::Options &optionsIn)
Amalgamate the input options with the ones stored in the parser.
Definition: BDSParser.cc:76
const GMAD::BeamBase * GetBeamBase() const
Return bare beam base class.
Definition: BDSParser.hh:62
const GMAD::FastList< GMAD::PhysicsBiasing > & GetBiasing() const
Return biasing list.
Definition: BDSParser.hh:95
A set of particle coordinates in both local and global.
Wrapper for particle definition.
G4String Name() const
Accessor.
G4double KineticEnergy() const
Accessor.
G4double BRho() const
Accessor.
G4bool IsAnIon() const
Accessor.
High energy muon processes.
Generates primary particle vertices using BDSBunch.
Control over the beginning and end of run actions.
Definition: BDSRunAction.hh:44
Wrapper from G4RunManager that provides more output.
virtual void Initialize()
virtual void BeamOn(G4int n_event, const char *macroFile=nullptr, G4int n_select=-1)
Altered BeamOn function to account for Placet synchronisation.
static BDSSamplerRegistry * Instance()
Accessor for registry.
BDSIM's Geant4 stacking action.
Provide extra output for Geant4 through a verbose stepping action.
static BDSTemporaryFiles * Instance()
Singleton accessor.
Action to decide whether or not to store trajectory information.
The BDS Visualisation Manager.
void StartSession(int argc, char **argv)
Start interactive mode.
Options for a beam distribution.
Definition: beamBase.h:35
Basic options class independent of Geant4.
Definition: optionsBase.h:36
std::string physicsList
list of physics processes
Definition: optionsBase.h:113
bool verbose
General verbosity.
Definition: optionsBase.h:64
bool recreate
Whether to recreate from a file or not.
Definition: optionsBase.h:92
std::vector< G4ParallelWorldPhysics * > ConstructParallelWorldPhysics(const std::vector< G4VUserParallelWorld * > &worlds)
Construct the parallel physics process for each sampler world.
void PrintDefinedParticles()
void RegisterSamplerPhysics(const std::vector< G4ParallelWorldPhysics * > &processes, G4VModularPhysicsList *physicsList)
Register each parallel physics process to the main physics list.
void RegisterImportanceBiasing(const std::vector< G4VUserParallelWorld * > &worlds, G4VModularPhysicsList *physicsList)
Create importance geometry sampler and register importance biasing with physics list.
std::vector< G4VUserParallelWorld * > ConstructAndRegisterParallelWorlds(G4VUserDetectorConstruction *massWorld, G4bool buildSamplerWorld, G4bool buildPlacementFieldsWorld)
void PrintPrimaryParticleProcesses(const G4String &primaryParticleName)
G4bool Geant4EnvironmentIsSet()
Check if the geant4 environmental variables necessary for a run are set.
void ConstructExtendedParticleSet()
void HandleAborts(int signal_number)
void ConstructDesignAndBeamParticle(const GMAD::Beam &beamDefinition, G4double ffact, BDSParticleDefinition *&designParticle, BDSParticleDefinition *&beamParticle, G4bool &beamDifferentFromDesignParticle)
G4int VerboseEventStop(G4int verboseEventStart, G4int verboseEventContinueFor)
void AddIStore(const std::vector< G4VUserParallelWorld * > &worlds)
Get store, and prepare importance sampling for importance geometry sampler.
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())
G4VModularPhysicsList * BuildPhysics(const G4String &physicsList, G4int verbosity=1)