BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Public Member Functions | Private Attributes | Friends
BDSArray2DCoordsRQuad Class Reference

A wrapper to achieve 2D reflection of a minimal quadrupole field solve. More...

#include <BDSArray2DCoordsRQuad.hh>

Inheritance diagram for BDSArray2DCoordsRQuad:
Inheritance graph
Collaboration diagram for BDSArray2DCoordsRQuad:
Collaboration graph

Public Member Functions

 BDSArray2DCoordsRQuad (BDSArray2DCoords *arrayIn)
 Wrap an existing BDSArray2DCoords instance. More...
 
virtual std::ostream & Print (std::ostream &out) const
 
virtual G4bool OutsideCoords (G4double x, G4double y, G4double z, G4double t) const
 Overridden from BDSArray4DCoords. More...
 
virtual G4double ArrayCoordsFromX (G4double x) const
 Overridden from BDSArray4DCoords. More...
 
virtual G4double ArrayCoordsFromY (G4double y) const
 Overridden from BDSArray4DCoords. More...
 
virtual G4int NearestX (G4double x) const
 Overridden from BDSArray4DCoords. More...
 
virtual G4int NearestY (G4double y) const
 Overridden from BDSArray4DCoords. More...
 
virtual const BDSFieldValueGetConst (G4int x, G4int y, G4int z=0, G4int t=0) const
 Overridden from BDSArray4D. More...
 
virtual G4bool Outside (G4int x, G4int y, G4int z, G4int t) const
 Overridden from BDSArray4D. More...
 
- Public Member Functions inherited from BDSArray2DCoords
 BDSArray2DCoords ()=delete
 
 BDSArray2DCoords (G4int nX, G4int nY, G4double xMinIn, G4double xMaxIn, G4double yMinIn, G4double yMaxIn, BDSDimensionType xDimensionIn=BDSDimensionType::x, BDSDimensionType yDimensionIn=BDSDimensionType::y)
 
virtual void ExtractSection2x2 (G4double x, G4double y, BDSFieldValue(&localData)[2][2], G4double &xFrac, G4double &yFrac) const
 Extract 2x2 points lying around coordinate x. More...
 
virtual void ExtractSection4x4 (G4double x, G4double y, BDSFieldValue(&localData)[4][4], G4double &xFrac, G4double &yFrac) const
 Extract 4x4 points lying around coordinate x. More...
 
virtual BDSFieldValue ExtractNearest (G4double x, G4double y=0, G4double z=0, G4double t=0) const
 Extract nearest field value from array. z,t ignored but required for overload. More...
 
virtual BDSExtent Extent () const
 
- Public Member Functions inherited from BDSArray3DCoords
 BDSArray3DCoords ()=delete
 
 BDSArray3DCoords (G4int nX, G4int nY, G4int nZ, G4double xMinIn, G4double xMaxIn, G4double yMinIn, G4double yMaxIn, G4double zMinIn, G4double zMaxIn, BDSDimensionType xDimensionIn=BDSDimensionType::x, BDSDimensionType yDimensionIn=BDSDimensionType::y, BDSDimensionType zDimensionIn=BDSDimensionType::z)
 
virtual void ExtractSection2x2x2 (G4double x, G4double y, G4double z, BDSFieldValue(&localData)[2][2][2], G4double &xFrac, G4double &yFrac, G4double &zFrac) const
 Extract 2x2x2 points lying around coordinate x. More...
 
virtual void ExtractSection4x4x4 (G4double x, G4double y, G4double z, BDSFieldValue(&localData)[4][4][4], G4double &xFrac, G4double &yFrac, G4double &zFrac) const
 Extract 4x4x4 points lying around coordinate x. More...
 
virtual BDSFieldValue ExtractNearest (G4double x, G4double y=0, G4double z=0, G4double t=0) const
 Extract nearest field value from array. t ignored but required for overload. More...
 
- Public Member Functions inherited from BDSArray4DCoords
 BDSArray4DCoords ()=delete
 
 BDSArray4DCoords (G4int nXIn, G4int nYIn, G4int nZIn, G4int nTIn, G4double xMinIn, G4double xMaxIn, G4double yMinIn, G4double yMaxIn, G4double zMinIn, G4double zMaxIn, G4double tMinIn, G4double tMaxIn, BDSDimensionType xDimensionIn=BDSDimensionType::x, BDSDimensionType yDimensionIn=BDSDimensionType::y, BDSDimensionType zDimensionIn=BDSDimensionType::z, BDSDimensionType tDimensionIn=BDSDimensionType::t)
 
G4double SmallestSpatialStep () const
 
virtual G4bool OutsideCoords (G4double x, G4double y, G4double z, G4double t) const
 Whether the spatial coordinates lie outside the range of the array or not. More...
 
