CMS 3D CMS Logo

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 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

- 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
 
- 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 10 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.

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 }

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

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.

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 }

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

◆ 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.

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 }

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

Referenced by uncheckedValueInTesla().

◆ 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.

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 }

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

Member Data Documentation

◆ mapping_

Trapezoid2RectangleMappingX TrapezoidalCylindricalMFGrid::mapping_
private
Vector3DBase
Definition: Vector3DBase.h:8
Trapezoid2RectangleMappingX::rectangle
void rectangle(double xtrap, double ytrap, double &xrec, double &yrec) const
Definition: Trapezoid2RectangleMappingX.h:42
LinearGridInterpolator3D
Definition: LinearGridInterpolator3D.h:22
mps_fire.i
i
Definition: mps_fire.py:428
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
MFGrid::LocalVector
GloballyPositioned< float >::LocalVector LocalVector
Definition: MFGrid.h:32
TrapezoidalCylindricalMFGrid::toGridFrame
void toGridFrame(const LocalPoint &p, double &a, double &b, double &c) const override
find grid coordinates for point. For debugging and validation only.
Definition: TrapezoidalCylindricalMFGrid.cc:142
TrapezoidalCylindricalMFGrid::mapping_
Trapezoid2RectangleMappingX mapping_
Definition: TrapezoidalCylindricalMFGrid.h:23
submitDQMOfflineCAF.nLines
nLines
Definition: submitDQMOfflineCAF.py:676
MFGrid::frame
const GloballyPositioned< float > & frame() const
Local reference frame.
Definition: MFGrid.h:60
PV3DBase::z
T z() const
Definition: PV3DBase.h:61
MFGrid3D::GridType
Grid3D GridType
Definition: MFGrid3D.h:56
MFGrid3D::grid_
GridType grid_
Definition: MFGrid3D.h:59
h
Geom::Cylindrical2Cartesian
Definition: CoordinateSets.h:34
Grid1D
Definition: Grid1D.h:7
Geom::pi
constexpr double pi()
Definition: Pi.h:31
MFGrid3D::BVector
Grid3D::BVector BVector
Definition: MFGrid3D.h:57
MFGrid::LocalPoint
GloballyPositioned< float >::LocalPoint LocalPoint
Definition: MFGrid.h:31
Point3DBase< float, GlobalTag >
b
double b
Definition: hdecay.h:118
Trapezoid2RectangleMappingX
Definition: Trapezoid2RectangleMappingX.h:21
a
double a
Definition: hdecay.h:119
Trapezoid2RectangleMappingX::trapezoid
void trapezoid(double xrec, double yrec, double &xtrap, double &ytrap) const
Definition: Trapezoid2RectangleMappingX.h:54
MFGrid3D::MFGrid3D
MFGrid3D(const GloballyPositioned< float > &vol)
Definition: MFGrid3D.h:19
dumpMFGeometry_cfg.delta
delta
Definition: dumpMFGeometry_cfg.py:25
MagGeometryError
Definition: MagExceptions.h:18
MFGrid::GlobalVector
GloballyPositioned< float >::GlobalVector GlobalVector
Definition: MFGrid.h:30
GloballyPositioned::toLocal
LocalPoint toLocal(const GlobalPoint &gp) const
Definition: GloballyPositioned.h:98
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
PV3DBase::perp
T perp() const
Definition: PV3DBase.h:69