BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSIMClass.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include "BDSIMClass.hh"
19
20#include "BDSExecOptions.hh" // executable command line options
21#include "BDSGlobalConstants.hh" // global parameters
22
23#include <algorithm>
24#include <csignal>
25#include <cstdlib>
26#include <cstdio>
27
28#include "G4EventManager.hh" // Geant4 includes
29#include "G4GenericBiasingPhysics.hh"
30#include "G4GeometryManager.hh"
31#include "G4GeometryTolerance.hh"
32#include "G4PhysicsListHelper.hh"
33#include "G4ParallelWorldPhysics.hh"
34#include "G4ParticleDefinition.hh"
35#include "G4SteppingManager.hh"
36#include "G4TrackingManager.hh"
37#include "G4Version.hh"
38#include "G4VModularPhysicsList.hh"
39#ifdef USE_GEANT4CGALBOOLEAN
40#include "G4BooleanProcessorCGAL.hh"
41#endif
42
43#include "CLHEP/Units/SystemOfUnits.h"
44
45#include "BDSAcceleratorModel.hh"
46#include "BDSAperturePointsLoader.hh"
47#include "BDSBeamPipeFactory.hh"
48#include "BDSBunch.hh"
49#include "BDSBunchFactory.hh"
50#include "BDSCavityFactory.hh"
51#include "BDSColours.hh"
52#include "BDSComponentFactoryUser.hh"
53#include "BDSDebug.hh"
54#include "BDSDetectorConstruction.hh"
55#include "BDSEventAction.hh"
56#include "BDSException.hh"
57#include "BDSFieldFactory.hh"
58#include "BDSFieldLoader.hh"
59#include "BDSGeometryFactory.hh"
60#include "BDSGeometryFactorySQL.hh"
61#include "BDSGeometryWriter.hh"
62#include "BDSIonDefinition.hh"
63#include "BDSMaterials.hh"
64#include "BDSOutput.hh"
65#include "BDSOutputFactory.hh"
66#include "BDSParallelWorldUtilities.hh"
67#include "BDSParser.hh" // Parser
68#include "BDSParticleDefinition.hh"
69#include "BDSPhysicsUtilities.hh"
70#include "BDSPolarizationState.hh"
71#include "BDSPrimaryGeneratorAction.hh"
72#include "BDSRandom.hh" // for random number generator from CLHEP
73#include "BDSRunAction.hh"
74#include "BDSRunManager.hh"
75#include "BDSSamplerRegistry.hh"
76#include "BDSSDManager.hh"
77#include "BDSSteppingAction.hh"
78#include "BDSStackingAction.hh"
79#include "BDSTemporaryFiles.hh"
80#include "BDSTrackingAction.hh"
81#include "BDSUtilities.hh"
82#include "BDSVisManager.hh"
83#include "BDSWarning.hh"
84
85
87 ignoreSIGINT(false),
88 usualPrintOut(true),
89 initialised(false),
90 initialisationResult(1),
91 argcCache(0),
92 argvCache(nullptr),
93 parser(nullptr),
94 bdsOutput(nullptr),
95 bdsBunch(nullptr),
96 runManager(nullptr),
97 userComponentFactory(nullptr),
98 userPhysicsList(nullptr),
99 realWorld(nullptr)
100{;}
101
103 ignoreSIGINT(false),
104 usualPrintOut(true),
105 initialised(false),
106 initialisationResult(1),
107 argcCache(0),
108 argvCache(nullptr),
109 parser(parserIn),
110 bdsOutput(nullptr),
111 bdsBunch(nullptr),
112 runManager(nullptr),
113 userComponentFactory(nullptr),
114 userPhysicsList(nullptr),
115 realWorld(nullptr)
116{
118}
119
120
121BDSIM::BDSIM(int argc, char** argv, bool usualPrintOutIn):
122 ignoreSIGINT(false),
123 usualPrintOut(usualPrintOutIn),
124 initialised(false),
125 initialisationResult(1),
126 argcCache(argc),
127 argvCache(argv),
128 parser(nullptr),
129 bdsOutput(nullptr),
130 bdsBunch(nullptr),
131 runManager(nullptr),
132 userComponentFactory(nullptr),
133 userPhysicsList(nullptr),
134 realWorld(nullptr)
135{
137}
138
139int BDSIM::Initialise(int argc, char** argv, bool usualPrintOutIn)
140{
141 argcCache = argc;
142 argvCache = argv;
143 usualPrintOut = usualPrintOutIn;
146}
147
149{
150
151#ifdef USE_GEANT4CGALBOOLEAN
152 G4BooleanSolid::SetExternalBooleanProcessor(new G4BooleanProcessorCGAL());
153#endif
154
156 const BDSExecOptions* execOptions = new BDSExecOptions(argcCache,argvCache);
157 if (usualPrintOut)
158 {execOptions->Print();}
159 ignoreSIGINT = execOptions->IgnoreSIGINT(); // different sig catching for cmake
160
161 execOptions->PrintCopyright();
162#ifdef BDSDEBUG
163 G4cout << __METHOD_NAME__ << "DEBUG mode is on." << G4endl;
164#endif
165
167 if (!parser) {
168 parser = BDSParser::Instance(execOptions->InputFileName());
170 }
171
172 parser->AmalgamateOptions(execOptions->Options());
173 parser->AmalgamateBeam(execOptions->Beam(),
174 execOptions->Options().recreate);
177
178
181
183 delete execOptions;
184
189
191 BDSRandom::CreateRandomNumberGenerator(globals->RandomEngine());
192 BDSRandom::SetSeed(); // set the seed from options
193
195 bdsOutput = BDSOutputFactory::CreateOutput(globals->OutputFormat(),
196 globals->OutputFileName());
197
200 {
201 G4cerr << "No Geant4 environmental variables found - please source geant4.sh environment" << G4endl;
202 G4cout << "A common fault is the wrong Geant4 environment as compared to the one BDSIM was compiled with." << G4endl;
203 return 1;
204 }
205
209
212
214 auto parallelWorldsRequiringPhysics = BDS::ConstructAndRegisterParallelWorlds(realWorld,
216 realWorld->BuildPlacementFieldsWorld());
217 runManager->SetUserInitialization(realWorld);
218
221#ifdef BDSDEBUG
222 G4cout << __METHOD_NAME__ << "> Constructing physics processes" << G4endl;
223#endif
224 G4String physicsListName = parser->GetOptions().physicsList;
225
226#if G4VERSION_NUMBER > 1049
227 // from 10.5 onwards they have a looping particle killer that warnings and kills particles
228 // deemed to be looping that are <100 MeV. This is unrelated to the primary energy so troublesome.
229 // set to the 'low' limits here ~10keV. This must be done before any physics is created as the
230 // parameters are copied into the transportation physics process for each particle and it's very
231 // hard to sift through and fix afterwards
232 G4PhysicsListHelper::GetPhysicsListHelper()->UseLowLooperThresholds();
233#endif
234 // sampler physics process for parallel world tracking must be instantiated BEFORE
235 // regular physics.
236 // Note, we purposively don't create a parallel world process for the curvilinear
237 // world as we don't need the track information from it - unreliable that way. We
238 // query the geometry directly using our BDSAuxiliaryNavigator class.
239 auto parallelWorldPhysics = BDS::ConstructParallelWorldPhysics(parallelWorldsRequiringPhysics);
240 G4int physicsVerbosity = globals->PhysicsVerbosity();
241 G4VModularPhysicsList* physList;
242 if (userPhysicsList)
243 {
244 G4cout << "Using externally registered user defined physics list" << G4endl;
245 physList = userPhysicsList;
246 }
247 else
248 {physList = BDS::BuildPhysics(physicsListName, physicsVerbosity);}
249
250 // create geometry sampler and register importance sampling biasing. Has to be here
251 // before physicsList is "initialised" in run manager.
252 if (BDSGlobalConstants::Instance()->UseImportanceSampling())
253 {BDS::RegisterImportanceBiasing(parallelWorldsRequiringPhysics, physList);}
254 if (BDSGlobalConstants::Instance()->ExtendPionDecayChannels())
256 if (BDSGlobalConstants::Instance()->TurnOffMuonDecay())
258
259 // Construction of the physics lists defines the necessary particles and therefore
260 // we can calculate the beam rigidity for the particle the beam is designed w.r.t. This
261 // must happen before the geometry is constructed (which is called by
262 // runManager->Initialize()).
263 BDSParticleDefinition* designParticle = nullptr;
264 BDSParticleDefinition* beamParticle = nullptr;
265 G4bool beamDifferentFromDesignParticle = false;
267 globals->FFact(),
268 designParticle,
269 beamParticle,
270 beamDifferentFromDesignParticle);
271 G4double minEK = globals->MinimumKineticEnergy();
272 if (beamParticle->KineticEnergy() < minEK && BDS::IsFinite(minEK))
273 {throw BDSException("option, minimumKineticEnergy is higher than kinetic energy of the beam - all primary particles wil be killed!");}
274 if (usualPrintOut)
275 {
276 G4cout << "Design particle properties: " << G4endl << *designParticle;
277 if (beamDifferentFromDesignParticle)
278 {G4cout << "Beam particle properties: " << G4endl << *beamParticle;}
279 }
280 // update rigidity where needed
281 realWorld->SetDesignParticle(designParticle);
283 BDSGeometryFactorySQL::SetDefaultRigidity(designParticle->BRho()); // used for sql field loading
284
285 // Muon splitting - optional - should be done *after* biasing to work with it - TBC it's before...
286 BDS::BuildMuonBiasing(physList);
287
288 BDS::RegisterSamplerPhysics(parallelWorldPhysics, physList);
289 auto biasPhysics = BDS::BuildAndAttachBiasWrapper(parser->GetBiasing());
290 if (biasPhysics)//could be nullptr and can't be passed to geant4 like this
291 {physList->RegisterPhysics(biasPhysics);}
292 runManager->SetUserInitialization(physList);
293
296 parser->GetBeam(),
297 globals->BeamlineTransform(),
298 globals->BeamlineS(),
299 globals->GeneratePrimariesOnly());
300 G4cout << "Bunch distribution: \"" << bdsBunch->Name() << "\"" << G4endl;
303 delete beamParticle;
307
311 if (globals->GeneratePrimariesOnly())
312 {
313 GeneratePrimariesOnly(globals);
314 return 0;
315 }
316
318 G4GeometryTolerance* theGeometryTolerance = G4GeometryTolerance::GetInstance();
319 if (usualPrintOut)
320 {
321 G4cout << __METHOD_NAME__ << "Geometry Tolerances: " << G4endl;
322 G4cout << __METHOD_NAME__ << std::setw(12) << "Surface: " << std::setw(7) << theGeometryTolerance->GetSurfaceTolerance() << " mm" << G4endl;
323 G4cout << __METHOD_NAME__ << std::setw(12) << "Angular: " << std::setw(7) << theGeometryTolerance->GetAngularTolerance() << " rad" << G4endl;
324 G4cout << __METHOD_NAME__ << std::setw(12) << "Radial: " << std::setw(7) << theGeometryTolerance->GetRadialTolerance() << " mm" << G4endl;
325 }
326
328 BDSEventAction* eventAction = new BDSEventAction(bdsOutput);
329 runManager->SetUserAction(eventAction);
330
331 BDSRunAction* runAction = new BDSRunAction(bdsOutput,
332 bdsBunch,
334 eventAction,
335 globals->StoreTrajectorySamplerID());
336 runManager->SetUserAction(runAction);
337
338 // Only add stepping action if it is actually used, so do check here (for performance reasons)
339 G4int verboseSteppingEventStart = globals->VerboseSteppingEventStart();
340 G4int verboseSteppingEventStop = BDS::VerboseEventStop(verboseSteppingEventStart,
341 globals->VerboseSteppingEventContinueFor());
342 if (globals->VerboseSteppingBDSIM())
343 {
344 runManager->SetUserAction(new BDSSteppingAction(true,
345 verboseSteppingEventStart,
346 verboseSteppingEventStop));
347 }
348
349 runManager->SetUserAction(new BDSTrackingAction(globals->Batch(),
350 globals->StoreTrajectory(),
351 globals->StoreTrajectoryOptions(),
352 eventAction,
353 verboseSteppingEventStart,
354 verboseSteppingEventStop,
355 globals->VerboseSteppingPrimaryOnly(),
356 globals->VerboseSteppingLevel(),
358
359 runManager->SetUserAction(new BDSStackingAction(globals));
360
361 auto primaryGeneratorAction = new BDSPrimaryGeneratorAction(bdsBunch, parser->GetBeam(), globals->Batch());
362 // possibly updated after the primary generator as loaded a beam file
363 eventAction->SetPrintModulo(BDSGlobalConstants::Instance()->PrintModuloEvents());
364 runManager->SetUserAction(primaryGeneratorAction);
365 BDSFieldFactory::SetPrimaryGeneratorAction(primaryGeneratorAction);
366
369
371 if (globals->UseImportanceSampling())
372 {BDS::AddIStore(parallelWorldsRequiringPhysics);}
373
376
377 if (usualPrintOut && globals->PhysicsVerbose())
378 {
381 }
382
386 runManager->SetVerboseLevel(std::min(globals->VerboseRunLevel(), globals->PhysicsVerbosity()));
387 G4EventManager::GetEventManager()->SetVerboseLevel(globals->VerboseEventLevel());
388 G4EventManager::GetEventManager()->GetTrackingManager()->SetVerboseLevel(globals->VerboseTrackingLevel());
389
391 G4bool bCloseGeometry = G4GeometryManager::GetInstance()->CloseGeometry();
392 if (!bCloseGeometry)
393 {
394 G4cerr << __METHOD_NAME__ << "error - geometry not closed." << G4endl;
395 return 1;
396 }
397
398 if (globals->ExportGeometry())
399 {
400 BDSGeometryWriter geometrywriter;
401 geometrywriter.ExportGeometry(globals->ExportType(),
402 globals->ExportFileName());
403 }
404
405 initialised = true;
406 return 0;
407}
408
409void BDSIM::BeamOn(int nGenerate)
410{
412 {return;} // a mode where we don't do anything
413
414 G4cout.precision(10);
416 struct sigaction act;
417 act.sa_handler = &BDS::HandleAborts;
418 sigemptyset(&act.sa_mask);
419 act.sa_flags = 0;
420 if (!ignoreSIGINT)
421 {sigaction(SIGINT, &act, nullptr);}
422 sigaction(SIGABRT, &act, nullptr);
423 sigaction(SIGTERM, &act, nullptr);
424 sigaction(SIGSEGV, &act, nullptr);
425
427 try
428 {
429 if (!BDSGlobalConstants::Instance()->Batch()) // Interactive mode
430 {
431 BDSVisManager visManager = BDSVisManager(BDSGlobalConstants::Instance()->VisMacroFileName(),
432 BDSGlobalConstants::Instance()->Geant4MacroFileName(),
433 realWorld,
434 BDSGlobalConstants::Instance()->VisVerbosity());
435 visManager.StartSession(argcCache, argvCache);
436 }
437 else
438 {// batch mode
439 if (nGenerate < 0)
441 else
442 {runManager->BeamOn(nGenerate);}
443 }
444 }
445 catch (const BDSException& exception)
446 {
447 // don't do this for now in case it's dangerous and we try tracking with open geometry
448 //G4GeometryManager::GetInstance()->OpenGeometry();
449 throw exception;
450 }
451}
452
454{
456 G4GeometryManager::GetInstance()->OpenGeometry();
457
458#ifdef BDSDEBUG
459 G4cout << __METHOD_NAME__ << "deleting..." << G4endl;
460#endif
461 delete bdsOutput;
462
463 try
464 {
465 // order important here because of singletons relying on each other
466 delete BDSSDManager::Instance();
470 delete BDSAcceleratorModel::Instance();
472 delete BDSFieldFactory::Instance(); // this uses BDSGlobalConstants which uses BDSMaterials
474 delete BDSMaterials::Instance();
475
476 // instances not used in this file, but no other good location for deletion
477 if (initialisationResult < 2)
478 {
479 delete BDSColours::Instance();
483 }
484 }
485 catch (...)
486 {;} // ignore any exception as this is a destructor
487
488 delete runManager;
489 delete bdsBunch;
490
491 if (usualPrintOut)
492 {G4cout << __METHOD_NAME__ << "End of Run. Thank you for using BDSIM!" << G4endl;}
493}
494
495void BDSIM::RegisterUserComponent(const G4String& componentTypeName,
496 BDSComponentConstructor* componentConstructor)
497{
498 if (initialised)
499 {BDS::Warning(__METHOD_NAME__, "BDSIM kernel already initialised - this component will not be available");}
502
503 userComponentFactory->RegisterComponent(componentTypeName,
504 componentConstructor);
505}
506
508{
509 // output creation is duplicated below but with this if loop, we exit so ok.
511 const G4int nToGenerate = globals->NGenerate();
512 const G4int printModulo = globals->PrintModuloEvents();
513 bdsBunch->BeginOfRunAction(nToGenerate, globals->Batch());
514 auto flagsCache(G4cout.flags());
515 for (G4int i = 0; i < nToGenerate; i++)
516 {
517 if (i%printModulo == 0)
518 {G4cout << "\r Primary> " << std::fixed << i << " of " << nToGenerate << G4endl;}
520 // always pull particle definition in case it's updated
522 bdsOutput->FillEventPrimaryOnly(coords, pDef);
523 }
524 G4cout.flags(flagsCache); // restore cout flags
525 // Write options now the file is open
528
529 // Write beam
531 bdsOutput->FillBeam(bb);
532
534}
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 void BeginOfRunAction(G4int numberOfEvents, G4bool batchMode)
Definition BDSBunch.cc:284
virtual G4bool ExpectChangingParticleType() const
A hint of whether we expect to require and extended particle set (ie pions, kaons,...
Definition BDSBunch.hh:79
virtual const BDSParticleDefinition * ParticleDefinition() const
Access the beam particle definition.
Definition BDSBunch.hh:95
G4String Name() const
Distribution name.
Definition BDSBunch.hh:144
virtual BDSParticleCoordsFullGlobal GetNextParticleValid(G4int maxTries=100)
Definition BDSBunch.cc:233
static BDSCavityFactory * Instance()
Singleton accessor.
static BDSColours * Instance()
singleton pattern
Definition BDSColours.cc:32
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 (initial) design particle definition.
Process information at the event level.
void SetPrintModulo(G4int printModuloIn)
General exception with possible name of object and message.
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(const G4String &geometryType, const 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.
BDSOutput * bdsOutput
Cache of main objects in BDSIM.
void RegisterUserComponent(const G4String &componentTypeName, BDSComponentConstructor *componentConstructor)
void BeamOn(int nGenerate=-1)
int Initialise()
The main function where everything is constructed.
~BDSIM()
The destructor opens the geometry in Geant4 and deletes everything.
BDSComponentFactoryUser * userComponentFactory
Optional user registered component factory.
BDSBunch * bdsBunch
Cache of main objects in BDSIM.
bool ignoreSIGINT
For cmake testing.
Definition BDSIMClass.hh:97
void GeneratePrimariesOnly(const BDSGlobalConstants *globals)
BDSDetectorConstruction * realWorld
Cache of main objects in BDSIM.
int initialisationResult
Possible to not finish initialisation but have completed ok - flag for this.
G4VModularPhysicsList * userPhysicsList
Optional user registered physics list.
int argcCache
Cache of argc.
char ** argvCache
Cache of argv.
bool usualPrintOut
Whether to allow the usual cout output.
Definition BDSIMClass.hh:98
BDSParser * parser
Cache of main objects in BDSIM.
bool initialised
Whether initialisation was completed safely.
Definition BDSIMClass.hh:99
static BDSMaterials * Instance()
Singleton pattern access.
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:272
void FillBeam(const GMAD::BeamBase *beam)
Definition BDSOutput.cc:210
void FillOptions(const GMAD::OptionsBase *options)
Definition BDSOutput.cc:217
virtual void CloseFile()=0
Const entry to parser objects.
Definition BDSParser.hh:36
void AmalgamateBeam(const GMAD::Beam &beamIn, bool recreate)
Amalgamate the input beam definition with the ones stored in teh parser.
Definition BDSParser.cc:74
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:93
static BDSParser * Instance()
Access method.
Definition BDSParser.cc:29
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:85
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:92
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.
Polarization state to pass to processes.
Generates primary particle vertices using BDSBunch.
Control over the beginning and end of run actions.
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:34
Basic options class independent of Geant4.
Definition optionsBase.h:35
std::string physicsList
list of physics processes
bool verbose
General verbosity.
Definition optionsBase.h:64
bool recreate
Whether to recreate from a file or not.
Definition optionsBase.h:94
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.
void ExtendPionDecayChannels(G4VModularPhysicsList *physicsList)
Extend the default pi+- decay channels in Geant4.
std::vector< G4VUserParallelWorld * > ConstructAndRegisterParallelWorlds(G4VUserDetectorConstruction *massWorld, G4bool buildSamplerWorld, G4bool buildPlacementFieldsWorld)
void PrintPrimaryParticleProcesses(const G4String &primaryParticleName)
void BuildMuonBiasing(G4VModularPhysicsList *physicsList)
Build muon splitting biasing and wrap the various processes in the physics list.
G4bool Geant4EnvironmentIsSet()
Check if the geant4 environmental variables necessary for a run are set.
void TurnOffMuonDecay()
Set mu+- as stable so they won't decay.
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)