CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
BoundingBox Class Reference

#include <BoundingBox.h>

Public Member Functions

 BoundingBox ()
 
 BoundingBox ()
 
 BoundingBox (const Plane &plane)
 
 BoundingBox (const double &min_r, const double &max_r, const double &min_z, const double &max_z)
 
GlobalPoint const & corner (unsigned int i) const
 
void grow (const double &r, const double &z)
 
void grow (const double &skin)
 
bool inside (const double &r, const double &z) const
 
GlobalPoint const & operator[] (unsigned int i) const
 
std::pair< double, double > range_r () const
 
std::pair< double, double > range_z () const
 

Static Public Member Functions

static std::vector< GlobalPointcorners (const Plane &)
 

Private Attributes

GlobalPoint m_corners [8]
 
double r_max
 
double r_min
 
double z_max
 
double z_min
 

Detailed Description

A helper class that returns the corners of a rectangle that fully contains a bound plane.

Definition at line 12 of file BoundingBox.h.

Constructor & Destructor Documentation

◆ BoundingBox() [1/4]

BoundingBox::BoundingBox ( )
inline

Definition at line 14 of file BoundingBox.h.

14 {}

◆ BoundingBox() [2/4]

BoundingBox::BoundingBox ( const Plane plane)

◆ BoundingBox() [3/4]

BoundingBox::BoundingBox ( )
inline

Definition at line 14 of file BoundingBox.h.

14 : r_min(0.), r_max(0.), z_min(0.), z_max(0.) {}
double z_min
Definition: BoundingBox.h:10
double z_max
Definition: BoundingBox.h:11
double r_min
Definition: BoundingBox.h:8
double r_max
Definition: BoundingBox.h:9

◆ BoundingBox() [4/4]

BoundingBox::BoundingBox ( const double &  min_r,
const double &  max_r,
const double &  min_z,
const double &  max_z 
)
inline

Definition at line 16 of file BoundingBox.h.

17  : r_min(min_r), r_max(max_r), z_min(min_z), z_max(max_z) {}
double z_min
Definition: BoundingBox.h:10
double z_max
Definition: BoundingBox.h:11
double r_min
Definition: BoundingBox.h:8
double r_max
Definition: BoundingBox.h:9

Member Function Documentation

◆ corner()

GlobalPoint const& BoundingBox::corner ( unsigned int  i) const
inline

Definition at line 21 of file BoundingBox.h.

References mps_fire::i, and m_corners.

21 { return m_corners[i]; }
GlobalPoint m_corners[8]
Definition: BoundingBox.h:24

◆ corners()

std::vector< GlobalPoint > BoundingBox::corners ( const Plane )
static

Definition at line 20 of file BoundingBox.cc.

References mps_fire::result.

Referenced by RodPlaneBuilderFromDet::computeBounds(), ForwardRingDiskBuilderFromDet::computeBounds(), Phase1PixelBlade::computeRadiusRanges(), PlaneBuilderForGluedDet::computeRectBounds(), BarrelDetLayer::computeSurface(), ForwardDetLayer::computeSurface(), CylinderBuilderFromDet::operator()(), and PhiBorderFinder::PhiBorderFinder().

20  {
21  std::vector<GlobalPoint> result;
22  result.reserve(8);
23 
24  float hLen = plane.bounds().length() / 2;
25  float hWid = plane.bounds().width() / 2;
26  float hThick = plane.bounds().thickness() / 2;
27 
28  result.push_back(plane.toGlobal(LocalPoint(hWid, hLen, hThick)));
29  result.push_back(plane.toGlobal(LocalPoint(hWid, hLen, -hThick)));
30  result.push_back(plane.toGlobal(LocalPoint(hWid, -hLen, hThick)));
31  result.push_back(plane.toGlobal(LocalPoint(hWid, -hLen, -hThick)));
32  result.push_back(plane.toGlobal(LocalPoint(-hWid, hLen, hThick)));
33  result.push_back(plane.toGlobal(LocalPoint(-hWid, hLen, -hThick)));
34  result.push_back(plane.toGlobal(LocalPoint(-hWid, -hLen, hThick)));
35  result.push_back(plane.toGlobal(LocalPoint(-hWid, -hLen, -hThick)));
36 
37  return result;
38 }

◆ grow() [1/2]

void BoundingBox::grow ( const double &  r,
const double &  z 
)

Definition at line 3 of file BoundingBox.cc.

References alignCSCRings::r, r_max, r_min, z, z_max, and z_min.

Referenced by DD4hep_MaterialAccountingGroup::DD4hep_MaterialAccountingGroup().

3  {
4  if (r < r_min)
5  r_min = r;
6  if (r > r_max)
7  r_max = r;
8  if (z < z_min)
9  z_min = z;
10  if (z > z_max)
11  z_max = z;
12 }
double z_min
Definition: BoundingBox.h:10
double z_max
Definition: BoundingBox.h:11
double r_min
Definition: BoundingBox.h:8
double r_max
Definition: BoundingBox.h:9

◆ grow() [2/2]

void BoundingBox::grow ( const double &  skin)

Definition at line 14 of file BoundingBox.cc.

References r_max, r_min, z_max, and z_min.

14  {
15  r_min -= skin; // yes, we allow r_min to go negative
16  r_max += skin;
17  z_min -= skin;
18  z_max += skin;
19 }
double z_min
Definition: BoundingBox.h:10
double z_max
Definition: BoundingBox.h:11
double r_min
Definition: BoundingBox.h:8
double r_max
Definition: BoundingBox.h:9

◆ inside()

bool BoundingBox::inside ( const double &  r,
const double &  z 
) const
inline

Definition at line 23 of file BoundingBox.h.

References alignCSCRings::r, r_min, z, z_max, and z_min.

Referenced by DD4hep_MaterialAccountingGroup::isInside().

23  {
24  return (r >= r_min and r <= r_max and z >= z_min and z <= z_max);
25  };
double z_min
Definition: BoundingBox.h:10
double z_max
Definition: BoundingBox.h:11
double r_min
Definition: BoundingBox.h:8

◆ operator[]()

GlobalPoint const& BoundingBox::operator[] ( unsigned int  i) const
inline

Definition at line 20 of file BoundingBox.h.

References mps_fire::i, and m_corners.

20 { return m_corners[i]; }
GlobalPoint m_corners[8]
Definition: BoundingBox.h:24

◆ range_r()

std::pair<double, double> BoundingBox::range_r ( ) const
inline

◆ range_z()

std::pair<double, double> BoundingBox::range_z ( ) const
inline

Member Data Documentation

◆ m_corners

GlobalPoint BoundingBox::m_corners[8]
private

Definition at line 24 of file BoundingBox.h.

Referenced by corner(), and operator[]().

◆ r_max

double BoundingBox::r_max
private

Definition at line 9 of file BoundingBox.h.

Referenced by grow(), and range_r().

◆ r_min

double BoundingBox::r_min
private

Definition at line 8 of file BoundingBox.h.

Referenced by grow(), inside(), and range_r().

◆ z_max

double BoundingBox::z_max
private

Definition at line 11 of file BoundingBox.h.

Referenced by grow(), inside(), and range_z().

◆ z_min

double BoundingBox::z_min
private

Definition at line 10 of file BoundingBox.h.

Referenced by grow(), inside(), and range_z().