CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
RectangularPlaneBounds.cc
Go to the documentation of this file.
3 #include <cmath>
4 
6  : halfWidth(w), halfLength(h), halfThickness(t) {}
7 
9 
10 bool RectangularPlaneBounds::inside(const Local3DPoint& p, const LocalError& err, float scale) const {
11  if ((scale >= 0) && inside(p))
12  return true;
13  return std::abs(p.z()) < halfThickness && (std::abs(p.x()) < halfWidth + std::sqrt(err.xx()) * scale) &&
14  (std::abs(p.y()) < halfLength + std::sqrt(err.yy()) * scale);
15 }
16 
17 bool RectangularPlaneBounds::inside(const Local2DPoint& p, const LocalError& err, float scale) const {
18  if ((scale >= 0) && inside(p))
19  return true;
20  return (std::abs(p.x()) < halfWidth + std::sqrt(err.xx()) * scale) &&
21  (std::abs(p.y()) < halfLength + std::sqrt(err.yy()) * scale);
22 }
23 
25  return std::max((std::abs(p.x()) - halfWidth) / std::sqrt(err.xx()),
26  (std::abs(p.y()) - halfLength) / std::sqrt(err.yy()));
27 }
28 
29 std::pair<bool, bool> RectangularPlaneBounds::inout(const Local3DPoint& p, const LocalError& err, float scale) const {
30  float xl = std::abs(p.x()) - std::sqrt(err.xx()) * scale;
31  float xh = std::abs(p.x()) + std::sqrt(err.xx()) * scale;
32  bool inx = xl < halfWidth;
33  bool outx = xh > halfWidth;
34 
35  float yl = std::abs(p.y()) - std::sqrt(err.yy()) * scale;
36  float yh = std::abs(p.y()) + std::sqrt(err.yy()) * scale;
37  bool iny = yl < halfLength;
38  bool outy = yh > halfLength;
39 
40  return std::pair<bool, bool>(inx && iny, outx || outy);
41 }
42 
Bounds * clone() const override
float xx() const
Definition: LocalError.h:22
T y() const
Definition: PV2DBase.h:44
T y() const
Definition: PV3DBase.h:60
RectangularPlaneBounds(float w, float h, float t)
float yy() const
Definition: LocalError.h:24
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
std::pair< bool, bool > inout(const Local3DPoint &p, const LocalError &err, float scale=1.f) const
bool inside(const Local2DPoint &p) const override
Definition: Bounds.h:18
T w() const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
T x() const
Definition: PV2DBase.h:43
T x() const
Definition: PV3DBase.h:59
float significanceInside(const Local3DPoint &, const LocalError &) const override