BmnRoot
26.10.0-210-gc52d34b0
Software framework of the BM@N experiment
Toggle main menu visibility
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
22
class
BmnAlignHierarchy
;
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
43
struct
ParamRef
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.
62
struct
NodeRef
63
{
64
const
char
*
name
{
""
};
65
Int_t
level
{0};
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
72
class
BmnParamLayout
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
:
111
Range_t
fAll
,
fLeaves
,
fComposites
;
112
Nodes_t
fByNode
;
113
};
114
115
// === inline implementation ====================================================
116
117
inline
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_t
bool Bool_t
Int_t
int Int_t
TString.h
BmnAlignHierarchy
Definition
BmnAlignHierarchy.h:89
BmnParamLayout::ParamIndex
static Int_t ParamIndex(const std::string &name)
Definition
BmnParamLayout.cxx:33
BmnParamLayout::Nodes_t
std::vector< NodeRef > Nodes_t
Definition
BmnParamLayout.h:76
BmnParamLayout::ByNode
const Nodes_t & ByNode() const noexcept
Definition
BmnParamLayout.h:101
BmnParamLayout::ParamName
static const char * ParamName(Int_t p)
Definition
BmnParamLayout.cxx:28
BmnParamLayout::fComposites
Range_t fComposites
Definition
BmnParamLayout.h:111
BmnParamLayout::Find
const NodeRef * Find(const std::string &name) const
Definition
BmnParamLayout.h:117
BmnParamLayout::fLeaves
Range_t fLeaves
Definition
BmnParamLayout.h:111
BmnParamLayout::BmnParamLayout
BmnParamLayout()=default
BmnParamLayout::Range_t
std::vector< ParamRef > Range_t
Definition
BmnParamLayout.h:75
BmnParamLayout::All
const Range_t & All() const noexcept
Definition
BmnParamLayout.h:97
BmnParamLayout::operator[]
const ParamRef & operator[](Int_t full) const
Definition
BmnParamLayout.h:105
BmnParamLayout::fAll
Range_t fAll
Definition
BmnParamLayout.h:111
BmnParamLayout::Leaves
const Range_t & Leaves() const noexcept
Definition
BmnParamLayout.h:98
BmnParamLayout::Size
Int_t Size() const noexcept
Definition
BmnParamLayout.h:94
BmnParamLayout::fByNode
Nodes_t fByNode
Definition
BmnParamLayout.h:112
BmnParamLayout::Rebuild
void Rebuild(const BmnAlignHierarchy &hierarchy)
Definition
BmnParamLayout.cxx:42
BmnParamLayout::Composites
const Range_t & Composites() const noexcept
Definition
BmnParamLayout.h:99
BmnParamLayout::~BmnParamLayout
virtual ~BmnParamLayout()=default
BmnParamLayout::ParamNames
static const std::vector< std::string > & ParamNames()
Definition
BmnParamLayout.cxx:22
TString
TString::Format
static TString Format(const char *fmt,...)
NodeRef
Definition
BmnParamLayout.h:63
NodeRef::name
const char * name
Definition
BmnParamLayout.h:64
NodeRef::leaf
Int_t leaf
Definition
BmnParamLayout.h:66
NodeRef::IsComposite
Bool_t IsComposite() const noexcept
Definition
BmnParamLayout.h:69
NodeRef::params
std::vector< ParamRef > params
Definition
BmnParamLayout.h:67
NodeRef::level
Int_t level
Definition
BmnParamLayout.h:65
ParamRef
Definition
BmnParamLayout.h:44
ParamRef::full
Int_t full
Definition
BmnParamLayout.h:45
ParamRef::nodeName
const char * nodeName
Definition
BmnParamLayout.h:51
ParamRef::prm
Int_t prm
Definition
BmnParamLayout.h:49
ParamRef::prmName
const char * prmName
Definition
BmnParamLayout.h:52
ParamRef::Label
TString Label() const
Definition
BmnParamLayout.h:56
ParamRef::leaf
Int_t leaf
Definition
BmnParamLayout.h:46
ParamRef::level
Int_t level
Definition
BmnParamLayout.h:50
ParamRef::IsComposite
Bool_t IsComposite() const noexcept
Definition
BmnParamLayout.h:54
ParamRef::comp
Int_t comp
Definition
BmnParamLayout.h:47
ParamRef::node
Int_t node
Definition
BmnParamLayout.h:48
align_new
src
BmnParamLayout.h
Generated on
for BmnRoot by
1.17.0