00001
00002
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
00010
00011
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
00049
00050
00051
00052 #endif
00053 }
00054
00055 bool MagCylinder::inside( const GlobalPoint& gp, double tolerance) const
00056 {
00057 #ifndef NO_DETAILED_TIMING
00058
00059
00060
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
00069
00070
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 }