BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSGeometryFactorySQL.hh
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2023.
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 G4bool makeSensitive = true,
69 BDSSDType sensitivityType = BDSSDType::energydep,
70 BDSSDType vacuumSensitivityType = BDSSDType::energydepvacuum,
71 G4UserLimits* userLimitsToAttachToAllLVs = nullptr);
72
73protected:
75 virtual void CleanUp();
76
78 void CleanUpSQL();
79
80private:
81 std::unordered_map<G4VSolid*, BDSExtent> unShiftedExtents;
82
83 // For List of uniform fields for volumes
84 std::list<G4ThreeVector> UniformField;
85 std::list<G4String> Fieldvol;
86
87 // For List of Quad/Sext/Oct Fields
88 std::list<G4double> QuadBgrad;
89 std::list<G4String> Quadvol;
90 std::list<G4double> SextBgrad;
91 std::list<G4String> Sextvol;
92 std::list<G4double> OctBgrad;
93 std::list<G4String> Octvol;
94
95 std::vector<G4LogicalVolume*> VOL_LIST;
96
97 G4int NVariables;
98 G4double VisRed;
99 G4double VisGreen;
100 G4double VisBlue;
101 G4double VisAlpha;
102 G4String VisType;
103 G4String Material;
104 G4String TableName;
105 G4String Name;
106
107 G4double PosX;
108 G4double PosY;
109 G4double PosZ;
110 G4double RotPsi;
111 G4double RotTheta;
112 G4double RotPhi;
113 G4double K1,K2,K3,K4;
114 G4String PARENTNAME;
115 G4String InheritStyle;
116 G4String Parameterisation;
117 G4String MagType;
118 G4int align_in;
119 G4int align_out;
120 G4int SetSensitive;
121 G4int PrecisionRegion;
122 G4int ApproximationRegion;
123 G4double FieldX, FieldY, FieldZ;
124
125 G4double lengthUserLimit;
126
127 G4Region* precisionRegionSQL;
128 G4Region* approximationRegionSQL;
129
130 void BuildSQLObjects(G4String file);
131 void SetCommonParams(BDSMySQLTable*,G4int);
132 void SetPlacementParams(BDSMySQLTable*,G4int);
133 G4VisAttributes* VisAtt();
134 G4UserLimits* UserLimits(G4double);
135 void SetLogVolAtt(G4LogicalVolume*, G4double);
136 void SetLogVolRegion(G4LogicalVolume*);
137 G4LogicalVolume* BuildCone(BDSMySQLTable* aSQLTable, G4int k);
138 G4LogicalVolume* BuildEllipticalCone(BDSMySQLTable* aSQLTable, G4int k);
139 G4LogicalVolume* BuildPolyCone(BDSMySQLTable* aSQLTable, G4int k);
140 G4LogicalVolume* BuildBox(BDSMySQLTable* aSQLTable, G4int k);
141 G4LogicalVolume* BuildTrap(BDSMySQLTable* aSQLTable, G4int k);
142 G4LogicalVolume* BuildTorus(BDSMySQLTable* aSQLTable, G4int k);
143 G4LogicalVolume* BuildSampler(BDSMySQLTable* aSQLTable, G4int k);
144 G4LogicalVolume* BuildTube(BDSMySQLTable* aSQLTable, G4int k);
145 G4LogicalVolume* BuildEllipticalTube(BDSMySQLTable* aSQLTable, G4int k);
146 //G4LogicalVolume* BuildPCLTube(BDSMySQLTable* aSQLTable, G4int k);
147 G4RotationMatrix* RotateComponent(G4double psi,
148 G4double phi,
149 G4double theta);
150 G4RotationMatrix* rotateComponent;
151 void PlaceComponents(BDSMySQLTable* aSQLTable, std::vector<G4LogicalVolume*> VOL_LIST);
152
153 G4LogicalVolume* itsMarkerVol;
154 std::vector<BDSMySQLTable*> itsSQLTable;
155 // BDSFieldMagSQL* itsMagField;
156 // BDSSDSampler* SensDet;
157
158 void SetMultiplePhysicalVolumes(G4VPhysicalVolume* aPhysVol);
159
161 template <typename T>
162 void AssignVariable(BDSMySQLTable* aSQLTable, G4int k, G4String variableName, T& variable);
163
167 std::map<G4LogicalVolume*, G4int> samplerIDs;
168
169 std::set<G4LogicalVolume*> sensitiveComponents;
170
171 G4VPhysicalVolume* alignInVolume;
172 G4VPhysicalVolume* alignOutVolume;
173
174 std::map<G4String, G4ThreeVector> uniformFieldVolField;
175 std::map<G4String, G4double> quadVolBgrad;
176 std::map<G4String, G4double> sextVolBgrad;
177 std::map<G4String, G4double> octVolBgrad;
178
180 static G4double defaultRigidity;
181};
182
183#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, G4bool makeSensitive=true, BDSSDType sensitivityType=BDSSDType::energydep, BDSSDType vacuumSensitivityType=BDSSDType::energydepvacuum, 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.
Improve type-safety of native enum data type in C++.