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 
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) {NumberOfPoints[i] = 0;};
38  for (int i=0;i<3; ++i) {ReferencePoint[i] = 0.;};
39  for (int i=0;i<3; ++i) {BasicDistance0[i] = 0.;};
40  for (int i=0;i<3; ++i) {for (int j=0;j<3; ++j) {BasicDistance1[i][j] = 0.;};};
41  for (int i=0;i<3; ++i) {for (int j=0;j<3; ++j) {BasicDistance2[i][j] = 0.;};};
42  for (int i=0;i<4; ++i) {RParAsFunOfPhi[i] = 0.;};
43  for (int i=0;i<3; ++i) {EasyCoordinate[i] = false;};
44  }
45  // destructor
47 
48 private:
49  // header classes (5: one for each type)
51  public:
52  // constructor
54  // destructor
56  private:
57  public:
58  void printInfo();
59  };
60  // b-field container
62  public:
63  // constructor
64  BVector(){}
65  // destructor
67  private:
68  // three component vector in float precision
69  float B3[3];
70  public:
71  // Accessors
72  void putB3(float Bx, float By, float Bz);
73  float bx();
74  float by();
75  float bz();
76  };
77 
78  // DEFINITION OF GRID
79  // type
80  int GridType;
81  // header
82  int NumberOfPoints[3];
83  double ReferencePoint[3];
84  double BasicDistance0[3]; // constant step
85  double BasicDistance1[3][3]; // linear step
86  double BasicDistance2[3][3]; // linear offset
87  double RParAsFunOfPhi[4]; // R = f(phi) or const. (0,2: const. par. ; 1,3: const./sin(phi))
88  bool EasyCoordinate[3];
89  // field (Bx,By,Bz) container
90  std::vector<BVector> FieldValues;
91 
92 public:
94  void load(const std::string& name);
96  int gridType();
97 
99  void interpolateAtPoint(double X1, double X2, double X3, float &Bx, float &By, float &Bz);
100 
101  // calculates indices from coordinates
102  void putCoordGetInd(double X1, double X2, double X3, int &Index1, int &Index2, int &Index3);
103  // takes indices and returns magnetic field values
104  void putIndicesGetB(int Index1, int Index2, int Index3, float &Bx, float &By, float &Bz);
105  // takes indices, calculates coordinates, and returns coordinates
106  void putIndGetCoord(int Index1, int Index2, int Index3, double &X1, double &X2, double &X3);
107  // converts three indices into one number (for the vector FieldValues)
108  int lineNumber(int Index1, int Index2, int Index3);
109 };
110 
111 
112 #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