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