ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConstantBField.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ConstantBField.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
12 
13 namespace Acts {
14 
21 class ConstantBField final {
22  public:
23  struct Cache {
25  Cache(std::reference_wrapper<const MagneticFieldContext> /*mcfg*/) {}
26  };
27 
31  explicit ConstantBField(Vector3D B) : m_BField(std::move(B)) {}
32 
38  ConstantBField(double Bx = 0., double By = 0., double Bz = 0.)
39  : m_BField(Bx, By, Bz) {}
40 
48  Vector3D getField(const Vector3D& /*position*/) const { return m_BField; }
49 
58  Vector3D getField(const Vector3D& /*position*/, Cache& /*cache*/) const {
59  return m_BField;
60  }
61 
72  Vector3D getFieldGradient(const Vector3D& /*position*/,
73  ActsMatrixD<3, 3>& /*derivative*/) const {
74  return m_BField;
75  }
76 
88  Vector3D getFieldGradient(const Vector3D& /*position*/,
89  ActsMatrixD<3, 3>& /*derivative*/,
90  Cache& /*cache*/) const {
91  return m_BField;
92  }
93 
100  bool isInside(const Vector3D& /*position*/) const { return true; }
101 
107  void setField(double Bx, double By, double Bz) { m_BField << Bx, By, Bz; }
108 
112  void setField(const Vector3D& B) { m_BField = B; }
113 
114  private:
117 };
118 } // namespace Acts