test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
TrapezoidalCylindricalMFGrid Class Reference

#include <TrapezoidalCylindricalMFGrid.h>

Inheritance diagram for TrapezoidalCylindricalMFGrid:
MFGrid3D MFGrid MagneticFieldProvider< float >

Public Member Functions

void dump () const
 
virtual LocalPoint fromGridFrame (double a, double b, double c) const
 find grid coordinates for point. For debugging and validation only. More...
 
virtual void toGridFrame (const LocalPoint &p, double &a, double &b, double &c) const
 find grid coordinates for point. For debugging and validation only. More...
 
 TrapezoidalCylindricalMFGrid (binary_ifstream &istr, const GloballyPositioned< float > &vol)
 
virtual LocalVector uncheckedValueInTesla (const LocalPoint &p) const
 Interpolated field value at given point; does not check for exceptions. More...
 
- Public Member Functions inherited from MFGrid3D
virtual Dimensions dimensions (void) const
 
virtual Indexes index (const LocalPoint &p) const
 
 MFGrid3D (const GloballyPositioned< float > &vol)
 
virtual LocalPoint nodePosition (int i, int j, int k) const
 Position of node in local frame. More...
 
virtual LocalVector nodeValue (int i, int j, int k) const
 Field value at node. More...
 
virtual LocalVector valueInTesla (const LocalPoint &p) const
 Interpolated field value at given point. More...
 
- Public Member Functions inherited from MFGrid
const GloballyPositioned< float > & frame () const
 Local reference frame. More...
 
 MFGrid (const GloballyPositioned< float > &vol)
 
virtual ~MFGrid ()
 
- Public Member Functions inherited from MagneticFieldProvider< float >
virtual LocalVectorType derivativeInTeslaPerMeter (const LocalPointType &p, int N) const
 
virtual int hasDerivatives () const
 
virtual LocalVectorType valueInTesla (const LocalPointType &p) const =0
 
virtual ~MagneticFieldProvider ()
 

Private Attributes

Trapezoid2RectangleMappingX mapping_
 

Additional Inherited Members

- Public Types inherited from MFGrid
typedef GloballyPositioned
< float >::GlobalPoint 
GlobalPoint
 
typedef GloballyPositioned
< float >::GlobalVector 
GlobalVector
 
typedef GloballyPositioned
< float >::LocalPoint 
LocalPoint
 
typedef GloballyPositioned
< float >::LocalVector 
LocalVector
 
- Public Types inherited from MagneticFieldProvider< float >
typedef Point3DBase< float,
GlobalTag
GlobalPointType
 
typedef Vector3DBase< float,
GlobalTag
GlobalVectorType
 
typedef Point3DBase< float,
LocalTag
LocalPointType
 
typedef Vector3DBase< float,
LocalTag
LocalVectorType
 
- Protected Types inherited from MFGrid3D
using BVector = Grid3D::BVector
 
using GridType = Grid3D
 
- Protected Member Functions inherited from MFGrid3D
void setGrid (const GridType &grid)
 
- Protected Attributes inherited from MFGrid3D
GridType grid_
 

Detailed Description

Definition at line 11 of file TrapezoidalCylindricalMFGrid.h.

Constructor & Destructor Documentation

TrapezoidalCylindricalMFGrid::TrapezoidalCylindricalMFGrid ( binary_ifstream istr,
const GloballyPositioned< float > &  vol 
)

Definition at line 10 of file TrapezoidalCylindricalMFGrid.cc.

References a, funct::abs(), b, gather_cfg::cout, delta, MFGrid::frame(), MFGrid3D::grid_, h, i, j, mapping_, submitDQMOfflineCAF::nLines, Geom::pi(), Trapezoid2RectangleMappingX::rectangle(), and GloballyPositioned< T >::toLocal().

