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