19#include "BDSAcceleratorComponent.hh"
20#include "BDSBeamPipe.hh"
21#include "BDSBeamPipeFactory.hh"
22#include "BDSBeamPipeInfo.hh"
23#include "BDSColours.hh"
25#include "BDSFieldBuilder.hh"
26#include "BDSFieldInfo.hh"
27#include "BDSGaborLens.hh"
28#include "BDSExtent.hh"
29#include "BDSException.hh"
30#include "BDSMaterials.hh"
31#include "BDSSDType.hh"
34#include "G4ExtrudedSolid.hh"
35#include "G4LogicalVolume.hh"
36#include "G4PVPlacement.hh"
37#include "G4RotationMatrix.hh"
39#include "G4TwoVector.hh"
40#include "G4ThreeVector.hh"
41#include "G4VisAttributes.hh"
48#include "CLHEP/Units/SystemOfUnits.h"
52 G4double horizontalWidthIn,
53 G4double anodeLengthIn,
54 G4Material* anodeMaterialIn,
55 G4double anodeRadiusIn,
56 G4double anodeThicknessIn,
57 G4double electrodeLengthIn,
58 G4Material* electrodeMaterialIn,
59 G4double electrodeRadiusIn,
60 G4double electrodeThicknessIn,
61 G4Material* outerMaterialIn,
66 horizontalWidth(horizontalWidthIn),
67 anodeRadius(anodeRadiusIn),
68 anodeLength(anodeLengthIn),
69 anodeMaterial(anodeMaterialIn),
70 anodeThickness(anodeThicknessIn),
71 electrodeRadius(electrodeRadiusIn),
72 electrodeLength(electrodeLengthIn),
73 electrodeMaterial(electrodeMaterialIn),
74 electrodeThickness(electrodeThicknessIn),
75 outerMaterial(outerMaterialIn),
77 vacuumFieldInfo(vacuumFieldInfoIn)
84 if (chordLength <= endcapsLength)
85 {
throw BDSException(__METHOD_NAME__,
"the element length must be greater than 20 mm for element \"" + name +
"\"");}
87 vacuumLength = chordLength - 2*endcapsLength;
90 if (horizontalWidth <= 0)
91 {
throw BDSException(__METHOD_NAME__,
"option \"horizontalWidth\" is not defined or must be greater than 0 for element \"" + name +
"\"");}
94 {
throw BDSException(__METHOD_NAME__,
"option \"anodeLength\" is not defined or must be greater than 0 for element \"" + name +
"\"");}
97 {
throw BDSException(__METHOD_NAME__,
"option \"anodeRadius\" is not defined or must be greater than 0 for element \"" + name +
"\"");}
99 if (anodeThickness <= 0)
100 {
throw BDSException(__METHOD_NAME__,
"option \"anodeThickness\" is not defined or must be greater than 0 for element \"" + name +
"\"");}
102 if (electrodeLength <= 0)
103 {
throw BDSException(__METHOD_NAME__,
"option \"electrodeLength\" is not defined or must be greater than 0 for element \"" + name +
"\"");}
105 if (electrodeRadius <= 0)
106 {
throw BDSException(__METHOD_NAME__,
"option \"electrodeRadius\" is not defined or must be greater than 0 for element \"" + name +
"\"");}
108 if (electrodeThickness <= 0)
109 {
throw BDSException(__METHOD_NAME__,
"option \"electrodeThickness\" is not defined or must be greater than 0 for element \"" + name +
"\"");}
111 if ((anodeRadius + anodeThickness) > beamPipeInfo->ExtentInner().MinimumAbsTransverse())
112 {
throw BDSException(__METHOD_NAME__,
"\"anodeRadius\" must be smaller than the beam pipe aperture for element \"" + name +
"\"");}
114 if (anodeLength > vacuumLength)
115 {
throw BDSException(__METHOD_NAME__,
"\"anodeLength\" must be shorter than the element length minus 20mm for element \"" + name +
"\"");}
117 if ((electrodeRadius + electrodeThickness) > anodeRadius)
118 {
throw BDSException(__METHOD_NAME__,
"\"anodeRadius\" cannot be smaller than \"electrodeRadius\" + \"electrodeThickness\" for element \"" + name +
"\"");}
120 if (electrodeLength > 0.5*vacuumLength)
121 {
throw BDSException(__METHOD_NAME__,
"\"electrodeLength\" must be smaller than half element length minus 20mm for element \"" + name +
"\"");}
125BDSGaborLens::~BDSGaborLens()
130 containerSolid =
new G4Tubs(
name +
"_container_solid",
135 containerLogicalVolume =
new G4LogicalVolume(containerSolid,
137 name +
"_container_lv");
152 G4double coilOuterRadius = horizontalWidth*0.5 *0.9;
153 G4Tubs* coils =
new G4Tubs(
name +
"_coils_solid",
160 G4LogicalVolume* coilsLV =
new G4LogicalVolume(coils,
164 G4VisAttributes* coilVisAttr =
new G4VisAttributes(*coil);
165 coilVisAttr->SetVisibility(
true);
166 coilsLV->SetVisAttributes(coilVisAttr);
171 G4PVPlacement* coilsPV =
new G4PVPlacement(
nullptr,
172 G4ThreeVector(0,0,0),
175 containerLogicalVolume,
181 G4Tubs* outer =
new G4Tubs(
name +
"_outer_solid",
187 G4LogicalVolume* outerLV =
new G4LogicalVolume(outer,
191 G4VisAttributes* outerVisAttr =
new G4VisAttributes(*outercolour);
192 outerVisAttr->SetVisibility(
true);
193 outerLV->SetVisAttributes(outerVisAttr);
198 G4PVPlacement* outerPV =
new G4PVPlacement(
nullptr,
199 G4ThreeVector(0,0,0),
202 containerLogicalVolume,
208 G4Tubs* endcap =
new G4Tubs(
name +
"_endcap_solid",
215 G4LogicalVolume* endcapLV =
new G4LogicalVolume(endcap,
217 name +
"_endcap_lv");
219 G4VisAttributes* endcapVisAttr =
new G4VisAttributes(*endcapcolour);
220 endcapVisAttr->SetVisibility(
true);
221 endcapLV->SetVisAttributes(endcapVisAttr);
226 G4double endcapZ = (
chordLength-endcapsLength)*0.5;
227 G4PVPlacement* endcapInPV =
new G4PVPlacement(
nullptr,
228 G4ThreeVector(0,0,-endcapZ),
230 name +
"_endcapIn_pv",
231 containerLogicalVolume,
237 G4PVPlacement* endcapOutPV =
new G4PVPlacement(
nullptr,
238 G4ThreeVector(0,0,endcapZ),
240 name +
"_endcapOut_pv",
241 containerLogicalVolume,
256 G4PVPlacement* bpPV =
new G4PVPlacement(
nullptr,
260 containerLogicalVolume,
277 G4Tubs* anode =
new G4Tubs(
name +
"_anode_solid",
279 anodeRadius + anodeThickness,
284 G4LogicalVolume* anodeLV =
new G4LogicalVolume(anode,
288 G4VisAttributes* anodeVisAttr =
new G4VisAttributes(*anodecolour);
289 anodeVisAttr->SetVisibility(
true);
290 anodeLV->SetVisAttributes(anodeVisAttr);
295 G4PVPlacement* anodePV =
new G4PVPlacement(
nullptr,
296 G4ThreeVector(0,0,0),
305 G4Tubs* electrode =
new G4Tubs(
name +
"_electrode_solid",
307 electrodeRadius + electrodeThickness,
312 G4LogicalVolume* electrodeLV =
new G4LogicalVolume(electrode,
314 name +
"_electrode_lv");
316 G4VisAttributes* electrodeVisAttr =
new G4VisAttributes(*electrodecolour);
317 electrodeVisAttr->SetVisibility(
true);
318 electrodeLV->SetVisAttributes(electrodeVisAttr);
324 G4PVPlacement* electrodeInPV =
new G4PVPlacement(
nullptr,
325 G4ThreeVector(0,0,-elecZ),
327 name +
"_electrodeIn_pv",
334 G4PVPlacement* electrodeOutPV =
new G4PVPlacement(
nullptr,
335 G4ThreeVector(0,0,elecZ),
337 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.