BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
BDSAcceleratorModel.hh
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#ifndef BDSACCELERATORMODEL_H
20#define BDSACCELERATORMODEL_H
21#include "BDSBeamlineSet.hh"
22#include "BDSPlacementToMake.hh"
23#include "BDSScorerHistogramDef.hh"
24
25#include "globals.hh" // geant4 globals / types
26#include "G4Transform3D.hh"
27
28#include <map>
29#include <set>
30#include <vector>
31
32class BDSApertureInfo;
33class BDSBeamline;
34class BDSFieldObjects;
36class BDSRegion;
37class G4LogicalVolume;
38class G4Region;
39class G4VPhysicalVolume;
40class G4VSolid;
41class G4VUserParallelWorld;
42
61{
62public:
63 static BDSAcceleratorModel* Instance();
65
67 inline void RegisterWorldPV(G4VPhysicalVolume* worldIn) {worldPV = worldIn;}
68 inline void RegisterWorldLV(G4LogicalVolume* worldIn) {worldLV = worldIn;}
69 inline void RegisterWorldSolid(G4VSolid* worldIn) {worldSolid = worldIn;}
71
72 inline G4VPhysicalVolume* WorldPV() const {return worldPV;}
73 inline G4LogicalVolume* WorldLV() const {return worldLV;}
74
76 void RegisterBeamlineSetMain(const BDSBeamlineSet& setIn);
77
79 void RegisterBeamlineSetExtra(const G4String& name,
80 const BDSBeamlineSet& setIn);
81
83 inline const BDSBeamlineSet& BeamlineSetMain() const {return mainBeamlineSet;}
84 const BDSBeamlineSet& BeamlineSet(const G4String& name) const;
85 inline const std::map<G4String, BDSBeamlineSet>& ExtraBeamlines() const {return extraBeamlines;}
86 const BDSBeamline* BeamlineMain() const {return mainBeamlineSet.massWorld;}
88
89 inline void RegisterParallelWorld(G4VUserParallelWorld* world) {parallelWorlds.insert(world);}
90
92 inline void RegisterPlacementBeamline(BDSBeamline* placementBLIn) {placementBeamline = placementBLIn;}
93
96
98 inline void RegisterPlacementFieldPlacements(const std::vector<BDSPlacementToMake>& pIn) {placementFieldPlacements = pIn;}
99
101 const std::vector<BDSPlacementToMake>& PlacementFieldPWPlacements() const {return placementFieldPlacements;}
102
104 inline void RegisterBLMs(BDSBeamline* blmsIn) {blmsBeamline = blmsIn;}
105
107 inline BDSBeamline* BLMsBeamline() const {return blmsBeamline;}
108
110 inline void RegisterTunnelBeamline(BDSBeamline* beamlineIn) {tunnelBeamline = beamlineIn;}
111
113 inline BDSBeamline* TunnelBeamline() const {return tunnelBeamline;}
114
116 inline void RegisterFields(std::vector<BDSFieldObjects*>& fieldsIn){fields = fieldsIn;}
117
119 void RegisterRegion(BDSRegion* region);
120
122 inline void RegisterAperture(const G4String& name, BDSApertureInfo* apertureIn) {apertures[name] = apertureIn;}
123
125 void RegisterApertures(const std::map<G4String, BDSApertureInfo*>& aperturesIn);
126
129 BDSApertureInfo* Aperture(G4String name) const;
130
132 G4Region* Region(const G4String& name) const;
133
135 std::set<G4LogicalVolume*>* VolumeSet(const G4String& name);
136
139 G4bool VolumeInSet(G4LogicalVolume* volume,
140 const G4String& registryName);
141
145
148 G4bool BeamlineIsMassWorld(BDSBeamline* bl) const;
149
153 G4int& index) const;
154
159
161 void RegisterScorerPlacement(const G4String& meshName,
162 const G4Transform3D& placement);
163
165 const std::vector<BDSScorerHistogramDef>& ScorerHistogramDefinitions() const {return scorerHistogramDefs;}
166 const std::map<G4String, BDSScorerHistogramDef>& ScorerHistogramDefinitionsMap() const {return scorerHistogramDefsMap;}
167 const BDSScorerHistogramDef* ScorerHistogramDef(const G4String& name);
168 const std::map<G4String, G4Transform3D>& ScorerMeshPlacementsMap() const {return scorerMeshPlacements;}
170
171 void RegisterLinkComponent(BDSLinkComponent* linkComponentIn) {linkComponents.insert(linkComponentIn);}
172 inline const std::set<BDSLinkComponent*>& LinkComponents() const {return linkComponents;}
173
174private:
176
177 static BDSAcceleratorModel* instance;
178
179 G4VPhysicalVolume* worldPV;
180 G4LogicalVolume* worldLV;
181 G4VSolid* worldSolid;
182
183 BDSBeamlineSet mainBeamlineSet;
184 std::map<G4String, BDSBeamlineSet> extraBeamlines;
185
186 std::set<G4VUserParallelWorld*> parallelWorlds;
187
189 std::map<BDSBeamline*, BDSBeamline*> clToMassWorldMap;
190
193 std::map<BDSBeamline*, G4bool> massWorldMapTF;
194
196 void MapBeamlineSet(const BDSBeamlineSet& setIn);
197
201
202 std::vector<BDSFieldObjects*> fields;
203 std::map<G4String, BDSRegion*> regions;
204 std::set<BDSRegion*> regionStorage;
205 std::map<G4String, BDSApertureInfo*> apertures;
206
209 std::vector<BDSPlacementToMake> placementFieldPlacements;
210
211 std::map<G4String, std::set<G4LogicalVolume*>* > volumeRegistries;
212
214 std::vector<BDSScorerHistogramDef> scorerHistogramDefs;
215 std::map<G4String, BDSScorerHistogramDef> scorerHistogramDefsMap;
217 std::map<G4String, G4Transform3D> scorerMeshPlacements;
218
219 std::set<BDSLinkComponent*> linkComponents;
220};
221
222#endif
A holder class for all representations of the accelerator model created in BDSIM.
BDSBeamline * placementBeamline
Placement beam line.
std::vector< BDSPlacementToMake > placementFieldPlacements
void RegisterFields(std::vector< BDSFieldObjects * > &fieldsIn)
Register all field objects.
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.
void RegisterWorldLV(G4LogicalVolume *worldIn)
Register constituent of world.
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.
const std::vector< BDSScorerHistogramDef > & ScorerHistogramDefinitions() const
Access all scorer histogram definitions.
const std::map< G4String, BDSBeamlineSet > & ExtraBeamlines() const
Accessor.
std::map< G4String, std::set< G4LogicalVolume * > * > volumeRegistries
All volume registries.
const std::map< G4String, BDSScorerHistogramDef > & ScorerHistogramDefinitionsMap() const
Access all scorer histogram definitions.
BDSBeamline * CorrespondingMassWorldBeamline(BDSBeamline *bl) const
const std::map< G4String, G4Transform3D > & ScorerMeshPlacementsMap() const
Access all scorer histogram definitions.
const std::vector< BDSPlacementToMake > & PlacementFieldPWPlacements() const
Access field volumes for parallel world.
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.
BDSBeamline * TunnelBeamline() const
Access the beam line containing all the tunnel segments.
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.
const BDSBeamlineSet & BeamlineSetMain() const
Accessor.
void RegisterAperture(const G4String &name, BDSApertureInfo *apertureIn)
Register a single aperture.
const BDSBeamline * BeamlineMain() const
Accessor.
BDSBeamline * BLMsBeamline() const
Access the beam line of blm placements.
void RegisterTunnelBeamline(BDSBeamline *beamlineIn)
Register the beam line containing all the tunnel segments.
G4bool VolumeInSet(G4LogicalVolume *volume, const G4String &registryName)
BDSBeamline * PlacementBeamline() const
Access the beam line of arbitrary placements.
void RegisterWorldPV(G4VPhysicalVolume *worldIn)
Register constituent of world.
void RegisterPlacementBeamline(BDSBeamline *placementBLIn)
Register the beam line of arbitrary placements.
void RegisterPlacementFieldPlacements(const std::vector< BDSPlacementToMake > &pIn)
Register complete placements to make for field volumes in parallel world.
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.
G4LogicalVolume * WorldLV() const
Access the logical volume of the world.
void RegisterBLMs(BDSBeamline *blmsIn)
Register a beam line of blm placements.
G4Region * Region(const G4String &name) const
Access region information. Will exit if not found.
G4VPhysicalVolume * WorldPV() const
Access the physical volume of the world.
void RegisterWorldSolid(G4VSolid *worldIn)
Register constituent of world.
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.
A vector of BDSBeamlineElement instances - a beamline.
Definition: BDSBeamline.hh:61
A holder for all the Geant4 field related objects.
A BDSAcceleratorComponent wrapper for BDSLinkOpaqueBox.
Range cuts for a region. Help with defaults.
Definition: BDSRegion.hh:41
Definition for a scorer histogram.