19#include "BDSAcceleratorComponentRegistry.hh"
20#include "BDSAcceleratorModel.hh"
21#include "BDSApertureInfo.hh"
22#include "BDSBeamline.hh"
23#include "BDSBeamlineSet.hh"
25#include "BDSException.hh"
26#include "BDSFieldObjects.hh"
27#include "BDSLinkComponent.hh"
28#include "BDSPhysicalVolumeInfoRegistry.hh"
29#include "BDSRegion.hh"
30#include "BDSScorerHistogramDef.hh"
31#include "BDSUtilities.hh"
34#include "G4LogicalVolume.hh"
35#include "G4VPhysicalVolume.hh"
37#include "G4VUserParallelWorld.hh"
59 tunnelBeamline(nullptr),
60 placementBeamline(nullptr),
67BDSAcceleratorModel::~BDSAcceleratorModel()
70 G4cout <<
"BDSAcceleratorModel> Deleting model" << G4endl;
86 {bl.second.DeleteContents();}
88 for (
auto lc : linkComponents)
104 G4cout <<
"BDSAcceleratorModel> Deletion complete" << G4endl;
111 mainBeamlineSet = setIn;
120 {search->second.DeleteContents();}
128 {
return mainBeamlineSet;}
132 {
throw BDSException(__METHOD_NAME__,
"No such beam line set \"" + name +
"\"");}
134 {
return search->second;}
139 regions[region->
name] = region;
145 apertures.insert(aperturesIn.begin(), aperturesIn.end());
152 {
return result->second;}
154 {
throw BDSException(__METHOD_NAME__,
"Invalid aperture name \"" + name +
"\"");}
159 auto result = regions.find(name);
160 if (result != regions.end())
161 {
return result->second->g4region;}
164 G4cerr <<
"Invalid region name \"" << name <<
"\"" << G4endl;
165 G4cout <<
"Available regions are: " << G4endl;
166 for (
const auto& r : regions)
167 {G4cout << r.first <<
" ";}
168 throw BDSException(__METHOD_NAME__,
"invalid region name.");
180 const G4String& registryName)
187 return registry->find(volume) != registry->end();
195 {
return result->second;}
242 const G4Transform3D& placement)
244 scorerMeshPlacements[meshName] = placement;
251 {
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.
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)