CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
SpecialCylindricalMFGrid Class Reference

#include <SpecialCylindricalMFGrid.h>

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

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

- 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
typedef Basic3DVector< float > BVector
 
typedef Grid3D GridType
 
- 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)

Date:
2011/04/16 12:47:37
Revision:
1.3
Author
T. Todorov - updated 08 N. Amapane

Definition at line 19 of file SpecialCylindricalMFGrid.h.

Constructor & Destructor Documentation

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 10 of file SpecialCylindricalMFGrid.cc.

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

Member Function Documentation

void SpecialCylindricalMFGrid::dump ( void  ) const
virtual

Reimplemented from MFGrid.

Definition at line 101 of file SpecialCylindricalMFGrid.cc.

101 {}
MFGrid::LocalPoint SpecialCylindricalMFGrid::fromGridFrame ( double  a,
double  b,
double  c 
) const
virtual

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

Implements MFGrid.

Definition at line 104 of file SpecialCylindricalMFGrid.cc.

References funct::cos(), MFGrid::frame(), dttmaxenums::R, sector1, funct::sin(), startingPoint(), stepSize(), and GloballyPositioned< T >::toLocal().

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

References funct::cos(), gather_cfg::cout, MFGrid::frame(), sector1, funct::sin(), startingPoint(), stepSize(), and GloballyPositioned< T >::toGlobal().

Referenced by uncheckedValueInTesla().

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

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

Implements MFGrid3D.

Definition at line 87 of file SpecialCylindricalMFGrid.cc.

References a, b, trackerHits::c, MFGrid3D::grid_, LinearGridInterpolator3D::interpolate(), and toGridFrame().

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

Member Data Documentation

bool SpecialCylindricalMFGrid::sector1
private

Definition at line 48 of file SpecialCylindricalMFGrid.h.

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

double SpecialCylindricalMFGrid::startConstTerm_
private

Definition at line 43 of file SpecialCylindricalMFGrid.h.

Referenced by SpecialCylindricalMFGrid().

double SpecialCylindricalMFGrid::startPhiTerm_
private

Definition at line 44 of file SpecialCylindricalMFGrid.h.

Referenced by SpecialCylindricalMFGrid().

double SpecialCylindricalMFGrid::stepConstTerm_
private

Definition at line 41 of file SpecialCylindricalMFGrid.h.

Referenced by SpecialCylindricalMFGrid().

double SpecialCylindricalMFGrid::stepPhiTerm_
private

Definition at line 42 of file SpecialCylindricalMFGrid.h.

Referenced by SpecialCylindricalMFGrid().