19#include "BDSBeamPipeFactoryPoints.hh"
20#include "BDSBeamPipe.hh"
21#include "BDSExtent.hh"
22#include "BDSUtilities.hh"
25#include "G4CutTubs.hh"
26#include "G4ExtrudedSolid.hh"
27#include "G4IntersectionSolid.hh"
28#include "G4SubtractionSolid.hh"
29#include "G4ThreeVector.hh"
30#include "G4TwoVector.hh"
36BDSBeamPipeFactoryPoints::BDSBeamPipeFactoryPoints()
41BDSBeamPipeFactoryPoints::~BDSBeamPipeFactoryPoints()
47 BDSBeamPipeFactoryBase::CleanUp();
69void BDSBeamPipeFactoryPoints::AppendPoint(std::vector<G4TwoVector>& vec,
73 vec.emplace_back(G4TwoVector(x,y));
84 AppendAngleEllipse(vec, startAngle, finishAngle, radius, radius,nPoints, xOffset, yOffset);
96 G4double diff = finishAngle - startAngle;
97 G4double delta = diff / (G4double)nPoints;
98 G4double ang = startAngle;
99 for (G4int i = 0; i < nPoints; i++)
101 G4double xl = xOffset + radiusA*std::sin(ang);
102 G4double yl = yOffset + radiusB*std::cos(ang);
103 AppendPoint(vec, xl, yl);
110 G4bool buildLongForIntersection)
113 G4double zHalfLength = 0.5*length;
114 if (buildLongForIntersection)
115 {zHalfLength *= 1.5;}
117 G4TwoVector zOffsets(0,0);
119 vacuumSolid =
new G4ExtrudedSolid(name +
"_vacuum_solid",
140 beamPipeSolid =
new G4SubtractionSolid(name +
"_pipe_solid",
144 containerSolid =
new G4ExtrudedSolid(name +
"_container_solid",
159 const G4ThreeVector& inputFace,
160 const G4ThreeVector& outputFace)
167 CreateSolids(name +
"_straight", angledVolumeLength,
true);
171 G4double zHalfLengthContainer = length*0.5;
176 G4VSolid* faceSolid =
new G4CutTubs(name +
"_face_solid",
186 G4VSolid* faceSolidContainer =
new G4CutTubs(name +
"_cont_face_solid",
189 zHalfLengthContainer,
195 allSolids.insert(faceSolid);
196 allSolids.insert(faceSolidContainer);
200 G4VSolid* vacuumTemp = vacuumSolid;
201 vacuumSolid =
new G4IntersectionSolid(name +
"_vacuum_solid",
205 G4VSolid* beamPipeTemp = beamPipeSolid;
206 beamPipeSolid =
new G4IntersectionSolid(name +
"_pipe_solid",
210 G4VSolid* containerTemp = containerSolid;
211 containerSolid =
new G4IntersectionSolid(name +
"_container_solid",
225 G4Material* vacuumMaterialIn,
226 G4double beamPipeThicknessIn,
227 G4Material* beamPipeMaterialIn,
228 const G4String& pointsFileIn,
229 const G4String& pointsUnitIn)
238 GeneratePoints(aper1In, aper2In, aper3In, aper4In, beamPipeThicknessIn);
251 const G4ThreeVector& inputFaceNormalIn,
252 const G4ThreeVector& outputFaceNormalIn,
257 G4Material* vacuumMaterialIn,
258 G4double beamPipeThicknessIn,
259 G4Material* beamPipeMaterialIn,
260 const G4String& pointsFileIn,
261 const G4String& pointsUnitIn)
270 GeneratePoints(aper1In, aper2In, aper3In, aper4In, beamPipeThicknessIn);
285 G4Material* vacuumMaterialIn,
286 G4Material* beamPipeMaterialIn,
290 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.