BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnATestTrack.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: Igor Polev, polev@jinr.ru
7
8
BmnATestTrack class header-only implementation
9
Minimalistic representation of random linear track
10
(for alignment algorithm test only)
11
*/
12
13
#ifndef BMNATESTTRACK_H
14
#define BMNATESTTRACK_H
15
16
#include "
BmnATestHit.h
"
17
#include "
BmnAlignDefines.h
"
18
#include "
BmnAlignResult.h
"
19
#include "
BmnAligner.h
"
20
#include "
TPolyLine3D.h
"
21
22
#include <stdexcept>
23
24
#define BMN_TEST_TRACK_SOLID_COLOR kBlack
25
#define BMN_TEST_TRACK_NONSOLID_COLOR kMagenta
26
#define BMN_TEST_TRACK_DEF_MAX_Z 500.0
27
28
class
BmnATestTrack
29
{
30
private
:
31
// according to _VBCK_ line is defined as:
32
// x = AlphaX1 + AlphaX2 * z
33
// y = AlphaY1 + AlphaY2 * z
34
// see readme.md for details
35
SVectLC
fAlpha
;
36
SVect3
fVertex
,
fDirection
;
37
Int_t
fMaxHits
,
fHitsCnt
{0};
38
BmnATestHit
**
fpHits
;
39
40
protected
:
41
typedef
BmnAligner<BmnATestHit>
BmnAlignerClass
;
42
43
public
:
44
BmnATestTrack
() =
delete
;
45
BmnATestTrack
(
SVectLC
Alpha,
Int_t
nHits);
46
BmnATestTrack
(
Double_t
Alpha1Sigma,
Double_t
Alpha2Min,
Double_t
Alpha2Max,
Int_t
nHits);
47
~BmnATestTrack
() {
delete
[]
fpHits
; }
48
49
const
SVectLC
&
GetAlpha
() const noexcept {
return
fAlpha
; }
50
const
SVect3
&
GetVertex
() const noexcept {
return
fVertex
; }
51
const
SVect3
&
GetDirection
() const noexcept {
return
fDirection
; }
52
53
void
AddHit
(
BmnATestHit
& hit);
54
void
AddMSE
(
BmnAlignerClass
* pAligner,
Bool_t
withResiduals =
kFALSE
)
const
;
55
56
Double_t
X
(
Double_t
z)
const
noexcept
{
return
fAlpha
(
iX0
) +
fAlpha
(
iX1
) * z; }
57
Double_t
Y
(
Double_t
z)
const
noexcept
{
return
fAlpha
(
iY0
) +
fAlpha
(
iY1
) * z; }
58
59
// for ROOT macro mode only
60
void
Draw
(
Bool_t
solid =
kTRUE
,
Double_t
maxZ =
BMN_TEST_TRACK_DEF_MAX_Z
)
const
;
61
};
62
63
inline
BmnATestTrack::BmnATestTrack
(
SVectLC
Alpha,
Int_t
nHits)
64
: fAlpha(Alpha)
65
, fMaxHits(nHits)
66
{
67
fVertex
=
SVect3
({
fAlpha
(
iX0
),
fAlpha
(
iY0
), 0.0});
68
fDirection
=
SVect3
({
fAlpha
(
iX1
),
fAlpha
(
iY1
), 1.0});
69
70
fpHits
=
new
BmnATestHit*[
fMaxHits
];
71
for
(Int_t
i
= 0;
i
<
fMaxHits
;
i
++)
72
fpHits
[
i
] =
nullptr
;
73
}
74
75
inline
BmnATestTrack::BmnATestTrack
(
Double_t
Alpha1Sigma,
Double_t
Alpha2Min,
Double_t
Alpha2Max,
Int_t
nHits)
76
: fMaxHits(nHits)
77
{
78
fAlpha
(
iX0
) =
BMN_RND
.
Gaus
(0.0, Alpha1Sigma);
79
fAlpha
(
iY0
) =
BMN_RND
.
Gaus
(0.0, Alpha1Sigma);
80
fAlpha
(
iX1
) =
BMN_RND
.
Uniform
(Alpha2Min, Alpha2Max);
81
fAlpha
(
iY1
) =
BMN_RND
.
Uniform
(Alpha2Min, Alpha2Max);
82
fVertex
=
SVect3
({
fAlpha
(
iX0
),
fAlpha
(
iY0
), 0.0});
83
fDirection
=
SVect3
({
fAlpha
(
iX1
),
fAlpha
(
iY1
), 1.0});
84
85
fpHits
=
new
BmnATestHit*[
fMaxHits
];
86
for
(Int_t
i
= 0;
i
<
fMaxHits
;
i
++)
87
fpHits
[
i
] =
nullptr
;
88
}
89
90
inline
void
BmnATestTrack::AddHit
(
BmnATestHit
& hit)
91
{
92
if
(
fHitsCnt
>=
fMaxHits
)
93
throw
std::runtime_error(
"BmnATestTrack::AddHit: too many hits"
);
94
fpHits
[
fHitsCnt
++] = &hit;
95
}
96
97
inline
void
BmnATestTrack::AddMSE
(BmnAlignerClass* pAligner,
Bool_t
withResiduals)
const
98
{
99
if
(!
fpHits
)
100
throw
std::runtime_error(
"BmnATestTrack::AddResiduals: hits not registered"
);
101
Double_t
z, delta, omega;
102
BmnAlignResult&
result
{*pAligner->GetCurrentResult()};
103
104
for
(Int_t
i
= 0;
i
<
fHitsCnt
;
i
++) {
105
Int_t
detectorIdx{
static_cast<
Int_t
>
(
fpHits
[
i
]->GetDetectorID())};
106
const
SVectGL
& A =
result
.A(detectorIdx);
107
z =
fpHits
[
i
]->GetZ() + A(
iZ
);
108
109
omega = pAligner->OmegaScaleFactor() *
fpHits
[
i
]->GetWx();
110
delta =
fpHits
[
i
]->GetX() + A(
iX
) -
X
(z);
111
result
.AddValueMSE(detectorIdx, omega * delta * delta);
112
if
(withResiduals)
113
result
.ResidualsX().Fill(delta);
114
115
omega = pAligner->OmegaScaleFactor() *
fpHits
[
i
]->GetWy();
116
delta =
fpHits
[
i
]->GetY() + A(
iY
) -
Y
(z);
117
result
.AddValueMSE(detectorIdx, omega * delta * delta);
118
if
(withResiduals)
119
result
.ResidualsY().Fill(delta);
120
}
121
}
122
123
// visualization works in ROOT macro mode only
124
inline
void
BmnATestTrack::Draw
(
Bool_t
solid,
Double_t
maxZ)
const
125
{
126
Double_t
x[2]{
X
(0.0),
X
(maxZ)}, y[2]{
Y
(0.0),
Y
(maxZ)}, z[2]{0.0, maxZ};
127
// note: x and z axis are swapped
128
auto
* line =
new
TPolyLine3D(2, z, y, x);
129
if
(solid)
130
line->SetLineColor(
BMN_TEST_TRACK_SOLID_COLOR
);
131
else
{
132
line->SetLineColor(
BMN_TEST_TRACK_NONSOLID_COLOR
);
133
line->SetLineStyle(2);
134
}
135
line->Draw();
136
// draw hits if known
137
if
(
fpHits
)
138
for
(Int_t
i
= 0;
i
<
fHitsCnt
;
i
++)
139
if
(
fpHits
[
i
])
140
fpHits
[
i
]->Draw();
141
142
// in macro mode we don't clean RAM, sorry
143
}
144
145
#endif
// BMNATESTTRACK_H
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
TPolyLine3D.h
iY1
@ iY1
Definition
BmnAlignDefines.h:95
iY0
@ iY0
Definition
BmnAlignDefines.h:94
iX1
@ iX1
Definition
BmnAlignDefines.h:93
iX0
@ iX0
Definition
BmnAlignDefines.h:92
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
SVect3
ROOT::Math::SVector< Double_t, 3 > SVect3
Definition
BmnAlignDefines.h:71
SVectLC
ROOT::Math::SVector< Double_t, BMN_LOCAL_PARAMS_PT > SVectLC
Definition
BmnAlignDefines.h:72
iZ
@ iZ
Definition
BmnAlignDefines.h:87
iX
@ iX
Definition
BmnAlignDefines.h:85
iY
@ iY
Definition
BmnAlignDefines.h:86
BmnATestHit
Definition
BmnATestHit.h:20
BmnATestTrack
Definition
BmnATestTrack.h:29
BmnATestTrack::~BmnATestTrack
~BmnATestTrack()
Definition
BmnATestTrack.h:47
BmnATestTrack::fMaxHits
Int_t fMaxHits
Definition
BmnATestTrack.h:37
BmnATestTrack::GetVertex
const SVect3 & GetVertex() const noexcept
Definition
BmnATestTrack.h:50
BmnATestTrack::fAlpha
SVectLC fAlpha
Definition
BmnATestTrack.h:35
BmnATestTrack::GetAlpha
const SVectLC & GetAlpha() const noexcept
Definition
BmnATestTrack.h:49
BmnATestTrack::fVertex
SVect3 fVertex
Definition
BmnATestTrack.h:36
BmnATestTrack::AddMSE
void AddMSE(BmnAlignerClass *pAligner, Bool_t withResiduals=kFALSE) const
BmnATestTrack::fDirection
SVect3 fDirection
Definition
BmnATestTrack.h:36
BmnATestTrack::BmnATestTrack
BmnATestTrack(Double_t Alpha1Sigma, Double_t Alpha2Min, Double_t Alpha2Max, Int_t nHits)
BmnATestTrack::BmnATestTrack
BmnATestTrack()=delete
BmnATestTrack::Y
Double_t Y(Double_t z) const noexcept
Definition
BmnATestTrack.h:57
BmnATestTrack::X
Double_t X(Double_t z) const noexcept
Definition
BmnATestTrack.h:56
BmnATestTrack::BmnATestTrack
BmnATestTrack(SVectLC Alpha, Int_t nHits)
BmnATestTrack::Draw
void Draw(Bool_t solid=kTRUE, Double_t maxZ=BMN_TEST_TRACK_DEF_MAX_Z) const
BmnATestTrack::BmnAlignerClass
BmnAligner< BmnATestHit > BmnAlignerClass
Definition
BmnATestTrack.h:41
BmnATestTrack::GetDirection
const SVect3 & GetDirection() const noexcept
Definition
BmnATestTrack.h:51
BmnATestTrack::AddHit
void AddHit(BmnATestHit &hit)
BmnATestTrack::fHitsCnt
Int_t fHitsCnt
Definition
BmnATestTrack.h:37
BmnATestTrack::fpHits
BmnATestHit ** fpHits
Definition
BmnATestTrack.h:38
BmnAligner
Definition
BmnAligner.h:37
TRandom::Gaus
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
TRandom::Uniform
virtual Double_t Uniform(Double_t x1, Double_t x2)
BmnATestHit.h
BMN_TEST_TRACK_DEF_MAX_Z
#define BMN_TEST_TRACK_DEF_MAX_Z
Definition
BmnATestTrack.h:26
BMN_TEST_TRACK_SOLID_COLOR
#define BMN_TEST_TRACK_SOLID_COLOR
Definition
BmnATestTrack.h:24
BMN_TEST_TRACK_NONSOLID_COLOR
#define BMN_TEST_TRACK_NONSOLID_COLOR
Definition
BmnATestTrack.h:25
BmnAlignDefines.h
BmnAlignResult.h
BmnAligner.h
nlohmann::result
json_pointer result
Definition
json.hpp:11939
install
include
BmnATestTrack.h
Generated on
for BmnRoot by
1.17.0