CbmRoot
CbmFieldMapSym3.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- CbmFieldMapSym3 source file -----
3 // ----- Created 12/01/04 by M. Al/Turany (CbmField.cxx) -----
4 // ----- Redesign 13/02/06 by V. Friese -----
5 // -------------------------------------------------------------------------
6 #include "CbmFieldMapSym3.h"
7 
8 #include <TArrayF.h> // for TArrayF
9 
10 // ------------- Default constructor ----------------------------------
12  : CbmFieldMap(), fHemiX(0.), fHemiY(0.), fHemiZ(0.) {
13  fType = 3;
14 }
15 // ------------------------------------------------------------------------
16 
17 
18 // ------------- Standard constructor ---------------------------------
19 CbmFieldMapSym3::CbmFieldMapSym3(const char* mapName, const char* fileType)
20  : CbmFieldMap(mapName, fileType), fHemiX(0.), fHemiY(0.), fHemiZ(0.) {
21  fType = 3;
22 }
23 // ------------------------------------------------------------------------
24 
25 
26 // ------------- Constructor from CbmFieldPar -------------------------
28  : CbmFieldMap(fieldPar), fHemiX(0.), fHemiY(0.), fHemiZ(0.) {
29  fType = 3;
30 }
31 // ------------------------------------------------------------------------
32 
33 
34 // ------------ Destructor --------------------------------------------
36 // ------------------------------------------------------------------------
37 
38 
39 // ----------- Get x component of the field ---------------------------
40 Double_t CbmFieldMapSym3::GetBx(Double_t x, Double_t y, Double_t z) {
41 
42  Int_t ix = 0;
43  Int_t iy = 0;
44  Int_t iz = 0;
45  Double_t dx = 0.;
46  Double_t dy = 0.;
47  Double_t dz = 0.;
48 
49  if (IsInside(x, y, z, ix, iy, iz, dx, dy, dz)) {
50 
51  // Get Bx field values at grid cell corners
52  fHa[0][0][0] = fBx->At(ix * fNy * fNz + iy * fNz + iz);
53  fHa[1][0][0] = fBx->At((ix + 1) * fNy * fNz + iy * fNz + iz);
54  fHa[0][1][0] = fBx->At(ix * fNy * fNz + (iy + 1) * fNz + iz);
55  fHa[1][1][0] = fBx->At((ix + 1) * fNy * fNz + (iy + 1) * fNz + iz);
56  fHa[0][0][1] = fBx->At(ix * fNy * fNz + iy * fNz + (iz + 1));
57  fHa[1][0][1] = fBx->At((ix + 1) * fNy * fNz + iy * fNz + (iz + 1));
58  fHa[0][1][1] = fBx->At(ix * fNy * fNz + (iy + 1) * fNz + (iz + 1));
59  fHa[1][1][1] = fBx->At((ix + 1) * fNy * fNz + (iy + 1) * fNz + (iz + 1));
60 
61  // Return interpolated field value
62  return Interpolate(dx, dy, dz) * fHemiX * fHemiY;
63  }
64 
65  return 0.;
66 }
67 // ------------------------------------------------------------------------
68 
69 
70 // ----------- Get y component of the field ---------------------------
71 Double_t CbmFieldMapSym3::GetBy(Double_t x, Double_t y, Double_t z) {
72 
73  Int_t ix = 0;
74  Int_t iy = 0;
75  Int_t iz = 0;
76  Double_t dx = 0.;
77  Double_t dy = 0.;
78  Double_t dz = 0.;
79 
80  if (IsInside(x, y, z, ix, iy, iz, dx, dy, dz)) {
81 
82  // Get By field values at grid cell corners
83  fHa[0][0][0] = fBy->At(ix * fNy * fNz + iy * fNz + iz);
84  fHa[1][0][0] = fBy->At((ix + 1) * fNy * fNz + iy * fNz + iz);
85  fHa[0][1][0] = fBy->At(ix * fNy * fNz + (iy + 1) * fNz + iz);
86  fHa[1][1][0] = fBy->At((ix + 1) * fNy * fNz + (iy + 1) * fNz + iz);
87  fHa[0][0][1] = fBy->At(ix * fNy * fNz + iy * fNz + (iz + 1));
88  fHa[1][0][1] = fBy->At((ix + 1) * fNy * fNz + iy * fNz + (iz + 1));
89  fHa[0][1][1] = fBy->At(ix * fNy * fNz + (iy + 1) * fNz + (iz + 1));
90  fHa[1][1][1] = fBy->At((ix + 1) * fNy * fNz + (iy + 1) * fNz + (iz + 1));
91 
92  // Return interpolated field value
93  return Interpolate(dx, dy, dz);
94  }
95 
96  return 0.;
97 }
98 // ------------------------------------------------------------------------
99 
100 
101 // ----------- Get z component of the field ---------------------------
102 Double_t CbmFieldMapSym3::GetBz(Double_t x, Double_t y, Double_t z) {
103 
104  Int_t ix = 0;
105  Int_t iy = 0;
106  Int_t iz = 0;
107  Double_t dx = 0.;
108  Double_t dy = 0.;
109  Double_t dz = 0.;
110 
111  if (IsInside(x, y, z, ix, iy, iz, dx, dy, dz)) {
112 
113  // Get Bz field values at grid cell corners
114  fHa[0][0][0] = fBz->At(ix * fNy * fNz + iy * fNz + iz);
115  fHa[1][0][0] = fBz->At((ix + 1) * fNy * fNz + iy * fNz + iz);
116  fHa[0][1][0] = fBz->At(ix * fNy * fNz + (iy + 1) * fNz + iz);
117  fHa[1][1][0] = fBz->At((ix + 1) * fNy * fNz + (iy + 1) * fNz + iz);
118  fHa[0][0][1] = fBz->At(ix * fNy * fNz + iy * fNz + (iz + 1));
119  fHa[1][0][1] = fBz->At((ix + 1) * fNy * fNz + iy * fNz + (iz + 1));
120  fHa[0][1][1] = fBz->At(ix * fNy * fNz + (iy + 1) * fNz + (iz + 1));
121  fHa[1][1][1] = fBz->At((ix + 1) * fNy * fNz + (iy + 1) * fNz + (iz + 1));
122 
123  // Return interpolated field value
124  return Interpolate(dx, dy, dz) * fHemiY * fHemiZ;
125  }
126 
127  return 0.;
128 }
129 // ------------------------------------------------------------------------
130 
131 
132 // ----------- Check whether a point is inside the map ----------------
133 Bool_t CbmFieldMapSym3::IsInside(Double_t x,
134  Double_t y,
135  Double_t z,
136  Int_t& ix,
137  Int_t& iy,
138  Int_t& iz,
139  Double_t& dx,
140  Double_t& dy,
141  Double_t& dz) {
142 
143  // --- Transform into local coordinate system
144  Double_t xl = x - fPosX;
145  Double_t yl = y - fPosY;
146  Double_t zl = z - fPosZ;
147 
148  // --- Reflect w.r.t. symmetry axes
149  fHemiX = fHemiY = fHemiZ = 1.;
150  if (xl < 0.) {
151  fHemiX = -1.;
152  xl = -1. * xl;
153  }
154  if (yl < 0.) {
155  fHemiY = -1.;
156  yl = -1. * yl;
157  }
158  if (zl < 0.) {
159  fHemiZ = -1.;
160  zl = -1. * zl;
161  }
162 
163  // --- Check for being outside the map range
164  if (!(xl >= fXmin && xl < fXmax && yl >= fYmin && yl < fYmax && zl >= fZmin
165  && zl < fZmax)) {
166  ix = iy = iz = 0;
167  dx = dy = dz = 0.;
168  return kFALSE;
169  }
170 
171  // --- Determine grid cell
172  ix = Int_t((xl - fXmin) / fXstep);
173  iy = Int_t((yl - fYmin) / fYstep);
174  iz = Int_t((zl - fZmin) / fZstep);
175 
176  // Relative distance from grid point (in units of cell size)
177  dx = (xl - fXmin) / fXstep - Double_t(ix);
178  dy = (yl - fYmin) / fYstep - Double_t(iy);
179  dz = (zl - fZmin) / fZstep - Double_t(iz);
180 
181  return kTRUE;
182 }
183 // ------------------------------------------------------------------------
184 
185 
CbmFieldMapSym3
Definition: CbmFieldMapSym3.h:35
CbmFieldMap::Interpolate
Double_t Interpolate(Double_t dx, Double_t dy, Double_t dz)
Definition: CbmFieldMap.cxx:786
CbmFieldMap::fYmin
Double_t fYmin
Definition: CbmFieldMap.h:210
CbmFieldMap::GetBy
TArrayF * GetBy() const
Definition: CbmFieldMap.h:159
CbmFieldMap::fXmin
Double_t fXmin
Definition: CbmFieldMap.h:209
CbmFieldMap::fPosZ
Double_t fPosZ
Definition: CbmFieldMap.h:205
CbmFieldMap::fNz
Int_t fNz
Definition: CbmFieldMap.h:215
CbmFieldMap::fNy
Int_t fNy
Definition: CbmFieldMap.h:215
CbmFieldMapSym3::CbmFieldMapSym3
CbmFieldMapSym3()
Definition: CbmFieldMapSym3.cxx:11
CbmFieldMapSym3::IsInside
virtual Bool_t IsInside(Double_t x, Double_t y, Double_t z, Int_t &ix, Int_t &iy, Int_t &iz, Double_t &dx, Double_t &dy, Double_t &dz)
Definition: CbmFieldMapSym3.cxx:133
CbmFieldMapSym3::fHemiZ
Double_t fHemiZ
Definition: CbmFieldMapSym3.h:86
CbmFieldMap::fXstep
Double_t fXstep
Definition: CbmFieldMap.h:209
CbmFieldMap::fPosX
Double_t fPosX
Definition: CbmFieldMap.h:205
CbmFieldMap::fZstep
Double_t fZstep
Definition: CbmFieldMap.h:211
CbmFieldMap::fZmin
Double_t fZmin
Definition: CbmFieldMap.h:211
CbmFieldMap::fBz
TArrayF * fBz
Definition: CbmFieldMap.h:221
CbmFieldMap::fBy
TArrayF * fBy
Definition: CbmFieldMap.h:220
CbmFieldMap::GetBz
TArrayF * GetBz() const
Definition: CbmFieldMap.h:160
CbmFieldMap
Definition: CbmFieldMap.h:34
CbmFieldMap::fPosY
Double_t fPosY
Definition: CbmFieldMap.h:205
CbmFieldMapSym3.h
CbmFieldMapSym3::fHemiY
Double_t fHemiY
Definition: CbmFieldMapSym3.h:86
CbmFieldMapSym3::fHemiX
Double_t fHemiX
Definition: CbmFieldMapSym3.h:86
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmFieldMap::fBx
TArrayF * fBx
Definition: CbmFieldMap.h:219
CbmFieldMap::fYstep
Double_t fYstep
Definition: CbmFieldMap.h:210
CbmFieldMapSym3::~CbmFieldMapSym3
virtual ~CbmFieldMapSym3()
Definition: CbmFieldMapSym3.cxx:35
CbmFieldMap::fZmax
Double_t fZmax
Definition: CbmFieldMap.h:211
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmFieldMap::fHa
Double_t fHa[2][2][2]
Definition: CbmFieldMap.h:226
CbmFieldPar
Definition: CbmFieldPar.h:31
CbmFieldMap::GetBx
TArrayF * GetBx() const
Definition: CbmFieldMap.h:158