Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:09:16

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2021 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 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/MagneticField/MagneticFieldContext.hpp"
0013 #include "Acts/Utilities/Any.hpp"
0014 #include "Acts/Utilities/Result.hpp"
0015 
0016 #include <array>
0017 #include <memory>
0018 
0019 namespace Acts {
0020 
0021 /// @defgroup MagneticField Magnetic field
0022 
0023 /// Base class for all magnetic field providers
0024 class MagneticFieldProvider {
0025  public:
0026   /// Opaque cache type that can store arbitrary implementation specific cache
0027   /// data. Examples are an interpolation cell, or an experiment specific
0028   /// conditions data handle.
0029   using Cache = Acts::AnyBase<sizeof(char) * 512>;
0030 
0031   /// Make an opaque cache for the magnetic field. Instructs the specific
0032   /// implementation to generate a @c Cache instance for magnetic field lookup.
0033   ///
0034   /// @param mctx The magnetic field context to generate cache for
0035   /// @return Cache The opaque cache object
0036   virtual Cache makeCache(const MagneticFieldContext& mctx) const = 0;
0037 
0038   /// Retrieve magnetic field value at a given location. Requires a cache object
0039   /// created through makeCache().
0040   ///
0041   /// @param [in] position global 3D position for the lookup
0042   /// @param [in,out] cache Field provider specific cache object
0043   ///
0044   /// @return magnetic field vector at given position
0045   virtual Result<Vector3> getField(const Vector3& position,
0046                                    Cache& cache) const = 0;
0047 
0048   /// Retrieve magnetic field value its its gradient. Requires a cache object
0049   /// created through makeCache().
0050   ///
0051   /// @param [in]  position   global 3D position
0052   /// @param [out] derivative gradient of magnetic field vector as (3x3) matrix
0053   /// @param [in,out] cache Field provider specific cache object
0054   /// @return magnetic field vector
0055   virtual Result<Vector3> getFieldGradient(const Vector3& position,
0056                                            ActsMatrix<3, 3>& derivative,
0057                                            Cache& cache) const = 0;
0058 
0059   virtual ~MagneticFieldProvider();
0060 };
0061 
0062 inline MagneticFieldProvider::~MagneticFieldProvider() = default;
0063 
0064 }  // namespace Acts