Go to the documentation of this file.00001 #ifndef Geom_SimpleConeBounds_H
00002 #define Geom_SimpleConeBounds_H
00003
00015 #include "DataFormats/GeometryVector/interface/LocalPoint.h"
00016 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
00017 #include "DataFormats/GeometryVector/interface/Pi.h"
00018 #include "DataFormats/GeometrySurface/interface/LocalError.h"
00019 #include "DataFormats/GeometrySurface/interface/Bounds.h"
00020
00021 #include <cmath>
00022 #include <limits>
00023 #include <algorithm>
00024
00025
00026 class SimpleConeBounds : public Bounds {
00027 public:
00028
00030 SimpleConeBounds( float zmin, float rmin_zmin, float rmax_zmin,
00031 float zmax, float rmin_zmax, float rmax_zmax) :
00032 theZmin(zmin), theRminZmin(rmin_zmin), theRmaxZmin(rmax_zmin),
00033 theZmax(zmax), theRminZmax(rmin_zmax), theRmaxZmax(rmax_zmax) {
00034 if (theZmin > theZmax) {
00035 std::swap(theRminZmin, theRminZmax);
00036 std::swap(theRmaxZmin, theRmaxZmax);
00037 }
00038 if (theRminZmin > theRmaxZmin) std::swap(theRminZmin, theRmaxZmin);
00039 if (theRminZmax > theRmaxZmax) std::swap(theRminZmax, theRmaxZmax);
00040 }
00041
00043 virtual float length() const { return theZmax - theZmin;}
00045 virtual float width() const { return 2*std::max(theRmaxZmin,theRmaxZmax);}
00048 virtual float thickness() const { return ((theRmaxZmin-theRminZmin)+
00049 (theRmaxZmax-theRminZmax))/2.;}
00050
00051 virtual bool inside( const Local3DPoint& p) const {
00052 float lrmin = (p.z()-theZmin)*(theRminZmax-theRminZmin)/(theZmax-theZmin);
00053 float lrmax = (p.z()-theZmin)*(theRmaxZmax-theRmaxZmin)/(theZmax-theZmin);
00054 return p.z() > theZmin && p.z() < theZmax &&
00055 p.perp() > lrmin && p.perp() < lrmax;
00056 }
00057
00058 virtual bool inside( const Local3DPoint& p, const LocalError& err, float scale) const {
00059
00060
00061 SimpleConeBounds tmp(theZmin - sqrt(err.yy())*scale,
00062 theRminZmin, theRmaxZmin,
00063 theZmax+ sqrt(err.yy())*scale,
00064 theRminZmax, theRmaxZmax);
00065 return tmp.inside(p);
00066 }
00067
00068 virtual bool inside( const Local2DPoint& p, const LocalError& err) const {
00069 return Bounds::inside(p,err);
00070 }
00071
00072 virtual Bounds* clone() const {
00073 return new SimpleConeBounds(*this);
00074 }
00075
00076
00077 Geom::Theta<float> openingAngle() const {
00078 float theta = atan(((theRmaxZmax+theRminZmax)/2.-
00079 (theRmaxZmin+theRminZmin)/2.)/length());
00080 return Geom::Theta<float>(theta < 0 ? theta+Geom::pi() : theta);
00081 }
00082
00083 GlobalPoint vertex() const{
00084 float rAtZmax = (theRmaxZmax+theRminZmax)/2.;
00085 float rAtZmin = (theRmaxZmin+theRminZmin)/2.;
00086 float dr = (rAtZmax-rAtZmin);
00087
00088 if (std::abs(dr) < 0.0001) {
00089 return GlobalPoint(0,0,std::numeric_limits<float>::max());
00090 } else {
00091 return GlobalPoint(0,0,(theZmin*rAtZmax - theZmax*rAtZmin)/dr);
00092 }
00093 }
00094
00095 private:
00096 float theZmin;
00097 float theRminZmin;
00098 float theRmaxZmin;
00099 float theZmax;
00100 float theRminZmax;
00101 float theRmaxZmax;
00102 };
00103
00104 #endif // Geom_SimpleConeBounds_H