CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SimpleConeBounds.h
Go to the documentation of this file.
1 #ifndef Geom_SimpleConeBounds_H
2 #define Geom_SimpleConeBounds_H
3 
20 
21 #include <cmath>
22 #include <limits>
23 #include <algorithm>
24 
25 
26 class SimpleConeBounds : public Bounds {
27 public:
28 
30  SimpleConeBounds( float zmin, float rmin_zmin, float rmax_zmin,
31  float zmax, float rmin_zmax, float rmax_zmax) :
32  theZmin(zmin), theRminZmin(rmin_zmin), theRmaxZmin(rmax_zmin),
33  theZmax(zmax), theRminZmax(rmin_zmax), theRmaxZmax(rmax_zmax) {
34  if (theZmin > theZmax) {
37  }
40  }
41 
43  virtual float length() const { return theZmax - theZmin;}
45  virtual float width() const { return 2*std::max(theRmaxZmin,theRmaxZmax);}
48  virtual float thickness() const { return ((theRmaxZmin-theRminZmin)+
49  (theRmaxZmax-theRminZmax))/2.;}
50 
51  virtual bool inside( const Local3DPoint& p) const {
52  float lrmin = (p.z()-theZmin)*(theRminZmax-theRminZmin)/(theZmax-theZmin);
53  float lrmax = (p.z()-theZmin)*(theRmaxZmax-theRmaxZmin)/(theZmax-theZmin);
54  return p.z() > theZmin && p.z() < theZmax &&
55  p.perp() > lrmin && p.perp() < lrmax;
56  }
57 
58  virtual bool inside( const Local3DPoint& p, const LocalError& err, float scale) const {
59  // std::cout << "WARNING: SimpleConeBounds::inside(const Local3DPoint&, const LocalError not fully implemented"
60  // << std::endl; // FIXME! does not check R.
61  SimpleConeBounds tmp(theZmin - sqrt(err.yy())*scale,
63  theZmax+ sqrt(err.yy())*scale,
65  return tmp.inside(p);
66  }
67 
68  virtual bool inside( const Local2DPoint& p, const LocalError& err) const {
69  return Bounds::inside(p,err);
70  }
71 
72  virtual Bounds* clone() const {
73  return new SimpleConeBounds(*this);
74  }
75 
76  // Extension of the Bounds interface
78  float theta = atan(((theRmaxZmax+theRminZmax)/2.-
80  return Geom::Theta<float>(theta < 0 ? theta+Geom::pi() : theta);
81  }
82 
84  float rAtZmax = (theRmaxZmax+theRminZmax)/2.;
85  float rAtZmin = (theRmaxZmin+theRminZmin)/2.;
86  float dr = (rAtZmax-rAtZmin);
87 
88  if (std::abs(dr) < 0.0001) { // handle degenerate case (cone->cylinder)
90  } else {
91  return GlobalPoint(0,0,(theZmin*rAtZmax - theZmax*rAtZmin)/dr);
92  }
93  }
94 
95 private:
96  float theZmin;
97  float theRminZmin;
98  float theRmaxZmin;
99  float theZmax;
100  float theRminZmax;
101  float theRmaxZmax;
102 };
103 
104 #endif // Geom_SimpleConeBounds_H
virtual float length() const
Length along Z.
T perp() const
Definition: PV3DBase.h:66
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Geom::Theta< T > theta() const
#define abs(x)
Definition: mlp_lapack.h:159
virtual bool inside(const Local3DPoint &p, const LocalError &err, float scale) const
Determine if a point is inside the bounds, taking error into account.
virtual float width() const
Maximum diameter.
virtual bool inside(const Local2DPoint &p, const LocalError &err) const
float yy() const
Definition: LocalError.h:21
const T & max(const T &a, const T &b)
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T sqrt(T t)
Definition: SSEVec.h:28
T z() const
Definition: PV3DBase.h:58
SimpleConeBounds(float zmin, float rmin_zmin, float rmax_zmin, float zmax, float rmin_zmax, float rmax_zmax)
Construct from inner/outer radius on the two Z faces.
virtual Bounds * clone() const
Geom::Theta< float > openingAngle() const
virtual bool inside(const Local3DPoint &p) const
Determine if the point is inside the bounds.
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
double pi()
Definition: Pi.h:31
Definition: Bounds.h:18
GlobalPoint vertex() const
virtual float thickness() const