BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnFieldMapSym3.cxx
Go to the documentation of this file.
1
// -------------------------------------------------------------------------
2
// ----- BmnFieldMapSym3 source file -----
3
// ----- Created 12/01/04 by M. Al/Turany (BmnField.cxx) -----
4
// ----- Redesign 13/02/06 by V. Friese -----
5
// -------------------------------------------------------------------------
6
7
#include "
BmnFieldMapSym3.h
"
8
9
#include "FairRun.h"
10
#include "FairRuntimeDb.h"
11
#include "
TArrayF.h
"
12
#include "
TMath.h
"
13
14
using namespace
TMath
;
15
16
// ------------- Default constructor ----------------------------------
17
BmnFieldMapSym3::BmnFieldMapSym3
()
18
:
BmnFieldMap
()
19
,
fHemiX
(0.)
20
,
fHemiY
(0.)
21
,
fHemiZ
(0.)
22
{
23
fType = 3;
24
}
25
26
// ------------- Standard constructor ---------------------------------
27
BmnFieldMapSym3::BmnFieldMapSym3
(
const
char
* mapName)
28
:
BmnFieldMap
(mapName)
29
,
fHemiX
(0.)
30
,
fHemiY
(0.)
31
,
fHemiZ
(0.)
32
{
33
fType = 3;
34
}
35
36
// ------------- Constructor from BmnFieldPar -------------------------
37
BmnFieldMapSym3::BmnFieldMapSym3
(
BmnFieldPar
* fieldPar)
38
:
BmnFieldMap
(fieldPar)
39
,
fHemiX
(0.)
40
,
fHemiY
(0.)
41
,
fHemiZ
(0.)
42
{
43
fType = 3;
44
}
45
46
// ------------ Destructor --------------------------------------------
47
BmnFieldMapSym3::~BmnFieldMapSym3
() {}
48
49
// ----------- Get x component of the field ---------------------------
50
Double_t
BmnFieldMapSym3::GetBx
(
Double_t
x,
Double_t
y,
Double_t
z)
51
{
52
Int_t
ix = 0;
53
Int_t
iy = 0;
54
Int_t
iz = 0;
55
Double_t
dx = 0.;
56
Double_t
dy = 0.;
57
Double_t
dz = 0.;
58
59
if
(
IsInside
(x, y, z, ix, iy, iz, dx, dy, dz)) {
60
// Get Bx field values at grid cell corners
61
fHa
[0][0][0] =
fBx
->At(ix *
fNy
*
fNz
+ iy *
fNz
+ iz);
62
fHa
[1][0][0] =
fBx
->At((ix + 1) *
fNy
*
fNz
+ iy *
fNz
+ iz);
63
fHa
[0][1][0] =
fBx
->At(ix *
fNy
*
fNz
+ (iy + 1) *
fNz
+ iz);
64
fHa
[1][1][0] =
fBx
->At((ix + 1) *
fNy
*
fNz
+ (iy + 1) *
fNz
+ iz);
65
fHa
[0][0][1] =
fBx
->At(ix *
fNy
*
fNz
+ iy *
fNz
+ (iz + 1));
66
fHa
[1][0][1] =
fBx
->At((ix + 1) *
fNy
*
fNz
+ iy *
fNz
+ (iz + 1));
67
fHa
[0][1][1] =
fBx
->At(ix *
fNy
*
fNz
+ (iy + 1) *
fNz
+ (iz + 1));
68
fHa
[1][1][1] =
fBx
->At((ix + 1) *
fNy
*
fNz
+ (iy + 1) *
fNz
+ (iz + 1));
69
70
// Return interpolated field value
71
return
Interpolate
(dx, dy, dz) *
fHemiX
*
fHemiY
;
72
}
73
74
return
0.;
75
}
76
77
// ----------- Get y component of the field ---------------------------
78
Double_t
BmnFieldMapSym3::GetBy
(
Double_t
x,
Double_t
y,
Double_t
z)
79
{
80
Int_t
ix = 0;
81
Int_t
iy = 0;
82
Int_t
iz = 0;
83
Double_t
dx = 0.;
84
Double_t
dy = 0.;
85
Double_t
dz = 0.;
86
87
if
(
IsInside
(x, y, z, ix, iy, iz, dx, dy, dz)) {
88
89
// Get By field values at grid cell corners
90
fHa
[0][0][0] =
fBy
->At(ix *
fNy
*
fNz
+ iy *
fNz
+ iz);
91
fHa
[1][0][0] =
fBy
->At((ix + 1) *
fNy
*
fNz
+ iy *
fNz
+ iz);
92
fHa
[0][1][0] =
fBy
->At(ix *
fNy
*
fNz
+ (iy + 1) *
fNz
+ iz);
93
fHa
[1][1][0] =
fBy
->At((ix + 1) *
fNy
*
fNz
+ (iy + 1) *
fNz
+ iz);
94
fHa
[0][0][1] =
fBy
->At(ix *
fNy
*
fNz
+ iy *
fNz
+ (iz + 1));
95
fHa
[1][0][1] =
fBy
->At((ix + 1) *
fNy
*
fNz
+ iy *
fNz
+ (iz + 1));
96
fHa
[0][1][1] =
fBy
->At(ix *
fNy
*
fNz
+ (iy + 1) *
fNz
+ (iz + 1));
97
fHa
[1][1][1] =
fBy
->At((ix + 1) *
fNy
*
fNz
+ (iy + 1) *
fNz
+ (iz + 1));
98
99
// Return interpolated field value
100
return
Interpolate
(dx, dy, dz);
101
}
102
return
0.;
103
}
104
105
// ----------- Get z component of the field ---------------------------
106
Double_t
BmnFieldMapSym3::GetBz
(
Double_t
x,
Double_t
y,
Double_t
z)
107
{
108
Int_t
ix = 0;
109
Int_t
iy = 0;
110
Int_t
iz = 0;
111
Double_t
dx = 0.;
112
Double_t
dy = 0.;
113
Double_t
dz = 0.;
114
115
if
(
IsInside
(x, y, z, ix, iy, iz, dx, dy, dz)) {
116
117
// Get Bz field values at grid cell corners
118
fHa
[0][0][0] =
fBz
->At(ix *
fNy
*
fNz
+ iy *
fNz
+ iz);
119
fHa
[1][0][0] =
fBz
->At((ix + 1) *
fNy
*
fNz
+ iy *
fNz
+ iz);
120
fHa
[0][1][0] =
fBz
->At(ix *
fNy
*
fNz
+ (iy + 1) *
fNz
+ iz);
121
fHa
[1][1][0] =
fBz
->At((ix + 1) *
fNy
*
fNz
+ (iy + 1) *
fNz
+ iz);
122
fHa
[0][0][1] =
fBz
->At(ix *
fNy
*
fNz
+ iy *
fNz
+ (iz + 1));
123
fHa
[1][0][1] =
fBz
->At((ix + 1) *
fNy
*
fNz
+ iy *
fNz
+ (iz + 1));
124
fHa
[0][1][1] =
fBz
->At(ix *
fNy
*
fNz
+ (iy + 1) *
fNz
+ (iz + 1));
125
fHa
[1][1][1] =
fBz
->At((ix + 1) *
fNy
*
fNz
+ (iy + 1) *
fNz
+ (iz + 1));
126
127
// Return interpolated field value
128
return
Interpolate
(dx, dy, dz) *
fHemiY
*
fHemiZ
;
129
}
130
131
return
0.;
132
}
133
134
// ----------- Check whether a point is inside the map ----------------
135
Bool_t
BmnFieldMapSym3::IsInside
(
Double_t
x,
136
Double_t
y,
137
Double_t
z,
138
Int_t
& ix,
139
Int_t
& iy,
140
Int_t
& iz,
141
Double_t
& dx,
142
Double_t
& dy,
143
Double_t
& dz)
144
{
145
// --- Transform into local coordinate system
146
Double_t
xl = x -
fPosX
;
147
Double_t
yl = y -
fPosY
;
148
Double_t
zl = z -
fPosZ
;
149
150
// --- Reflect w.r.t. symmetry axes
151
fHemiX
=
fHemiY
=
fHemiZ
= 1.;
152
if
(xl < 0.) {
153
fHemiX
= -1.;
154
xl = -1. * xl;
155
}
156
if
(yl < 0.) {
157
fHemiY
= -1.;
158
yl = -1. * yl;
159
}
160
if
(zl < 0.) {
161
fHemiZ
= -1.;
162
zl = -1. * zl;
163
}
164
165
// --- Check for being outside the map range
166
if
(!(xl >=
fXmin
&& xl < fXmax && yl >=
fYmin
&& yl < fYmax && zl >=
fZmin
&& zl <
fZmax
)) {
167
ix = iy = iz = 0;
168
dx = dy = dz = 0.;
169
return
kFALSE
;
170
}
171
172
// --- Determine grid cell
173
ix =
Int_t
((xl -
fXmin
) /
fXstep
);
174
iy =
Int_t
((yl -
fYmin
) /
fYstep
);
175
iz =
Int_t
((zl -
fZmin
) /
fZstep
);
176
177
// Relative distance from grid point (in units of cell size)
178
dx = (xl -
fXmin
) /
fXstep
-
Double_t
(ix);
179
dy = (yl -
fYmin
) /
fYstep
-
Double_t
(iy);
180
dz = (zl -
fZmin
) /
fZstep
-
Double_t
(iz);
181
182
return
kTRUE
;
183
}
184
185
void
BmnFieldMapSym3::FillParContainer
()
186
{
187
TString
MapName = GetName();
188
// LOG(info) << "BmnFieldMapSym3::FillParContainer() ";
189
FairRun* fRun = FairRun::Instance();
190
FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
191
// Bool_t kParameterMerged = kTRUE;
192
BmnFieldPar
* fieldPar = (
BmnFieldPar
*)rtdb->getContainer(
"BmnFieldPar"
);
193
fieldPar->
SetParameters
(
this
);
194
fieldPar->setInputVersion(fRun->GetRunId(), 1);
195
fieldPar->setChanged();
196
}
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
TArrayF.h
TMath.h
BmnFieldMapSym3::fHemiX
Double_t fHemiX
Hemispheres of a point (for temporary use).
Definition
BmnFieldMapSym3.h:74
BmnFieldMapSym3::IsInside
virtual Bool_t IsInside(Double_t x, Double_t y, Double_t z, Int_t &ix, Int_t &iy, Int_t &iz, Double_t &dx, Double_t &dy, Double_t &dz)
Determine whether a point is inside the field map.
Definition
BmnFieldMapSym3.cxx:135
BmnFieldMapSym3::fHemiZ
Double_t fHemiZ
Definition
BmnFieldMapSym3.h:74
BmnFieldMapSym3::FillParContainer
void FillParContainer()
Definition
BmnFieldMapSym3.cxx:185
BmnFieldMapSym3::BmnFieldMapSym3
BmnFieldMapSym3()
Default constructor.
Definition
BmnFieldMapSym3.cxx:17
BmnFieldMapSym3::~BmnFieldMapSym3
virtual ~BmnFieldMapSym3()
Destructor.
Definition
BmnFieldMapSym3.cxx:47
BmnFieldMapSym3::fHemiY
Double_t fHemiY
Definition
BmnFieldMapSym3.h:74
BmnFieldMap::fHa
Double_t fHa[2][2][2]
Variables for temporary storage Used in the very frequently called method GetFieldValue.
Definition
BmnFieldMap.h:156
BmnFieldMap::fBy
TArrayF * fBy
Definition
BmnFieldMap.h:151
BmnFieldMap::fPosZ
Double_t fPosZ
Definition
BmnFieldMap.h:138
BmnFieldMap::GetBx
TArrayF * GetBx() const
Accessors to the field value arrays.
Definition
BmnFieldMap.h:96
BmnFieldMap::fPosY
Double_t fPosY
Definition
BmnFieldMap.h:138
BmnFieldMap::GetBy
TArrayF * GetBy() const
Definition
BmnFieldMap.h:97
BmnFieldMap::fBz
TArrayF * fBz
Definition
BmnFieldMap.h:152
BmnFieldMap::Interpolate
Double_t Interpolate(Double_t dx, Double_t dy, Double_t dz)
Get field values by interpolation of the grid.
Definition
BmnFieldMap.cxx:610
BmnFieldMap::fPosX
Double_t fPosX
Field centre position in global coordinates.
Definition
BmnFieldMap.h:138
BmnFieldMap::fZmin
Double_t fZmin
Definition
BmnFieldMap.h:144
BmnFieldMap::GetBz
TArrayF * GetBz() const
Definition
BmnFieldMap.h:98
BmnFieldMap::fXstep
Double_t fXstep
Definition
BmnFieldMap.h:142
BmnFieldMap::fZstep
Double_t fZstep
Definition
BmnFieldMap.h:144
BmnFieldMap::BmnFieldMap
BmnFieldMap()
Definition
BmnFieldMap.cxx:18
BmnFieldMap::fXmin
Double_t fXmin
Field limits in local coordinate system.
Definition
BmnFieldMap.h:142
BmnFieldMap::fNy
Int_t fNy
Definition
BmnFieldMap.h:147
BmnFieldMap::fBx
TArrayF * fBx
Arrays with the field values.
Definition
BmnFieldMap.h:150
BmnFieldMap::fZmax
Double_t fZmax
Definition
BmnFieldMap.h:144
BmnFieldMap::fYmin
Double_t fYmin
Definition
BmnFieldMap.h:143
BmnFieldMap::fYstep
Double_t fYstep
Definition
BmnFieldMap.h:143
BmnFieldMap::fNz
Int_t fNz
Definition
BmnFieldMap.h:147
BmnFieldPar
Definition
BmnFieldPar.h:26
BmnFieldPar::SetParameters
void SetParameters(FairField *field)
Set parameters from BmnField.
Definition
BmnFieldPar.cxx:180
TString
BmnFieldMapSym3.h
TMath
field
BmnFieldMapSym3.cxx
Generated on
for BmnRoot by
1.17.0