Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:22

0001 #include "CylinderFromSectorMFGrid.h"
0002 #include "MagneticField/VolumeGeometry/interface/MagExceptions.h"
0003 #include <iostream>
0004 
0005 CylinderFromSectorMFGrid::CylinderFromSectorMFGrid(const GloballyPositioned<float>& vol,
0006                                                    double phiMin,
0007                                                    double phiMax,
0008                                                    MFGrid* sectorGrid)
0009     : MFGrid(vol),
0010       thePhiMin(phiMin),
0011       thePhiMax(phiMax),
0012       theSectorGrid(sectorGrid)
0013 
0014 {
0015   if (thePhiMax < thePhiMin)
0016     thePhiMax += 2.0 * Geom::pi();
0017   theDelta = thePhiMax - thePhiMin;
0018 }
0019 
0020 CylinderFromSectorMFGrid::~CylinderFromSectorMFGrid() { delete theSectorGrid; }
0021 
0022 MFGrid::LocalVector CylinderFromSectorMFGrid::valueInTesla(const LocalPoint& p) const {
0023   double phi = p.phi();
0024   if (phi < thePhiMax && phi > thePhiMin)
0025     return theSectorGrid->valueInTesla(p);
0026   else {
0027     double phiRot = floor((phi - thePhiMin) / theDelta) * theDelta;
0028     double c = cos(phiRot);
0029     double s = sin(phiRot);
0030     double xrot = p.x() * c + p.y() * s;
0031     double yrot = -p.x() * s + p.y() * c;
0032 
0033     // get field in interpolation sector
0034     MFGrid::LocalVector tmp = theSectorGrid->valueInTesla(LocalPoint(xrot, yrot, p.z()));
0035 
0036     // rotate field back to original sector
0037     return MFGrid::LocalVector(tmp.x() * c - tmp.y() * s, tmp.x() * s + tmp.y() * c, tmp.z());
0038   }
0039 }
0040 
0041 void CylinderFromSectorMFGrid::throwUp(const char* message) const {
0042   std::cout << "Throwing exception " << message << std::endl;
0043   throw MagGeometryError(message);
0044 }
0045 void CylinderFromSectorMFGrid::toGridFrame(const LocalPoint& p, double& a, double& b, double& c) const {
0046   throwUp("Not implemented yet");
0047 }
0048 
0049 MFGrid::LocalPoint CylinderFromSectorMFGrid::fromGridFrame(double a, double b, double c) const {
0050   throwUp("Not implemented yet");
0051   return LocalPoint();
0052 }
0053 
0054 Dimensions CylinderFromSectorMFGrid::dimensions() const { return theSectorGrid->dimensions(); }
0055 
0056 MFGrid::LocalPoint CylinderFromSectorMFGrid::nodePosition(int i, int j, int k) const {
0057   throwUp("Not implemented yet");
0058   return LocalPoint();
0059 }
0060 
0061 MFGrid::LocalVector CylinderFromSectorMFGrid::nodeValue(int i, int j, int k) const {
0062   throwUp("Not implemented yet");
0063   return LocalVector();
0064 }