FairShip
Loading...
Searching...
No Matches
ShipConstField.cxx
Go to the documentation of this file.
1
// SPDX-License-Identifier: LGPL-3.0-or-later
2
// SPDX-FileCopyrightText: Copyright CERN for the benefit of the SHiP
3
// Collaboration
4
5
// -------------------------------------------------------------------------
6
// ----- ShipConstField source file -----
7
// ----- Created 06/01/04 by M. Al/Turany -----
8
// ----- Redesign 13/02/06 by V. Friese -----
9
// -------------------------------------------------------------------------
10
#include "
ShipConstField.h
"
11
12
#include <iomanip>
13
#include <iostream>
14
15
#include "
ShipFieldPar.h
"
16
17
using
std::cerr;
18
using
std::cout;
19
using
std::endl;
20
using
std::setw;
21
22
// ----- Default constructor -------------------------------------------
23
ShipConstField::ShipConstField
()
24
: FairField(),
25
fXmin
(0.),
26
fXmax
(0.),
27
fYmin
(0.),
28
fYmax
(0.),
29
fZmin
(0.),
30
fZmax
(0.),
31
fBx
(0.),
32
fBy
(0.),
33
fBz
(0.) {
34
fType = 0;
35
}
36
// -------------------------------------------------------------------------
37
38
// ----- Standard constructor ------------------------------------------
39
ShipConstField::ShipConstField
(
const
char
* name, Double_t xMin, Double_t xMax,
40
Double_t yMin, Double_t yMax, Double_t zMin,
41
Double_t zMax, Double_t bX, Double_t bY,
42
Double_t bZ)
43
: FairField(name),
44
fXmin
(xMin),
45
fXmax
(xMax),
46
fYmin
(yMin),
47
fYmax
(yMax),
48
fZmin
(zMin),
49
fZmax
(zMax),
50
fBx
(bX),
51
fBy
(bY),
52
fBz
(bZ) {
53
fType = 0;
54
}
55
// -------------------------------------------------------------------------
56
57
// -------- Constructor from CbmFieldPar -------------------------------
58
ShipConstField::ShipConstField
(
ShipFieldPar
* fieldPar)
59
: FairField(),
60
fXmin
(0.),
61
fXmax
(0.),
62
fYmin
(0.),
63
fYmax
(0.),
64
fZmin
(0.),
65
fZmax
(0.),
66
fBx
(0.),
67
fBy
(0.),
68
fBz
(0.) {
69
if
(!fieldPar) {
70
cerr <<
"-W- ShipConstField::ShipConstField: empty parameter container!"
71
<< endl;
72
fType = 0;
73
}
else
{
74
fXmin
= fieldPar->
GetXmin
();
75
fXmax
= fieldPar->
GetXmax
();
76
fYmin
= fieldPar->
GetYmin
();
77
fYmax
= fieldPar->
GetYmax
();
78
fZmin
= fieldPar->
GetZmin
();
79
fZmax
= fieldPar->
GetZmax
();
80
fBx
= fieldPar->
GetBx
();
81
fBy
= fieldPar->
GetBy
();
82
fBz
= fieldPar->
GetBz
();
83
fType = fieldPar->
GetType
();
84
}
85
}
86
// -------------------------------------------------------------------------
87
88
// ----- Destructor ----------------------------------------------------
89
ShipConstField::~ShipConstField
() =
default
;
90
// -------------------------------------------------------------------------
91
92
// ----- Set field region ----------------------------------------------
93
void
ShipConstField::SetFieldRegion
(Double_t xMin, Double_t xMax, Double_t yMin,
94
Double_t yMax, Double_t zMin,
95
Double_t zMax) {
96
fXmin
= xMin;
97
fXmax
= xMax;
98
fYmin
= yMin;
99
fYmax
= yMax;
100
fZmin
= zMin;
101
fZmax
= zMax;
102
}
103
// -------------------------------------------------------------------------
104
105
// ----- Set field values ----------------------------------------------
106
void
ShipConstField::SetField
(Double_t bX, Double_t bY, Double_t bZ) {
107
fBx
= bX;
108
fBy
= bY;
109
fBz
= bZ;
110
}
111
// -------------------------------------------------------------------------
112
113
// ----- Get x component of field --------------------------------------
114
Double_t
ShipConstField::GetBx
(Double_t x, Double_t y, Double_t z) {
115
if
(x < fXmin || x >
fXmax
|| y < fYmin || y >
fYmax
|| z <
fZmin
||
116
z >
fZmax
)
117
return
0.;
118
return
fBx
;
119
}
120
// -------------------------------------------------------------------------
121
122
// ----- Get y component of field --------------------------------------
123
Double_t
ShipConstField::GetBy
(Double_t x, Double_t y, Double_t z) {
124
if
(x < fXmin || x >
fXmax
|| y < fYmin || y >
fYmax
|| z <
fZmin
||
125
z >
fZmax
)
126
return
0.;
127
return
fBy
;
128
}
129
// -------------------------------------------------------------------------
130
131
// ----- Get z component of field --------------------------------------
132
Double_t
ShipConstField::GetBz
(Double_t x, Double_t y, Double_t z) {
133
if
(x < fXmin || x >
fXmax
|| y < fYmin || y >
fYmax
|| z <
fZmin
||
134
z >
fZmax
)
135
return
0.;
136
return
fBz
;
137
}
138
// -------------------------------------------------------------------------
139
140
// ----- Get all field components at once ------------------------------
141
void
ShipConstField::GetFieldValue
(
const
Double_t point[3], Double_t* bField) {
142
if
(point[0] <
fXmin
|| point[0] >
fXmax
|| point[1] <
fYmin
||
143
point[1] >
fYmax
|| point[2] <
fZmin
|| point[2] >
fZmax
) {
144
bField[0] = 0.;
145
bField[1] = 0.;
146
bField[2] = 0.;
147
return
;
148
}
149
bField[0] =
fBx
;
150
bField[1] =
fBy
;
151
bField[2] =
fBz
;
152
}
153
// -------------------------------------------------------------------------
154
155
// ----- Screen output -------------------------------------------------
156
void
ShipConstField::Print
(Option_t*)
const
{
157
cout <<
"======================================================"
<< endl;
158
cout <<
"---- "
<< fTitle <<
" : "
<< fName << endl;
159
cout <<
"----"
<< endl;
160
cout <<
"---- Field type : constant"
<< endl;
161
cout <<
"----"
<< endl;
162
cout <<
"---- Field regions : "
<< endl;
163
cout <<
"---- x = "
<< setw(4) <<
fXmin
<<
" to "
<< setw(4) <<
fXmax
164
<<
" cm"
<< endl;
165
cout <<
"---- y = "
<< setw(4) <<
fYmin
<<
" to "
<< setw(4) <<
fYmax
166
<<
" cm"
<< endl;
167
cout <<
"---- z = "
<< setw(4) <<
fZmin
<<
" to "
<< setw(4) <<
fZmax
168
<<
" cm"
<< endl;
169
cout.precision(4);
170
cout <<
"---- B = ( "
<<
fBx
<<
", "
<<
fBy
<<
", "
<<
fBz
<<
" ) kG"
171
<< endl;
172
cout <<
"======================================================"
<< endl;
173
}
174
// -------------------------------------------------------------------------
ShipConstField.h
ShipFieldPar.h
ShipConstField::ShipConstField
ShipConstField()
Definition
ShipConstField.cxx:23
ShipConstField::~ShipConstField
~ShipConstField() override
ShipConstField::fYmin
Double_t fYmin
Definition
ShipConstField.h:95
ShipConstField::GetBz
Double_t GetBz() const
Definition
ShipConstField.h:86
ShipConstField::SetFieldRegion
void SetFieldRegion(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
Definition
ShipConstField.cxx:93
ShipConstField::GetBy
Double_t GetBy() const
Definition
ShipConstField.h:85
ShipConstField::fBy
Double_t fBy
Definition
ShipConstField.h:102
ShipConstField::fXmin
Double_t fXmin
Definition
ShipConstField.h:93
ShipConstField::GetBx
Double_t GetBx() const
Definition
ShipConstField.h:84
ShipConstField::fZmax
Double_t fZmax
Definition
ShipConstField.h:98
ShipConstField::fBz
Double_t fBz
Definition
ShipConstField.h:103
ShipConstField::fYmax
Double_t fYmax
Definition
ShipConstField.h:96
ShipConstField::GetFieldValue
void GetFieldValue(const Double_t point[3], Double_t *bField) override
Definition
ShipConstField.cxx:141
ShipConstField::Print
void Print(Option_t *="") const override
Definition
ShipConstField.cxx:156
ShipConstField::SetField
void SetField(Double_t bX, Double_t bY, Double_t bZ)
Definition
ShipConstField.cxx:106
ShipConstField::fZmin
Double_t fZmin
Definition
ShipConstField.h:97
ShipConstField::fBx
Double_t fBx
Definition
ShipConstField.h:101
ShipConstField::fXmax
Double_t fXmax
Definition
ShipConstField.h:94
ShipFieldPar
Definition
ShipFieldPar.h:15
ShipFieldPar::GetZmax
Double_t GetZmax() const
Definition
ShipFieldPar.h:42
ShipFieldPar::GetYmin
Double_t GetYmin() const
Definition
ShipFieldPar.h:39
ShipFieldPar::GetYmax
Double_t GetYmax() const
Definition
ShipFieldPar.h:40
ShipFieldPar::GetXmax
Double_t GetXmax() const
Definition
ShipFieldPar.h:38
ShipFieldPar::GetBx
Double_t GetBx() const
Definition
ShipFieldPar.h:43
ShipFieldPar::GetBz
Double_t GetBz() const
Definition
ShipFieldPar.h:45
ShipFieldPar::GetType
Int_t GetType() const
Definition
ShipFieldPar.h:36
ShipFieldPar::GetBy
Double_t GetBy() const
Definition
ShipFieldPar.h:44
ShipFieldPar::GetXmin
Double_t GetXmin() const
Definition
ShipFieldPar.h:37
ShipFieldPar::GetZmin
Double_t GetZmin() const
Definition
ShipFieldPar.h:41
field
ShipConstField.cxx
Generated by
Doxygen
1.15.0