8 #ifndef LARCOREALG_GEOMETRY_PLANEGEO_H
9 #define LARCOREALG_GEOMETRY_PLANEGEO_H
24 #include "Math/GenVector/Cartesian2D.h"
25 #include "Math/GenVector/PositionVector2D.h"
26 #include "Math/GenVector/DisplacementVector2D.h"
29 #include "TGeoMatrix.h"
43 struct ActiveAreaCalculator;
174 TGeoNode
const& node,
220 template <
typename Vector>
235 template <
typename Vector>
316 {
return Wire(wireid); }
441 template <
typename Vector>
444 {
return GetNormalDirection<DefaultVector_t>(); }
456 template <
typename Vector>
460 {
return GetIncreasingWireDirection<DefaultVector_t>(); }
478 template <
typename Po
int>
480 {
return geo::vect::convertTo<Point>(
fCenter); }
497 template <
typename Po
int>
501 {
return GetBoxCenter<DefaultPoint_t>(); }
512 template <
typename Vector>
515 {
return GetWireDirection<DefaultVector_t>(); }
644 { position -= distance * GetNormalDirection<geo::Vector_t>(); }
739 template <
typename Vector>
740 std::enable_if_t<geo::vect::dimension<Vector>() == 3U,
double>
785 template <
typename Stream>
787 (
Stream&& out, std::string indent =
"",
unsigned int verbosity = 1)
const;
798 (std::string indent =
"",
unsigned int verbosity = 1)
const;
881 template <
typename Po
int>
916 template <
typename Po
int>
920 {
return ProjectionReferencePoint<DefaultPoint_t>(); }
981 template <
typename Vector>
985 {
return ComposeVector<DefaultVector_t>(decomp); }
1003 template <
typename Vector>
1009 {
return ComposeVector<DefaultVector_t>(
distance, proj); }
1023 template <
typename Po
int>
1027 {
return ComposePoint<DefaultPoint_t>(decomp); }
1052 template <
typename Po
int>
1058 {
return ComposePoint<DefaultPoint_t>(
distance, proj); }
1110 (TVector3
const& point)
const
1130 (TVector3
const& v)
const
1293 template <
typename Po
int>
1297 {
return ComposePoint<DefaultPoint_t>(decomp); }
1320 template <
typename Po
int>
1326 {
return ComposePoint<DefaultPoint_t>(
distance, proj); }
1507 template <
typename T>
1509 {
return std::min(max, std::max(min, v)); }
1522 return { ID(), boundedValue<geo::WireID::WireID_t>(wireNo, 0, Nwires()) };
1538 template <
typename Stream>
1541 std::string indent ,
1542 unsigned int verbosity
1546 out <<
"plane " << std::string(ID());
1548 if (verbosity-- <= 0)
return;
1552 <<
" at " << GetCenter<geo::Vector_t>() <<
" cm"
1553 <<
", theta: " << ThetaZ() <<
" rad";
1555 if (verbosity-- <= 0)
return;
1558 unsigned int const nWires = Nwires();
1560 out <<
"\n" << indent
1561 <<
"normal to wire: " << PhiZ() <<
" rad"
1562 <<
", with orientation " << OrientationName(Orientation())
1563 <<
", has " << nWires <<
" wires measuring " << ViewName(View())
1564 <<
" with a wire pitch of " << WirePitch() <<
" cm"
1567 if (verbosity-- <= 0)
return;
1570 auto const& normal = GetNormalDirection<geo::Vector_t>();
1571 auto const& incrZdir = GetIncreasingWireDirection<geo::Vector_t>();
1572 auto const& wireNormalDir = fDecompWire.NormalDir();
1573 out <<
"\n" << indent
1574 <<
"normal to plane: " << normal
1575 <<
", direction of increasing wire number: " << incrZdir
1576 <<
" [wire frame normal: " << wireNormalDir <<
"]"
1577 <<
" (" << (WireIDincreasesWithZ()?
"increases":
"decreases") <<
" with z)";
1579 if (verbosity-- <= 0)
return;
1583 auto const& wireDir = GetWireDirection<geo::Vector_t>();
1584 auto const& widthDir = WidthDir<geo::Vector_t>();
1585 auto const& depthDir = DepthDir<geo::Vector_t>();
1586 auto const& frameNormalDir = fDecompFrame.NormalDir();
1588 out <<
"\n" << indent
1589 <<
"wire direction: " << wireDir
1590 <<
"; width " << Width() <<
" cm in direction: " << widthDir
1591 <<
", depth " << Depth() <<
" cm in direction: " << depthDir
1592 <<
" [normal: " << frameNormalDir <<
"]"
1595 if (verbosity-- <= 0)
return;
1599 out <<
"\n" << indent <<
"wires cover width "
1600 << ActiveArea().width.lower <<
" to " << ActiveArea().width.upper
1602 << ActiveArea().depth.lower <<
" to " << ActiveArea().depth.upper
1604 if (verbosity-- <= 0)
return;
1609 out <<
"\n" << indent
1610 <<
"bounding box: " << box.Min() <<
" -- " << box.Max();
1621 #endif // LARCOREALG_GEOMETRY_PLANEGEO_H
Point_t ComposePoint(DecomposedVector_t const &decomp) const
Returns the 3D point from composition of projection and distance.
static std::string OrientationName(geo::Orient_t orientation)
Returns the name of the specified orientation.
geo::WirePtr WirePtr(unsigned int iwire) const
Returns the wire number iwire from this plane.
unsigned int NElements() const
WireGeo const & Wire(WireID const &wireid) const
Returns the wire in wireid from this plane.
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
geo::Vector_t toWorldCoords(LocalVector_t const &local) const
Transform direction vector from local to world.
auto VectorSecondaryComponent(Vector_t const &v) const
Returns the secondary component of a vector.
WireDecomposedVector_t DecomposePoint(TVector3 const &point) const
void SetView(geo::View_t view)
Set the signal view (for TPCGeo).
DefaultVector_t GetNormalDirection() const
WireCollection_t const & ElementIteratorBox
Type returned by IterateElements().
WidthDepthProjection_t VectorWidthDepthProjection(geo::Vector_t const &v) const
Returns the projection of the specified vector on the plane.
geo::Point_t fCenter
Center of the plane, lying on the wire plane.
static std::string ViewName(geo::View_t view)
Returns the name of the specified view.
auto PointNormalComponent(Point_t const &point) const
Returns the secondary component of a point.
std::string PlaneInfo(std::string indent="", unsigned int verbosity=1) const
Returns a string with plane information.
void UpdateIncreasingWireDir()
Updates the cached direction to increasing wires.
double fWirePitch
Pitch of wires in this plane.
WireCoordProjection_t PointProjection(TVector3 const &point) const
std::vector< geo::WireGeo > WireCollection_t
void UpdateWirePitch()
Updates the stored wire pitch.
void UpdateWidthDepthDir()
Updates the cached depth and width direction.
DefaultPoint_t ComposePoint(WireDecomposedVector_t const &decomp) const
WireGeo const & Wire(unsigned int iwire) const
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
DefaultVector_t WidthDir() const
double InterWireDistance(TVector3 const &dir) const
enum geo::_plane_orient Orient_t
double DistanceFromPlane(TVector3 const &point) const
void UpdateOrientation()
Updates plane orientation.
WireCoordProjection_t VectorProjection(TVector3 const &v) const
geo::PlaneID fID
ID of this plane.
The data type to uniquely identify a Plane.
Volume delimited by two points.
Point ProjectionReferencePoint() const
Returns the reference point used by PointProjection().
void DriftPoint(TVector3 &position, double distance) const
Vector_t ComposeVector(DecomposedVector_t const &decomp) const
Returns the 3D vector from composition of projection and distance.
::geo::Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
Point GetBoxCenter() const
Returns the centre of the box representing the plane.
bool isProjectionOnPlane(geo::Point_t const &point) const
Returns if the projection of specified point is within the plane.
Point ComposePoint(WireDecomposedVector_t const &decomp) const
Returns the 3D point from composition of projection and distance.
::geo::Vector_t toVector(Vector const &v)
Convert the specified vector into a geo::Vector_t.
WidthDepthProjection_t PointWidthDepthProjection(geo::Point_t const &point) const
Returns the projection of the specified point on the plane.
geo::WireGeo const & NearestWire(geo::Point_t const &pos) const
Returns the wire closest to the specified position.
DefaultPoint_t ComposePoint(WDDecomposedVector_t const &decomp) const
ElementIteratorBox IterateWires() const
WireID_t Wire
Index of the wire within its plane.
Rect const & ActiveArea() const
Returns an area covered by the wires in the plane.
bool shouldFlipWire(geo::WireGeo const &wire) const
Whether the specified wire should have start and end swapped.
Vector GetNormalDirection() const
Returns the direction normal to the plane.
bool HasElement(geo::WireID const &wireid) const
WireCoordProjection_t Projection(geo::Point_t const &point) const
Returns the projection of the specified point on the plane.
WidthDepthProjection_t MoveProjectionToPlane(WidthDepthProjection_t const &proj) const
Returns the projection, moved onto the plane if necessary.
Vector GetIncreasingWireDirection() const
Returns the direction of increasing wires.
LocalPoint_t toLocalCoords(geo::Point_t const &world) const
Transform point from world frame to local plane frame.
WDDecomposedVector_t DecomposePointWidthDepth(TVector3 const &point) const
void WorldToLocal(const double *world, double *plane) const
Transform point from world frame to local plane frame.
View_t fView
Does this plane measure U, V, or W?
geo::BoxBoundedGeo BoundingBox() const
void DetectGeometryDirections()
Sets the geometry directions.
double InterWireProjectedDistance(WireCoordProjection_t const &projDir) const
Returns the distance between wires along the specified direction.
void DriftPoint(geo::Point_t &position, double distance) const
Shifts the position of an electron drifted by a distance.
Rect fActiveArea
Area covered by wires in frame base.
double ThetaZ() const
Angle of the wires from positive z axis; .
Projection_t ProjectPointOnPlane(Point_t const &point) const
Returns the projection of the specified point on the plane.
double PlaneCoordinateFrom(geo::Point_t const &point, geo::WireGeo const &refWire) const
Returns the coordinate of point on the plane respect to a wire.
ElementIteratorBox IterateElements() const
Allows range-for iteration on all wires in this plane.
void UpdatePlaneNormal(geo::BoxBoundedGeo const &TPCbox)
Updates the cached normal to plane versor; needs the TPC box coordinates.
Interface to algorithm class for sorting geo::XXXGeo objects.
DefaultVector_t GetIncreasingWireDirection() const
TGeoVolume const * fVolume
Plane volume description.
bool isProjectionOnPlane(TVector3 const &point) const
View_t View() const
Which coordinate does this plane measure.
ROOT::Math::DisplacementVector2D< ROOT::Math::Cartesian2D< double >, WidthDepthReferenceTag > WidthDepthProjection_t
Offer iterators automatically dereferencing their values.
lar::util::simple_geo::Volume Coverage() const
Returns a volume including all the wires in the plane.
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
WireDecomposedVector_t DecomposePoint(geo::Point_t const &point) const
Decomposes a 3D point in two components.
geo::LocalTransformationGeo< ROOT::Math::Transform3D, LocalPoint_t, LocalVector_t > LocalTransformation_t
Classes to project and compose a vector on a plane.
geo::WireID NearestWireID(geo::Point_t const &pos) const
Returns the ID of wire closest to the specified position.
WidthDepthDecomposer_t::DecomposedVector_t WDDecomposedVector_t
WidthDepthDecomposer_t fDecompFrame
void UpdatePhiZ()
Updates the stored .
geo::WirePtr GetElementPtr(WireID const &wireid) const
double PhiZ() const
Angle from positive z axis of the wire coordinate axis, in radians.
const WireGeo & MiddleWire() const
Return the middle wire in the plane.
RTree::BoundingBox BoundingBox
geo::Point_t toWorldCoords(LocalPoint_t const &local) const
Transform point from local plane frame to world frame.
ROOT::Math::DisplacementVector2D< ROOT::Math::Cartesian2D< double >, WireCoordinateReferenceTag > WireCoordProjection_t
Type for projections in the wire base representation.
Tag for vectors in the "local" GDML coordinate frame of the plane.
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
WireCollection_t fWire
List of wires in this plane.
WireGeo const & GetElement(WireID const &wireid) const
WireCoordProjection_t Projection(geo::Vector_t const &v) const
Returns the projection of the specified vector on the plane.
double Depth() const
Return the depth of the plane.
DefaultPoint_t ProjectionReferencePoint() const
geo::Point_t MovePointOverPlane(geo::Point_t const &point) const
Returns the point, moved so that its projection is over the plane.
Point GetCenter() const
Returns the centre of the wire plane in world coordinates [cm].
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
double Width() const
Return the width of the plane.
double InterWireDistance(geo::Vector_t const &dir) const
Returns the distance between wires along the specified direction.
Utilities to extend the interface of geometry vectors.
DecomposedVector_t DecomposePoint(Point_t const &point) const
Decomposes a 3D point in two components.
void DriftPoint(geo::Point_t &position) const
Shifts the position along drift direction to fall on the plane.
WireCoordProjection_t PointProjection(geo::Point_t const &point) const
geo::WirePtr WirePtr(WireID const &wireid) const
Returns the wire in wireid from this plane.
constexpr PlaneID const & asPlaneID() const
Conversion to PlaneID (for convenience of notation).
double CosPhiZ() const
Cosine of PhiZ()
void UpdateWirePitchSlow()
Updates the stored wire pitch with a slower, more robust algorithm.
const WireGeo & FirstWire() const
Return the first wire in the plane.
bool HasElement(unsigned int iwire) const
void UpdateAfterSorting(geo::PlaneID planeid, geo::BoxBoundedGeo const &TPCbox)
Performs all needed updates after the TPC has sorted the planes.
double SinPhiZ() const
Sine of PhiZ()
ROOT::Math::DisplacementVector2D< ROOT::Math::Cartesian2D< double >, WidthDepthReferenceTag > WidthDepthDisplacement_t
Type for vector projections in the plane frame base representation.
std::vector< TGeoNode const * > GeoNodePath_t
void markInvalid()
Sets the ID as invalid.
LocalTransformation_t fTrans
Plane to world transform.
Definition of data types for geometry description.
Point_t ReferencePoint() const
Returns the reference point for the plane coordinate, as a 3D point.
static T boundedValue(T v, T min, T max)
Returns min if v < min, max if v > max, v otherwise.
void UpdateView()
Updates the stored view.
Provides a base class aware of world box coordinates.
typename PlaneDecomposer_t::DecomposedVector_t DecomposedVector_t
Type representing a decomposition on the plane.
Orient_t Orientation() const
What is the orientation of the plane.
std::enable_if_t< geo::vect::dimension< Vector >)==3U, double > InterWireProjectedDistance(Vector const &dir) const
Returns the distance between wires along the specified direction.
Encapsulate the geometry of a wire.
Vector DepthDir() const
Return the direction of plane depth.
Tag for plane frame base vectors.
DefaultVector_t GetWireDirection() const
DefaultPoint_t GetBoxCenter() const
Vector_t const & SecondaryDir() const
Returns the plane secondary axis direction.
WidthDepthProjection_t DeltaFromPlane(WidthDepthProjection_t const &proj, double wMargin, double dMargin) const
Returns a projection vector that, added to the argument, gives a projection inside (or at the border ...
Vector_t const & MainDir() const
Returns the plane main axis direction.
WidthDepthProjection_t DeltaFromActivePlane(WidthDepthProjection_t const &proj, double wMargin, double dMargin) const
Returns a projection vector that, added to the argument, gives a projection inside (or at the border ...
WireCoordProjection_t VectorProjection(geo::Vector_t const &v) const
A base class aware of world box coordinatesAn object describing a simple shape can inherit from this ...
geo::Vector_t GetNormalAxis() const
Returns a direction normal to the plane (pointing is not defined).
auto PointSecondaryComponent(Point_t const &point) const
Returns the secondary component of a point.
Projection_t ProjectVectorOnPlane(Vector_t const &v) const
Returns the projection of the specified vector on the plane.
bool HasWire(unsigned int iwire) const
Returns whether a wire with index iwire is present in this plane.
void PrintPlaneInfo(Stream &&out, std::string indent="", unsigned int verbosity=1) const
Prints information about this plane.
double DistanceFromPlane(geo::Point_t const &point) const
Returns the distance of the specified point from the wire plane.
geo::PlaneID const & ID() const
Returns the identifier of this plane.
DefaultPoint_t GetCenter() const
unsigned int Nwires() const
Number of wires in this plane.
TVector3 WorldToLocal(TVector3 const &world) const
Transform point from world frame to local plane frame.
geo::WireID ClosestWireID(geo::WireID::WireID_t wireNo) const
Returns the closest valid wire ID to the specified wire.
bool WireIDincreasesWithZ() const
Returns whether the higher z wires have higher wire ID.
Some simple functions to represent geometry entities.
WireDecomposer_t::DecomposedVector_t WireDecomposedVector_t
Type describing a 3D point or vector decomposed on a plane on wire base.
double fCosPhiZ
Cosine of .
TVector3 LocalToWorldVect(const TVector3 &local) const
Transform direction vector from local to world.
Vector WidthDir() const
Return the direction of plane width.
WDDecomposedVector_t DecomposePointWidthDepth(geo::Point_t const &point) const
Decomposes a 3D point in two components.
GenPoint3DBase_t< double, C > Point3DBase_t
Type of 3D point with representation in double precision.
unsigned int WireID_t
Type for the ID number.
void UpdateWirePlaneCenter()
Updates the stored wire plane center.
GenVector3DBase_t< double, C > Vector3DBase_t
WireDecomposer_t fDecompWire
void LocalToWorldVect(const double *plane, double *world) const
Transform direction vector from local to world.
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.
double WireCoordinate(Point const &point) const
Returns the coordinate of the point on the plane, in wire units.
void UpdateDecompWireOrigin()
Updates the position of the wire coordinate decomposition.
Class computing the active area of the plane.
void UpdateActiveArea()
Updates the internally used active area.
bool HasWire(geo::WireID const &wireid) const
Returns whether the wire in wireid is present in this plane.
geo::Vector3DBase_t< PlaneGeoCoordinatesTag > LocalVector_t
Type of displacement vectors in the local GDML wire plane frame.
Point ComposePoint(WDDecomposedVector_t const &decomp) const
Returns the 3D vector from composition of projection and distance.
const WireGeo & LastWire() const
Return the last wire in the plane.
TVector3 WorldToLocalVect(TVector3 const &world) const
Transform direction vector from world to local.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
static constexpr unsigned int MaxVerbosity
Maximum value for print verbosity.
DefaultVector_t DepthDir() const
void DriftPoint(TVector3 &position) const
void SortWires(geo::GeoObjectSorter const &sorter)
Apply sorting to WireGeo objects.
Orient_t fOrientation
Is the plane vertical or horizontal?
Vector ComposeVector(WireDecomposedVector_t const &decomp) const
Returns the 3D vector from composition of projection and distance.
double PlaneCoordinate(geo::Point_t const &point) const
Returns the coordinate of the point on the plane.
TVector3 LocalToWorld(const TVector3 &local) const
Transform point from local plane frame to world frame.
void UpdateWireDir()
Updates the cached direction to wire.
void LocalToWorld(const double *plane, double *world) const
Transform point from local plane frame to world frame.
double PlaneCoordinate(TVector3 const &point) const
geo::Point3DBase_t< PlaneGeoCoordinatesTag > LocalPoint_t
Type of points in the local GDML wire plane frame.
ROOT::Math::Transform3D TransformationMatrix
Type of transformation matrix used in geometry.
LocalVector_t toLocalCoords(geo::Vector_t const &world) const
Transform direction vector from world to local.
double WirePitch() const
Return the wire pitch (in centimeters). It is assumed constant.
void WorldToLocalVect(const double *world, double *plane) const
Transform direction vector from world to local.
geo::WireID NearestWireID(TVector3 const &pos) const
Tag for wire base vectors.
PlaneGeo(TGeoNode const &node, geo::TransformationMatrix &&trans, WireCollection_t &&wires)
Construct a representation of a single plane of the detector.
Vector GetWireDirection() const
Returns the direction of the wires.
DefaultVector_t ComposeVector(WireDecomposedVector_t const &decomp) const