ATLAS Offline Software
Loading...
Searching...
No Matches
BFieldMeshZR.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5//
6// Find and return the cache of the bin containing (z,r)
7//
8inline void
9BFieldMeshZR::getCache(double z,
10 double r,
11 BFieldCacheZR& cache,
12 double scaleFactor) const
13{
14 // find the mesh, and relative location in the mesh
15 // z
16 const std::vector<double>& mz(m_mesh[0]);
17 int iz = int((z - zmin()) * m_invUnit[0]); // index to LUT
18 iz = m_LUT[0][iz]; // tentative mesh index from LUT
19 if (z > mz[iz + 1]) {
20 ++iz;
21 }
22 // r
23 const std::vector<double>& mr(m_mesh[1]);
24 int ir = int((r - rmin()) * m_invUnit[1]); // index to LUT
25 ir = m_LUT[1][ir]; // tentative mesh index from LUT
26 if (r > mr[ir + 1]) {
27 ++ir;
28 }
29 // store the bin edges
30 cache.setRange(mz[iz], mz[iz + 1], mr[ir], mr[ir + 1]);
31 // store the B field at the 8 corners
32 int im0 = iz * m_zoff + ir; // index of the first corner
33 cache.setField(0, m_field[im0], scaleFactor);
34 cache.setField(1, m_field[im0 + 1], scaleFactor);
35 cache.setField(2, m_field[im0 + m_zoff], scaleFactor);
36 cache.setField(3, m_field[im0 + m_zoff + 1], scaleFactor);
37}
38
39inline BFieldMeshZR::BFieldMeshZR(double zmin,
40 double zmax,
41 double rmin,
42 double rmax)
43 : m_min { zmin, rmin },
44 m_max { zmax, rmax }
45{
46}
47
48inline void
49BFieldMeshZR::reserve(int nz, int nr)
50{
51 m_mesh[0].reserve(nz);
52 m_mesh[1].reserve(nr);
53 m_field.reserve(nz * nr);
54}
55// add elements to vectors
56inline void
57BFieldMeshZR::appendMesh(int i, double mesh)
58{
59 m_mesh[i].push_back(mesh);
60}
61inline void
62BFieldMeshZR::appendField(const BFieldVectorZR& field)
63{
64 m_field.push_back(field);
65}
66
67// test if a point is inside this zone
68inline bool
69BFieldMeshZR::inside(double z, double r) const
70{
71 return (z >= zmin() && z <= zmax() && r >= rmin() && r <= rmax());
72}
73
74inline double
75BFieldMeshZR::min(size_t i) const
76{
77 return m_min[i];
78}
79inline double
80BFieldMeshZR::max(size_t i) const
81{
82 return m_max[i];
83}
84inline double
85BFieldMeshZR::zmin() const
86{
87 return m_min[0];
88}
89inline double
90BFieldMeshZR::zmax() const
91{
92 return m_max[0];
93}
94inline double
95BFieldMeshZR::rmin() const
96{
97 return m_min[1];
98}
99inline double
100BFieldMeshZR::rmax() const
101{
102 return m_max[1];
103}
104inline unsigned
105BFieldMeshZR::nmesh(size_t i) const
106{
107 return m_mesh[i].size();
108}
109inline double
110BFieldMeshZR::mesh(size_t i, size_t j) const
111{
112 return m_mesh[i][j];
113}
114inline unsigned
115BFieldMeshZR::nfield() const
116{
117 return m_field.size();
118}
119inline const BFieldVectorZR&
120BFieldMeshZR::field(size_t i) const
121{
122 return m_field[i];
123}
124