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
17using std::cerr;
18using std::cout;
19using std::endl;
20using std::setw;
21
22// ----- Default constructor -------------------------------------------
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 ------------------------------------------
39ShipConstField::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 -------------------------------
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 ----------------------------------------------------
90// -------------------------------------------------------------------------
91
92// ----- Set field region ----------------------------------------------
93void 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 ----------------------------------------------
106void 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 --------------------------------------
114Double_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 --------------------------------------
123Double_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 --------------------------------------
132Double_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// ----- Screen output -------------------------------------------------
142 cout << "======================================================" << endl;
143 cout << "---- " << fTitle << " : " << fName << endl;
144 cout << "----" << endl;
145 cout << "---- Field type : constant" << endl;
146 cout << "----" << endl;
147 cout << "---- Field regions : " << endl;
148 cout << "---- x = " << setw(4) << fXmin << " to " << setw(4) << fXmax
149 << " cm" << endl;
150 cout << "---- y = " << setw(4) << fYmin << " to " << setw(4) << fYmax
151 << " cm" << endl;
152 cout << "---- z = " << setw(4) << fZmin << " to " << setw(4) << fZmax
153 << " cm" << endl;
154 cout.precision(4);
155 cout << "---- B = ( " << fBx << ", " << fBy << ", " << fBz << " ) kG"
156 << endl;
157 cout << "======================================================" << endl;
158}
159// -------------------------------------------------------------------------
virtual ~ShipConstField()
Double_t GetBz() const
void SetFieldRegion(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
Double_t GetBy() const
Double_t GetBx() const
virtual void Print()
void SetField(Double_t bX, Double_t bY, Double_t bZ)
Double_t GetZmax() const
Definition: ShipFieldPar.h:42
Double_t GetYmin() const
Definition: ShipFieldPar.h:39
Double_t GetYmax() const
Definition: ShipFieldPar.h:40
Double_t GetXmax() const
Definition: ShipFieldPar.h:38
Double_t GetBx() const
Definition: ShipFieldPar.h:43
Double_t GetBz() const
Definition: ShipFieldPar.h:45
Int_t GetType() const
Definition: ShipFieldPar.h:36
Double_t GetBy() const
Definition: ShipFieldPar.h:44
Double_t GetXmin() const
Definition: ShipFieldPar.h:37
Double_t GetZmin() const
Definition: ShipFieldPar.h:41