File indexing completed on 2025-08-06 08:17:58
0001 #pragma once
0002
0003 #include "PHField.h"
0004
0005 #if defined(__GNUC__) && !defined(__clang__)
0006 #pragma GCC diagnostic push
0007 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
0008 #include <Eigen/Dense>
0009 #pragma GCC diagnostic pop
0010 #else
0011 #include <Eigen/Dense>
0012 #endif
0013
0014 #include <array>
0015 #include <deque>
0016 #include <map>
0017 #include <optional>
0018 #include <string>
0019
0020
0021
0022 class PHFieldInterpolated : public PHField
0023 {
0024 public:
0025 typedef Eigen::Vector3i Indices_t;
0026 typedef Eigen::Vector3f Point_t;
0027 typedef Eigen::Vector3f Field_t;
0028
0029
0030 static int const GRID_COUNT = 111;
0031 static float constexpr GRID_STEP = 20;
0032 static float constexpr GRID_MIN = - GRID_STEP * (GRID_COUNT / 2);
0033 static float constexpr GRID_MAX = + GRID_STEP * (GRID_COUNT / 2);
0034
0035
0036
0037
0038 explicit PHFieldInterpolated () = default;
0039
0040
0041 ~PHFieldInterpolated () override = default;
0042
0043
0044
0045
0046
0047 void GetFieldValue (double const*, double*) const override;
0048
0049
0050 void load_fieldmap (
0051 std::string const& = "/cvmfs/sphenix.sdcc.bnl.gov/alma9.2-gcc-14.2.0/release/release_ana/ana.499/share/calibrations/Field/Map/sphenix3dtrackingmapxyz.root",
0052 const float& = 1.0
0053 );
0054
0055
0056 Eigen::VectorXf get_design_vector (Point_t const&) const;
0057
0058 void cache_interpolation (Point_t const&) const;
0059
0060 Field_t get_interpolated (Point_t const&) const;
0061
0062
0063 static Indices_t get_indices (std::size_t const&);
0064
0065 static std::size_t get_index (Indices_t const&);
0066
0067
0068 static Indices_t get_indices (Point_t const&);
0069
0070 static Point_t get_point (Indices_t const&);
0071
0072
0073 Field_t get_field (std::size_t const& index) const { return m_field.at(index); }
0074
0075 Field_t get_field (Indices_t const& indices) const { return get_field(get_index(indices)); }
0076
0077 Field_t get_field (Point_t const& point) const { return get_field(get_indices(point)); }
0078
0079
0080 static void validate_indices (Indices_t const&);
0081
0082 static void validate_point (Point_t const&);
0083
0084
0085 void print_map() const;
0086
0087
0088 void print_coefficients() const;
0089
0090 private:
0091
0092
0093 std::deque<Field_t> m_field;
0094
0095
0096
0097
0098
0099 mutable Indices_t m_buffered_indices = {-1, -1, -1};
0100
0101 mutable Point_t m_center;
0102
0103
0104 mutable std::array<Eigen::VectorXf, 3> m_coefficients;
0105 };