LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
geo::BoxBoundedGeo Class Reference

A base class aware of world box coordinatesAn object describing a simple shape can inherit from this one to gain access to a common boundary checking interface. More...

#include "BoxBoundedGeo.h"

Inheritance diagram for geo::BoxBoundedGeo:
geo::CryostatGeo geo::TPCGeo

Public Types

using Coords_t = geo::Point_t
 Type of the coordinate triplet. More...
 
using Coord_t = Coords_t::Scalar
 Type of the coordinate. More...
 

Public Member Functions

 BoxBoundedGeo ()=default
 Default constructor: sets an empty volume. More...
 
 BoxBoundedGeo (Coord_t x_min, Coord_t x_max, Coord_t y_min, Coord_t y_max, Coord_t z_min, Coord_t z_max)
 Constructor: sets the boundaries in world coordinates as specified. More...
 
 BoxBoundedGeo (Coords_t lower, Coords_t upper)
 Constructor: sets the boundaries in world coordinates as specified. More...
 
Dimension queries
double MinX () const
 Returns the world x coordinate of the start of the box. More...
 
double MaxX () const
 Returns the world x coordinate of the end of the box. More...
 
double CenterX () const
 Returns the world x coordinate of the center of the box. More...
 
double SizeX () const
 Returns the full size in the X dimension. More...
 
double HalfSizeX () const
 Returns the size from the center to the border on X dimension. More...
 
double MinY () const
 Returns the world y coordinate of the start of the box. More...
 
double MaxY () const
 Returns the world y coordinate of the end of the box. More...
 
double CenterY () const
 Returns the world y coordinate of the center of the box. More...
 
double SizeY () const
 Returns the full size in the Y dimension. More...
 
double HalfSizeY () const
 Returns the size from the center to the border on Y dimension. More...
 
double MinZ () const
 Returns the world z coordinate of the start of the box. More...
 
double MaxZ () const
 Returns the world z coordinate of the end of the box. More...
 
double CenterZ () const
 Returns the world z coordinate of the center of the box. More...
 
double SizeZ () const
 Returns the full size in the Z dimension. More...
 
double HalfSizeZ () const
 Returns the size from the center to the border on Z dimension. More...
 
geo::Point_t Min () const
 Returns the corner point with the smallest coordinates. More...
 
geo::Point_t Max () const
 Returns the corner point with the largest coordinates. More...
 
geo::Point_t Center () const
 Returns the center point of the box. More...
 
Containment in the full volume
bool ContainsX (double x, double const wiggle=1) const
 Returns whether this TPC contains the specified world x coordinate. More...
 
bool ContainsY (double y, double const wiggle=1) const
 Returns whether this TPC contains the specified world y coordinate. More...
 
bool ContainsZ (double z, double const wiggle=1) const
 Returns whether this TPC contains the specified world z coordinate. More...
 
bool ContainsYZ (double y, double z, double const wiggle=1) const
 Returns if TPC contains the specified world y and z coordinates. More...
 
bool ContainsPosition (geo::Point_t const &point, double wiggle=1.0) const
 Returns whether this volume contains the specified point. More...
 
bool ContainsPosition (TVector3 const &point, double wiggle=1.0) const
 
bool ContainsPosition (double const *point, double wiggle=1.0) const
 
Containment in a fiducial volume
bool InFiducialX (double x, double neg_margin, double pos_margin) const
 Returns whether TPC fiducial volume contains world x coordinate. More...
 
bool InFiducialX (double x, double margin) const
 Returns whether TPC fiducial volume contains world x coordinate. More...
 
bool InFiducialY (double y, double neg_margin, double pos_margin) const
 Returns whether TPC fiducial volume contains world y coordinate. More...
 
bool InFiducialY (double y, double margin) const
 Returns whether TPC fiducial volume contains world y coordinate. More...
 
bool InFiducialZ (double z, double neg_margin, double pos_margin) const
 Returns whether TPC fiducial volume contains world z coordinate. More...
 
bool InFiducialZ (double z, double margin) const
 Returns whether TPC fiducial volume contains world z coordinate. More...
 
Overlaps
bool OverlapsX (geo::BoxBoundedGeo const &other) const
 Returns if the x coordinates covered by this and other box overlap. More...
 
bool OverlapsY (geo::BoxBoundedGeo const &other) const
 Returns if the y coordinates covered by this and other box overlap. More...
 
bool OverlapsZ (geo::BoxBoundedGeo const &other) const
 Returns if the z coordinates covered by this and other box overlap. More...
 
bool Overlaps (geo::BoxBoundedGeo const &other) const
 Returns if this and other box overlap. More...
 
Setting dimensions
void SetBoundaries (Coord_t x_min, Coord_t x_max, Coord_t y_min, Coord_t y_max, Coord_t z_min, Coord_t z_max)
 Sets the boundaries in world coordinates as specified. More...
 
void SetBoundaries (Coords_t lower, Coords_t upper)
 Sets the boundaries in world coordinates as specified. More...
 
void ExtendToInclude (Coord_t x, Coord_t y, Coord_t z)
 Extends the current box to also include the specified point. More...
 
void ExtendToInclude (geo::Point_t const &point)
 Extends the current box to also include the specified point. More...
 
void ExtendToInclude (BoxBoundedGeo const &box)
 Extends the current box to also include the specified one. More...
 
std::vector< TVector3 > GetIntersections (TVector3 const &TrajectoryStart, TVector3 const &TrajectoryDirect) const
 Calculates the entry and exit points of a trajectory on the box surface. More...
 
std::vector< geo::Point_tGetIntersections (geo::Point_t const &TrajectoryStart, geo::Vector_t const &TrajectoryDirect) const
 Calculates the entry and exit points of a trajectory on the box surface. More...
 

