CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
FourPointPlaneBounds Class Reference

#include <FourPointPlaneBounds.h>

Inheritance diagram for FourPointPlaneBounds:
Bounds

Public Types

typedef LocalPoint::ScalarType Scalar
 

Public Member Functions

Boundsclone () const override
 
 FourPointPlaneBounds (const LocalPoint &a, const LocalPoint &b, const LocalPoint &c, const LocalPoint &d)
 
bool inside (const Local3DPoint &lp) const override
 Determine if the point is inside the bounds. More...
 
bool inside (const Local3DPoint &lp, const LocalError &e, float scale) const override
 Determine if a point is inside the bounds, taking error into account. More...
 
float length () const override
 
float thickness () const override
 
float width () const override
 
 ~FourPointPlaneBounds () override
 
- Public Member Functions inherited from Bounds
void computeSpan (Surface const &plane)
 
virtual bool inside (const Local2DPoint &p) const
 
virtual bool inside (const Local2DPoint &p, float tollerance) const
 Determine if a point is inside the bounds, taking a tollerance into account. More...
 
virtual bool inside (const Local2DPoint &p, const LocalError &err, float scale=1.f) const
 Determine if a 2D point is inside the bounds, taking error into account. More...
 
std::pair< float, float > const & phiSpan () const
 
std::pair< float, float > const & rSpan () const
 
virtual float significanceInside (const Local3DPoint &, const LocalError &) const
 
virtual float widthAtHalfLength () const
 Width at half length. Useful for e.g. pitch definition. More...
 
std::pair< float, float > const & zSpan () const
 
virtual ~Bounds ()
 

Private Member Functions

double checkSide (int i, const Local2DPoint &lp) const
 
double checkSide (int i, Scalar x, Scalar y) const
 
const Local2DPointcorner (int i) const
 

Private Attributes

Local2DPoint corners_ [4]
 

Detailed Description

Definition at line 10 of file FourPointPlaneBounds.h.

Member Typedef Documentation

◆ Scalar

Definition at line 12 of file FourPointPlaneBounds.h.

Constructor & Destructor Documentation

◆ FourPointPlaneBounds()

FourPointPlaneBounds::FourPointPlaneBounds ( const LocalPoint a,
const LocalPoint b,
const LocalPoint c,
const LocalPoint d 
)

The corners are ASSUMED to come in cyclic order

Definition at line 8 of file FourPointPlaneBounds.cc.

References a, b, HltBtagPostValidation_cff::c, checkSide(), corner(), corners_, gather_cfg::cout, ztail::d, mps_fire::i, and std::swap().

Referenced by clone().

11  {
12  corners_[0] = Local2DPoint(a.x(), a.y());
13  corners_[1] = Local2DPoint(b.x(), b.y());
14  corners_[2] = Local2DPoint(c.x(), c.y());
15  corners_[3] = Local2DPoint(d.x(), d.y());
16 
17  // check for convexity
18  for (int i = 0; i < 4; ++i) {
19  if (checkSide(i, corner(i + 2)) * checkSide(i, corner(i + 3)) < 0) { // not on same side
20  throw GeometryError("FourPointPlaneBounds: coners not in order or not convex");
21  }
22  }
23 
24  double side = checkSide(0, corners_[2]); // - for clockwise corners, + for counterclockwise
25  if (side < 0) {
26  std::cout << "FourPointPlaneBounds: Changing order of corners to counterclockwise" << std::endl;
27  std::swap(corners_[1], corners_[3]);
28  }
29 }
const Local2DPoint & corner(int i) const
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
d
Definition: ztail.py:151
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
Point2DBase< float, LocalTag > Local2DPoint
Definition: LocalPoint.h:8
double checkSide(int i, const Local2DPoint &lp) const

◆ ~FourPointPlaneBounds()

FourPointPlaneBounds::~FourPointPlaneBounds ( )
inlineoverride

Definition at line 17 of file FourPointPlaneBounds.h.

17 {}

Member Function Documentation

◆ checkSide() [1/2]

double FourPointPlaneBounds::checkSide ( int  i,
const Local2DPoint lp 
) const
private

