BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Public Member Functions | Private Member Functions | Private Attributes
BDSIM Class Reference

Interface class to use BDSIM. More...

#include <BDSIMClass.hh>

Collaboration diagram for BDSIM:
Collaboration graph

Public Member Functions

 BDSIM ()
 
int Initialise (int argc, char **argv, bool usualPrintOut=true)
 Initialise everything given these arguments. More...
 
 BDSIM (int argc, char **argv, bool usualPrintOut=true)
 Construct and initialise BDSIM. More...
 
 ~BDSIM ()
 The destructor opens the geometry in Geant4 and deletes everything. More...
 
bool Initialised () const
 
int InitialisationResult () const
 
void BeamOn (int nGenerate=-1)
 
void RegisterUserComponent (const G4String &componentTypeName, BDSComponentConstructor *componentConstructor)
 
void RegisterUserPhysicsList (G4VModularPhysicsList *userPhysicsListIn)
 Provide a physics list that will be used inplace of the BDSIM generate one. More...
 
G4VModularPhysicsList * UserPhysicsList () const
 Access user physics list. More...
 

Private Member Functions

int Initialise ()
 The main function where everything is constructed. More...
 

Private Attributes

bool ignoreSIGINT
 For cmake testing. More...
 
bool usualPrintOut
 Whether to allow the usual cout output. More...
 
bool initialised
 Whether initialisation was completed safely. More...
 
int initialisationResult
 Possible to not finish initialisation but have completed ok - flag for this. More...
 
int argcCache
 Cache of argc. More...
 
char ** argvCache
 Cache of argv. More...
 
BDSParserparser
 Cache of main objects in BDSIM. More...
 
BDSOutputbdsOutput
 Cache of main objects in BDSIM. More...
 
BDSBunchbdsBunch
 Cache of main objects in BDSIM. More...
 
BDSRunManagerrunManager
 Cache of main objects in BDSIM. More...
 
BDSComponentFactoryUseruserComponentFactory
 Optional user registered component factory. More...
 
G4VModularPhysicsList * userPhysicsList
 Optional user registered physics list. More...
 
BDSDetectorConstructionrealWorld
 Cache of main objects in BDSIM. More...
 

Detailed Description

Interface class to use BDSIM.

First way to use: bds = new BDSIM(argc, argv); bds->BeamOn();

Second way to use (delayed initialisation): bds = new BDSIM(); // modify bds in some way bds->Initialise(argc, argv); bds->BeamOn();

Author
Laurie Nevay

Definition at line 49 of file BDSIMClass.hh.

Constructor & Destructor Documentation

◆ BDSIM() [1/2]

BDSIM::BDSIM ( )

Construct an instance but don't initialise. Requires initialisation with arguments argc and arv

Definition at line 83 of file BDSIMClass.cc.

◆ BDSIM() [2/2]

BDSIM::BDSIM ( int  argc,
char **  argv,
bool  usualPrintOut = true 
)

Construct and initialise BDSIM.

Definition at line 99 of file BDSIMClass.cc.

References initialisationResult, and Initialise().

Here is the call graph for this function:

◆ ~BDSIM()

BDSIM::~BDSIM ( )

Member Function Documentation

◆ BeamOn()

void BDSIM::BeamOn ( int  nGenerate = -1)

Generate nGenerate events. If the default argument -1 is used, the number is taken from the standard input e.g. the executable option ngenerate and then the one specified in the input gmad files as an option.

Catch aborts to close output stream/file. perhaps not all are needed.

Run in either interactive or batch mode

Definition at line 428 of file BDSIMClass.cc.

References argcCache, argvCache, BDSRunManager::BeamOn(), BDS::HandleAborts(), ignoreSIGINT, initialisationResult, initialised, BDSGlobalConstants::Instance(), realWorld, runManager, and BDSVisManager::StartSession().

Here is the call graph for this function:

◆ InitialisationResult()

int BDSIM::InitialisationResult ( ) const
inline

Definition at line 69 of file BDSIMClass.hh.

◆ Initialise() [1/2]

int BDSIM::Initialise ( )
private

The main function where everything is constructed.

Initialize executable command line options reader object

Parse lattice file

Update options generated by parser with those from executable options.

Check options for consistency

Explicitly initialise materials to construct required materials before global constants.

No longer needed. Everything can safely use BDSGlobalConstants from now on.

