CMS 3D CMS Logo

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 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) {
35  }
38  }
39 
41  float length() const override { return theZmax - theZmin;}
43  float width() const override { return 2*std::max(theRmaxZmin,theRmaxZmax);}
46  float thickness() const override { return ((theRmaxZmin-theRminZmin)+
47  (theRmaxZmax-theRminZmax))/2.;}
48 
49  using Bounds::inside;
50 
51  bool inside( const Local3DPoint& p) const override {
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  bool inside( const Local3DPoint& p, const LocalError& err, float scale) const override {
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  Bounds* clone() const override {
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
float length() const override
Length along Z.
bool inside(const Local3DPoint &p, const LocalError &err, float scale) const override
Determine if a point is inside the bounds, taking error into account.
T perp() const
Definition: PV3DBase.h:72
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Geom::Theta< T > theta() const
Bounds * clone() const override
bool inside(const Local3DPoint &p) const override
Determine if the point is inside the bounds.
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
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:18
T z() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
float thickness() const override
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.
Geom::Theta< float > openingAngle() const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
Definition: Bounds.h:22
constexpr double pi()
Definition: Pi.h:31
float width() const override
Maximum diameter.
GlobalPoint vertex() const