BmnRoot
Loading...
Searching...
No Matches
BmnFieldConst.cxx
Go to the documentation of this file.
1/********************************************************************************
2 * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3 * *
4 * This software is distributed under the terms of the *
5 * GNU Lesser General Public Licence (LGPL) version 3, *
6 * copied verbatim in the file "LICENSE" *
7 ********************************************************************************/
8// -------------------------------------------------------------------------
9// ----- BmnFieldConst source file -----
10// ----- Created 30/01/07 by M. Al/Turany -----
11// -------------------------------------------------------------------------
12#include "BmnFieldConst.h"
13
14#include "BmnFieldPar.h"
15#include "FairLogger.h" // for logging
16#include "FairRun.h" // for FairRun
17#include "FairRuntimeDb.h" // for FairRuntimeDb
18
19#include <TString.h> // for operator<<, TString
20#include <iomanip> // for operator<<, setw
21
22using std::setprecision;
23using std::setw;
24
26 : FairField()
27 , fXmin(0)
28 , fXmax(0)
29 , fYmin(0)
30 , fYmax(0)
31 , fZmin(0)
32 , fZmax(0)
33 , fBx(0)
34 , fBy(0)
35 , fBz(0)
36 , fIsOff(kFALSE)
37{
38 fType = 0;
39}
40
42 Double_t xMin,
43 Double_t xMax,
44 Double_t yMin,
45 Double_t yMax,
46 Double_t zMin,
47 Double_t zMax,
48 Double_t bX,
49 Double_t bY,
50 Double_t bZ)
51 : FairField(name)
52 , fXmin(xMin)
53 , fXmax(xMax)
54 , fYmin(yMin)
55 , fYmax(yMax)
56 , fZmin(zMin)
57 , fZmax(zMax)
58 , fBx(bX)
59 , fBy(bY)
60 , fBz(bZ)
61 , fIsOff(kFALSE)
62
63{
64 fType = 0;
65}
66
68 : FairField()
69 , fXmin(0)
70 , fXmax(0)
71 , fYmin(0)
72 , fYmax(0)
73 , fZmin(0)
74 , fZmax(0)
75 , fBx(0)
76 , fBy(0)
77 , fBz(0)
78 , fIsOff(kFALSE)
79{
80 if (!fieldPar) {
81 LOG(warn) << "BmnFieldConst::BmnFieldConst: empty parameter container!";
82 fType = -1;
83 } else {
84 fXmin = fieldPar->GetXmin();
85 fXmax = fieldPar->GetXmax();
86 fYmin = fieldPar->GetYmin();
87 fYmax = fieldPar->GetYmax();
88 fZmin = fieldPar->GetZmin();
89 fZmax = fieldPar->GetZmax();
90 fBx = fieldPar->GetBx();
91 fBy = fieldPar->GetBy();
92 fBz = fieldPar->GetBz();
93 fType = fieldPar->GetType();
94 fIsOff = fieldPar->IsFieldOff();
95 }
96}
97
99
101 Double_t xMax,
102 Double_t yMin,
103 Double_t yMax,
104 Double_t zMin,
105 Double_t zMax)
106{
107 fXmin = xMin;
108 fXmax = xMax;
109 fYmin = yMin;
110 fYmax = yMax;
111 fZmin = zMin;
112 fZmax = zMax;
113}
114
115void BmnFieldConst::SetField(Double_t bX, Double_t bY, Double_t bZ)
116{
117 fBx = bX;
118 fBy = bY;
119 fBz = bZ;
120 if ((bX == 0) && (bY == 0) && (bZ == 0)) fIsOff = kTRUE;
121 else fIsOff = kFALSE;
122}
123
124Double_t BmnFieldConst::GetBx(Double_t x, Double_t y, Double_t z)
125{
126 if (x < fXmin || x > fXmax || y < fYmin || y > fYmax || z < fZmin || z > fZmax) {
127 return 0.;
128 }
129 return fBx;
130}
131
132Double_t BmnFieldConst::GetBy(Double_t x, Double_t y, Double_t z)
133{
134 if (x < fXmin || x > fXmax || y < fYmin || y > fYmax || z < fZmin || z > fZmax) {
135 return 0.;
136 }
137 return fBy;
138}
139
140Double_t BmnFieldConst::GetBz(Double_t x, Double_t y, Double_t z)
141{
142 if (x < fXmin || x > fXmax || y < fYmin || y > fYmax || z < fZmin || z > fZmax) {
143 return 0.;
144 }
145 return fBz;
146}
147
148void BmnFieldConst::Print(Option_t*) const
149{
150 LOG(info) << "======================================================";
151 LOG(info) << "---- " << fTitle << " : " << fName;
152 LOG(info) << "----";
153 LOG(info) << "---- Field type : constant";
154 if (fIsOff) LOG(info) << "---- Field is off ----";
155 LOG(info) << "----";
156 LOG(info) << "---- Field regions : ";
157 LOG(info) << "---- x = " << setw(4) << fXmin << " to " << setw(4) << fXmax << " cm";
158 LOG(info) << "---- y = " << setw(4) << fYmin << " to " << setw(4) << fYmax << " cm";
159 LOG(info) << "---- z = " << setw(4) << fZmin << " to " << setw(4) << fZmax << " cm";
160 LOG(info) << "---- B = ( " << setprecision(4) << fBx << ", " << fBy << ", " << fBz << " ) kG";
161 LOG(info) << "======================================================";
162}
163
165{
166 TString MapName = GetName();
167 // LOG(info) << "BmnFieldConst::FillParContainer() ";
168 FairRun* fRun = FairRun::Instance();
169 FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
170 // Bool_t kParameterMerged = kTRUE;
171 BmnFieldPar* Par = static_cast<BmnFieldPar*>(rtdb->getContainer("BmnFieldPar"));
172 Par->SetParameters(this);
173 Par->setInputVersion(fRun->GetRunId(), 1);
174 Par->setChanged();
175}
void SetField(Double_t bX, Double_t bY, Double_t bZ)
virtual ~BmnFieldConst()
virtual void Print(Option_t *) 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 GetBz() const
Double_t GetBx() const
Double_t GetXmin() const
Definition BmnFieldPar.h:57
Bool_t IsFieldOff() const
Definition BmnFieldPar.h:71
Double_t GetYmax() const
Definition BmnFieldPar.h:60
Double_t GetBz() const
Definition BmnFieldPar.h:65
Double_t GetZmin() const
Definition BmnFieldPar.h:61
Int_t GetType() const
Definition BmnFieldPar.h:56
Double_t GetZmax() const
Definition BmnFieldPar.h:62
Double_t GetBy() const
Definition BmnFieldPar.h:64
Double_t GetBx() const
Definition BmnFieldPar.h:63
Double_t GetXmax() const
Definition BmnFieldPar.h:58
void SetParameters(FairField *field)
Double_t GetYmin() const
Definition BmnFieldPar.h:59