ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHField2D.h
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHField2D.h
1 
2 #ifndef PHFIELD_PHFIELD2D_H
3 #define PHFIELD_PHFIELD2D_H
4 
5 #include "PHField.h"
6 
7 #include <boost/tuple/tuple.hpp>
8 
9 #include <map>
10 #include <string>
11 #include <vector>
12 
13 class PHField2D : public PHField
14 {
15  typedef boost::tuple<float, float> trio;
16 
17  public:
18  PHField2D(const std::string &filename, const int verb = 0, const float magfield_rescale = 1.0);
19  ~PHField2D() override {}
24  void GetFieldValue(const double Point[4], double *Bfield) const override;
25 
26  void GetFieldCyl(const double CylPoint[4], double *Bfield) const;
27 
28  protected:
29  // < i, j, k > , this allows i and i+1 to be neighbors ( <i,j,k>=<z,r,phi> )
30  std::vector<std::vector<float> > BFieldZ_;
31  std::vector<std::vector<float> > BFieldR_;
32  std::vector<std::vector<float> > BFieldPHI_;
33 
34  // maps indices to values z_map[i] = z_value that corresponds to ith index
35  std::vector<float> z_map_; // < i >
36  std::vector<float> r_map_; // < j >
37  std::vector<float> phi_map_; // < k >
38 
39  float maxz_, minz_; // boundaries of magnetic field map cyl
40  double magfield_unit;
41 
42  private:
43  void print_map(std::map<trio, trio>::iterator &it) const;
44  // mutable allows to change internal data even in const methods
45  // I don't like this too much but these are cached values to speed up
46  // the field lookup by a lot
47  // I want them to be data members so we can run 2 fieldmaps in parallel
48  // and still have caching. Putting those as static variables into
49  // the implementation will prevent this
50  mutable unsigned int r_index0_cache;
51  mutable unsigned int r_index1_cache;
52  mutable unsigned int z_index0_cache;
53  mutable unsigned int z_index1_cache;
54 };
55 
56 #endif