CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/MagneticField/VolumeGeometry/src/MagCylinder.cc

Go to the documentation of this file.
00001 // 
00002 //#include "Utilities/Configuration/interface/Architecture.h"
00003 
00004 #include "MagneticField/VolumeGeometry/interface/MagCylinder.h"
00005 #include "MagneticField/VolumeGeometry/interface/MagExceptions.h"
00006 #include "DataFormats/GeometrySurface/interface/Cylinder.h"
00007 
00008 MagCylinder::MagCylinder( const PositionType& pos,
00009                           const RotationType& rot, 
00010                           DDSolidShape shape,
00011                           const std::vector<VolumeSide>& faces,
00012                           const MagneticFieldProvider<float> * mfp)
00013   : MagVolume(pos,rot,shape,mfp), theFaces(faces), theZmin(0.), theZmax(0.), theInnerR(0.), theOuterR(0.)
00014 {
00015   using SurfaceOrientation::GlobalFace;
00016 
00017   unsigned int def = 0;
00018   for (std::vector<VolumeSide>::const_iterator i=faces.begin(); i!= faces.end(); ++i) {
00019     if (i->globalFace() == SurfaceOrientation::zminus) {
00020       theZmin = MagVolume::toLocal( i->surface().position()).z();
00021       ++def;
00022     }
00023     else if (i->globalFace() == SurfaceOrientation::zplus) {
00024       theZmax = MagVolume::toLocal( i->surface().position()).z();
00025       ++def;
00026     }
00027     else if (i->globalFace() == SurfaceOrientation::outer || i->globalFace() == SurfaceOrientation::inner) {
00028       const Cylinder* cyl = dynamic_cast<const Cylinder*>(&(i->surface()));
00029       if (cyl == 0) {
00030         throw MagGeometryError("MagCylinder inner/outer surface is not a cylinder");
00031       }
00032       if (i->globalFace() == SurfaceOrientation::outer) theOuterR = cyl->radius();
00033       else                                              theInnerR = cyl->radius();
00034       ++def;
00035     }
00036   }
00037   if (def != faces.size()) {
00038     throw MagGeometryError("MagCylinder constructed with wrong number/type of faces");
00039   }
00040   
00041 }
00042 
00043 bool MagCylinder::inside( const GlobalPoint& gp, double tolerance) const 
00044 {
00045   return inside( toLocal(gp), tolerance);
00046 }
00047 
00048 bool MagCylinder::inside( const LocalPoint& lp, double tolerance) const 
00049 {
00050   Scalar r( lp.perp());
00051   return 
00052     lp.z() > theZmin - tolerance &&
00053     lp.z() < theZmax + tolerance &&
00054     r      > theInnerR - tolerance && 
00055     r      < theOuterR + tolerance;
00056 }