CMS 3D CMS Logo

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