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();
64 TString sName(inpFName);
65 if (gSystem->ExpandPathName(sName)) {
66 LOG(fatal) <<
"Failed to expand file name " << inpFName;
68 std::ifstream in(sName.Data(), std::ifstream::in);
70 LOG(fatal) <<
"Failed to open file " << inpFName;
74 int valI, component = -1, nParams = 0, header[4] = {-1, -1, -1, -1};
77 while (std::getline(in, line)) {
78 if (line.empty() || line[0] ==
'#') {
81 std::stringstream ss(line);
85 while (cnt < 4 && (ss >> header[cnt++])) {
89 LOG(fatal) <<
"Wrong header " << line;
92 curParam = &mSolPar[header[0]][header[1]][header[2]];
94 while (cnt < header[3] && (ss >> curParam->
parBxyz[component][cnt++])) {
97 if (cnt != header[3]) {
98 LOG(fatal) <<
"Wrong data (npar=" << cnt <<
") for param " << header[0] <<
" " << header[1] <<
" " << header[2]
99 <<
" " << header[3] <<
" " << line;
110 LOG(info) <<
"Loaded " << nParams <<
" params from " << inpFName;
122 int zSeg, rSeg, quadrant;
126 const SolParam* par = &mSolPar[rSeg][zSeg][quadrant];
138 int zSeg, rSeg, quadrant;
142 const SolParam* par = &mSolPar[rSeg][zSeg][quadrant];
143 b =
CalcPol(par->parBxyz[comp], xyz[
kX], xyz[
kY], xyz[
kZ]) * mFactorSol;
152 int zSeg, rSeg, quadrant;
153 if (!
GetSegment(xyz.X(), xyz.Y(), xyz.Z(), zSeg, rSeg, quadrant)) {
156 const SolParam* par = &mSolPar[rSeg][zSeg][quadrant];
157 b =
CalcPol(par->parBxyz[comp], xyz.X(), xyz.Y(), xyz.Z()) * mFactorSol;
166 int zSeg, rSeg, quadrant;
167 if (!
GetSegment(xyz.X(), xyz.Y(), xyz.Z(), zSeg, rSeg, quadrant)) {
170 const SolParam* par = &mSolPar[rSeg][zSeg][quadrant];
171 b =
CalcPol(par->parBxyz[comp], xyz.X(), xyz.Y(), xyz.Z()) * mFactorSol;
180 int zSeg, rSeg, quadrant;
184 const SolParam* par = &mSolPar[rSeg][zSeg][quadrant];
185 b =
CalcPol(par->parBxyz[comp], xyz[
kX], xyz[
kY], xyz[
kZ]) * mFactorSol;
194 int zSeg, rSeg, quadrant;
198 const SolParam* par = &mSolPar[rSeg][zSeg][quadrant];
210 int zSeg, rSeg, quadrant;
211 if (!
GetSegment(xyz.X(), xyz.Y(), xyz.Z(), zSeg, rSeg, quadrant)) {
214 const SolParam* par = &mSolPar[rSeg][zSeg][quadrant];
215 bxyz[
kX] =
CalcPol(par->parBxyz[
kX], xyz.X(), xyz.Y(), xyz.Z()) * mFactorSol;
216 bxyz[
kY] =
CalcPol(par->parBxyz[
kY], xyz.X(), xyz.Y(), xyz.Z()) * mFactorSol;
217 bxyz[
kZ] =
CalcPol(par->parBxyz[
kZ], xyz.X(), xyz.Y(), xyz.Z()) * mFactorSol;
226 int zSeg, rSeg, quadrant;
227 if (!
GetSegment(xyz.X(), xyz.Y(), xyz.Z(), zSeg, rSeg, quadrant)) {
230 const SolParam* par = &mSolPar[rSeg][zSeg][quadrant];
231 bxyz[
kX] =
CalcPol(par->parBxyz[
kX], xyz.X(), xyz.Y(), xyz.Z()) * mFactorSol;
232 bxyz[
kY] =
CalcPol(par->parBxyz[
kY], xyz.X(), xyz.Y(), xyz.Z()) * mFactorSol;
233 bxyz[
kZ] =
CalcPol(par->parBxyz[
kZ], xyz.X(), xyz.Y(), xyz.Z()) * mFactorSol;
254 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"