Skip to content
Snippets Groups Projects
Commit 57dcd2c7 authored by Sergey Gorbunov's avatar Sergey Gorbunov
Browse files

Kf refit: proper initialization of the no-field case

parent 043446e8
No related branches found
No related tags found
1 merge request!1904Ca: update of the track fit utilities
......@@ -17,13 +17,16 @@ using namespace cbm::algo::ca;
//
template<typename DataT>
bool FieldRegion<DataT>::fgForceUseOfOriginalField = false;
template<typename DataT>
std::function<std::tuple<double, double, double>(double x, double y, double z)>
FieldRegion<DataT>::fgOdiginalField([](double, double, double) {
FieldRegion<DataT>::fgOriginalField([](double, double, double) {
assert(false && "ca::FieldRegion: The original field is not set, use cbm::ca::tools::SetCbmField()");
return std::tuple(kfdefs::Undef<double>, kfdefs::Undef<double>, kfdefs::Undef<double>);
});
template<typename DataT>
bool FieldRegion<DataT>::fgIsZeroOriginalField = false;
//----------------------------------------------------------------------------------------------------------------------
//
......
......@@ -220,7 +220,13 @@ namespace cbm::algo::ca
FieldValue<DataT> Get(const DataT& x, const DataT& y, const DataT& z) const;
/// Is the field region empty?
bool IsZeroField() const { return fIsZeroField; }
bool IsZeroField() const
{
if (fgForceUseOfOriginalField || fUseOriginalField) {
return fgIsZeroOriginalField;
}
return fIsZeroField;
}
/// Interpolates the magnetic field by three nodal points and sets the result to this FieldRegion object
/// The result is a quadratic interpolation of the field as a function of z
......@@ -278,9 +284,11 @@ namespace cbm::algo::ca
static void ForceUseOfOriginalField(bool v = true) { fgForceUseOfOriginalField = v; }
/// Set the original field
static void SetOriginalField(std::function<std::tuple<double, double, double>(double x, double y, double z)> f)
static void SetOriginalField(std::function<std::tuple<double, double, double>(double x, double y, double z)> f,
bool isZeroField)
{
fgOdiginalField = f;
fgOriginalField = f;
fgIsZeroOriginalField = isZeroField;
}
/// \brief Copies all/one entries from the other class
......@@ -295,7 +303,8 @@ namespace cbm::algo::ca
public:
static bool fgForceUseOfOriginalField;
static std::function<std::tuple<double, double, double>(double x, double y, double z)> fgOdiginalField;
static std::function<std::tuple<double, double, double>(double x, double y, double z)> fgOriginalField;
static bool fgIsZeroOriginalField;
// TODO: Probably it's better to have arrays instead of separate fvec values? (S.Zharko)
// Bx(z) = cx0 + cx1*(z-z0) + cx2*(z-z0)^2
......@@ -368,7 +377,7 @@ namespace cbm::algo::ca
} // CopyBase
/// \brief Explicit instantiation declarations for FieldRegion class with specific template types to ensure proper fgOdiginalField definition
/// \brief Explicit instantiation declarations for FieldRegion class with specific template types to ensure proper fgOriginalField definition
extern template class FieldRegion<fvec>;
extern template class FieldRegion<float>;
extern template class FieldRegion<double>;
......
......@@ -37,7 +37,12 @@ namespace cbm::ca::tools
return std::tuple(0., 0., 0.);
}
};
ca::FieldRegion<ca::fvec>::SetOriginalField(fld);
if (FairRunAna::Instance()->GetField()) {
ca::FieldRegion<ca::fvec>::SetOriginalField(fld, false);
}
else {
ca::FieldRegion<ca::fvec>::SetOriginalField(fld, true);
}
}
} // namespace cbm::ca::tools
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment