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