BmnRoot 26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnAlignPriors.h
Go to the documentation of this file.
1/*
2 BM@N alignment routine
3 BM@N experiment at NICA complex, JINR, 2025
4
5 Department: Math & Soft Group of HEP lab
6 Author: Claude (Opus 5)
7 Supervisor: Igor Polev, polev@jinr.int
8
9 BmnAlignPriors class declaration
10 Prior knowledge about the alignment: constraints and presigmas
11*/
12
13#ifndef BMNALIGNPRIORS_H
14#define BMNALIGNPRIORS_H
15
16#include "BmnAlignHierarchy.h"
17
18#include <TMatrixD.h>
19#include <TVectorD.h>
20
21/*
22 * Everything the fit is told before it sees a single hit, in the form the
23 * solver consumes it:
24 *
25 * - constraints : exact linear relations the solution must satisfy, entering
26 * the system as Lagrange multiplier rows.
27 * - presigmas : per-parameter prior uncertainties, entering as
28 * pseudo-measurements "parameter == reference +/- sigma" (see Apply).
29 *
30 * Both are addressed in the full layout of BmnAlignHierarchy. BmnAlignConfig
31 * fills this from JSON; BmnAligner and BmnAlignReport only read it.
32 *
33 * They are also the way to hold an element in place. A constraint on a leaf
34 * pins its effective correction, so the element does not move at all. A
35 * tight presigma pins its own share only, so it still moves with its
36 * ancestors.
37 *
38 * Data is public on purpose: this is the parsed content of two config files,
39 * and the loaders write it field by field. The two members below carry the
40 * behaviour that belongs with the data rather than with either consumer.
41 */
42
44{
45 public:
46 // --- constraints -----------------------------------------------------
47 // constraints * A = rhs, one row per constraint, columns in the full layout
50 Bool_t inhomogeneous{kFALSE}; // any non-zero right-hand side
51
52 // --- presigmas -------------------------------------------------------
53 VecDouble_t sigma; // prior sigma per full-layout parameter; <= 0 means "no prior"
54 VecDouble_t ref; // value the prior pulls towards
55 Int_t presigmaCount{0}; // parameters that actually carry one
56
57 // sizes the presigma arrays and records the layout the addressing is in.
58 // Call once the hierarchy is built and before either loader runs.
59 void Init(const BmnAlignHierarchy& hierarchy)
60 {
61 fAllParams = hierarchy.AllParams();
62 sigma.assign(fAllParams, 0.0);
63 ref.assign(fAllParams, 0.0);
64 presigmaCount = 0;
65 constraints.ResizeTo(0, fAllParams);
66 rhs.ResizeTo(0);
68 fKept.clear();
69 fKeptRows.ResizeTo(0, 0);
70 }
71
72 Int_t ConstCount() const noexcept { return constraints.GetNrows(); }
73 Bool_t UsePresigmas() const noexcept { return presigmaCount > 0; }
74 // the independent constraints, found by Check(): their indices into
75 // constraints / rhs, and their rows promoted to the solved basis
76 const VecInt_t& Kept() const noexcept { return fKept; }
77 const TMatrixD& KeptRows() const noexcept { return fKeptRows; }
78 Int_t KeptCount() const noexcept { return static_cast<Int_t>(fKept.size()); }
79 // presigmas are absent altogether when no file was given, hence the guard
80 Double_t SigmaAt(Int_t full) const noexcept { return full < static_cast<Int_t>(sigma.size()) ? sigma[full] : 0.0; }
81
82 // Folds the presigmas into an already reduced system, as pseudo-measurements
83 // of the parameters they refer to. accA is the accumulated solution in the
84 // full layout (effective leaf corrections), null on the first iteration;
85 // leaf priors are measured against its own-share part.
86 void Apply(TVectorD& vB, TMatrixD& mC, const BmnAlignHierarchy& hierarchy, const TVectorD* accA) const;
87
88 // Finds the independent constraints (see Kept()). kFALSE if the constraints
89 // contradict each other, or if the composite parameters of the hierarchy are
90 // not all determined by what is configured here, i.e. if the fit would be
91 // singular along some direction of the level split. Logs the reason.
92 Bool_t Check(const BmnAlignHierarchy& hierarchy);
93
94 protected:
95 Int_t fAllParams{0}; // the layout everything above is addressed in
96 VecInt_t fKept; // see Kept()
97 TMatrixD fKeptRows; // see KeptRows()
98};
99
100#endif // BMNALIGNPRIORS_H
std::vector< Double_t > VecDouble_t
std::vector< Int_t > VecInt_t
bool Bool_t
int Int_t
constexpr Bool_t kFALSE
double Double_t
TMatrixT< Double_t > TMatrixD
TVectorT< Double_t > TVectorD
Int_t AllParams() const noexcept
Double_t SigmaAt(Int_t full) const noexcept
VecDouble_t ref
VecDouble_t sigma
void Apply(TVectorD &vB, TMatrixD &mC, const BmnAlignHierarchy &hierarchy, const TVectorD *accA) const
void Init(const BmnAlignHierarchy &hierarchy)
TMatrixD constraints
Bool_t Check(const BmnAlignHierarchy &hierarchy)
const VecInt_t & Kept() const noexcept
Bool_t UsePresigmas() const noexcept
const TMatrixD & KeptRows() const noexcept
Int_t KeptCount() const noexcept
Int_t ConstCount() const noexcept