Static Public Member Functions

static bool CoordinateContained (double c, double min, double max, double wiggle=1.)
 Returns whether the specified coordinate is in a range. More...
 
static bool CoordinateContained (double c, double const *range, double wiggle=1.)
 Returns whether the specified coordinate is in a range. More...
 
static void set_min (Coord_t &var, Coord_t value)
 Sets var to value if value is smaller than the current var value. More...
 
static void set_max (Coord_t &var, Coord_t value)
 Sets var to value if value is larger than the current var value. More...
 
static void set_min (Coords_t &var, geo::Point_t const &value)
 Sets each coordinate of var to the one in value if the latter is smaller. More...
 
static void set_max (Coords_t &var, geo::Point_t const &value)
 Sets each coordinate of var to the one in value if the latter is larger. More...
 

Private Member Functions

void SortCoordinates ()
 Makes sure each coordinate of the minimum point is smaller than maximum. More...
 

Private Attributes

Coords_t c_min
 minimum coordinates (x, y, z) More...
 
Coords_t c_max
 maximum coordinates (x, y, z) More...
 

Detailed Description

A base class aware of world box coordinates

An object describing a simple shape can inherit from this one to gain access to a common boundary checking interface.

The boundary is a simple box with axes parallel to the coordinate system.

Definition at line 33 of file BoxBoundedGeo.h.

Member Typedef Documentation

using geo::BoxBoundedGeo::Coord_t = Coords_t::Scalar

Type of the coordinate.

Definition at line 36 of file BoxBoundedGeo.h.

Type of the coordinate triplet.

Definition at line 35 of file BoxBoundedGeo.h.

Constructor & Destructor Documentation

geo::BoxBoundedGeo::BoxBoundedGeo ( )
default

Default constructor: sets an empty volume.

See also
SetBoundaries

We allow for a default construction since the derived object might need some specific action before being aware of its boundaries. In that case, SetBoundaries() will set the boundaries.

geo::BoxBoundedGeo::BoxBoundedGeo ( Coord_t  x_min,
Coord_t  x_max,
Coord_t  y_min,
Coord_t  y_max,
Coord_t  z_min,
Coord_t  z_max 
)
inline

Constructor: sets the boundaries in world coordinates as specified.

Parameters
x_minlower x coordinate
x_maxupper x coordinate
y_minlower y coordinate
y_maxupper y coordinate
z_minlower z coordinate
z_maxupper z coordinate
See also
SetBoundaries()

Note that is assumed that each minimum is larger than its maximum, and no check is performed.

Definition at line 61 of file BoxBoundedGeo.h.

References c_max, SortCoordinates(), x_max, and x_min.

67  : c_min{x_min, y_min, z_min}, c_max{x_max, y_max, z_max}
68  {
70  }
double x_min
Definition: berger.C:15
Coords_t c_max
maximum coordinates (x, y, z)
double x_max
Definition: berger.C:16
Coords_t c_min
minimum coordinates (x, y, z)
void SortCoordinates()
Makes sure each coordinate of the minimum point is smaller than maximum.
geo::BoxBoundedGeo::BoxBoundedGeo ( Coords_t  lower,
Coords_t  upper 
)
inline

Constructor: sets the boundaries in world coordinates as specified.

Parameters
lowerlower coordinates (x, y, z)
upperupper coordinates (x, y, z)
See also
SetBoundaries()

Note that is assumed that each minimum is larger than its maximum, and no check is performed.

Definition at line 81 of file BoxBoundedGeo.h.

References SortCoordinates().

81  : c_min(lower), c_max(upper)
82  {
84  }
Coords_t c_max
maximum coordinates (x, y, z)
Coords_t c_min
minimum coordinates (x, y, z)
void SortCoordinates()
Makes sure each coordinate of the minimum point is smaller than maximum.

Member Function Documentation

geo::Point_t geo::BoxBoundedGeo::Center ( ) const
inline

Returns the center point of the box.

Definition at line 141 of file BoxBoundedGeo.h.

References CenterX(), CenterY(), and CenterZ().

Referenced by geo::buildDriftVolumes(), geo::CryostatGeo::GetCenter(), and geo::PlaneGeo::UpdatePlaneNormal().

141 { return {CenterX(), CenterY(), CenterZ()}; }
double CenterX() const
Returns the world x coordinate of the center of the box.
Definition: BoxBoundedGeo.h:96
double CenterZ() const
Returns the world z coordinate of the center of the box.
double CenterY() const
Returns the world y coordinate of the center of the box.
double geo::BoxBoundedGeo::CenterX ( ) const
inline

Returns the world x coordinate of the center of the box.

Definition at line 96 of file BoxBoundedGeo.h.

References MaxX(), and MinX().

Referenced by Center().

96 { return (MinX() + MaxX()) / 2.; }
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:90
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:93
double geo::BoxBoundedGeo::CenterY ( ) const
inline

Returns the world y coordinate of the center of the box.

Definition at line 111 of file BoxBoundedGeo.h.

References MaxY(), and MinY().

Referenced by Center().

111 { return (MinY() + MaxY()) / 2.; }
double MaxY() const
Returns the world y coordinate of the end of the box.
double MinY() const
Returns the world y coordinate of the start of the box.
double geo::BoxBoundedGeo::CenterZ ( ) const
inline

Returns the world z coordinate of the center of the box.

Definition at line 126 of file BoxBoundedGeo.h.

References MaxZ(), and MinZ().

Referenced by Center().

126 { return (MinZ() + MaxZ()) / 2.; }
double MinZ() const
Returns the world z coordinate of the start of the box.
double MaxZ() const
Returns the world z coordinate of the end of the box.
bool geo::BoxBoundedGeo::ContainsPosition ( geo::Point_t const &  point,
double  wiggle = 1.0 
) const
inline

