CMS 3D CMS Logo

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

#include <RectangularCylindricalMFGrid.h>

Inheritance diagram for RectangularCylindricalMFGrid:
MFGrid3D MFGrid MagneticFieldProvider< float >

Public Member Functions

virtual void dump () const
 
virtual LocalPoint fromGridFrame (double a, double b, double c) const
 find grid coordinates for point. For debugging and validation only. More...
 
 RectangularCylindricalMFGrid (binary_ifstream &istr, const GloballyPositioned< float > &vol)
 
virtual void toGridFrame (const LocalPoint &p, double &a, double &b, double &c) const
 find grid coordinates for point. For debugging and validation only. More...
 
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 ()
 

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 9 of file RectangularCylindricalMFGrid.h.

Constructor & Destructor Documentation

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

Definition at line 8 of file RectangularCylindricalMFGrid.cc.

References gather_cfg::cout, MFGrid::frame(), MFGrid3D::grid_, submitDQMOfflineCAF::nLines, and GloballyPositioned< T >::toLocal().

10  : MFGrid3D(vol)
11 {
12  // The parameters read from the data files are given in global coordinates.
13  // In version 85l, local frame has the same orientation of global frame for the reference
14  // volume, i.e. the r.f. transformation is only a translation.
15  // There is therefore no need to convert the field values to local coordinates.
16  // Check this assumption:
17  GlobalVector localXDir(frame().toGlobal(LocalVector(1,0,0)));
18  GlobalVector localYDir(frame().toGlobal(LocalVector(0,1,0)));
19 
20  if (localXDir.dot(GlobalVector(1,0,0)) > 0.999999 &&
21  localYDir.dot(GlobalVector(0,1,0)) > 0.999999) {
22  // "null" rotation - requires no conversion...
23  } else {
24  cout << "ERROR: RectangularCylindricalMFGrid: unexpected orientation: x: "
25  << localXDir << " y: " << localYDir << endl;
26  }
27 
28  int n1, n2, n3;
29  inFile >> n1 >> n2 >> n3;
30  double xref, yref, zref;
31  inFile >> xref >> yref >> zref;
32  double stepx, stepy, stepz;
33  inFile >> stepx >> stepy >> stepz;
34 
35  vector<BVector> fieldValues;
36  float Bx, By, Bz;
37  int nLines = n1*n2*n3;
38  fieldValues.reserve(nLines);
39  for (int iLine=0; iLine<nLines; ++iLine){
40  inFile >> Bx >> By >> Bz;
41  fieldValues.push_back(BVector(Bx,By,Bz));
42  }
43  // check completeness
44  string lastEntry;
45  inFile >> lastEntry;
46  if (lastEntry != "complete"){
47  cout << "ERROR during file reading: file is not complete" << endl;
48  }
49 
50  GlobalPoint grefp( GlobalPoint::Cylindrical( xref, yref, zref));
51  LocalPoint lrefp = frame().toLocal( grefp);
52 
53 #ifdef DEBUG_GRID
54  cout << "Grid reference point in grid system: " << xref << "," << yref << "," << zref << endl;
55  cout << "Grid reference point in global x,y,z: " << grefp << endl;
56  cout << "Grid reference point in local x,y,z: " << lrefp << endl;
57  cout << "steps " << stepx << "," << stepy << "," << stepz << endl;
58 #endif
59 
60  Grid1D gridX( lrefp.perp(), lrefp.perp() + stepx*(n1-1), n1);
61  //Grid1D gridY( lrefp.phi(), lrefp.phi() + stepy*(n2-1), n2); // wrong: gives zero
62  Grid1D gridY( yref, yref + stepy*(n2-1), n2);
63  Grid1D gridZ( lrefp.z(), lrefp.z() + stepz*(n3-1), n3);
64 
65  grid_ = GridType( gridX, gridY, gridZ, fieldValues);
66 
67 }
T perp() const
Definition: PV3DBase.h:72
MFGrid3D(const GloballyPositioned< float > &vol)
Definition: MFGrid3D.h:20
GloballyPositioned< float >::GlobalVector GlobalVector
Definition: MFGrid.h:33
LocalPoint toLocal(const GlobalPoint &gp) const
T z() const
Definition: PV3DBase.h:64
GridType grid_
Definition: MFGrid3D.h:62
Definition: Grid1D.h:7
Grid3D GridType
Definition: MFGrid3D.h:59
Grid3D::BVector BVector
Definition: MFGrid3D.h:60
GloballyPositioned< float >::LocalVector LocalVector
Definition: MFGrid.h:35
const GloballyPositioned< float > & frame() const
Local reference frame.
Definition: MFGrid.h:63
tuple cout
Definition: gather_cfg.py:145

Member Function Documentation

void RectangularCylindricalMFGrid::dump ( void  ) const
virtual

