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 
24 class SimpleConeBounds GCC11_FINAL : public Bounds {
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) {
33  std::swap(theRminZmin, theRminZmax);
34  std::swap(theRmaxZmin, theRmaxZmax);
35  }
36  if (theRminZmin > theRmaxZmin) std::swap(theRminZmin, theRmaxZmin);
37  if (theRminZmax > theRmaxZmax) std::swap(theRminZmax, theRmaxZmax);
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  virtual bool inside( const Local3DPoint& p) const {
50  float lrmin = (p.z()-theZmin)*(theRminZmax-theRminZmin)/(theZmax-theZmin);
51  float lrmax = (p.z()-theZmin)*(theRmaxZmax-theRmaxZmin)/(theZmax-theZmin);
52  return p.z() > theZmin && p.z() < theZmax &&
53  p.perp() > lrmin && p.perp() < lrmax;
54  }
55 
56  virtual bool inside( const Local3DPoint& p, const LocalError& err, float scale) const {
57  // std::cout << "WARNING: SimpleConeBounds::inside(const Local3DPoint&, const LocalError not fully implemented"
58  // << std::endl; // FIXME! does not check R.
59  SimpleConeBounds tmp(theZmin - sqrt(err.yy())*scale,
60  theRminZmin, theRmaxZmin,
61  theZmax+ sqrt(err.yy())*scale,
62  theRminZmax, theRmaxZmax);
63  return tmp.inside(p);
64  }
65 
66  virtual bool inside( const Local2DPoint& p, const LocalError& err) const {
67  return Bounds::inside(p,err);
68  }
69 
70  virtual Bounds* clone() const {
71  return new SimpleConeBounds(*this);
72  }
73 
74  // Extension of the Bounds interface
76  float theta = atan(((theRmaxZmax+theRminZmax)/2.-
77  (theRmaxZmin+theRminZmin)/2.)/length());
78  return Geom::Theta<float>(theta < 0 ? theta+Geom::pi() : theta);
79  }
80 
82  float rAtZmax = (theRmaxZmax+theRminZmax)/2.;
83  float rAtZmin = (theRmaxZmin+theRminZmin)/2.;
84  float dr = (rAtZmax-rAtZmin);
85 
86  if (std::abs(dr) < 0.0001) { // handle degenerate case (cone->cylinder)
88  } else {
89  return GlobalPoint(0,0,(theZmin*rAtZmax - theZmax*rAtZmin)/dr);
90  }
91  }
92 
93 private:
94  float theZmin;
95  float theRminZmin;
96  float theRmaxZmin;
97  float theZmax;
98  float theRminZmax;
99  float theRmaxZmax;
100 };
101 
102 #endif // Geom_SimpleConeBounds_H
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 float thickness() const
Geom::Theta< float > openingAngle() const
T perp() const
Definition: PV3DBase.h:72
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
GloballyPositioned< float >::GlobalPoint GlobalPoint
Definition: MagVolume.h:20
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Geom::Theta< T > theta() const
virtual float length() const
Length along Z.
float yy() const
Definition: LocalError.h:26
const T & max(const T &a, const T &b)
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
GlobalPoint vertex() const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
virtual bool inside(const Local2DPoint &p, const LocalError &err) const
double pi()
Definition: Pi.h:31
Definition: Bounds.h:22
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 Local3DPoint &p) const
Determine if the point is inside the bounds.
virtual Bounds * clone() const
Unlimited (trivial) bounds.