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