45 std::fstream fin(fname, std::fstream::in);
55 int xcount{-1}, ycount{-1}, zcount{-1};
56 double xcurr{0}, ycurr{0}, zcurr{0};
59 while(std::getline(fin >>
std::ws, line))
61 std::stringstream ss(line);
63 if(ss.str().front() ==
'#')
71 while(std::getline(fin >>
std::ws, line))
73 double x{0},
y{0},
z{0}, fx{0}, fy{0}, fz{0},
f{0};
74 std::stringstream ss(line);
76 if(ss.str().front() ==
'#')
79 ss >>
x >>
y >>
z >> fx >> fy >> fz >>
f;
81 if(
std::abs(
x - xcurr) > 0.0 || xcount < 0)
91 if(
std::abs(
y - ycurr) > 0.0 || ycount < 0)
96 m_field_x[xcount].emplace_back(std::vector<double>{});
97 m_field_y[xcount].emplace_back(std::vector<double>{});
98 m_field_z[xcount].emplace_back(std::vector<double>{});
102 m_field_y[xcount][ycount].push_back(fy * tesla);
103 m_field_z[xcount][ycount].push_back(fz * tesla);
105 if(
std::abs(
z - zcurr) > 0.0 || zcount < 0)
118 const double x = pos[0];
119 const double y = pos[1];
120 const double z = pos[2];
130 EDepSimLog(
"Printing values for magnetic field.");
#define EDepSimLog(outStream)
std::vector< std::vector< std::vector< double > > > m_field_x
std::vector< std::vector< std::vector< double > > > m_field_y
std::array< double, 3 > m_delta
bool ReadFile(const std::string &fname)
std::array< double, 3 > m_offset
#define EDepSimError(outStream)
virtual void GetFieldValue(const G4double pos[4], G4double *field) const
void line(double t, double *p, double &x, double &y, double &z)
double interpolate(const double *point, const std::vector< std::vector< std::vector< double >>> &g, const double *delta, const double *offset) const
std::vector< std::vector< std::vector< double > > > m_field_z
QTextStream & endl(QTextStream &s)