Returns whether this volume contains the specified point.

Parameters
pointthe point [cm]
wiggleexpansion factor for the range
Returns
whether the specified coordinate is in this volume

If the wiggle is larger than 1, each size of the volume is expanded by the wiggle factor. If the wiggle is less than 1, each size is shrinked.

Definition at line 210 of file BoxBoundedGeo.h.

References ContainsX(), and ContainsYZ().

Referenced by ContainsPosition(), and geo::GeometryCore::MaterialName().

211  {
212  return ContainsX(point.X(), wiggle) && ContainsYZ(point.Y(), point.Z(), wiggle);
213  } // ContainsPosition()
bool ContainsX(double x, double const wiggle=1) const
Returns whether this TPC contains the specified world x coordinate.
bool ContainsYZ(double y, double z, double const wiggle=1) const
Returns if TPC contains the specified world y and z coordinates.
bool geo::BoxBoundedGeo::ContainsPosition ( TVector3 const &  point,
double  wiggle = 1.0 
) const
See also
ContainsPosition(geo::Point_t const&, double) const.

Definition at line 24 of file BoxBoundedGeo.cxx.

References ContainsPosition(), and geo::vect::toPoint().

25  {
26  return ContainsPosition(geo::vect::toPoint(point), wiggle);
27  }
::geo::Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
bool ContainsPosition(geo::Point_t const &point, double wiggle=1.0) const
Returns whether this volume contains the specified point.
bool geo::BoxBoundedGeo::ContainsPosition ( double const *  point,
double  wiggle = 1.0 
) const
See also
ContainsPosition(geo::Point_t const&, double) const.

Definition at line 30 of file BoxBoundedGeo.cxx.

References ContainsPosition(), and geo::vect::makePointFromCoords().

31  {
32  return ContainsPosition(geo::vect::makePointFromCoords(point), wiggle);
33  }
GENVECTOR_CONSTEXPR::geo::Point_t makePointFromCoords(Coords &&coords)
Creates a geo::Point_t from its coordinates (see makeFromCoords()).
bool ContainsPosition(geo::Point_t const &point, double wiggle=1.0) const
Returns whether this volume contains the specified point.
bool geo::BoxBoundedGeo::ContainsX ( double  x,
double const  wiggle = 1 
) const
inline

Returns whether this TPC contains the specified world x coordinate.

Parameters
xthe absolute ("world") coordinate x
wiggleexpansion factor for the range (see ContainsPosition())
Returns
whether the specified coordinate is in this TPC
See also
ContainsPosition()

Note that x is by definition the drift direction, and a reconstructed x typically depends on an assumption respect to the event time.

Definition at line 158 of file BoxBoundedGeo.h.

References CoordinateContained(), MaxX(), and MinX().

Referenced by ContainsPosition().

159  {
160  return CoordinateContained(x, MinX(), MaxX(), wiggle);
161  }
Float_t x
Definition: compare.C:6
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:90
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:93
static bool CoordinateContained(double c, double min, double max, double wiggle=1.)
Returns whether the specified coordinate is in a range.
bool geo::BoxBoundedGeo::ContainsY ( double  y,
double const  wiggle = 1 
) const
inline

Returns whether this TPC contains the specified world y coordinate.

Parameters
ythe absolute ("world") coordinate y
wiggleexpansion factor for the range (see ContainsPosition())
Returns
whether the specified coordinate is in this TPC
See also
ContainsPosition()

Definition at line 170 of file BoxBoundedGeo.h.

References CoordinateContained(), MaxY(), and MinY().

Referenced by ContainsYZ().

171  {
172  return CoordinateContained(y, MinY(), MaxY(), wiggle);
173  }
Float_t y
Definition: compare.C:6
double MaxY() const
Returns the world y coordinate of the end of the box.
static bool CoordinateContained(double c, double min, double max, double wiggle=1.)
Returns whether the specified coordinate is in a range.
double MinY() const
Returns the world y coordinate of the start of the box.
bool geo::BoxBoundedGeo::ContainsYZ ( double  y,
double  z,
double const  wiggle = 1 
) const
inline

Returns if TPC contains the specified world y and z coordinates.

Parameters
ythe absolute ("world") coordinate y
zthe absolute ("world") coordinate z
wiggleexpansion factor for the range (see ContainsPosition())
Returns
whether the specified coordinate is in this TPC
See also
ContainsPosition()

Definition at line 195 of file BoxBoundedGeo.h.

References ContainsY(), and ContainsZ().

Referenced by ContainsPosition().

196  {
197  return ContainsY(y, wiggle) && ContainsZ(z, wiggle);
198  }
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
bool ContainsY(double y, double const wiggle=1) const
Returns whether this TPC contains the specified world y coordinate.
bool ContainsZ(double z, double const wiggle=1) const
Returns whether this TPC contains the specified world z coordinate.
bool geo::BoxBoundedGeo::ContainsZ ( double  z,
double const  wiggle = 1 
) const
inline

Returns whether this TPC contains the specified world z coordinate.

Parameters
zthe absolute ("world") coordinate z
wiggleexpansion factor for the range (see ContainsPosition())
Returns
whether the specified coordinate is in this TPC
See also
ContainsPosition()

Definition at line 182 of file BoxBoundedGeo.h.

References CoordinateContained(), MaxZ(), and MinZ().

Referenced by ContainsYZ().

183  {
184  return CoordinateContained(z, MinZ(), MaxZ(), wiggle);
185  }
Double_t z
Definition: plot.C:276
double MinZ() const
Returns the world z coordinate of the start of the box.
double MaxZ() const
Returns the world z coordinate of the end of the box.
static bool CoordinateContained(double c, double min, double max, double wiggle=1.)
Returns whether the specified coordinate is in a range.
static bool geo::BoxBoundedGeo::CoordinateContained ( double  c,
double  min,
double  max,
double  wiggle = 1. 
)
inlinestatic

