17 #ifndef LARCOREOBJ_SIMPLETYPESANDCONSTANTS_GEO_VECTORS_UTILS_H 18 #define LARCOREOBJ_SIMPLETYPESANDCONSTANTS_GEO_VECTORS_UTILS_H 25 #include "Math/GenVector/DisplacementVector2D.h" 26 #include "Math/GenVector/DisplacementVector3D.h" 27 #include "Math/GenVector/LorentzVector.h" 28 #include "Math/GenVector/PositionVector2D.h" 29 #include "Math/GenVector/PositionVector3D.h" 36 #include <type_traits> 60 template <
typename Op,
typename... T>
63 template <
typename Op,
typename First,
typename Second,
typename... Others>
65 static auto compute(Op op, First&& a, Second&& b, Others&&... others) -> decltype(
auto)
69 op, std::forward<Second>(b), std::forward<Others>(others)...));
73 template <
typename Op,
typename T>
75 static auto compute(Op, T&& v) -> decltype(
auto) {
return std::forward<T>(v); }
78 template <
typename Op,
typename... T>
84 template <
typename... T>
87 auto and_op = [](
auto&& a,
auto&& b) {
return a && b; };
104 template <
typename Vector>
106 using type =
typename Vector::Scalar;
109 template <
typename Vector>
113 template <
typename Vector>
116 template <
typename Class>
117 static constexpr
bool TestX(decltype(std::declval<Class>().
X())*)
121 template <
typename Class>
126 template <
typename Class>
127 static constexpr
bool TestY(decltype(std::declval<Class>().
Y())*)
131 template <
typename Class>
136 template <
typename Class>
137 static constexpr
bool TestZ(decltype(std::declval<Class>().
Z())*)
141 template <
typename Class>
146 template <
typename Class>
147 static constexpr
bool TestT(decltype(std::declval<Class>().T())*)
151 template <
typename Class>
158 static constexpr
bool X = TestX<Vector>(
nullptr);
159 static constexpr
bool Y = TestY<Vector>(
nullptr);
160 static constexpr
bool Z = TestZ<Vector>(
nullptr);
161 static constexpr
bool T = TestT<Vector>(
nullptr);
164 template <
typename Vector>
169 template <
typename Vector>
174 template <
typename Vector>
179 template <
typename Vector>
185 template <
typename Vector,
typename =
void>
188 template <
typename Vector>
195 template <
typename Vector>
198 template <
typename T>
202 using type =
typename decltype(std::mem_fn(std::declval<T>()))::result_type;
205 template <
typename T>
208 template <
typename T>
211 template <
typename Class,
typename Func>
216 template <
typename T>
219 template <
typename Vector,
typename SetterType =
void>
222 template <
typename Vector>
229 template <
typename Vector,
typename SetterType>
241 "Invalid setter type");
244 template <
typename Vector>
256 template <
typename Vector>
279 template <
typename Getter>
282 using Vector_t = std::remove_reference_t<MemberFuncClass_t<Getter>>;
286 template <
typename Vector,
typename SetterType>
299 template <
typename Vector,
typename SetterType>
336 template <
typename Getter,
typename Setter>
339 using Vector_t = std::remove_reference_t<MemberFuncClass_t<Getter>>;
343 template <
typename CoordHelper,
typename StoredVector>
379 template <
typename CoordHelper,
typename StoredVector>
449 template <
typename T>
456 template <
typename T>
459 if (
std::abs(value) < tol)
return 0.;
621 template <
typename Vector>
625 return details::dimension<Vector>();
627 template <
typename Vector>
630 return dimension<Vector>();
635 template <
typename Vector>
637 constexpr std::array<std::size_t, geo::vect::dimension<Vector>()>
indices();
638 template <
typename Vector>
639 constexpr
auto indices(Vector
const&) -> decltype(indices<Vector>());
643 template <
typename Vector>
667 template <
typename Vector,
typename Coords>
682 template <
typename Vector,
typename Coords>
686 template <
typename Vector>
690 template <
typename Vector>
714 template <
typename Vector>
738 template <
typename Vector>
743 template <
typename Vector>
749 template <
typename Vector>
754 template <
typename Vector>
759 template <
typename Vector>
764 template <
typename Vector>
769 template <
typename Vector>
812 template <
typename Vector>
826 template <
typename Vector>
830 template <
typename Vector>
833 template <
typename Vector>
838 template <
typename Vector>
841 template <
typename Vector>
846 template <
typename Vector>
853 template <
typename Vector>
870 template <
typename Vector>
873 return bindCoord(v, XcoordManager<Vector>);
886 template <
typename Vector>
889 return bindCoord<Vector>(v, YcoordManager<Vector>);
902 template <
typename Vector>
905 return bindCoord<Vector>(v, ZcoordManager<Vector>);
918 template <
typename Vector>
921 return bindCoord<Vector>(v, TcoordManager<Vector>);
935 template <
typename Vector>
936 auto coord(Vector& v,
unsigned int n) noexcept;
940 template <
typename Vector>
945 template <
typename Vector>
954 template <
typename Vector>
966 unsigned int index = std::numeric_limits<unsigned int>::max();
1071 return (v == other.
v) && (index == other.
index);
1076 return (v != other.
v) || (index != other.
index);
1081 return (v == other.
v) && (index <= other.
index);
1086 return (v == other.
v) && (index >= other.
index);
1091 return (v == other.
v) && (index < other.
index);
1096 return (v == other.
v) && (index > other.
index);
1104 template <
typename Vector>
1112 template <
typename Vector>
1119 template <
typename Vector>
1138 template <
typename Vector>
1154 template <
typename Dest,
typename Source>
1172 template <
typename Dest,
typename Source>
1173 std::vector<Dest>
convertCollTo(std::vector<Source>
const& coll);
1186 template <
typename Vector,
typename Pred>
1224 template <
typename Vector,
typename Scalar>
1232 template <
typename Vector,
typename Scalar>
1239 template <
typename Vector,
typename Scalar>
1246 template <
typename Vector,
typename Scalar>
1253 template <
typename Vector>
1257 template <
typename Vector>
1264 template <
typename Vector>
1265 Vector
cross(Vector
const& a, Vector
const& b)
1271 template <
typename Vector,
typename OtherVector>
1272 constexpr
auto dot(Vector
const& a, OtherVector
const& b)
1278 template <
typename Vector>
1285 template <
typename Vector>
1293 template <
typename Vector>
1332 template <
unsigned int N = 3U>
1334 static constexpr
unsigned int Dim = N;
1350 template <
typename BeginIter,
typename EndIter>
1361 bool empty()
const {
return fW == 0.0; }
1377 template <
typename Po
int>
1381 return makeWeightedPoint<Point>(1.0 / fW);
1402 template <
typename Po
int>
1405 std::size_t ic = 0U;
1417 template <
typename Po
int>
1420 std::size_t ic = 0U;
1422 fSums[ic++] += weight * c();
1435 template <
typename BeginIter,
typename EndIter>
1438 std::for_each(begin, end, [
this](
auto const& p) { this->add(p); });
1454 template <
typename Point, std::size_t... I>
1457 return {fSums.operator[](I)...};
1460 template <
typename Point, std::size_t... I>
1463 return {(fSums.operator[](I) * w)...};
1467 template <
typename Po
int>
1470 return geo::vect::makeFromCoords<Point>(fSums);
1475 template <
typename Po
int>
1513 template <
typename Po
int,
typename BeginIter,
typename EndIter>
1516 constexpr
auto Dim = geo::vect::dimension<Point>();
1541 template <
typename BeginIter,
typename EndIter>
1544 return middlePointAs<geo::Point_t>(
begin,
end);
1563 template <
typename Po
int>
1566 constexpr
auto Dim = geo::vect::dimension<Point>();
1568 .
template middlePointAs<Point>();
1583 template <
typename Po
int>
1586 return geo::vect::convertTo<::geo::Point_t>(p);
1590 template <
typename Vector>
1593 return geo::vect::convertTo<::geo::Vector_t>(v);
1598 template <
typename Po
int>
1601 return convertCollTo<geo::Point_t>(coll);
1606 template <
typename Vector>
1609 return convertCollTo<geo::Vector_t>(coll);
1613 template <
typename Coords>
1616 return makeFromCoords<::geo::Point_t>(std::forward<Coords>(coords));
1620 template <
typename Coords>
1623 return makeFromCoords<::geo::Vector_t>(std::forward<Coords>(coords));
1645 template <
class CoordSystem,
class Tag>
1646 decltype(
auto)
begin(
ROOT::Math::PositionVector2D<CoordSystem, Tag> const& v)
1651 template <
class CoordSystem,
class Tag>
1652 decltype(
auto)
cbegin(
ROOT::Math::PositionVector2D<CoordSystem, Tag> const& v)
1657 template <
class CoordSystem,
class Tag>
1658 decltype(
auto)
end(
ROOT::Math::PositionVector2D<CoordSystem, Tag> const& v)
1663 template <
class CoordSystem,
class Tag>
1664 decltype(
auto)
cend(
ROOT::Math::PositionVector2D<CoordSystem, Tag> const& v)
1669 template <
class CoordSystem,
class Tag>
1670 decltype(
auto)
begin(
ROOT::Math::DisplacementVector2D<CoordSystem, Tag> const& v)
1675 template <
class CoordSystem,
class Tag>
1676 decltype(
auto)
cbegin(
ROOT::Math::DisplacementVector2D<CoordSystem, Tag> const& v)
1681 template <
class CoordSystem,
class Tag>
1682 decltype(
auto)
end(
ROOT::Math::DisplacementVector2D<CoordSystem, Tag> const& v)
1687 template <
class CoordSystem,
class Tag>
1688 decltype(
auto)
cend(
ROOT::Math::DisplacementVector2D<CoordSystem, Tag> const& v)
1696 template <
class CoordSystem,
class Tag>
1697 decltype(
auto)
begin(
ROOT::Math::PositionVector3D<CoordSystem, Tag> const& v)
1702 template <
class CoordSystem,
class Tag>
1703 decltype(
auto)
cbegin(
ROOT::Math::PositionVector3D<CoordSystem, Tag> const& v)
1708 template <
class CoordSystem,
class Tag>
1709 decltype(
auto)
end(
ROOT::Math::PositionVector3D<CoordSystem, Tag> const& v)
1714 template <
class CoordSystem,
class Tag>
1715 decltype(
auto)
cend(
ROOT::Math::PositionVector3D<CoordSystem, Tag> const& v)
1720 template <
class CoordSystem,
class Tag>
1721 decltype(
auto)
begin(
ROOT::Math::DisplacementVector3D<CoordSystem, Tag> const& v)
1726 template <
class CoordSystem,
class Tag>
1727 decltype(
auto)
cbegin(
ROOT::Math::DisplacementVector3D<CoordSystem, Tag> const& v)
1732 template <
class CoordSystem,
class Tag>
1733 decltype(
auto)
end(
ROOT::Math::DisplacementVector3D<CoordSystem, Tag> const& v)
1738 template <
class CoordSystem,
class Tag>
1739 decltype(
auto)
cend(
ROOT::Math::DisplacementVector3D<CoordSystem, Tag> const& v)
1747 template <
class CoordSystem>
1753 template <
class CoordSystem>
1759 template <
class CoordSystem>
1765 template <
class CoordSystem>
1805 template <
typename T>
1808 return static_cast<T&&
>(t);
1811 template <
typename T>
1814 static_assert(!std::is_lvalue_reference<T>(),
1815 "template argument substituting T is an lvalue reference type");
1816 return static_cast<T&&
>(t);
1820 template <
typename Vector,
typename >
1821 struct DimensionImpl :
public std::integral_constant<unsigned int,
1822 HasT<Vector>() ? 4U :
1823 HasZ<Vector>() ? 3U :
1824 HasY<Vector>() ? 2U :
1825 HasX<Vector>() ? 1U :
1828 template <
typename Array>
1830 :
public std::integral_constant<unsigned int, std::extent_v<Array>> {};
1832 template <
typename T, std::
size_t Dim>
1834 :
public std::integral_constant<unsigned int, Dim> {};
1836 template <
typename T>
1838 :
public std::integral_constant<unsigned int, 2> {};
1840 template <
typename T>
1842 :
public std::integral_constant<unsigned int, 3> {};
1846 template <
typename Vector>
1849 template <
typename Vector>
1855 template <
typename Vector>
1858 return makeVectorIndices<Vector>();
1861 template <
typename T, T... Indices>
1866 return std::array<T,
sizeof...(Indices)>{{Indices...}};
1870 template <
typename T, T N>
1873 return makeIndexSeqImpl<T>(std::make_integer_sequence<T, N>{});
1877 template <std::
size_t I,
typename Data>
1883 template <
typename Vector,
typename Coords, std::size_t... Indices>
1886 return {accessElement<Indices>(constexpr_forward<Coords>(coords))...};
1890 template <
typename Vector>
1893 template <
typename Vector,
unsigned int Dim = dimension<Vector>()>
1896 template <
typename Vector>
1898 static auto get(
unsigned int n) noexcept
1900 return (
n == 0) ? XcoordManager<Vector> : NoCoordManager<Vector>;
1904 template <
typename Vector>
1906 static auto get(
unsigned int n) noexcept
1912 template <
typename Vector>
1914 static auto get(
unsigned int n) noexcept
1920 template <
typename Vector>
1922 static auto get(
unsigned int n) noexcept
1930 template <
typename Vector,
unsigned int N>
1932 static constexpr
unsigned int Dim = N;
1937 static_assert(dimension<Vector>() == Dim,
"Inconsistent vector size.");
1940 template <
typename Vector,
unsigned int N>
1943 template <
typename Vector>
1951 return {{XcoordManager<Vector>, YcoordManager<Vector>}};
1955 template <
typename Vector>
1963 return {{XcoordManager<Vector>, YcoordManager<Vector>, ZcoordManager<Vector>}};
1967 template <
typename Vector>
1975 return {{XcoordManager<Vector>,
1976 YcoordManager<Vector>,
1977 ZcoordManager<Vector>,
1978 TcoordManager<Vector>}};
1983 template <
typename Vector,
unsigned int N>
1985 static constexpr
unsigned int Dim = N;
1990 static_assert(dimension<Vector>() == Dim,
"Inconsistent vector size.");
1993 template <
typename Vector,
unsigned int N>
1996 template <
typename Vector>
2008 template <
typename Vector>
2020 template <
typename Vector>
2033 template <
typename Dest,
typename Source>
2035 static_assert(dimension<Source>() == dimension<Dest>(),
2036 "Source and destination vectors must have the same dimension.");
2039 template <
typename Dest,
typename Source,
unsigned int Dim>
2041 static_assert(std::is_arithmetic_v<std::decay_t<decltype(std::declval<Source>()[0])>>);
2042 static Dest
convert(Source
const& v) {
return geo::vect::makeFromCoords<Dest>(v); }
2046 template <
typename Dest,
typename Source,
unsigned int Dim>
2049 template <
typename Dest,
typename Source>
2052 template <
typename Dest,
typename T, std::
size_t Dim>
2056 template <
typename Dest,
typename T, std::
size_t Dim>
2060 template <
typename Dest,
typename T>
2062 static_assert(std::is_arithmetic_v<T>);
2063 static Dest
convert(T* v) {
return geo::vect::makeFromCoords<Dest>(v); }
2067 template <
typename Dest,
typename Source,
unsigned int Dim>
2070 static_assert(
AlwaysFalse<Dest>(),
"This vector dimensionality is not implemented yet.");
2073 template <
typename Dest,
typename Source>
2078 template <
typename Dest,
typename Source>
2083 template <
typename Dest,
typename Source>
2091 template <
typename Dest,
typename Source>
2095 template <
typename Vector>
2097 static constexpr decltype(
auto) convert(Vector const& v) {
return v; }
2101 template <
typename Point, std::size_t... I>
2112 template <
typename Vector>
2115 return details::makeIndexSeq<std::size_t, dimension<Vector>()>();
2118 template <
typename Vector>
2121 return indices<Vector>();
2125 template <
typename Vector,
typename Coords>
2129 return makeFromCoordsImpl<Vector>(constexpr_forward<Coords>(coords), makeVectorIndices<Vector>());
2133 template <
typename Vector>
2140 template <
typename Vector>
2143 return vect::bindCoord<Vector>(v, coordManager<Vector>(
n));
2147 template <
typename Vector,
typename Coords>
2157 template <
typename Vector>
2160 using PlainVector = std::remove_reference_t<Vector>;
2164 template <
typename Vector>
2167 return coordManagers<Vector>();
2170 template <
typename Vector>
2173 using ConstVector = std::add_const_t<std::remove_reference_t<Vector>>;
2177 template <
typename Vector>
2180 return coordReaders<Vector>();
2184 template <
typename Vector>
2190 template <
typename Vector>
2193 using ConstVector = std::add_const_t<std::remove_reference_t<Vector>>;
2198 template <
typename Dest,
typename Source>
2205 template <
typename Dest,
typename Source>
2209 std::vector<Dest> dest;
2210 dest.reserve(coll.size());
2212 coll.begin(), coll.end(), std::back_inserter(dest), geo::vect::convertTo<Dest, Source>);
2218 template <
typename Vector,
typename Pred>
2224 values[i++] = pred(c());
2225 return makeFromCoords<Vector>(
values);
2229 template <
typename Vector>
2237 #endif // LARCOREOBJ_SIMPLETYPESANDCONSTANTS_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.
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)
An object with a begin and end iterator.
static constexpr auto XcoordManager
Object that can be bound to a vector to manage its X coordinate.
Point makePointImpl(std::index_sequence< I... >) const
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)
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
geo::vect::coordinate_t< Vector_t > Coord_t
Type of vector coordinate.
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
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).
::geo::Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
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.
auto iterateCoords(Vector const &v)
Returns an object for ranged-for iteration on coordinates.
::geo::Vector_t toVector(Vector const &v)
Convert the specified vector into a geo::Vector_t.
static constexpr auto TcoordManager
std::remove_cv_t< Coord_t > value_type
BoundCoordManager & operator+=(Scalar_t c)
Increments by the specified amount.
constexpr auto bindCoord(Vector const &v, CoordReader_t< Vector > helper)
Binds the specified constant vector to the coordinate reader.
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
enum geo::coordinates Coord_t
Enumerate the possible plane projections.
static Return_t bind(Vector &v)
iterator_t operator-(difference_type d) const
Returns an iterator decremented by d positions (unchecked).
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.
constexpr unsigned int dimension()
Returns the dimension of the specified vector type.
Point middlePoint(std::initializer_list< Point > points)
Returns the middle of the specified points.
static constexpr auto ZcoordManager< Vector const >
recob::tracking::Point_t Point_t
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.
std::vector< geo::Point_t > convertCollToPoint(std::vector< Point > const &coll)
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
constexpr std::array< std::size_t, geo::vect::dimension< Vector >)> indices()
Returns a sequence of indices valid for a vector of the specified type.
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)
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.
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.
CoordHelper_t fCoord
Helper to manage a specific coordinate.
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.
geo::Point_t middlePoint() const
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.
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.
std::vector< geo::Vector_t > convertCollToVector(std::vector< Vector > const &coll)
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
span(IterB &&b, IterE &&e, Adaptor &&adaptor) -> span< decltype(adaptor(std::forward< IterB >(b))), decltype(adaptor(std::forward< IterE >(e))) >
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.
constexpr unsigned int dimension(Vector &&)
Returns the dimension of the specified vector type.
VectorScalar_t< Vector > Scalar_t
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).
GENVECTOR_CONSTEXPR::geo::Point_t makePointFromCoords(Coords &&coords)
Creates a geo::Point_t from its coordinates (see makeFromCoords()).
Namespace collecting geometry-related classes utilities.
GENVECTOR_CONSTEXPR::geo::Vector_t makeVectorFromCoords(Coords &&coords)
Creates a geo::Vector_t from its coordinates (see makeFromCoords()).
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())*)