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