18#include "BDSBeamPipeFactoryBase.hh"
19#include "BDSBeamPipeFactoryElliptical.hh"
20#include "BDSBeamPipeFactoryRectEllipse.hh"
21#include "BDSBeamPipe.hh"
23#include "BDSException.hh"
24#include "BDSExtent.hh"
25#include "BDSUtilities.hh"
29#include "G4CutTubs.hh"
30#include "G4EllipticalTube.hh"
31#include "G4IntersectionSolid.hh"
32#include "G4LogicalVolume.hh"
33#include "G4SubtractionSolid.hh"
34#include "G4ThreeVector.hh"
37#include "CLHEP/Units/SystemOfUnits.h"
44BDSBeamPipeFactoryRectEllipse::BDSBeamPipeFactoryRectEllipse()
53 G4Material* vacuumMaterialIn,
54 G4double beamPipeThicknessIn,
55 G4Material* beamPipeMaterialIn,
65 if (((aper1In == aper3In) && (aper2In == aper4In)) ||
66 ( (aper3In < aper1In) && (aper4In < aper2In) ) )
70 vacuumMaterialIn, beamPipeThicknessIn, beamPipeMaterialIn);
77 G4VSolid* vacCylSolid =
new G4EllipticalTube(nameIn +
"_vacuum_ellipsoid",
82 G4VSolid* vacRectSolid =
new G4Box(nameIn +
"_vacuum_box",
86 allSolids.insert(vacCylSolid);
87 allSolids.insert(vacRectSolid);
89 vacuumSolid =
new G4IntersectionSolid(nameIn +
"_vacuum_solid",
95 G4VSolid* bpInnerCylSolid =
new G4EllipticalTube(nameIn +
"_pipe_inner_ellipsoid",
100 G4VSolid* bpInnerRectSolid =
new G4Box(nameIn +
"_pipe_inner_box",
105 G4VSolid* bpInnerSolid =
new G4IntersectionSolid(nameIn +
"_pipe_inner_solid",
111 G4VSolid* bpOuterCylSolid =
new G4EllipticalTube(nameIn +
"_pipe_inner_ellipsoid",
112 aper3In + extraWidth,
113 aper4In + extraWidth,
116 G4VSolid* bpOuterRectSolid =
new G4Box(nameIn +
"_pipe_inner_box",
117 aper1In + extraWidth,
118 aper2In + extraWidth,
120 G4VSolid* bpOuterSolid =
new G4IntersectionSolid(nameIn +
"_pipe_inner_solid",
124 allSolids.insert(bpInnerCylSolid);
125 allSolids.insert(bpInnerRectSolid);
126 allSolids.insert(bpInnerSolid);
127 allSolids.insert(bpOuterCylSolid);
128 allSolids.insert(bpOuterRectSolid);
129 allSolids.insert(bpOuterSolid);
132 beamPipeSolid =
new G4SubtractionSolid(nameIn +
"_pipe_solid",
137 G4VSolid* contCylSolid =
new G4EllipticalTube(nameIn +
"_vacuum_ellipsoid",
142 G4VSolid* contRectSolid =
new G4Box(nameIn +
"_vacuum_box",
147 allSolids.insert(contCylSolid);
148 allSolids.insert(contRectSolid);
151 containerSolid =
new G4IntersectionSolid(nameIn +
"_vacuum_solid",
158 CreateContainerSubtractionSolid(nameIn, lengthIn, beamPipeThicknessIn, aper1In, aper2In, aper3In, aper4In);
165 const G4ThreeVector& inputFaceNormalIn,
166 const G4ThreeVector& outputFaceNormalIn,
171 G4Material* vacuumMaterialIn,
172 G4double beamPipeThicknessIn,
173 G4Material* beamPipeMaterialIn,
183 if (((aper1In == aper3In) && (aper2In == aper4In)) ||
184 ( (aper3In < aper1In) && (aper4In < aper2In) ) )
188 aper1In, aper2In, aper3In, aper4In,
189 vacuumMaterialIn, beamPipeThicknessIn, beamPipeMaterialIn);
197 G4double width = std::max(aper1In,aper3In) + beamPipeThicknessIn +
lengthSafetyLarge;
198 G4double height = std::max(aper2In,aper4In) + beamPipeThicknessIn +
lengthSafetyLarge;
202 CreateContainerSubtractionSolid(nameIn, lengthIn, beamPipeThicknessIn, aper1In,
203 aper2In, aper3In, aper4In);
206 lengthIn, width, height);
210 G4Material* vacuumMaterialIn,
211 G4Material* beamPipeMaterialIn,
213 G4double containerWidthIn,
214 G4double containerHeightIn)
217 beamPipeMaterialIn, lengthIn);
234 G4double beamPipeThicknessIn,
235 const G4ThreeVector& inputfaceIn,
236 const G4ThreeVector& outputfaceIn)
246 G4VSolid* vacCylSolid =
new G4EllipticalTube(nameIn +
"_vacuum_ellipsoid",
251 G4VSolid* vacRectSolid =
new G4Box(nameIn +
"_vacuum_box",
254 1.1*angledVolumeLength);
257 G4VSolid* longVacuumSolid =
new G4IntersectionSolid(nameIn +
"_vacuum_long_solid",
262 G4double angledFaceRadius = (std::max(std::max(aper1In,aper2In),std::max(aper3In,aper4In)) + beamPipeThicknessIn) * 1.1;
267 G4VSolid* vacuumAngledSolid =
new G4CutTubs(nameIn +
"_pipe_angled_faces",
276 allSolids.insert(vacCylSolid);
277 allSolids.insert(vacRectSolid);
278 allSolids.insert(longVacuumSolid);
279 allSolids.insert(vacuumAngledSolid);
281 vacuumSolid =
new G4IntersectionSolid(nameIn +
"_vacuum_solid",
289 G4String message =
"beam pipe thickness in element \"" + nameIn
290 +
"\" is thinner than minimum " + std::to_string(
lengthSafetyLarge / CLHEP::mm) +
"mm.";
293 G4VSolid* bpInnerCylSolid =
new G4EllipticalTube(nameIn +
"_pipe_inner_ellipsoid",
298 G4VSolid* bpInnerRectSolid =
new G4Box(nameIn +
"_pipe_inner_box",
301 1.1*angledVolumeLength);
303 G4VSolid* bpInnerSolid =
new G4IntersectionSolid(nameIn +
"_pipe_inner_solid",
310 G4VSolid* bpOuterCylSolid =
new G4EllipticalTube(nameIn +
"_pipe_inner_ellipsoid",
311 aper3In + extraWidth,
312 aper4In + extraWidth,
315 G4VSolid* bpOuterRectSolid =
new G4Box(nameIn +
"_pipe_inner_box",
316 aper1In + extraWidth,
317 aper2In + extraWidth,
318 1.1*angledVolumeLength);
319 G4VSolid* bpOuterSolid =
new G4IntersectionSolid(nameIn +
"_pipe_inner_solid",
323 G4VSolid* longBeamPipeSolid =
new G4SubtractionSolid(nameIn +
"_long_pipe_solid",
327 allSolids.insert(bpInnerCylSolid);
328 allSolids.insert(bpInnerRectSolid);
329 allSolids.insert(bpInnerSolid);
330 allSolids.insert(bpOuterCylSolid);
331 allSolids.insert(bpOuterRectSolid);
332 allSolids.insert(bpOuterSolid);
335 beamPipeSolid =
new G4IntersectionSolid(nameIn +
"_pipe_solid",
341 G4VSolid* contCylSolid =
new G4EllipticalTube(nameIn +
"_vacuum_ellipsoid",
348 G4VSolid* contRectSolid =
new G4Box(nameIn +
"_vacuum_box",
351 1.1*angledVolumeLength);
353 G4VSolid* longContainerSolid =
new G4IntersectionSolid(nameIn +
"_long_container_solid",
357 allSolids.insert(contCylSolid);
358 allSolids.insert(contRectSolid);
359 allSolids.insert(longContainerSolid);
361 containerSolid =
new G4IntersectionSolid(nameIn +
"_container_solid",
366void BDSBeamPipeFactoryRectEllipse::CreateContainerSubtractionSolid(
const G4String& nameIn,
368 G4double& beamPipeThicknessIn,
375 G4VSolid* contSubCylSolid =
new G4EllipticalTube(nameIn +
"_subtraction_ellipsoid",
380 G4VSolid* contSubRectSolid =
new G4Box(nameIn +
"_subtraction_box",
384 allSolids.insert(contSubCylSolid);
385 allSolids.insert(contSubRectSolid);
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.
Factory for elliptical beam pipes.
virtual BDSBeamPipe * CreateBeamPipe(const G4String &nameIn, G4double lengthIn, G4double aper1=0, G4double aper2=0, G4double aper3=0, G4double aper4=0, G4Material *vacuumMaterialIn=nullptr, G4double beamPipeThicknessIn=0, G4Material *beamPipeMaterialIn=nullptr, const G4String &pointsFileIn="", const G4String &pointsUnitIn="")
create a flat ended beampipe
BDSBeamPipe * CommonFinalConstruction(const G4String &nameIn, G4Material *vacuumMaterialIn, G4Material *beamPipeMaterialIn, G4double lengthIn, G4double widthIn, G4double heightIn)
virtual BDSBeamPipe * CreateBeamPipe(const G4String &nameIn, G4double lengthIn, G4double aper1=0, G4double aper2=0, G4double aper3=0, G4double aper4=0, G4Material *vacuumMaterialIn=nullptr, G4double beamPipeThicknessIn=0, G4Material *beamPipeMaterialIn=nullptr, const G4String &pointsFileIn="", const G4String &pointsUnitIn="")
create a flat ended beampipe
void CreateGeneralAngledSolids(const G4String &nameIn, G4double lengthIn, G4double aper1In, G4double aper2In, G4double aper3In, G4double aper4In, G4double beamPipeThicknessIn, const G4ThreeVector &inputfaceIn, const G4ThreeVector &outputfaceIn)
A holder class for a piece of beam pipe geometry.
General exception with possible name of object and message.
Holder for +- extents in 3 dimensions.
G4double lengthSafety
Cache of global constants variable.
G4double lengthSafetyLarge
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.