15 #ifndef LARCOREALG_GEOMETRY_GEO_VECTORS_UTILS_H 16 #define LARCOREALG_GEOMETRY_GEO_VECTORS_UTILS_H 23 #include "Math/GenVector/DisplacementVector2D.h" 24 #include "Math/GenVector/DisplacementVector3D.h" 25 #include "Math/GenVector/LorentzVector.h" 26 #include "Math/GenVector/PositionVector2D.h" 27 #include "Math/GenVector/PositionVector3D.h" 34 #include <type_traits> 58 template <
typename Op,
typename... T>
61 template <
typename Op,
typename First,
typename Second,
typename... Others>
63 static auto compute(Op op, First&& a, Second&& b, Others&&... others) -> decltype(
auto)
67 op, std::forward<Second>(b), std::forward<Others>(others)...));
71 template <
typename Op,
typename T>
73 static auto compute(Op, T&& v) -> decltype(
auto) {
return std::forward<T>(v); }
76 template <
typename Op,
typename... T>
82 template <
typename... T>
85 auto and_op = [](
auto&& a,
auto&& b) {
return a && b; };
102 template <
typename Vector>
104 using type =
typename Vector::Scalar;
107 template <
typename Vector>
111 template <
typename Vector>
114 template <
typename Class>
115 static constexpr
bool TestX(decltype(std::declval<Class>().
X())*)
119 template <
typename Class>
124 template <
typename Class>
125 static constexpr
bool TestY(decltype(std::declval<Class>().
Y())*)
129 template <
typename Class>
134 template <
typename Class>
135 static constexpr
bool TestZ(decltype(std::declval<Class>().
Z())*)
139 template <
typename Class>
144 template <
typename Class>
145 static constexpr
bool TestT(decltype(std::declval<Class>().T())*)
149 template <
typename Class>
156 static constexpr
bool X = TestX<Vector>(
nullptr);
157 static constexpr
bool Y = TestY<Vector>(
nullptr);
158 static constexpr
bool Z = TestZ<Vector>(
nullptr);
159 static constexpr
bool T = TestT<Vector>(
nullptr);
162 template <
typename Vector>
167 template <
typename Vector>
172 template <
typename Vector>
177 template <
typename Vector>
183 template <
typename Vector,
typename =
void>
186 template <
typename Vector>
193 template <
typename Vector>
196 template <
typename T>
200 using type =
typename decltype(std::mem_fn(std::declval<T>()))::result_type;
203 template <
typename T>
206 template <
typename T>
209 template <
typename Class,
typename Func>
214 template <
typename T>
217 template <
typename Vector,
typename SetterType =
void>
220 template <
typename Vector>
227 template <
typename Vector,
typename SetterType>
239 "Invalid setter type");
242 template <
typename Vector>
254 template <
typename Vector>
277 template <
typename Getter>
280 using Vector_t = std::remove_reference_t<MemberFuncClass_t<Getter>>;
284 template <
typename Vector,
typename SetterType>
297 template <
typename Vector,
typename SetterType>
334 template <
typename Getter,
typename Setter>
337 using Vector_t = std::remove_reference_t<MemberFuncClass_t<Getter>>;
341 template <
typename CoordHelper,
typename StoredVector>
377 template <
typename CoordHelper,
typename StoredVector>
447 template <
typename T>
454 template <
typename T>
457 if (
std::abs(value) < tol)
return 0.;
619 template <
typename Vector>
623 return details::dimension<Vector>();
625 template <
typename Vector>
628 return dimension<Vector>();
633 template <
typename Vector>
635 constexpr std::array<std::size_t, vect::dimension<Vector>()>
indices();
636 template <
typename Vector>
637 constexpr
auto indices(Vector
const&) -> decltype(indices<Vector>());
641 template <
typename Vector>
665 template <
typename Vector,
typename Coords>
680 template <
typename Vector,
typename Coords>
684 template <
typename Vector>
688 template <
typename Vector>
712 template <
typename Vector>
736 template <
typename Vector>
741 template <
typename Vector>
747 template <
typename Vector>
752 template <
typename Vector>
757 template <
typename Vector>
762 template <
typename Vector>
767 template <
typename Vector>
810 template <
typename Vector>
824 template <
typename Vector>
828 template <
typename Vector>
831 template <
typename Vector>
836 template <
typename Vector>
839 template <
typename Vector>
844 template <
typename Vector>
851 template <
typename Vector>
868 template <
typename Vector>
871 return bindCoord(v, XcoordManager<Vector>);
884 template <
typename Vector>
887 return bindCoord<Vector>(v, YcoordManager<Vector>);
900 template <
typename Vector>
903 return bindCoord<Vector>(v, ZcoordManager<Vector>);
916 template <
typename Vector>
919 return bindCoord<Vector>(v, TcoordManager<Vector>);
933 template <
typename Vector>
934 auto coord(Vector& v,
unsigned int n) noexcept;
936 template <
typename Vector>
941 template <
typename Vector>
946 template <
typename Vector>
955 template <
typename Vector>
967 unsigned int index = std::numeric_limits<unsigned int>::max();
1072 return (v == other.
v) && (index == other.
index);
1077 return (v != other.
v) || (index != other.
index);
1082 return (v == other.
v) && (index <= other.
index);
1087 return (v == other.
v) && (index >= other.
index);
1092 return (v == other.
v) && (index < other.
index);
1097 return (v == other.
v) && (index > other.
index);
1105 template <
typename Vector>
1113 template <
typename Vector>
1120 template <
typename Vector>
1136 template <
typename Dest,
typename Source>
1154 template <
typename Dest,
typename Source>
1155 std::vector<Dest>
convertCollTo(std::vector<Source>
const& coll);
1168 template <
typename Vector,
typename Pred>
1206 template <
typename Vector,
typename Scalar>
1214 template <
typename Vector,
typename Scalar>
1221 template <
typename Vector,
typename Scalar>
1228 template <
typename Vector,
typename Scalar>
1235 template <
typename Vector>
1239 template <
typename Vector>
1246 template <
typename Vector>
1247 Vector
cross(Vector
const& a, Vector
const& b)
1253 template <
typename Vector,
typename OtherVector>
1254 constexpr
auto dot(Vector
const& a, OtherVector
const& b)
1260 template <
typename Vector>
1267 template <
typename Vector>
1275 template <
typename Vector>
1314 template <
unsigned int N = 3U>
1316 static constexpr
unsigned int Dim = N;
1332 template <
typename BeginIter,
typename EndIter>
1343 bool empty()
const {
return fW == 0.0; }
1359 template <
typename Po
int>
1363 return makeWeightedPoint<Point>(1.0 / fW);
1384 template <
typename Po
int>
1387 std::size_t ic = 0U;
1399 template <
typename Po
int>
1402 std::size_t ic = 0U;
1404 fSums[ic++] += weight * c();
1417 template <
typename BeginIter,
typename EndIter>
1420 std::for_each(begin, end, [
this](
auto const& p) { this->add(p); });
1436 template <
typename Point, std::size_t... I>
1439 return {fSums.operator[](I)...};
1442 template <
typename Point, std::size_t... I>
1445 return {(fSums.operator[](I) * w)...};
1449 template <
typename Po
int>
1452 return vect::makeFromCoords<Point>(fSums);
1457 template <
typename Po
int>
1495 template <
typename Po
int,
typename BeginIter,
typename EndIter>
1498 constexpr
auto Dim = vect::dimension<Point>();
1523 template <
typename BeginIter,
typename EndIter>
1526 return middlePointAs<Point_t>(
begin,
end);
1545 template <
typename Po
int>
1548 constexpr
auto Dim = vect::dimension<Point>();
1550 .
template middlePointAs<Point>();
1561 template <
typename Po
int>
1564 return vect::convertTo<Point_t>(p);
1568 template <
typename Vector>
1571 return vect::convertTo<Vector_t>(v);
1576 template <
typename Po
int>
1579 return convertCollTo<Point_t>(coll);
1584 template <
typename Vector>
1587 return convertCollTo<Vector_t>(coll);
1591 template <
typename Coords>
1594 return makeFromCoords<Point_t>(std::forward<Coords>(coords));
1598 template <
typename Coords>
1601 return makeFromCoords<Vector_t>(std::forward<Coords>(coords));
1623 template <
class CoordSystem,
class Tag>
1624 decltype(
auto)
begin(
ROOT::Math::PositionVector2D<CoordSystem, Tag> const& v)
1629 template <
class CoordSystem,
class Tag>
1630 decltype(
auto)
cbegin(
ROOT::Math::PositionVector2D<CoordSystem, Tag> const& v)
1635 template <
class CoordSystem,
class Tag>
1636 decltype(
auto)
end(
ROOT::Math::PositionVector2D<CoordSystem, Tag> const& v)
1641 template <
class CoordSystem,
class Tag>
1642 decltype(
auto)
cend(
ROOT::Math::PositionVector2D<CoordSystem, Tag> const& v)
1647 template <
class CoordSystem,
class Tag>
1648 decltype(
auto)
begin(
ROOT::Math::DisplacementVector2D<CoordSystem, Tag> const& v)
1653 template <
class CoordSystem,
class Tag>
1654 decltype(
auto)
cbegin(
ROOT::Math::DisplacementVector2D<CoordSystem, Tag> const& v)
1659 template <
class CoordSystem,
class Tag>
1660 decltype(
auto)
end(
ROOT::Math::DisplacementVector2D<CoordSystem, Tag> const& v)
1665 template <
class CoordSystem,
class Tag>
1666 decltype(
auto)
cend(
ROOT::Math::DisplacementVector2D<CoordSystem, Tag> const& v)
1674 template <
class CoordSystem,
class Tag>
1675 decltype(
auto)
begin(
ROOT::Math::PositionVector3D<CoordSystem, Tag> const& v)
1680 template <
class CoordSystem,
class Tag>
1681 decltype(
auto)
cbegin(
ROOT::Math::PositionVector3D<CoordSystem, Tag> const& v)
1686 template <
class CoordSystem,
class Tag>
1687 decltype(
auto)
end(
ROOT::Math::PositionVector3D<CoordSystem, Tag> const& v)
1692 template <
class CoordSystem,
class Tag>
1693 decltype(
auto)
cend(
ROOT::Math::PositionVector3D<CoordSystem, Tag> const& v)
1698 template <
class CoordSystem,
class Tag>
1699 decltype(
auto)
begin(
ROOT::Math::DisplacementVector3D<CoordSystem, Tag> const& v)
1704 template <
class CoordSystem,
class Tag>
1705 decltype(
auto)
cbegin(
ROOT::Math::DisplacementVector3D<CoordSystem, Tag> const& v)
1710 template <
class CoordSystem,
class Tag>
1711 decltype(
auto)
end(
ROOT::Math::DisplacementVector3D<CoordSystem, Tag> const& v)
1716 template <
class CoordSystem,
class Tag>
1717 decltype(
auto)
cend(
ROOT::Math::DisplacementVector3D<CoordSystem, Tag> const& v)
1725 template <
class CoordSystem>
1731 template <
class CoordSystem>
1737 template <
class CoordSystem>
1743 template <
class CoordSystem>
1783 template <
typename T>
1786 return static_cast<T&&
>(t);
1789 template <
typename T>
1792 static_assert(!std::is_lvalue_reference<T>(),
1793 "template argument substituting T is an lvalue reference type");
1794 return static_cast<T&&
>(t);
1798 template <
typename Vector,
typename >
1799 struct DimensionImpl :
public std::integral_constant<unsigned int,
1800 HasT<Vector>() ? 4U :
1801 HasZ<Vector>() ? 3U :
1802 HasY<Vector>() ? 2U :
1803 HasX<Vector>() ? 1U :
1806 template <
typename Array>
1808 :
public std::integral_constant<unsigned int, std::extent_v<Array>> {};
1810 template <
typename T, std::
size_t Dim>
1812 :
public std::integral_constant<unsigned int, Dim> {};
1814 template <
typename T>
1816 :
public std::integral_constant<unsigned int, 2> {};
1818 template <
typename T>
1820 :
public std::integral_constant<unsigned int, 3> {};
1824 template <
typename Vector>
1827 template <
typename Vector>
1833 template <
typename Vector>
1836 return makeVectorIndices<Vector>();
1839 template <
typename T, T... Indices>
1844 return std::array<T,
sizeof...(Indices)>{{Indices...}};
1848 template <
typename T, T N>
1851 return makeIndexSeqImpl<T>(std::make_integer_sequence<T, N>{});
1855 template <std::
size_t I,
typename Data>
1861 template <
typename Vector,
typename Coords, std::size_t... Indices>
1864 return {accessElement<Indices>(constexpr_forward<Coords>(coords))...};
1868 template <
typename Vector>
1871 template <
typename Vector,
unsigned int Dim = dimension<Vector>()>
1874 template <
typename Vector>
1876 static auto get(
unsigned int n) noexcept
1878 return (
n == 0) ? XcoordManager<Vector> : NoCoordManager<Vector>;
1882 template <
typename Vector>
1884 static auto get(
unsigned int n) noexcept
1890 template <
typename Vector>
1892 static auto get(
unsigned int n) noexcept
1898 template <
typename Vector>
1900 static auto get(
unsigned int n) noexcept
1907 template <
typename Vector,
unsigned int N>
1909 static constexpr
unsigned int Dim = N;
1914 static_assert(dimension<Vector>() == Dim,
"Inconsistent vector size.");
1917 template <
typename Vector,
unsigned int N>
1920 template <
typename Vector>
1928 return {{XcoordManager<Vector>, YcoordManager<Vector>}};
1932 template <
typename Vector>
1940 return {{XcoordManager<Vector>, YcoordManager<Vector>, ZcoordManager<Vector>}};
1944 template <
typename Vector>
1952 return {{XcoordManager<Vector>,
1953 YcoordManager<Vector>,
1954 ZcoordManager<Vector>,
1955 TcoordManager<Vector>}};
1960 template <
typename Vector,
unsigned int N>
1962 static constexpr
unsigned int Dim = N;
1967 static_assert(dimension<Vector>() == Dim,
"Inconsistent vector size.");
1970 template <
typename Vector,
unsigned int N>
1973 template <
typename Vector>
1985 template <
typename Vector>
1997 template <
typename Vector>
2010 template <
typename Dest,
typename Source>
2012 static_assert(dimension<Source>() == dimension<Dest>(),
2013 "Source and destination vectors must have the same dimension.");
2016 template <
typename Dest,
typename Source,
unsigned int Dim>
2018 static_assert(std::is_arithmetic_v<std::decay_t<decltype(std::declval<Source>()[0])>>);
2019 static Dest
convert(Source
const& v) {
return geo::vect::makeFromCoords<Dest>(v); }
2023 template <
typename Dest,
typename Source,
unsigned int Dim>
2026 template <
typename Dest,
typename Source>
2029 template <
typename Dest,
typename T, std::
size_t Dim>
2033 template <
typename Dest,
typename T, std::
size_t Dim>
2037 template <
typename Dest,
typename T>
2039 static_assert(std::is_arithmetic_v<T>);
2040 static Dest
convert(T* v) {
return geo::vect::makeFromCoords<Dest>(v); }
2044 template <
typename Dest,
typename Source,
unsigned int Dim>
2047 static_assert(
AlwaysFalse<Dest>(),
"This vector dimensionality is not implemented yet.");
2050 template <
typename Dest,
typename Source>
2055 template <
typename Dest,
typename Source>
2060 template <
typename Dest,
typename Source>
2068 template <
typename Dest,
typename Source>
2072 template <
typename Vector>
2074 static constexpr decltype(
auto) convert(Vector const& v) {
return v; }
2078 template <
typename Point, std::size_t... I>
2089 template <
typename Vector>
2090 constexpr std::array<std::size_t, geo::vect::dimension<Vector>()>
geo::vect::indices()
2092 return details::makeIndexSeq<std::size_t, dimension<Vector>()>();
2095 template <
typename Vector>
2098 return indices<Vector>();
2102 template <
typename Vector,
typename Coords>
2106 return makeFromCoordsImpl<Vector>(constexpr_forward<Coords>(coords), makeVectorIndices<Vector>());
2110 template <
typename Vector>
2117 template <
typename Vector>
2120 return vect::bindCoord<Vector>(v, coordManager<Vector>(
n));
2124 template <
typename Vector>
2131 template <
typename Vector,
typename Coords>
2141 template <
typename Vector>
2144 using PlainVector = std::remove_reference_t<Vector>;
2148 template <
typename Vector>
2151 return coordManagers<Vector>();
2154 template <
typename Vector>
2157 using ConstVector = std::add_const_t<std::remove_reference_t<Vector>>;
2161 template <
typename Vector>
2164 return coordReaders<Vector>();
2168 template <
typename Vector>
2174 template <
typename Vector>
2177 using ConstVector = std::add_const_t<std::remove_reference_t<Vector>>;
2182 template <
typename Dest,
typename Source>
2189 template <
typename Dest,
typename Source>
2192 std::vector<Dest> dest;
2193 dest.reserve(coll.size());
2195 coll.begin(), coll.end(), std::back_inserter(dest), geo::vect::convertTo<Dest, Source>);
2200 template <
typename Vector,
typename Pred>
2206 values[i++] = pred(c());
2207 return makeFromCoords<Vector>(
values);
2211 template <
typename Vector>
2219 #endif // LARCOREALG_GEOMETRY_GEO_VECTORS_UTILS_H
void operator()(Vector_t &v, Scalar_t c) const
Setter: assigns a value to the bound coordinate of specified vector.
constexpr auto coordManager(unsigned int n)
Returns an object that can be bound to a vector to manage one of its coordinates. ...
constexpr T && constexpr_forward(std::remove_reference_t< T > &&t)
constexpr auto coordManager(unsigned int n, Vector &v)
Returns an object that can be bound to a vector to manage one of its coordinates. ...
static constexpr bool TestZ(...)
void round01(Vector &v, Scalar tol)
Returns a vector with all components rounded if close to 0, -1 or +1.
static constexpr auto XcoordManager< Vector const >
Object that can be bound to a vector to access its X coordinate.
decltype(auto) cbegin(ROOT::Math::LorentzVector< CoordSystem > const &v)
Constant iterator to vector coordinates.
Coordinate
Enumerate the possible plane projections.
typename BaseTypes_t::Scalar_t Scalar_t
BoundCoordManager(Stored_t &v, CoordHelper_t coordManager)
Constructor: manage the specified coordinate of specified vector.
typename Traits_t::Getter_t Getter_t
void clear()
Resets the status of the object to no accumulated points.
typename CoordHelper_t::Getter_t Getter_t
Point makePoint() const
Converts the internal sums into a Point.
constexpr auto accessElement(Data &&data)
CoordConstIterator(Vector &v, unsigned int index=0)
Constructor: points to index coordinate of vector v.
std::array< Manager_t, Dim > Return_t
Point middlePointAs() const
Returns the middle point, NaN components if no point.
auto Zcoord(Vector &v)
Returns an object to manage the coordinate Z of the vector v.
2D point (x, y) (by default, with double precision)
constexpr auto makeVectorIndices(Vector &&)
static constexpr bool TestX(...)
constexpr auto makeIndexSeq()
static auto compute(Op, T &&v) -> decltype(auto)
constexpr std::array< std::size_t, vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
static constexpr auto XcoordManager
Object that can be bound to a vector to manage its X coordinate.
Point makePointImpl(std::index_sequence< I... >) const
vect::coordinate_t< Vector_t > Coord_t
Type of vector coordinate.
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
std::vector< Dest > convertCollTo(std::vector< Source > const &coll)
Returns a vector of type Dest with the same content as a Src.
static Dest convert(Source const &v)
void mult(Vector_t &v, Scalar_t f) const
Multiplies the coordinate by the specified amount.
std::array< Manager_t, Dim > Return_t
decltype(XcoordManager< Vector >) Manager_t
static constexpr auto YcoordManager< Vector const >
static constexpr auto const YcoordManager
typename BaseTypes_t::Vector_t Vector_t
auto mixedProduct(Vector const &a, Vector const &b, Vector const &c)
GENVECTOR_CONSTEXPR Point_t makePointFromCoords(Coords &&coords)
Creates a geo::Point_t from its coordinates (see makeFromCoords()).
auto coord(Vector &v, unsigned int n) noexcept
Returns an object to manage the coordinate n of a vector.
constexpr auto bindCoordReaders(Vector const &v)
typename Vector::Scalar type
Helper class to compute the middle point in a point set.
bool operator<=(iterator_t const &other) const
constexpr auto indices(Vector const &) -> decltype(indices< Vector >())
Returns a sequence of indices valid for a vector of the specified type.
constexpr auto makeCoordReader(Getter getter)
typename Traits_t::Setter_t Setter_t
std::decay_t< Vector > Vector_t
std::vector< Vector_t > convertCollToVector(std::vector< Vector > const &coll)
constexpr auto makeIndexSeqImpl(std::integer_sequence< T, Indices... >)
typename MemberFuncReturnType< T >::type MemberFuncReturn_t
::fhicl::TupleAs< Point(::geo::Length_t,::geo::Length_t,::geo::Length_t)> Point3D
Atom object for reading a 3D point or vector (centimeters).
double weight() const
Returns the total weight (number of points if all have weight 1).
iterator_t operator-(iterator_t const &other) const
Returns the distance from another iterator.
constexpr auto abs(T v)
Returns the absolute value of the argument.
static constexpr auto TcoordManager
std::remove_cv_t< Coord_t > value_type
BoundCoordManager & operator+=(Scalar_t c)
Increments by the specified amount.
GENVECTOR_CONSTEXPR Vector_t makeVectorFromCoords(Coords &&coords)
Creates a geo::Vector_t from its coordinates (see makeFromCoords()).
BoundCoordManager(Stored_t &v, Getter_t getter, Setter_t setter)
Constructor: manage the specified vector with specified methods.
static constexpr auto ZcoordManager
decltype(Xcoord(std::declval< Vector >())) Manager_t
static Return_t bind(Vector &v)
iterator_t operator-(difference_type d) const
Returns an iterator decremented by d positions (unchecked).
auto coord(Vector &v, Coordinate n) noexcept
typename BaseTypes_t::Getter_t Getter_t
typename BaseTypes_t::Setter_t Setter_t
constexpr auto coordManagers()
Returns an array with all coordinate managers for a type of vector.
void round0(Vector &v, Scalar tol)
Returns a vector with all components rounded if close to 0.
static Return_t bind(Vector &v)
Helper class for read/write of a single vector coordinate.
typename CoordHelper_t::Vector_t Vector_t
bool operator>(iterator_t const &other) const
typename MemberFuncClassType< T >::type MemberFuncClass_t
BoundCoordGetter(Stored_t &v, Getter_t getter)
Constructor: manage the specified vector with specified methods.
std::array< Length_t, Dim > fSums
Sum of each of the point components.
void add(Point const &p)
Accumulates a point.
Point middlePoint(std::initializer_list< Point > points)
Returns the middle of the specified points.
static constexpr auto ZcoordManager< Vector const >
static auto compute(Op op, First &&a, Second &&b, Others &&...others) -> decltype(auto)
unsigned int fillCoords(Coords &dest, Vector const &src)
Fills a coordinate array with the coordinates of a vector.
typename BaseTypes_t::Scalar_t Scalar_t
Point middlePointAs(BeginIter begin, EndIter end)
Returns the middle of the specified points.
void add(Point const &p, double weight)
Accumulates a point.
iterator_t operator+(difference_type d) const
Returns an iterator incremented by d positions (unchecked).
static constexpr bool TestX(decltype(std::declval< Class >().X())*)
typename VectorScalar< Vector >::type VectorScalar_t
typename Traits_t::Vector_t Vector_t
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
iterator_t operator--(int)
Points to previous coordinate (unchecked), returns the previous iterator.
std::array< Manager_t, Dim > Return_t
std::random_access_iterator_tag iterator_category
constexpr auto coordReaders()
Returns an array with all coordinate readers for a type of vector.
BoundCoordManager & operator/=(Scalar_t f)
Divides by the specified amount.
void decr(Vector_t &v, Scalar_t c) const
Decrements the coordinate by the specified amount.
CoordHelper CoordHelper_t
Utilities to manipulate geometry vectors.The utilities include generic vector interface facilities al...
bool isfinite(Vector const &v)
Returns whether all components of the vector are finite.
typename BaseTypes_t::Vector_t Vector_t
auto array(Array const &a)
Returns a manipulator which will print the specified array.
typename Traits_t::Scalar_t Scalar_t
Getter_t fGetter
Member function returning the coordinate value.
constexpr CoordManager_t< Vector > NoCoordManager
void add(BeginIter begin, EndIter end)
Adds a sequence of points.
bool empty() const
Returns whether the total weight is zero (usually means no points).
typename BaseTypes_t::Vector_t Vector_t
void incr(Vector_t &v, Scalar_t c) const
Increments the coordinate by the specified amount.
iterator_t & operator--()
Points to the previous coordinate (unchecked).
Point2D< T > operator+(Point2D< T > const &a, Point2D< T > const &b)
Definitions of geometry vector data types.
auto vector_cend(Vector const &v)
Returns a const-iterator pointing after the last coordinate of v.
constexpr Vector makeFromCoordsImpl(Coords &&coords, std::index_sequence< Indices... >)
constexpr CoordGetter(Getter_t getter)
Constructor: sets getter and setter functions.
typename BaseTypes_t::Scalar_t Scalar_t
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
MiddlePointAccumulatorDim(BeginIter begin, EndIter end)
Constructor: starts with accumulating a sequence of points.
auto extended_and(T...args) -> decltype(auto)
typename CoordHelper_t::Setter_t Setter_t
decltype(auto) begin(ROOT::Math::LorentzVector< CoordSystem > const &v)
typename CoordHelper_t::Scalar_t Scalar_t
bool operator>=(iterator_t const &other) const
Simple class definitions for geometry concepts.
MemberFuncReturn_t< Setter_t > SetterReturn_t
constexpr auto makeCoordManager(Getter getter, Setter setter)
static Return_t bind(Vector &v)
Point makeWeightedPoint(double w) const
3D point (x, y, z) (by default, with double precision)
constexpr int to_int(Coordinate const coord) noexcept
Enumerate the possible plane projections.
void LorentzVector(Stream &&out, TLorentzVector const &v)
Print a TLorentzVector to an output stream.
iterator_t & operator++()
Points to the next coordinate (unchecked).
BoundCoordManager & operator*=(Scalar_t f)
Multiplies by the specified amount.
Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
std::array< Manager_t, Dim > Return_t
auto Ycoord(Vector &v)
Returns an object to manage the coordinate Y of the vector v.
typename decltype(std::mem_fn(std::declval< T >()))::result_type type
static constexpr bool TestY(...)
decltype(details::makeCoordManager(&Vector::X,&Vector::SetX)) CoordManager_t
Type of a coordinate manager for a vector type.
bool isfiniteImpl(Point const &point, std::index_sequence< I... >)
constexpr auto dot(Vector const &a, OtherVector const &b)
Return cross product of two vectors.
Stored_t & vector() const
Vector transformCoords(Vector const &v, Pred &&pred)
Returns a new vector applying a predicate to each component.
constexpr auto coordReaders(Vector &&)
Returns an array with all coordinate readers for a type of vector.
Definition of data types for geometry description.
CoordHelper_t fCoord
Helper to manage a specific coordinate.
Vector_t toVector(Vector const &v)
Convert the specified vector into a geo::Vector_t.
Vector rounded01(Vector const &v, Scalar tol)
Returns a vector with all components rounded if close to 0, -1 or +1.
auto mag2(Vector const &v)
Return norm of the specified vector.
std::array< Manager_t, Dim > Return_t
static Dest convert(T *v)
auto Xcoord(Vector &v)
Returns an object to manage the coordinate X of the vector v.
BoundCoordManager & operator-=(Scalar_t c)
Decrements by the specified amount.
typename BaseTypes_t::Getter_t Getter_t
Point makeWeightedPointImpl(double w, std::index_sequence< I... >) const
BoundCoordGetter(Stored_t &v, CoordHelper_t coordManager)
Constructor: manage the specified coordinate of specified vector.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Scalar_t operator()(Vector_t const &v) const
Returns the value of the bound coordinate.
std::array< Manager_t, Dim > Return_t
auto Tcoord(Vector &v)
Returns an object to manage the coordinate T of the vector v.
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
CoordHelper_t const & manager() const
auto extended_accumulate(Op op, T &&...args)
BoundCoordManager & operator=(Scalar_t c)
Setter: assigns a value to the bound coordinate of specified vector.
static Dest convert(Source const &v)
typename BaseTypes_t::Getter_t Getter_t
LArSoft-specific namespace.
std::make_index_sequence< Dim > IndexSequence_t
static constexpr auto TcoordManager< Vector const >
auto vector_cbegin(Vector const &v)
Returns a const-iterator pointing to the first coordinate of v.
Point_t middlePoint() const
static Dest convert(Source const &v)
std::array< VectorScalar_t< Vector >, dimension< Vector >()> CoordinateArray_t
A STL array suitable to contain all coordinate values of a Vector.
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
decltype(details::makeCoordReader(&Vector::X)) CoordReader_t
Type of a coordinate reader for a vector type.
decltype(auto) end(ROOT::Math::LorentzVector< CoordSystem > const &v)
Scalar_t operator()() const
Returns the value of the bound coordinate.
constexpr auto bindCoordManagers(Vector &v)
constexpr CoordManager(Getter_t getter, Setter_t setter)
Constructor: sets getter and setter functions.
std::array< Manager_t, Dim > Return_t
constexpr auto coordManagers(Vector &&)
Returns an array with all coordinate managers for a type of vector.
std::array< Manager_t, Dim > Return_t
Setter_t fSetter
Member function setting the coordinate value.
reference operator[](difference_type n) const
Access the current coordinate.
bool operator==(iterator_t const &other) const
Stored_t & fVector
The vector to manage the coordinate of.
MiddlePointAccumulatorDim()
Default constructor: starts with no accumulated point.
std::ptrdiff_t difference_type
Helper class for read of a single vector coordinate.
bool operator!=(iterator_t const &other) const
details::VectorScalar_t< Vector > coordinate_t
Type of coordinate of the specified vector type.
#define GENVECTOR_CONSTEXPR
A declaration is made constexpr if GenVector supports it.
constexpr unsigned int dimension(Vector &&)
Returns the dimension of the specified vector type.
VectorScalar_t< Vector > Scalar_t
std::vector< Point_t > convertCollToPoint(std::vector< Point > const &coll)
constexpr Vector makeFromCoords(Coords &&coords)
Creates a Vector object with coordinates from coords.
static constexpr bool TestT(...)
std::make_index_sequence< dimension< Vector >()> VectorIndices_t
Type of sequence of indices up to Vector size.
Vector cross(Vector const &a, Vector const &b)
Return cross product of two vectors.
Vector normalize(Vector const &v)
Returns a vector parallel to v and with norm 1.
Dest convertTo(Source const &v)
Returns a vector of type Dest with the same content as a Src.
void div(Vector_t &v, Scalar_t f) const
Divides the coordinate by the specified amount.
Vector rounded0(Vector const &v, Scalar tol)
Returns a vector with all components rounded if close to 0.
reference operator*() const
Access the current coordinate.
auto bindCoord(Vector &v, CoordManager_t< Vector > helper) -> details::BoundCoordManager< CoordManager_t< Vector >, Vector >
Binds the specified vector to the coordinate manager.
iterator_t & operator+=(difference_type d)
Increments the iterator by d positions (unchecked).
recob::tracking::Vector_t Vector_t
static Dest convert(Source const &v)
Scalar_t(Vector_t::*)() const Getter_t
decltype(auto) cend(ROOT::Math::LorentzVector< CoordSystem > const &v)
iterator_t & operator-=(difference_type d)
Decrements the iterator by d positions (unchecked).
iterator_t operator++(int)
Points to the next coordinate (unchecked), returns the previous iterator.
bool operator<(iterator_t const &other) const
static constexpr bool TestY(decltype(std::declval< Class >().Y())*)
static constexpr bool TestZ(decltype(std::declval< Class >().Z())*)
static constexpr bool TestT(decltype(std::declval< Class >().T())*)