Returns whether the specified coordinate is in a range.

Parameters
cthe coordinate
minlower boundary of the range
maxupper boundary of the range
wiggleexpansion factor for the range
Returns
whether the specified coordinate is in a range

If the wiggle is larger than 1, the range is expanded by the wiggle factor. If the wiggle is less than 1, the range is shrinked.

Definition at line 359 of file BoxBoundedGeo.h.

Referenced by ContainsX(), ContainsY(), ContainsZ(), CoordinateContained(), InFiducialX(), InFiducialY(), and InFiducialZ().

360  {
361  return (c >= (min > 0 ? min / wiggle : min * wiggle)) &&
362  (c <= (max < 0 ? max / wiggle : max * wiggle));
363  } // CoordinateContained()
static bool geo::BoxBoundedGeo::CoordinateContained ( double  c,
double const *  range,
double  wiggle = 1. 
)
inlinestatic

Returns whether the specified coordinate is in a range.

Parameters
cthe coordinate
rangepointer to [ lower boundary, upper boundary ] of the range
wiggleexpansion factor for the range
Returns
whether the specified coordinate is in a range
See also
CoordinateContained(double, double, double, double)

If the wiggle is larger than 1, the range is expanded by the wiggle factor. If the wiggle is less than 1, the range is shrinked.

Definition at line 376 of file BoxBoundedGeo.h.

References CoordinateContained().

377  {
378  return CoordinateContained(c, range[0], range[1], wiggle);
379  }
static bool CoordinateContained(double c, double min, double max, double wiggle=1.)
Returns whether the specified coordinate is in a range.
void geo::BoxBoundedGeo::ExtendToInclude ( Coord_t  x,
Coord_t  y,
Coord_t  z 
)
inline

Extends the current box to also include the specified point.

Parameters
xx coordinate of the point to include
yy coordinate of the point to include
zz coordinate of the point to include

Definition at line 423 of file BoxBoundedGeo.h.

Referenced by geo::PlaneGeo::BoundingBox(), evd_tool::ProtoDUNEDrawer::DetOutline3D(), evd_tool::StandardDrawer::DetOutline3D(), larg4::ISTPC::extractActiveLArVolume(), larg4::OpFastScintillation::extractActiveVolumes(), and phot::PhotonVisibilityService::reconfigure().

424  {
426  }
Float_t x
Definition: compare.C:6
Float_t y
Definition: compare.C:6
Double_t z
Definition: plot.C:276
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:180
void ExtendToInclude(Coord_t x, Coord_t y, Coord_t z)
Extends the current box to also include the specified point.
void geo::BoxBoundedGeo::ExtendToInclude ( geo::Point_t const &  point)
inline

Extends the current box to also include the specified point.

Parameters
pointcoordinates of the point to include

Definition at line 432 of file BoxBoundedGeo.h.

References c_max, c_min, set_max(), and set_min().

433  {
434  set_min(c_min, point);
435  set_max(c_max, point);
436  }
static void set_min(Coord_t &var, Coord_t value)
Sets var to value if value is smaller than the current var value.
static void set_max(Coord_t &var, Coord_t value)
Sets var to value if value is larger than the current var value.
Coords_t c_max
maximum coordinates (x, y, z)
Coords_t c_min
minimum coordinates (x, y, z)
void geo::BoxBoundedGeo::ExtendToInclude ( BoxBoundedGeo const &  box)
inline

Extends the current box to also include the specified one.

Parameters
boxthe box to include

It is assumed that the box has its boundaries properly sorted.

Definition at line 444 of file BoxBoundedGeo.h.

References c_max, c_min, GetIntersections(), Max(), Min(), set_max(), and set_min().

445  {
446  set_min(c_min, box.Min());
447  set_max(c_max, box.Max());
448  } // ExtendToInclude()
static void set_min(Coord_t &var, Coord_t value)
Sets var to value if value is smaller than the current var value.
static void set_max(Coord_t &var, Coord_t value)
Sets var to value if value is larger than the current var value.
Coords_t c_max
maximum coordinates (x, y, z)
Coords_t c_min
minimum coordinates (x, y, z)
std::vector< TVector3 > geo::BoxBoundedGeo::GetIntersections ( TVector3 const &  TrajectoryStart,
TVector3 const &  TrajectoryDirect 
) const

Calculates the entry and exit points of a trajectory on the box surface.

Author
Christoph Rudolf von Rohr (crohr.nosp@m.@fna.nosp@m.l.gov)
Date
July 27th, 2015
Parameters
TrajectoryStartposition of the trajectory source
TrajectoryDirectdirection vector of the trajectory

This member is public since it just gives an output and does not change any member. The algorithm works only for a box shaped active volume with facing walls parallel to axis. If the return std::vector is empty the trajectory does not intersect with the box. Normally the return value should have one (if the trajectory originates in the box) or two (else) entries. If the return value has two entries the first represents the entry point and the second the exit point

Definition at line 125 of file BoxBoundedGeo.cxx.

Referenced by ExtendToInclude().

127  {
128  std::vector<TVector3> intersections;
129  for (auto const& point :
130  GetIntersections(geo::Point_t(TrajectoryStart), geo::Vector_t(TrajectoryDirect)))
131  intersections.emplace_back(point.X(), point.Y(), point.Z());
132  return intersections;
133  } // GetIntersections(TVector3)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Definition: geo_vectors.h:160
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:180
std::vector< TVector3 > GetIntersections(TVector3 const &TrajectoryStart, TVector3 const &TrajectoryDirect) const
Calculates the entry and exit points of a trajectory on the box surface.
std::vector< geo::Point_t > geo::BoxBoundedGeo::GetIntersections ( geo::Point_t const &  TrajectoryStart,
geo::Vector_t const &  TrajectoryDirect 
) const

