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