CMS 3D CMS Logo

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

#include <SpecialCylindricalMFGrid.h>

Inheritance diagram for SpecialCylindricalMFGrid:
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...
 
 SpecialCylindricalMFGrid (binary_ifstream &istr, const GloballyPositioned< float > &vol, int gridType)
 
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 ()
 

Private Member Functions

double startingPoint (double sinPhi) const
 
double stepSize (double sinPhi) const
 

Private Attributes

bool sector1
 
double startConstTerm_
 
double startPhiTerm_
 
double stepConstTerm_
 
double stepPhiTerm_
 

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

Interpolator for cylindrical grids type 5 or 6 (r,phi,z) 1/sin(phi) or 1/cos(phi)

Author
T. Todorov - updated 08 N. Amapane

Definition at line 18 of file SpecialCylindricalMFGrid.h.

Member Typedef Documentation

◆ binary_ifstream

Definition at line 20 of file SpecialCylindricalMFGrid.h.

Constructor & Destructor Documentation

◆ SpecialCylindricalMFGrid()

SpecialCylindricalMFGrid::SpecialCylindricalMFGrid ( binary_ifstream istr,
const GloballyPositioned< float > &  vol,
int  gridType 
)

Constructor. gridType = 5 => 1/sin(phi); i.e. master sector is #4 gridType = 6 => 1/cos(phi); i.e. master sector is #1

Definition at line 9 of file SpecialCylindricalMFGrid.cc.

References gather_cfg::cout, MFGrid::frame(), MFGrid3D::grid_, mps_fire::i, testHGCalDigi_cfg::inFile, submitDQMOfflineCAF::nLines, sector1, startConstTerm_, startPhiTerm_, stepConstTerm_, stepPhiTerm_, GloballyPositioned< T >::toLocal(), PV3DBase< T, VectorTag, FrameTag >::x(), PV3DBase< T, VectorTag, FrameTag >::y(), and PV3DBase< T, VectorTag, FrameTag >::z().

12  : MFGrid3D(vol) {
13  if (gridType == 5) {
14  sector1 = false;
15  } else if (gridType == 6) {
16  sector1 = true;
17  } else {
18  cout << "ERROR wrong SpecialCylindricalMFGrid type " << gridType << endl;
19  sector1 = false;
20  }
21 
22  int n1, n2, n3;
23  inFile >> n1 >> n2 >> n3;
24 #ifdef DEBUG_GRID
25  cout << "n1 " << n1 << " n2 " << n2 << " n3 " << n3 << endl;
26 #endif
27  double xref, yref, zref;
28  inFile >> xref >> yref >> zref;
29  double stepx, stepy, stepz;
30  inFile >> stepx >> stepy >> stepz;
31 
32  double RParAsFunOfPhi[4]; // R = f(phi) or const. (0,2: const. par. ; 1,3: const./sin(phi));
33  inFile >> RParAsFunOfPhi[0] >> RParAsFunOfPhi[1] >> RParAsFunOfPhi[2] >> RParAsFunOfPhi[3];
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  // This would be fine only if local r.f. has the axes oriented as the global r.f.
42  // For this volume we know that the local and global r.f. have different axis
43  // orientation, so we do not try to be clever.
44  // fieldValues.push_back(BVector(Bx,By,Bz));
45 
46  // Preserve double precision!
48  fieldValues.push_back(BVector(lB.x(), lB.y(), lB.z()));
49  }
50  // check completeness
51  string lastEntry;
52  inFile >> lastEntry;
53  if (lastEntry != "complete") {
54  cout << "ERROR during file reading: file is not complete" << endl;
55  }
56 
57  GlobalPoint grefp(GlobalPoint::Cylindrical(xref, yref, zref));
58 
59 #ifdef DEBUG_GRID
60  LocalPoint lrefp = frame().toLocal(grefp);
61  cout << "Grid reference point in grid system: " << xref << "," << yref << "," << zref << endl;
62  cout << "Grid reference point in global x,y,z: " << grefp << endl;
63  cout << "Grid reference point in local x,y,z: " << lrefp << endl;
64  cout << "steps " << stepx << "," << stepy << "," << stepz << endl;
65  cout << "RParAsFunOfPhi[0...4] = ";
66  for (int i = 0; i < 4; ++i)
67  cout << RParAsFunOfPhi[i] << " ";
68  cout << endl;
69 #endif
70 
71  Grid1D gridX(0, n1 - 1, n1); // offset and step size not constant
72  Grid1D gridY(yref, yref + stepy * (n2 - 1), n2);
73  Grid1D gridZ(grefp.z(), grefp.z() + stepz * (n3 - 1), n3);
74 
75  grid_ = GridType(gridX, gridY, gridZ, fieldValues);
76 
77  stepConstTerm_ = (RParAsFunOfPhi[0] - RParAsFunOfPhi[2]) / (n1 - 1);
78  stepPhiTerm_ = (RParAsFunOfPhi[1] - RParAsFunOfPhi[3]) / (n1 - 1);
79  startConstTerm_ = RParAsFunOfPhi[2];
80  startPhiTerm_ = RParAsFunOfPhi[3];
81 
82  // Activate/deactivate timers
83  // static SimpleConfigurable<bool> timerOn(false,"MFGrid:timing");
84  // (*TimingReport::current()).switchOn("MagneticFieldProvider::valueInTesla(SpecialCylindricalMFGrid)",timerOn);
85 }
MFGrid3D(const GloballyPositioned< float > &vol)
Definition: MFGrid3D.h:19
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

Member Function Documentation

◆ dump()

void SpecialCylindricalMFGrid::dump ( void  ) const
overridevirtual

Reimplemented from MFGrid.

Definition at line 100 of file SpecialCylindricalMFGrid.cc.

