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 
18 
19 #include <cmath>
20 #include <limits>
21 #include <algorithm>
22 
23 
25 public:
26 
28  SimpleConeBounds( float zmin, float rmin_zmin, float rmax_zmin,
29  float zmax, float rmin_zmax, float rmax_zmax) :
30  theZmin(zmin), theRminZmin(rmin_zmin), theRmaxZmin(rmax_zmin),
31  theZmax(zmax), theRminZmax(rmin_zmax), theRmaxZmax(rmax_zmax) {
32  if (theZmin > theZmax) {
35  }
38  }
39 
41  virtual float length() const { return theZmax - theZmin;}
43  virtual float width() const { return 2*std::max(theRmaxZmin,theRmaxZmax);}
46  virtual float thickness() const { return ((theRmaxZmin-theRminZmin)+
47  (theRmaxZmax-theRminZmax))/2.;}
48 
49  using Bounds::inside;
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.
#define GCC11_FINAL
T perp() const
Definition: PV3DBase.h:72
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
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:26
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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:22
GlobalPoint vertex() const
virtual float thickness() const