12  : MFGrid3D(vol)
13 {
14  // The parameters read from the data files are given in global coordinates.
15  // In version 85l, local frame has the same orientation of global frame for the reference
16  // volume, i.e. the r.f. transformation is only a translation.
17  // There is therefore no need to convert the field values to local coordinates.
18  // Check this assumption:
19  GlobalVector localXDir(frame().toGlobal(LocalVector(1,0,0)));
20  GlobalVector localYDir(frame().toGlobal(LocalVector(0,1,0)));
21 
22  if (localXDir.dot(GlobalVector(1,0,0)) > 0.999999 &&
23  localYDir.dot(GlobalVector(0,1,0)) > 0.999999) {
24  // "null" rotation - requires no conversion...
25  } else {
26  cout << "ERROR: TrapezoidalCylindricalMFGrid: unexpected orientation: x: "
27  << localXDir << " y: " << localYDir << endl;
28  }
29 
30  int n1, n2, n3;
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;
36 
37  double BasicDistance1[3][3]; // linear step
38  double BasicDistance2[3][3]; // linear offset
39  bool easya, easyb, easyc;
40 
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;
48 
49  vector<BVector> fieldValues;
50  float Bx, By, Bz;
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));
56  }
57  // check completeness
58  string lastEntry;
59  inFile >> lastEntry;
60  if (lastEntry != "complete") {
61  cout << "ERROR during file reading: file is not complete" << endl;
62  }
63 
64 #ifdef DEBUG_GRID
65  cout << "easya " << easya << " easyb " << easyb << " easyc " << easyc << endl;
66 #endif
67 
68  if (!easyb || !easyc) {
69  throw MagGeometryError("TrapezoidalCartesianMFGrid only implemented for first coordinate");
70  }
71 
72 #ifdef DEBUG_GRID
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;
76 
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;
80  }
81 #endif
82 
83  // the "not easy" coordinate is x
84  double a = stepx * (n1 -1);
85  double b = a + BasicDistance1[0][1] * (n2-1)*(n1-1) + BasicDistance1[0][2] * (n3-1)*(n1-1);
86  // double h = stepy * (n2-1);
87  double h = stepz * (n3-1);
88  double delta = -BasicDistance2[0][1] * (n2-1) -BasicDistance2[0][2] * (n3-1);
89 
90 #ifdef DEBUG_GRID
91  cout << "Trapeze size (a,b,h) = " << a << "," << b << "," << h << endl;
92 #endif
93 
94  GlobalPoint grefp( GlobalPoint::Cylindrical( xref, Geom::pi() - yref, zref));
95  LocalPoint lrefp = frame().toLocal( grefp);
96 
97 #ifdef DEBUG_GRID
98  cout << "Global origin " << grefp << endl;
99  cout << "Local origin " << lrefp << endl;
100 #endif
101 
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;
106 #ifdef DEBUG_GRID
107  cout << "a1 = " << a1 << endl;
108 #endif
109 
110  // transform reference point to grid frame
111  double x0 = lrefp.perp() + a1;
112  double y0 = lrefp.z() + h/2.;
113  mapping_ = Trapezoid2RectangleMappingX( x0, y0, b_over_a, h);
114  }
115  else { // parallelogram
116  mapping_ = Trapezoid2RectangleMappingX( 0, 0, delta/h);
117  }
118  double xrec, yrec;
119  mapping_.rectangle( lrefp.perp(), lrefp.z(), xrec, yrec);
120 
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);
124  grid_ = GridType( gridX, gridY, gridZ, fieldValues);
125 
126  // Activate/deactivate timers
127 // static SimpleConfigurable<bool> timerOn(false,"MFGrid:timing");
128 // (*TimingReport::current()).switchOn("MagneticFieldProvider::valueInTesla(TrapezoidalCylindricalMFGrid)",timerOn);
129 }
dbl * delta
Definition: mlp_gen.cc:36
int i
Definition: DBlmapReader.cc:9
T perp() const
Definition: PV3DBase.h:72
MFGrid3D(const GloballyPositioned< float > &vol)
Definition: MFGrid3D.h:20
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
GloballyPositioned< float >::GlobalVector GlobalVector
Definition: MFGrid.h:33
void rectangle(double xtrap, double ytrap, double &xrec, double &yrec) const
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
Trapezoid2RectangleMappingX mapping_
GridType grid_
Definition: MFGrid3D.h:62
Definition: Grid1D.h:7
Grid3D GridType
Definition: MFGrid3D.h:59
Grid3D::BVector BVector
Definition: MFGrid3D.h:60
double b
Definition: hdecay.h:120
GloballyPositioned< float >::LocalVector LocalVector
Definition: MFGrid.h:35
double a
Definition: hdecay.h:121
const GloballyPositioned< float > & frame() const
Local reference frame.
Definition: MFGrid.h:63
tuple cout
Definition: gather_cfg.py:145
constexpr double pi()
Definition: Pi.h:31

