BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
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>
12using std::cerr;
13using std::cout;
14using std::endl;
15
16const int kMaxLen = 2048;
17
18// ------ Constructor --------------------------------------------------
19
20BmnFieldPar::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)
39 , fParentName("")
40 , fTypeOfParent(0)
41{}
42// -------------------------------------------------------------------------
43
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)
63 , fParentName("")
64 , fTypeOfParent(0)
65{}
66// -------------------------------------------------------------------------
67
68// ------ Destructor ---------------------------------------------------
69
71// -------------------------------------------------------------------------
72
73// ------ Put parameters -----------------------------------------------
74
75void 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
113Bool_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];
162 if (!list->fill("Field map distortion filename", tmp, kMaxLen))
163 return kFALSE;
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
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}
const int kMaxLen
bool Bool_t
char Text_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
Double_t GetZmin() const
Double_t GetYmin() const
virtual Double_t GetBz(Double_t x, Double_t y, Double_t z)
Bool_t IsFieldOff() const
Whether magnetic field is off.
Double_t GetZmax() const
Double_t GetYmax() const
Double_t GetXmin() const
Accessors to field region.
virtual Double_t GetBy(Double_t x, Double_t y, Double_t z)
Double_t GetXmax() const
virtual Double_t GetBx(Double_t x, Double_t y, Double_t z)
Get components of field at a given point.
Double_t GetPositionX() const
Accessor to field centre position in global system.
Definition BmnFieldMap.h:85
Double_t GetPositionY() const
Definition BmnFieldMap.h:86
Bool_t IsFieldOff() const
Whether magnetic field is off.
Definition BmnFieldMap.h:93
Double_t GetPositionZ() const
Definition BmnFieldMap.h:87
Double_t GetScale() const
Accessor to global scaling factor.
Definition BmnFieldMap.h:90
Double_t fBz
Definition BmnFieldPar.h:85
Double_t fYmax
Definition BmnFieldPar.h:81
Int_t fTypeOfParent
Field type of parent field (in case of distorted field map).
Double_t fXmax
Definition BmnFieldPar.h:80
Double_t fPosX
Field centre position for field map.
Definition BmnFieldPar.h:91
Double_t fPosZ
Definition BmnFieldPar.h:91
TString fDistortionFilename
Field map distortion filename (in case of distorted field map).
Double_t fPosY
Definition BmnFieldPar.h:91
virtual void putParams(FairParamList *list)
Put parameters.
Double_t fBy
Definition BmnFieldPar.h:85
BmnFieldPar()
default constructor
TString fParentName
Field name of parent field (in case of distorted field map).
virtual Bool_t getParams(FairParamList *list)
Get parameters.
Double_t fYmin
Definition BmnFieldPar.h:81
Double_t fBx
Field values in case of constant field [kG].
Definition BmnFieldPar.h:85
~BmnFieldPar()
Destructor.
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
TString fMapName
Field map name in case of field map.
Definition BmnFieldPar.h:88
Double_t fZmax
Definition BmnFieldPar.h:82
Double_t fZmin
Definition BmnFieldPar.h:82
Bool_t fIsOff
Whether magnetic field is off.
Definition BmnFieldPar.h:97
Double_t fScale
Scaling factor for field map.
Definition BmnFieldPar.h:94
Double_t fXmin
Field limits in case of constant field.
Definition BmnFieldPar.h:80
void SetParameters(FairField *field)
Set parameters from BmnField.
const int kTypeDistorted
Definition BmnFieldPar.h:23
const int kMaxFieldMapType
Definition BmnFieldPar.h:22