CMS 3D CMS Logo

TrapezoidalPlaneBounds.cc
Go to the documentation of this file.
1 
2 
5 #include <cmath>
6 
8  float a, float t) :
9  hbotedge(be), htopedge(te), hapothem(a), hthickness(t) {
10 
11  // pre-compute offset of triangle vertex and tg of (half) opening
12  // angle of the trapezoid for faster inside() implementation.
13 
14  offset = a * (te+be) / (te-be); // check sign if te < be !!!
15  tan_a = te / std::abs(offset + a);
16 }
17 
18 
20  return (hbotedge>htopedge) ? -1 : 1;
21 }
22 
24  return (std::abs(p.y()) < hapothem) &
25  (std::abs(p.x()) < tan_a*std::abs(p.y()+offset));
26 }
27 
29  return ((std::abs(p.y()) < hapothem) & (std::abs(p.z()) < hthickness)) && std::abs(p.x()) < tan_a*std::abs(p.y()+offset);
30 }
31 
33  const LocalError& err, float scale) const {
34  if (scale>=0 && inside(p)) return true;
35 
37  htopedge + std::sqrt(err.xx())*scale,
38  hapothem + std::sqrt(err.yy())*scale,
39  hthickness);
40  return tmp.inside(p);
41 }
42 
43 bool TrapezoidalPlaneBounds::inside( const Local2DPoint& p, const LocalError& err, float scale) const {
44  return Bounds::inside(p,err,scale);
45 }
46 
48  return std::max(
49  (std::abs(p.y())-hapothem)/std::sqrt(err.yy()),
50  (std::abs(p.x())-tan_a*std::abs(p.y()+offset))/std::sqrt(err.xx())
51  );
52 }
53 
54 
55 
57  return new TrapezoidalPlaneBounds(*this);
58 }
59 
60 
61 
62 const std::array<const float, 4> TrapezoidalPlaneBounds::parameters() const {
63  // Same order as geant3 for constructor compatibility
64  std::array<const float, 4> vec { { hbotedge, htopedge, hthickness, hapothem } };
65  return vec;
66 }
float xx() const
Definition: LocalError.h:24
T y() const
Definition: PV2DBase.h:46
virtual const std::array< const float, 4 > parameters() const
TrapezoidalPlaneBounds(float be, float te, float a, float t)
T y() const
Definition: PV3DBase.h:63
Bounds * clone() const override
virtual bool inside(const Local3DPoint &) const =0
Determine if the point is inside the bounds.
float yy() const
Definition: LocalError.h:26
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
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
bool inside(const Local2DPoint &p) const override
double a
Definition: hdecay.h:121
Definition: Bounds.h:22
float significanceInside(const Local3DPoint &, const LocalError &) const override
virtual int yAxisOrientation() const
T x() const
Definition: PV2DBase.h:45
T x() const
Definition: PV3DBase.h:62