FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairConstField.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 // ----- FairConstField source file -----
10 // ----- Created 30/01/07 by M. Al/Turany -----
11 // -------------------------------------------------------------------------
12 #include "FairConstField.h"
13 
14 #include "FairConstPar.h" // for FairConstPar
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 
22 using std::setprecision;
23 using std::setw;
24 
26  : fXmin(0)
27  , fXmax(0)
28  , fYmin(0)
29  , fYmax(0)
30  , fZmin(0)
31  , fZmax(0)
32  , fBx(0)
33  , fBy(0)
34  , fBz(0)
35 {
36  fType = 0;
37 }
38 
40  Double_t xMin,
41  Double_t xMax,
42  Double_t yMin,
43  Double_t yMax,
44  Double_t zMin,
45  Double_t zMax,
46  Double_t bX,
47  Double_t bY,
48  Double_t bZ)
49  : FairField(name)
50  , fXmin(xMin)
51  , fXmax(xMax)
52  , fYmin(yMin)
53  , fYmax(yMax)
54  , fZmin(zMin)
55  , fZmax(zMax)
56  , fBx(bX)
57  , fBy(bY)
58  , fBz(bZ)
59 
60 {
61  fType = 0;
62 }
63 
65  : FairField()
66  , fXmin(0)
67  , fXmax(0)
68  , fYmin(0)
69  , fYmax(0)
70  , fZmin(0)
71  , fZmax(0)
72  , fBx(0)
73  , fBy(0)
74  , fBz(0)
75 {
76  if (!fieldPar) {
77  LOG(warn) << "empty parameter container!";
78  fType = -1;
79  } else {
80  fXmin = fieldPar->GetXmin();
81  fXmax = fieldPar->GetXmax();
82  fYmin = fieldPar->GetYmin();
83  fYmax = fieldPar->GetYmax();
84  fZmin = fieldPar->GetZmin();
85  fZmax = fieldPar->GetZmax();
86  fBx = fieldPar->GetBx();
87  fBy = fieldPar->GetBy();
88  fBz = fieldPar->GetBz();
89  fType = fieldPar->GetType();
90  }
91 }
92 
94 
95 void FairConstField::SetFieldRegion(Double_t xMin,
96  Double_t xMax,
97  Double_t yMin,
98  Double_t yMax,
99  Double_t zMin,
100  Double_t zMax)
101 {
102  fXmin = xMin;
103  fXmax = xMax;
104  fYmin = yMin;
105  fYmax = yMax;
106  fZmin = zMin;
107  fZmax = zMax;
108 }
109 
110 void FairConstField::SetField(Double_t bX, Double_t bY, Double_t bZ)
111 {
112  fBx = bX;
113  fBy = bY;
114  fBz = bZ;
115 }
116 
117 Double_t FairConstField::GetBx(Double_t x, Double_t y, Double_t z)
118 {
119  if (x < fXmin || x > fXmax || y < fYmin || y > fYmax || z < fZmin || z > fZmax) {
120  return 0.;
121  }
122  return fBx;
123 }
124 
125 Double_t FairConstField::GetBy(Double_t x, Double_t y, Double_t z)
126 {
127  if (x < fXmin || x > fXmax || y < fYmin || y > fYmax || z < fZmin || z > fZmax) {
128  return 0.;
129  }
130  return fBy;
131 }
132 
133 Double_t FairConstField::GetBz(Double_t x, Double_t y, Double_t z)
134 {
135  if (x < fXmin || x > fXmax || y < fYmin || y > fYmax || z < fZmin || z > fZmax) {
136  return 0.;
137  }
138  return fBz;
139 }
140 
141 void FairConstField::Print(Option_t*) const
142 {
143  LOG(info) << "======================================================";
144  LOG(info) << "---- " << fTitle << " : " << fName;
145  LOG(info) << "----";
146  LOG(info) << "---- Field type : constant";
147  LOG(info) << "----";
148  LOG(info) << "---- Field regions : ";
149  LOG(info) << "---- x = " << setw(4) << fXmin << " to " << setw(4) << fXmax << " cm";
150  LOG(info) << "---- y = " << setw(4) << fYmin << " to " << setw(4) << fYmax << " cm";
151  LOG(info) << "---- z = " << setw(4) << fZmin << " to " << setw(4) << fZmax << " cm";
152  LOG(info) << "---- B = ( " << setprecision(4) << fBx << ", " << fBy << ", " << fBz << " ) kG";
153  LOG(info) << "======================================================";
154 }
155 
157 {
158  TString MapName = GetName();
159  // LOG(info) << "FairConstField::FillParContainer() ";
160  FairRun* fRun = FairRun::Instance();
161  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
162  // Bool_t kParameterMerged = kTRUE;
163  FairConstPar* Par = static_cast<FairConstPar*>(rtdb->getContainer("FairConstPar"));
164  Par->SetParameters(this);
165  Par->setInputVersion(fRun->GetRunId(), 1);
166  Par->setChanged();
167 }
168 
Double_t GetBx() const
Definition: FairConstPar.h:47
list of container factories
Definition: FairRuntimeDb.h:24
Int_t fType
Definition: FairField.h:111
Double_t GetXmin() const
Definition: FairMapPar.h:39
Double_t GetYmin() const
Definition: FairMapPar.h:41
Double_t GetBy() const
Definition: FairConstPar.h:48
static FairRun * Instance()
Definition: FairRun.cxx:31
void SetField(Double_t bX, Double_t bY, Double_t bZ)
void setChanged(Bool_t flag=kTRUE)
Definition: FairParSet.h:72
ClassImp(FairEventBuilder)
virtual void Print(Option_t *) const
Double_t GetBx() const
FairParSet * getContainer(const Text_t *)
void SetParameters(FairField *field)
void SetFieldRegion(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
virtual ~FairConstField()
Int_t GetType() const
Definition: FairMapPar.h:38
Double_t GetYmax() const
Definition: FairMapPar.h:42
Double_t GetXmax() const
Definition: FairMapPar.h:40
void setInputVersion(Int_t v=-1, Int_t i=0)
Definition: FairParSet.h:51
FairRuntimeDb * GetRuntimeDb(void)
Definition: FairRun.h:80
Double_t GetZmax() const
Definition: FairMapPar.h:44
Double_t GetBz() const
Double_t GetZmin() const
Definition: FairMapPar.h:43
Double_t GetBy() const
Double_t GetBz() const
Definition: FairConstPar.h:49
Int_t GetRunId()
Definition: FairRun.h:97