CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SpecialCylindricalMFGrid Class Reference

#include <SpecialCylindricalMFGrid.h>

Inheritance diagram for SpecialCylindricalMFGrid:
MFGrid3D MFGrid MagneticFieldProvider< float >

List of all members.

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.
 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.
virtual LocalVector uncheckedValueInTesla (const LocalPoint &p) const
 Interpolated field value at given point; does not check for exceptions.

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_

Detailed Description

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

Date:
2008/04/09 20:16:04
Revision:
1.2
Author:
T. Todorov - updated 08 N. Amapane

Definition at line 18 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().

  : MFGrid3D(vol)
{
  if (gridType == 5 ) {
    sector1 = false;
  } else if (gridType == 6 ) {
    sector1 = true;
  } else {
    cout << "ERROR wrong SpecialCylindricalMFGrid type " << gridType << endl;
    sector1 = false;
  }

  int n1, n2, n3;
  inFile >> n1 >> n2 >> n3;
#ifdef DEBUG_GRID
  cout << "n1 " << n1 << " n2 " << n2 << " n3 " << n3 << endl;
#endif
  double xref, yref, zref;
  inFile >> xref >> yref >> zref;
  double stepx, stepy, stepz;
  inFile >> stepx    >> stepy    >> stepz;

  double RParAsFunOfPhi[4];  // R = f(phi) or const. (0,2: const. par. ; 1,3: const./sin(phi));
  inFile >> RParAsFunOfPhi[0] >> RParAsFunOfPhi[1] >> RParAsFunOfPhi[2] >> RParAsFunOfPhi[3];

  vector<BVector> fieldValues;
  float Bx, By, Bz;
  int nLines = n1*n2*n3;
  fieldValues.reserve(nLines);
  for (int iLine=0; iLine<nLines; ++iLine){
    inFile >> Bx >> By >> Bz;
    // This would be fine only if local r.f. has the axes oriented as the global r.f.
    // For this volume we know that the local and global r.f. have different axis
    // orientation, so we do not try to be clever.
    //    fieldValues.push_back(BVector(Bx,By,Bz));
    
    // Preserve double precision!
    Vector3DBase<double, LocalTag>  lB = frame().toLocal(Vector3DBase<double, GlobalTag>(Bx,By,Bz));
    fieldValues.push_back(BVector(lB.x(), lB.y(), lB.z()));
  }
  // check completeness
  string lastEntry;
  inFile >> lastEntry;
  if (lastEntry != "complete"){
    cout << "ERROR during file reading: file is not complete" << endl;
  }

  GlobalPoint grefp( GlobalPoint::Cylindrical( xref, yref, zref));

#ifdef DEBUG_GRID
  LocalPoint lrefp = frame().toLocal( grefp);
  cout << "Grid reference point in grid system: " << xref << "," << yref << "," << zref << endl;
  cout << "Grid reference point in global x,y,z: " << grefp << endl;
  cout << "Grid reference point in local x,y,z: " << lrefp << endl;
  cout << "steps " << stepx << "," <<  stepy << "," << stepz << endl;
  cout << "RParAsFunOfPhi[0...4] = ";
  for (int i=0; i<4; ++i) cout << RParAsFunOfPhi[i] << " "; cout << endl;
#endif

  Grid1D gridX( 0, n1-1, n1); // offset and step size not constant
  Grid1D gridY( yref, yref + stepy*(n2-1), n2);
  Grid1D gridZ( grefp.z(), grefp.z() + stepz*(n3-1), n3);

  grid_ = GridType( gridX, gridY, gridZ, fieldValues);

  stepConstTerm_ = (RParAsFunOfPhi[0] - RParAsFunOfPhi[2]) / (n1-1);
  stepPhiTerm_   = (RParAsFunOfPhi[1] - RParAsFunOfPhi[3]) / (n1-1);
  startConstTerm_ = RParAsFunOfPhi[2];
  startPhiTerm_   = RParAsFunOfPhi[3];

  // Activate/deactivate timers
//   static SimpleConfigurable<bool> timerOn(false,"MFGrid:timing");
//   (*TimingReport::current()).switchOn("MagneticFieldProvider::valueInTesla(SpecialCylindricalMFGrid)",timerOn);
}

