File indexing completed on 2024-04-06 12:04:14
0001 #ifndef Geom_Cylinder_H
0002 #define Geom_Cylinder_H
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include "DataFormats/GeometrySurface/interface/Surface.h"
0016 #include "DataFormats/GeometrySurface/interface/Plane.h"
0017 #include "DataFormats/GeometrySurface/interface/SimpleCylinderBounds.h"
0018
0019 class Cylinder final : public Surface {
0020 public:
0021 template <typename... Args>
0022 Cylinder(Scalar radius, Args&&... args) : Surface(std::forward<Args>(args)...), theRadius(radius) {}
0023
0024 Cylinder(const PositionType& pos, const RotationType& rot, SimpleCylinderBounds const& bounds)
0025 : Surface(pos, rot, bounds.clone()), theRadius(computeRadius(bounds)) {}
0026
0027
0028 static float computeRadius(Bounds const& bounds) { return 0.5f * (bounds.width() - bounds.thickness()); }
0029
0030 typedef ReferenceCountingPointer<Cylinder> CylinderPointer;
0031 typedef ConstReferenceCountingPointer<Cylinder> ConstCylinderPointer;
0032 typedef ReferenceCountingPointer<Cylinder> BoundCylinderPointer;
0033 typedef ConstReferenceCountingPointer<Cylinder> ConstBoundCylinderPointer;
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 static CylinderPointer build(const PositionType& pos,
0046 const RotationType& rot,
0047 Scalar radius,
0048 Bounds* bounds = nullptr) {
0049 return CylinderPointer(new Cylinder(radius, pos, rot, bounds));
0050 }
0051
0052 static CylinderPointer build(Scalar radius,
0053 const PositionType& pos,
0054 const RotationType& rot,
0055 Bounds* bounds = nullptr) {
0056 return CylinderPointer(new Cylinder(radius, pos, rot, bounds));
0057 }
0058
0059 ~Cylinder() override {}
0060
0061
0062
0063
0064 Scalar radius() const { return theRadius; }
0065
0066
0067
0068 using Surface::side;
0069 Side side(const LocalPoint& p, Scalar toler) const override;
0070
0071
0072 ConstReferenceCountingPointer<TangentPlane> tangentPlane(const GlobalPoint&) const override;
0073
0074 ConstReferenceCountingPointer<TangentPlane> tangentPlane(const LocalPoint&) const override;
0075
0076
0077 Plane fastTangent(const GlobalPoint& aPoint) const {
0078 GlobalVector yPlane(rotation().z());
0079 GlobalVector xPlane(yPlane.cross(aPoint - position()));
0080 return Plane(aPoint, RotationType(xPlane, yPlane));
0081 }
0082
0083
0084 Plane fastTangent(const LocalPoint& aPoint) const { return fastTangent(toGlobal(aPoint)); }
0085
0086 private:
0087 Scalar theRadius;
0088 };
0089
0090 #endif