CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
MagneticFieldGrid.h
Go to the documentation of this file.
1 #ifndef MagneticFieldGrid_H
2 #define MagneticFieldGrid_H
3 
19 // interpolation package
22 
23 // used libs
24 #include <vector>
25 #include <algorithm>
26 #include <cmath>
27 #include <string>
28 #include <iostream>
29 #include <fstream>
30 
32 public:
33  // constructor
35  GridType = 0;
36  for (int i = 0; i < 3; ++i) {
37  NumberOfPoints[i] = 0;
38  };
39  for (int i = 0; i < 3; ++i) {
40  ReferencePoint[i] = 0.;
41  };
42  for (int i = 0; i < 3; ++i) {
43  BasicDistance0[i] = 0.;
44  };
45  for (int i = 0; i < 3; ++i) {
46  for (int j = 0; j < 3; ++j) {
47  BasicDistance1[i][j] = 0.;
48  };
49  };
50  for (int i = 0; i < 3; ++i) {
51  for (int j = 0; j < 3; ++j) {
52  BasicDistance2[i][j] = 0.;
53  };
54  };
55  for (int i = 0; i < 4; ++i) {
56  RParAsFunOfPhi[i] = 0.;
57  };
58  for (int i = 0; i < 3; ++i) {
59  EasyCoordinate[i] = false;
60  };
61  }
62  // destructor
64 
65 private:
66  // header classes (5: one for each type)
68  public:
69  // constructor
71  // destructor
73 
74  private:
75  public:
76  void printInfo();
77  };
78  // b-field container
80  public:
81  // constructor
82  BVector() {}
83  // destructor
84  ~BVector() {}
85 
86  private:
87  // three component vector in float precision
88  float B3[3];
89 
90  public:
91  // Accessors
92  void putB3(float Bx, float By, float Bz);
93  float bx();
94  float by();
95  float bz();
96  };
97 
98  // DEFINITION OF GRID
99  // type
100  int GridType;
101  // header
102  int NumberOfPoints[3];
103  double ReferencePoint[3];
104  double BasicDistance0[3]; // constant step
105  double BasicDistance1[3][3]; // linear step
106  double BasicDistance2[3][3]; // linear offset
107  double RParAsFunOfPhi[4]; // R = f(phi) or const. (0,2: const. par. ; 1,3: const./sin(phi))
108  bool EasyCoordinate[3];
109  // field (Bx,By,Bz) container
110  std::vector<BVector> FieldValues;
111 
112 public:
114  void load(const std::string &name);
116  int gridType();
117 
119  void interpolateAtPoint(double X1, double X2, double X3, float &Bx, float &By, float &Bz);
120 
121  // calculates indices from coordinates
122  void putCoordGetInd(double X1, double X2, double X3, int &Index1, int &Index2, int &Index3);
123  // takes indices and returns magnetic field values
124  void putIndicesGetB(int Index1, int Index2, int Index3, float &Bx, float &By, float &Bz);
125  // takes indices, calculates coordinates, and returns coordinates
126  void putIndGetCoord(int Index1, int Index2, int Index3, double &X1, double &X2, double &X3);
127  // converts three indices into one number (for the vector FieldValues)
128  int lineNumber(int Index1, int Index2, int Index3);
129 };
130 
131 #endif
std::vector< BVector > FieldValues
#define dso_internal
Definition: Visibility.h:13
def load(fileName)
Definition: svgfig.py:547
def printInfo(self, event)