CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions
RectangularCylindricalMFGrid Class Reference

#include <RectangularCylindricalMFGrid.h>

Inheritance diagram for RectangularCylindricalMFGrid:
MFGrid3D MFGrid MagneticFieldProvider< float >

Public Types

using binary_ifstream = magneticfield::interpolation::binary_ifstream
 
- 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, GlobalTagGlobalPointType
 
typedef Vector3DBase< float, GlobalTagGlobalVectorType
 
typedef Point3DBase< float, LocalTagLocalPointType
 
typedef Vector3DBase< float, LocalTagLocalVectorType
 

Public Member Functions

void dump () const override
 
LocalPoint fromGridFrame (double a, double b, double c) const override
 find grid coordinates for point. For debugging and validation only. More...
 
 RectangularCylindricalMFGrid (binary_ifstream &istr, const GloballyPositioned< float > &vol)
 
void toGridFrame (const LocalPoint &p, double &a, double &b, double &c) const override
 find grid coordinates for point. For debugging and validation only. More...
 
LocalVector uncheckedValueInTesla (const LocalPoint &p) const override
 Interpolated field value at given point; does not check for exceptions. More...
 
- Public Member Functions inherited from MFGrid3D
Dimensions dimensions (void) const override
 
Indexes index (const LocalPoint &p) const override
 
 MFGrid3D (const GloballyPositioned< float > &vol)
 
LocalPoint nodePosition (int i, int j, int k) const override
 Position of node in local frame. More...
 
LocalVector nodeValue (int i, int j, int k) const override
 Field value at node. More...
 
LocalVector valueInTesla (const LocalPoint &p) const override
 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)
 
 ~MFGrid () override
 
- 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

- 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 RectangularCylindricalMFGrid.h.

Member Typedef Documentation

◆ binary_ifstream

Definition at line 13 of file RectangularCylindricalMFGrid.h.

Constructor & Destructor Documentation

◆ RectangularCylindricalMFGrid()

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_, testHGCalDigi_cfg::inFile, submitDQMOfflineCAF::nLines, and GloballyPositioned< T >::toLocal().

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

Member Function Documentation

◆ dump()

void RectangularCylindricalMFGrid::dump ( void  ) const
overridevirtual

Reimplemented from MFGrid.

Definition at line 66 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().

66  {
67  cout << endl << "Dump of RectangularCylindricalMFGrid" << endl;
68  cout << "Number of points from Grid1D " << grid_.grida().nodes() << " " << grid_.gridb().nodes() << " "
69  << grid_.gridc().nodes() << endl;
70 
71  cout << "Reference Point from Grid1D " << grid_.grida().lower() << " " << grid_.gridb().lower() << " "
72  << grid_.gridc().lower() << endl;
73 
74  cout << "Basic Distance from Grid1D " << grid_.grida().step() << " " << grid_.gridb().step() << " "
75  << grid_.gridc().step() << endl;
76 
77  cout << "Dumping " << grid_.data().size() << " field values " << endl;
78  // grid_.dump();
79 }
const Container & data() const
Definition: Grid3D.h:63
const Grid1D & grida() const
Definition: Grid3D.h:59
Scalar lower() const
Definition: Grid1D.h:19
Scalar step() const
Definition: Grid1D.h:18
int nodes() const
Definition: Grid1D.h:21
GridType grid_
Definition: MFGrid3D.h:59
const Grid1D & gridb() const
Definition: Grid3D.h:60
const Grid1D & gridc() const
Definition: Grid3D.h:61

◆ fromGridFrame()

MFGrid::LocalPoint RectangularCylindricalMFGrid::fromGridFrame ( double  a,
double  b,
double  c 
) const
overridevirtual

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

Implements MFGrid.

Definition at line 108 of file RectangularCylindricalMFGrid.cc.

References a, b, and HltBtagPostValidation_cff::c.

108  {
109  // FIXME: "OLD" convention of phi.
110  // return LocalPoint( LocalPoint::Cylindrical(a, Geom::pi() - b, c));
112 }
GloballyPositioned< float >::LocalPoint LocalPoint
Definition: MFGrid.h:31
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

◆ toGridFrame()

void RectangularCylindricalMFGrid::toGridFrame ( const LocalPoint p,
double &  a,
double &  b,
double &  c 
) const
overridevirtual

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

Implements MFGrid.

Definition at line 100 of file RectangularCylindricalMFGrid.cc.

References a, b, HltBtagPostValidation_cff::c, and AlCaHLTBitMon_ParallelJobs::p.

100  {
101  a = p.perp();
102  // FIXME: "OLD" convention of phi.
103  // b = Geom::pi() - p.phi();
104  b = p.phi();
105  c = p.z();
106 }
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

◆ uncheckedValueInTesla()

MFGrid::LocalVector RectangularCylindricalMFGrid::uncheckedValueInTesla ( const LocalPoint p) const
overridevirtual

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

Implements MFGrid3D.

Definition at line 81 of file RectangularCylindricalMFGrid.cc.

References MillePedeFileConverter_cfg::e, MFGrid3D::grid_, Grid3D::grida(), Grid3D::gridc(), Grid1D::index(), LinearGridInterpolator3D::interpolate(), dqmdumpme::k, Grid1D::lower(), Grid1D::node(), AlCaHLTBitMon_ParallelJobs::p, dttmaxenums::R, mps_fire::result, and Grid1D::step().

81  {
82  const float minimalSignificantR = 1e-6; // [cm], points below this radius are treated as zero radius
83  float R = p.perp();
84  if (R < minimalSignificantR) {
85  if (grid_.grida().lower() < minimalSignificantR) {
86  int k = grid_.gridc().index(p.z());
87  double u = (p.z() - grid_.gridc().node(k)) / grid_.gridc().step();
88  LocalVector result((1 - u) * grid_(0, 0, k) + u * grid_(0, 0, k + 1));
89  return result;
90  }
91  }
92 
94  // FIXME: "OLD" convention of phi.
95  // GridType::ValueType value = interpol( R, Geom::pi() - p.phi(), p.z());
96  GridType::ReturnType value = interpol.interpolate(R, p.phi(), p.z());
97  return LocalVector(value);
98 }
const Grid1D & grida() const
Definition: Grid3D.h:59
Scalar lower() const
Definition: Grid1D.h:19
Scalar step() const
Definition: Grid1D.h:18
int index(Scalar a, Scalar &f) const
Definition: Grid1D.h:29
Scalar node(int i) const
Definition: Grid1D.h:24
Definition: value.py:1
ValueType ReturnType
Definition: Grid3D.h:33
GridType grid_
Definition: MFGrid3D.h:59
const Grid1D & gridc() const
Definition: Grid3D.h:61
GloballyPositioned< float >::LocalVector LocalVector
Definition: MFGrid.h:32