Project
Loading...
Searching...
No Matches
GPUTPCGMPolynomialField.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
14
15#ifndef GPUTPCGMPOLYNOMIALFIELD_H
16#define GPUTPCGMPOLYNOMIALFIELD_H
17
18#include "GPUCommonDef.h"
19
20namespace o2::gpu
21{
28{
29 public:
30 GPUTPCGMPolynomialField() : mNominalBz(0.f)
31 {
32 Reset();
33 }
34
35 void Reset();
36
37 void SetFieldNominal(float nominalBz);
38
39 void SetFieldTpc(const float* Bx, const float* By, const float* Bz);
40 void SetFieldTrd(const float* Bx, const float* By, const float* Bz);
41 void SetFieldIts(const float* Bx, const float* By, const float* Bz);
42
43 GPUdi() float GetNominalBz() const { return mNominalBz; }
44
45 GPUd() void GetField(float x, float y, float z, float* B) const;
46 GPUd() float GetFieldBz(float x, float y, float z) const;
47
48 GPUd() void GetFieldTrd(float x, float y, float z, float* B) const;
49 GPUd() float GetFieldTrdBz(float x, float y, float z) const;
50
51 GPUd() void GetFieldIts(float x, float y, float z, float* B) const;
52 GPUd() float GetFieldItsBz(float x, float y, float z) const;
53
54 void Print() const;
55
56 static constexpr const int32_t NTPCM = 10; // number of coefficients
57 static constexpr const int32_t NTRDM = 20; // number of coefficients for the TRD field
58 static constexpr const int32_t NITSM = 10; // number of coefficients for the ITS field
59
60 GPUd() static void GetPolynomsTpc(float x, float y, float z, float f[NTPCM]);
61 GPUd() static void GetPolynomsTrd(float x, float y, float z, float f[NTRDM]);
62 GPUd() static void GetPolynomsIts(float x, float y, float z, float f[NITSM]);
63
64 const float* GetCoefmTpcBx() const { return mTpcBx; }
65 const float* GetCoefmTpcBy() const { return mTpcBy; }
66 const float* GetCoefmTpcBz() const { return mTpcBz; }
67
68 const float* GetCoefmTrdBx() const { return mTrdBx; }
69 const float* GetCoefmTrdBy() const { return mTrdBy; }
70 const float* GetCoefmTrdBz() const { return mTrdBz; }
71
72 const float* GetCoefmItsBx() const { return mItsBx; }
73 const float* GetCoefmItsBy() const { return mItsBy; }
74 const float* GetCoefmItsBz() const { return mItsBz; }
75
76 private:
77 float mNominalBz; // nominal constant field value in [kG * 2.99792458E-4 GeV/c/cm]
78 float mTpcBx[NTPCM]; // polynomial coefficients
79 float mTpcBy[NTPCM];
80 float mTpcBz[NTPCM];
81 float mTrdBx[NTRDM]; // polynomial coefficients
82 float mTrdBy[NTRDM];
83 float mTrdBz[NTRDM];
84 float mItsBx[NITSM]; // polynomial coefficients
85 float mItsBy[NITSM];
86 float mItsBz[NITSM];
87};
88
90{
91 mNominalBz = 0.f;
92 for (int32_t i = 0; i < NTPCM; i++) {
93 mTpcBx[i] = 0.f;
94 mTpcBy[i] = 0.f;
95 mTpcBz[i] = 0.f;
96 }
97 for (int32_t i = 0; i < NTRDM; i++) {
98 mTrdBx[i] = 0.f;
99 mTrdBy[i] = 0.f;
100 mTrdBz[i] = 0.f;
101 }
102 for (int32_t i = 0; i < NITSM; i++) {
103 mItsBx[i] = 0.f;
104 mItsBy[i] = 0.f;
105 mItsBz[i] = 0.f;
106 }
107}
108
109inline void GPUTPCGMPolynomialField::SetFieldNominal(float nominalBz) { mNominalBz = nominalBz; }
110
111inline void GPUTPCGMPolynomialField::SetFieldTpc(const float* Bx, const float* By, const float* Bz)
112{
113 if (Bx && By && Bz) {
114 for (int32_t i = 0; i < NTPCM; i++) {
115 mTpcBx[i] = Bx[i];
116 mTpcBy[i] = By[i];
117 mTpcBz[i] = Bz[i];
118 }
119 }
120}
121
122inline void GPUTPCGMPolynomialField::SetFieldTrd(const float* Bx, const float* By, const float* Bz)
123{
124 if (Bx && By && Bz) {
125 for (int32_t i = 0; i < NTRDM; i++) {
126 mTrdBx[i] = Bx[i];
127 mTrdBy[i] = By[i];
128 mTrdBz[i] = Bz[i];
129 }
130 }
131}
132
133inline void GPUTPCGMPolynomialField::SetFieldIts(const float* Bx, const float* By, const float* Bz)
134{
135 if (Bx && By && Bz) {
136 for (int32_t i = 0; i < NITSM; i++) {
137 mItsBx[i] = Bx[i];
138 mItsBy[i] = By[i];
139 mItsBz[i] = Bz[i];
140 }
141 }
142}
143
144GPUdi() void GPUTPCGMPolynomialField::GetPolynomsTpc(float x, float y, float z, float f[NTPCM])
145{
146 f[0] = 1.f;
147 f[1] = x;
148 f[2] = y;
149 f[3] = z;
150 f[4] = x * x;
151 f[5] = x * y;
152 f[6] = x * z;
153 f[7] = y * y;
154 f[8] = y * z;
155 f[9] = z * z;
156}
157
158GPUdi() void GPUTPCGMPolynomialField::GetField(float x, float y, float z, float* B) const
159{
160 const float* fBxS = &mTpcBx[1];
161 const float* fByS = &mTpcBy[1];
162 const float* fBzS = &mTpcBz[1];
163
164 const float f[NTPCM - 1] = {x, y, z, x * x, x * y, x * z, y * y, y * z, z * z};
165 float bx = mTpcBx[0], by = mTpcBy[0], bz = mTpcBz[0];
166 for (int32_t i = NTPCM - 1; i--;) {
167 // for (int32_t i=0;i<NTPCM-1; i++){
168 bx += fBxS[i] * f[i];
169 by += fByS[i] * f[i];
170 bz += fBzS[i] * f[i];
171 }
172 B[0] = bx;
173 B[1] = by;
174 B[2] = bz;
175}
176
177GPUdi() float GPUTPCGMPolynomialField::GetFieldBz(float x, float y, float z) const
178{
179 const float* fBzS = &mTpcBz[1];
180
181 const float f[NTPCM - 1] = {x, y, z, x * x, x * y, x * z, y * y, y * z, z * z};
182 float bz = mTpcBz[0];
183 for (int32_t i = NTPCM - 1; i--;) {
184 bz += fBzS[i] * f[i];
185 }
186 return bz;
187}
188
189GPUdi() void GPUTPCGMPolynomialField::GetPolynomsTrd(float x, float y, float z, float f[NTRDM])
190{
191 float xx = x * x, xy = x * y, xz = x * z, yy = y * y, yz = y * z, zz = z * z;
192 f[0] = 1.f;
193 f[1] = x;
194 f[2] = y;
195 f[3] = z;
196 f[4] = xx;
197 f[5] = xy;
198 f[6] = xz;
199 f[7] = yy;
200 f[8] = yz;
201 f[9] = zz;
202 f[10] = x * xx;
203 f[11] = x * xy;
204 f[12] = x * xz;
205 f[13] = x * yy;
206 f[14] = x * yz;
207 f[15] = x * zz;
208 f[16] = y * yy;
209 f[17] = y * yz;
210 f[18] = y * zz;
211 f[19] = z * zz;
212}
213
214GPUdi() void GPUTPCGMPolynomialField::GetFieldTrd(float x, float y, float z, float* B) const
215{
216 float f[NTRDM];
217 GetPolynomsTrd(x, y, z, f);
218 float bx = 0.f, by = 0.f, bz = 0.f;
219 for (int32_t i = 0; i < NTRDM; i++) {
220 bx += mTrdBx[i] * f[i];
221 by += mTrdBy[i] * f[i];
222 bz += mTrdBz[i] * f[i];
223 }
224 B[0] = bx;
225 B[1] = by;
226 B[2] = bz;
227}
228
229GPUdi() float GPUTPCGMPolynomialField::GetFieldTrdBz(float x, float y, float z) const
230{
231 float f[NTRDM];
232 GetPolynomsTrd(x, y, z, f);
233 float bz = 0.f;
234 for (int32_t i = 0; i < NTRDM; i++) {
235 bz += mTrdBz[i] * f[i];
236 }
237 return bz;
238}
239
240GPUdi() void GPUTPCGMPolynomialField::GetPolynomsIts(float x, float y, float z, float f[NITSM])
241{
242 float xx = x * x, xy = x * y, xz = x * z, yy = y * y, yz = y * z, zz = z * z;
243 f[0] = 1.f;
244 f[1] = x;
245 f[2] = y;
246 f[3] = z;
247 f[4] = xx;
248 f[5] = xy;
249 f[6] = xz;
250 f[7] = yy;
251 f[8] = yz;
252 f[9] = zz;
253 /*
254 f[10]=x*xx; f[11]=x*xy; f[12]=x*xz; f[13]=x*yy; f[14]=x*yz; f[15]=x*zz;
255 f[16]=y*yy; f[17]=y*yz; f[18]=y*zz;
256 f[19]=z*zz;
257 */
258}
259
260GPUdi() void GPUTPCGMPolynomialField::GetFieldIts(float x, float y, float z, float* B) const
261{
262 const float* fBxS = &mItsBx[1];
263 const float* fByS = &mItsBy[1];
264 const float* fBzS = &mItsBz[1];
265
266 const float f[NITSM - 1] = {x, y, z, x * x, x * y, x * z, y * y, y * z, z * z};
267 float bx = mItsBx[0], by = mItsBy[0], bz = mItsBz[0];
268 for (int32_t i = NITSM - 1; i--;) {
269 bx += fBxS[i] * f[i];
270 by += fByS[i] * f[i];
271 bz += fBzS[i] * f[i];
272 }
273 B[0] = bx;
274 B[1] = by;
275 B[2] = bz;
276}
277
278GPUdi() float GPUTPCGMPolynomialField::GetFieldItsBz(float x, float y, float z) const
279{
280 const float* fBzS = &mItsBz[1];
281
282 const float f[NITSM - 1] = {x, y, z, x * x, x * y, x * z, y * y, y * z, z * z};
283 float bz = mItsBz[0];
284 for (int32_t i = NITSM - 1; i--;) {
285 bz += fBzS[i] * f[i];
286 }
287 return bz;
288}
289
290} // namespace o2::gpu
291
292#endif
int32_t i
Definition B.h:16
void SetFieldTpc(const float *Bx, const float *By, const float *Bz)
void SetFieldTrd(const float *Bx, const float *By, const float *Bz)
static constexpr const int32_t NTPCM
static constexpr const int32_t NTRDM
static constexpr const int32_t NITSM
void SetFieldIts(const float *Bx, const float *By, const float *Bz)
GPUdi() float GetNominalBz() const
GPUd() void GetField(float x
GLint GLenum GLint x
Definition glcorearb.h:403
GLdouble f
Definition glcorearb.h:310
GLint y
Definition glcorearb.h:270
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
GPUdi() o2
Definition TrackTRD.h:38