18#include "BDSAcceleratorComponent.hh"
19#include "BDSBeamPipe.hh"
20#include "BDSBeamPipeFactory.hh"
21#include "BDSBeamPipeInfo.hh"
22#include "BDSColours.hh"
24#include "BDSFieldBuilder.hh"
25#include "BDSFieldInfo.hh"
26#include "BDSGaborLens.hh"
27#include "BDSExtent.hh"
28#include "BDSException.hh"
29#include "BDSMaterials.hh"
30#include "BDSSDType.hh"
33#include "G4ExtrudedSolid.hh"
34#include "G4LogicalVolume.hh"
35#include "G4PVPlacement.hh"
36#include "G4RotationMatrix.hh"
38#include "G4TwoVector.hh"
39#include "G4ThreeVector.hh"
40#include "G4VisAttributes.hh"
47#include "CLHEP/Units/SystemOfUnits.h"
51 G4double horizontalWidthIn,
52 G4double anodeLengthIn,
53 G4Material* anodeMaterialIn,
54 G4double anodeRadiusIn,
55 G4double anodeThicknessIn,
56 G4double electrodeLengthIn,
57 G4Material* electrodeMaterialIn,
58 G4double electrodeRadiusIn,
59 G4double electrodeThicknessIn,
60 G4Material* outerMaterialIn,
65 horizontalWidth(horizontalWidthIn),
66 anodeRadius(anodeRadiusIn),
67 anodeLength(anodeLengthIn),
68 anodeMaterial(anodeMaterialIn),
69 anodeThickness(anodeThicknessIn),
70 electrodeRadius(electrodeRadiusIn),
71 electrodeLength(electrodeLengthIn),
72 electrodeMaterial(electrodeMaterialIn),
73 electrodeThickness(electrodeThicknessIn),
74 outerMaterial(outerMaterialIn),
76 vacuumFieldInfo(vacuumFieldInfoIn)
83 if (chordLength <= endcapsLength)
84 {
throw BDSException(__METHOD_NAME__,
"the element length must be greater than 20 mm for element \"" + name +
"\"");}
86 vacuumLength = chordLength - 2*endcapsLength;
89 if (horizontalWidth <= 0)
90 {
throw BDSException(__METHOD_NAME__,
"option \"horizontalWidth\" is not defined or must be greater than 0 for element \"" + name +
"\"");}
93 {
throw BDSException(__METHOD_NAME__,
"option \"anodeLength\" is not defined or must be greater than 0 for element \"" + name +
"\"");}
96 {
throw BDSException(__METHOD_NAME__,
"option \"anodeRadius\" is not defined or must be greater than 0 for element \"" + name +
"\"");}
98 if (anodeThickness <= 0)
99 {
throw BDSException(__METHOD_NAME__,
"option \"anodeThickness\" is not defined or must be greater than 0 for element \"" + name +
"\"");}
101 if (electrodeLength <= 0)
102 {
throw BDSException(__METHOD_NAME__,
"option \"electrodeLength\" is not defined or must be greater than 0 for element \"" + name +
"\"");}
104 if (electrodeRadius <= 0)
105 {
throw BDSException(__METHOD_NAME__,
"option \"electrodeRadius\" is not defined or must be greater than 0 for element \"" + name +
"\"");}
107 if (electrodeThickness <= 0)
108 {
throw BDSException(__METHOD_NAME__,
"option \"electrodeThickness\" is not defined or must be greater than 0 for element \"" + name +
"\"");}
110 if ((anodeRadius + anodeThickness) > beamPipeInfo->ExtentInner().MinimumAbsTransverse())
111 {
throw BDSException(__METHOD_NAME__,
"\"anodeRadius\" must be smaller than the beam pipe aperture for element \"" + name +
"\"");}
113 if (anodeLength > vacuumLength)
114 {
throw BDSException(__METHOD_NAME__,
"\"anodeLength\" must be shorter than the element length minus 20mm for element \"" + name +
"\"");}
116 if ((electrodeRadius + electrodeThickness) > anodeRadius)
117 {
throw BDSException(__METHOD_NAME__,
"\"anodeRadius\" cannot be smaller than \"electrodeRadius\" + \"electrodeThickness\" for element \"" + name +
"\"");}
119 if (electrodeLength > 0.5*vacuumLength)
120 {
throw BDSException(__METHOD_NAME__,
"\"electrodeLength\" must be smaller than half element length minus 20mm for element \"" + name +
"\"");}
124BDSGaborLens::~BDSGaborLens()
129 containerSolid =
new G4Tubs(
name +
"_container_solid",
134 containerLogicalVolume =
new G4LogicalVolume(containerSolid,
136 name +
"_container_lv");
151 G4double coilOuterRadius = horizontalWidth*0.5 *0.9;
152 G4Tubs* coils =
new G4Tubs(
name +
"_coils_solid",
159 G4LogicalVolume* coilsLV =
new G4LogicalVolume(coils,
163 G4VisAttributes* coilVisAttr =
new G4VisAttributes(*coil);
164 coilVisAttr->SetVisibility(
true);
165 coilsLV->SetVisAttributes(coilVisAttr);
170 G4PVPlacement* coilsPV =
new G4PVPlacement(
nullptr,
171 G4ThreeVector(0,0,0),
174 containerLogicalVolume,
180 G4Tubs* outer =
new G4Tubs(
name +
"_outer_solid",
186 G4LogicalVolume* outerLV =
new G4LogicalVolume(outer,
190 G4VisAttributes* outerVisAttr =
new G4VisAttributes(*outercolour);
191 outerVisAttr->SetVisibility(
true);
192 outerLV->SetVisAttributes(outerVisAttr);
197 G4PVPlacement* outerPV =
new G4PVPlacement(
nullptr,
198 G4ThreeVector(0,0,0),
201 containerLogicalVolume,
207 G4Tubs* endcap =
new G4Tubs(
name +
"_endcap_solid",
214 G4LogicalVolume* endcapLV =
new G4LogicalVolume(endcap,
216 name +
"_endcap_lv");
218 G4VisAttributes* endcapVisAttr =
new G4VisAttributes(*endcapcolour);
219 endcapVisAttr->SetVisibility(
true);
220 endcapLV->SetVisAttributes(endcapVisAttr);
225 G4double endcapZ = (
chordLength-endcapsLength)*0.5;
226 G4PVPlacement* endcapInPV =
new G4PVPlacement(
nullptr,
227 G4ThreeVector(0,0,-endcapZ),
229 name +
"_endcapIn_pv",
230 containerLogicalVolume,
236 G4PVPlacement* endcapOutPV =
new G4PVPlacement(
nullptr,
237 G4ThreeVector(0,0,endcapZ),
239 name +
"_endcapOut_pv",
240 containerLogicalVolume,
255 G4PVPlacement* bpPV =
new G4PVPlacement(
nullptr,
259 containerLogicalVolume,
276 G4Tubs* anode =
new G4Tubs(
name +
"_anode_solid",
278 anodeRadius + anodeThickness,
283 G4LogicalVolume* anodeLV =
new G4LogicalVolume(anode,
287 G4VisAttributes* anodeVisAttr =
new G4VisAttributes(*anodecolour);
288 anodeVisAttr->SetVisibility(
true);
289 anodeLV->SetVisAttributes(anodeVisAttr);
294 G4PVPlacement* anodePV =
new G4PVPlacement(
nullptr,
295 G4ThreeVector(0,0,0),
304 G4Tubs* electrode =
new G4Tubs(
name +
"_electrode_solid",
306 electrodeRadius + electrodeThickness,
311 G4LogicalVolume* electrodeLV =
new G4LogicalVolume(electrode,
313 name +
"_electrode_lv");
315 G4VisAttributes* electrodeVisAttr =
new G4VisAttributes(*electrodecolour);
316 electrodeVisAttr->SetVisibility(
true);
317 electrodeLV->SetVisAttributes(electrodeVisAttr);
323 G4PVPlacement* electrodeInPV =
new G4PVPlacement(
nullptr,
324 G4ThreeVector(0,0,-elecZ),
326 name +
"_electrodeIn_pv",
333 G4PVPlacement* electrodeOutPV =
new G4PVPlacement(
nullptr,
334 G4ThreeVector(0,0,elecZ),
336 name +
"_electrodeOut_pv",
Abstract class that represents a component of an accelerator.
void SetAcceleratorVacuumLogicalVolume(G4LogicalVolume *accVacLVIn)
const G4String name
Const protected member variable that may not be changed by derived classes.
static G4double lengthSafety
Useful variable often used in construction.
static G4bool checkOverlaps
Useful variable often used in construction.
virtual std::set< G4LogicalVolume * > GetAcceleratorVacuumLogicalVolumes() const
Access the 'vacuum' volume(s) in this component if any. Default is empty set.
static G4double lengthSafetyLarge
G4double chordLength
Protected member variable that can be modified by derived classes.
BDSBeamPipeInfo * beamPipeInfo
Optional beam pipe recipe that is written out to the survey if it exists.
The main interface for using the beam pipe factories.
static BDSBeamPipeFactory * Instance()
Singleton accessor.
Holder class for all information required to describe a beam pipe model.
G4Material * vacuumMaterial
Public member for direct access.
G4double IndicativeRadius() const
Return an indicative extent of the beam pipe - typically the maximum of x or y extent.
A holder class for a piece of beam pipe geometry.
G4LogicalVolume * GetVacuumLogicalVolume() const
Access the vacuum volume to set fields and limits.
G4Colour * GetColour(G4double red, G4double green, G4double blue, G4double alpha=1)
Get a cached anonymous colour by values.
static BDSColours * Instance()
singleton pattern
General exception with possible name of object and message.
Holder for +- extents in 3 dimensions.
G4double MaximumAbsTransverse() const
Return the maximum absolute value considering only x,y.
void RegisterFieldForConstruction(const BDSFieldInfo *info, G4LogicalVolume *logicalVolume, const G4bool propagateToDaughters=false, const BDSMagnetStrength *magnetStrengthForScaling=nullptr, const G4String &scalingKey="none")
static BDSFieldBuilder * Instance()
Singleton pattern accessor.
All info required to build complete field of any type.
void BuildOuter()
Build the outer volume.
BDSGaborLens()=delete
total length of both end caps
void BuildBeamPipe()
Build the beam pipe.
virtual void BuildContainerLogicalVolume()
G4LogicalVolume * GetContainerLogicalVolume() const
Accessor - see member for more info.
void InheritExtents(BDSGeometryComponent const *const anotherComponent)
Update the extents of this object with those of another object.
void RegisterDaughter(BDSGeometryComponent *anotherComponent)
void RegisterLogicalVolume(G4LogicalVolume *logicalVolume)
void RegisterPhysicalVolume(G4VPhysicalVolume *physicalVolume)
void RegisterSolid(G4VSolid *solid)
static BDSMaterials * Instance()
Singleton pattern access.
G4Material * GetMaterial(G4String material) const
Get material by name.