18#include "BDSBeamPipeFactoryPoints.hh"
19#include "BDSBeamPipe.hh"
20#include "BDSExtent.hh"
21#include "BDSUtilities.hh"
24#include "G4CutTubs.hh"
25#include "G4ExtrudedSolid.hh"
26#include "G4IntersectionSolid.hh"
27#include "G4SubtractionSolid.hh"
28#include "G4ThreeVector.hh"
29#include "G4TwoVector.hh"
35BDSBeamPipeFactoryPoints::BDSBeamPipeFactoryPoints()
40BDSBeamPipeFactoryPoints::~BDSBeamPipeFactoryPoints()
46 BDSBeamPipeFactoryBase::CleanUp();
68void BDSBeamPipeFactoryPoints::AppendPoint(std::vector<G4TwoVector>& vec,
72 vec.emplace_back(G4TwoVector(x,y));
83 AppendAngleEllipse(vec, startAngle, finishAngle, radius, radius,nPoints, xOffset, yOffset);
95 G4double diff = finishAngle - startAngle;
96 G4double delta = diff / (G4double)nPoints;
97 G4double ang = startAngle;
98 for (G4int i = 0; i < nPoints; i++)
100 G4double xl = xOffset + radiusA*std::sin(ang);
101 G4double yl = yOffset + radiusB*std::cos(ang);
102 AppendPoint(vec, xl, yl);
109 G4bool buildLongForIntersection)
112 G4double zHalfLength = 0.5*length;
113 if (buildLongForIntersection)
114 {zHalfLength *= 1.5;}
116 G4TwoVector zOffsets(0,0);
118 vacuumSolid =
new G4ExtrudedSolid(name +
"_vacuum_solid",
139 beamPipeSolid =
new G4SubtractionSolid(name +
"_pipe_solid",
143 containerSolid =
new G4ExtrudedSolid(name +
"_container_solid",
158 const G4ThreeVector& inputFace,
159 const G4ThreeVector& outputFace)
166 CreateSolids(name +
"_straight", angledVolumeLength,
true);
170 G4double zHalfLengthContainer = length*0.5;
175 G4VSolid* faceSolid =
new G4CutTubs(name +
"_face_solid",
185 G4VSolid* faceSolidContainer =
new G4CutTubs(name +
"_cont_face_solid",
188 zHalfLengthContainer,
194 allSolids.insert(faceSolid);
195 allSolids.insert(faceSolidContainer);
199 G4VSolid* vacuumTemp = vacuumSolid;
200 vacuumSolid =
new G4IntersectionSolid(name +
"_vacuum_solid",
204 G4VSolid* beamPipeTemp = beamPipeSolid;
205 beamPipeSolid =
new G4IntersectionSolid(name +
"_pipe_solid",
209 G4VSolid* containerTemp = containerSolid;
210 containerSolid =
new G4IntersectionSolid(name +
"_container_solid",
224 G4Material* vacuumMaterialIn,
225 G4double beamPipeThicknessIn,
226 G4Material* beamPipeMaterialIn,
227 const G4String& pointsFileIn,
228 const G4String& pointsUnitIn)
237 GeneratePoints(aper1In, aper2In, aper3In, aper4In, beamPipeThicknessIn);
250 const G4ThreeVector& inputFaceNormalIn,
251 const G4ThreeVector& outputFaceNormalIn,
256 G4Material* vacuumMaterialIn,
257 G4double beamPipeThicknessIn,
258 G4Material* beamPipeMaterialIn,
259 const G4String& pointsFileIn,
260 const G4String& pointsUnitIn)
269 GeneratePoints(aper1In, aper2In, aper3In, aper4In, beamPipeThicknessIn);
284 G4Material* vacuumMaterialIn,
285 G4Material* beamPipeMaterialIn,
289 beamPipeMaterialIn, lengthIn);
G4ThreeVector outputFaceNormal
For recording the face normals in the finished pipe component.
G4ThreeVector inputFaceNormal
For recording the face normals in the finished pipe component.
void CommonConstruction(const G4String &nameIn, G4Material *vacuumMaterialIn, G4Material *beamPipeMaterialIn, G4double length)
finalise beampipe construction
BDSBeamPipe * BuildBeamPipeAndRegisterVolumes(BDSExtent extent, G4double containerRadius, G4bool containerIsCircular=false)
build beampipe and register logical volumes
static void CheckAngledVolumeCanBeBuilt(G4double length, const G4ThreeVector &inputfaceAngle, const G4ThreeVector &outputfaceAngle, G4double horizontalWidth, const G4String &name)
check if a beam pipe volume with angled faces can be constructed
G4VSolid * containerSubtractionSolid
Longer (in length) version of container solid for unambiguous subtraction.
G4VSolid * beamPipeInnerSolid
Solid for inner surface of beam pipe.
std::vector< G4TwoVector > containerSubtractionEdge
Vector of x,y coordinates for the container subtraction volume.
std::vector< G4TwoVector > beamPipeInnerEdge
Vector of x,y coordinates for beam pipe inner edge.
virtual void CleanUp()
Clear member vectors and run base class clean up to clear pointers between runs.
G4VSolid * beamPipeOuterSolid
Solid for outer surface of beam pipe.
virtual void GeneratePoints(G4double aper1, G4double aper2, G4double aper3, G4double aper4, G4double beamPipeThickness, G4int pointsPerTwoPi=40)=0
G4double extentY
Extents prepared by GeneratePoints function as only it knows the extents.
virtual G4double CalculateIntersectionRadius(G4double aper1, G4double aper2, G4double aper3, G4double aper4, G4double beamPipeThickness)=0
void CleanUpPoints()
Actual clean up here for this class only.
virtual BDSBeamPipe * CommonFinalConstruction(const G4String &nameIn, G4Material *vacuumMaterialIn, G4Material *beamPipeMaterialIn, G4double lengthIn)
G4double extentX
Extents prepared by GeneratePoints function as only it knows the extents.
std::vector< G4TwoVector > vacuumEdge
Vector of x,y coordinates for vacuum extruded solid edge.
virtual BDSBeamPipe * CreateBeamPipe(const G4String &nameIn, G4double lengthIn, G4double aper1In, G4double aper2In, G4double aper3In, G4double aper4In, G4Material *vacuumMaterialIn, G4double beamPipeThicknessIn, G4Material *beamPipeMaterialIn, const G4String &pointsFileIn="", const G4String &pointsUnitIn="")
Required overloaded method from BDSBeamPipeFactoryBase to build straight piece of beam pipe.
void CreateSolidsAngled(const G4String &name, G4double length, const G4ThreeVector &inputFace, const G4ThreeVector &outputFace)
Create angled solids. Uses CreateSolids() method.
void AppendAngle(std::vector< G4TwoVector > &vec, G4double startAngle, G4double finishAngle, G4double radius, G4int nPoints=10, G4double xOffset=0, G4double yOffset=0)
void CreateSolids(const G4String &name, G4double length, G4bool buildLongForIntersection=false)
G4String pointsFile
Temporary copy of input variables.
G4double intersectionRadius
std::vector< G4TwoVector > containerEdge
Vector of x,y coordinates for the container volume.
std::vector< G4TwoVector > beamPipeOuterEdge
Vector of x,y coordinates for beam pipe outer edge.
G4String pointsUnit
Temporary copy of input variables.
void AppendAngleEllipse(std::vector< G4TwoVector > &vec, G4double startAngle, G4double finishAngle, G4double radiusA, G4double radiusB, G4int nPoints=10, G4double xOffset=0, G4double yOffset=0)
Generate 2-vector points (and append them) about an ellipse.
A holder class for a piece of beam pipe geometry.
Holder for +- extents in 3 dimensions.
G4double lengthSafety
Cache of global constants variable.
G4double CalculateSafeAngledVolumeLength(G4double angleIn, G4double angleOut, G4double length, G4double containerWidth, G4double containerHeight=0)
Calculate safe length of an angled volume so it fills the length of its container.