EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ScalableBField.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ScalableBField.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
10 
13 
14 namespace ActsExamples {
15 
16 namespace BField {
17 
20  double scalor = 1.;
21 };
22 
29 class ScalableBField final {
30  public:
31  struct Cache {
32  double scalor = 1.;
33 
36  scalor = std::any_cast<const ScalableBFieldContext>(mcfg).scalor;
37  }
38  };
39 
43  explicit ScalableBField(Acts::Vector3D B) : m_BField(std::move(B)) {}
44 
50  ScalableBField(double Bx = 0., double By = 0., double Bz = 0.)
51  : m_BField(Bx, By, Bz) {}
52 
60  Acts::Vector3D getField(const Acts::Vector3D& /*position*/) const {
61  return m_BField;
62  }
63 
72  Acts::Vector3D getField(const Acts::Vector3D& /*position*/,
73  Cache& cache) const {
74  return m_BField * cache.scalor;
75  }
76 
89  const Acts::Vector3D& /*position*/,
90  Acts::ActsMatrixD<3, 3>& /*derivative*/) const {
91  return m_BField;
92  }
93 
107  Acts::ActsMatrixD<3, 3>& /*derivative*/,
108  Cache& cache) const {
109  return m_BField * cache.scalor;
110  }
111 
118  bool isInside(const Acts::Vector3D& /*position*/) const { return true; }
119 
125  void setField(double Bx, double By, double Bz) { m_BField << Bx, By, Bz; }
126 
130  void setField(const Acts::Vector3D& B) { m_BField = B; }
131 
132  private:
135 };
136 
137 } // namespace BField
138 } // namespace ActsExamples