Definition at line 31 of file FourPointPlaneBounds.cc.

References mps_fire::i, PV2DBase< T, PVType, FrameType >::x(), and PV2DBase< T, PVType, FrameType >::y().

Referenced by FourPointPlaneBounds(), and inside().

31 { return checkSide(i, lp.x(), lp.y()); }
T x() const
Definition: PV2DBase.h:43
T y() const
Definition: PV2DBase.h:44
double checkSide(int i, const Local2DPoint &lp) const

◆ checkSide() [2/2]

double FourPointPlaneBounds::checkSide ( int  i,
Scalar  x,
Scalar  y 
) const
inlineprivate

Definition at line 36 of file FourPointPlaneBounds.h.

References corner(), mps_fire::i, findQualityFiles::v, x, PV2DBase< T, PVType, FrameType >::x(), y, and PV2DBase< T, PVType, FrameType >::y().

36  {
37  const Local2DPoint& cor(corner(i));
38  Local2DVector v(corner(i + 1) - cor);
39  // Local2DVector normal( -v.y(), v.x()); // 90 deg rotated
40  return -v.y() * (x - cor.x()) + v.x() * (y - cor.y()); // == normal.dot(LP(x,y)-cor))
41  }
const Local2DPoint & corner(int i) const

◆ clone()

Bounds* FourPointPlaneBounds::clone ( void  ) const
inlineoverridevirtual

Implements Bounds.

Definition at line 28 of file FourPointPlaneBounds.h.

References FourPointPlaneBounds().

28 { return new FourPointPlaneBounds(*this); }
FourPointPlaneBounds(const LocalPoint &a, const LocalPoint &b, const LocalPoint &c, const LocalPoint &d)

◆ corner()

const Local2DPoint& FourPointPlaneBounds::corner ( int  i) const
inlineprivate

Definition at line 33 of file FourPointPlaneBounds.h.

References corners_, and mps_fire::i.

Referenced by checkSide(), and FourPointPlaneBounds().

33 { return corners_[i % 4]; }

◆ inside() [1/2]

bool FourPointPlaneBounds::inside ( const Local3DPoint ) const
overridevirtual

Determine if the point is inside the bounds.

Implements Bounds.

Definition at line 33 of file FourPointPlaneBounds.cc.

References checkSide(), mps_fire::i, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

33  {
34  for (int i = 0; i < 4; ++i) {
35  if (checkSide(i, lp.x(), lp.y()) < 0)
36  return false;
37  }
38  return true;
39 }
double checkSide(int i, const Local2DPoint &lp) const

◆ inside() [2/2]

bool FourPointPlaneBounds::inside ( const Local3DPoint ,
const LocalError ,
float  scale 
) const
inlineoverridevirtual

Determine if a point is inside the bounds, taking error into account.

Implements Bounds.

Definition at line 26 of file FourPointPlaneBounds.h.

References inside().

Referenced by inside().

26 { return inside(lp); }
bool inside(const Local3DPoint &lp) const override
Determine if the point is inside the bounds.

◆ length()

float FourPointPlaneBounds::length ( ) const
overridevirtual

"Lenght" of the bounded volume; refer to the concrete class documentation for the specific definition.

Implements Bounds.

Definition at line 41 of file FourPointPlaneBounds.cc.

41 { return 0; }

◆ thickness()

float FourPointPlaneBounds::thickness ( ) const
overridevirtual

"Thickness" of the bound around the surface; refer to the concrete class documentation for the specific definition.

Implements Bounds.

Definition at line 43 of file FourPointPlaneBounds.cc.

43 { return 0; }

◆ width()

float FourPointPlaneBounds::width ( ) const
overridevirtual

"width" of the bounds; refer to the concrete class documentation for the specific definition.

Implements Bounds.

Definition at line 42 of file FourPointPlaneBounds.cc.

42 { return 0; }

Member Data Documentation

◆ corners_

Local2DPoint FourPointPlaneBounds::corners_[4]
private

Definition at line 31 of file FourPointPlaneBounds.h.

Referenced by corner(), and FourPointPlaneBounds().