18#include "BDSAcceleratorComponentRegistry.hh"
19#include "BDSAcceleratorModel.hh"
20#include "BDSApertureInfo.hh"
21#include "BDSBeamline.hh"
22#include "BDSBeamlineSet.hh"
24#include "BDSException.hh"
25#include "BDSFieldObjects.hh"
26#include "BDSLinkComponent.hh"
27#include "BDSPhysicalVolumeInfoRegistry.hh"
28#include "BDSRegion.hh"
29#include "BDSScorerHistogramDef.hh"
30#include "BDSUtilities.hh"
33#include "G4LogicalVolume.hh"
34#include "G4VPhysicalVolume.hh"
36#include "G4VUserParallelWorld.hh"
58 tunnelBeamline(nullptr),
59 placementBeamline(nullptr),
66BDSAcceleratorModel::~BDSAcceleratorModel()
69 G4cout <<
"BDSAcceleratorModel> Deleting model" << G4endl;
85 {bl.second.DeleteContents();}
87 for (
auto lc : linkComponents)
103 G4cout <<
"BDSAcceleratorModel> Deletion complete" << G4endl;
110 mainBeamlineSet = setIn;
119 {search->second.DeleteContents();}
127 {
return mainBeamlineSet;}
131 {
throw BDSException(__METHOD_NAME__,
"No such beam line set \"" + name +
"\"");}
133 {
return search->second;}
138 regions[region->
name] = region;
144 apertures.insert(aperturesIn.begin(), aperturesIn.end());
151 {
return result->second;}
153 {
throw BDSException(__METHOD_NAME__,
"Invalid aperture name \"" + name +
"\"");}
158 auto result = regions.find(name);
159 if (result != regions.end())
160 {
return result->second->g4region;}
163 G4cerr <<
"Invalid region name \"" << name <<
"\"" << G4endl;
164 G4cout <<
"Available regions are: " << G4endl;
165 for (
const auto& r : regions)
166 {G4cout << r.first <<
" ";}
167 throw BDSException(__METHOD_NAME__,
"invalid region name.");
179 const G4String& registryName)
186 return registry->find(volume) != registry->end();
194 {
return result->second;}
241 const G4Transform3D& placement)
243 scorerMeshPlacements[meshName] = placement;
250 {
return &result->second;}
static BDSAcceleratorComponentRegistry * Instance()
Singleton accessor.
A holder class for all representations of the accelerator model created in BDSIM.
BDSBeamline * placementBeamline
Placement beam line.
std::vector< BDSScorerHistogramDef > scorerHistogramDefs
Scorer histogram definitions cached from construction here to be used in output creation.
void RegisterBeamlineSetExtra(const G4String &name, const BDSBeamlineSet &setIn)
Register a set of beam lines to be managed and cleared up at the end of the simulation.
std::map< G4String, BDSScorerHistogramDef > scorerHistogramDefsMap
Scorer histogram definitions cached from construction here to be used in output creation.
BDSBeamline * blmsBeamline
BLMs beam line.
std::set< G4LogicalVolume * > * VolumeSet(const G4String &name)
Returns pointer to a set of logical volumes. If no set by that name exits, create it.
std::map< BDSBeamline *, G4bool > massWorldMapTF
std::map< G4String, BDSBeamlineSet > extraBeamlines
Extra beamlines.
void MassWorldBeamlineAndIndex(BDSBeamline *&bl, G4int &index) const
BDSApertureInfo * Aperture(G4String name) const
const BDSScorerHistogramDef * ScorerHistogramDef(const G4String &name)
Access all scorer histogram definitions.
std::map< G4String, std::set< G4LogicalVolume * > * > volumeRegistries
All volume registries.
BDSBeamline * CorrespondingMassWorldBeamline(BDSBeamline *bl) const
std::map< G4String, BDSApertureInfo * > apertures
All apertures.
BDSAcceleratorModel()
Default constructor is private as singleton.
std::vector< BDSFieldObjects * > fields
All field objects.
G4bool BeamlineIsMassWorld(BDSBeamline *bl) const
std::set< BDSRegion * > regionStorage
Unique storage of regions.
void MapBeamlineSet(const BDSBeamlineSet &setIn)
Utility function to apply mapping.
void RegisterApertures(const std::map< G4String, BDSApertureInfo * > &aperturesIn)
Register a map of apertures with associated names.
void RegisterScorerPlacement(const G4String &meshName, const G4Transform3D &placement)
Register a copy of the scorer placement so it can be used in the output.
G4bool VolumeInSet(G4LogicalVolume *volume, const G4String ®istryName)
void RegisterBeamlineSetMain(const BDSBeamlineSet &setIn)
Register the main beam line set.
G4VPhysicalVolume * worldPV
Physical volume of the mass world.
const BDSBeamlineSet & BeamlineSet(const G4String &name) const
Accessor.
std::set< G4VUserParallelWorld * > parallelWorlds
Parallel worlds not use with beam lines.
void RegisterScorerHistogramDefinition(const BDSScorerHistogramDef &def)
std::map< BDSBeamline *, BDSBeamline * > clToMassWorldMap
Mapping from any curvilinear beam line to the corresponding mass world beam line.
G4Region * Region(const G4String &name) const
Access region information. Will exit if not found.
BDSBeamline * tunnelBeamline
Tunnel segments beam line.
void RegisterRegion(BDSRegion *region)
Register a region.
Holder class for all information required to describe an aperture.
Simple struct to return a beamline plus associated beam lines.
void DeleteContents()
Destroy objects pointed to by this instance.
A vector of BDSBeamlineElement instances - a beamline.
const BDSBeamlineElement * at(int iElement) const
Return a reference to the element at i.
General exception with possible name of object and message.
static BDSPhysicalVolumeInfoRegistry * Instance()
Singleton accessor.
Range cuts for a region. Help with defaults.
G4String name
Public members for simplicity.
Definition for a scorer histogram.
G4String uniqueName
Unique name of mesh/scorer -> slash required by Geant4.
V MapGetWithDefault(const std::map< K, V > &m, const K &key, const V &defaultValue)