BmnRoot
26.10.0-233-gb9bbe585
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnATestDetector.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: Igor Polev, polev@jinr.int
7
8
BmnATestDetector implementation
9
*/
10
11
/*
12
=== DEPRECATION NOTICE =========================================
13
Due to complex changes in BmnAligner, this class requires rework
14
================================================================
15
*/
16
17
#include "
BmnATestDetector.h
"
18
19
#include "fairlogger/Logger.h"
20
21
#include <fstream>
22
#include <nlohmann/json.hpp>
23
24
BmnATestDetector::BmnATestDetector
(
Double_t
detectorStep,
const
char
* dumpPath)
25
:
BmnSimpleDM
(BMN_TEST_MODULE_COUNT)
26
{
27
LOG(info) <<
" > Generating "
<< BMN_TEST_MODULE_COUNT <<
" test detectors planes"
;
28
29
Double_t
nominalZ = detectorStep;
30
for
(
Int_t
i
= 0;
i
< BMN_TEST_MODULE_COUNT;
i
++) {
// first detector is fixed
31
for
(
Int_t
j =
iX
; j <=
iZ
; j++) {
32
if
(
i
> 0)
33
fMisalignments
[
i
](j) = BMN_RND.Gaus(0.0, BMN_ALIGN_PARAM_TOLERENCE);
34
// if (i == 2 && j == iX)
35
// fMisalignments[i](j) = 0.1;
36
}
37
fNominalZ
[
i
] = nominalZ;
38
nominalZ += detectorStep;
39
}
40
41
if
(dumpPath)
42
Save
(dumpPath);
43
RebuildDetectors
();
44
}
45
46
Bool_t
BmnATestDetector::Save
(
const
char
* path)
const
47
{
48
LOG(info) <<
" Saving test detectors planes to "
<< path;
49
std::ofstream ofs(path);
50
if
(!ofs.good()) {
51
LOG(error) <<
" <!> failed to open JSON file "
<< path;
52
return
kFALSE
;
53
}
54
55
nlohmann::json j;
56
j[
"nominal_z"
] =
fNominalZ
;
57
j[
"misalignments"
] = nlohmann::json::array();
58
for
(
Int_t
i
= 0;
i
< BMN_TEST_MODULE_COUNT;
i
++) {
59
j[
"misalignments"
].push_back({
fMisalignments
[
i
](
iX
),
fMisalignments
[
i
](
iY
),
fMisalignments
[
i
](
iZ
)});
60
}
61
62
ofs << j.dump(2);
63
return
kTRUE
;
64
}
65
66
Bool_t
BmnATestDetector::Load
(
const
char
* path)
67
{
68
LOG(info) <<
" > Loading test detectors planes from "
<< path;
69
std::ifstream ifs(path);
70
if
(!ifs.good()) {
71
LOG(error) <<
" <!> failed to open JSON file "
<< path;
72
return
kFALSE
;
73
}
74
nlohmann::json j;
75
ifs >> j;
76
77
const
auto
& jz = j[
"nominal_z"
];
78
const
auto
& jm = j[
"misalignments"
];
79
80
if
(jz.size() != jm.size()) {
81
LOG(error) <<
" <!> inconsistent number of detector planes in JSON file "
<< path;
82
return
kFALSE
;
83
}
84
85
for
(
Int_t
i
= 0;
i
< BMN_TEST_MODULE_COUNT;
i
++) {
86
fNominalZ
[
i
] = jz[
i
].get<
double
>();
87
fMisalignments
[
i
] =
88
SVectGL
(jm[
i
][
static_cast<
Int_t
>
(
iX
)].get<double>(), jm[
i
][
static_cast<
Int_t
>
(
iY
)].get<double>(),
89
jm[
i
][
static_cast<
Int_t
>
(
iZ
)].get<double>());
90
}
91
92
RebuildDetectors
();
93
return
kTRUE
;
94
}
95
96
void
BmnATestDetector::RebuildDetectors
()
97
{
98
for
(
Int_t
i
= 0;
i
< BMN_TEST_MODULE_COUNT;
i
++)
99
fDetectors
[
i
] =
BmnATestDetectorPlane
(
fNominalZ
[
i
],
fMisalignments
[
i
],
i
);
100
}
BmnATestDetector.h
SVectGL
RM::SVector< Double_t, BMN_GLOBAL_PARAMS_PD > SVectGL
Definition
BmnAlignDefines.h:61
iZ
@ iZ
Definition
BmnAlignDefines.h:27
iX
@ iX
Definition
BmnAlignDefines.h:25
iY
@ iY
Definition
BmnAlignDefines.h:26
i
int i
Definition
P4_F32vec4.h:22
Bool_t
bool Bool_t
Int_t
int Int_t
kFALSE
constexpr Bool_t kFALSE
Double_t
double Double_t
kTRUE
constexpr Bool_t kTRUE
BmnATestDetectorPlane
Definition
BmnATestDetectorPlane.h:33
BmnATestDetector::fMisalignments
SVectGL fMisalignments[BMN_TEST_MODULE_COUNT]
Definition
BmnATestDetector.h:49
BmnATestDetector::fDetectors
BmnATestDetectorPlane fDetectors[BMN_TEST_MODULE_COUNT]
Definition
BmnATestDetector.h:50
BmnATestDetector::BmnATestDetector
BmnATestDetector(Double_t detectorStep, const char *dumpPath=nullptr)
Definition
BmnATestDetector.cxx:24
BmnATestDetector::Save
Bool_t Save(const char *path) const
Definition
BmnATestDetector.cxx:46
BmnATestDetector::RebuildDetectors
void RebuildDetectors()
Definition
BmnATestDetector.cxx:96
BmnATestDetector::Load
Bool_t Load(const char *path)
Definition
BmnATestDetector.cxx:66
BmnATestDetector::fNominalZ
Double_t fNominalZ[BMN_TEST_MODULE_COUNT]
Definition
BmnATestDetector.h:48
BmnSimpleDM::BmnSimpleDM
BmnSimpleDM()=delete
align_new
deprecated
BmnATestDetector.cxx
Generated on
for BmnRoot by
1.17.0