CMS 3D CMS Logo

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