Public Member Functions | Private Attributes | List of all members
EDepSim::ArbMagField Class Reference

#include <EDepSimArbMagField.hh>

Inheritance diagram for EDepSim::ArbMagField:

Public Member Functions

 ArbMagField ()
 
bool ReadFile (const std::string &fname)
 
void PrintInfo () const
 
virtual void GetFieldValue (const G4double pos[4], G4double *field) const
 

Private Attributes

std::string m_filename
 
std::array< double, 3 > m_offset
 
std::array< double, 3 > m_delta
 
std::vector< std::vector< std::vector< double > > > m_field_x
 
std::vector< std::vector< std::vector< double > > > m_field_y
 
std::vector< std::vector< std::vector< double > > > m_field_z
 

Detailed Description

Definition at line 60 of file EDepSimArbMagField.hh.

Constructor & Destructor Documentation

EDepSim::ArbMagField::ArbMagField ( )

Definition at line 38 of file EDepSimArbMagField.cc.

39 {
40 }

Member Function Documentation

void EDepSim::ArbMagField::GetFieldValue ( const G4double  pos[4],
G4double *  field 
) const
virtual

Definition at line 116 of file EDepSimArbMagField.cc.

117 {
118  const double x = pos[0];
119  const double y = pos[1];
120  const double z = pos[2];
121 
122  EDepSim::Cubic interp;
123  field[0] = interp.interpolate(x, y, z, m_field_x, m_delta[0], m_delta[1], m_delta[2], m_offset[0], m_offset[1], m_offset[2]);
124  field[1] = interp.interpolate(x, y, z, m_field_y, m_delta[0], m_delta[1], m_delta[2], m_offset[0], m_offset[1], m_offset[2]);
125  field[2] = interp.interpolate(x, y, z, m_field_z, m_delta[0], m_delta[1], m_delta[2], m_offset[0], m_offset[1], m_offset[2]);
126 }
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
std::array< double, 3 > m_offset
double interpolate(const double *point, const std::vector< std::vector< std::vector< double >>> &g, const double *delta, const double *offset) const
list x
Definition: train.py:276
std::vector< std::vector< std::vector< double > > > m_field_z
void EDepSim::ArbMagField::PrintInfo ( ) const

Definition at line 128 of file EDepSimArbMagField.cc.

129 {
130  EDepSimLog("Printing values for magnetic field.");
131  EDepSimLog("m_filename : " << m_filename
132  << "\nm_offset : " << m_offset[0] << ", " << m_offset[1] << ", " << m_offset[2]
133  << "\nm_delta : " << m_delta[0] << ", " << m_delta[1] << ", " << m_delta[2]);
134 }
#define EDepSimLog(outStream)
Definition: EDepSimLog.hh:717
std::array< double, 3 > m_delta
std::array< double, 3 > m_offset
bool EDepSim::ArbMagField::ReadFile ( const std::string fname)

Definition at line 42 of file EDepSimArbMagField.cc.

43 {
44  m_filename = fname;
45  std::fstream fin(fname, std::fstream::in);
46 
47  if(!fin.is_open())
48  {
49  EDepSimError("Can't read " << fname << std::endl);
50  return false;
51  }
52  else
53  {
54  EDepSimLog("Reading " << fname << " ...");
55  int xcount{-1}, ycount{-1}, zcount{-1};
56  double xcurr{0}, ycurr{0}, zcurr{0};
58 
59  while(std::getline(fin >> std::ws, line))
60  {
61  std::stringstream ss(line);
62 
63  if(ss.str().front() == '#')
64  continue;
65 
66  ss >> m_offset[0] >> m_offset[1] >> m_offset[2]
67  >> m_delta[0] >> m_delta[1] >> m_delta[2];
68  break;
69  }
70 
71  while(std::getline(fin >> std::ws, line))
72  {
73  double x{0}, y{0}, z{0}, fx{0}, fy{0}, fz{0}, f{0};
74  std::stringstream ss(line);
75 
76  if(ss.str().front() == '#')
77  continue;
78 
79  ss >> x >> y >> z >> fx >> fy >> fz >> f;
80 
81  if(std::abs(x - xcurr) > 0.0 || xcount < 0)
82  {
83  xcurr = x;
84  xcount += 1;
85  ycount = -1;
86  m_field_x.emplace_back(std::vector<std::vector<double>>{});
87  m_field_y.emplace_back(std::vector<std::vector<double>>{});
88  m_field_z.emplace_back(std::vector<std::vector<double>>{});
89  }
90 
91  if(std::abs(y - ycurr) > 0.0 || ycount < 0)
92  {
93  ycurr = y;
94  ycount += 1;
95  zcount = -1;
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>{});
99  }
100 
101  m_field_x[xcount][ycount].push_back(fx * tesla);
102  m_field_y[xcount][ycount].push_back(fy * tesla);
103  m_field_z[xcount][ycount].push_back(fz * tesla);
104 
105  if(std::abs(z - zcurr) > 0.0 || zcount < 0)
106  {
107  zcurr = z;
108  zcount += 1;
109  }
110  }
111  }
112 
113  return true;
114 }
#define EDepSimLog(outStream)
Definition: EDepSimLog.hh:717
std::vector< std::vector< std::vector< double > > > m_field_x
std::string string
Definition: nybbler.cc:12
struct vector vector
std::vector< std::vector< std::vector< double > > > m_field_y
std::array< double, 3 > m_delta
T abs(T value)
std::array< double, 3 > m_offset
#define EDepSimError(outStream)
Definition: EDepSimLog.hh:503
void line(double t, double *p, double &x, double &y, double &z)
list x
Definition: train.py:276
std::vector< std::vector< std::vector< double > > > m_field_z
QTextStream & endl(QTextStream &s)

Member Data Documentation

std::array<double, 3> EDepSim::ArbMagField::m_delta
private

Definition at line 72 of file EDepSimArbMagField.hh.

std::vector<std::vector<std::vector<double> > > EDepSim::ArbMagField::m_field_x
private

Definition at line 73 of file EDepSimArbMagField.hh.

std::vector<std::vector<std::vector<double> > > EDepSim::ArbMagField::m_field_y
private

Definition at line 74 of file EDepSimArbMagField.hh.

std::vector<std::vector<std::vector<double> > > EDepSim::ArbMagField::m_field_z
private

Definition at line 75 of file EDepSimArbMagField.hh.

std::string EDepSim::ArbMagField::m_filename
private

Definition at line 70 of file EDepSimArbMagField.hh.

std::array<double, 3> EDepSim::ArbMagField::m_offset
private

Definition at line 71 of file EDepSimArbMagField.hh.


The documentation for this class was generated from the following files: