BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
BDSGeometryFactorySQL.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 BDSGEOMETRYFACTORYSQL_H
20#define BDSGEOMETRYFACTORYSQL_H
21
22#include "BDSGeometryFactoryBase.hh"
23
24#include "globals.hh"
25#include "G4ThreeVector.hh"
26#include "G4RotationMatrix.hh"
27
28#include <list>
29#include <map>
30#include <unordered_map>
31#include <vector>
32
33class BDSMySQLTable;
34
35class G4Colour;
36class G4LogicalVolume;
37class G4Region;
38class G4UserLimits;
39class G4VisAttributes;
40
52{
53public:
55 virtual ~BDSGeometryFactorySQL(){;}
56
57 static void SetDefaultRigidity(G4double rigidityIn) {defaultRigidity = rigidityIn;}
58
61 virtual BDSGeometryExternal* Build(G4String componentName,
62 G4String fileName,
63 std::map<G4String, G4Colour*>* colourMapping = nullptr,
64 G4bool autoColour = true,
65 G4double suggestedLength = 0,
66 G4double suggestedHorizontalWidth = 0,
67 std::vector<G4String>* vacuumBiasVolumeNames = nullptr,
68 G4UserLimits* userLimitsToAttachToAllLVs = nullptr);
69
70protected:
72 virtual void CleanUp();
73
75 void CleanUpSQL();
76
77private:
78 std::unordered_map<G4VSolid*, BDSExtent> unShiftedExtents;
79
80 // For List of uniform fields for volumes
81 std::list<G4ThreeVector> UniformField;
82 std::list<G4String> Fieldvol;
83
84 // For List of Quad/Sext/Oct Fields
85 std::list<G4double> QuadBgrad;
86 std::list<G4String> Quadvol;
87 std::list<G4double> SextBgrad;
88 std::list<G4String> Sextvol;
89 std::list<G4double> OctBgrad;
90 std::list<G4String> Octvol;
91
92 std::vector<G4LogicalVolume*> VOL_LIST;
93
94 G4int NVariables;
95 G4double VisRed;
96 G4double VisGreen;
97 G4double VisBlue;
98 G4double VisAlpha;
99 G4String VisType;
100 G4String Material;
101 G4String TableName;
102 G4String Name;
103
104 G4double PosX;
105 G4double PosY;
106 G4double PosZ;
107 G4double RotPsi;
108 G4double RotTheta;
109 G4double RotPhi;
110 G4double K1,K2,K3,K4;
111 G4String PARENTNAME;
112 G4String InheritStyle;
113 G4String Parameterisation;
114 G4String MagType;
115 G4int align_in;
116 G4int align_out;
117 G4int SetSensitive;
118 G4int PrecisionRegion;
119 G4int ApproximationRegion;
120 G4double FieldX, FieldY, FieldZ;
121
122 G4double lengthUserLimit;
123
124 G4Region* precisionRegionSQL;
125 G4Region* approximationRegionSQL;
126
127 void BuildSQLObjects(G4String file);
128 void SetCommonParams(BDSMySQLTable*,G4int);
129 void SetPlacementParams(BDSMySQLTable*,G4int);
130 G4VisAttributes* VisAtt();
131 G4UserLimits* UserLimits(G4double);
132 void SetLogVolAtt(G4LogicalVolume*, G4double);
133 void SetLogVolRegion(G4LogicalVolume*);
134 G4LogicalVolume* BuildCone(BDSMySQLTable* aSQLTable, G4int k);
135 G4LogicalVolume* BuildEllipticalCone(BDSMySQLTable* aSQLTable, G4int k);
136 G4LogicalVolume* BuildPolyCone(BDSMySQLTable* aSQLTable, G4int k);
137 G4LogicalVolume* BuildBox(BDSMySQLTable* aSQLTable, G4int k);
138 G4LogicalVolume* BuildTrap(BDSMySQLTable* aSQLTable, G4int k);
139 G4LogicalVolume* BuildTorus(BDSMySQLTable* aSQLTable, G4int k);
140 G4LogicalVolume* BuildSampler(BDSMySQLTable* aSQLTable, G4int k);
141 G4LogicalVolume* BuildTube(BDSMySQLTable* aSQLTable, G4int k);
142 G4LogicalVolume* BuildEllipticalTube(BDSMySQLTable* aSQLTable, G4int k);
143 //G4LogicalVolume* BuildPCLTube(BDSMySQLTable* aSQLTable, G4int k);
144 G4RotationMatrix* RotateComponent(G4double psi,
145 G4double phi,
146 G4double theta);
147 G4RotationMatrix* rotateComponent;
148 void PlaceComponents(BDSMySQLTable* aSQLTable, std::vector<G4LogicalVolume*> VOL_LIST);
149
150 G4LogicalVolume* itsMarkerVol;
151 std::vector<BDSMySQLTable*> itsSQLTable;
152 // BDSFieldMagSQL* itsMagField;
153 // BDSSDSampler* SensDet;
154
155 void SetMultiplePhysicalVolumes(G4VPhysicalVolume* aPhysVol);
156
158 template <typename T>
159 void AssignVariable(BDSMySQLTable* aSQLTable, G4int k, G4String variableName, T& variable);
160
164 std::map<G4LogicalVolume*, G4int> samplerIDs;
165
166 std::set<G4LogicalVolume*> sensitiveComponents;
167
168 G4VPhysicalVolume* alignInVolume;
169 G4VPhysicalVolume* alignOutVolume;
170
171 std::map<G4String, G4ThreeVector> uniformFieldVolField;
172 std::map<G4String, G4double> quadVolBgrad;
173 std::map<G4String, G4double> sextVolBgrad;
174 std::map<G4String, G4double> octVolBgrad;
175
177 static G4double defaultRigidity;
178};
179
180#endif
A loaded piece of externally provided geometry.
Base class for external geometry loading factories.
Geometry factory for SQL geometry.
void PlaceComponents(BDSMySQLTable *aSQLTable, std::vector< G4LogicalVolume * > VOL_LIST)
void CleanUpSQL()
Non-virtual clean up as used in constructor.
virtual BDSGeometryExternal * Build(G4String componentName, G4String fileName, std::map< G4String, G4Colour * > *colourMapping=nullptr, G4bool autoColour=true, G4double suggestedLength=0, G4double suggestedHorizontalWidth=0, std::vector< G4String > *vacuumBiasVolumeNames=nullptr, G4UserLimits *userLimitsToAttachToAllLVs=nullptr)
void AssignVariable(BDSMySQLTable *aSQLTable, G4int k, G4String variableName, T &variable)
Search SQL table for variableName and if exists assign to variable.
virtual void CleanUp()
Clean up members.
static G4double defaultRigidity
Cache of default rigidity for possibly constructing fields (only SQL)
std::map< G4LogicalVolume *, G4int > samplerIDs
Representation of a mysql table.