Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:14

0001 #ifndef Geom_Surface_H
0002 #define Geom_Surface_H
0003 
0004 #include "DataFormats/GeometrySurface/interface/ReferenceCounted.h"
0005 
0006 #include "DataFormats/GeometrySurface/interface/GloballyPositioned.h"
0007 
0008 #include "DataFormats/GeometrySurface/interface/MediumProperties.h"
0009 #include "DataFormats/GeometrySurface/interface/Bounds.h"
0010 
0011 #include "FWCore/Utilities/interface/clone_ptr.h"
0012 #include <algorithm>
0013 
0014 /** Collection of enums to specify orientation of the surface wrt the
0015  *  volume it a bound of.
0016  */
0017 namespace SurfaceOrientation {
0018   enum Side { positiveSide, negativeSide, onSurface };
0019   enum GlobalFace { outer, inner, zplus, zminus, phiplus, phiminus };
0020 }  // namespace SurfaceOrientation
0021 
0022 //template <class T> class ReferenceCountingPointer;
0023 
0024 class Plane;
0025 using TangentPlane = Plane;
0026 
0027 /** Base class for 2D surfaces in 3D space.
0028  *  May have MediumProperties.
0029  * may have bounds
0030  *  The Bounds define a region AROUND the surface.
0031  *  Surfaces which differ only by the shape of their bounds are of the
0032  *  same "surface" type  
0033  *  (e.g. Plane or Cylinder).
0034  */
0035 
0036 class Surface : public ReferenceCountedInConditions, public GloballyPositioned<float> {
0037 public:
0038   using Side = SurfaceOrientation::Side;
0039 
0040   using Base = GloballyPositioned<float>;
0041 
0042   ~Surface() override {}
0043 
0044 protected:
0045   Surface() {}
0046   Surface(const PositionType& pos, const RotationType& rot) : Base(pos, rot) {}
0047 
0048   Surface(const PositionType& pos, const RotationType& rot, Bounds* bounds) : Base(pos, rot), theBounds(bounds) {}
0049 
0050   Surface(const PositionType& pos, const RotationType& rot, MediumProperties mp)
0051       : Base(pos, rot), theMediumProperties(mp) {}
0052 
0053   Surface(const PositionType& pos, const RotationType& rot, MediumProperties mp, Bounds* bounds)
0054       : Base(pos, rot), theMediumProperties(mp), theBounds(bounds) {}
0055 
0056   Surface(const Surface& iSurface)
0057       : ReferenceCountedInConditions(iSurface),
0058         Base(iSurface),
0059         theMediumProperties(iSurface.theMediumProperties),
0060         theBounds(iSurface.theBounds) {}
0061 
0062   Surface(Surface&& iSurface)
0063       : ReferenceCountedInConditions(iSurface),
0064         Base(iSurface),
0065         theMediumProperties(iSurface.theMediumProperties),
0066         theBounds(std::move(iSurface.theBounds)) {}
0067 
0068 public:
0069   /** Returns the side of the surface on which the point is.
0070    *  Not defined for 1-sided surfaces (Moebius leaf etc.)
0071    *  For normal 2-sided surfaces the meaning of side is surface type dependent.
0072    */
0073   virtual Side side(const LocalPoint& p, Scalar tolerance = 0) const = 0;
0074   virtual Side side(const GlobalPoint& p, Scalar tolerance = 0) const { return side(toLocal(p), tolerance); }
0075 
0076   using Base::toGlobal;
0077   using Base::toLocal;
0078 
0079   GlobalPoint toGlobal(const Point2DBase<Scalar, LocalTag> lp) const {
0080     return GlobalPoint(rotation().multiplyInverse(lp.basicVector()) + position().basicVector());
0081   }
0082 
0083   const MediumProperties& mediumProperties() const { return theMediumProperties; }
0084 
0085   void setMediumProperties(const MediumProperties& mp) { theMediumProperties = mp; }
0086 
0087   const Bounds& bounds() const { return *theBounds; }
0088 
0089   // here and not in plane because of PixelBarrelLayer::overlap
0090   std::pair<float, float> const& phiSpan() const { return bounds().phiSpan(); }
0091   std::pair<float, float> const& zSpan() const { return bounds().zSpan(); }
0092   std::pair<float, float> const& rSpan() const { return bounds().rSpan(); }
0093 
0094   /** Tangent plane to surface from global point.
0095    * Returns a plane, tangent to the Surface at a point.
0096    * The point must be on the surface.
0097    * The return type is a ReferenceCountingPointer, so the plane 
0098    * will be deleted automatically when no longer needed.
0099    */
0100   virtual ConstReferenceCountingPointer<TangentPlane> tangentPlane(const GlobalPoint&) const = 0;
0101   /** Tangent plane to surface from local point.
0102    */
0103   virtual ConstReferenceCountingPointer<TangentPlane> tangentPlane(const LocalPoint&) const = 0;
0104 
0105 protected:
0106   MediumProperties theMediumProperties;
0107   extstd::clone_ptr<Bounds> theBounds;
0108 };
0109 
0110 #endif  // Geom_Surface_H