26 cout <<
"ERROR: TrapezoidalCylindricalMFGrid: unexpected orientation: x: " 27 << localXDir <<
" y: " << localYDir << endl;
31 inFile >> n1 >> n2 >> n3;
32 double xref, yref, zref;
33 inFile >> xref >> yref >> zref;
34 double stepx, stepy, stepz;
35 inFile >> stepx >> stepy >> stepz;
37 double BasicDistance1[3][3];
38 double BasicDistance2[3][3];
39 bool easya, easyb, easyc;
41 inFile >> BasicDistance1[0][0] >> BasicDistance1[1][0] >> BasicDistance1[2][0];
42 inFile >> BasicDistance1[0][1] >> BasicDistance1[1][1] >> BasicDistance1[2][1];
43 inFile >> BasicDistance1[0][2] >> BasicDistance1[1][2] >> BasicDistance1[2][2];
44 inFile >> BasicDistance2[0][0] >> BasicDistance2[1][0] >> BasicDistance2[2][0];
45 inFile >> BasicDistance2[0][1] >> BasicDistance2[1][1] >> BasicDistance2[2][1];
46 inFile >> BasicDistance2[0][2] >> BasicDistance2[1][2] >> BasicDistance2[2][2];
47 inFile >> easya >> easyb >> easyc;
49 vector<BVector> fieldValues;
51 int nLines = n1*n2*n3;
52 fieldValues.reserve(nLines);
53 for (
int iLine=0; iLine<nLines; ++iLine){
54 inFile >> Bx >> By >> Bz;
55 fieldValues.push_back(
BVector(Bx,By,Bz));
60 if (lastEntry !=
"complete") {
61 cout <<
"ERROR during file reading: file is not complete" << endl;
65 cout <<
"easya " << easya <<
" easyb " << easyb <<
" easyc " << easyc << endl;
68 if (!easyb || !easyc) {
69 throw MagGeometryError(
"TrapezoidalCartesianMFGrid only implemented for first coordinate");
73 cout <<
"Grid reference point in grid system: " << xref <<
"," << yref <<
"," << zref << endl;
74 cout <<
"steps " << stepx <<
"," << stepy <<
"," << stepz << endl;
75 cout <<
"ns " << n1 <<
"," << n2 <<
"," << n3 << endl;
77 for (
int i=0;
i<3; ++
i)
for (
int j=0; j<3; ++j) {
78 cout <<
"BasicDistance1[" <<
i <<
"][" << j <<
"] = " << BasicDistance1[
i][j]
79 <<
"BasicDistance2[" <<
i <<
"][" << j <<
"] = " << BasicDistance2[
i][j] << endl;
84 double a = stepx * (n1 -1);
85 double b = a + BasicDistance1[0][1] * (n2-1)*(n1-1) + BasicDistance1[0][2] * (n3-1)*(n1-1);
87 double h = stepz * (n3-1);
88 double delta = -BasicDistance2[0][1] * (n2-1) -BasicDistance2[0][2] * (n3-1);
91 cout <<
"Trapeze size (a,b,h) = " << a <<
"," << b <<
"," << h << endl;
98 cout <<
"Global origin " << grefp << endl;
99 cout <<
"Local origin " << lrefp << endl;
102 double baMinus1 = BasicDistance1[0][2]*(n3-1) / stepx;
103 if (
std::abs(baMinus1) > 0.000001) {
104 double b_over_a = 1 + baMinus1;
105 double a1 =
std::abs(baMinus1) > 0.000001 ? delta / baMinus1 : a/2;
107 cout <<
"a1 = " << a1 << endl;
111 double x0 = lrefp.perp() + a1;
112 double y0 = lrefp.z() + h/2.;
121 Grid1D gridX( xrec, xrec + (a+b)/2., n1);
122 Grid1D gridY( yref, yref + stepy*(n2-1), n2);
123 Grid1D gridZ( yrec, yrec + h, n3);
148 double&
a,
double&
b,
double&
c)
const
virtual void toGridFrame(const LocalPoint &p, double &a, double &b, double &c) const
find grid coordinates for point. For debugging and validation only.
void trapezoid(double xrec, double yrec, double &xtrap, double &ytrap) const
virtual LocalVector uncheckedValueInTesla(const LocalPoint &p) const
Interpolated field value at given point; does not check for exceptions.
GloballyPositioned< float >::GlobalVector GlobalVector
GloballyPositioned< float >::LocalPoint LocalPoint
ReturnType interpolate(Scalar a, Scalar b, Scalar c)
void rectangle(double xtrap, double ytrap, double &xrec, double &yrec) const
LocalPoint toLocal(const GlobalPoint &gp) const
Abs< T >::type abs(const T &t)
TrapezoidalCylindricalMFGrid(binary_ifstream &istr, const GloballyPositioned< float > &vol)
Trapezoid2RectangleMappingX mapping_
GloballyPositioned< float >::GlobalPoint GlobalPoint
GloballyPositioned< float >::LocalVector LocalVector
virtual LocalPoint fromGridFrame(double a, double b, double c) const
find grid coordinates for point. For debugging and validation only.
const GloballyPositioned< float > & frame() const
Local reference frame.