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