CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/MagneticField/Interpolation/src/CylinderFromSectorMFGrid.cc

Go to the documentation of this file.
00001 #include "CylinderFromSectorMFGrid.h"
00002 #include "MagneticField/VolumeGeometry/interface/MagExceptions.h"
00003 #include <iostream>
00004 
00005 CylinderFromSectorMFGrid::CylinderFromSectorMFGrid( const GloballyPositioned<float>& vol,
00006                                                     double phiMin, double phiMax,
00007                                                     MFGrid* sectorGrid) :
00008   MFGrid(vol), thePhiMin(phiMin), thePhiMax(phiMax), theSectorGrid( sectorGrid)
00009 
00010 {
00011    if (thePhiMax < thePhiMin) thePhiMax += 2.0*Geom::pi();
00012    theDelta = thePhiMax - thePhiMin;
00013 }
00014 
00015 CylinderFromSectorMFGrid::~CylinderFromSectorMFGrid()
00016 {
00017   delete theSectorGrid;
00018 }
00019 
00020 MFGrid::LocalVector CylinderFromSectorMFGrid::valueInTesla( const LocalPoint& p) const
00021 {
00022   double phi = p.phi();
00023   if (phi < thePhiMax && phi > thePhiMin) return theSectorGrid->valueInTesla(p);
00024   else {
00025     double phiRot = floor((phi-thePhiMin)/theDelta) * theDelta;
00026     double c = cos(phiRot);
00027     double s = sin(phiRot);
00028     double xrot =  p.x()*c + p.y()*s;
00029     double yrot = -p.x()*s + p.y()*c;
00030 
00031     // get field in interpolation sector 
00032     MFGrid::LocalVector tmp = theSectorGrid->valueInTesla( LocalPoint(xrot,yrot,p.z()));
00033 
00034     // rotate field back to original sector
00035     return MFGrid::LocalVector( tmp.x()*c - tmp.y()*s, tmp.x()*s + tmp.y()*c, tmp.z());
00036   }
00037 }
00038 
00039 void CylinderFromSectorMFGrid::throwUp( const char *message) const
00040 {
00041   std::cout << "Throwing exception " << message << std::endl;
00042   throw MagGeometryError(message);
00043 }
00044 void CylinderFromSectorMFGrid::toGridFrame( const LocalPoint& p, double& a, double& b, double& c) const 
00045 {
00046   throwUp("Not implemented yet");
00047 }
00048 
00049 MFGrid::LocalPoint CylinderFromSectorMFGrid::fromGridFrame( double a, double b, double c) const
00050 {
00051   throwUp("Not implemented yet");
00052   return LocalPoint();
00053 }
00054 
00055 Dimensions CylinderFromSectorMFGrid::dimensions() const 
00056 {return theSectorGrid->dimensions();}
00057 
00058 MFGrid::LocalPoint  CylinderFromSectorMFGrid::nodePosition( int i, int j, int k) const
00059 {
00060   throwUp("Not implemented yet");
00061   return LocalPoint();
00062 }
00063 
00064 MFGrid::LocalVector CylinderFromSectorMFGrid::nodeValue( int i, int j, int k) const
00065 {
00066   throwUp("Not implemented yet");
00067   return LocalVector();
00068 }