FairRoot/PandaRoot
PndConstField.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndConstField source file -----
3 // ----- Created 30/01/07 by M. Al/Turany -----
4 // -------------------------------------------------------------------------
5 
6 #include "PndConstField.h"
7 #include "PndConstPar.h"
8 
9 
10 #include "FairRun.h"
11 #include "FairRuntimeDb.h"
12 
13 
14 
15 #include <iomanip>
16 #include <iostream>
17 
18 
19 using namespace std;
20 
21 // ----- Default constructor -------------------------------------------
23 : fXmin(0),
24  fXmax(0),
25  fYmin(0),
26  fYmax(0),
27  fZmin(0),
28  fZmax(0),
29  fBx(0),
30  fBy(0),
31  fBz(0)
32 {
33  fType = 0;
34 }
35 // -------------------------------------------------------------------------
36 
37 
38 
39 // ----- Standard constructor ------------------------------------------
41  Double_t xMax, Double_t yMin,
42  Double_t yMax, Double_t zMin,
43  Double_t zMax, Double_t bX,
44  Double_t bY, Double_t bZ)
45  : FairField(name),
46  fXmin(xMin),
47  fXmax(xMax),
48  fYmin(yMin),
49  fYmax(yMax),
50  fZmin(zMin),
51  fZmax(zMax),
52  fBx(bX),
53  fBy(bY),
54  fBz(bZ)
55 
56 {
57  fType = 0;
58 }
59 // -------------------------------------------------------------------------
60 
61 
62 
63 // -------- Constructor from PndFieldPar -------------------------------
65  : FairField(),
66  fXmin(0),
67  fXmax(0),
68  fYmin(0),
69  fYmax(0),
70  fZmin(0),
71  fZmax(0),
72  fBx(0),
73  fBy(0),
74  fBz(0)
75  {
76  if ( ! fieldPar ) {
77  cerr << "-W- PndConstField::PndConstField: empty parameter container!"<< endl;
78  fType= -1;
79  }
80  else {
81  fXmin = fieldPar->GetXmin();
82  fXmax = fieldPar->GetXmax();
83  fYmin = fieldPar->GetYmin();
84  fYmax = fieldPar->GetYmax();
85  fZmin = fieldPar->GetZmin();
86  fZmax = fieldPar->GetZmax();
87  fBx = fieldPar->GetBx();
88  fBy = fieldPar->GetBy();
89  fBz = fieldPar->GetBz();
90  fType = fieldPar->GetType();
91  }
92 }
93 // -------------------------------------------------------------------------
94 
95 
96 
97 // ----- Destructor ----------------------------------------------------
99 // -------------------------------------------------------------------------
100 
101 
102 
103 // ----- Set field region ----------------------------------------------
105  Double_t yMin, Double_t yMax,
106  Double_t zMin, Double_t zMax) {
107  fXmin = xMin;
108  fXmax = xMax;
109  fYmin = yMin;
110  fYmax = yMax;
111  fZmin = zMin;
112  fZmax = zMax;
113 }
114 // -------------------------------------------------------------------------
115 
116 
117 
118 // ----- Set field values ----------------------------------------------
120  fBx = bX;
121  fBy = bY;
122  fBz = bZ;
123 }
124 // -------------------------------------------------------------------------
125 
126 
127 
128 // ----- Get x component of field --------------------------------------
130  if ( x < fXmin || x > fXmax ||
131  y < fYmin || y > fYmax ||
132  z < fZmin || z > fZmax ) return 0.;
133  return fBx;
134 }
135 // -------------------------------------------------------------------------
136 
137 
138 
139 // ----- Get y component of field --------------------------------------
141  if ( x < fXmin || x > fXmax ||
142  y < fYmin || y > fYmax ||
143  z < fZmin || z > fZmax ) return 0.;
144  return fBy;
145 }
146 // -------------------------------------------------------------------------
147 
148 
149 
150 // ----- Get z component of field --------------------------------------
152  if ( x < fXmin || x > fXmax ||
153  y < fYmin || y > fYmax ||
154  z < fZmin || z > fZmax ) return 0.;
155  return fBz;
156 }
157 // -------------------------------------------------------------------------
158 
159 // ----- GetBxyz components of field ------------------------------------
161  //This method is added for comatibility with the field maps and to be able to use a mixture of
162  // of maps and constant fields
163 
164 
165  if ( point [0] < fXmin || point [0] > fXmax ||
166  point [1] < fYmin || point [1] > fYmax ||
167  point [2] < fZmin || point [2] > fZmax ) {
168  bField[0]=0; bField[1]=0; bField[2]=0;
169  }
170  else{
171  bField[0]=fBx; bField[1]=fBy; bField[2]=fBz;
172  }
173 }
174 
175 // ----- Screen output -------------------------------------------------
177  cout << "======================================================" << endl;
178  cout << "---- " << fTitle << " : " << fName << endl;
179  cout << "----" << endl;
180  cout << "---- Field type : constant" << endl;
181  cout << "----" << endl;
182  cout << "---- Field regions : " << endl;
183  cout << "---- x = " << setw(4) << fXmin << " to " << setw(4)
184  << fXmax << " cm" << endl;
185  cout << "---- y = " << setw(4) << fYmin << " to " << setw(4)
186  << fYmax << " cm" << endl;
187  cout << "---- z = " << setw(4) << fZmin << " to " << setw(4)
188  << fZmax << " cm" << endl;
189  cout.precision(4);
190  cout << "---- B = ( " << fBx << ", " << fBy << ", " << fBz << " ) kG"
191  << endl;
192  cout << "======================================================" << endl;
193 }
194 // -------------------------------------------------------------------------
195 // --------- Fill the parameters --------------------------------------------
197 {
198  TString MapName=GetName();
199 // cout << "PndConstField::FillParContainer() " << endl;
200  FairRun *fRun=FairRun::Instance();
201  FairRuntimeDb *rtdb=fRun->GetRuntimeDb();
202  PndConstPar* Par = (PndConstPar*) rtdb->getContainer("PndConstPar");
203  Par->SetParameters(this);
204  Par->setInputVersion(fRun->GetRunId(),1);
205  Par->setChanged();
206 
207 }
208 
209 
Double_t GetYmin() const
Definition: PndMapPar.h:54
Double_t fYmin
Double_t GetXmax() const
Definition: PndMapPar.h:53
Double_t fXmax
virtual void Print()
void SetFieldRegion(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
Double_t GetBx() const
Definition: PndConstField.h:95
FairRunAna * fRun
Definition: hit_dirc.C:58
Double_t
void SetField(Double_t bX, Double_t bY, Double_t bZ)
Double_t GetZmin() const
Definition: PndMapPar.h:56
Double_t GetZmax() const
Definition: PndMapPar.h:57
PndMultiFieldPar * fieldPar
Definition: sim_ftof.C:102
TClonesArray * point
Definition: anaLmdDigi.C:29
Double_t fZmin
void SetParameters(FairField *field)
Definition: PndConstPar.cxx:54
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
Double_t GetBz() const
Definition: PndConstField.h:97
Double_t z
Double_t GetBy() const
Definition: PndConstPar.h:42
void FillParContainer()
TString name
virtual ~PndConstField()
Double_t GetBx() const
Definition: PndConstPar.h:41
Double_t x
Double_t GetXmin() const
Definition: PndMapPar.h:52
PndMultiFieldPar * Par
Definition: sim_emc_apd.C:115
Double_t fXmin
Double_t fYmax
Double_t GetYmax() const
Definition: PndMapPar.h:55
ClassImp(PndAnaContFact)
Double_t fZmax
Double_t GetBz() const
Definition: PndConstPar.h:43
Double_t y
virtual void GetBxyz(const Double_t point[3], Double_t *bField)
Double_t GetBy() const
Definition: PndConstField.h:96
Int_t GetType() const
Definition: PndMapPar.h:51