Force construction of global constants after parser has been initialised (requires materials first). This uses the options and beam from BDSParser. Non-const as we'll update the particle definition.

Initialize random number generator

Construct output

Check geant4 exists in the current environment

Construct mandatory run manager (the G4 kernel) and register mandatory initialization classes.

Register the geometry and parallel world construction methods with run manager.

Here the geometry isn't actually constructed - this is called by the runManager->Initialize()

For geometry sampling, phys list must be initialized before detector. BUT for samplers we use a parallel world and this HAS to be before the physics

Instantiate the specific type of bunch distribution.

We no longer need beamParticle so delete it to avoid confusion. The definition is held inside bdsBunch (can be updated dynamically).

Construct extra common particles for possible tracking if required without using a physics list.

Optionally generate primaries only and exit Unfortunately, this has to be here as we can't query the geant4 particle table until after the physics list has been constructed and attached a run manager.

Print the geometry tolerance

Set user action classes

Initialize G4 kernel

Create importance store for parallel importance world

Implement bias operations on all volumes only after G4RunManager::Initialize()

Set verbosity levels at run and G4 event level. Per event and stepping are controlled in event, tracking and stepping action. These have to be done here due to the order of construction in Geant4.

Close the geometry in preparation for running - everything is now fixed.

Definition at line 126 of file BDSIMClass.cc.

References BDS::AddIStore(), BDSParser::AmalgamateBeam(), BDSParser::AmalgamateOptions(), argcCache, argvCache, bdsBunch, bdsOutput, BDSExecOptions::Beam(), BDSBunch::BeginOfRunAction(), BDSParticleDefinition::BRho(), BDS::BuildPhysics(), BDSDetectorConstruction::BuildPhysicsBias(), BDSDetectorConstruction::BuildSamplerWorld(), BDSParser::CheckOptions(), BDSOutput::CloseFile(), BDS::ConstructAndRegisterParallelWorlds(), BDS::ConstructDesignAndBeamParticle(), BDS::ConstructExtendedParticleSet(), BDS::ConstructParallelWorldPhysics(), BDSBunchFactory::CreateBunch(), BDSOutputFactory::CreateOutput(), BDSBunch::ExpectChangingParticleType(), BDSGeometryWriter::ExportGeometry(), BDSOutput::FillBeam(), BDSOutput::FillEventPrimaryOnly(), BDSOutput::FillOptions(), BDS::Geant4EnvironmentIsSet(), BDSParser::GetBeam(), BDSParser::GetBeamBase(), BDSParser::GetBiasing(), BDSBunch::GetNextParticleValid(), BDSParser::GetOptions(), BDSParser::GetOptionsBase(), BDSExecOptions::IgnoreSIGINT(), ignoreSIGINT, initialised, BDSRunManager::Initialize(), BDSExecOptions::InputFileName(), BDSGlobalConstants::Instance(), BDSMaterials::Instance(), BDSParser::Instance(), BDSParticleDefinition::IsAnIon(), BDS::IsFinite(), BDSParticleDefinition::KineticEnergy(), BDSParticleDefinition::Name(), BDSOutput::NewFile(), BDSExecOptions::Options(), parser, BDSBunch::ParticleDefinition(), GMAD::OptionsBase::physicsList, BDSMaterials::PrepareRequiredMaterials(), BDSExecOptions::Print(), BDSExecOptions::PrintCopyright(), BDS::PrintDefinedParticles(), BDS::PrintPrimaryParticleProcesses(), realWorld, GMAD::OptionsBase::recreate, BDS::RegisterImportanceBiasing(), BDS::RegisterSamplerPhysics(), runManager, BDSDetectorConstruction::SetDesignParticle(), BDSFieldFactory::SetDesignParticle(), BDSFieldFactory::SetPrimaryGeneratorAction(), BDSGlobalConstants::StoreTrajectoryOptions(), BDSGlobalConstants::UseImportanceSampling(), userComponentFactory, userPhysicsList, usualPrintOut, GMAD::OptionsBase::verbose, and BDS::VerboseEventStop().

Referenced by BDSIM(), and Initialise().

Here is the caller graph for this function:

◆ Initialise() [2/2]

int BDSIM::Initialise ( int  argc,
char **  argv,
bool  usualPrintOut = true 
)

Initialise everything given these arguments.