Calculates the entry and exit points of a trajectory on the box surface.

Author
Christoph Rudolf von Rohr (crohr.nosp@m.@fna.nosp@m.l.gov)
Date
July 27th, 2015
Parameters
TrajectoryStartposition of the trajectory source
TrajectoryDirectdirection vector of the trajectory

This member is public since it just gives an output and does not change any member. The algorithm works only for a box shaped active volume with facing walls parallel to axis. If the return std::vector is empty the trajectory does not intersect with the box. Normally the return value should have one (if the trajectory originates in the box) or two (else) entries. If the return value has two entries the first represents the entry point and the second the exit point

Definition at line 36 of file BoxBoundedGeo.cxx.

References geo::vect::bindCoord(), c_max, c_min, geo::vect::coord(), Max(), and Min().

39  {
40 
41  std::vector<geo::Point_t> IntersectionPoints;
42  std::vector<double> LineParameters;
43 
44  // Generate normal vectors and offsets for every plane of the box
45  // All normal vectors are headed outwards
46  // BUG the double brace syntax is required to work around clang bug 21629
47  // (https://bugs.llvm.org/show_bug.cgi?id=21629)
48  static std::array<geo::Vector_t, 6U> const NormalVectors = {{
49  -geo::Xaxis<geo::Vector_t>(),
50  geo::Xaxis<geo::Vector_t>(), // anode, cathode,
51  -geo::Yaxis<geo::Vector_t>(),
52  geo::Yaxis<geo::Vector_t>(), // bottom, top,
53  -geo::Zaxis<geo::Vector_t>(),
54  geo::Zaxis<geo::Vector_t>() // upstream, downstream
55  }};
56  // BUG the double brace syntax is required to work around clang bug 21629
57  // (https://bugs.llvm.org/show_bug.cgi?id=21629)
58  std::array<geo::Point_t, 6U> const NormalVectorOffsets = {{
59  geo::Point_t{Min().X(), Min().Y(), Min().Z()}, // Anode offset
60  geo::Point_t{Max().X(), Min().Y(), Min().Z()}, // Cathode
61  geo::Point_t{Min().X(), Min().Y(), Min().Z()}, // Bottom
62  geo::Point_t{Min().X(), Max().Y(), Min().Z()}, // Top
63  geo::Point_t{Min().X(), Min().Y(), Min().Z()}, // upstream
64  geo::Point_t{Min().X(), Min().Y(), Max().Z()} // downstream
65  }};
66 
67  // Loop over all surfaces of the box
68  for (unsigned int face_no = 0; face_no < NormalVectors.size(); face_no++) {
69  // Check if trajectory and surface are not parallel
70  if (NormalVectors[face_no].Dot(TrajectoryDirect)) {
71  // Calculate the line parameter for the intersection points
72  LineParameters.push_back(
73  NormalVectors[face_no].Dot(NormalVectorOffsets.at(face_no) - TrajectoryStart) /
74  NormalVectors[face_no].Dot(TrajectoryDirect));
75  }
76  else
77  continue;
78 
79  // Calculate intersection point using the line parameter
80  IntersectionPoints.push_back(TrajectoryStart + LineParameters.back() * TrajectoryDirect);
81 
82  // Coordinate which should be ignored when checking for limits added by Christoph Rudolf von Rohr 05/21/2016
83  unsigned int NoCheckCoord;
84 
85  // Calculate NoCheckCoord out of the face_no
86  if (face_no % 2) {
87  // Convert odd face number to coordinate
88  NoCheckCoord = (face_no - 1) / 2;
89  }
90  else {
91  // Convert even face number to coordinate
92  NoCheckCoord = face_no / 2;
93  }
94 
95  // Loop over all three space coordinates
96  unsigned int coord = 0;
97  for (auto extractCoord : geo::vect::coordReaders<geo::Point_t>()) {
98  auto const lastPointCoord = geo::vect::bindCoord(IntersectionPoints.back(), extractCoord);
99  auto const minCoord = geo::vect::bindCoord(c_min, extractCoord);
100  auto const maxCoord = geo::vect::bindCoord(c_max, extractCoord);
101 
102  // Changed by Christoph Rudolf von Rohr 05/21/2016
103  // Then check if point is not within the surface limits at this coordinate, without looking
104  // at the plane normal vector coordinate. We can assume, that our algorithm already found this coordinate correctily.
105  // In rare cases, looking for boundaries in this coordinate causes unexpected behavior due to floating point inaccuracies.
106  if (coord++ != NoCheckCoord &&
107  ((lastPointCoord() > maxCoord()) || (lastPointCoord() < minCoord))) {
108  // if off limits, get rid of the useless data and break the coordinate loop
109  LineParameters.pop_back();
110  IntersectionPoints.pop_back();
111  break;
112  }
113  } // coordinate loop
114  } // Surcaces loop
115 
116  // sort points according to their parameter value (first is entry, second is exit)
117  if (LineParameters.size() == 2 && LineParameters.front() > LineParameters.back()) {
118  std::swap(IntersectionPoints.front(), IntersectionPoints.back());
119  }
120 
121  return IntersectionPoints;
122  } // GetIntersections()
auto coord(Vector &v, unsigned int n) noexcept
Returns an object to manage the coordinate n of a vector.
constexpr auto bindCoord(Vector const &v, CoordReader_t< Vector > helper)
Binds the specified constant vector to the coordinate reader.
geo::Point_t Min() const
Returns the corner point with the smallest coordinates.
Coords_t c_max
maximum coordinates (x, y, z)
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:180
Coords_t c_min
minimum coordinates (x, y, z)
void swap(lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &a, lar::deep_const_fwd_iterator_nested< CITER, INNERCONTEXTRACT > &b)
geo::Point_t Max() const
Returns the corner point with the largest coordinates.
double geo::BoxBoundedGeo::HalfSizeX ( ) const
inline

