19#include "BDSExtent.hh"
20#include "BDSGlobalConstants.hh"
21#include "BDSMagnetOuter.hh"
22#include "BDSMagnetOuterFactoryPolesSquare.hh"
23#include "BDSMaterials.hh"
24#include "BDSSDType.hh"
29#include "G4IntersectionSolid.hh"
30#include "G4LogicalVolume.hh"
31#include "G4Material.hh"
32#include "G4PVPlacement.hh"
33#include "G4SubtractionSolid.hh"
35#include "G4VisAttributes.hh"
42BDSMagnetOuterFactoryPolesSquare::BDSMagnetOuterFactoryPolesSquare():
65 G4double magnetContainerLength,
66 G4double magnetContainerRadiusIn)
69 G4VSolid* yokeOuter =
new G4Box(name +
"_yoke_outer_solid",
74 G4VSolid* yokeInner =
new G4Box(name +
"_yoke_inner_solid",
79 allSolids.insert(yokeOuter);
80 allSolids.insert(yokeInner);
82 yokeSolid =
new G4SubtractionSolid(name +
"_yoke_solid",
89 G4VSolid* containerOuter =
new G4Box(name +
"_container_outer_solid",
94 G4VSolid* containerInner =
new G4Tubs(name +
"_container_inner_solid",
101 allSolids.insert(containerOuter);
102 allSolids.insert(containerInner);
113 containerSolid =
new G4SubtractionSolid(name +
"_outer_container_solid",
117 magnetContainerSolid =
new G4Box(name +
"_container_solid",
118 magnetContainerRadiusIn,
119 magnetContainerRadiusIn,
120 magnetContainerLength*0.5);
122 magContExtent =
BDSExtent(magnetContainerRadiusIn, magnetContainerRadiusIn, magnetContainerLength*0.5);
131 G4int nPoles = 2*orderIn;
134 for (G4int i = 0; i < nPoles; ++i)
136 G4RotationMatrix* iPoleRM =
new G4RotationMatrix();
137 G4double rotationAngle = (0.5-i)*
segmentAngle + CLHEP::pi*0.5;
138 iPoleRM->rotateZ(rotationAngle);
139 allRotationMatrices.insert(iPoleRM);
141 G4IntersectionSolid* aSolid =
new G4IntersectionSolid(name +
"_pole_solid",
147 poleSolids.push_back(aSolid);
153 G4Material* outerMaterial)
155 G4VisAttributes* outerVisAttr =
new G4VisAttributes(*colour);
156 outerVisAttr->SetVisibility(
true);
158 allVisAttributes.insert(outerVisAttr);
160 for (G4int n = 0; n < 2*
order; ++n)
162 G4LogicalVolume* thisPole =
new G4LogicalVolume(poleSolids[n],
165 thisPole->SetVisAttributes(outerVisAttr);
166 poleLVs.push_back(thisPole);
167 allLogicalVolumes.insert(thisPole);
174 yokeLV->SetVisAttributes(outerVisAttr);
178 containerLV =
new G4LogicalVolume(containerSolid,
180 name +
"_container_lv");
183 magnetContainerLV =
new G4LogicalVolume(magnetContainerSolid,
185 name +
"_container_lv");
192 for (
auto& lv : poleLVs)
194 for (
auto& lv : allLogicalVolumes)
207 yokePV =
new G4PVPlacement(
nullptr,
219 G4double nPoles = 2*orderIn;
221 G4PVPlacement* aPlacement =
nullptr;
222 for (G4int n = 0; n < 2*orderIn; ++n)
224 G4RotationMatrix* rm =
new G4RotationMatrix();
225 G4double rotationAngle = (0.5-n)*
segmentAngle + CLHEP::pi*0.5;
226 rm->rotateZ(-rotationAngle);
227 allRotationMatrices.insert(rm);
228 G4String pvName = name +
"_pole_" + std::to_string(n) +
"_pv";
230 aPlacement =
new G4PVPlacement(rm,
238 allPhysicalVolumes.insert(aPlacement);
246 G4double magnetContainerRadiusIn,
250 orderIn, magnetContainerRadiusIn, recipe);
252 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.