Member Function Documentation

void SpecialCylindricalMFGrid::dump ( void  ) const [virtual]

Reimplemented from MFGrid.

Definition at line 101 of file SpecialCylindricalMFGrid.cc.

{}
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().

{
  double sinPhi; // sin or cos depending on wether we are at phi=0 or phi=pi/2
  if (sector1) {
    sinPhi = cos(b);
  } else {
    sinPhi = sin(b);
  }
  
  double R = a*stepSize(sinPhi) + startingPoint(sinPhi);
  // "OLD" convention of phi.
  //  GlobalPoint gp( GlobalPoint::Cylindrical(R, Geom::pi() - b, c));
  GlobalPoint gp( GlobalPoint::Cylindrical(R, b, c));
  return frame().toLocal(gp);
}
double SpecialCylindricalMFGrid::startingPoint ( double  sinPhi) const [inline, private]

Definition at line 46 of file SpecialCylindricalMFGrid.h.

References startConstTerm_, and startPhiTerm_.

Referenced by fromGridFrame(), and toGridFrame().

{return startConstTerm_ + startPhiTerm_/sinPhi;}
double SpecialCylindricalMFGrid::stepSize ( double  sinPhi) const [inline, private]

Definition at line 45 of file SpecialCylindricalMFGrid.h.

References stepConstTerm_, and stepPhiTerm_.

Referenced by fromGridFrame(), and toGridFrame().

{return stepConstTerm_ + stepPhiTerm_ /sinPhi;}
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().

{
  GlobalPoint gp = frame().toGlobal(p);
  double sinPhi; // sin or cos depending on wether we are at phi=0 or phi=pi/2
  if (sector1) {
    sinPhi = cos(gp.phi());
  } else {
    sinPhi = sin(gp.phi());
  }
  a = (gp.perp()-startingPoint(sinPhi))/stepSize(sinPhi);
  // FIXME: "OLD" convention of phi.
  // b = Geom::pi() - gp.phi();
  b = gp.phi();
  c = gp.z();

#ifdef DEBUG_GRID
  if (sector1) {
    cout << "toGridFrame: sinPhi " ;
  } else {
    cout << "toGridFrame: cosPhi " ;
  }
  cout << sinPhi << " LocalPoint " << p 
       << " GlobalPoint " << gp << endl 
       << " a " << a << " b " << b << " c " << c << endl;
    
#endif
}
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().

{
//   static TimingReport::Item & timer= (*TimingReport::current())["MagneticFieldProvider::valueInTesla(SpecialCylindricalMFGrid)"];
//   TimeMe t(timer,false);

  LinearGridInterpolator3D interpol( grid_);
  double a, b, c;
  toGridFrame( p, a, b, c);
  // the following holds if B values was not converted to local coords -- see ctor
//   GlobalVector gv( interpol.interpolate( a, b, c)); // grid in global frame
//   return frame().toLocal(gv);           // must return a local vector
  return LocalVector(interpol.interpolate( a, b, c));
}

Member Data Documentation

Definition at line 47 of file SpecialCylindricalMFGrid.h.

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

Definition at line 42 of file SpecialCylindricalMFGrid.h.

Referenced by SpecialCylindricalMFGrid(), and startingPoint().

Definition at line 43 of file SpecialCylindricalMFGrid.h.

Referenced by SpecialCylindricalMFGrid(), and startingPoint().

Definition at line 40 of file SpecialCylindricalMFGrid.h.

Referenced by SpecialCylindricalMFGrid(), and stepSize().

Definition at line 41 of file SpecialCylindricalMFGrid.h.

Referenced by SpecialCylindricalMFGrid(), and stepSize().