Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:27:39

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-2018 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 #include "Acts/Definitions/Algebra.hpp"
0011 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0012 #include "Acts/MagneticField/MagneticFieldProvider.hpp"
0013 
0014 namespace Acts {
0015 
0016 /// @ingroup MagneticField
0017 /// @brief Null bfield which returns 0 always
0018 class NullBField final : public MagneticFieldProvider {
0019  public:
0020   struct Cache {
0021     /// @brief constructor with context
0022     Cache(const MagneticFieldContext& /*mcfg*/) {}
0023   };
0024 
0025   /// @brief Default constructor
0026   NullBField() = default;
0027 
0028   /// @copydoc MagneticFieldProvider::getField(const Vector3&,MagneticFieldProvider::Cache&) const
0029   ///
0030   /// @note The @p position is ignored and only kept as argument to provide
0031   ///       a consistent interface with other magnetic field services.
0032   Result<Vector3> getField(const Vector3& position,
0033                            MagneticFieldProvider::Cache& cache) const override {
0034     (void)position;
0035     (void)cache;
0036     return Result<Vector3>::success(m_BField);
0037   }
0038 
0039   /// @copydoc MagneticFieldProvider::getFieldGradient(const Vector3&,ActsMatrix<3,3>&,MagneticFieldProvider::Cache&) const
0040   ///
0041   /// @note The @p position is ignored and only kept as argument to provide
0042   ///       a consistent interface with other magnetic field services.
0043   /// @note currently the derivative is not calculated
0044   /// @todo return derivative
0045   Result<Vector3> getFieldGradient(
0046       const Vector3& position, ActsMatrix<3, 3>& derivative,
0047       MagneticFieldProvider::Cache& cache) const override {
0048     (void)position;
0049     (void)derivative;
0050     (void)cache;
0051     return Result<Vector3>::success(m_BField);
0052   }
0053 
0054   /// @copydoc MagneticFieldProvider::makeCache(const MagneticFieldContext&) const
0055   Acts::MagneticFieldProvider::Cache makeCache(
0056       const Acts::MagneticFieldContext& mctx) const override {
0057     return Acts::MagneticFieldProvider::Cache(std::in_place_type<Cache>, mctx);
0058   }
0059 
0060   /// @brief check whether given 3D position is inside look-up domain
0061   ///
0062   /// @return @c true if position is inside the defined look-up grid,
0063   ///         otherwise @c false
0064   /// @note The method will always return true for the null B-Field
0065   bool isInside(const Vector3& /*position*/) const { return true; }
0066 
0067  private:
0068   /// magnetic field vector
0069   const Vector3 m_BField = Vector3::Zero();
0070 };
0071 }  // namespace Acts