CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
TrapezoidalCylindricalMFGrid Class Reference

#include <TrapezoidalCylindricalMFGrid.h>

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

Private Attributes

Trapezoid2RectangleMappingX mapping_
 

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 12 of file TrapezoidalCylindricalMFGrid.h.

Member Typedef Documentation

◆ binary_ifstream

Definition at line 14 of file TrapezoidalCylindricalMFGrid.h.

Constructor & Destructor Documentation

◆ TrapezoidalCylindricalMFGrid()

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, dumpMFGeometry_cfg::delta, MFGrid::frame(), MFGrid3D::grid_, h, mps_fire::i, testHGCalDigi_cfg::inFile, dqmiolumiharvest::j, mapping_, submitDQMOfflineCAF::nLines, Geom::pi(), Trapezoid2RectangleMappingX::rectangle(), and GloballyPositioned< T >::toLocal().

12  : MFGrid3D(vol) {
13  // The parameters read from the data files are given in global coordinates.
14  // In version 85l, local frame has the same orientation of global frame for the reference
15  // volume, i.e. the r.f. transformation is only a translation.
16  // There is therefore no need to convert the field values to local coordinates.
17  // Check this assumption:
18  GlobalVector localXDir(frame().toGlobal(LocalVector(1, 0, 0)));
19  GlobalVector localYDir(frame().toGlobal(LocalVector(0, 1, 0)));
20 
21  if (localXDir.dot(GlobalVector(1, 0, 0)) > 0.999999 && localYDir.dot(GlobalVector(0, 1, 0)) > 0.999999) {
22  // "null" rotation - requires no conversion...
23  } else {
24  cout << "ERROR: TrapezoidalCylindricalMFGrid: unexpected orientation: x: " << localXDir << " y: " << localYDir
25  << 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  double BasicDistance1[3][3]; // linear step
36  double BasicDistance2[3][3]; // linear offset
37  bool easya, easyb, easyc;
38 
39  inFile >> BasicDistance1[0][0] >> BasicDistance1[1][0] >> BasicDistance1[2][0];
40  inFile >> BasicDistance1[0][1] >> BasicDistance1[1][1] >> BasicDistance1[2][1];
41  inFile >> BasicDistance1[0][2] >> BasicDistance1[1][2] >> BasicDistance1[2][2];
42  inFile >> BasicDistance2[0][0] >> BasicDistance2[1][0] >> BasicDistance2[2][0];
43  inFile >> BasicDistance2[0][1] >> BasicDistance2[1][1] >> BasicDistance2[2][1];
44  inFile >> BasicDistance2[0][2] >> BasicDistance2[1][2] >> BasicDistance2[2][2];
45  inFile >> easya >> easyb >> easyc;
46 
47  vector<BVector> fieldValues;
48  float Bx, By, Bz;
49  int nLines = n1 * n2 * n3;
50  fieldValues.reserve(nLines);
51  for (int iLine = 0; iLine < nLines; ++iLine) {
52  inFile >> Bx >> By >> Bz;
53  fieldValues.push_back(BVector(Bx, By, Bz));
54  }
55  // check completeness
56  string lastEntry;
57  inFile >> lastEntry;
58  if (lastEntry != "complete") {
59  cout << "ERROR during file reading: file is not complete" << endl;
60  }
61 
62 #ifdef DEBUG_GRID
63  cout << "easya " << easya << " easyb " << easyb << " easyc " << easyc << endl;
64 #endif
65 
66  if (!easyb || !easyc) {
67  throw MagGeometryError("TrapezoidalCartesianMFGrid only implemented for first coordinate");
68  }
69 
70 #ifdef DEBUG_GRID
71  cout << "Grid reference point in grid system: " << xref << "," << yref << "," << zref << endl;
72  cout << "steps " << stepx << "," << stepy << "," << stepz << endl;
73  cout << "ns " << n1 << "," << n2 << "," << n3 << endl;
74 
75  for (int i = 0; i < 3; ++i)
76  for (int j = 0; j < 3; ++j) {
77  cout << "BasicDistance1[" << i << "][" << j << "] = " << BasicDistance1[i][j] << "BasicDistance2[" << i << "]["
78  << j << "] = " << BasicDistance2[i][j] << endl;
79  }
80 #endif
81 
82  // the "not easy" coordinate is x
83  double a = stepx * (n1 - 1);
84  double b = a + BasicDistance1[0][1] * (n2 - 1) * (n1 - 1) + BasicDistance1[0][2] * (n3 - 1) * (n1 - 1);
85  // double h = stepy * (n2-1);
86  double h = stepz * (n3 - 1);
87  double delta = -BasicDistance2[0][1] * (n2 - 1) - BasicDistance2[0][2] * (n3 - 1);
88 
89 #ifdef DEBUG_GRID
90  cout << "Trapeze size (a,b,h) = " << a << "," << b << "," << h << endl;
91 #endif
92 
93  GlobalPoint grefp(GlobalPoint::Cylindrical(xref, Geom::pi() - yref, zref));
94  LocalPoint lrefp = frame().toLocal(grefp);
95 
96 #ifdef DEBUG_GRID
97  cout << "Global origin " << grefp << endl;
98  cout << "Local origin " << lrefp << endl;
99 #endif
100 
101  double baMinus1 = BasicDistance1[0][2] * (n3 - 1) / stepx;
102  if (std::abs(baMinus1) > 0.000001) {
103  double b_over_a = 1 + baMinus1;
104  double a1 = std::abs(baMinus1) > 0.000001 ? delta / baMinus1 : a / 2;
105 #ifdef DEBUG_GRID
106  cout << "a1 = " << a1 << endl;
107 #endif
108 
109  // transform reference point to grid frame
110  double x0 = lrefp.perp() + a1;
111  double y0 = lrefp.z() + h / 2.;
112  mapping_ = Trapezoid2RectangleMappingX(x0, y0, b_over_a, h);
113  } else { // parallelogram
115  }
116  double xrec, yrec;
117  mapping_.rectangle(lrefp.perp(), lrefp.z(), xrec, yrec);
118 
119  Grid1D gridX(xrec, xrec + (a + b) / 2., n1);
120  Grid1D gridY(yref, yref + stepy * (n2 - 1), n2);
121  Grid1D gridZ(yrec, yrec + h, n3);
122  grid_ = GridType(gridX, gridY, gridZ, fieldValues);
123 
124  // Activate/deactivate timers
125  // static SimpleConfigurable<bool> timerOn(false,"MFGrid:timing");
126  // (*TimingReport::current()).switchOn("MagneticFieldProvider::valueInTesla(TrapezoidalCylindricalMFGrid)",timerOn);
127 }
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
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void rectangle(double xtrap, double ytrap, double &xrec, double &yrec) const
Trapezoid2RectangleMappingX mapping_
GridType grid_
Definition: MFGrid3D.h:59
Definition: Grid1D.h:7
Grid3D GridType
Definition: MFGrid3D.h:56
Grid3D::BVector BVector
Definition: MFGrid3D.h:57
double b
Definition: hdecay.h:120
GloballyPositioned< float >::LocalVector LocalVector
Definition: MFGrid.h:32
double a
Definition: hdecay.h:121
constexpr double pi()
Definition: Pi.h:31
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

Member Function Documentation

◆ dump()

void TrapezoidalCylindricalMFGrid::dump ( void  ) const
overridevirtual

Reimplemented from MFGrid.

Definition at line 129 of file TrapezoidalCylindricalMFGrid.cc.

129 {}

◆ fromGridFrame()

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

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

Implements MFGrid.

Definition at line 149 of file TrapezoidalCylindricalMFGrid.cc.

References a, b, HltBtagPostValidation_cff::c, mapping_, and Trapezoid2RectangleMappingX::trapezoid().

149  {
150  double rtrap, ztrap;
151  mapping_.trapezoid(a, c, rtrap, ztrap);
152  // FIXME: "OLD" convention of phi.
153  // return LocalPoint(LocalPoint::Cylindrical(rtrap, Geom::pi() - b, ztrap));
154  return LocalPoint(LocalPoint::Cylindrical(rtrap, b, ztrap));
155 }
void trapezoid(double xrec, double yrec, double &xtrap, double &ytrap) const
GloballyPositioned< float >::LocalPoint LocalPoint
Definition: MFGrid.h:31
Trapezoid2RectangleMappingX mapping_
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

◆ toGridFrame()

void TrapezoidalCylindricalMFGrid::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 142 of file TrapezoidalCylindricalMFGrid.cc.

References a, b, HltBtagPostValidation_cff::c, mapping_, AlCaHLTBitMon_ParallelJobs::p, and Trapezoid2RectangleMappingX::rectangle().

Referenced by uncheckedValueInTesla().

142  {
143  mapping_.rectangle(p.perp(), p.z(), a, c);
144  // FIXME: "OLD" convention of phi.
145  // b = Geom::pi() - p.phi();
146  b = p.phi();
147 }
void rectangle(double xtrap, double ytrap, double &xrec, double &yrec) const
Trapezoid2RectangleMappingX mapping_
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

◆ uncheckedValueInTesla()

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

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

Implements MFGrid3D.

Definition at line 131 of file TrapezoidalCylindricalMFGrid.cc.

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

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

Member Data Documentation

◆ mapping_

Trapezoid2RectangleMappingX TrapezoidalCylindricalMFGrid::mapping_
private