LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
|
Helper class to compute the middle point in a point set. More...
#include "geo_vectors_utils.h"
Public Member Functions | |
MiddlePointAccumulatorDim () | |
Default constructor: starts with no accumulated point. More... | |
template<typename BeginIter , typename EndIter > | |
MiddlePointAccumulatorDim (BeginIter begin, EndIter end) | |
Constructor: starts with accumulating a sequence of points. More... | |
Result query | |
bool | empty () const |
Returns whether the total weight is zero (usually means no points). More... | |
double | weight () const |
Returns the total weight (number of points if all have weight 1). More... | |
template<typename Point > | |
Point | middlePointAs () const |
Returns the middle point, NaN components if no point. More... | |
geo::Point_t | middlePoint () const |
Addition of points | |
template<typename Point > | |
void | add (Point const &p) |
Accumulates a point. More... | |
template<typename Point > | |
void | add (Point const &p, double weight) |
Accumulates a point. More... | |
template<typename BeginIter , typename EndIter > | |
void | add (BeginIter begin, EndIter end) |
Adds a sequence of points. More... | |
void | clear () |
Resets the status of the object to no accumulated points. More... | |
Private Types | |
using | IndexSequence_t = std::make_index_sequence< Dim > |
Private Member Functions | |
template<typename Point , std::size_t... I> | |
Point | makePointImpl (std::index_sequence< I... >) const |
template<typename Point , std::size_t... I> | |
Point | makeWeightedPointImpl (double w, std::index_sequence< I... >) const |
template<typename Point > | |
Point | makePoint () const |
Converts the internal sums into a Point . More... | |
template<typename Point > | |
Point | makeWeightedPoint (double w) const |
Private Attributes | |
std::array< Length_t, Dim > | fSums |
Sum of each of the point components. More... | |
double | fW = 0.0 |
Total weight. More... | |
Static Private Attributes | |
static constexpr unsigned int | Dim = N |
Dimension of the points. More... | |
Helper class to compute the middle point in a point set.
N | _(default: 3 )_ dimension of the points |
This class accumulates cartesian points and returns their middle point when asked.
In the following example, only the points from a list (points
) which have y coordinate larger than 0 are averaged, all with the same weight:
Note the check to make sure that there are points that fulfil the requirement.
Definition at line 1333 of file geo_vectors_utils.h.
|
private |
Definition at line 1452 of file geo_vectors_utils.h.
|
inline |
Default constructor: starts with no accumulated point.
Definition at line 1340 of file geo_vectors_utils.h.
|
inline |
Constructor: starts with accumulating a sequence of points.
BeginIter | type of iterator to a point type compatible with add() |
EndIter | type of end iterator |
begin | iterator to the first point to be added |
end | iterator after the last point to be added |
Definition at line 1351 of file geo_vectors_utils.h.
|
inline |
Accumulates a point.
p | point to be included |
The point is added with weight 1.
Definition at line 1403 of file geo_vectors_utils.h.
References geo::vect::bindCoordManagers().
Referenced by trkf::TrajectoryMCSFitter::linearRegression().
|
inline |
Accumulates a point.
p | point to be included |
weight | the relative weight of this point |
Definition at line 1418 of file geo_vectors_utils.h.
References geo::vect::bindCoordManagers(), and weight.
|
inline |
Adds a sequence of points.
BeginIter | type of iterator to a point type compatible with add() |
EndIter | type of end iterator |
begin | iterator to the first point to be added |
end | iterator after the last point to be added |
Each point is added with weight 1.0.
Definition at line 1436 of file geo_vectors_utils.h.
|
inline |
Resets the status of the object to no accumulated points.
Definition at line 1442 of file geo_vectors_utils.h.
|
inline |
Returns whether the total weight is zero (usually means no points).
Definition at line 1361 of file geo_vectors_utils.h.
|
inlineprivate |
Converts the internal sums into a Point
.
Definition at line 1468 of file geo_vectors_utils.h.
|
inlineprivate |
Definition at line 1455 of file geo_vectors_utils.h.
|
inlineprivate |
Converts the internal sums into a Point
with components scaled by w
.
Definition at line 1476 of file geo_vectors_utils.h.
References w.
|
inlineprivate |
Definition at line 1461 of file geo_vectors_utils.h.
|
inline |
Returns the middle point as a geo::Point_t
, NaN components if no point.
Definition at line 1386 of file geo_vectors_utils.h.
Referenced by trkf::TrajectoryMCSFitter::linearRegression().
|
inline |
Returns the middle point, NaN components if no point.
Point | type of the output point |
The type of return point must be specified as template argument, e.g.
The Point
type is required to have a constructor with the three cartesian components as arguments.
Definition at line 1378 of file geo_vectors_utils.h.
|
inline |
Returns the total weight (number of points if all have weight 1).
Definition at line 1364 of file geo_vectors_utils.h.
|
staticprivate |
Dimension of the points.
Definition at line 1334 of file geo_vectors_utils.h.
|
private |
Sum of each of the point components.
Definition at line 1335 of file geo_vectors_utils.h.
|
private |
Total weight.
Definition at line 1336 of file geo_vectors_utils.h.