19#include "BDSBeamPipe.hh"
20#include "BDSBeamPipeFactory.hh"
21#include "BDSBeamPipeInfo.hh"
22#include "BDSBeamPipeType.hh"
23#include "BDSFieldBuilder.hh"
24#include "BDSFieldInfo.hh"
25#include "BDSIntegratorType.hh"
26#include "BDSMagnetGeometryType.hh"
27#include "BDSMagnetOuter.hh"
28#include "BDSMagnetOuterInfo.hh"
29#include "BDSMagnetOuterFactory.hh"
30#include "BDSMagnetOuterFactoryLHC.hh"
31#include "BDSMagnetStrength.hh"
32#include "BDSMagnetType.hh"
33#include "BDSMagnet.hh"
34#include "BDSUtilities.hh"
37#include "G4LogicalVolume.hh"
38#include "G4Material.hh"
39#include "G4PVPlacement.hh"
41#include "G4ThreeVector.hh"
42#include "G4Transform3D.hh"
44#include "G4VPhysicalVolume.hh"
46#include "CLHEP/Units/SystemOfUnits.h"
51 const G4String& nameIn,
61 magnetOuterInfo(magnetOuterInfoIn),
62 vacuumFieldInfo(vacuumFieldInfoIn),
63 outerFieldInfo(outerFieldInfoIn),
66 magnetOuterOffset(G4ThreeVector(0,0,0)),
68 beamPipePlacementTransform(G4Transform3D()),
81 if (lengthIn < 1e-4*CLHEP::m)
84 if (lengthIn < 1e-6*CLHEP::m)
93 G4String result =
"none";
96 case BDSMagnetType::hkicker:
97 case BDSMagnetType::vkicker:
98 case BDSMagnetType::muonspoiler:
99 case BDSMagnetType::sectorbend:
100 case BDSMagnetType::rectangularbend:
101 {result =
"field";
break;}
102 case BDSMagnetType::quadrupole:
103 {result =
"k1";
break;}
104 case BDSMagnetType::sextupole:
105 {result =
"k2";
break;}
106 case BDSMagnetType::octupole:
107 {result =
"k3";
break;}
108 case BDSMagnetType::decapole:
109 {result =
"k4";
break;}
248 containerLogicalVolume,
256 if (mgt == BDSMagnetGeometryType::lhcleft || mgt == BDSMagnetGeometryType::lhcright)
259 std::vector<BDSGeometryComponent*> daughters(daughtersSet.begin(), daughtersSet.end());
263 G4double sign = mgt == BDSMagnetGeometryType::lhcleft ? 1.0 : -1.0;
268 secondBPField->SetIntegratorType(BDSIntegratorType::g4classicalrk4);
283 containerLogicalVolume =
new G4LogicalVolume(containerSolid,
285 name +
"_container_lv");
288 containerLogicalVolume->SetUserLimits(
userLimits);
309 G4PVPlacement* beamPipePV =
new G4PVPlacement(
nullptr,
312 name +
"_beampipe_pv",
313 containerLogicalVolume,
327 G4PVPlacement* magnetOuterPV =
new G4PVPlacement(
nullptr,
331 containerLogicalVolume,
346void BDSMagnet::SetVacuumField(
BDSFieldInfo* vacuumFieldInfoIn)
352BDSMagnet::~BDSMagnet()
Abstract class that represents a component of an accelerator.
G4UserLimits * userLimits
Cache of user limits.
virtual G4String Material() const
Return the name of a material associated with the component - ie the primary material.
void SetAcceleratorVacuumLogicalVolume(G4LogicalVolume *accVacLVIn)
const G4String name
Const protected member variable that may not be changed by derived classes.
static G4Material * emptyMaterial
Useful variable often used in construction.
static G4double lengthSafety
Useful variable often used in construction.
static G4bool checkOverlaps
Useful variable often used in construction.
G4double angle
Protected member variable that can be modified by derived classes.
BDSBeamPipeInfo * GetBeamPipeInfo() const
virtual void BuildUserLimits()
G4double chordLength
Protected member variable that can be modified by derived classes.
static G4VisAttributes * containerVisAttr
Useful variable often used in construction.
BDSBeamPipeInfo * beamPipeInfo
Optional beam pipe recipe that is written out to the survey if it exists.
virtual void SetFieldUsePlacementWorldTransform()
static BDSBeamPipeFactory * Instance()
Singleton accessor.
Holder class for all information required to describe a beam pipe model.
BDSBeamPipeType beamPipeType
Public member for direct access.
G4LogicalVolume * GetVacuumLogicalVolume() const
Access the vacuum volume to set fields and limits.
G4ThreeVector InputFaceNormal() const
Accessor.
G4ThreeVector OutputFaceNormal() const
Accessor.
std::set< G4LogicalVolume * > GetVolumesForField() const
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 SetTransform(const G4Transform3D &transformIn)
Set the field definition transform.
G4Transform3D Transform() const
Transform for the field definition only.
void Translate(const G4ThreeVector &translationIn)
BDSMagnetStrength * MagnetStrength() const
Accessor.
A generic geometry component for a bdsim model.
virtual std::set< BDSGeometryComponent * > GetAllDaughters() const
Accessor - see member for more info.
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.
G4Transform3D GetPlacementTransform() const
Accessor - see member for more info.
void SetPlacementOffset(const G4ThreeVector &offsetIn)
Set the offset from 0,0,0 that the object should ideally be placed in its parent.
void RegisterDaughter(BDSGeometryComponent *anotherComponent)
void RegisterPhysicalVolume(G4VPhysicalVolume *physicalVolume)
G4VSolid * GetContainerSolid() const
Accessor - see member for more info.
G4ThreeVector GetPlacementOffset() const
Accessor - see member for more info.
static const G4double beamSeparation
Used in many places - make it a constant in the code and put here as most relevant.
static BDSMagnetOuterFactory * Instance()
Singleton accessor.
BDSMagnetOuter * CreateMagnetOuter(BDSMagnetType magnetType, BDSMagnetOuterInfo *outerInfo, G4double outerLength, G4double chordLength, BDSBeamPipe *beampipe)
Holder struct of all information required to create the outer geometry of a magnet.
BDSGeometryComponent * GetMagnetContainer() const
void ClearMagnetContainer()
Clear the memory of the now unneeded magnet container object.
void SetInputFaceNormal(const G4ThreeVector &input)
Setter for face normals.
G4ThreeVector InputFaceNormal() const
Accessor.
BDSSimpleComponent * EndPieceAfter() const
Access the end piece.
G4ThreeVector OutputFaceNormal() const
Accessor.
void SetOutputFaceNormal(const G4ThreeVector &output)
Setter for face normals.
BDSSimpleComponent * EndPieceBefore() const
Access the end piece.
Efficient storage of magnet strengths.
virtual void SetOutputFaceNormal(const G4ThreeVector &output)
Update face normal and also to beam pipe and magnet outer.
G4Transform3D beamPipePlacementTransform
BDSFieldInfo * vacuumFieldInfo
Field information for vacuum field.
G4bool isThin
Boolean to store if the element is thin - will have no geometry constructed.
G4double horizontalWidth
For outer volume construction.
BDSMagnetType magnetType
Magnet type.
BDSMagnetOuterInfo * magnetOuterInfo
Model information for the outer volume construction.
virtual void SetFieldUsePlacementWorldTransform()
Override function as we have different field recipe objects.
BDSBeamPipe * beampipe
The constructed beampipe.
virtual void BuildBeampipe()
virtual void BuildVacuumField()
Construct the field for the vacuum and attach it.
virtual void BuildContainerLogicalVolume()
BDSFieldInfo * outerFieldInfo
Field information for outer magnetic field (optional)
BDSMagnet()=delete
Private default constructor to force the use of the supplied one.
BDSMagnetOuter * outer
The assembled outer magnet geometry.
virtual G4String Material() const
Accessor to outer material if it exists.
virtual void BuildOuter()
static G4String DetermineScalingKey(BDSMagnetType typeIn)
void SetOuterField(BDSFieldInfo *outerFieldInfoIn)
@ { Delete existing field info and replace.
virtual void SetInputFaceNormal(const G4ThreeVector &input)
Update face normal and also to beam pipe and magnet outer.
virtual void BuildOuterField()
Construct the magnetic field for the outer magnet geometry.
virtual void PlaceComponents()
type underlying() const
return underlying value (can be used in switch statement)
G4ThreeVector RotateToReferenceFrame(G4ThreeVector faceNormal, G4double fullAngle)
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())