100 {}

◆ fromGridFrame()

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

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

Implements MFGrid.

Definition at line 102 of file SpecialCylindricalMFGrid.cc.

References a, b, HltBtagPostValidation_cff::c, funct::cos(), MFGrid::frame(), runTauDisplay::gp, dttmaxenums::R, sector1, funct::sin(), l1tSlwPFPuppiJets_cfi::sinPhi, startingPoint(), stepSize(), and GloballyPositioned< T >::toLocal().

102  {
103  double sinPhi; // sin or cos depending on wether we are at phi=0 or phi=pi/2
104  if (sector1) {
105  sinPhi = cos(b);
106  } else {
107  sinPhi = sin(b);
108  }
109 
110  double R = a * stepSize(sinPhi) + startingPoint(sinPhi);
111  // "OLD" convention of phi.
112  // GlobalPoint gp( GlobalPoint::Cylindrical(R, Geom::pi() - b, c));
114  return frame().toLocal(gp);
115 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double stepSize(double sinPhi) const
LocalPoint toLocal(const GlobalPoint &gp) const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const GloballyPositioned< float > & frame() const
Local reference frame.
Definition: MFGrid.h:60
double b
Definition: hdecay.h:120
double startingPoint(double sinPhi) const
double a
Definition: hdecay.h:121

◆ startingPoint()

double SpecialCylindricalMFGrid::startingPoint ( double  sinPhi) const
inlineprivate

◆ stepSize()

double SpecialCylindricalMFGrid::stepSize ( double  sinPhi) const
inlineprivate

◆ toGridFrame()

void SpecialCylindricalMFGrid::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 117 of file SpecialCylindricalMFGrid.cc.

References a, b, HltBtagPostValidation_cff::c, funct::cos(), gather_cfg::cout, MFGrid::frame(), runTauDisplay::gp, AlCaHLTBitMon_ParallelJobs::p, sector1, funct::sin(), l1tSlwPFPuppiJets_cfi::sinPhi, startingPoint(), stepSize(), and GloballyPositioned< T >::toGlobal().

Referenced by uncheckedValueInTesla().

117  {
119  double sinPhi; // sin or cos depending on wether we are at phi=0 or phi=pi/2
120  if (sector1) {
121  sinPhi = cos(gp.phi());
122  } else {
123  sinPhi = sin(gp.phi());
124  }
125  a = (gp.perp() - startingPoint(sinPhi)) / stepSize(sinPhi);
126  // FIXME: "OLD" convention of phi.
127  // b = Geom::pi() - gp.phi();
128  b = gp.phi();
129  c = gp.z();
130 
131 #ifdef DEBUG_GRID
132  if (sector1) {
133  cout << "toGridFrame: sinPhi ";
134  } else {
135  cout << "toGridFrame: cosPhi ";
136  }
137  cout << sinPhi << " LocalPoint " << p << " GlobalPoint " << gp << endl
138  << " a " << a << " b " << b << " c " << c << endl;
139 
140 #endif
141 }
GlobalPoint toGlobal(const LocalPoint &lp) const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double stepSize(double sinPhi) const
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
const GloballyPositioned< float > & frame() const
Local reference frame.
Definition: MFGrid.h:60
double b
Definition: hdecay.h:120
double startingPoint(double sinPhi) const
double a
Definition: hdecay.h:121

◆ uncheckedValueInTesla()

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

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

Implements MFGrid3D.

Definition at line 87 of file SpecialCylindricalMFGrid.cc.

References a, b, HltBtagPostValidation_cff::c, MFGrid3D::grid_, LinearGridInterpolator3D::interpolate(), AlCaHLTBitMon_ParallelJobs::p, and toGridFrame().

87  {
88  // static TimingReport::Item & timer= (*TimingReport::current())["MagneticFieldProvider::valueInTesla(SpecialCylindricalMFGrid)"];
89  // TimeMe t(timer,false);
90 
92  double a, b, c;
93  toGridFrame(p, a, b, c);
94  // the following holds if B values was not converted to local coords -- see ctor
95  // GlobalVector gv( interpol.interpolate( a, b, c)); // grid in global frame
96  // return frame().toLocal(gv); // must return a local vector
97  return LocalVector(interpol.interpolate(a, b, c));
98 }
void toGridFrame(const LocalPoint &p, double &a, double &b, double &c) const override
find grid coordinates for point. For debugging and validation only.
GridType grid_
Definition: MFGrid3D.h:59
double b
Definition: hdecay.h:120
GloballyPositioned< float >::LocalVector LocalVector
Definition: MFGrid.h:32
double a
Definition: hdecay.h:121

Member Data Documentation

◆ sector1

bool SpecialCylindricalMFGrid::sector1
private

Definition at line 45 of file SpecialCylindricalMFGrid.h.

Referenced by fromGridFrame(), SpecialCylindricalMFGrid(), and toGridFrame().

◆ startConstTerm_

double SpecialCylindricalMFGrid::startConstTerm_
private

Definition at line 40 of file SpecialCylindricalMFGrid.h.

Referenced by SpecialCylindricalMFGrid().

◆ startPhiTerm_

double SpecialCylindricalMFGrid::startPhiTerm_
private

Definition at line 41 of file SpecialCylindricalMFGrid.h.

Referenced by SpecialCylindricalMFGrid().

◆ stepConstTerm_

double SpecialCylindricalMFGrid::stepConstTerm_
private

Definition at line 38 of file SpecialCylindricalMFGrid.h.

Referenced by SpecialCylindricalMFGrid().

◆ stepPhiTerm_

double SpecialCylindricalMFGrid::stepPhiTerm_
private

Definition at line 39 of file SpecialCylindricalMFGrid.h.

Referenced by SpecialCylindricalMFGrid().