13#ifndef BMNALIGNHIERARCHY_H
14#define BMNALIGNHIERARCHY_H
19#include "fairlogger/Logger.h"
109 const std::string& parent,
136 const std::vector<Node_t>&
Nodes() const noexcept {
return fNodes; }
184 for (std::size_t
i = 0;
i <
fNodes.size();
i++)
186 return static_cast<Int_t>(
i);
191 const std::string& parent,
196 LOG(error) <<
" <!> AddComposite: BeginBuild() was not called";
200 LOG(error) <<
" <!> AddComposite: node name must not be empty";
204 LOG(error) <<
" <!> AddComposite: duplicate node name '" << name <<
"'";
208 if (!parent.empty()) {
211 LOG(error) <<
" <!> AddComposite: node '" << name <<
"' refers to unknown parent '" << parent <<
"'";
214 if (
fNodes[parentIdx].leaf >= 0) {
215 LOG(error) <<
" <!> AddComposite: node '" << name <<
"' cannot descend from leaf '" << parent <<
"'";
231 for (
Int_t leafIdx : leaves) {
233 LOG(error) <<
" <!> AddComposite: node '" << name <<
"' lists element " << leafIdx <<
" out of range [0, "
237 if (
fNodes[leafIdx].parent >= 0) {
238 LOG(error) <<
" <!> AddComposite: element " << leafIdx <<
" already belongs to '"
239 <<
fNodes[
fNodes[leafIdx].parent].name <<
"', cannot also belong to '" << name <<
"'";
242 fNodes[leafIdx].parent = nodeIdx;
254 LOG(error) <<
" <!> EndBuild: BeginBuild() was not called";
260 Int_t level{0}, walk{node.parent};
263 LOG(error) <<
" <!> EndBuild: parent cycle detected at node '" << node.name <<
"'";
266 walk =
fNodes[walk].parent;
280 if (walk == nodeIdx) {
287 LOG(error) <<
" <!> EndBuild: composite '" << node.
name <<
"' owns no detector element";
292 LOG_IF(warning, cnt == 1) <<
" ! composite '" << node.
name
293 <<
"' owns a single element: its motion is"
294 " already fully described by that element's own parameters";
310 ownsDirect =
fNodes[l].parent == nodeIdx;
311 LOG_IF(warning, !ownsDirect) <<
" ! composite '" <<
fNodes[nodeIdx].name
312 <<
"' owns every element"
313 " through child nodes: its parameters are a combination of theirs,"
314 " so the data cannot separate the two levels at all - the split"
315 " rests on the presigmas alone and converges slowly";
335 LOG(info) <<
Form(
" level %d : %-12s pivot (%.3f, %.3f, %.3f) cm", node.
level, node.
name.c_str(),
345 fJ(row + p, col + p) = 1.0;
374 rows.
SetSub(0, nLeaf, cComp);
397 mC_h.
SetSub(0, nLeaf, mCJ);
400 vB_h.
SetSub(nLeaf, mJT * vB);
407 hier.
GetSub(0, nLeaf - 1, leaf);
445 const TMatrixD covLC{hier.
GetSub(0, nLeaf - 1, nLeaf, last)}, covCL{hier.
GetSub(nLeaf, last, 0, nLeaf - 1)},
446 covCC{hier.
GetSub(nLeaf, last, nLeaf, last)};
std::vector< Double_t > VecDouble_t
RM::SVector< Double_t, 3 > SVect3
std::vector< Int_t > VecInt_t
#define BMN_GLOBAL_PARAMS_PD
TMatrixT< Double_t > TMatrixD
char * Form(const char *fmt,...)
TVectorT< Double_t > TVectorD
Int_t LeafCount() const noexcept
const TMatrixD & J() const noexcept
Int_t FindNode(const std::string &name) const
Int_t LeafParams() const noexcept
Int_t CompositeCount() const noexcept
Bool_t BuildFlat(const BmnDetectorModel &detModel)
virtual ~BmnAlignHierarchy()=default
const std::vector< Node_t > & Nodes() const noexcept
Int_t AllParams() const noexcept
void ToEffectiveCov(const TMatrixD &hier, TMatrixD &eff) const
const BmnParamLayout & Layout() const noexcept
Int_t CompositeParams() const noexcept
Bool_t Ready() const noexcept
void PromoteSystem(const TVectorD &vB, const TMatrixD &mC, TVectorD &vB_h, TMatrixD &mC_h) const
BmnAlignHierarchy()=default
Int_t CompositeParamBase() const noexcept
std::vector< Node_t > fNodes
void BeginBuild(const BmnDetectorModel &detModel, const VecDouble_t &leafZ)
void FillBlock(Int_t row, Int_t col, const SVect3 &dP)
const BmnDetectorModel * DetModel() const noexcept
TMatrixD PromoteConstraints(const TMatrixD &constraints) const
const BmnDetectorModel * fpDetModel
Bool_t AddComposite(const std::string &name, const std::string &parent, const VecInt_t &leaves, const SVect3 *pivot)
void ToLeaf(const TVectorD &hier, TVectorD &leaf) const
Int_t EncodedID(Int_t idx) const
virtual std::string DecodeID(Int_t id) const =0
virtual Int_t Alignables() const =0
TMatrixT< Element > GetSub(Int_t row_lwb, Int_t row_upb, Int_t col_lwb, Int_t col_upb, Option_t *option="S") const
TMatrixTBase< Element > & ResizeTo(const TMatrixT< Element > &m)
TMatrixTBase< Element > & SetSub(Int_t row_lwb, Int_t col_lwb, const TMatrixTBase< Element > &source) override
TVectorT< Element > & Zero()
TVectorT< Element > & SetSub(Int_t row_lwb, const TVectorT< Element > &source)
TVectorT< Element > & ResizeTo(const TVectorT< Element > &v)
TVectorT< Element > GetSub(Int_t row_lwb, Int_t row_upb, Option_t *option="S") const