virtual void OutsideCoordsWarn (G4double x, G4double y, G4double z, G4double t) const
 
BDSFourVector< G4double > ArrayCoordsFromXYZT (G4double x, G4double y, G4double z, G4double t) const
 Convenience function to easily get array coords in all dimensions at once. More...
 
BDSFourVector< G4double > XYZTFromArrayCoords (G4double x, G4double y, G4double z, G4double t) const
 
BDSFourVector< G4int > NearestXYZT (G4double x, G4double y, G4double z, G4double t) const
 Return the index of the nearest field value in space. More...
 
BDSFourVector< G4int > NearestXYZT (const BDSFourVector< G4double > &pos) const
 Return the index of the nearest field value in space via four-vector. More...
 
virtual void ExtractSection2x2x2x2 (G4double x, G4double y, G4double z, G4double t, BDSFieldValue(&localData)[2][2][2][2], G4double &xFrac, G4double &yFrac, G4double &zFrac, G4double &tFrac) const
 Extract 2x2x2x2 points lying around coordinate x. More...
 
virtual void ExtractSection4x4x4x4 (G4double x, G4double y, G4double z, G4double t, BDSFieldValue(&localData)[4][4][4][4], G4double &xFrac, G4double &yFrac, G4double &zFrac, G4double &tFrac) const
 Extract 4x4x4x4 points lying around coordinate x. More...
 
virtual BDSFieldValue ExtractNearest (G4double x, G4double y=0, G4double z=0, G4double t=0) const
 Extract nearest field value from array. More...
 
virtual std::ostream & Print (std::ostream &out) const
 
virtual BDSExtent Extent () const
 Return the SPATIAL (only) extent of this field without any offset. Ignores time. More...
 
G4double XMin () const
 
G4double YMin () const
 
G4double ZMin () const
 
G4double TMin () const
 
G4double XMax () const
 
G4double YMax () const
 
G4double ZMax () const
 
G4double TMax () const
 
G4int DimensionIndex (BDSDimensionType spatialDimension) const
 
std::array< G4int, 4 > ArrayToSpatialDimensionIndices () const
 Access all indices at once. More...
 
G4double XStep () const
 The distance in spatial coordinates between any two points in the array. More...
 
G4double YStep () const
 The distance in spatial coordinates between any two points in the array. More...
 
G4double ZStep () const
 The distance in spatial coordinates between any two points in the array. More...
 
G4double TStep () const
 The distance in spatial coordinates between any two points in the array. More...
 
virtual G4double ArrayCoordsFromZ (G4double z) const
 Not much point in being both virtual and inline (in our use case) but has to be virtual. More...
 
virtual G4double ArrayCoordsFromT (G4double t) const
 Not much point in being both virtual and inline (in our use case) but has to be virtual. More...
 
void ArrayCoordsFromXY (G4double &x, G4double &xArr, G4double &y, G4double &yArr) const
 Utility version to forward to individual function. More...
 
void ArrayCoordsFromXYZ (G4double &x, G4double &xArr, G4double &y, G4double &yArr, G4double &z, G4double &zArr) const
 Utility version to forward to individual function. More...
 
void ArrayCoordsFromXYZT (G4double &x, G4double &xArr, G4double &y, G4double &yArr, G4double &z, G4double &zArr, G4double &t, G4double &tArr) const
 Utility version to forward to individual function. More...
 
G4double XFromArrayCoords (G4double xCoord) const
 Return spatial value from a continuous array coordinate in one dimension. More...
 
G4double YFromArrayCoords (G4double yCoord) const
 Return spatial value from a continuous array coordinate in one dimension. More...
 
G4double ZFromArrayCoords (G4double zCoord) const
 Return spatial value from a continuous array coordinate in one dimension. More...
 
G4double TFromArrayCoords (G4double tCoord) const
 Return spatial value from a continuous array coordinate in one dimension. More...
 
virtual G4int NearestZ (G4double z) const
 Not much point in being both virtual and inline (in our use case) but has to be virtual. More...
 
virtual G4int NearestT (G4double t) const
 Not much point in being both virtual and inline (in our use case) but has to be virtual. More...
 
BDSDimensionType FirstDimension () const
 Accessor for each dimension label. e.g. array 'x' = spatial z. More...
 
BDSDimensionType SecondDimension () const
 Accessor for each dimension label. e.g. array 'x' = spatial z. More...
 
BDSDimensionType ThirdDimension () const
 Accessor for each dimension label. e.g. array 'x' = spatial z. More...
 
BDSDimensionType FourthDimension () const
 Accessor for each dimension label. e.g. array 'x' = spatial z. More...
 
