18#include "BDSExtent.hh"
19#include "BDSGlobalConstants.hh"
20#include "BDSMagnetOuter.hh"
21#include "BDSMagnetOuterFactoryPolesSquare.hh"
22#include "BDSMaterials.hh"
23#include "BDSSDType.hh"
28#include "G4IntersectionSolid.hh"
29#include "G4LogicalVolume.hh"
30#include "G4Material.hh"
31#include "G4PVPlacement.hh"
32#include "G4SubtractionSolid.hh"
34#include "G4VisAttributes.hh"
41BDSMagnetOuterFactoryPolesSquare::BDSMagnetOuterFactoryPolesSquare():
64 G4double magnetContainerLength,
65 G4double magnetContainerRadiusIn)
68 G4VSolid* yokeOuter =
new G4Box(name +
"_yoke_outer_solid",
73 G4VSolid* yokeInner =
new G4Box(name +
"_yoke_inner_solid",
78 allSolids.insert(yokeOuter);
79 allSolids.insert(yokeInner);
81 yokeSolid =
new G4SubtractionSolid(name +
"_yoke_solid",
88 G4VSolid* containerOuter =
new G4Box(name +
"_container_outer_solid",
93 G4VSolid* containerInner =
new G4Tubs(name +
"_container_inner_solid",
100 allSolids.insert(containerOuter);
101 allSolids.insert(containerInner);
112 containerSolid =
new G4SubtractionSolid(name +
"_outer_container_solid",
116 magnetContainerSolid =
new G4Box(name +
"_container_solid",
117 magnetContainerRadiusIn,
118 magnetContainerRadiusIn,
119 magnetContainerLength*0.5);
121 magContExtent =
BDSExtent(magnetContainerRadiusIn, magnetContainerRadiusIn, magnetContainerLength*0.5);
130 G4int nPoles = 2*orderIn;
133 for (G4int i = 0; i < nPoles; ++i)
135 G4RotationMatrix* iPoleRM =
new G4RotationMatrix();
136 G4double rotationAngle = (0.5-i)*
segmentAngle + CLHEP::pi*0.5;
137 iPoleRM->rotateZ(rotationAngle);
138 allRotationMatrices.insert(iPoleRM);
140 G4IntersectionSolid* aSolid =
new G4IntersectionSolid(name +
"_pole_solid",
146 poleSolids.push_back(aSolid);
152 G4Material* outerMaterial)
154 G4VisAttributes* outerVisAttr =
new G4VisAttributes(*colour);
155 outerVisAttr->SetVisibility(
true);
157 allVisAttributes.insert(outerVisAttr);
159 for (G4int n = 0; n < 2*
order; ++n)
161 G4LogicalVolume* thisPole =
new G4LogicalVolume(poleSolids[n],
164 thisPole->SetVisAttributes(outerVisAttr);
165 poleLVs.push_back(thisPole);
166 allLogicalVolumes.insert(thisPole);
173 yokeLV->SetVisAttributes(outerVisAttr);
177 containerLV =
new G4LogicalVolume(containerSolid,
179 name +
"_container_lv");
182 magnetContainerLV =
new G4LogicalVolume(magnetContainerSolid,
184 name +
"_container_lv");
191 for (
auto& lv : poleLVs)
193 for (
auto& lv : allLogicalVolumes)
206 yokePV =
new G4PVPlacement(
nullptr,
218 G4double nPoles = 2*orderIn;
220 G4PVPlacement* aPlacement =
nullptr;
221 for (G4int n = 0; n < 2*orderIn; ++n)
223 G4RotationMatrix* rm =
new G4RotationMatrix();
224 G4double rotationAngle = (0.5-n)*
segmentAngle + CLHEP::pi*0.5;
225 rm->rotateZ(-rotationAngle);
226 allRotationMatrices.insert(rm);
227 G4String pvName = name +
"_pole_" + std::to_string(n) +
"_pv";
229 aPlacement =
new G4PVPlacement(rm,
237 allPhysicalVolumes.insert(aPlacement);
245 G4double magnetContainerRadiusIn,
249 orderIn, magnetContainerRadiusIn, recipe);
251 std::set<G4LogicalVolume*> tempLVs(poleLVs.begin(), poleLVs.end());
A holder class for a piece of beam pipe geometry.
Holder for +- extents in 3 dimensions.
G4bool checkOverlaps
Cache of global constants variable.
G4double lengthSafety
Cache of global constants variable.
G4VisAttributes * containerVisAttr
Cache of global constants variable.
G4int nSegmentsPerCircle
Cache of global constants variable.
G4UserLimits * defaultUserLimits
Cache of global constants variable.
void RegisterLogicalVolume(G4LogicalVolume *logicalVolume)
void RegisterSensitiveVolume(G4LogicalVolume *sensitiveVolume, BDSSDType sensitivityType)
static BDSGlobalConstants * Instance()
Access method.
G4VSolid * poleSolid
Solid for an individual pole that will be placed multiple times.
G4bool sensitiveOuter
Cache of global constants variable.
G4VSolid * yokeSolid
Solid for outer part that connects all poles.
Factory class for outer volume of magnets. Produces magnets with 2N-poles around the beampipe with a ...
G4double yokeFinishRadius
Finish radius of yoke geometry from magnet centre - less than horizontalWidth.
G4double segmentAngle
2PI / # of poles - angle per segment allocated for each pole.
G4VSolid * poleIntersectionSolid
Solid used to chop off pole.
virtual void CleanUp()
Empty containers for next use - this class is never deleted so can't rely on scope.
virtual void CreateLogicalVolumesCoil(const G4String &name)
G4double poleStartRadius
Start radius of the pole from magnet centre.
G4bool buildPole
Whether or not to build poles (and therefore coils).
G4double yokeStartRadius
Start radius of yoke geometry from magnet cetnre.
virtual BDSMagnetOuter * CommonConstructor(const G4String &name, G4double length, BDSBeamPipe *beamPipe, G4int order, G4double magnetContainerLength, const BDSMagnetOuterInfo *recipe)
Common construction tasks to all methods - assemble yoke and poles in container.
void CleanUpPolesSquare()
Clean up for this factory. Non-virtual as used in constructor.
virtual void IntersectPoleWithYoke(const G4String &name, G4double length, G4int orderIn)
Chop off the top of the pole to match the appropriate yoke geometry.
virtual BDSMagnetOuter * CommonConstructor(const G4String &name, G4double length, BDSBeamPipe *beamPipe, G4int order, G4double magnetContainerLength, const BDSMagnetOuterInfo *recipe)
virtual void CreateLogicalVolumes(const G4String &name, G4Colour *colour, G4Material *outerMaterial)
std::vector< G4RotationMatrix * > poleRotations
virtual void PlaceComponents(const G4String &name, G4int order)
Place the poles and yoke in the container volume.
virtual void CreateYokeAndContainerSolid(const G4String &name, G4double length, G4int order, G4double magnetContainerLength, G4double magnetContainerRadiusIn)
Create yoke that connects poles and container to put them in.
virtual void CleanUp()
Clean up all memebers used.
Holder struct of all information required to create the outer geometry of a magnet.
An object for both the returned magnet outer body but also a tight fitting container for the whole ma...
static BDSMaterials * Instance()
Singleton pattern access.
G4Material * GetMaterial(G4String material) const
Get material by name.