18#include <fmt/format.h>
48 auto w21 = -dz2 * det;
50 auto w11 = -dz2 * w21;
51 auto w12 = -dz1 * w22;
53 for (
int iD = 0; iD < 3; ++iD) {
56 auto& coeff = fCoeff[iD];
58 coeff[1] = db1 * w11 + db2 * w12;
59 coeff[2] = db1 * w21 + db2 * w22;
71 auto dz = z - this->fZfirst;
72 return FieldValue<T>{this->fCoeff[0][0] + dz * (this->fCoeff[0][1] + dz * this->fCoeff[0][2]),
73 this->fCoeff[1][0] + dz * (this->fCoeff[1][1] + dz * this->fCoeff[1][2]),
74 this->fCoeff[2][0] + dz * (this->fCoeff[2][1] + dz * this->fCoeff[2][2]), z};
91 T c0 = dz2 * T(1. / 2.);
92 T c1 = dz2 * dz * T(1. / 6.);
93 T c2 = dz2 * dz2 * T(1. / 12.);
94 return {c0 * fld.fCoeff[0][0] + c1 * fld.fCoeff[0][1] + c2 * fld.fCoeff[0][2],
95 c0 * fld.fCoeff[1][0] + c1 * fld.fCoeff[1][1] + c2 * fld.fCoeff[1][2],
96 c0 * fld.fCoeff[2][0] + c1 * fld.fCoeff[2][1] + c2 * fld.fCoeff[2][2]};
104 auto dz = z - fZfirst;
105 for (
int iD = 0; iD < 3; ++iD) {
106 auto& coeff = fCoeff[iD];
107 auto c2dz = coeff[2] * dz;
108 coeff[0] += (coeff[1] + c2dz) * dz;
109 coeff[1] += (2 * c2dz);
120 for (
int iD = 0; iD < 3; ++iD) {
121 for (
int iC = 0; iC < 3; ++iC) {
133 constexpr char IndentChar =
'\t';
134 std::stringstream msg;
135 std::string indent(indentLevel, IndentChar);
138 const auto& coeff = this->fCoeff;
139 msg << indent << format(
"Field Region (EFieldMode::Interpolated): dz = z - ({})", Cnv(this->fZfirst));
141 << indent << IndentChar
142 << format(
"Bx(dz) = {:>12} + {:>12} dz + {:>12} dz2", Cnv(coeff[0][0]), Cnv(coeff[0][1]), Cnv(coeff[0][2]));
144 << indent << IndentChar
145 << format(
"Bx(dz) = {:>12} + {:>12} dz + {:>12} dz2", Cnv(coeff[1][0]), Cnv(coeff[1][1]), Cnv(coeff[1][2]));
147 << indent << IndentChar
148 << format(
"Bx(dz) = {:>12} + {:>12} dz + {:>12} dz2", Cnv(coeff[2][0]), Cnv(coeff[2][1]), Cnv(coeff[2][2]));
151 <<
"\nWARNING: the GlobalField::ForceUseOfOriginalField() is enabled, so the magnetic field interpolation "
153 <<
"\nis replaced with the global magnetic function for debugging purposes. If you see this message and are "
155 <<
"\nnot sure, what is going on, please call GlobalField::ForceUseOfOriginalField(false) and re-run the "
177 constexpr char IndentChar =
'\t';
178 std::stringstream msg;
179 std::string indent(indentLevel, IndentChar);
180 msg << indent <<
"Field region (EFieldMode::Original): type=" <<
static_cast<int>(fFieldType);
200 &&
"cbm::algo::kf::GlobalField: The original globa magnetic field is required by "
201 "kf::defs::dbg::ForceOriginalField = true. Please provide it with the "
202 "kf::GlobalField::SetGlobalField() function.");
Magnetic flux density interpolation along the track vs. z-coordinate (header)
T GetComponent(int iD) const
Gets component by index.
T GetZ() const
Gets z-coordinate of the spatial point [cm].
bool IsZero() const
Checks, if the field value is zero (negligible)
Magnetic field region, corresponding to a hit triplet.
Magnetic flux density vector.
static EFieldType fgOriginalFieldType
Global field type.
static std::tuple< double, double, double > UndefField(double, double, double)
Undefined magnetic field function.
static FieldValue< T > GetFieldValue(const FieldFn_t &fieldFn, T x, T y, T z)
Creates a field value object in a spactial point of a generic floating-point type.
static FieldFn_t fgOriginalField
Global variable to store the field function (x,y,z)->(Bx,By,Bz)
static bool IsUsingOriginalFieldForced()
Checks if the original field function is used.
static bool fgForceUseOfOriginalField
Flag to force the use of the original field in all field classes.
Concrete representation of the FieldRegion class (primary template)
constexpr T2 Undef
Undefined values.
DataOut Cast(const DataT &val)
Converts a value of type DataT to type DataOut.
DataT One()
Returns a value of the data type set to one.
void CheckSimdVectorEquality(fvec v, const char *name)
Checks, if a SIMD vector horizontally equal TODO: Find this method in the VC!
EFieldType
Magnetic field type in different setup regions.
@ Normal
Field near the tracker subsystem.
std::function< std::tuple< double, double, double >(double, double, double)> FieldFn_t
Magnetic field function type Signature: tuple<Bx, By, Bz>(x, y, z);.