- Public Member Functions inherited from BDSArray4D
 BDSArray4D ()=delete
 
 BDSArray4D (G4int nXIn, G4int nYIn, G4int nZIn, G4int nTIn)
 
virtual BDSFieldValueoperator() (G4int x, G4int y=0, G4int z=0, G4int t=0)
 Setter & (technically, a non-const) accessor. More...
 
const BDSFieldValueoperator() (BDSFourVector< G4int > &pos)
 Convenience accessor to operator(). More...
 
virtual const BDSFieldValueGetConst (G4int x, G4int y=0, G4int z=0, G4int t=0) const
 
virtual const BDSFieldValueoperator() (G4int x, G4int y=0, G4int z=0, G4int t=0) const
 Convenience shortcut to GetConst(). More...
 
const BDSFieldValueoperator() (const BDSFourVector< G4int > &pos) const
 Convenience accessor to operator(). More...
 
virtual G4bool Outside (G4int x, G4int y, G4int z, G4int t) const
 Return whether the indices are valid and lie within the array boundaries or not. More...
 
virtual void OutsideWarn (G4int x, G4int y, G4int z, G4int t) const
 Use Outside() but warn and exit if the coordinates requested are outside the array. More...
 
virtual std::ostream & Print (std::ostream &out) const
 
G4int NX () const
 Access the number of elements in a given dimension. More...
 
G4int NY () const
 Access the number of elements in a given dimension. More...
 
G4int NZ () const
 Access the number of elements in a given dimension. More...
 
G4int NT () const
 Access the number of elements in a given dimension. More...
 
BDSFourVector< G4int > NXYZT () const
 Access the number of elements in a given dimension. More...
 

Private Attributes

BDSFieldValue returnValue
 

Friends

std::ostream & operator<< (std::ostream &out, BDSArray2DCoordsRQuad const &a)
 Delegate function to call polymorphic Print(). More...
 

Additional Inherited Members

- Protected Member Functions inherited from BDSArray4DCoords
void BuildDimensionIndex ()
 Build up an array of ints based on the order of dimensions stored in the array. More...
 
- Protected Attributes inherited from BDSArray4DCoords
G4double smallestSpatialStep
 
BDSDimensionType xDimension
 
BDSDimensionType yDimension
 
BDSDimensionType zDimension
 
BDSDimensionType tDimension
 
std::array< G4int, 4 > dimensions
 
G4double xMin
 Dimension parameter - protected for derived class access. More...
 
G4double xMax
 Dimension parameter - protected for derived class access. More...
 
G4double yMin
 Dimension parameter - protected for derived class access. More...
 
G4double yMax
 Dimension parameter - protected for derived class access. More...
 
G4double zMin
 Dimension parameter - protected for derived class access. More...
 
G4double zMax
 Dimension parameter - protected for derived class access. More...
 
G4double tMin
 Dimension parameter - protected for derived class access. More...
 
G4double tMax
 Dimension parameter - protected for derived class access. More...
 
G4double xStep
 Dimension parameter - protected for derived class access. More...
 
G4double yStep
 Dimension parameter - protected for derived class access. More...
 
G4double zStep
 Dimension parameter - protected for derived class access. More...
 
G4double tStep
 Dimension parameter - protected for derived class access. More...
 
- Protected Attributes inherited from BDSArray4D
BDSFieldValue defaultValue
 Need to store a default value so it can be return by reference. More...
 
const G4int nX
 Dimension. More...
 
const G4int nY
 Dimension. More...
 
const G4int nZ
 Dimension. More...
 
const G4int nT
 Dimension. More...
 

Detailed Description

A wrapper to achieve 2D reflection of a minimal quadrupole field solve.

NOTE: This should only be used for arrays where the spatial spacing is the same in both x and y - ie xStep and yStep are the same, otherwise the field map will be distorted.

This allows a small 2pi/8 segment between the x axis and y=x in the positive quadrant to be reflected to represent a quadrupole. Ie relfected about y=z in the positive quadrant (A); reflected and inverted in the negative quadrant (C); reflected and y field component inverted in quadrant (B); reflected and x component inverted in quadrant (D)

B | A

C | D

This owns the array it wraps.

This makes an array look 4 times bigger than it is - ie 2x as big in x and y. The array coordinates are correspondingly shifted. What would've been (0,0) in a 100x100 array will now be at index (101,101).

This is reflected about 0,0 and can only be so given the implementation.

Some interfaces are overloaded and some aren't as are required to be (NX for example). The ostream << writes both the raw array and the reflected version too.

Note, by return a reference to a non-const member returnValue that may be updated by another query, thread safety could be an issue.

The reflection includes the diagonal line in the array.

Author
Laurie Nevay

Definition at line 65 of file BDSArray2DCoordsRQuad.hh.

