BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnNewFieldMap.cxx
Go to the documentation of this file.
1
// -------------------------------------------------------------------------
2
// ----- BmnNewFieldMap source file -----
3
// ----- Created 03/02/2015 by P. Batyuk -----
4
// -------------------------------------------------------------------------
5
#include "
BmnNewFieldMap.h
"
6
7
#include "
BmnFieldPar.h
"
8
#include "FairRun.h"
9
#include "FairRuntimeDb.h"
10
#include "
TArrayF.h
"
11
#include "
TMath.h
"
12
13
using namespace
TMath
;
14
15
BmnNewFieldMap::BmnNewFieldMap
()
16
:
BmnFieldMap
()
17
{
18
fType = 1;
19
}
20
21
BmnNewFieldMap::BmnNewFieldMap
(
const
char
* mapFileName)
22
:
BmnFieldMap
(mapFileName)
23
{
24
fType = 1;
25
}
26
27
BmnNewFieldMap::BmnNewFieldMap
(
BmnFieldPar
* fieldPar)
28
:
BmnFieldMap
(fieldPar)
29
{
30
fType = 1;
31
}
32
33
BmnNewFieldMap::~BmnNewFieldMap
() {}
34
35
Double_t
BmnNewFieldMap::GetBx
(
Double_t
x,
Double_t
y,
Double_t
z)
36
{
37
return
FieldInterpolate
(
fBx
, x, y, z);
38
}
39
40
Double_t
BmnNewFieldMap::GetBy
(
Double_t
x,
Double_t
y,
Double_t
z)
41
{
42
return
FieldInterpolate
(
fBy
, x, y, z);
43
}
44
45
Double_t
BmnNewFieldMap::GetBz
(
Double_t
x,
Double_t
y,
Double_t
z)
46
{
47
return
FieldInterpolate
(
fBz
, x, y, z);
48
}
49
50
Bool_t
BmnNewFieldMap::IsInside
(
Double_t
x,
51
Double_t
y,
52
Double_t
z,
53
Int_t
& ix,
54
Int_t
& iy,
55
Int_t
& iz,
56
Double_t
& dx,
57
Double_t
& dy,
58
Double_t
& dz)
59
{
60
// --- Check for being outside the map range
61
if
(x < fXmin || x >=
fXmax
|| y < fYmin || y >=
fYmax
|| z < fZmin || z >=
fZmax
) {
62
ix = iy = iz = 0;
63
dx = dy = dz = 0.;
64
return
kFALSE
;
65
}
66
67
// Relative distance from grid point (in units of cell size) and grid cell numbers
68
69
Double_t
xx, yy, zz;
70
xx = (x -
fXmin
) /
fXstep
;
71
yy = (y -
fYmin
) /
fYstep
;
72
zz = (z -
fZmin
) /
fZstep
;
73
ix =
Int_t
(xx);
74
iy =
Int_t
(yy);
75
iz =
Int_t
(zz);
76
dx = xx -
Double_t
(ix);
77
dy = yy -
Double_t
(iy);
78
dz = zz -
Double_t
(iz);
79
80
return
kTRUE
;
81
}
82
83
Double_t
BmnNewFieldMap::FieldInterpolate
(
TArrayF
* fcomp,
Double_t
x,
Double_t
y,
Double_t
z)
84
{
85
Int_t
ix = 0;
86
Int_t
iy = 0;
87
Int_t
iz = 0;
88
Double_t
dx = 0.;
89
Double_t
dy = 0.;
90
Double_t
dz = 0.;
91
92
if
(x < fXmin || x >=
fXmax
|| y < fYmin || y >=
fYmax
|| z < fZmin || z >=
fZmax
) {
93
return
0.;
94
}
95
96
// Relative distance from grid point (in units of cell size) and grid cell numbers
97
98
Double_t
xx, yy, zz;
99
xx = (x -
fXmin
) /
fXstep
;
100
yy = (y -
fYmin
) /
fYstep
;
101
zz = (z -
fZmin
) /
fZstep
;
102
ix =
Int_t
(xx);
103
iy =
Int_t
(yy);
104
iz =
Int_t
(zz);
105
dx = xx -
Double_t
(ix);
106
dy = yy -
Double_t
(iy);
107
dz = zz -
Double_t
(iz);
108
109
Int_t
ixyz1 = ix *
fNy
*
fNz
+ iy *
fNz
+ iz;
110
Int_t
ixyz2 = ixyz1 +
fNy
*
fNz
;
111
Int_t
ixyz3 = ixyz1 +
fNz
;
112
Int_t
ixyz4 = ixyz2 +
fNz
;
113
114
fHa
[0][0][0] = fcomp->
At
(ixyz1);
115
fHa
[1][0][0] = fcomp->
At
(ixyz2);
116
fHa
[0][1][0] = fcomp->
At
(ixyz3);
117
fHa
[1][1][0] = fcomp->
At
(ixyz4);
118
fHa
[0][0][1] = fcomp->
At
(ixyz1 + 1);
119
fHa
[1][0][1] = fcomp->
At
(ixyz2 + 1);
120
fHa
[0][1][1] = fcomp->
At
(ixyz3 + 1);
121
fHa
[1][1][1] = fcomp->
At
(ixyz4 + 1);
122
123
return
Interpolate
(dx, dy, dz);
124
}
125
126
void
BmnNewFieldMap::FillParContainer
()
127
{
128
TString
MapName = GetName();
129
LOG(debug) <<
"BmnNewFieldMap::FillParContainer() "
;
130
FairRun* fRun = FairRun::Instance();
131
FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
132
// Bool_t kParameterMerged = kTRUE;
133
BmnFieldPar
* fieldPar = (
BmnFieldPar
*)rtdb->getContainer(
"BmnFieldPar"
);
134
fieldPar->
SetParameters
(
this
);
135
fieldPar->setInputVersion(fRun->GetRunId(), 1);
136
fieldPar->setChanged();
137
}
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
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::GetBx
TArrayF * GetBx() const
Accessors to the field value arrays.
Definition
BmnFieldMap.h:96
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::fZmin
Double_t fZmin
Definition
BmnFieldMap.h:144
BmnFieldMap::GetBz
TArrayF * GetBz() const
Definition
BmnFieldMap.h:98
BmnFieldMap::fYmax
Double_t fYmax
Definition
BmnFieldMap.h:143
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::fXmax
Double_t fXmax
Definition
BmnFieldMap.h:142
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
BmnNewFieldMap::BmnNewFieldMap
BmnNewFieldMap()
Definition
BmnNewFieldMap.cxx:15
BmnNewFieldMap::FieldInterpolate
Double_t FieldInterpolate(TArrayF *fcomp, Double_t x, Double_t y, Double_t z)
Definition
BmnNewFieldMap.cxx:83
BmnNewFieldMap::IsInside
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
BmnNewFieldMap.cxx:50
BmnNewFieldMap::FillParContainer
void FillParContainer()
Definition
BmnNewFieldMap.cxx:126
BmnNewFieldMap::~BmnNewFieldMap
virtual ~BmnNewFieldMap()
Definition
BmnNewFieldMap.cxx:33
TArrayF
TArrayF::At
Float_t At(Int_t i) const
TString
BmnFieldPar.h
BmnNewFieldMap.h
TMath
field
BmnNewFieldMap.cxx
Generated on
for BmnRoot by
1.17.0