00001 #ifndef MagneticFieldGrid_H
00002 #define MagneticFieldGrid_H
00003
00020
00021 #include "MagneticField/Interpolation/src/VectorFieldInterpolation.h"
00022 #include "MagneticField/Interpolation/src/binary_ifstream.h"
00023
00024
00025 #include <vector>
00026 #include <algorithm>
00027 #include <cmath>
00028 #include <string>
00029 #include <iostream>
00030 #include <fstream>
00031
00032 class MagneticFieldGrid{
00033 public:
00034
00035 MagneticFieldGrid(){
00036 GridType = 0;
00037 for (int i=0;i<3; ++i) {NumberOfPoints[i] = 0;};
00038 for (int i=0;i<3; ++i) {ReferencePoint[i] = 0.;};
00039 for (int i=0;i<3; ++i) {BasicDistance0[i] = 0.;};
00040 for (int i=0;i<3; ++i) {for (int j=0;j<3; ++j) {BasicDistance1[i][j] = 0.;};};
00041 for (int i=0;i<3; ++i) {for (int j=0;j<3; ++j) {BasicDistance2[i][j] = 0.;};};
00042 for (int i=0;i<4; ++i) {RParAsFunOfPhi[i] = 0.;};
00043 for (int i=0;i<3; ++i) {EasyCoordinate[i] = false;};
00044 }
00045
00046 ~MagneticFieldGrid(){}
00047
00048 private:
00049
00050 class HeaderType3{
00051 public:
00052
00053 HeaderType3(){}
00054
00055 ~HeaderType3(){}
00056 private:
00057 public:
00058 void printInfo();
00059 };
00060
00061 class BVector{
00062 public:
00063
00064 BVector(){}
00065
00066 ~BVector(){}
00067 private:
00068
00069 float B3[3];
00070 public:
00071
00072 void putB3(float Bx, float By, float Bz);
00073 float bx();
00074 float by();
00075 float bz();
00076 };
00077
00078
00079
00080 int GridType;
00081
00082 int NumberOfPoints[3];
00083 double ReferencePoint[3];
00084 double BasicDistance0[3];
00085 double BasicDistance1[3][3];
00086 double BasicDistance2[3][3];
00087 double RParAsFunOfPhi[4];
00088 bool EasyCoordinate[3];
00089
00090 std::vector<BVector> FieldValues;
00091
00092 public:
00094 void load(const std::string& name);
00096 int gridType();
00097
00099 void interpolateAtPoint(double X1, double X2, double X3, float &Bx, float &By, float &Bz);
00100
00101
00102 void putCoordGetInd(double X1, double X2, double X3, int &Index1, int &Index2, int &Index3);
00103
00104 void putIndicesGetB(int Index1, int Index2, int Index3, float &Bx, float &By, float &Bz);
00105
00106 void putIndGetCoord(int Index1, int Index2, int Index3, double &X1, double &X2, double &X3);
00107
00108 int lineNumber(int Index1, int Index2, int Index3);
00109 };
00110
00111
00112 #endif