Constructor & Destructor Documentation

◆ BDSArray2DCoordsRQuad()

BDSArray2DCoordsRQuad::BDSArray2DCoordsRQuad ( BDSArray2DCoords arrayIn)
explicit

Wrap an existing BDSArray2DCoords instance.

Definition at line 29 of file BDSArray2DCoordsRQuad.cc.

◆ ~BDSArray2DCoordsRQuad()

virtual BDSArray2DCoordsRQuad::~BDSArray2DCoordsRQuad ( )
inlinevirtual

Definition at line 71 of file BDSArray2DCoordsRQuad.hh.

Member Function Documentation

◆ ArrayCoordsFromX()

G4double BDSArray2DCoordsRQuad::ArrayCoordsFromX ( G4double  x) const
virtual

Overridden from BDSArray4DCoords.

Reimplemented from BDSArray4DCoords.

Definition at line 46 of file BDSArray2DCoordsRQuad.cc.

References BDSArray4DCoords::xMax, BDSArray4DCoords::xMin, and BDSArray4DCoords::xStep.

Referenced by NearestX().

Here is the caller graph for this function:

◆ ArrayCoordsFromY()

G4double BDSArray2DCoordsRQuad::ArrayCoordsFromY ( G4double  y) const
virtual

Overridden from BDSArray4DCoords.

Reimplemented from BDSArray4DCoords.

Definition at line 51 of file BDSArray2DCoordsRQuad.cc.

References BDSArray4DCoords::yMax, BDSArray4DCoords::yMin, and BDSArray4DCoords::yStep.

Referenced by NearestY().

Here is the caller graph for this function:

◆ GetConst()

const BDSFieldValue & BDSArray2DCoordsRQuad::GetConst ( G4int  x,
G4int  y,
G4int  z = 0,
G4int  t = 0 
) const
virtual

Overridden from BDSArray4D.

Reimplemented from BDSArray4D.

Definition at line 66 of file BDSArray2DCoordsRQuad.cc.

References BDSArray4D::defaultValue, BDSArray4D::GetConst(), BDSArray4D::nX, BDSArray4D::nY, Outside(), returnValue, BDSThreeVector< T >::x(), BDSThreeVector< T >::y(), and BDSThreeVector< T >::z().

Referenced by Print().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NearestX()

G4int BDSArray2DCoordsRQuad::NearestX ( G4double  x) const
virtual

Overridden from BDSArray4DCoords.

Reimplemented from BDSArray4DCoords.

Definition at line 56 of file BDSArray2DCoordsRQuad.cc.

References ArrayCoordsFromX().

Here is the call graph for this function:

◆ NearestY()

G4int BDSArray2DCoordsRQuad::NearestY ( G4double  y) const
virtual

Overridden from BDSArray4DCoords.

Reimplemented from BDSArray4DCoords.

Definition at line 61 of file BDSArray2DCoordsRQuad.cc.

References ArrayCoordsFromY().

Here is the call graph for this function:

◆ Outside()

G4bool BDSArray2DCoordsRQuad::Outside ( G4int  x,
G4int  y,
G4int  z,
G4int  t 
) const
virtual

Overridden from BDSArray4D.

Reimplemented from BDSArray4D.

Definition at line 140 of file BDSArray2DCoordsRQuad.cc.

References BDSArray4D::nT, BDSArray4D::nX, BDSArray4D::nY, and BDSArray4D::nZ.

Referenced by GetConst().

Here is the caller graph for this function:

◆ OutsideCoords()

G4bool BDSArray2DCoordsRQuad::OutsideCoords ( G4double  x,
G4double  y,
G4double  z,
G4double  t 
) const
virtual

◆ Print()

std::ostream & BDSArray2DCoordsRQuad::Print ( std::ostream &  out) const
virtual

This prints out the raw underlying data, then the reflected version as would normally be queried.

Reimplemented from BDSArray4DCoords.

Definition at line 152 of file BDSArray2DCoordsRQuad.cc.

References GetConst(), BDSArray4D::nT, BDSArray4D::nX, BDSArray4D::nY, BDSArray4D::nZ, and BDSArray4DCoords::Print().

Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  out,
BDSArray2DCoordsRQuad const &  a 
)
friend

Delegate function to call polymorphic Print().

Definition at line 172 of file BDSArray2DCoordsRQuad.cc.

Field Documentation

◆ returnValue

BDSFieldValue BDSArray2DCoordsRQuad::returnValue
mutableprivate

Must return by reference and the true data value may have to be reflected in one or more dimensions. Copy to this and return reference to it.

Definition at line 108 of file BDSArray2DCoordsRQuad.hh.

Referenced by GetConst().


The documentation for this class was generated from the following files: