CMS 3D CMS Logo

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 #ifndef NO_DETAILED_TIMING
00009 // TOFIX
00010 // #include "Utilities/Notification/interface/TimingReport.h"
00011 // #include "Utilities/UI/interface/SimpleConfigurable.h"
00012 #endif
00013 
00014 MagCylinder::MagCylinder( const PositionType& pos,
00015                           const RotationType& rot, 
00016                           DDSolidShape shape,
00017                           const std::vector<VolumeSide>& faces,
00018                           const MagneticFieldProvider<float> * mfp)
00019   : MagVolume(pos,rot,shape,mfp), theFaces(faces), theInnerR(0)
00020 {
00021   using SurfaceOrientation::GlobalFace;
00022 
00023   unsigned int def = 0;
00024   for (std::vector<VolumeSide>::const_iterator i=faces.begin(); i!= faces.end(); ++i) {
00025     if (i->globalFace() == SurfaceOrientation::zminus) {
00026       theZmin = MagVolume::toLocal( i->surface().position()).z();
00027       ++def;
00028     }
00029     else if (i->globalFace() == SurfaceOrientation::zplus) {
00030       theZmax = MagVolume::toLocal( i->surface().position()).z();
00031       ++def;
00032     }
00033     else if (i->globalFace() == SurfaceOrientation::outer || i->globalFace() == SurfaceOrientation::inner) {
00034       const Cylinder* cyl = dynamic_cast<const Cylinder*>(&(i->surface()));
00035       if (cyl == 0) {
00036         throw MagGeometryError("MagCylinder inner/outer surface is not a cylinder");
00037       }
00038       if (i->globalFace() == SurfaceOrientation::outer) theOuterR = cyl->radius();
00039       else                                              theInnerR = cyl->radius();
00040       ++def;
00041     }
00042   }
00043   if (def != faces.size()) {
00044     throw MagGeometryError("MagCylinder constructed with wrong number/type of faces");
00045   }
00046   
00047 #ifndef NO_DETAILED_TIMING
00048 // TOFIX
00049 //   static SimpleConfigurable<bool> timerOn(false,"MagCylinder:timing");
00050 //   bool timerOn = false;
00051 //   (*TimingReport::current()).switchOn("MagCylinder::inside",timerOn);
00052 #endif
00053 }
00054 
00055 bool MagCylinder::inside( const GlobalPoint& gp, double tolerance) const 
00056 {
00057 #ifndef NO_DETAILED_TIMING
00058 // TOFIX
00059 //   static TimingReport::Item & timer = (*TimingReport::current())["MagCylinder::inside(global)"];
00060 //   TimeMe t(timer,false);
00061 #endif
00062   return inside( toLocal(gp), tolerance);
00063 }
00064 
00065 bool MagCylinder::inside( const LocalPoint& lp, double tolerance) const 
00066 {
00067 #ifndef NO_DETAILED_TIMING
00068 // TOFIX
00069 //   static TimingReport::Item & timer = (*TimingReport::current())["MagCylinder::inside(local)"];
00070 //   TimeMe t(timer,false);
00071 #endif
00072 
00073   Scalar r( lp.perp());
00074   return 
00075     lp.z() > theZmin - tolerance &&
00076     lp.z() < theZmax + tolerance &&
00077     r      > theInnerR - tolerance && 
00078     r      < theOuterR + tolerance;
00079 }

Generated on Tue Jun 9 17:40:38 2009 for CMSSW by  doxygen 1.5.4