CbmRoot
Loading...
Searching...
No Matches
KfFieldSlice.h
Go to the documentation of this file.
1/* Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergei Zharko [committer] */
4
9
10#pragma once
11
12#include "KfDefs.h"
13#include "KfFieldValue.h"
14#include "KfMath.h"
15#include "KfTrackParam.h"
16#include "KfUtils.h"
17
18#include <boost/serialization/access.hpp>
19#include <boost/serialization/array.hpp>
20
21#include <array>
22#include <functional>
23#include <string>
24
25namespace cbm::algo::kf
26{
30 template<typename T>
31 class alignas(VcMemAlign) FieldSlice {
32 template<typename>
33 friend class FieldSlice;
34
35 static constexpr int kPolDegree{5};
36 static constexpr int kNofCoeff{((kPolDegree + 1) * (kPolDegree + 2)) / 2};
37
39 using CoeffArray_t = std::array<T, kNofCoeff>;
40
41 public:
43 FieldSlice() = default;
44
50 FieldSlice(const FieldFn_t& fieldFn, double xMax, double yMax, double zRef);
51
54 template<typename I>
56 : fBx(utils::simd::Cast<I, T, kNofCoeff>(other.fBx))
57 , fBy(utils::simd::Cast<I, T, kNofCoeff>(other.fBy))
58 , fBz(utils::simd::Cast<I, T, kNofCoeff>(other.fBz))
59 , fZref(utils::simd::Cast<I, T>(other.fZref))
60 {
61 }
62
64 ~FieldSlice() = default;
65
67 FieldSlice& operator=(const FieldSlice& other) = default;
68
73 constexpr FieldValue<T> GetFieldValue(const T& x, const T& y) const
74 {
75 using math::Horner;
76 return FieldValue<T>(Horner<kPolDegree>(fBx.cbegin(), x, y), //
77 Horner<kPolDegree>(fBy.cbegin(), x, y), //
78 Horner<kPolDegree>(fBz.cbegin(), x, y));
79 }
80
84 constexpr FieldValue<T> GetFieldValueForLine(const TrackParam<T>& trkPar) const
85 {
86 T dz = fZref - trkPar.GetZ();
87 return GetFieldValue(trkPar.GetX() + trkPar.GetTx() * dz, trkPar.GetY() + trkPar.GetTy() * dz);
88 }
89
91 const T& GetZref() const { return fZref; }
92
96 std::string ToString(int indentLevel = 0, int verbose = 1) const;
97
99 void CheckConsistency() const;
100
101 private:
103 friend class boost::serialization::access;
104 template<class Archive>
105 void serialize(Archive& ar, const unsigned int)
106 {
107 ar& fBx;
108 ar& fBy;
109 ar& fBz;
110 ar& fZref;
111 }
112
113 CoeffArray_t fBx{{T(0.)}};
114 CoeffArray_t fBy{{T(0.)}};
115 CoeffArray_t fBz{{T(0.)}};
116 T fZref{defs::Undef<T>};
117 };
118} // namespace cbm::algo::kf
std::string ToString(ECbmModuleId modId)
Definition CbmDefs.cxx:70
Common constant definitions for the Kalman Filter library.
Magnetic flux density vector representation.
Collection of generic mathematical methods.
A magnetic field approximation on the two-dimensional plane.
void serialize(Archive &ar, const unsigned int)
~FieldSlice()=default
Destructor.
FieldSlice & operator=(const FieldSlice &other)=default
Copy assignment operator.
FieldSlice(const FieldSlice< I > &other)
Copy constructor.
const T & GetZref() const
Gets reference z-coordinate of the slice [cm].
FieldSlice()=default
Default constructor.
constexpr FieldValue< T > GetFieldValueForLine(const TrackParam< T > &trkPar) const
Gets field value for the intersection with a straight track.
std::array< T, kNofCoeff > CoeffArray_t
Array of the approximation coefficients [<monomial>].
constexpr FieldValue< T > GetFieldValue(const T &x, const T &y) const
Gets field value at a point on the transverse plane.
Magnetic flux density vector.
T GetTy() const
Gets slope along y-axis.
T GetZ() const
Gets z position [cm].
T GetTx() const
Gets slope along x-axis.
T GetY() const
Gets y position [cm].
T GetX() const
Gets x position [cm].
TrackParam classes of different types.
std::function< std::tuple< double, double, double >(double, double, double)> FieldFn_t
Magnetic field function type Signature: tuple<Bx, By, Bz>(x, y, z);.
Definition KfDefs.h:66