FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MyFieldPar.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 // -------------------------------------------------------------------------
10 // ----- MyFieldPar file -----
11 // ----- Created 26/03/14 by M. Al-Turany -----
12 // -------------------------------------------------------------------------
13 
14 #include "MyFieldPar.h"
15 
16 #include "FairParamList.h"
17 #include "MyConstField.h"
18 
19 #include <iostream>
20 using std::cerr;
21 using std::cout;
22 using std::endl;
23 
24 const int kMaxLen = 2048;
25 
26 // ------ Constructor --------------------------------------------------
27 MyFieldPar::MyFieldPar(const char* name, const char* title, const char* context)
28  : FairParGenericSet(name, title, context)
29  , fType(-1)
30  , fXmin(0.)
31  , fXmax(0.)
32  , fYmin(0.)
33  , fYmax(0.)
34  , fZmin(0.)
35  , fZmax(0.)
36  , fBx(0.)
37  , fBy(0.)
38  , fBz(0.)
39  , fMapName("")
40  , fPosX(0.)
41  , fPosY(0.)
42  , fPosZ(0.)
43  , fScale(0.)
44  , fPeak(0.)
45  , fMiddle(0.)
46 
47 {}
48 // -------------------------------------------------------------------------
49 
52  , fType(-1)
53  , fXmin(0.)
54  , fXmax(0.)
55  , fYmin(0.)
56  , fYmax(0.)
57  , fZmin(0.)
58  , fZmax(0.)
59  , fBx(0.)
60  , fBy(0.)
61  , fBz(0.)
62  , fMapName("")
63  , fPosX(0.)
64  , fPosY(0.)
65  , fPosZ(0.)
66  , fScale(0.)
67  , fPeak(0.)
68  , fMiddle(0.)
69 
70 {}
71 // -------------------------------------------------------------------------
72 
73 // ------ Destructor ---------------------------------------------------
75 // -------------------------------------------------------------------------
76 
77 // ------ Put parameters -----------------------------------------------
79 {
80 
81  if (!list)
82  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  } else if (fType >= 1 && fType <= kMaxFieldMapType) { //
97  list->add("Field Peak", fPeak);
98  list->add("Field Middle", fMiddle);
99  } else if (fType >= 2 && fType <= kMaxFieldMapType) { // field map
100  list->add("Field map name", fMapName);
101  list->add("Field x position", fPosX);
102  list->add("Field y position", fPosY);
103  list->add("Field z position", fPosZ);
104  list->add("Field scaling factor", fScale);
105  }
106 }
107 // -------------------------------------------------------------------------
108 
109 // -------- Get parameters ---------------------------------------------
111 {
112 
113  if (!list)
114  return kFALSE;
115 
116  if (!list->fill("Field Type", &fType))
117  return kFALSE;
118 
119  if (fType == 0) { // constant field
120  if (!list->fill("Field min x", &fXmin))
121  return kFALSE;
122  if (!list->fill("Field max x", &fXmax))
123  return kFALSE;
124  if (!list->fill("Field min y", &fYmin))
125  return kFALSE;
126  if (!list->fill("Field max y", &fYmax))
127  return kFALSE;
128  if (!list->fill("Field min z", &fZmin))
129  return kFALSE;
130  if (!list->fill("Field max z", &fZmax))
131  return kFALSE;
132  if (!list->fill("Field Bx", &fBx))
133  return kFALSE;
134  if (!list->fill("Field By", &fBy))
135  return kFALSE;
136  if (!list->fill("Field Bz", &fBz))
137  return kFALSE;
138 
139  } else if (fType >= 1 && fType <= kMaxFieldMapType) {
140 
141  if (!list->fill("Field Peak", &fPeak))
142  return kFALSE;
143  if (!list->fill("Field Middle", &fMiddle))
144  return kFALSE;
145 
146  } else if (fType >= 2 && fType <= kMaxFieldMapType) { // field map
147  Text_t mapName[80];
148  if (!list->fill("Field map name", mapName, 80))
149  return kFALSE;
150  fMapName = mapName;
151  if (!list->fill("Field x position", &fPosX))
152  return kFALSE;
153  if (!list->fill("Field y position", &fPosY))
154  return kFALSE;
155  if (!list->fill("Field z position", &fPosZ))
156  return kFALSE;
157  if (!list->fill("Field scaling factor", &fScale))
158  return kFALSE;
159  }
160 
161  return kTRUE;
162 }
163 // -------------------------------------------------------------------------
164 
166 {
167 
168  if (!field) {
169  cerr << "-W- MyFieldPar::SetParameters: Empty field pointer!" << endl;
170  return;
171  }
172 
173  fType = field->GetType();
174 
175  if (fType == 0) { // constant field
176  MyConstField* fieldConst = (MyConstField*)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  } else {
189  cerr << "-W- MyFieldPar::SetParameters: Unknown field type " << fType << "!" << endl;
190  fBx = fBy = fBz = 0.;
191  fXmin = fXmax = fYmin = fYmax = fZmin = fZmax = 0.;
192  fMapName = "";
193  fPosX = fPosY = fPosZ = fScale = 0.;
194  }
195 
196  return;
197 }
198 // -------------------------------------------------------------------------
199 
Double_t GetYmax() const
Definition: MyConstField.h:83
const int kMaxLen
Definition: MyFieldPar.cxx:24
virtual Double_t GetBx(Double_t x, Double_t y, Double_t z)
Double_t GetXmax() const
Definition: MyConstField.h:81
void SetParameters(FairField *field)
Definition: MyFieldPar.cxx:165
const int kMaxFieldMapType
Definition: MyFieldPar.h:22
Double_t GetXmin() const
Definition: MyConstField.h:80
virtual void putParams(FairParamList *list)
Definition: MyFieldPar.cxx:78
Int_t GetType() const
Definition: FairField.h:62
Double_t GetZmin() const
Definition: MyConstField.h:84
ClassImp(FairEventBuilder)
Double_t GetZmax() const
Definition: MyConstField.h:85
Bool_t fill(const Text_t *, Text_t *, const Int_t)
virtual Bool_t getParams(FairParamList *list)
Definition: MyFieldPar.cxx:110
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)
void add(FairParamObj &)
Double_t GetYmin() const
Definition: MyConstField.h:82