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;
155 <ROOT::Math::Cartesian2D<double>, WidthDepthReferenceTag>;
174 TGeoNode
const& node,
190 double ThetaZ()
const;
194 {
return std::atan2(fSinPhiZ, fCosPhiZ); }
220 template <
typename Vector>
221 Vector WidthDir()
const {
return geo::vect::convertTo<Vector>(fDecompFrame.MainDir()); }
235 template <
typename Vector>
236 Vector DepthDir()
const {
return geo::vect::convertTo<Vector>(fDecompFrame.SecondaryDir()); }
246 double Width()
const {
return fFrameSize.Width(); }
254 double Depth()
const {
return fFrameSize.Depth(); }
269 unsigned int Nwires()
const {
return fWire.size(); }
279 bool HasWire(
unsigned int iwire)
const {
return iwire < Nwires(); }
280 bool HasElement(
unsigned int iwire)
const {
return HasWire(iwire); }
293 {
return HasWire(wireid.
Wire); }
295 {
return HasWire(wireid); }
316 {
return Wire(wireid); }
325 {
return HasWire(iwire)? &(fWire[iwire]):
nullptr; }
422 bool WireIDincreasesWithZ()
const;
441 template <
typename Vector>
444 {
return GetNormalDirection<DefaultVector_t>(); }
456 template <
typename Vector>
458 {
return geo::vect::convertTo<Vector>(fDecompWire.SecondaryDir()); }
460 {
return GetIncreasingWireDirection<DefaultVector_t>(); }
478 template <
typename Po
int>
480 {
return geo::vect::convertTo<Point>(fCenter); }
497 template <
typename Po
int>
499 {
return geo::vect::convertTo<Point>(toWorldCoords(
LocalPoint_t{ 0.0, 0.0, 0.0 })); }
501 {
return GetBoxCenter<DefaultPoint_t>(); }
512 template <
typename Vector>
515 {
return GetWireDirection<DefaultVector_t>(); }
571 geo::WireGeo const& NearestWire(geo::Point_t
const& pos)
const;
622 {
return fDecompWire.PointNormalComponent(point); }
644 { position -= distance * GetNormalDirection<geo::Vector_t>(); }
646 { position -= distance * GetNormalDirection(); }
660 { DriftPoint(position, DistanceFromPlane(position)); }
662 { DriftPoint(position, DistanceFromPlane(position)); }
687 double InterWireProjectedDistance
688 (WireCoordProjection_t
const& projDir)
const;
739 template <
typename Vector>
740 std::enable_if_t<geo::vect::dimension<Vector>() == 3U,
double>
742 {
return InterWireProjectedDistance(VectorProjection(dir)); }
785 template <
typename Stream>
802 static constexpr
unsigned int MaxVerbosity = 6;
833 double PlaneCoordinateFrom
839 double PlaneCoordinateFrom
862 {
return fDecompWire.PointSecondaryComponent(point); }
881 template <
typename Po
int>
883 {
return PlaneCoordinate(point) / WirePitch(); }
902 {
return fDecompWire.DecomposePoint(point); }
916 template <
typename Po
int>
918 {
return geo::vect::convertTo<Point>(fDecompWire.ReferencePoint()); }
920 {
return ProjectionReferencePoint<DefaultPoint_t>(); }
940 WireCoordProjection_t
Projection(geo::Point_t
const& point)
const 941 {
return fDecompWire.ProjectPointOnPlane(point); }
943 {
return Projection(point); }
962 {
return fDecompWire.ProjectVectorOnPlane(v); }
964 {
return Projection(v); }
981 template <
typename Vector>
983 {
return geo::vect::convertTo<Vector>(fDecompWire.ComposeVector(decomp)); }
985 {
return ComposeVector<DefaultVector_t>(decomp); }
1003 template <
typename Vector>
1005 (
double distance, WireCoordProjection_t
const& proj)
const 1006 {
return geo::vect::convertTo<Vector>(fDecompWire.ComposeVector(distance, proj)); }
1008 (
double distance, WireCoordProjection_t
const& proj)
const 1009 {
return ComposeVector<DefaultVector_t>(
distance, proj); }
1023 template <
typename Po
int>
1025 {
return geo::vect::convertTo<Point>(fDecompWire.ComposePoint(decomp)); }
1027 {
return ComposePoint<DefaultPoint_t>(decomp); }
1052 template <
typename Po
int>
1054 (
double distance, WireCoordProjection_t
const& proj)
const 1055 {
return geo::vect::convertTo<Point>(fDecompWire.ComposePoint(distance, proj)); }
1057 (
double distance, WireCoordProjection_t
const& proj)
const 1058 {
return ComposePoint<DefaultPoint_t>(
distance, proj); }
1089 {
return fDecompFrame.DecomposePoint(point); }
1106 WidthDepthProjection_t PointWidthDepthProjection
1107 (geo::Point_t
const& point)
const 1108 {
return fDecompFrame.ProjectPointOnPlane(point); }
1109 WidthDepthProjection_t PointWidthDepthProjection
1110 (TVector3
const& point)
const 1126 WidthDepthProjection_t VectorWidthDepthProjection
1128 {
return fDecompFrame.ProjectVectorOnPlane(v); }
1129 WidthDepthProjection_t VectorWidthDepthProjection
1130 (TVector3
const& v)
const 1146 bool isProjectionOnPlane(geo::Point_t
const& point)
const;
1176 WidthDepthProjection_t DeltaFromPlane
1177 (WidthDepthProjection_t
const& proj,
double wMargin,
double dMargin)
1193 WidthDepthProjection_t DeltaFromPlane
1194 (WidthDepthProjection_t
const& proj,
double margin = 0.0)
const 1195 {
return DeltaFromPlane(proj, margin, margin); }
1224 WidthDepthProjection_t DeltaFromActivePlane
1225 (WidthDepthProjection_t
const& proj,
double wMargin,
double dMargin)
1241 WidthDepthProjection_t DeltaFromActivePlane
1242 (WidthDepthProjection_t
const& proj,
double margin = 0.0)
const 1243 {
return DeltaFromActivePlane(proj, margin, margin); }
1261 WidthDepthProjection_t MoveProjectionToPlane
1262 (WidthDepthProjection_t
const& proj)
const;
1276 geo::Point_t MovePointOverPlane(geo::Point_t
const& point)
const;
1277 TVector3 MovePointOverPlane(TVector3
const& point)
const;
1293 template <
typename Po
int>
1295 {
return geo::vect::convertTo<Point>(fDecompFrame.ComposePoint(decomp)); }
1297 {
return ComposePoint<DefaultPoint_t>(decomp); }
1320 template <
typename Po
int>
1322 (
double distance, WidthDepthProjection_t
const& proj)
const 1323 {
return geo::vect::convertTo<Point>(fDecompFrame.ComposePoint(distance, proj)); }
1325 (
double distance, WidthDepthProjection_t
const& proj)
const 1326 {
return ComposePoint<DefaultPoint_t>(
distance, proj); }
1344 { fTrans.LocalToWorld(plane, world); }
1348 {
return fTrans.LocalToWorld<TVector3>(local); }
1352 {
return fTrans.toWorldCoords(local); }
1356 { fTrans.LocalToWorldVect(plane, world); }
1360 {
return fTrans.LocalToWorldVect<TVector3>(local); }
1364 {
return fTrans.toWorldCoords(local); }
1368 { fTrans.WorldToLocal(world, plane); }
1372 {
return fTrans.WorldToLocal<TVector3>(world); }
1376 {
return fTrans.toLocalCoords(world); }
1380 { fTrans.WorldToLocalVect(world, plane); }
1384 {
return fTrans.WorldToLocalVect<TVector3>(world); }
1388 {
return fTrans.toLocalCoords(world); }
1406 void UpdateAfterSorting
1419 void DetectGeometryDirections();
1428 void UpdateWidthDepthDir();
1431 void UpdateIncreasingWireDir();
1434 void UpdateWireDir();
1437 void UpdateOrientation();
1440 void UpdateWirePitch();
1443 void UpdateWirePlaneCenter();
1452 void UpdateWirePitchSlow();
1455 void UpdateDecompWireOrigin();
1458 void UpdateActiveArea();
1474 double Width()
const {
return 2.0 * HalfWidth(); }
1475 double Depth()
const {
return 2.0 * HalfDepth(); }
1507 template <
typename T>
1522 return {
ID(), boundedValue<geo::WireID::WireID_t>(wireNo, 0, Nwires()) };
1532 return ClosestWireID(wireid.
Wire);
1538 template <
typename Stream>
1542 unsigned int verbosity
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
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...
geo::Vector_t toWorldCoords(LocalVector_t const &local) const
Transform direction vector from local to world.
Utilities to extend the interface of geometry vectors.
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().
geo::Point_t fCenter
Center of the plane, lying on the wire plane.
double fWirePitch
Pitch of wires in this plane.
WireCoordProjection_t PointProjection(TVector3 const &point) const
std::vector< geo::WireGeo > WireCollection_t
DefaultPoint_t ComposePoint(WireDecomposedVector_t const &decomp) const
AdcChannelData::View View
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
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
::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.
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.
DefaultPoint_t ComposePoint(WDDecomposedVector_t const &decomp) const
ElementIteratorBox IterateWires() const
double Width(Resonance_t res)
resonance width (GeV)
WireID_t Wire
Index of the wire within its plane.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Rect const & ActiveArea() const
Returns an area covered by the wires in the plane.
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.
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?
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.
ElementIteratorBox IterateElements() const
Allows range-for iteration on all wires in this plane.
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.
WireDecomposedVector_t DecomposePoint(geo::Point_t const &point) const
Decomposes a 3D point in two components.
Classes to project and compose a vector on a plane.
WidthDepthDecomposer_t::DecomposedVector_t WDDecomposedVector_t
WidthDepthDecomposer_t fDecompFrame
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.
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.
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
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.
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()
const WireGeo & FirstWire() const
Return the first wire in the plane.
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
bool HasElement(unsigned int iwire) const
static int max(int a, int b)
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.
static T boundedValue(T v, T min, T max)
Returns min if v < min, max if v > max, v otherwise.
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.
RTree::BoundingBox BoundingBox
Vector DepthDir() const
Return the direction of plane depth.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Tag for plane frame base vectors.
DefaultVector_t GetWireDirection() const
DefaultPoint_t GetBoxCenter() const
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 ...
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
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.
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.
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.
Class computing the active area of the plane.
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.
LArSoft geometry interface.
DefaultVector_t DepthDir() const
void DriftPoint(TVector3 &position) const
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 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.
Vector GetWireDirection() const
Returns the direction of the wires.
DefaultVector_t ComposeVector(WireDecomposedVector_t const &decomp) const