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 
20 class ConstantBField final {
21  public:
22  struct Cache {
24  Cache(std::reference_wrapper<const MagneticFieldContext> /*mcfg*/) {}
25  };
26 
30  explicit ConstantBField(Vector3D B) : m_BField(std::move(B)) {}
31 
37  ConstantBField(double Bx = 0., double By = 0., double Bz = 0.)
38  : m_BField(Bx, By, Bz) {}
39 
47  Vector3D getField(const Vector3D& /*position*/) const { return m_BField; }
48 
57  Vector3D getField(const Vector3D& /*position*/, Cache& /*cache*/) const {
58  return m_BField;
59  }
60 
71  Vector3D getFieldGradient(const Vector3D& /*position*/,
72  ActsMatrixD<3, 3>& /*derivative*/) const {
73  return m_BField;
74  }
75 
87  Vector3D getFieldGradient(const Vector3D& /*position*/,
88  ActsMatrixD<3, 3>& /*derivative*/,
89  Cache& /*cache*/) const {
90  return m_BField;
91  }
92 
99  bool isInside(const Vector3D& /*position*/) const { return true; }
100 
106  void setField(double Bx, double By, double Bz) { m_BField << Bx, By, Bz; }
107 
111  void setField(const Vector3D& B) { m_BField = B; }
112 
113  private:
116 };
117 } // namespace Acts