Reimplemented from MFGrid.

Definition at line 69 of file RectangularCylindricalMFGrid.cc.

References gather_cfg::cout, Grid3D::data(), MFGrid3D::grid_, Grid3D::grida(), Grid3D::gridb(), Grid3D::gridc(), Grid1D::lower(), Grid1D::nodes(), and Grid1D::step().

70 {
71  cout << endl << "Dump of RectangularCylindricalMFGrid" << endl;
72  cout << "Number of points from Grid1D "
73  << grid_.grida().nodes() << " " << grid_.gridb().nodes() << " " << grid_.gridc().nodes() << endl;
74 
75  cout << "Reference Point from Grid1D "
76  << grid_.grida().lower() << " " << grid_.gridb().lower() << " " << grid_.gridc().lower() << endl;
77 
78  cout << "Basic Distance from Grid1D "
79  << grid_.grida().step() << " " << grid_.gridb().step() << " " << grid_.gridc().step() << endl;
80 
81 
82  cout << "Dumping " << grid_.data().size() << " field values " << endl;
83  // grid_.dump();
84 }
Scalar step() const
Definition: Grid1D.h:21
const Grid1D & grida() const
Definition: Grid3D.h:67
int nodes() const
Definition: Grid1D.h:24
const Grid1D & gridc() const
Definition: Grid3D.h:69
const Container & data() const
Definition: Grid3D.h:71
Scalar lower() const
Definition: Grid1D.h:22
GridType grid_
Definition: MFGrid3D.h:62
tuple cout
Definition: gather_cfg.py:145
const Grid1D & gridb() const
Definition: Grid3D.h:68
MFGrid::LocalPoint RectangularCylindricalMFGrid::fromGridFrame ( double  a,
double  b,
double  c 
) const
virtual

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

Implements MFGrid.

Definition at line 116 of file RectangularCylindricalMFGrid.cc.

117 {
118 
119  // FIXME: "OLD" convention of phi.
120  // return LocalPoint( LocalPoint::Cylindrical(a, Geom::pi() - b, c));
121  return LocalPoint( LocalPoint::Cylindrical(a, b, c));
122 }
GloballyPositioned< float >::LocalPoint LocalPoint
Definition: MFGrid.h:34
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
void RectangularCylindricalMFGrid::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 106 of file RectangularCylindricalMFGrid.cc.

108 {
109  a = p.perp();
110  // FIXME: "OLD" convention of phi.
111  // b = Geom::pi() - p.phi();
112  b = p.phi();
113  c = p.z();
114 }
T perp() const
Definition: PV3DBase.h:72
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
T z() const
Definition: PV3DBase.h:64
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
MFGrid::LocalVector RectangularCylindricalMFGrid::uncheckedValueInTesla ( const LocalPoint p) const
virtual

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

Implements MFGrid3D.

Definition at line 86 of file RectangularCylindricalMFGrid.cc.

References alignCSCRings::e, MFGrid3D::grid_, Grid3D::grida(), Grid3D::gridc(), Grid1D::index(), LinearGridInterpolator3D::interpolate(), relval_2017::k, Grid1D::lower(), Grid1D::node(), dttmaxenums::R, mps_fire::result, Grid1D::step(), and relativeConstraints::value.

87 {
88  const float minimalSignificantR = 1e-6; // [cm], points below this radius are treated as zero radius
89  float R = p.perp();
90  if (R < minimalSignificantR) {
91  if (grid_.grida().lower() < minimalSignificantR) {
92  int k = grid_.gridc().index(p.z());
93  double u = (p.z() - grid_.gridc().node(k)) / grid_.gridc().step();
94  LocalVector result((1-u)*grid_(0, 0, k) + u*grid_(0, 0, k+1));
95  return result;
96  }
97  }
98 
100  // FIXME: "OLD" convention of phi.
101  // GridType::ValueType value = interpol( R, Geom::pi() - p.phi(), p.z());
102  GridType::ReturnType value = interpol.interpolate( R, p.phi(), p.z());
103  return LocalVector(value);
104 }
Scalar step() const
Definition: Grid1D.h:21
const Grid1D & grida() const
Definition: Grid3D.h:67
T perp() const
Definition: PV3DBase.h:72
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Scalar node(int i) const
Definition: Grid1D.h:27
tuple result
Definition: mps_fire.py:95
const Grid1D & gridc() const
Definition: Grid3D.h:69
T z() const
Definition: PV3DBase.h:64
ValueType ReturnType
Definition: Grid3D.h:34
Scalar lower() const
Definition: Grid1D.h:22
GridType grid_
Definition: MFGrid3D.h:62
GloballyPositioned< float >::LocalVector LocalVector
Definition: MFGrid.h:35
int index(Scalar a, Scalar &f) const
Definition: Grid1D.h:34