ATLAS Offline Software
BFieldMesh.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
30 //
31 #ifndef BFIELDMESH_H
32 #define BFIELDMESH_H
33 
34 #include "CxxUtils/restrict.h"
37 #include <array>
38 #include <cmath>
39 #include <vector>
40 
41 template<class T>
43 {
44 public:
45  static_assert((std::is_same<T, short>::value ||
47  "Type for the BField Mesh must be one of short or double");
48  BFieldMesh() = default;
49  BFieldMesh(const BFieldMesh&) = default;
50  BFieldMesh(BFieldMesh&&) = default;
51  BFieldMesh& operator=(const BFieldMesh&) = default;
53  ~BFieldMesh() = default;
55  BFieldMesh(double zmin,
56  double zmax,
57  double rmin,
58  double rmax,
59  double phimin,
60  double phimax,
61  double bscale);
62 
64  void setRange(double zmin,
65  double zmax,
66  double rmin,
67  double rmax,
68  double phimin,
69  double phimax);
70 
72  void setBscale(double bscale);
74  void scaleBscale(double factor);
76  void reserve(int nz, int nr, int nphi, int nfield);
78  void reserve(int nz, int nr, int nphi);
80  void appendMesh(int axis, double value);
84  void buildLUT();
85  /* @brief test if a point is inside this mesh*/
86  bool inside(double z, double r, double phi) const;
87  /* @brief get the cache corresponding to a particular cell*/
88  void getCache(double z,
89  double r,
90  double phi,
91  BFieldCache& cache,
92  double scaleFactor = 1.0) const;
94  void getB(const double* ATH_RESTRICT xyz,
95  double* ATH_RESTRICT B,
96  double* ATH_RESTRICT deriv = nullptr) const;
98  double min(size_t axis) const;
100  double max(size_t axis) const;
102  double zmin() const;
104  double zmax() const;
106  double rmin() const;
108  double rmax() const;
110  double phimin() const;
112  double phimax() const;
114  unsigned nmesh(size_t axis) const;
117  double mesh(size_t axis, size_t index) const;
119  unsigned nfield() const;
121  const BFieldVector<T>& field(size_t index) const;
123  double bscale() const;
125  int memSize() const;
126 
127 protected:
128  std::array<double, 3> m_min;
129  std::array<double, 3> m_max;
130  std::array<std::vector<double>, 3> m_mesh;
131 
132 private:
133  std::vector<BFieldVector<T>> m_field;
134  double m_scale = 1.0;
135  double m_nomScale; // nominal m_scale from the map
136 
137  // look-up table and related variables
138  std::array<std::vector<int>, 3> m_LUT;
139  std::array<double, 3> m_invUnit= {0, 0, 0}; // inverse unit size in the LUT
140  int m_roff = 0, m_zoff = 0;
141 };
143 #endif
beamspotman.r
def r
Definition: beamspotman.py:676
BFieldMesh::BFieldMesh
BFieldMesh(double zmin, double zmax, double rmin, double rmax, double phimin, double phimax, double bscale)
constructor with mesh dimensions and scale
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
BFieldMesh::phimin
double phimin() const
minimun in phi
BFieldMesh::m_field
std::vector< BFieldVector< T > > m_field
Definition: BFieldMesh.h:133
index
Definition: index.py:1
BFieldMesh::min
double min(size_t axis) const
minimum for a particular axis = 0 (z), 1 (r), 2 (phi)
BFieldCache.h
yodamerge_tmp.axis
list axis
Definition: yodamerge_tmp.py:241
BFieldMesh::max
double max(size_t axis) const
maximum or a particular axis = 0 (z), 1 (r), 2 (phi)
xyz
#define xyz
BFieldMesh::setRange
void setRange(double zmin, double zmax, double rmin, double rmax, double phimin, double phimax)
set mesh range/dimensions
athena.value
value
Definition: athena.py:122
BFieldMesh::getCache
void getCache(double z, double r, double phi, BFieldCache &cache, double scaleFactor=1.0) const
BFieldMesh::m_min
std::array< double, 3 > m_min
Definition: BFieldMesh.h:128
BFieldMesh::inside
bool inside(double z, double r, double phi) const
BFieldMesh::getB
void getB(const double *ATH_RESTRICT xyz, double *ATH_RESTRICT B, double *ATH_RESTRICT deriv=nullptr) const
get the bfield given a point in xyz
BFieldMesh::m_zoff
int m_zoff
Definition: BFieldMesh.h:140
BFieldMesh::appendMesh
void appendMesh(int axis, double value)
add a position for a cell corner for an axis
BFieldMesh::nfield
unsigned nfield() const
field entries in mesh
BFieldMesh::m_nomScale
double m_nomScale
Definition: BFieldMesh.h:135
ATH_RESTRICT
#define ATH_RESTRICT
Definition: restrict.h:31
BFieldMesh::bscale
double bscale() const
scale
BFieldMesh::scaleBscale
void scaleBscale(double factor)
scale B scale by a factor
BFieldMesh::operator=
BFieldMesh & operator=(const BFieldMesh &)=default
BFieldMesh::reserve
void reserve(int nz, int nr, int nphi)
allocate space to vectors
BFieldMesh::phimax
double phimax() const
maximum in phi
BFieldMesh::m_LUT
std::array< std::vector< int >, 3 > m_LUT
Definition: BFieldMesh.h:138
BFieldMesh::BFieldMesh
BFieldMesh()=default
z
#define z
BFieldMesh
Definition: BFieldMesh.h:43
BFieldMesh::operator=
BFieldMesh & operator=(BFieldMesh &&)=default
BFieldMesh::zmax
double zmax() const
maximum in z
BFieldMesh::BFieldMesh
BFieldMesh(BFieldMesh &&)=default
BFieldMesh.icc
BFieldMesh::m_mesh
std::array< std::vector< double >, 3 > m_mesh
Definition: BFieldMesh.h:130
BFieldMesh::mesh
double mesh(size_t axis, size_t index) const
coordinate along axis (0 (z), 1 (r), 2 (phi)) of the cell at index (0 to nmesh-1)
BFieldMesh::~BFieldMesh
~BFieldMesh()=default
BFieldMesh::m_roff
int m_roff
Definition: BFieldMesh.h:140
BFieldMesh::nmesh
unsigned nmesh(size_t axis) const
number of cells along each axis = 0 (z), 1 (r), 2 (phi)
BFieldMesh::m_scale
double m_scale
Definition: BFieldMesh.h:134
BFieldMesh::field
const BFieldVector< T > & field(size_t index) const
field vector at cell corner at index
BFieldCache
BFieldCache.h.
Definition: BFieldCache.h:25
BFieldVector.h
restrict.h
Macro wrapping the nonstandard restrict keyword.
BFieldMesh::setBscale
void setBscale(double bscale)
set B scale
dqt_zlumi_alleff_HIST.B
B
Definition: dqt_zlumi_alleff_HIST.py:110
BFieldMesh::appendField
void appendField(const BFieldVector< T > &field)
append a filed vector
BFieldMesh::zmin
double zmin() const
minimum in z
BFieldMesh::m_invUnit
std::array< double, 3 > m_invUnit
Definition: BFieldMesh.h:139
BFieldMesh::reserve
void reserve(int nz, int nr, int nphi, int nfield)
allocate space to vectors
BFieldVector
Definition: BFieldVector.h:22
BFieldMesh::memSize
int memSize() const
memory size
BFieldMesh::rmax
double rmax() const
maximum in r
BFieldMesh::m_max
std::array< double, 3 > m_max
Definition: BFieldMesh.h:129
BFieldMesh::buildLUT
void buildLUT()
build Look Up Table
BFieldMesh::BFieldMesh
BFieldMesh(const BFieldMesh &)=default
BFieldMesh::rmin
double rmin() const
minimun in r