BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSAcceleratorModel.hh
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#ifndef BDSACCELERATORMODEL_H
19#define BDSACCELERATORMODEL_H
20#include "BDSBeamlineSet.hh"
21#include "BDSPlacementToMake.hh"
22#include "BDSScorerHistogramDef.hh"
23
24#include "globals.hh" // geant4 globals / types
25#include "G4Transform3D.hh"
26
27#include <map>
28#include <set>
29#include <vector>
30
31class BDSApertureInfo;
32class BDSBeamline;
33class BDSFieldObjects;
35class BDSRegion;
36class G4LogicalVolume;
37class G4Region;
38class G4VPhysicalVolume;
39class G4VSolid;
40class G4VUserParallelWorld;
41
60{
61public:
62 static BDSAcceleratorModel* Instance();
64
66 inline void RegisterWorldPV(G4VPhysicalVolume* worldIn) {worldPV = worldIn;}
67 inline void RegisterWorldLV(G4LogicalVolume* worldIn) {worldLV = worldIn;}
68 inline void RegisterWorldSolid(G4VSolid* worldIn) {worldSolid = worldIn;}
70
71 inline G4VPhysicalVolume* WorldPV() const {return worldPV;}
72 inline G4LogicalVolume* WorldLV() const {return worldLV;}
73
75 void RegisterBeamlineSetMain(const BDSBeamlineSet& setIn);
76
78 void RegisterBeamlineSetExtra(const G4String& name,
79 const BDSBeamlineSet& setIn);
80
82 inline const BDSBeamlineSet& BeamlineSetMain() const {return mainBeamlineSet;}
83 const BDSBeamlineSet& BeamlineSet(const G4String& name) const;
84 inline const std::map<G4String, BDSBeamlineSet>& ExtraBeamlines() const {return extraBeamlines;}
85 const BDSBeamline* BeamlineMain() const {return mainBeamlineSet.massWorld;}
87
88 inline void RegisterParallelWorld(G4VUserParallelWorld* world) {parallelWorlds.insert(world);}
89
91 inline void RegisterPlacementBeamline(BDSBeamline* placementBLIn) {placementBeamline = placementBLIn;}
92
95
97 inline void RegisterPlacementFieldPlacements(const std::vector<BDSPlacementToMake>& pIn) {placementFieldPlacements = pIn;}
98
100 const std::vector<BDSPlacementToMake>& PlacementFieldPWPlacements() const {return placementFieldPlacements;}
101
103 inline void RegisterBLMs(BDSBeamline* blmsIn) {blmsBeamline = blmsIn;}
104
106 inline BDSBeamline* BLMsBeamline() const {return blmsBeamline;}
107
109 inline void RegisterTunnelBeamline(BDSBeamline* beamlineIn) {tunnelBeamline = beamlineIn;}
110
112 inline BDSBeamline* TunnelBeamline() const {return tunnelBeamline;}
113
115 inline void RegisterFields(std::vector<BDSFieldObjects*>& fieldsIn){fields = fieldsIn;}
116
118 void RegisterRegion(BDSRegion* region);
119
121 inline void RegisterAperture(const G4String& name, BDSApertureInfo* apertureIn) {apertures[name] = apertureIn;}
122
124 void RegisterApertures(const std::map<G4String, BDSApertureInfo*>& aperturesIn);
125
128 BDSApertureInfo* Aperture(G4String name) const;
129
131 G4Region* Region(const G4String& name) const;
132
134 std::set<G4LogicalVolume*>* VolumeSet(const G4String& name);
135
138 G4bool VolumeInSet(G4LogicalVolume* volume,
139 const G4String& registryName);
140
144
147 G4bool BeamlineIsMassWorld(BDSBeamline* bl) const;
148
152 G4int& index) const;
153
158
160 void RegisterScorerPlacement(const G4String& meshName,
161 const G4Transform3D& placement);
162
164 const std::vector<BDSScorerHistogramDef>& ScorerHistogramDefinitions() const {return scorerHistogramDefs;}
165 const std::map<G4String, BDSScorerHistogramDef>& ScorerHistogramDefinitionsMap() const {return scorerHistogramDefsMap;}
166 const BDSScorerHistogramDef* ScorerHistogramDef(const G4String& name);
167 const std::map<G4String, G4Transform3D>& ScorerMeshPlacementsMap() const {return scorerMeshPlacements;}
169
170 void RegisterLinkComponent(BDSLinkComponent* linkComponentIn) {linkComponents.insert(linkComponentIn);}
171 inline const std::set<BDSLinkComponent*>& LinkComponents() const {return linkComponents;}
172
173private:
175
176 static BDSAcceleratorModel* instance;
177
178 G4VPhysicalVolume* worldPV;
179 G4LogicalVolume* worldLV;
180 G4VSolid* worldSolid;
181
182 BDSBeamlineSet mainBeamlineSet;
183 std::map<G4String, BDSBeamlineSet> extraBeamlines;
184
185 std::set<G4VUserParallelWorld*> parallelWorlds;
186
188 std::map<BDSBeamline*, BDSBeamline*> clToMassWorldMap;
189
192 std::map<BDSBeamline*, G4bool> massWorldMapTF;
193
195 void MapBeamlineSet(const BDSBeamlineSet& setIn);
196
200
201 std::vector<BDSFieldObjects*> fields;
202 std::map<G4String, BDSRegion*> regions;
203 std::set<BDSRegion*> regionStorage;
204 std::map<G4String, BDSApertureInfo*> apertures;
205
208 std::vector<BDSPlacementToMake> placementFieldPlacements;
209
210 std::map<G4String, std::set<G4LogicalVolume*>* > volumeRegistries;
211
213 std::vector<BDSScorerHistogramDef> scorerHistogramDefs;
214 std::map<G4String, BDSScorerHistogramDef> scorerHistogramDefsMap;
216 std::map<G4String, G4Transform3D> scorerMeshPlacements;
217
218 std::set<BDSLinkComponent*> linkComponents;
219};
220
221#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.
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:40
Definition for a scorer histogram.