CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/DataFormats/GeometrySurface/interface/Surface.h

Go to the documentation of this file.
00001 #ifndef Geom_Surface_H
00002 #define Geom_Surface_H
00003 
00004 #include "DataFormats/GeometrySurface/interface/ReferenceCounted.h"
00005 
00006 #include "DataFormats/GeometrySurface/interface/GloballyPositioned.h"
00007 
00008 
00009 #include "DataFormats/GeometrySurface/interface/MediumProperties.h"
00010 
00011 /*
00012 #include "DataFormats/GeometrySurface/interface/GlobalError.h"
00013 #include "DataFormats/GeometrySurface/interface/LocalError.h"
00014 */
00018 namespace SurfaceOrientation {
00019   enum Side {positiveSide, negativeSide, onSurface};
00020   enum GlobalFace {outer,inner,zplus,zminus,phiplus,phiminus};
00021 }
00022 
00023 
00024 //template <class T> class ReferenceCountingPointer;
00025 
00026 class TangentPlane;
00027 
00032 class Surface : public GloballyPositioned<float> 
00033                 , public ReferenceCountedInConditions 
00034 {
00035 public:
00036   typedef SurfaceOrientation::Side Side;
00037 
00038   typedef GloballyPositioned<float>       Base;
00039 
00040   Surface( const PositionType& pos, const RotationType& rot) :
00041     Base( pos, rot), theMediumProperties(0.,0.), m_mpSet(false) {}
00042 
00043   Surface( const PositionType& pos, const RotationType& rot, 
00044            MediumProperties* mp) : 
00045     Base( pos, rot), 
00046     theMediumProperties(mp? *mp : MediumProperties(0.,0.)),
00047     m_mpSet(mp)
00048   {}
00049  
00050  Surface( const PositionType& pos, const RotationType& rot,
00051            MediumProperties mp) :
00052     Base( pos, rot),
00053     theMediumProperties(mp),
00054     m_mpSet(true)
00055   {}
00056  
00057   Surface( const Surface& iSurface ) : 
00058   Base( iSurface), 
00059   theMediumProperties(iSurface.theMediumProperties),
00060   m_mpSet(iSurface.m_mpSet)
00061   {}
00062 
00063   // pure virtual destructor - makes base classs abstract
00064   virtual ~Surface() = 0;
00065 
00070   virtual Side side( const LocalPoint& p, Scalar tolerance=0) const = 0;
00071   virtual Side side( const GlobalPoint& p, Scalar tolerance=0) const {
00072     return side( toLocal(p), tolerance);
00073   }
00074 
00075   using Base::toGlobal;
00076   using Base::toLocal;
00077 
00078   GlobalPoint toGlobal( const Point2DBase< Scalar, LocalTag> lp) const {
00079     return GlobalPoint( rotation().multiplyInverse( lp.basicVector()) +
00080                         position().basicVector());
00081   }
00082 
00083   /*
00084   GlobalError toGlobal( const LocalError& le) const {
00085     return rotation().transform(le);
00086   }
00087 
00088   LocalError toLocal( const GlobalError& ge) const {
00089     return rotation().transform(ge);
00090   }
00091   */
00092 
00093   const MediumProperties* mediumProperties() const { 
00094     return  m_mpSet ? &theMediumProperties : 0;
00095   }
00096 
00097   void setMediumProperties( const MediumProperties & mp ) {
00098     theMediumProperties = mp;
00099     m_mpSet = true;
00100   }
00101 
00102   void setMediumProperties( MediumProperties* mp ) {
00103     if (mp) {
00104       theMediumProperties = *mp;
00105       m_mpSet = true;
00106     } else {
00107       theMediumProperties = MediumProperties(0.,0.);
00108       m_mpSet = false;
00109     }
00110   }
00111 
00118   virtual ReferenceCountingPointer<TangentPlane> tangentPlane (const GlobalPoint&) const = 0;
00121   virtual ReferenceCountingPointer<TangentPlane> tangentPlane (const LocalPoint&) const = 0;
00122 
00123 private:
00124 
00125   MediumProperties theMediumProperties;
00126   bool m_mpSet;
00127 };
00128   
00129 inline Surface::~Surface() {}
00130 
00131 #endif // Geom_Surface_H