CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RectangularPlaneBounds.cc
Go to the documentation of this file.
3 #include <cmath>
4 
5 RectangularPlaneBounds::RectangularPlaneBounds( float w, float h, float t) :
6  halfWidth(w), halfLength(h), halfThickness(t) {}
7 
8 
9 bool RectangularPlaneBounds::inside( const Local2DPoint& p) const {
10  return std::abs(p.x()) <= halfWidth && std::abs(p.y()) <= halfLength;
11 }
12 
13 bool RectangularPlaneBounds::inside( const Local3DPoint& p) const {
14  return
15  std::abs(p.x()) < halfWidth &&
16  std::abs(p.y()) < halfLength &&
17  std::abs(p.z()) < halfThickness;
18 }
19 
20 bool RectangularPlaneBounds::inside(const Local2DPoint& p, float tollerance) const {
21  return std::abs(p.x()) < halfWidth + tollerance &&
22  std::abs(p.y()) < halfLength + tollerance;
23 
24 }
25 
26 bool RectangularPlaneBounds::inside(const Local3DPoint& p, const LocalError& err,
27  float scale) const {
28  if(scale >=0){
29  return
30  std::abs(p.z()) < halfThickness &&
31  (std::abs(p.x()) < halfWidth || std::abs(p.x()) < halfWidth + std::sqrt(err.xx())*scale) &&
32  (std::abs(p.y()) < halfLength || std::abs(p.y()) < halfLength + std::sqrt(err.yy())*scale);
33  }else{
34  return
35  std::abs(p.z()) < halfThickness &&
36  (std::abs(p.x()) < halfWidth + std::sqrt(err.xx())*scale) &&
37  (std::abs(p.y()) < halfLength + std::sqrt(err.yy())*scale);
38  }
39 }
40 
41 bool RectangularPlaneBounds::inside( const Local2DPoint& p, const LocalError& err,
42  float scale) const {
43  if(scale >=0){
44  return
45  (std::abs(p.x()) < halfWidth || std::abs(p.x()) < halfWidth + std::sqrt(err.xx())*scale) &&
46  (std::abs(p.y()) < halfLength || std::abs(p.y()) < halfLength + std::sqrt(err.yy())*scale);
47  }else{
48  return
49  (std::abs(p.x()) < halfWidth + std::sqrt(err.xx())*scale) &&
50  (std::abs(p.y()) < halfLength + std::sqrt(err.yy())*scale);
51  }
52 }
53 
54 
55 std::pair<bool,bool> RectangularPlaneBounds::inout( const Local3DPoint& p, const LocalError& err, float scale) const {
56  float xl = std::abs(p.x()) - std::sqrt(err.xx())*scale;
57  float xh = std::abs(p.x()) + std::sqrt(err.xx())*scale;
58  bool inx = xl<halfWidth;
59  bool outx = xh>halfWidth;
60 
61  float yl = std::abs(p.y()) - std::sqrt(err.yy())*scale;
62  float yh = std::abs(p.y()) + std::sqrt(err.yy())*scale;
63  bool iny = yl<halfLength;
64  bool outy = yh>halfLength;
65 
66  return std::pair<bool,bool>(inx&&iny,outx||outy);
67 
68 }
69 
71  return new RectangularPlaneBounds(*this);
72 }
73 
74 
float xx() const
Definition: LocalError.h:24
T y() const
Definition: PV2DBase.h:46
T y() const
Definition: PV3DBase.h:63
#define abs(x)
Definition: mlp_lapack.h:159
float yy() const
Definition: LocalError.h:26
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
Definition: Bounds.h:22
T w() const
T x() const
Definition: PV2DBase.h:45
T x() const
Definition: PV3DBase.h:62