CbmRoot
Loading...
Searching...
No Matches
CbmFieldMapSym1.cxx
Go to the documentation of this file.
1/* Copyright (C) 2008-2020 Justus-Liebig-Universitaet Giessen, Giessen
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Elena Litvinenko, Elena Lebedeva [committer] */
4
5// -------------------------------------------------------------------------
6// ----- CbmFieldMapSym1 source file -----
7// ----- Created 22/09/08 by E.Litvinenko -----
8// -------------------------------------------------------------------------
9#include "CbmFieldMapSym1.h"
10
11#include <TArrayF.h> // for TArrayF
12
13// ------------- Default constructor ----------------------------------
14CbmFieldMapSym1::CbmFieldMapSym1() : CbmFieldMap(), fHemiX(0.) { fType = 5; }
15// ------------------------------------------------------------------------
16
17
18// ------------- Standard constructor ---------------------------------
19CbmFieldMapSym1::CbmFieldMapSym1(const char* mapName, const char* fileType) : CbmFieldMap(mapName, fileType), fHemiX(0.)
20{
21 fType = 5;
22}
23// ------------------------------------------------------------------------
24
25
26// ------------ Constructor from CbmFieldPar --------------------------
27CbmFieldMapSym1::CbmFieldMapSym1(CbmFieldPar* fieldPar) : CbmFieldMap(fieldPar), fHemiX(0.) { fType = 5; }
28// ------------------------------------------------------------------------
29
30
31// ------------ Destructor --------------------------------------------
33// ------------------------------------------------------------------------
34
35
36// ----------- Get x component of the field ---------------------------
37Double_t CbmFieldMapSym1::GetBx(Double_t x, Double_t y, Double_t z)
38{
39
40 Int_t ix = 0;
41 Int_t iy = 0;
42 Int_t iz = 0;
43 Double_t dx = 0.;
44 Double_t dy = 0.;
45 Double_t dz = 0.;
46
47 if (IsInside(x, y, z, ix, iy, iz, dx, dy, dz)) {
48
49 // Get Bx field values at grid cell corners
50 fHa[0][0][0] = fBx->At(ix * fNy * fNz + iy * fNz + iz);
51 fHa[1][0][0] = fBx->At((ix + 1) * fNy * fNz + iy * fNz + iz);
52 fHa[0][1][0] = fBx->At(ix * fNy * fNz + (iy + 1) * fNz + iz);
53 fHa[1][1][0] = fBx->At((ix + 1) * fNy * fNz + (iy + 1) * fNz + iz);
54 fHa[0][0][1] = fBx->At(ix * fNy * fNz + iy * fNz + (iz + 1));
55 fHa[1][0][1] = fBx->At((ix + 1) * fNy * fNz + iy * fNz + (iz + 1));
56 fHa[0][1][1] = fBx->At(ix * fNy * fNz + (iy + 1) * fNz + (iz + 1));
57 fHa[1][1][1] = fBx->At((ix + 1) * fNy * fNz + (iy + 1) * fNz + (iz + 1));
58
59 // Return interpolated field value
60 return Interpolate(dx, dy, dz) * fHemiX;
61 }
62
63 return 0.;
64}
65// ------------------------------------------------------------------------
66
67
68// ----------- Get y component of the field ---------------------------
69Double_t CbmFieldMapSym1::GetBy(Double_t x, Double_t y, Double_t z)
70{
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 ---------------------------
101Double_t CbmFieldMapSym1::GetBz(Double_t x, Double_t y, Double_t z)
102{
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);
125 }
126
127 return 0.;
128}
129// ------------------------------------------------------------------------
130
131
132// ----------- Check whether a point is inside the map ----------------
133Bool_t CbmFieldMapSym1::IsInside(Double_t x, Double_t y, Double_t z, Int_t& ix, Int_t& iy, Int_t& iz, Double_t& dx,
134 Double_t& dy, Double_t& dz)
135{
136
137 // --- Transform into local coordinate system
138 Double_t xl = x - fPosX;
139 Double_t yl = y - fPosY;
140 Double_t zl = z - fPosZ;
141
142 // --- Reflect w.r.t. symmetry axes
143 fHemiX = 1.;
144 if (xl < 0.) {
145 fHemiX = -1.;
146 xl = -1. * xl;
147 }
148
149 // --- Check for being outside the map range
150 if (!(xl >= fXmin && xl < fXmax && yl >= fYmin && yl < fYmax && zl >= fZmin && zl < fZmax)) {
151 ix = iy = iz = 0;
152 dx = dy = dz = 0.;
153 return kFALSE;
154 }
155
156 // --- Determine grid cell
157 ix = Int_t((xl - fXmin) / fXstep);
158 iy = Int_t((yl - fYmin) / fYstep);
159 iz = Int_t((zl - fZmin) / fZstep);
160
161
162 // Relative distance from grid point (in units of cell size)
163 dx = (xl - fXmin) / fXstep - Double_t(ix);
164 dy = (yl - fYmin) / fYstep - Double_t(iy);
165 dz = (zl - fZmin) / fZstep - Double_t(iz);
166
167 return kTRUE;
168}
169// ------------------------------------------------------------------------
170
171
ClassImp(CbmConverterManager)
virtual ~CbmFieldMapSym1()
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)
Double_t fPosZ
TArrayF * fBy
Double_t fPosY
TArrayF * GetBz() const
Double_t fPosX
Double_t fZmin
Double_t fZmax
Double_t fYmin
Double_t fHa[2][2][2]
TArrayF * GetBx() const
TArrayF * fBx
TArrayF * fBz
Double_t fXmin
Double_t fYstep
Double_t fZstep
Double_t Interpolate(Double_t dx, Double_t dy, Double_t dz)
Double_t fXstep
TArrayF * GetBy() const