Returns the size from the center to the border on X dimension.

Definition at line 102 of file BoxBoundedGeo.h.

References SizeX().

102 { return SizeX() / 2.0; }
double SizeX() const
Returns the full size in the X dimension.
Definition: BoxBoundedGeo.h:99
double geo::BoxBoundedGeo::HalfSizeY ( ) const
inline

Returns the size from the center to the border on Y dimension.

Definition at line 117 of file BoxBoundedGeo.h.

References SizeY().

117 { return SizeY() / 2.0; }
double SizeY() const
Returns the full size in the Y dimension.
double geo::BoxBoundedGeo::HalfSizeZ ( ) const
inline

Returns the size from the center to the border on Z dimension.

Definition at line 132 of file BoxBoundedGeo.h.

References SizeZ().

132 { return SizeZ() / 2.0; }
double SizeZ() const
Returns the full size in the Z dimension.
bool geo::BoxBoundedGeo::InFiducialX ( double  x,
double  neg_margin,
double  pos_margin 
) const
inline

Returns whether TPC fiducial volume contains world x coordinate.

Parameters
xthe absolute ("world") coordinate x
neg_marginhow far within the TPC the fiducial region starts
pos_marginhow far before the TPC the fiducial region ends
Returns
whether the specified coordinate is in this TPC fiducial volume

The fiducial volume is defined by the specified margins, that denote how much of the coordinate is not fiducial. For example,

bool bWithin = tpc->InFiducialX(x, 5., 8.);

on a TPC with x from 0 to 100 (cm, presumably) will return true for all x between 5 and 92. If positive margin is not specified, it's assumed to be the same as the negative one. Specifying a negative mergin effectively extends the TPC volume. Note that x is by definition the drift direction, and a reconstructed x typically depends on an assumption respect to the event time.

Definition at line 243 of file BoxBoundedGeo.h.

References CoordinateContained(), MaxX(), and MinX().

244  {
245  return CoordinateContained(x, MinX() + neg_margin, MaxX() - pos_margin);
246  }
Float_t x
Definition: compare.C:6
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:90
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:93
static bool CoordinateContained(double c, double min, double max, double wiggle=1.)
Returns whether the specified coordinate is in a range.
bool geo::BoxBoundedGeo::InFiducialX ( double  x,
double  margin 
) const
inline

Returns whether TPC fiducial volume contains world x coordinate.

See also
InFiducialX(double, double, double) const

Margins are symmetric.

Definition at line 253 of file BoxBoundedGeo.h.

References InFiducialX().

Referenced by InFiducialX().

253 { return InFiducialX(x, margin, margin); }
Float_t x
Definition: compare.C:6
bool InFiducialX(double x, double neg_margin, double pos_margin) const
Returns whether TPC fiducial volume contains world x coordinate.
bool geo::BoxBoundedGeo::InFiducialY ( double  y,
double  neg_margin,
double  pos_margin 
) const
inline

Returns whether TPC fiducial volume contains world y coordinate.

Parameters
ythe absolute ("world") coordinate y
neg_marginhow far within the TPC the fiducial region starts
pos_marginhow far before the TPC the fiducial region ends
Returns
whether the specified coordinate is in this TPC fiducial volume

The fiducial volume is defined by the specified margins, that denote how much of the coordinate is not fiducial. For example,

bool bWithin = tpc->InFiducialY(y, 5., 8.);

on a TPC with y from 0 to 100 (cm, presumably) will return true for all y between 5 and 92. If positive margin is not specified, it's assumed to be the same as the negative one. Specifying a negative mergin effectively extends the TPC volume.

Definition at line 273 of file BoxBoundedGeo.h.

References CoordinateContained(), MaxY(), and MinY().

274  {
275  return CoordinateContained(y, MinY() + neg_margin, MaxY() - pos_margin);
276  }
Float_t y
Definition: compare.C:6
double MaxY() const
Returns the world y coordinate of the end of the box.
static bool CoordinateContained(double c, double min, double max, double wiggle=1.)
Returns whether the specified coordinate is in a range.
double MinY() const
Returns the world y coordinate of the start of the box.
bool geo::BoxBoundedGeo::InFiducialY ( double  y,
double  margin 
) const
inline

Returns whether TPC fiducial volume contains world y coordinate.

See also
InFiducialY(double, double, double) const

Margins are symmetric.

Definition at line 283 of file BoxBoundedGeo.h.

References InFiducialY().

Referenced by InFiducialY().

283 { return InFiducialY(y, margin, margin); }
Float_t y
Definition: compare.C:6
bool InFiducialY(double y, double neg_margin, double pos_margin) const
Returns whether TPC fiducial volume contains world y coordinate.
bool geo::BoxBoundedGeo::InFiducialZ ( double  z,
double  neg_margin,
double  pos_margin 
) const
inline

Returns whether TPC fiducial volume contains world z coordinate.

Parameters
zthe absolute ("world") coordinate y
neg_marginhow far within the TPC the fiducial region starts
pos_marginhow far before the TPC the fiducial region ends
Returns
whether the specified coordinate is in this TPC fiducial volume

The fiducial volume is defined by the specified margins, that denote how much of the coordinate is not fiducial. For example,

bool bWithin = tpc->InFiducialZ(z, 5., 8.);

on a TPC with z from 0 to 100 (cm, presumably) will return true for all z between 5 and 92. If positive margin is not specified, it's assumed to be the same as the negative one. Specifying a negative mergin effectively extends the TPC volume.

