29 423.f * 423.f, 500.f * 500.f};
33#ifndef GPUCA_STANDALONE
41 if (!inpFName.empty() && !
LoadData(inpFName)) {
42 LOG(fatal) <<
"Failed to initialize from " << inpFName;
50 if (nomField != 2 && nomField != 5) {
51 LOG(fatal) <<
"No parametrization for nominal field of " << nomField <<
" kG";
54 pth.Form(inpFmt.data(), nomField);
56 LOG(fatal) <<
"Failed to initialize from " << pth.Data();
65 std::ifstream in(gSystem->ExpandPathName(inpFName.data()), std::ifstream::in);
67 LOG(fatal) <<
"Failed to open file " << inpFName;
71 int valI, component = -1, nParams = 0, header[4] = {-1, -1, -1, -1};
74 while (std::getline(in, line)) {
75 if (line.empty() || line[0] ==
'#') {
78 std::stringstream ss(line);
82 while (cnt < 4 && (ss >> header[cnt++])) {
86 LOG(fatal) <<
"Wrong header " << line;
89 curParam = &mSolPar[header[0]][header[1]][header[2]];
91 while (cnt < header[3] && (ss >> curParam->
parBxyz[component][cnt++])) {
94 if (cnt != header[3]) {
95 LOG(fatal) <<
"Wrong data (npar=" << cnt <<
") for param " << header[0] <<
" " << header[1] <<
" " << header[2]
96 <<
" " << header[3] <<
" " << line;
107 LOG(info) <<
"Loaded " << nParams <<
" params from " << inpFName;
119 int zSeg, rSeg, quadrant;
123 const SolParam* par = &mSolPar[rSeg][zSeg][quadrant];
135 int zSeg, rSeg, quadrant;
139 const SolParam* par = &mSolPar[rSeg][zSeg][quadrant];
140 b =
CalcPol(par->parBxyz[comp], xyz[
kX], xyz[
kY], xyz[
kZ]) * mFactorSol;
149 int zSeg, rSeg, quadrant;
150 if (!
GetSegment(xyz.X(), xyz.Y(), xyz.Z(), zSeg, rSeg, quadrant)) {
153 const SolParam* par = &mSolPar[rSeg][zSeg][quadrant];
154 b =
CalcPol(par->parBxyz[comp], xyz.X(), xyz.Y(), xyz.Z()) * mFactorSol;
163 int zSeg, rSeg, quadrant;
164 if (!
GetSegment(xyz.X(), xyz.Y(), xyz.Z(), zSeg, rSeg, quadrant)) {
167 const SolParam* par = &mSolPar[rSeg][zSeg][quadrant];
168 b =
CalcPol(par->parBxyz[comp], xyz.X(), xyz.Y(), xyz.Z()) * mFactorSol;
177 int zSeg, rSeg, quadrant;
181 const SolParam* par = &mSolPar[rSeg][zSeg][quadrant];
182 b =
CalcPol(par->parBxyz[comp], xyz[
kX], xyz[
kY], xyz[
kZ]) * mFactorSol;
191 int zSeg, rSeg, quadrant;
195 const SolParam* par = &mSolPar[rSeg][zSeg][quadrant];
207 int zSeg, rSeg, quadrant;
208 if (!
GetSegment(xyz.X(), xyz.Y(), xyz.Z(), zSeg, rSeg, quadrant)) {
211 const SolParam* par = &mSolPar[rSeg][zSeg][quadrant];
212 bxyz[
kX] =
CalcPol(par->parBxyz[
kX], xyz.X(), xyz.Y(), xyz.Z()) * mFactorSol;
213 bxyz[
kY] =
CalcPol(par->parBxyz[
kY], xyz.X(), xyz.Y(), xyz.Z()) * mFactorSol;
214 bxyz[
kZ] =
CalcPol(par->parBxyz[
kZ], xyz.X(), xyz.Y(), xyz.Z()) * mFactorSol;
223 int zSeg, rSeg, quadrant;
224 if (!
GetSegment(xyz.X(), xyz.Y(), xyz.Z(), zSeg, rSeg, quadrant)) {
227 const SolParam* par = &mSolPar[rSeg][zSeg][quadrant];
228 bxyz[
kX] =
CalcPol(par->parBxyz[
kX], xyz.X(), xyz.Y(), xyz.Z()) * mFactorSol;
229 bxyz[
kY] =
CalcPol(par->parBxyz[
kY], xyz.X(), xyz.Y(), xyz.Z()) * mFactorSol;
230 bxyz[
kZ] =
CalcPol(par->parBxyz[
kZ], xyz.X(), xyz.Y(), xyz.Z()) * mFactorSol;
251 float xx =
x *
x, yy =
y *
y, rr = xx + yy;
ClassImp(o2::field::MagFieldFast)
Definition of the fast magnetic field parametrization MagFieldFast.
static const float kSolZMax
bool Field(const double xyz[3], double bxyz[3]) const
bool GetBcomp(EDim comp, const double xyz[3], double &b) const
int GetQuadrant(float x, float y) const
bool GetSegment(float x, float y, float z, int &zSeg, int &rSeg, int &quadrant) const
MagFieldFast(const std::string inpFName="")
float CalcPol(const float *cf, float x, float y, float z) const
bool LoadData(const std::string inpFName)
static const float kSolR2Max[kNSolRRanges]
GLboolean GLboolean GLboolean b
GLdouble GLdouble GLdouble z
float parBxyz[kNDim][kNPolCoefs]
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"