Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-08 08:18:01

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0013 #include "Acts/MagneticField/MagneticFieldProvider.hpp"
0014 
0015 namespace Acts {
0016 
0017 /// Null bfield which returns 0 always
0018 ///
0019 /// @ingroup magnetic_field
0020 class NullBField final : public MagneticFieldProvider {
0021  public:
0022   /// Cache object for the null magnetic field provider.
0023   struct Cache {
0024     /// @brief constructor with context
0025     explicit Cache(const MagneticFieldContext& /*mcfg*/) {}
0026   };
0027 
0028   /// @brief Default constructor
0029   NullBField() = default;
0030 
0031   /// @copydoc MagneticFieldProvider::getField(const Vector3&,MagneticFieldProvider::Cache&) const
0032   ///
0033   /// @note The @p position is ignored and only kept as argument to provide
0034   ///       a consistent interface with other magnetic field services.
0035   Result<Vector3> getField(const Vector3& position,
0036                            MagneticFieldProvider::Cache& cache) const override {
0037     static_cast<void>(position);
0038     static_cast<void>(cache);
0039     return Result<Vector3>::success(Vector3::Zero());
0040   }
0041 
0042   /// @copydoc MagneticFieldProvider::makeCache(const MagneticFieldContext&) const
0043   Acts::MagneticFieldProvider::Cache makeCache(
0044       const Acts::MagneticFieldContext& mctx) const override {
0045     return Acts::MagneticFieldProvider::Cache(std::in_place_type<Cache>, mctx);
0046   }
0047 
0048   /// @brief check whether given 3D position is inside look-up domain
0049   ///
0050   /// @return @c true if position is inside the defined look-up grid,
0051   ///         otherwise @c false
0052   /// @note The method will always return true for the null B-Field
0053   bool isInside(const Vector3& /*position*/) const { return true; }
0054 };
0055 
0056 }  // namespace Acts