BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
|
4D array and base class for 3,2 & 1D arrays. More...
#include <BDSArray4D.hh>
Public Member Functions | |
BDSArray4D ()=delete | |
BDSArray4D (G4int nXIn, G4int nYIn, G4int nZIn, G4int nTIn) | |
virtual BDSFieldValue & | operator() (G4int x, G4int y=0, G4int z=0, G4int t=0) |
Setter & (technically, a non-const) accessor. | |
const BDSFieldValue & | operator() (BDSFourVector< G4int > &pos) |
Convenience accessor to operator(). | |
virtual const BDSFieldValue & | GetConst (G4int x, G4int y=0, G4int z=0, G4int t=0) const |
virtual const BDSFieldValue & | operator() (G4int x, G4int y=0, G4int z=0, G4int t=0) const |
Convenience shortcut to GetConst(). | |
const BDSFieldValue & | operator() (const BDSFourVector< G4int > &pos) const |
Convenience accessor to operator(). | |
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. | |
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. | |
virtual std::ostream & | Print (std::ostream &out) const |
G4int | NX () const |
Access the number of elements in a given dimension. | |
G4int | NY () const |
Access the number of elements in a given dimension. | |
G4int | NZ () const |
Access the number of elements in a given dimension. | |
G4int | NT () const |
Access the number of elements in a given dimension. | |
BDSFourVector< G4int > | NXYZT () const |
Access the number of elements in a given dimension. | |
Protected Attributes | |
BDSFieldValue | defaultValue |
Need to store a default value so it can be return by reference. | |
const G4int | nX |
Dimension. | |
const G4int | nY |
Dimension. | |
const G4int | nZ |
Dimension. | |
const G4int | nT |
Dimension. | |
Private Attributes | |
std::vector< BDSFieldValue > | data |
A 1D array representing all the data. | |
Friends | |
std::ostream & | operator<< (std::ostream &out, BDSArray4D const &a) |
Output stream. | |
4D array and base class for 3,2 & 1D arrays.
Data represents T,Z,Y,X dimensions. The data is stored as a (1D) vector and stored in that order. This means that adjacent X values are stored next to each other. Storing the data as a 1D vector improves performance for random access (through behind the scenes caching) and significantly improves performance for copying.
Data can be accessed by index only in the array. Testing of indices is provided.
The () operator is used for accessing and setting as the [] operator can only ever accept one parameter by design. https://isocpp.org/wiki/faq/operator-overloading#matrix-subscript-op
The size cannot be changed after construction.
Definition at line 50 of file BDSArray4D.hh.
|
delete |
No default constructor as the array is not adjustable after construction and therefore the size must be known at construction time.
BDSArray4D::BDSArray4D | ( | G4int | nXIn, |
G4int | nYIn, | ||
G4int | nZIn, | ||
G4int | nTIn | ||
) |
At construction the size of the array must be known as this implementation does not allow the size to be changed afterwards.
Definition at line 31 of file BDSArray4D.cc.
|
inlinevirtual |
Definition at line 59 of file BDSArray4D.hh.
|
virtual |
Accessor only as returns const reference to data. By being named this can be used explicitly to ensure const access - recommended main main interface.
Reimplemented in BDSArray2DCoordsRDipole, and BDSArray2DCoordsRQuad.
Definition at line 46 of file BDSArray4D.cc.
References data, defaultValue, nX, nY, nZ, and Outside().
Referenced by BDSArray1DCoords::ExtractNearest(), BDSArray1DCoordsTransformed::ExtractNearest(), BDSArray2DCoords::ExtractNearest(), BDSArray2DCoordsTransformed::ExtractNearest(), BDSArray3DCoords::ExtractNearest(), BDSArray3DCoordsTransformed::ExtractNearest(), BDSArray4DCoords::ExtractNearest(), BDSArray4DCoordsTransformed::ExtractNearest(), BDSArray1DCoords::ExtractSection2(), BDSArray1DCoordsTransformed::ExtractSection2(), BDSArray2DCoords::ExtractSection2x2(), BDSArray2DCoordsTransformed::ExtractSection2x2(), BDSArray3DCoords::ExtractSection2x2x2(), BDSArray3DCoordsTransformed::ExtractSection2x2x2(), BDSArray4DCoords::ExtractSection2x2x2x2(), BDSArray4DCoordsTransformed::ExtractSection2x2x2x2(), BDSArray1DCoords::ExtractSection4(), BDSArray1DCoordsTransformed::ExtractSection4(), BDSArray2DCoords::ExtractSection4x4(), BDSArray2DCoordsTransformed::ExtractSection4x4(), BDSArray3DCoords::ExtractSection4x4x4(), BDSArray3DCoordsTransformed::ExtractSection4x4x4(), BDSArray4DCoords::ExtractSection4x4x4x4(), BDSArray4DCoordsTransformed::ExtractSection4x4x4x4(), BDSArray2DCoordsRDipole::GetConst(), BDSArray2DCoordsRQuad::GetConst(), operator()(), and Print().
|
inline |
Access the number of elements in a given dimension.
Definition at line 65 of file BDSArray4D.hh.
References nT.
Referenced by NXYZT().
|
inline |
Access the number of elements in a given dimension.
Definition at line 62 of file BDSArray4D.hh.
References nX.
Referenced by NXYZT().
|
inline |
|
inline |
Access the number of elements in a given dimension.
Definition at line 63 of file BDSArray4D.hh.
References nY.
Referenced by NXYZT().
|
inline |
Access the number of elements in a given dimension.
Definition at line 64 of file BDSArray4D.hh.
References nZ.
Referenced by NXYZT().
|
inline |
Convenience accessor to operator().
Definition at line 76 of file BDSArray4D.hh.
References operator()(), BDSFourVector< Type >::t(), BDSFourVector< Type >::x(), BDSFourVector< Type >::y(), and BDSFourVector< Type >::z().
|
inline |
Convenience accessor to operator().
Definition at line 94 of file BDSArray4D.hh.
References operator()(), BDSFourVector< Type >::t(), BDSFourVector< Type >::x(), BDSFourVector< Type >::y(), and BDSFourVector< Type >::z().
|
virtual |
Setter & (technically, a non-const) accessor.
Definition at line 37 of file BDSArray4D.cc.
References data, nX, nY, nZ, and OutsideWarn().
Referenced by operator()().
|
virtual |
Convenience shortcut to GetConst().
Definition at line 56 of file BDSArray4D.cc.
References GetConst().
|
virtual |
Return whether the indices are valid and lie within the array boundaries or not.
Reimplemented in BDSArray2DCoordsRDipole, and BDSArray2DCoordsRQuad.
Definition at line 64 of file BDSArray4D.cc.
References nT, nX, nY, and nZ.
Referenced by GetConst(), and OutsideWarn().
|
virtual |
Use Outside() but warn and exit if the coordinates requested are outside the array.
Definition at line 76 of file BDSArray4D.cc.
References Outside().
Referenced by operator()().
|
virtual |
Virtual function is more flexible than plain operator<< for ostreaming as the derived function may use the base class part of the print out first or in a different way. The operator<< for ostream uses this function.
Reimplemented in BDSArray1DCoordsTransformed, BDSArray2DCoordsRDipole, BDSArray2DCoordsRQuad, BDSArray2DCoordsTransformed, BDSArray3DCoordsTransformed, BDSArray4DCoords, and BDSArray4DCoordsTransformed.
Definition at line 91 of file BDSArray4D.cc.
References GetConst(), nT, nX, nY, and nZ.
Referenced by BDSArray1DCoordsTransformed::Print(), BDSArray2DCoordsRDipole::Print(), BDSArray2DCoordsRQuad::Print(), BDSArray2DCoordsTransformed::Print(), BDSArray3DCoordsTransformed::Print(), and BDSArray4DCoords::Print().
|
friend |
Output stream.
Definition at line 112 of file BDSArray4D.cc.
|
private |
A 1D array representing all the data.
Definition at line 131 of file BDSArray4D.hh.
Referenced by GetConst(), and operator()().
|
protected |
Need to store a default value so it can be return by reference.
Definition at line 127 of file BDSArray4D.hh.
Referenced by BDSArray2DCoordsRDipole::GetConst(), BDSArray2DCoordsRQuad::GetConst(), and GetConst().
|
protected |
Dimension.
Definition at line 123 of file BDSArray4D.hh.
Referenced by BDSArray4DCoords::BDSArray4DCoords(), NT(), BDSArray2DCoordsRDipole::Outside(), BDSArray2DCoordsRQuad::Outside(), Outside(), BDSArray2DCoordsRDipole::Print(), BDSArray2DCoordsRQuad::Print(), and Print().
|
protected |
Dimension.
Definition at line 120 of file BDSArray4D.hh.
Referenced by BDSArray4DCoords::BDSArray4DCoords(), BDSArray2DCoordsRDipole::GetConst(), BDSArray2DCoordsRQuad::GetConst(), GetConst(), NX(), operator()(), BDSArray2DCoordsRDipole::Outside(), BDSArray2DCoordsRQuad::Outside(), Outside(), BDSArray2DCoordsRDipole::Print(), BDSArray2DCoordsRQuad::Print(), and Print().
|
protected |
Dimension.
Definition at line 121 of file BDSArray4D.hh.
Referenced by BDSArray4DCoords::BDSArray4DCoords(), BDSArray2DCoordsRDipole::GetConst(), BDSArray2DCoordsRQuad::GetConst(), GetConst(), NY(), operator()(), BDSArray2DCoordsRDipole::Outside(), BDSArray2DCoordsRQuad::Outside(), Outside(), BDSArray2DCoordsRDipole::Print(), BDSArray2DCoordsRQuad::Print(), and Print().
|
protected |
Dimension.
Definition at line 122 of file BDSArray4D.hh.
Referenced by BDSArray4DCoords::BDSArray4DCoords(), GetConst(), NZ(), operator()(), BDSArray2DCoordsRDipole::Outside(), BDSArray2DCoordsRQuad::Outside(), Outside(), BDSArray2DCoordsRDipole::Print(), BDSArray2DCoordsRQuad::Print(), and Print().