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
21using std::cerr;
22using std::cout;
23using std::endl;
24using std::setw;
25
26
27// ----- Default constructor -------------------------------------------
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 ------------------------------------------
46CbmFieldConst::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 -------------------------------
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 ----------------------------------------------------
99// -------------------------------------------------------------------------
100
101
102// ----- Set field region ----------------------------------------------
103void 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 ----------------------------------------------
117void 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 --------------------------------------
127Double_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 --------------------------------------
136Double_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 --------------------------------------
145Double_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// ----- Screen output -------------------------------------------------
154void CbmFieldConst::Print(Option_t*) const
155{
156 cout << "======================================================" << endl;
157 cout << "---- " << fTitle << " : " << fName << endl;
158 cout << "----" << endl;
159 cout << "---- Field type : constant" << endl;
160 cout << "----" << endl;
161 cout << "---- Field regions : " << endl;
162 cout << "---- x = " << setw(4) << fXmin << " to " << setw(4) << fXmax << " cm" << endl;
163 cout << "---- y = " << setw(4) << fYmin << " to " << setw(4) << fYmax << " cm" << endl;
164 cout << "---- z = " << setw(4) << fZmin << " to " << setw(4) << fZmax << " cm" << endl;
165 cout.precision(4);
166 cout << "---- B = ( " << fBx << ", " << fBy << ", " << fBz << " ) kG" << endl;
167 cout << "======================================================" << endl;
168}
169// -------------------------------------------------------------------------
170
171
ClassImp(CbmConverterManager)
Double_t GetBz() const
Double_t GetBy() const
Double_t GetBx() const
void SetFieldRegion(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
void SetField(Double_t bX, Double_t bY, Double_t bZ)
virtual void Print(Option_t *="") const
virtual ~CbmFieldConst()
Double_t GetXmin() const
Definition CbmFieldPar.h:62
Double_t GetBy() const
Definition CbmFieldPar.h:69
Double_t GetXmax() const
Definition CbmFieldPar.h:63
Int_t GetType() const
Definition CbmFieldPar.h:61
Double_t GetBx() const
Definition CbmFieldPar.h:68
Double_t GetYmin() const
Definition CbmFieldPar.h:64
Double_t GetZmax() const
Definition CbmFieldPar.h:67
Double_t GetZmin() const
Definition CbmFieldPar.h:66
Double_t GetBz() const
Definition CbmFieldPar.h:70
Double_t GetYmax() const
Definition CbmFieldPar.h:65