BmnRoot
26.10.0-18-g4e3414f9
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.ru
7
8
BmnATestDetector implementation
9
*/
10
11
#include "
BmnATestDetector.h
"
12
13
#include "fairlogger/Logger.h"
14
15
#include <fstream>
16
#include <
nlohmann/json.hpp
>
17
18
BmnATestDetector::BmnATestDetector
(
Double_t
detectorStep,
const
char
* dumpPath)
19
:
BmnSimpleDetModel
(
BMN_TEST_MODULE_COUNT
)
20
{
21
LOG(info) <<
" > Generating "
<<
BMN_TEST_MODULE_COUNT
<<
" test detectors planes"
;
22
23
Double_t
nominalZ = detectorStep;
24
for
(
Int_t
i
= 0;
i
<
BMN_TEST_MODULE_COUNT
;
i
++) {
// first detector is fixed
25
for
(
Int_t
j =
iX
; j <=
iZ
; j++) {
26
if
(
i
> 0)
27
fMisalignments
[
i
](j) =
BMN_RND
.Gaus(0.0,
BMN_ALIGN_PARAM_TOLERENCE
);
28
// if (i == 2 && j == iX)
29
// fMisalignments[i](j) = 0.1;
30
}
31
fNominalZ
[
i
] = nominalZ;
32
nominalZ += detectorStep;
33
}
34
35
if
(dumpPath)
36
Save
(dumpPath);
37
RebuildDetectors
();
38
}
39
40
Bool_t
BmnATestDetector::Save
(
const
char
* path)
const
41
{
42
LOG(info) <<
" Saving test detectors planes to "
<< path;
43
std::ofstream ofs(path);
44
if
(!ofs.good()) {
45
LOG(error) <<
" <!> failed to open JSON file "
<< path;
46
return
kFALSE
;
47
}
48
49
nlohmann::json
j;
50
j[
"nominal_z"
] =
fNominalZ
;
51
j[
"misalignments"
] = nlohmann::json::array();
52
for
(
Int_t
i
= 0;
i
<
BMN_TEST_MODULE_COUNT
;
i
++) {
53
j[
"misalignments"
].push_back({
fMisalignments
[
i
](
iX
),
fMisalignments
[
i
](
iY
),
fMisalignments
[
i
](
iZ
)});
54
}
55
56
ofs << j.dump(2);
57
return
kTRUE
;
58
}
59
60
Bool_t
BmnATestDetector::Load
(
const
char
* path)
61
{
62
LOG(info) <<
" > Loading test detectors planes from "
<< path;
63
std::ifstream ifs(path);
64
if
(!ifs.good()) {
65
LOG(error) <<
" <!> failed to open JSON file "
<< path;
66
return
kFALSE
;
67
}
68
nlohmann::json
j;
69
ifs >> j;
70
71
const
auto
& jz = j[
"nominal_z"
];
72
const
auto
& jm = j[
"misalignments"
];
73
74
if
(jz.size() != jm.size()) {
75
LOG(error) <<
" <!> inconsistent number of detector planes in JSON file "
<< path;
76
return
kFALSE
;
77
}
78
79
for
(
Int_t
i
= 0;
i
<
BMN_TEST_MODULE_COUNT
;
i
++) {
80
fNominalZ
[
i
] = jz[
i
].get<
double
>();
81
fMisalignments
[
i
] =
82
SVectGL
(jm[
i
][
static_cast<
Int_t
>
(
iX
)].get<double>(), jm[
i
][
static_cast<
Int_t
>
(
iY
)].get<double>(),
83
jm[
i
][
static_cast<
Int_t
>
(
iZ
)].get<double>());
84
}
85
86
RebuildDetectors
();
87
return
kTRUE
;
88
}
89
90
void
BmnATestDetector::RebuildDetectors
()
91
{
92
for
(
Int_t
i
= 0;
i
<
BMN_TEST_MODULE_COUNT
;
i
++)
93
fDetectors
[
i
] =
BmnATestDetectorPlane
(
fNominalZ
[
i
],
fMisalignments
[
i
],
i
);
94
}
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
BmnATestDetector.h
BMN_ALIGN_PARAM_TOLERENCE
#define BMN_ALIGN_PARAM_TOLERENCE
Definition
BmnAlignDefines.h:61
BMN_TEST_MODULE_COUNT
#define BMN_TEST_MODULE_COUNT
Definition
BmnAlignDefines.h:55
BMN_RND
static TRandom3 BMN_RND
Definition
BmnAlignDefines.h:101
SVectGL
ROOT::Math::SVector< Double_t, BMN_GLOBAL_PARAMS_PD > SVectGL
Definition
BmnAlignDefines.h:73
iZ
@ iZ
Definition
BmnAlignDefines.h:87
iX
@ iX
Definition
BmnAlignDefines.h:85
iY
@ iY
Definition
BmnAlignDefines.h:86
BmnATestDetectorPlane
Definition
BmnATestDetectorPlane.h:27
BmnATestDetector::fMisalignments
SVectGL fMisalignments[BMN_TEST_MODULE_COUNT]
Definition
BmnATestDetector.h:43
BmnATestDetector::BmnATestDetector
BmnATestDetector(Double_t detectorStep, const char *dumpPath=nullptr)
Definition
BmnATestDetector.cxx:18
BmnATestDetector::fNominalZ
Double_t fNominalZ[BMN_TEST_MODULE_COUNT]
Definition
BmnATestDetector.h:42
BmnATestDetector::Save
Bool_t Save(const char *path) const
Definition
BmnATestDetector.cxx:40
BmnATestDetector::fDetectors
BmnATestDetectorPlane fDetectors[BMN_TEST_MODULE_COUNT]
Definition
BmnATestDetector.h:44
BmnATestDetector::RebuildDetectors
void RebuildDetectors()
Definition
BmnATestDetector.cxx:90
BmnATestDetector::Load
Bool_t Load(const char *path)
Definition
BmnATestDetector.cxx:60
BmnSimpleDetModel::BmnSimpleDetModel
BmnSimpleDetModel()=delete
json.hpp
nlohmann::json
basic_json<> json
default specialization
Definition
json.hpp:3365
align_new
src
BmnATestDetector.cxx
Generated on
for BmnRoot by
1.17.0