Member Function Documentation

void TrapezoidalCylindricalMFGrid::dump ( void  ) const
virtual

Reimplemented from MFGrid.

Definition at line 131 of file TrapezoidalCylindricalMFGrid.cc.

132 {}
MFGrid::LocalPoint TrapezoidalCylindricalMFGrid::fromGridFrame ( double  a,
double  b,
double  c 
) const
virtual

find grid coordinates for point. For debugging and validation only.

Implements MFGrid.

Definition at line 157 of file TrapezoidalCylindricalMFGrid.cc.

References mapping_, and Trapezoid2RectangleMappingX::trapezoid().

158 {
159  double rtrap, ztrap;
160  mapping_.trapezoid( a, c, rtrap, ztrap);
161  // FIXME: "OLD" convention of phi.
162  // return LocalPoint(LocalPoint::Cylindrical(rtrap, Geom::pi() - b, ztrap));
163  return LocalPoint(LocalPoint::Cylindrical(rtrap, b, ztrap));
164 }
void trapezoid(double xrec, double yrec, double &xtrap, double &ytrap) const
GloballyPositioned< float >::LocalPoint LocalPoint
Definition: MFGrid.h:34
Trapezoid2RectangleMappingX mapping_
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
void TrapezoidalCylindricalMFGrid::toGridFrame ( const LocalPoint p,
double &  a,
double &  b,
double &  c 
) const
virtual

find grid coordinates for point. For debugging and validation only.

Implements MFGrid.

Definition at line 147 of file TrapezoidalCylindricalMFGrid.cc.

References a, EnergyCorrector::c, mapping_, and Trapezoid2RectangleMappingX::rectangle().

Referenced by uncheckedValueInTesla().

149 {
150  mapping_.rectangle( p.perp(), p.z(), a, c);
151  // FIXME: "OLD" convention of phi.
152  // b = Geom::pi() - p.phi();
153  b = p.phi();
154 }
T perp() const
Definition: PV3DBase.h:72
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
void rectangle(double xtrap, double ytrap, double &xrec, double &yrec) const
T z() const
Definition: PV3DBase.h:64
Trapezoid2RectangleMappingX mapping_
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
MFGrid::LocalVector TrapezoidalCylindricalMFGrid::uncheckedValueInTesla ( const LocalPoint p) const
virtual

Interpolated field value at given point; does not check for exceptions.

Implements MFGrid3D.

Definition at line 135 of file TrapezoidalCylindricalMFGrid.cc.

References a, b, EnergyCorrector::c, MFGrid::frame(), MFGrid3D::grid_, LinearGridInterpolator3D::interpolate(), toGridFrame(), and GloballyPositioned< T >::toLocal().

136 {
137 // static TimingReport::Item & timer= (*TimingReport::current())["MagneticFieldProvider::valueInTesla(TrapezoidalCylindricalMFGrid)"];
138 // TimeMe t(timer,false);
139 
140  LinearGridInterpolator3D interpol( grid_);
141  double a, b, c;
142  toGridFrame( p, a, b, c);
143  GlobalVector gv( interpol.interpolate( a, b, c)); // grid in global frame
144  return frame().toLocal(gv); // must return a local vector
145 }
virtual void toGridFrame(const LocalPoint &p, double &a, double &b, double &c) const
find grid coordinates for point. For debugging and validation only.
LocalPoint toLocal(const GlobalPoint &gp) const
GridType grid_
Definition: MFGrid3D.h:62
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
const GloballyPositioned< float > & frame() const
Local reference frame.
Definition: MFGrid.h:63

Member Data Documentation

Trapezoid2RectangleMappingX TrapezoidalCylindricalMFGrid::mapping_
private