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
RectangularCartesianMFGrid Class Reference

#include <RectangularCartesianMFGrid.h>

Inheritance diagram for RectangularCartesianMFGrid:
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...
 
 RectangularCartesianMFGrid (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 RectangularCartesianMFGrid.h.

Constructor & Destructor Documentation

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

Definition at line 9 of file RectangularCartesianMFGrid.cc.

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

11  : MFGrid3D(vol)
12 {
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: RectangularCartesianMFGrid: 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  vector<BVector> fieldValues;
38  float Bx, By, Bz;
39  int nLines = n1*n2*n3;
40  fieldValues.reserve(nLines);
41  for (int iLine=0; iLine<nLines; ++iLine){
42  inFile >> Bx >> By >> Bz;
43  fieldValues.push_back(BVector(Bx,By,Bz));
44  }
45  // check completeness
46  string lastEntry;
47  inFile >> lastEntry;
48  if (lastEntry != "complete"){
49  cout << "ERROR during file reading: file is not complete" << endl;
50  }
51 
52  GlobalPoint grefp( xref, yref, zref);
53  LocalPoint lrefp = frame().toLocal( grefp);
54 
55  Grid1D gridX( lrefp.x(), lrefp.x() + stepx*(n1-1), n1);
56  Grid1D gridY( lrefp.y(), lrefp.y() + stepy*(n2-1), n2);
57  Grid1D gridZ( lrefp.z(), lrefp.z() + stepz*(n3-1), n3);
58  grid_ = GridType( gridX, gridY, gridZ, fieldValues);
59 
60  // Activate/deactivate timers
61 // static SimpleConfigurable<bool> timerOn(false,"MFGrid:timing");
62 // (*TimingReport::current()).switchOn("MagneticFieldProvider::valueInTesla(RectangularCartesianMFGrid)",timerOn);
63 
64 }
MFGrid3D(const GloballyPositioned< float > &vol)
Definition: MFGrid3D.h:20
T y() const
Definition: PV3DBase.h:63
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:121
T x() const
Definition: PV3DBase.h:62

Member Function Documentation

void RectangularCartesianMFGrid::dump ( void  ) const
virtual

Reimplemented from MFGrid.

Definition at line 66 of file RectangularCartesianMFGrid.cc.

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

67 {
68  cout << endl << "Dump of RectangularCartesianMFGrid" << endl;
69 // cout << "Number of points from file "
70 // << n1 << " " << n2 << " " << n3 << endl;
71  cout << "Number of points from Grid1D "
72  << grid_.grida().nodes() << " " << grid_.gridb().nodes() << " " << grid_.gridc().nodes() << endl;
73 
74 // cout << "Reference Point from file "
75 // << xref << " " << yref << " " << zref << endl;
76  cout << "Reference Point from Grid1D "
77  << grid_.grida().lower() << " " << grid_.gridb().lower() << " " << grid_.gridc().lower() << endl;
78 
79 // cout << "Basic Distance from file "
80 // << stepx << " " << stepy << " " << stepz << endl;
81  cout << "Basic Distance from Grid1D "
82  << grid_.grida().step() << " " << grid_.gridb().step() << " " << grid_.gridc().step() << endl;
83 
84 
85  cout << "Dumping " << grid_.data().size() << " field values " << endl;
86  // grid_.dump();
87 }
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:121
const Grid1D & gridb() const
Definition: Grid3D.h:68
MFGrid::LocalPoint RectangularCartesianMFGrid::fromGridFrame ( double  a,
double  b,
double  c 
) const
virtual

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

Implements MFGrid.

Definition at line 108 of file RectangularCartesianMFGrid.cc.

109 {
110  return LocalPoint( a, b, c);
111 }
GloballyPositioned< float >::LocalPoint LocalPoint
Definition: MFGrid.h:34
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
void RectangularCartesianMFGrid::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 100 of file RectangularCartesianMFGrid.cc.

102 {
103  a = p.x();
104  b = p.y();
105  c = p.z();
106 }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
T x() const
Definition: PV3DBase.h:62
MFGrid::LocalVector RectangularCartesianMFGrid::uncheckedValueInTesla ( const LocalPoint p) const
virtual

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

Implements MFGrid3D.

Definition at line 90 of file RectangularCartesianMFGrid.cc.

References MFGrid3D::grid_, LinearGridInterpolator3D::interpolate(), and relativeConstraints::value.

91 {
92 // static TimingReport::Item & timer= (*TimingReport::current())["MagneticFieldProvider::valueInTesla(RectangularCartesianMFGrid)"];
93 // TimeMe t(timer,false);
94 
96  GridType::ReturnType value = interpol.interpolate( p.x(), p.y(), p.z());
97  return LocalVector(value);
98 }
T y() const
Definition: PV3DBase.h:63
T z() const
Definition: PV3DBase.h:64
ValueType ReturnType
Definition: Grid3D.h:34
GridType grid_
Definition: MFGrid3D.h:62
GloballyPositioned< float >::LocalVector LocalVector
Definition: MFGrid.h:35
T x() const
Definition: PV3DBase.h:62