Definition at line 303 of file BoxBoundedGeo.h.

References CoordinateContained(), MaxZ(), and MinZ().

304  {
305  return CoordinateContained(z, MinZ() + neg_margin, MaxZ() - pos_margin);
306  }
Double_t z
Definition: plot.C:276
double MinZ() const
Returns the world z coordinate of the start of the box.
double MaxZ() const
Returns the world z coordinate of the end of the box.
static bool CoordinateContained(double c, double min, double max, double wiggle=1.)
Returns whether the specified coordinate is in a range.
bool geo::BoxBoundedGeo::InFiducialZ ( double  z,
double  margin 
) const
inline

Returns whether TPC fiducial volume contains world z coordinate.

See also
InFiducialZ(double, double, double) const

Margins are symmetric.

Definition at line 313 of file BoxBoundedGeo.h.

References InFiducialZ().

Referenced by InFiducialZ().

313 { return InFiducialZ(z, margin, margin); }
Double_t z
Definition: plot.C:276
bool InFiducialZ(double z, double neg_margin, double pos_margin) const
Returns whether TPC fiducial volume contains world z coordinate.
geo::Point_t geo::BoxBoundedGeo::Max ( ) const
inline

Returns the corner point with the largest coordinates.

Definition at line 138 of file BoxBoundedGeo.h.

References c_max.

Referenced by ExtendToInclude(), GetIntersections(), geo::GeometryCore::MaterialName(), geo::CryostatGeo::PrintCryostatInfo(), and geo::TPCGeo::PrintTPCInfo().

138 { return c_max; }
Coords_t c_max
maximum coordinates (x, y, z)
double geo::BoxBoundedGeo::MaxX ( ) const
inline
double geo::BoxBoundedGeo::MaxY ( ) const
inline
double geo::BoxBoundedGeo::MaxZ ( ) const
inline
geo::Point_t geo::BoxBoundedGeo::Min ( ) const
inline

Returns the corner point with the smallest coordinates.

Definition at line 135 of file BoxBoundedGeo.h.

References c_min.

Referenced by ExtendToInclude(), GetIntersections(), geo::GeometryCore::MaterialName(), geo::CryostatGeo::PrintCryostatInfo(), and geo::TPCGeo::PrintTPCInfo().

135 { return c_min; }
Coords_t c_min
minimum coordinates (x, y, z)
double geo::BoxBoundedGeo::MinY ( ) const
inline
double geo::BoxBoundedGeo::MinZ ( ) const
inline
bool geo::BoxBoundedGeo::Overlaps ( geo::BoxBoundedGeo const &  other) const
inline

Returns if this and other box overlap.

Definition at line 340 of file BoxBoundedGeo.h.

References OverlapsX(), OverlapsY(), and OverlapsZ().

341  {
342  return OverlapsX(other) && OverlapsY(other) && OverlapsZ(other);
343  }
bool OverlapsX(geo::BoxBoundedGeo const &other) const
Returns if the x coordinates covered by this and other box overlap.
bool OverlapsZ(geo::BoxBoundedGeo const &other) const
Returns if the z coordinates covered by this and other box overlap.
bool OverlapsY(geo::BoxBoundedGeo const &other) const
Returns if the y coordinates covered by this and other box overlap.
bool geo::BoxBoundedGeo::OverlapsX ( geo::BoxBoundedGeo const &  other) const
inline

Returns if the x coordinates covered by this and other box overlap.

Definition at line 322 of file BoxBoundedGeo.h.

References MaxX(), and MinX().

Referenced by Overlaps().

323  {
324  return std::min(MaxX(), other.MaxX()) > std::max(MinX(), other.MinX());
325  }
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:90
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:93
bool geo::BoxBoundedGeo::OverlapsY ( geo::BoxBoundedGeo const &  other) const
inline

Returns if the y coordinates covered by this and other box overlap.

Definition at line 328 of file BoxBoundedGeo.h.

References MaxY(), and MinY().

Referenced by Overlaps().

329  {
330  return std::min(MaxY(), other.MaxY()) > std::max(MinY(), other.MinY());
331  }
double MaxY() const
Returns the world y coordinate of the end of the box.
double MinY() const
Returns the world y coordinate of the start of the box.
bool geo::BoxBoundedGeo::OverlapsZ ( geo::BoxBoundedGeo const &  other) const
inline

Returns if the z coordinates covered by this and other box overlap.

Definition at line 334 of file BoxBoundedGeo.h.

References MaxZ(), and MinZ().

Referenced by Overlaps().

335  {
336  return std::min(MaxZ(), other.MaxZ()) > std::max(MinZ(), other.MinZ());
337  }
double MinZ() const
Returns the world z coordinate of the start of the box.
double MaxZ() const
Returns the world z coordinate of the end of the box.
static void geo::BoxBoundedGeo::set_max ( Coord_t var,
Coord_t  value 
)
inlinestatic

Sets var to value if value is larger than the current var value.

Definition at line 479 of file BoxBoundedGeo.h.

References value.

Referenced by ExtendToInclude().

480  {
481  if (value > var) var = value;
482  }
double value
Definition: spectrum.C:18
static void geo::BoxBoundedGeo::set_max ( Coords_t var,
geo::Point_t const &  value 
)
inlinestatic

Sets each coordinate of var to the one in value if the latter is larger.

Definition at line 493 of file BoxBoundedGeo.h.

494  {
495  if (value.X() > var.X()) var.SetX(value.X());
496  if (value.Y() > var.Y()) var.SetY(value.Y());
497  if (value.Z() > var.Z()) var.SetZ(value.Z());
498  }
double value
Definition: spectrum.C:18
static void geo::BoxBoundedGeo::set_min ( Coord_t var,
Coord_t  value 
)
inlinestatic

