CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/DataFormats/GeometrySurface/interface/Cylinder.h

Go to the documentation of this file.
00001 #ifndef Geom_Cylinder_H
00002 #define Geom_Cylinder_H
00003 
00017 #include "DataFormats/GeometrySurface/interface/Surface.h"
00018 #include "DataFormats/GeometrySurface/interface/Plane.h"
00019 #include "DataFormats/GeometrySurface/interface/SimpleCylinderBounds.h"
00020 
00021 class Cylinder GCC11_FINAL  : public Surface {
00022 public:
00023 
00024   template<typename... Args>
00025     Cylinder(Scalar radius, Args&& ... args) :
00026     Surface(std::forward<Args>(args)...), theRadius(radius){}
00027 
00028   Cylinder(const PositionType& pos, const RotationType& rot, SimpleCylinderBounds const & bounds) :
00029     Surface(pos,rot, bounds.clone()),  theRadius(computeRadius(bounds)){}
00030   
00031   // average Rmin Rmax...
00032   static float computeRadius(Bounds const & bounds) {
00033     return  0.5f*(bounds.width() - bounds.thickness());
00034   }
00035 
00036 
00037   typedef ReferenceCountingPointer<Cylinder> CylinderPointer;
00038   typedef ConstReferenceCountingPointer<Cylinder> ConstCylinderPointer;
00039   typedef ReferenceCountingPointer<Cylinder> BoundCylinderPointer;
00040   typedef ConstReferenceCountingPointer<Cylinder> ConstBoundCylinderPointer;
00041 
00042 
00046   /*
00047   template<typename... Args>
00048   static CylinderPointer build(Args&& ... args) {
00049     return CylinderPointer(new Cylinder(std::forward<Args>(args)...));
00050   }
00051   */
00052 
00053   static CylinderPointer build(const PositionType& pos, const RotationType& rot,
00054                                Scalar radius, Bounds* bounds=0) {
00055     return CylinderPointer(new Cylinder(radius,pos,rot,bounds));
00056   }
00057 
00058   static CylinderPointer build(Scalar radius, const PositionType& pos, const RotationType& rot,
00059                                Bounds* bounds=0) {
00060     return CylinderPointer(new Cylinder(radius,pos,rot,bounds));
00061   }
00062 
00063   ~Cylinder(){}
00064 
00065 
00066   // -- Extension of Surface interface for cylinder
00067 
00069   Scalar radius() const {return theRadius;}
00070 
00071   // -- Implementation of Surface interface    
00072 
00073   using Surface::side;
00074   virtual Side side( const LocalPoint& p, Scalar toler) const;
00075 
00077   virtual ReferenceCountingPointer<TangentPlane> tangentPlane (const GlobalPoint&) const;
00079   virtual ReferenceCountingPointer<TangentPlane> tangentPlane (const LocalPoint&) const;
00080 
00082   Plane fastTangent(const GlobalPoint& aPoint) const{
00083     GlobalVector yPlane(rotation().z());
00084     GlobalVector xPlane(yPlane.cross(aPoint-position()));
00085     return Plane(aPoint,RotationType(xPlane, yPlane));
00086   }
00087 
00089   Plane fastTangent(const LocalPoint& aPoint) const {
00090     return fastTangent(toGlobal(aPoint));
00091   } 
00092 
00093 private:
00094 
00095   Scalar theRadius;
00096 
00097 };
00098 
00099 #endif