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