Sets var to value if value is smaller than the current var value.

Definition at line 473 of file BoxBoundedGeo.h.

References value.

Referenced by ExtendToInclude().

474  {
475  if (value < var) var = value;
476  }
double value
Definition: spectrum.C:18
static void geo::BoxBoundedGeo::set_min ( Coords_t var,
geo::Point_t const &  value 
)
inlinestatic

Sets each coordinate of var to the one in value if the latter is smaller.

Definition at line 485 of file BoxBoundedGeo.h.

486  {
487  if (value.X() < var.X()) var.SetX(value.X());
488  if (value.Y() < var.Y()) var.SetY(value.Y());
489  if (value.Z() < var.Z()) var.SetZ(value.Z());
490  }
double value
Definition: spectrum.C:18
void geo::BoxBoundedGeo::SetBoundaries ( Coord_t  x_min,
Coord_t  x_max,
Coord_t  y_min,
Coord_t  y_max,
Coord_t  z_min,
Coord_t  z_max 
)
inline

Sets the boundaries in world coordinates as specified.

Parameters
x_minlower x coordinate
x_maxupper x coordinate
y_minlower y coordinate
y_maxupper y coordinate
z_minlower z coordinate
z_maxupper z coordinate

Definition at line 393 of file BoxBoundedGeo.h.

References c_max, c_min, and SortCoordinates().

Referenced by geo::PlaneGeo::BoundingBox(), geo::CryostatGeo::InitCryoBoundaries(), and geo::TPCGeo::InitTPCBoundaries().

399  {
400  c_min.SetXYZ(x_min, y_min, z_min);
401  c_max.SetXYZ(x_max, y_max, z_max);
402  SortCoordinates();
403  }
double x_min
Definition: berger.C:15
Coords_t c_max
maximum coordinates (x, y, z)
double x_max
Definition: berger.C:16
Coords_t c_min
minimum coordinates (x, y, z)
void SortCoordinates()
Makes sure each coordinate of the minimum point is smaller than maximum.
void geo::BoxBoundedGeo::SetBoundaries ( Coords_t  lower,
Coords_t  upper 
)
inline

Sets the boundaries in world coordinates as specified.

Parameters
lowerlower coordinates (x, y, z)
upperupper coordinates (x, y, z)

Definition at line 410 of file BoxBoundedGeo.h.

References c_max, c_min, and SortCoordinates().

411  {
412  c_min = lower;
413  c_max = upper;
414  SortCoordinates();
415  }
Coords_t c_max
maximum coordinates (x, y, z)
Coords_t c_min
minimum coordinates (x, y, z)
void SortCoordinates()
Makes sure each coordinate of the minimum point is smaller than maximum.
double geo::BoxBoundedGeo::SizeX ( ) const
inline

Returns the full size in the X dimension.

Definition at line 99 of file BoxBoundedGeo.h.

References MaxX(), and MinX().

Referenced by HalfSizeX().

99 { return MaxX() - MinX(); }
double MinX() const
Returns the world x coordinate of the start of the box.
Definition: BoxBoundedGeo.h:90
double MaxX() const
Returns the world x coordinate of the end of the box.
Definition: BoxBoundedGeo.h:93
double geo::BoxBoundedGeo::SizeY ( ) const
inline

Returns the full size in the Y dimension.

Definition at line 114 of file BoxBoundedGeo.h.

References MaxY(), and MinY().

Referenced by HalfSizeY().

114 { return MaxY() - MinY(); }
double MaxY() const
Returns the world y coordinate of the end of the box.
double MinY() const
Returns the world y coordinate of the start of the box.
double geo::BoxBoundedGeo::SizeZ ( ) const
inline

Returns the full size in the Z dimension.

Definition at line 129 of file BoxBoundedGeo.h.

References MaxZ(), and MinZ().

Referenced by HalfSizeZ().

129 { return MaxZ() - MinZ(); }
double MinZ() const
Returns the world z coordinate of the start of the box.
double MaxZ() const
Returns the world z coordinate of the end of the box.
void geo::BoxBoundedGeo::SortCoordinates ( )
private

Makes sure each coordinate of the minimum point is smaller than maximum.

Definition at line 136 of file BoxBoundedGeo.cxx.

References geo::vect::bindCoord(), c_max, and c_min.

Referenced by BoxBoundedGeo(), and SetBoundaries().

137  {
138 
139  for (auto coordMan : geo::vect::coordManagers<geo::Point_t>()) {
140  auto min = geo::vect::bindCoord(c_min, coordMan);
141  auto max = geo::vect::bindCoord(c_max, coordMan);
142  if (min() > max()) {
143  auto temp = min();
144  min = max();
145  max = temp;
146  }
147  } // for
148 
149  } // BoxBoundedGeo::SortCoordinates()
constexpr auto bindCoord(Vector const &v, CoordReader_t< Vector > helper)
Binds the specified constant vector to the coordinate reader.
Coords_t c_max
maximum coordinates (x, y, z)
Coords_t c_min
minimum coordinates (x, y, z)

Member Data Documentation

Coords_t geo::BoxBoundedGeo::c_max
private

maximum coordinates (x, y, z)

Definition at line 503 of file BoxBoundedGeo.h.

Referenced by BoxBoundedGeo(), ExtendToInclude(), GetIntersections(), Max(), MaxX(), MaxY(), MaxZ(), SetBoundaries(), and SortCoordinates().

Coords_t geo::BoxBoundedGeo::c_min
private

minimum coordinates (x, y, z)

Definition at line 502 of file BoxBoundedGeo.h.

Referenced by ExtendToInclude(), GetIntersections(), Min(), MinX(), MinY(), MinZ(), SetBoundaries(), and SortCoordinates().


The documentation for this class was generated from the following files: