BmnRoot 26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnParamLayout.cxx
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 BmnParamLayout::Rebuild implementation
10
11 Out of line because the layout and the hierarchy each need the other: the
12 hierarchy owns a layout, and rebuilding a layout reads the hierarchy.
13*/
14
15#include "BmnParamLayout.h"
16
17#include "BmnAlignDefines.h"
18#include "BmnAlignHierarchy.h"
19
20#include <utility>
21
22const std::vector<std::string>& BmnParamLayout::ParamNames()
23{
24 static const std::vector<std::string> names{"dX", "dY", "dZ", "phi", "theta", "psi"};
25 return names;
26}
27
29{
30 return (p >= 0 && p < BMN_GLOBAL_PARAMS_PD) ? ParamNames()[p].c_str() : "";
31}
32
33Int_t BmnParamLayout::ParamIndex(const std::string& name)
34{
35 const std::vector<std::string>& names{ParamNames()};
36 for (Int_t p = 0; p < BMN_GLOBAL_PARAMS_PD; p++)
37 if (name == names[p])
38 return p;
39 return -1;
40}
41
43{
44 fAll.clear();
45 fLeaves.clear();
46 fComposites.clear();
47 fByNode.clear();
48 if (!hierarchy.Ready())
49 return;
50
51 // Filled by index rather than by push_back: the node order is an
52 // implementation detail of the hierarchy, while the full layout is defined
53 // by the parameter base of each node, and the config files depend on it.
54 fAll.resize(hierarchy.AllParams());
55 for (const BmnAlignHierarchy::Node_t& node : hierarchy.Nodes()) {
56 const Int_t base{node.leaf >= 0 ? node.leaf * BMN_GLOBAL_PARAMS_PD
57 : hierarchy.CompositeParamBase() + node.composite * BMN_GLOBAL_PARAMS_PD};
58 for (Int_t p = 0; p < BMN_GLOBAL_PARAMS_PD; p++) {
59 ParamRef& ref{fAll[base + p]};
60 ref.full = base + p;
61 ref.leaf = node.leaf;
62 ref.comp = node.composite < 0 ? -1 : node.composite * BMN_GLOBAL_PARAMS_PD + p;
63 ref.node = base / BMN_GLOBAL_PARAMS_PD;
64 ref.prm = p;
65 ref.level = node.level;
66 ref.nodeName = node.name.c_str();
67 ref.prmName = ParamName(p);
68 }
69 }
70
71 fLeaves.reserve(hierarchy.LeafParams());
72 fComposites.reserve(hierarchy.CompositeParams());
73 for (const ParamRef& ref : fAll) {
74 if (ref.IsComposite())
75 fComposites.push_back(ref);
76 else
77 fLeaves.push_back(ref);
78 }
79
80 // full-layout order puts the six corrections of one object side by side,
81 // so the groups are just consecutive slices of fAll
82 fByNode.reserve(fAll.size() / BMN_GLOBAL_PARAMS_PD);
83 for (std::size_t i = 0; i < fAll.size(); i += BMN_GLOBAL_PARAMS_PD) {
84 NodeRef node;
85 node.name = fAll[i].nodeName;
86 node.level = fAll[i].level;
87 node.leaf = fAll[i].leaf;
88 node.params.assign(fAll.begin() + i, fAll.begin() + i + BMN_GLOBAL_PARAMS_PD);
89 fByNode.push_back(std::move(node));
90 }
91}
#define BMN_GLOBAL_PARAMS_PD
int i
Definition P4_F32vec4.h:22
int Int_t
Int_t LeafParams() const noexcept
const std::vector< Node_t > & Nodes() const noexcept
Int_t AllParams() const noexcept
Int_t CompositeParams() const noexcept
Bool_t Ready() const noexcept
Int_t CompositeParamBase() const noexcept
static Int_t ParamIndex(const std::string &name)
static const char * ParamName(Int_t p)
void Rebuild(const BmnAlignHierarchy &hierarchy)
static const std::vector< std::string > & ParamNames()
const char * name
std::vector< ParamRef > params
Int_t level
const char * nodeName
const char * prmName