BmnRoot 26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnParamLayout.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 BmnParamLayout class header-only implementation
10 Traversable description of the alignment parameter set
11*/
12
13#ifndef BMNPARAMLAYOUT_H
14#define BMNPARAMLAYOUT_H
15
16#include <TString.h>
17#include <string>
18#include <vector>
19
20// Rebuild() reads it, but the hierarchy owns a layout in turn - so only the
21// declaration is visible here, and the definition lives in BmnParamLayout.cxx
23
24/*
25 * Parameter layout
26 * ================
27 *
28 * BmnAlignHierarchy defines *what* the parameters are - which element or
29 * composite node each belongs to, and how the levels propagate into one
30 * another. This class describes *where* each of them lives, so that the code
31 * working with parameters never computes an index itself.
32 *
33 * One ParamRef per parameter of the full layout is precomputed on Rebuild()
34 * and handed out by the traversal ranges below. Everything a loop over
35 * parameters used to derive by hand - the owning element, which of the six
36 * corrections it is, what to print it as - is a field of the reference.
37 *
38 * BmnAlignHierarchy::EndBuild() calls Rebuild(). The name pointers refer to
39 * the node names owned by the hierarchy, so it has to outlive the layout
40 * built from it.
41 */
42
44{
45 Int_t full{-1}; // index in the full layout; for a leaf parameter also its row of J
46 Int_t leaf{-1}; // detector element index, -1 for a composite parameter
47 Int_t comp{-1}; // index in the composite block (its column of J), -1 for a leaf parameter
48 Int_t node{-1}; // index of the owning object in ByNode()
49 Int_t prm{0}; // which correction, 0..BMN_GLOBAL_PARAMS_PD-1
50 Int_t level{0}; // hierarchy depth of the owning node
51 const char* nodeName{""}; // owned by the hierarchy, see the note above
52 const char* prmName{""}; // one of BmnParamLayout::ParamNames()
53
54 Bool_t IsComposite() const noexcept { return comp >= 0; }
55 // how the parameter is named in reports, e.g. "STA07 dZ"
56 TString Label() const { return TString::Format("%s %s", nodeName, prmName); }
57};
58
59// One alignable object - a detector element or a composite node - with the
60// BMN_GLOBAL_PARAMS_PD corrections it carries. Reporting and serialization are
61// written per object rather than per parameter, and this is what they walk.
62struct NodeRef
63{
64 const char* name{""};
66 Int_t leaf{-1}; // detector element index, -1 for a composite
67 std::vector<ParamRef> params;
68
69 Bool_t IsComposite() const noexcept { return leaf < 0; }
70};
71
73{
74 public:
75 typedef std::vector<ParamRef> Range_t;
76 typedef std::vector<NodeRef> Nodes_t;
77
78 BmnParamLayout() = default;
79 virtual ~BmnParamLayout() = default;
80
81 /*
82 * Names of the six rigid-body corrections, in parameter order. They are the
83 * vocabulary of the layout: reports label parameters with them, and the
84 * config files address parameters and declare the alignment type by them -
85 * which makes this list part of the file format, not a display detail.
86 * One definition, in the .cxx, so a header cannot hand out copies of it.
87 */
88 static const std::vector<std::string>& ParamNames();
89 static const char* ParamName(Int_t p); // "" if out of range
90 static Int_t ParamIndex(const std::string& name); // -1 if unknown
91
92 void Rebuild(const BmnAlignHierarchy& hierarchy);
93
94 Int_t Size() const noexcept { return static_cast<Int_t>(fAll.size()); }
95
96 // traversal ranges, all in full-layout order
97 const Range_t& All() const noexcept { return fAll; }
98 const Range_t& Leaves() const noexcept { return fLeaves; }
99 const Range_t& Composites() const noexcept { return fComposites; }
100 // the same parameters grouped by the object owning them, elements first
101 const Nodes_t& ByNode() const noexcept { return fByNode; }
102
103 // direct access by full-layout index, for config loaders addressing a
104 // parameter the user named rather than walking the set
105 const ParamRef& operator[](Int_t full) const { return fAll[full]; }
106
107 // the object a config file addressed by name, null if there is no such one
108 inline const NodeRef* Find(const std::string& name) const;
109
110 protected:
113};
114
115// === inline implementation ====================================================
116
117inline const NodeRef* BmnParamLayout::Find(const std::string& name) const
118{
119 for (const NodeRef& node : fByNode)
120 if (name == node.name)
121 return &node;
122 return nullptr;
123}
124
125#endif // BMNPARAMLAYOUT_H
bool Bool_t
int Int_t
static Int_t ParamIndex(const std::string &name)
std::vector< NodeRef > Nodes_t
const Nodes_t & ByNode() const noexcept
static const char * ParamName(Int_t p)
const NodeRef * Find(const std::string &name) const
BmnParamLayout()=default
std::vector< ParamRef > Range_t
const Range_t & All() const noexcept
const ParamRef & operator[](Int_t full) const
const Range_t & Leaves() const noexcept
Int_t Size() const noexcept
void Rebuild(const BmnAlignHierarchy &hierarchy)
const Range_t & Composites() const noexcept
virtual ~BmnParamLayout()=default
static const std::vector< std::string > & ParamNames()
static TString Format(const char *fmt,...)
const char * name
Bool_t IsComposite() const noexcept
std::vector< ParamRef > params
Int_t level
const char * nodeName
const char * prmName
TString Label() const
Bool_t IsComposite() const noexcept