19#ifndef BDSCOMPONENTFACTORY_H
20#define BDSCOMPONENTFACTORY_H
22#include "BDSFieldType.hh"
23#include "BDSMagnetGeometryType.hh"
24#include "BDSMagnetStrength.hh"
25#include "BDSMagnetType.hh"
26#include "BDSIntegratorType.hh"
27#include "BDSIntegratorSetType.hh"
30#include "G4ThreeVector.hh"
31#include "G4Transform3D.hh"
33#include "CLHEP/Units/PhysicalConstants.h"
81 G4bool usualPrintOut =
true);
92 G4double currentArcLengthIn = 0);
101 const G4double teleporterWidth,
102 const G4Transform3D& transformIn);
117 const G4ThreeVector& inputFaceNormal = G4ThreeVector(0,0,-1),
118 const G4ThreeVector& outputFaceNormal = G4ThreeVector(0,0,1));
133 G4double defaultHorizontalWidth = -1);
143 const G4Transform3D& fieldTransform,
146 G4double outerFieldScaling = 1.0,
156 G4double defaultHorizontalWidth = -1,
157 G4double defaultVHRatio = 1.0,
158 G4double defaultCoilWidthFraction = -1,
159 G4double defaultCoilHeightFraction = -1);
170 const G4double angleIn,
171 const G4double angleOut,
173 const G4bool yokeOnLeft =
false,
174 G4double defaultHorizontalWidth = -1,
175 G4double defaultVHRatio = -1,
176 G4double defaultCoilWidthFraction = -1,
177 G4double defaultCoilHeightFraction = -1);
184 const G4String& defaultMaterialName);
193 G4double horizontalWidth,
194 const G4String& name =
"not given");
198 G4double maxAngle = 0.5*CLHEP::halfpi);
203 G4double cavityLength);
271 const G4String& name);
274 const G4String& name,
277 G4double beamPipeRadius = 0,
286 const G4String& name,
300 G4double angle = 0.0,
301 const G4String& nameSuffix =
"")
const;
305 G4bool printWarning =
true);
326 G4double frequency)
const;
331 G4double frequency)
const;
337 G4double cavityLength,
373 const G4double arcLength)
const;
378 const G4double arcLength)
const;
384 G4double& field)
const;
392 G4double& chordLength,
394 G4double& angle)
const;
415 G4double elementArcLength)
const;
Abstract class that represents a component of an accelerator.
Holder class for all information required to describe a beam pipe model.
Holder for all Geometrical information required to create an RF cavity.
Factory for user specified accelerator components.
Factory to produce all types of BDSAcceleratorComponents.
static G4bool YokeOnLeft(const GMAD::Element *el, const BDSMagnetStrength *st)
std::map< G4String, BDSCrystalInfo * > crystalInfos
Maps of crystal info instances by name.
G4double OutgoingFaceAngle(const GMAD::Element *el) const
G4double AngleFromField(const G4double field, const G4double arcLength) const
void INDEVELOPMENTERROR() const
TBC - remove when modulators are implemented fully.
BDSComponentFactoryUser * userComponentFactory
User component factory if any.
KickerType
Private enum for kicker types.
G4double FieldFromAngle(const G4double angle, const G4double arcLength) const
static G4double PrepareHorizontalWidth(GMAD::Element const *el, G4double defaultHorizontalWidth=-1)
Prepare the element horizontal width in Geant4 units - if not set, use the global default.
BDSComponentFactory()=delete
No default constructor.
BDSAcceleratorComponent * CreateTeleporter(const G4double teleporterLength, const G4double teleporterWidth, const G4Transform3D &transformIn)
BDSModulatorInfo * defaultModulator
Default modulator for all components.
G4Material * PrepareVacuumMaterial(GMAD::Element const *el) const
Prepare the vacuum material from the element or resort to default in options.
void CalculateAngleAndFieldRBend(const GMAD::Element *el, G4double &arcLength, G4double &chordLength, G4double &field, G4double &angle) const
static G4Transform3D CreateFieldTransform(const BDSTiltOffset *tiltOffset)
Create a transform from a tilt offset. If nullptr, returns identity transform.
BDSMagnet * CreateMagnet(const GMAD::Element *el, BDSMagnetStrength *st, BDSFieldType fieldType, BDSMagnetType magnetType, G4double angle=0.0, const G4String &nameSuffix="") const
Helper method for common magnet construction.
BDSMagnetStrength * PrepareMagnetStrengthForMultipoles(GMAD::Element const *el) const
Prepare magnet strength for multipoles.
GMAD::Element const * element
element for storing instead of passing around
static void PoleFaceRotationsNotTooLarge(const GMAD::Element *el, G4double maxAngle=0.5 *CLHEP::halfpi)
Check whether the pole face rotation angles are too big for practical construction.
G4double thinElementLength
Length of a thin element.
BDSCavityInfo * PrepareCavityModelInfoForElement(GMAD::Element const *el, G4double frequency) const
GMAD::Element const * nextElement
element access to previous element (can be nullptr)
BDSCavityInfo * PrepareCavityModelInfo(GMAD::Element const *el, G4double frequency) const
const BDSIntegratorSetType integratorSetType
Local copy of enum of the integrator set, i.e. which one it is specifically.
G4bool yokeFields
Cache of whether to include yoke magnetic fields.
static G4bool coloursInitialised
static BDSFieldInfo * PrepareMagnetOuterFieldInfo(const BDSMagnetStrength *vacuumSt, const BDSFieldType &fieldType, const BDSBeamPipeInfo *bpInfo, const BDSMagnetOuterInfo *outerInfo, const G4Transform3D &fieldTransform, const BDSIntegratorSet *integratorSetIn, G4double brhoIn, G4double outerFieldScaling=1.0, BDSModulatorInfo *modulatorInfo=nullptr)
Prepare the field definition for the yoke of a magnet.
G4double beta0
Cache of relativistic beta for primary particle.
void PrepareColours()
Prepare all colours defined in the parser.
static BDSMagnetOuterInfo * PrepareMagnetOuterInfo(const G4String &elementNameIn, const GMAD::Element *el, const BDSMagnetStrength *st, const BDSBeamPipeInfo *beamPipe, G4double defaultHorizontalWidth=-1, G4double defaultVHRatio=1.0, G4double defaultCoilWidthFraction=-1, G4double defaultCoilHeightFraction=-1)
BDSAcceleratorComponent * CreateTerminator(G4double witdth)
static G4Colour * PrepareColour(GMAD::Element const *element)
Checks if colour is specified for element, else uses the default for that element type.
BDSMagnetStrength * PrepareMagnetStrengthForRMatrix(GMAD::Element const *el) const
Prepare magnet strength for rmatrix.
G4double currentArcLength
Updated each time CreateComponent is called - supplied from outside. Only here to pass around all fun...
const BDSParticleDefinition * designParticle
Particle w.r.t. which elements are built.
G4bool includeFringeFields
Cache of whether to include fringe fields.
void SetFieldDefinitions(GMAD::Element const *el, BDSAcceleratorComponent *component) const
static void CheckBendLengthAngleWidthCombo(G4double arcLength, G4double angle, G4double horizontalWidth, const G4String &name="not given")
void PrepareCrystals()
Prepare all crystals in defined the parser.
G4double lengthSafety
Length safety from global constants.
BDSMagnetStrength * PrepareCavityStrength(GMAD::Element const *el, BDSFieldType fieldType, G4double cavityLength, BDSMagnetStrength *&fringeIn, BDSMagnetStrength *&fringeOut) const
G4String elementName
Variable used to pass around the possibly modified name of an element.
void AddSynchronousTimeInformation(BDSMagnetStrength *st, G4double elementArcLength) const
Update the BDSMagnetStrength key synchronousT0 with the time at the centre of the element.
BDSAcceleratorComponent * CreateComponent(GMAD::Element const *elementIn, GMAD::Element const *prevElementIn, GMAD::Element const *nextElementIn, G4double currentArcLengthIn=0)
std::map< G4String, G4int > modifiedElements
void GetKickValue(G4double &hkick, G4double &vkick, const KickerType type) const
G4double BendAngle(const GMAD::Element *el) const
Calculate the angle of a bend whether it's an rbend or an sbend.
G4double IncomingFaceAngle(const GMAD::Element *el) const
void CalculateAngleAndFieldSBend(GMAD::Element const *el, G4double &angle, G4double &field) const
static G4Material * PrepareMaterial(GMAD::Element const *element, const G4String &defaultMaterialName)
Checks if a material is named in Element::material, else uses the supplied default.
static BDSTiltOffset * CreateTiltOffset(GMAD::Element const *el)
Create the tilt and offset information object by inspecting the parser element.
void SetModulatorDefinition(GMAD::Element const *el, BDSFieldInfo *info) const
void PrepareCavityModels()
const BDSIntegratorSet * integratorSet
Local copy of reference to integrator set to use.
BDSModulatorInfo * ModulatorDefinition(const GMAD::Element *el, G4bool inDevelopment=false) const
RFFieldDirection
Private enum for RF cavity principle accelerating direction.
G4double brho
Rigidity in T*m (G4units) for beam particles.
void SetBeta0(BDSMagnetStrength *stIn) const
Simple setter used to add Beta0 to a strength instance.
BDSCrystalInfo * PrepareCrystalInfo(const G4String &crystalName) const
static BDSBeamPipeInfo * PrepareBeamPipeInfo(GMAD::Element const *el, const G4ThreeVector &inputFaceNormal=G4ThreeVector(0, 0,-1), const G4ThreeVector &outputFaceNormal=G4ThreeVector(0, 0, 1))
static BDSMagnetGeometryType MagnetGeometryType(const GMAD::Element *el)
static G4double EFieldFromElement(GMAD::Element const *el, G4double cavityLength)
std::map< G4String, BDSCavityInfo * > cavityInfos
Map of cavity model info instances by name.
G4bool HasSufficientMinimumLength(GMAD::Element const *el, G4bool printWarning=true)
Test the component length is sufficient for practical construction.
static G4double ScalingFieldOuter(const GMAD::Element *ele)
Get the scaling factor for a particular outer field depending on the global and individual setting.
GMAD::Element const * prevElement
element access to previous element (can be nullptr)
Holder for all information required to create a crystal.
All info required to build complete field of any type.
Which integrator to use for each type of magnet / field object.
Holder struct of all information required to create the outer geometry of a magnet.
Efficient storage of magnet strengths.
Abstract base class that implements features common to all magnets.
Holder class for all information required to describe a modulator.
Wrapper for particle definition.
A holder for any placement offsets and rotations for a BDSAcceleratorComponent.
Parser namespace for GMAD language. Combination of Geant4 and MAD.