Definition at line 117 of file BDSIMClass.cc.

References argcCache, argvCache, initialisationResult, Initialise(), and usualPrintOut.

Here is the call graph for this function:

◆ Initialised()

bool BDSIM::Initialised ( ) const
inline

Accessor as to whether BDSIM kernel is initialised - ie all geometry and physics constructed.

Definition at line 67 of file BDSIMClass.hh.

References initialised.

◆ RegisterUserComponent()

void BDSIM::RegisterUserComponent ( const G4String &  componentTypeName,
BDSComponentConstructor componentConstructor 
)

Register a custom user beam line element by the type name you'd like it to have and the (user-provided) constructor that can construct it.

Definition at line 514 of file BDSIMClass.cc.

References initialised, BDSComponentFactoryUser::RegisterComponent(), and userComponentFactory.

Here is the call graph for this function:

◆ RegisterUserPhysicsList()

void BDSIM::RegisterUserPhysicsList ( G4VModularPhysicsList *  userPhysicsListIn)
inline

Provide a physics list that will be used inplace of the BDSIM generate one.

Definition at line 82 of file BDSIMClass.hh.

References userPhysicsList.

◆ UserPhysicsList()

G4VModularPhysicsList * BDSIM::UserPhysicsList ( ) const
inline

Access user physics list.

Definition at line 83 of file BDSIMClass.hh.

References userPhysicsList.

Field Documentation

◆ argcCache

int BDSIM::argcCache
private

Cache of argc.

Definition at line 93 of file BDSIMClass.hh.

Referenced by BeamOn(), and Initialise().

◆ argvCache

char** BDSIM::argvCache
private

Cache of argv.

Definition at line 94 of file BDSIMClass.hh.

Referenced by BeamOn(), and Initialise().

◆ bdsBunch

BDSBunch* BDSIM::bdsBunch
private

Cache of main objects in BDSIM.

Definition at line 99 of file BDSIMClass.hh.

Referenced by Initialise(), and ~BDSIM().

◆ bdsOutput

BDSOutput* BDSIM::bdsOutput
private

Cache of main objects in BDSIM.

Definition at line 98 of file BDSIMClass.hh.

Referenced by Initialise(), and ~BDSIM().

◆ ignoreSIGINT

bool BDSIM::ignoreSIGINT
private

For cmake testing.

Definition at line 89 of file BDSIMClass.hh.

Referenced by BeamOn(), and Initialise().

◆ initialisationResult

int BDSIM::initialisationResult
private

Possible to not finish initialisation but have completed ok - flag for this.

Definition at line 92 of file BDSIMClass.hh.

Referenced by BDSIM(), BeamOn(), Initialise(), and ~BDSIM().

◆ initialised

bool BDSIM::initialised
private

Whether initialisation was completed safely.

Definition at line 91 of file BDSIMClass.hh.

Referenced by BeamOn(), Initialise(), Initialised(), and RegisterUserComponent().

◆ parser

BDSParser* BDSIM::parser
private

Cache of main objects in BDSIM.

Definition at line 97 of file BDSIMClass.hh.

Referenced by Initialise(), and ~BDSIM().

◆ realWorld

BDSDetectorConstruction* BDSIM::realWorld
private

Cache of main objects in BDSIM.

Definition at line 103 of file BDSIMClass.hh.

Referenced by BeamOn(), and Initialise().

◆ runManager

BDSRunManager* BDSIM::runManager
private

Cache of main objects in BDSIM.

Definition at line 100 of file BDSIMClass.hh.

Referenced by BeamOn(), Initialise(), and ~BDSIM().

◆ userComponentFactory

BDSComponentFactoryUser* BDSIM::userComponentFactory
private

Optional user registered component factory.

Definition at line 101 of file BDSIMClass.hh.

Referenced by Initialise(), and RegisterUserComponent().

◆ userPhysicsList

G4VModularPhysicsList* BDSIM::userPhysicsList
private

Optional user registered physics list.

Definition at line 102 of file BDSIMClass.hh.

Referenced by Initialise(), RegisterUserPhysicsList(), and UserPhysicsList().

◆ usualPrintOut

bool BDSIM::usualPrintOut
private

Whether to allow the usual cout output.

Definition at line 90 of file BDSIMClass.hh.

Referenced by Initialise(), and ~BDSIM().


The documentation for this class was generated from the following files: