Project
Loading...
Searching...
No Matches
MagFieldFast.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
15#ifndef ALICEO2_FIELD_MAGFIELDFAST_H_
16#define ALICEO2_FIELD_MAGFIELDFAST_H_
17
18#include <GPUCommonRtypes.h>
19#include "MathUtils/Cartesian.h"
20
21#ifndef GPUCA_GPUCODE_DEVICE
22#include <string>
23#endif
24
25namespace o2
26{
27namespace field
28{
29// Fast polynomial parametrization of Alice magnetic field, to be used for reconstruction.
30// Solenoid part fitted by Shuto Yamasaki from AliMagWrapCheb in the |Z|<260Interface and R<500 cm
31// Dipole part: to do
33{
34 public:
35 enum { kNSolRRanges = 5,
38 kNPolCoefs = 20 };
39 enum EDim { kX,
43 struct SolParam {
45 };
46
47 MagFieldFast(const std::string inpFName = "");
48 MagFieldFast(float factor, int nomField = 5, const std::string inpFmt = "$(O2_ROOT)/share/Common/maps/sol%dk.txt");
49 MagFieldFast(const MagFieldFast& src) = default;
50 ~MagFieldFast() = default;
51
52 bool LoadData(const std::string inpFName);
53
54 bool Field(const double xyz[3], double bxyz[3]) const;
55 bool Field(const float xyz[3], float bxyz[3]) const;
56 bool Field(const math_utils::Point3D<float> xyz, float bxyz[3]) const;
57 bool Field(const math_utils::Point3D<double> xyz, double bxyz[3]) const;
58 bool GetBcomp(EDim comp, const double xyz[3], double& b) const;
59 bool GetBcomp(EDim comp, const float xyz[3], float& b) const;
60 bool GetBcomp(EDim comp, const math_utils::Point3D<float> xyz, double& b) const;
61 bool GetBcomp(EDim comp, const math_utils::Point3D<float> xyz, float& b) const;
62
63 bool GetBx(const double xyz[3], double& bx) const { return GetBcomp(kX, xyz, bx); }
64 bool GetBx(const float xyz[3], float& bx) const { return GetBcomp(kX, xyz, bx); }
65 bool GetBy(const double xyz[3], double& by) const { return GetBcomp(kY, xyz, by); }
66 bool GetBy(const float xyz[3], float& by) const { return GetBcomp(kY, xyz, by); }
67 bool GetBz(const double xyz[3], double& bz) const { return GetBcomp(kZ, xyz, bz); }
68 bool GetBz(const float xyz[3], float& bz) const { return GetBcomp(kZ, xyz, bz); }
69 void setFactorSol(float v = 1.f) { mFactorSol = v; }
70 float getFactorSol() const { return mFactorSol; }
71
72 protected:
73 bool GetSegment(float x, float y, float z, int& zSeg, int& rSeg, int& quadrant) const;
74 static const float kSolR2Max[kNSolRRanges]; // Rmax2 of each range
75 static const float kSolZMax; // max |Z| for solenoid parametrization
76
77 int GetQuadrant(float x, float y) const
78 {
80 return y > 0 ? (x > 0 ? 0 : 1) : (x > 0 ? 3 : 2);
81 }
82
83 float CalcPol(const float* cf, float x, float y, float z) const;
84
85 private:
86 float mFactorSol; // scaling factor
87 SolParam mSolPar[kNSolRRanges][kNSolZRanges][kNQuadrants];
88
89 ClassDefNV(MagFieldFast, 1);
90};
91
92inline float MagFieldFast::CalcPol(const float* cf, float x, float y, float z) const
93{
100 float val = cf[0] + x * (cf[1] + x * (cf[4] + x * cf[10] + y * cf[11] + z * cf[12]) + y * (cf[5] + z * cf[14])) +
101 y * (cf[2] + y * (cf[7] + x * cf[13] + y * cf[16] + z * cf[17]) + z * (cf[8])) +
102 z * (cf[3] + z * (cf[9] + x * cf[15] + y * cf[18] + z * cf[19]) + x * (cf[6]));
103
104 return val;
105}
106} // namespace field
107} // namespace o2
108
109#endif
bool GetBx(const float xyz[3], float &bx) const
bool GetBy(const float xyz[3], float &by) const
bool GetBy(const double xyz[3], double &by) const
bool GetBx(const double xyz[3], double &bx) const
float getFactorSol() const
static const float kSolZMax
void setFactorSol(float v=1.f)
bool GetBz(const double xyz[3], double &bz) const
bool Field(const double xyz[3], double bxyz[3]) const
bool GetBz(const float xyz[3], float &bz) const
bool GetBcomp(EDim comp, const double xyz[3], double &b) const
MagFieldFast(const MagFieldFast &src)=default
int GetQuadrant(float x, float y) const
bool GetSegment(float x, float y, float z, int &zSeg, int &rSeg, int &quadrant) const
float CalcPol(const float *cf, float x, float y, float z) const
bool LoadData(const std::string inpFName)
static const float kSolR2Max[kNSolRRanges]
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum src
Definition glcorearb.h:1767
const GLdouble * v
Definition glcorearb.h:832
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLuint GLfloat * val
Definition glcorearb.h:1582
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
float parBxyz[kNDim][kNPolCoefs]