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 class SimpleConeBounds final : public Bounds {
24 public:
26  SimpleConeBounds(float zmin, float rmin_zmin, float rmax_zmin, float zmax, float rmin_zmax, float rmax_zmax)
27  : theZmin(zmin),
28  theRminZmin(rmin_zmin),
29  theRmaxZmin(rmax_zmin),
30  theZmax(zmax),
31  theRminZmax(rmin_zmax),
32  theRmaxZmax(rmax_zmax) {
33  if (theZmin > theZmax) {
36  }
41  }
42 
44  float length() const override { return theZmax - theZmin; }
46  float width() const override { return 2 * std::max(theRmaxZmin, theRmaxZmax); }
49  float thickness() const override { return ((theRmaxZmin - theRminZmin) + (theRmaxZmax - theRminZmax)) / 2.; }
50 
51  using Bounds::inside;
52 
53  bool inside(const Local3DPoint& p) const override {
54  float lrmin = (p.z() - theZmin) * (theRminZmax - theRminZmin) / (theZmax - theZmin);
55  float lrmax = (p.z() - theZmin) * (theRmaxZmax - theRmaxZmin) / (theZmax - theZmin);
56  return p.z() > theZmin && p.z() < theZmax && p.perp() > lrmin && p.perp() < lrmax;
57  }
58 
59  bool inside(const Local3DPoint& p, const LocalError& err, float scale) const override {
60  // std::cout << "WARNING: SimpleConeBounds::inside(const Local3DPoint&, const LocalError not fully implemented"
61  // << std::endl; // FIXME! does not check R.
62  SimpleConeBounds tmp(theZmin - sqrt(err.yy()) * scale,
65  theZmax + sqrt(err.yy()) * scale,
67  theRmaxZmax);
68  return tmp.inside(p);
69  }
70 
71  virtual bool inside(const Local2DPoint& p, const LocalError& err) const { return Bounds::inside(p, err); }
72 
73  Bounds* clone() const override { return new SimpleConeBounds(*this); }
74 
75  // Extension of the Bounds interface
77  float theta = atan(((theRmaxZmax + theRminZmax) / 2. - (theRmaxZmin + theRminZmin) / 2.) / length());
78  return Geom::Theta<float>(theta < 0 ? theta + Geom::pi() : theta);
79  }
80 
81  GlobalPoint vertex() const {
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
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:69
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:24
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
T sqrt(T t)
Definition: SSEVec.h:19
T z() const
Definition: PV3DBase.h:61
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
Definition: Bounds.h:20
constexpr double pi()
Definition: Pi.h:31
float width() const override
Maximum diameter.
tmp
align.sh
Definition: createJobs.py:716
GlobalPoint vertex() const