ATLAS Offline Software
BFieldCache.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 #include "CxxUtils/vec.h"
5 #include <cmath>
6 inline void
7 BFieldCache::invalidate()
8 {
9  m_phimin = 0.0;
10  m_phimax = -1.0;
11 }
12 inline void
13 BFieldCache::setRange(double zmin,
14  double zmax,
15  double rmin,
16  double rmax,
17  double phimin,
18  double phimax)
19 {
20  m_zmin = zmin;
21  m_zmax = zmax;
22  m_rmin = rmin;
23  m_rmax = rmax;
24  m_phimin = phimin;
25  m_phimax = phimax;
26  m_invz = 1.0 / (zmax - zmin);
27  m_invr = 1.0 / (rmax - rmin);
28  m_invphi = 1.0 / (phimax - phimin);
29 }
30 
31 // set field array, filled externally
32 inline void
33 BFieldCache::setField(const CxxUtils::vec<double, 8>& field1,
34  const CxxUtils::vec<double, 8>& field2,
35  const CxxUtils::vec<double, 8>& field3)
36 {
37  CxxUtils::vstore(&m_field[0][0], field1);
38  CxxUtils::vstore(&m_field[1][0], field2);
39  CxxUtils::vstore(&m_field[2][0], field3);
40 }
41 
42 inline void
43 BFieldCache::setBscale(double bscale)
44 {
45  m_scale = bscale;
46 }
47 
48 inline float
49 BFieldCache::bscale() const
50 {
51  return m_scale;
52 }
53 
54 inline bool
55 BFieldCache::inside(double z, double r, double phi) const
56 {
57  if (phi < m_phimin) {
58  phi += 2.0 * M_PI;
59  }
60  // clang emits code that is more similar to using the "bit AND"
61  // rather than "logical AND" for this kind of check.
62  // Basically get rid of jmp instructions with calculating
63  // a bit more
64  return ((z <= m_zmax) & (z >= m_zmin) & (r <= m_rmax) & (r >= m_rmin) &
65  (phi <= m_phimax) & (phi >= m_phimin));
66 }
67