FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MyConstField.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 // ----- MyConstField source file -----
11 // ----- Created 06/01/04 by M. Al/Turany -----
12 // ----- Redesign 13/02/06 by V. Friese -----
13 // -------------------------------------------------------------------------
14 #include "MyConstField.h"
15 
16 #include "MyFieldPar.h"
17 
18 #include <iomanip>
19 #include <iostream>
20 
21 using std::cerr;
22 using std::cout;
23 using std::endl;
24 using std::setw;
25 
26 // ----- Default constructor -------------------------------------------
28  : FairField()
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 {
39  fType = 0;
40 }
41 // -------------------------------------------------------------------------
42 
43 // ----- Standard constructor ------------------------------------------
44 MyConstField::MyConstField(const char* name,
45  Double_t xMin,
46  Double_t xMax,
47  Double_t yMin,
48  Double_t yMax,
49  Double_t zMin,
50  Double_t zMax,
51  Double_t bX,
52  Double_t bY,
53  Double_t bZ)
54  : FairField(name)
55  , fXmin(xMin)
56  , fXmax(xMax)
57  , fYmin(yMin)
58  , fYmax(yMax)
59  , fZmin(zMin)
60  , fZmax(zMax)
61  , fBx(bX)
62  , fBy(bY)
63  , fBz(bZ)
64 {
65  fType = 0;
66 }
67 // -------------------------------------------------------------------------
68 
69 // -------- Constructor from CbmFieldPar -------------------------------
71  : FairField()
72  , fXmin(0.)
73  , fXmax(0.)
74  , fYmin(0.)
75  , fYmax(0.)
76  , fZmin(0.)
77  , fZmax(0.)
78  , fBx(0.)
79  , fBy(0.)
80  , fBz(0.)
81 {
82  if (!fieldPar) {
83  cerr << "-W- MyConstField::MyConstField: empty parameter container!" << endl;
84  fType = 0;
85  } else {
86  fXmin = fieldPar->GetXmin();
87  fXmax = fieldPar->GetXmax();
88  fYmin = fieldPar->GetYmin();
89  fYmax = fieldPar->GetYmax();
90  fZmin = fieldPar->GetZmin();
91  fZmax = fieldPar->GetZmax();
92  fBx = fieldPar->GetBx();
93  fBy = fieldPar->GetBy();
94  fBz = fieldPar->GetBz();
95  fType = fieldPar->GetType();
96  }
97 }
98 // -------------------------------------------------------------------------
99 
100 // ----- Destructor ----------------------------------------------------
102 // -------------------------------------------------------------------------
103 
104 // ----- Set field region ----------------------------------------------
105 void MyConstField::SetFieldRegion(Double_t xMin,
106  Double_t xMax,
107  Double_t yMin,
108  Double_t yMax,
109  Double_t zMin,
110  Double_t zMax)
111 {
112  fXmin = xMin;
113  fXmax = xMax;
114  fYmin = yMin;
115  fYmax = yMax;
116  fZmin = zMin;
117  fZmax = zMax;
118 }
119 // -------------------------------------------------------------------------
120 
121 // ----- Set field values ----------------------------------------------
122 void MyConstField::SetField(Double_t bX, Double_t bY, Double_t bZ)
123 {
124  fBx = bX;
125  fBy = bY;
126  fBz = bZ;
127 }
128 // -------------------------------------------------------------------------
129 
130 // ----- Get x component of field --------------------------------------
131 Double_t MyConstField::GetBx(Double_t x, Double_t y, Double_t z)
132 {
133  if (x < fXmin || x > fXmax || y < fYmin || y > fYmax || z < fZmin || z > fZmax)
134  return 0.;
135  return fBx;
136 }
137 // -------------------------------------------------------------------------
138 
139 // ----- Get y component of field --------------------------------------
140 Double_t MyConstField::GetBy(Double_t x, Double_t y, Double_t z)
141 {
142  if (x < fXmin || x > fXmax || y < fYmin || y > fYmax || z < fZmin || z > fZmax)
143  return 0.;
144  return fBy;
145 }
146 // -------------------------------------------------------------------------
147 
148 // ----- Get z component of field --------------------------------------
149 Double_t MyConstField::GetBz(Double_t x, Double_t y, Double_t z)
150 {
151  if (x < fXmin || x > fXmax || y < fYmin || y > fYmax || z < fZmin || z > fZmax)
152  return 0.;
153  return fBz;
154 }
155 // -------------------------------------------------------------------------
156 
157 // ----- Screen output -------------------------------------------------
158 void MyConstField::Print()
159 {
160  cout << "======================================================" << endl;
161  cout << "---- " << fTitle << " : " << fName << endl;
162  cout << "----" << endl;
163  cout << "---- Field type : constant" << endl;
164  cout << "----" << endl;
165  cout << "---- Field regions : " << endl;
166  cout << "---- x = " << setw(4) << fXmin << " to " << setw(4) << fXmax << " cm" << endl;
167  cout << "---- y = " << setw(4) << fYmin << " to " << setw(4) << fYmax << " cm" << endl;
168  cout << "---- z = " << setw(4) << fZmin << " to " << setw(4) << fZmax << " cm" << endl;
169  cout.precision(4);
170  cout << "---- B = ( " << fBx << ", " << fBy << ", " << fBz << " ) kG" << endl;
171  cout << "======================================================" << endl;
172 }
173 // -------------------------------------------------------------------------
174 
Double_t GetXmax() const
Definition: MyFieldPar.h:49
virtual void Print()
Int_t fType
Definition: FairField.h:111
Double_t GetXmin() const
Definition: MyFieldPar.h:48
Double_t GetYmax() const
Definition: MyFieldPar.h:51
ClassImp(FairEventBuilder)
Double_t GetZmin() const
Definition: MyFieldPar.h:52
void SetField(Double_t bX, Double_t bY, Double_t bZ)
Double_t GetZmax() const
Definition: MyFieldPar.h:53
virtual ~MyConstField()
Int_t GetType() const
Definition: MyFieldPar.h:47
Double_t GetBx() const
Definition: MyFieldPar.h:54
Double_t GetBy() const
Definition: MyConstField.h:89
void SetFieldRegion(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
Double_t GetYmin() const
Definition: MyFieldPar.h:50
Double_t GetBz() const
Definition: MyFieldPar.h:56
Double_t GetBx() const
Definition: MyConstField.h:88
Double_t GetBy() const
Definition: MyFieldPar.h:55
Double_t GetBz() const
Definition: MyConstField.h:90