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>
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_t > | GetIntersections (geo::Point_t const &TrajectoryStart, geo::Vector_t const &TrajectoryDirect) const |
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... | |
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.
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.
|
default |
Default constructor: sets an empty volume.
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.
|
inline |
Constructor: sets the boundaries in world coordinates as specified.
x_min | lower x coordinate |
x_max | upper x coordinate |
y_min | lower y coordinate |
y_max | upper y coordinate |
z_min | lower z coordinate |
z_max | upper z coordinate |
SetBoundaries()
Note that is assumed that each minimum is larger than its maximum, and no check is performed.
Definition at line 62 of file BoxBoundedGeo.h.
Constructor: sets the boundaries in world coordinates as specified.
lower | lower coordinates (x, y, z) |
upper | upper coordinates (x, y, z) |
SetBoundaries()
Note that is assumed that each minimum is larger than its maximum, and no check is performed.
Definition at line 79 of file BoxBoundedGeo.h.
|
inline |
Returns the center point of the box.
Definition at line 139 of file BoxBoundedGeo.h.
|
inline |
Returns the world x coordinate of the center of the box.
Definition at line 94 of file BoxBoundedGeo.h.
|
inline |
Returns the world y coordinate of the center of the box.
Definition at line 109 of file BoxBoundedGeo.h.
|
inline |
Returns the world z coordinate of the center of the box.
Definition at line 124 of file BoxBoundedGeo.h.
|
inline |
Returns whether this volume contains the specified point.
point | the point [cm] |
wiggle | expansion factor for the range |
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 205 of file BoxBoundedGeo.h.
bool geo::BoxBoundedGeo::ContainsPosition | ( | TVector3 const & | point, |
double | wiggle = 1.0 |
||
) | const |
Definition at line 26 of file BoxBoundedGeo.cxx.
bool geo::BoxBoundedGeo::ContainsPosition | ( | double const * | point, |
double | wiggle = 1.0 |
||
) | const |
Definition at line 31 of file BoxBoundedGeo.cxx.
|
inline |
Returns whether this TPC contains the specified world x coordinate.
x | the absolute ("world") coordinate x |
wiggle | expansion factor for the range (see 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 159 of file BoxBoundedGeo.h.
|
inline |
Returns whether this TPC contains the specified world y coordinate.
y | the absolute ("world") coordinate y |
wiggle | expansion factor for the range (see ContainsPosition()) |
Definition at line 169 of file BoxBoundedGeo.h.
|
inline |
Returns if TPC contains the specified world y and z coordinates.
y | the absolute ("world") coordinate y |
z | the absolute ("world") coordinate z |
wiggle | expansion factor for the range (see ContainsPosition()) |
Definition at line 190 of file BoxBoundedGeo.h.
|
inline |
Returns whether this TPC contains the specified world z coordinate.
z | the absolute ("world") coordinate z |
wiggle | expansion factor for the range (see ContainsPosition()) |
Definition at line 179 of file BoxBoundedGeo.h.
|
inlinestatic |
Returns whether the specified coordinate is in a range.
c | the coordinate |
min | lower boundary of the range |
max | upper boundary of the range |
wiggle | expansion factor for the 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 355 of file BoxBoundedGeo.h.
|
inlinestatic |
Returns whether the specified coordinate is in a range.
c | the coordinate |
range | pointer to [ lower boundary, upper boundary ] of the range |
wiggle | expansion factor for the 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 373 of file BoxBoundedGeo.h.
Extends the current box to also include the specified point.
x | x coordinate of the point to include |
y | y coordinate of the point to include |
z | z coordinate of the point to include |
Definition at line 414 of file BoxBoundedGeo.h.
|
inline |
Extends the current box to also include the specified point.
point | coordinates of the point to include |
Definition at line 421 of file BoxBoundedGeo.h.
|
inline |
Extends the current box to also include the specified one.
box | the box to include |
It is assumed that the box has its boundaries properly sorted.
Definition at line 433 of file BoxBoundedGeo.h.
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.
TrajectoryStart | position of the trajectory source |
TrajectoryDirect | direction 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 126 of file BoxBoundedGeo.cxx.
std::vector< geo::Point_t > geo::BoxBoundedGeo::GetIntersections | ( | geo::Point_t const & | TrajectoryStart, |
geo::Vector_t const & | TrajectoryDirect | ||
) | const |
Definition at line 35 of file BoxBoundedGeo.cxx.
|
inline |
Returns the size from the center to the border on X dimension.
Definition at line 100 of file BoxBoundedGeo.h.
|
inline |
Returns the size from the center to the border on Y dimension.
Definition at line 115 of file BoxBoundedGeo.h.
|
inline |
Returns the size from the center to the border on Z dimension.
Definition at line 130 of file BoxBoundedGeo.h.
|
inline |
Returns whether TPC fiducial volume contains world x coordinate.
x | the absolute ("world") coordinate x |
neg_margin | how far within the TPC the fiducial region starts |
pos_margin | how far before the TPC the fiducial region ends |
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 241 of file BoxBoundedGeo.h.
|
inline |
Returns whether TPC fiducial volume contains world x coordinate.
Margins are symmetric.
Definition at line 251 of file BoxBoundedGeo.h.
|
inline |
Returns whether TPC fiducial volume contains world y coordinate.
y | the absolute ("world") coordinate y |
neg_margin | how far within the TPC the fiducial region starts |
pos_margin | how far before the TPC the fiducial region ends |
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 272 of file BoxBoundedGeo.h.
|
inline |
Returns whether TPC fiducial volume contains world y coordinate.
Margins are symmetric.
Definition at line 282 of file BoxBoundedGeo.h.
|
inline |
Returns whether TPC fiducial volume contains world z coordinate.
z | the absolute ("world") coordinate y |
neg_margin | how far within the TPC the fiducial region starts |
pos_margin | how far before the TPC the fiducial region ends |
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.
|
inline |
Returns whether TPC fiducial volume contains world z coordinate.
Margins are symmetric.
Definition at line 313 of file BoxBoundedGeo.h.
|
inline |
Returns the corner point with the largest coordinates.
Definition at line 136 of file BoxBoundedGeo.h.
|
inline |
Returns the world x coordinate of the end of the box.
Definition at line 91 of file BoxBoundedGeo.h.
|
inline |
Returns the world y coordinate of the end of the box.
Definition at line 106 of file BoxBoundedGeo.h.
|
inline |
Returns the world z coordinate of the end of the box.
Definition at line 121 of file BoxBoundedGeo.h.
|
inline |
Returns the corner point with the smallest coordinates.
Definition at line 133 of file BoxBoundedGeo.h.
|
inline |
Returns the world x coordinate of the start of the box.
Definition at line 88 of file BoxBoundedGeo.h.
|
inline |
Returns the world y coordinate of the start of the box.
Definition at line 103 of file BoxBoundedGeo.h.
|
inline |
Returns the world z coordinate of the start of the box.
Definition at line 118 of file BoxBoundedGeo.h.
|
inline |
Returns if this and other
box overlap.
Definition at line 336 of file BoxBoundedGeo.h.
|
inline |
Returns if the x coordinates covered by this and other
box overlap.
Definition at line 324 of file BoxBoundedGeo.h.
|
inline |
Returns if the y coordinates covered by this and other
box overlap.
Definition at line 328 of file BoxBoundedGeo.h.
|
inline |
Returns if the z coordinates covered by this and other
box overlap.
Definition at line 332 of file BoxBoundedGeo.h.
Sets var to value if value is larger than the current var value.
Definition at line 468 of file BoxBoundedGeo.h.
|
inlinestatic |
Sets each coordinate of var to the one in value if the latter is larger.
Definition at line 480 of file BoxBoundedGeo.h.
Sets var to value if value is smaller than the current var value.
Definition at line 464 of file BoxBoundedGeo.h.
|
inlinestatic |
Sets each coordinate of var to the one in value if the latter is smaller.
Definition at line 472 of file BoxBoundedGeo.h.
|
inline |
Sets the boundaries in world coordinates as specified.
x_min | lower x coordinate |
x_max | upper x coordinate |
y_min | lower y coordinate |
y_max | upper y coordinate |
z_min | lower z coordinate |
z_max | upper z coordinate |
Definition at line 389 of file BoxBoundedGeo.h.
Sets the boundaries in world coordinates as specified.
lower | lower coordinates (x, y, z) |
upper | upper coordinates (x, y, z) |
Definition at line 405 of file BoxBoundedGeo.h.
|
inline |
Returns the full size in the X dimension.
Definition at line 97 of file BoxBoundedGeo.h.
|
inline |
Returns the full size in the Y dimension.
Definition at line 112 of file BoxBoundedGeo.h.
|
inline |
Returns the full size in the Z dimension.
Definition at line 127 of file BoxBoundedGeo.h.
|
private |
Makes sure each coordinate of the minimum point is smaller than maximum.
Definition at line 135 of file BoxBoundedGeo.cxx.
|
private |
maximum coordinates (x, y, z)
Definition at line 491 of file BoxBoundedGeo.h.
|
private |
minimum coordinates (x, y, z)
Definition at line 490 of file BoxBoundedGeo.h.