BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
BmnFieldPar.cxx
Go to the documentation of this file.
1
// -------------------------------------------------------------------------
2
// ----- BmnFieldPar source file -----
3
// ----- Created 20/02/06 by V. Friese -----
4
// -------------------------------------------------------------------------
5
#include "
BmnFieldPar.h
"
6
7
#include "
BmnFieldConst.h
"
8
#include "
BmnFieldMap.h
"
9
#include "FairParamList.h"
10
11
#include <iostream>
12
using
std::cerr;
13
using
std::cout;
14
using
std::endl;
15
16
const
int
kMaxLen
= 2048;
17
18
// ------ Constructor --------------------------------------------------
19
20
BmnFieldPar::BmnFieldPar
(
const
char
* name,
const
char
* title,
const
char
* context)
21
:
FairParGenericSet
(name, title, context)
22
,
fType
(-1)
23
,
fXmin
(0.)
24
,
fXmax
(0.)
25
,
fYmin
(0.)
26
,
fYmax
(0.)
27
,
fZmin
(0.)
28
,
fZmax
(0.)
29
,
fBx
(0.)
30
,
fBy
(0.)
31
,
fBz
(0.)
32
,
fMapName
(
""
)
33
,
fPosX
(0.)
34
,
fPosY
(0.)
35
,
fPosZ
(0.)
36
,
fScale
(0.)
37
,
fIsOff
(
kFALSE
)
38
,
fDistortionFilename
(
""
)
39
,
fParentName
(
""
)
40
,
fTypeOfParent
(0)
41
{}
42
// -------------------------------------------------------------------------
43
44
BmnFieldPar::BmnFieldPar
()
45
:
FairParGenericSet
()
46
,
fType
(-1)
47
,
fXmin
(0.)
48
,
fXmax
(0.)
49
,
fYmin
(0.)
50
,
fYmax
(0.)
51
,
fZmin
(0.)
52
,
fZmax
(0.)
53
,
fBx
(0.)
54
,
fBy
(0.)
55
,
fBz
(0.)
56
,
fMapName
(
""
)
57
,
fPosX
(0.)
58
,
fPosY
(0.)
59
,
fPosZ
(0.)
60
,
fScale
(0.)
61
,
fIsOff
(
kFALSE
)
62
,
fDistortionFilename
(
""
)
63
,
fParentName
(
""
)
64
,
fTypeOfParent
(0)
65
{}
66
// -------------------------------------------------------------------------
67
68
// ------ Destructor ---------------------------------------------------
69
70
BmnFieldPar::~BmnFieldPar
() {}
71
// -------------------------------------------------------------------------
72
73
// ------ Put parameters -----------------------------------------------
74
75
void
BmnFieldPar::putParams
(FairParamList* list)
76
{
77
78
if
(!list)
79
return
;
80
81
list->add(
"Field Type"
,
fType
);
82
83
if
(
fType
== 0) {
// constant field
84
list->add(
"Field min x"
,
fXmin
);
85
list->add(
"Field max x"
,
fXmax
);
86
list->add(
"Field min y"
,
fYmin
);
87
list->add(
"Field max y"
,
fYmax
);
88
list->add(
"Field min z"
,
fZmin
);
89
list->add(
"Field max z"
,
fZmax
);
90
list->add(
"Field Bx"
,
fBx
);
91
list->add(
"Field By"
,
fBy
);
92
list->add(
"Field Bz"
,
fBz
);
93
list->add(
"Field is off"
,
fIsOff
);
94
}
else
if
(
fType
>= 1 &&
fType
<=
kMaxFieldMapType
) {
// field map
95
list->add(
"Field map name"
,
fMapName
);
96
list->add(
"Field x position"
,
fPosX
);
97
list->add(
"Field y position"
,
fPosY
);
98
list->add(
"Field z position"
,
fPosZ
);
99
list->add(
"Field scaling factor"
,
fScale
);
100
list->add(
"Field is off"
,
fIsOff
);
101
102
if
(
fType
==
kTypeDistorted
) {
// BmnFieldMapDistorted case
103
list->add(
"Field map distortion filename"
,
fDistortionFilename
.Data());
104
list->add(
"Field name of parent field"
,
fParentName
.Data());
105
list->add(
"Field type of parent field"
,
fTypeOfParent
);
106
}
107
}
108
}
109
// -------------------------------------------------------------------------
110
111
// -------- Get parameters ---------------------------------------------
112
113
Bool_t
BmnFieldPar::getParams
(FairParamList* list)
114
{
115
116
if
(!list)
117
return
kFALSE
;
118
119
if
(!list->fill(
"Field Type"
, &
fType
))
120
return
kFALSE
;
121
122
if
(
fType
== 0) {
// constant field
123
if
(!list->fill(
"Field min x"
, &
fXmin
))
124
return
kFALSE
;
125
if
(!list->fill(
"Field max x"
, &
fXmax
))
126
return
kFALSE
;
127
if
(!list->fill(
"Field min y"
, &
fYmin
))
128
return
kFALSE
;
129
if
(!list->fill(
"Field max y"
, &
fYmax
))
130
return
kFALSE
;
131
if
(!list->fill(
"Field min z"
, &
fZmin
))
132
return
kFALSE
;
133
if
(!list->fill(
"Field max z"
, &
fZmax
))
134
return
kFALSE
;
135
if
(!list->fill(
"Field Bx"
, &
fBx
))
136
return
kFALSE
;
137
if
(!list->fill(
"Field By"
, &
fBy
))
138
return
kFALSE
;
139
if
(!list->fill(
"Field Bz"
, &
fBz
))
140
return
kFALSE
;
141
if
(!list->fill(
"Field is off"
, &
fIsOff
))
142
return
kFALSE
;
143
}
else
if
(
fType
>= 1 &&
fType
<=
kMaxFieldMapType
) {
// field map
144
Text_t
mapName[80];
145
if
(!list->fill(
"Field map name"
, mapName, 80))
146
return
kFALSE
;
147
fMapName
= mapName;
148
if
(!list->fill(
"Field x position"
, &
fPosX
))
149
return
kFALSE
;
150
if
(!list->fill(
"Field y position"
, &
fPosY
))
151
return
kFALSE
;
152
if
(!list->fill(
"Field z position"
, &
fPosZ
))
153
return
kFALSE
;
154
if
(!list->fill(
"Field scaling factor"
, &
fScale
))
155
return
kFALSE
;
156
if
(!list->fill(
"Field is off"
, &
fIsOff
))
157
return
kFALSE
;
158
159
if
(
fType
==
kTypeDistorted
) {
// BmnFieldMapDistorted case
160
Text_t
tmp[
kMaxLen
];
161
fDistortionFilename
=
""
;
162
if
(!list->fill(
"Field map distortion filename"
, tmp,
kMaxLen
))
163
return
kFALSE
;
164
fDistortionFilename
= tmp;
165
fParentName
=
""
;
166
if
(!list->fill(
"Field name of parent field"
, tmp,
kMaxLen
))
167
return
kFALSE
;
168
fParentName
= tmp;
169
if
(!list->fill(
"Field type of parent field"
, &
fTypeOfParent
))
170
return
kFALSE
;
171
}
172
}
173
174
return
kTRUE
;
175
}
176
// -------------------------------------------------------------------------
177
178
// --------- Set parameters from BmnField ------------------------------
179
180
void
BmnFieldPar::SetParameters
(
FairField
* field)
181
{
182
183
if
(!field) {
184
cerr <<
"-W- BmnFieldPar::SetParameters: Empty field pointer!"
<< endl;
185
return
;
186
}
187
188
fType
= field->GetType();
189
190
if
(
fType
== 0) {
// constant field
191
BmnFieldConst
* fieldConst = (
BmnFieldConst
*)field;
192
fBx
= fieldConst->
GetBx
();
193
fBy
= fieldConst->
GetBy
();
194
fBz
= fieldConst->
GetBz
();
195
fXmin
= fieldConst->
GetXmin
();
196
fXmax
= fieldConst->
GetXmax
();
197
fYmin
= fieldConst->
GetYmin
();
198
fYmax
= fieldConst->
GetYmax
();
199
fZmin
= fieldConst->
GetZmin
();
200
fZmax
= fieldConst->
GetZmax
();
201
fMapName
=
""
;
202
fPosX
=
fPosY
=
fPosZ
=
fScale
= 0.;
203
fIsOff
= fieldConst->
IsFieldOff
();
204
}
else
if
(
fType
>= 1 &&
fType
<=
kMaxFieldMapType
) {
// field map
205
BmnFieldMap
* fieldMap = (
BmnFieldMap
*)field;
206
fBx
=
fBy
=
fBz
= 0.;
207
fXmin
=
fXmax
=
fYmin
=
fYmax
=
fZmin
=
fZmax
= 0.;
208
209
fMapName
= field->GetName();
210
fPosX
= fieldMap->
GetPositionX
();
211
fPosY
= fieldMap->
GetPositionY
();
212
fPosZ
= fieldMap->
GetPositionZ
();
213
fScale
= fieldMap->
GetScale
();
214
fIsOff
= fieldMap->
IsFieldOff
();
215
}
else
{
216
cerr <<
"-W- BmnFieldPar::SetParameters: Unknown field type "
<<
fType
<<
"!"
<< endl;
217
fBx
=
fBy
=
fBz
= 0.;
218
fXmin
=
fXmax
=
fYmin
=
fYmax
=
fZmin
=
fZmax
= 0.;
219
fMapName
=
""
;
220
fPosX
=
fPosY
=
fPosZ
=
fScale
= 0.;
221
fIsOff
=
kFALSE
;
222
}
223
224
return
;
225
}
kMaxLen
const int kMaxLen
Definition
BmnFieldPar.cxx:16
Bool_t
bool Bool_t
Text_t
char Text_t
kFALSE
constexpr Bool_t kFALSE
kTRUE
constexpr Bool_t kTRUE
BmnFieldConst
Definition
BmnFieldConst.h:17
BmnFieldConst::GetZmin
Double_t GetZmin() const
Definition
BmnFieldConst.h:75
BmnFieldConst::GetYmin
Double_t GetYmin() const
Definition
BmnFieldConst.h:73
BmnFieldConst::GetBz
virtual Double_t GetBz(Double_t x, Double_t y, Double_t z)
Definition
BmnFieldConst.cxx:142
BmnFieldConst::IsFieldOff
Bool_t IsFieldOff() const
Whether magnetic field is off.
Definition
BmnFieldConst.h:84
BmnFieldConst::GetZmax
Double_t GetZmax() const
Definition
BmnFieldConst.h:76
BmnFieldConst::GetYmax
Double_t GetYmax() const
Definition
BmnFieldConst.h:74
BmnFieldConst::GetXmin
Double_t GetXmin() const
Accessors to field region.
Definition
BmnFieldConst.h:71
BmnFieldConst::GetBy
virtual Double_t GetBy(Double_t x, Double_t y, Double_t z)
Definition
BmnFieldConst.cxx:134
BmnFieldConst::GetXmax
Double_t GetXmax() const
Definition
BmnFieldConst.h:72
BmnFieldConst::GetBx
virtual Double_t GetBx(Double_t x, Double_t y, Double_t z)
Get components of field at a given point.
Definition
BmnFieldConst.cxx:126
BmnFieldMap
Definition
BmnFieldMap.h:22
BmnFieldMap::GetPositionX
Double_t GetPositionX() const
Accessor to field centre position in global system.
Definition
BmnFieldMap.h:85
BmnFieldMap::GetPositionY
Double_t GetPositionY() const
Definition
BmnFieldMap.h:86
BmnFieldMap::IsFieldOff
Bool_t IsFieldOff() const
Whether magnetic field is off.
Definition
BmnFieldMap.h:93
BmnFieldMap::GetPositionZ
Double_t GetPositionZ() const
Definition
BmnFieldMap.h:87
BmnFieldMap::GetScale
Double_t GetScale() const
Accessor to global scaling factor.
Definition
BmnFieldMap.h:90
BmnFieldPar::fBz
Double_t fBz
Definition
BmnFieldPar.h:85
BmnFieldPar::fYmax
Double_t fYmax
Definition
BmnFieldPar.h:81
BmnFieldPar::fTypeOfParent
Int_t fTypeOfParent
Field type of parent field (in case of distorted field map).
Definition
BmnFieldPar.h:106
BmnFieldPar::fXmax
Double_t fXmax
Definition
BmnFieldPar.h:80
BmnFieldPar::fPosX
Double_t fPosX
Field centre position for field map.
Definition
BmnFieldPar.h:91
BmnFieldPar::fPosZ
Double_t fPosZ
Definition
BmnFieldPar.h:91
BmnFieldPar::fDistortionFilename
TString fDistortionFilename
Field map distortion filename (in case of distorted field map).
Definition
BmnFieldPar.h:100
BmnFieldPar::fPosY
Double_t fPosY
Definition
BmnFieldPar.h:91
BmnFieldPar::putParams
virtual void putParams(FairParamList *list)
Put parameters.
Definition
BmnFieldPar.cxx:75
BmnFieldPar::fBy
Double_t fBy
Definition
BmnFieldPar.h:85
BmnFieldPar::BmnFieldPar
BmnFieldPar()
default constructor
Definition
BmnFieldPar.cxx:44
BmnFieldPar::fParentName
TString fParentName
Field name of parent field (in case of distorted field map).
Definition
BmnFieldPar.h:103
BmnFieldPar::getParams
virtual Bool_t getParams(FairParamList *list)
Get parameters.
Definition
BmnFieldPar.cxx:113
BmnFieldPar::fYmin
Double_t fYmin
Definition
BmnFieldPar.h:81
BmnFieldPar::fBx
Double_t fBx
Field values in case of constant field [kG].
Definition
BmnFieldPar.h:85
BmnFieldPar::~BmnFieldPar
~BmnFieldPar()
Destructor.
Definition
BmnFieldPar.cxx:70
BmnFieldPar::fType
Int_t fType
Field type 0 = constant field 1 = field map 2 = field map sym2 (symmetries in x and y) 3 = field map ...
Definition
BmnFieldPar.h:77
BmnFieldPar::fMapName
TString fMapName
Field map name in case of field map.
Definition
BmnFieldPar.h:88
BmnFieldPar::fZmax
Double_t fZmax
Definition
BmnFieldPar.h:82
BmnFieldPar::fZmin
Double_t fZmin
Definition
BmnFieldPar.h:82
BmnFieldPar::fIsOff
Bool_t fIsOff
Whether magnetic field is off.
Definition
BmnFieldPar.h:97
BmnFieldPar::fScale
Double_t fScale
Scaling factor for field map.
Definition
BmnFieldPar.h:94
BmnFieldPar::fXmin
Double_t fXmin
Field limits in case of constant field.
Definition
BmnFieldPar.h:80
BmnFieldPar::SetParameters
void SetParameters(FairField *field)
Set parameters from BmnField.
Definition
BmnFieldPar.cxx:180
FairField
FairParGenericSet
BmnFieldConst.h
BmnFieldMap.h
BmnFieldPar.h
kTypeDistorted
const int kTypeDistorted
Definition
BmnFieldPar.h:23
kMaxFieldMapType
const int kMaxFieldMapType
Definition
BmnFieldPar.h:22
field
BmnFieldPar.cxx
Generated on
for BmnRoot by
1.17.0