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