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