yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis 2.0.0
YODA::ScatterND< N > Class Template Reference

A generic data type which is just a collection of n-dim data points with errors. More...

#include <Scatter.h>

Inheritance diagram for YODA::ScatterND< N >:
YODA::AnalysisObject YODA::Scatter

Public Types

using NdVal = Utils::ndarray< double, N >
 
using NdValPair = Utils::ndarray< std::pair< double, double >, N >
 
using Point = PointND< N >
 
using Points = Utils::sortedvector< Point >
 
using Ptr = std::shared_ptr< ScatterND >
 
- Public Types inherited from YODA::AnalysisObject
typedef std::map< std::string, std::string > Annotations
 Collection type for annotations, as a string-string map.
 

Public Member Functions

size_t dim () const noexcept
 Dimension of this data object.
 
Constructors
 ScatterND (const std::string &path="", const std::string &title="")
 Empty constructor.
 
 ScatterND (const Points &points, const std::string &path="", const std::string &title="")
 Constructor from a set of points.
 
 ScatterND (Points &&points, const std::string &path="", const std::string &title="")
 Constructor from a set of rvalue points.
 
template<typename ValRange = std::initializer_list<ValList>, typename = std::enable_if_t<isIterable<ValRange, containedType<ValRange>>>>
 ScatterND (ValRange &&positions, const std::string &path="", const std::string &title="")
 Constructor from a vector of position values with no errors.
 
template<typename ValRange = std::initializer_list<ValList>, typename = std::enable_if_t<isIterable<ValRange, containedType<ValRange>>>>
 ScatterND (ValRange &&positions, ValRange &&errors, const std::string &path="", const std::string &title="")
 Constructor from vectors of values for positions and a single set of symmetric errors.
 
template<typename ValRange = std::initializer_list<ValList>, typename PairRange = std::initializer_list<PairList>, typename = enableIfNestedArrayWithPair<ValRange,PairRange>>
 ScatterND (ValRange &&positions, PairRange &&errors, const std::string &path="", const std::string &title="")
 Constructor from vectors of values for positions and a single set of symmetric errors.
 
 ScatterND (const ScatterND< N > &s, const std::string &path="")
 Copy constructor with optional new path.
 
 ScatterND (ScatterND< N > &&s, const std::string &path="")
 Move constructor with optional new path.
 
ScatterND< N > & operator= (const ScatterND< N > &s)
 Assignment operator.
 
ScatterND< N > & operator= (ScatterND< N > &&s)
 Move operator.
 
ScatterND< N > clone () const
 Make a copy on the stack.
 
ScatterND< N > * newclone () const
 Make a copy on the heap, via 'new'.
 
Modifiers
void reset ()
 Clear all points.
 
void scale (const NdVal &scales)
 Scaling.
 
void scale (const std::vector< double > &scales)
 
void scale (const size_t i, double factor)
 
Point accessors
size_t numPoints () const
 Number of points in the scatter.
 
Pointspoints ()
 Get the collection of points.
 
const Pointspoints () const
 Get the collection of points (const version)
 
PointND< N > & point (size_t index)
 Get a reference to the point with index index.
 
const PointND< N > & point (size_t index) const
 Get the point with index index (const version)
 
MPI (de-)serialisation
size_t lengthContent (bool fixed_length=false) const noexcept
 Length of serialized content vector for MPI reduce operations.
 
std::vector< double > serializeContent (bool fixed_length=false) const noexcept
 Content serialisation for MPI reduce operations.
 
void deserializeContent (const std::vector< double > &data)
 Content deserialisation for MPI reduce operations.
 
Combining sets of scatter points
ScatterND< N > & combineWith (const ScatterND< N > &other)
 
ScatterND< N > & combineWith (ScatterND< N > &&other)
 
ScatterND< N > & combineWith (const std::vector< ScatterND< N > > &others)
 
ScatterND< N > & combineWith (std::vector< ScatterND< N > > &&others)
 
Coordinate accessors
ValVec vals (const size_t i) const
 Get the coordinate vector along axis i.
 
ValVec mins (const size_t i) const
 Get the lowest value vector along axis i.
 
ValVec maxs (const size_t i) const
 Get the positive error vector along axis i.
 
double min (const size_t i) const
 Get the smallest central value along axis i.
 
double max (const size_t i) const
 Get the largest central value along axis i.
 
PairVec errs (const size_t i) const
 Get the error pairs along axis i.
 
ValVec errsAvg (const size_t i) const
 Get the average error along axis i.
 
ValVec xVals () const
 Axis-specific alias.
 
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 2)>>
ValVec yVals () const
 Axis-specific alias.
 
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 3)>>
ValVec zVals () const
 Axis-specific alias.
 
ValVec xMins () const
 Axis-specific alias.
 
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 2)>>
ValVec yMins () const
 Axis-specific alias.
 
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 3)>>
ValVec zMins () const
 Axis-specific alias.
 
ValVec xMaxs () const
 Axis-specific alias.
 
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 2)>>
ValVec yMaxs () const
 Axis-specific alias.
 
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 3)>>
ValVec zMaxs () const
 Axis-specific alias.
 
double xMin () const
 Axis-specific alias.
 
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 2)>>
double yMin () const
 Axis-specific alias.
 
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 3)>>
double zMin () const
 Axis-specific alias.
 
double xMax () const
 Axis-specific alias.
 
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 2)>>
double yMax () const
 Axis-specific alias.
 
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 3)>>
double zMax () const
 Axis-specific alias.
 
PairVec xErrs () const
 Axis-specific alias.
 
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 2)>>
PairVec yErrs () const
 Axis-specific alias.
 
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 3)>>
PairVec zErrs () const
 Axis-specific alias.
 
Utilities
std::vector< Pairedges (const size_t i) const
 
- Public Member Functions inherited from YODA::AnalysisObject
 AnalysisObject ()
 Default constructor.
 
 AnalysisObject (const std::string &type, const std::string &path, const std::string &title="")
 Constructor giving a type, a path and an optional title.
 
 AnalysisObject (const std::string &type, const std::string &path, const AnalysisObject &ao, const std::string &title="")
 Constructor giving a type, a path, another AO to copy annotation from, and an optional title.
 
virtual ~AnalysisObject ()
 Default destructor.
 
virtual AnalysisObjectoperator= (const AnalysisObject &ao) noexcept
 Default copy assignment operator.
 
std::vector< std::string > annotations () const
 
bool hasAnnotation (const std::string &name) const
 Check if an annotation is defined.
 
const std::string & annotation (const std::string &name) const
 Get an annotation by name (as a string)
 
const std::string & annotation (const std::string &name, const std::string &defaultreturn) const
 Get an annotation by name (as a string) with a default in case the annotation is not found.
 
template<typename T >
const T annotation (const std::string &name) const
 Get an annotation by name (copied to another type)
 
template<typename T >
const T annotation (const std::string &name, const T &defaultreturn) const
 Get an annotation by name (copied to another type) with a default in case the annotation is not found.
 
template<typename T >
void setAnnotation (const std::string &name, const T &value)
 Add or set an annotation by name (templated for remaining types)
 
void setAnnotations (const Annotations &anns)
 Set all annotations at once.
 
template<typename T >
void addAnnotation (const std::string &name, const T &value)
 Add or set an annotation by name.
 
void rmAnnotation (const std::string &name)
 Delete an annotation by name.
 
void clearAnnotations ()
 Delete an annotation by name.
 
const std::string title () const
 Get the AO title.
 
void setTitle (const std::string &title)
 Set the AO title.
 
const std::string path () const
 Get the AO path.
 
void setPath (const std::string &path)
 
const std::string name () const
 
virtual std::string type () const
 Get name of the analysis object type.
 
virtual AnalysisObjectmkInert (const std::string &path="", const std::string &source="") const noexcept
 Return an inert version of the analysis object (e.g. scatter, estimate)
 
size_t lengthMeta (const bool skipPath=true, const bool skipTitle=true) const noexcept
 Length of serialized meta-data vector for MPI reduce operations.
 
std::vector< std::string > serializeMeta (const bool skipPath=true, const bool skipTitle=true) const noexcept
 Mate-data serialisation for MPI reduce operations.
 
virtual void deserializeMeta (const std::vector< std::string > &data, const bool resetPath=false, const bool resetTitle=false)
 Mate-data deserialisation for MPI reduce operations.
 
- Public Member Functions inherited from YODA::Scatter
virtual ~Scatter ()
 Virtual destructor for inheritance.
 
virtual void rmPoints (std::vector< size_t > indices)
 Safely remove the points with indices indices.
 

Protected Types

using Pair = std::pair< double, double >
 
using ValVec = std::vector< double >
 
using PairVec = std::vector< Pair >
 
using ValList = std::initializer_list< double >
 
using PairList = std::initializer_list< Pair >
 
template<typename Arr >
using containedType = std::decay_t< decltype(*std::declval< Arr >().begin())>
 
template<typename Arr >
using containsPair = typename std::is_same< containedType< Arr >, Pair >
 
template<typename T , typename U >
using enableIfNestedArrayWithPair = std::enable_if_t<(isIterable< T, U, containedType< T >, containedType< U > > &&containsPair< containedType< U > >::value)>
 
template<typename... Args>
using isAllVals = std::is_same< double, std::common_type_t< Args..., double > >
 
template<typename... Args>
using isHalfValsHalfPairs = HalfValsHalfPairs< std::tuple< Args... >, std::make_index_sequence< N > >
 

Point inserters/removers

ScatterND< N > & addPoint (const PointND< N > &pt)
 Insert a new point.
 
ScatterND< N > & addPoint (PointND< N > &&pt)
 Insert a new rvalue point.
 
template<typename ValRange = ValList, typename = std::enable_if_t<isIterable<ValRange>>>
ScatterND< N > & addPoint (ValRange &&pos)
 Insert a new point from a position array (of N elements)
 
template<typename ValRange = ValList, typename = std::enable_if_t<isIterable<ValRange>>>
ScatterND< N > & addPoint (ValRange &&pos, ValRange &&err)
 Insert a new point from position and symmetric error arrays (of N elements)
 
template<typename ValRange = ValList, typename = std::enable_if_t<isIterable<ValRange>>>
ScatterND< N > & addPoint (ValRange &&pos, ValRange &&errdn, ValRange &&errup)
 Insert a new point from position and asymmetric error arrays (of N elements)
 
template<typename ValRange = ValList, typename PairRange = PairList>
auto addPoint (ValRange &&pos, PairRange &&err) -> std::enable_if_t<(isIterable< ValRange, PairRange > &&containsPair< PairRange >::value), ScatterND< N > > &
 Insert a new point from a position and error-pair array.
 
template<typename... Args>
auto addPoint (Args &&... args) -> std::enable_if_t<(sizeof...(Args)==2 *N||sizeof...(Args)==3 *N), ScatterND< N > > &
 
ScatterND< N > & addPoints (Points pts)
 Insert a collection of new points.
 
void rmPoint (size_t index)
 Remove the point with index index.
 
template<typename... Args, size_t... Is>
auto addPoint_aux (std::tuple< Args... > &&t, std::index_sequence< Is... >) -> std::enable_if_t<(isAllVals< Args... >::value), ScatterND< N > > &
 
template<typename... Args, size_t... Is>
auto addPoint_aux (std::tuple< Args... > &&t, std::index_sequence< Is... >) -> std::enable_if_t<(sizeof...(Args)==2 *N &&isHalfValsHalfPairs< Args... >::value), ScatterND< N > > &
 

Detailed Description

template<size_t N>
class YODA::ScatterND< N >

A generic data type which is just a collection of n-dim data points with errors.

Definition at line 154 of file Scatter.h.

Member Typedef Documentation

◆ containedType

template<size_t N>
template<typename Arr >
using YODA::ScatterND< N >::containedType = std::decay_t<decltype(*std::declval<Arr>().begin())>
protected

Definition at line 166 of file Scatter.h.

◆ containsPair

template<size_t N>
template<typename Arr >
using YODA::ScatterND< N >::containsPair = typename std::is_same<containedType<Arr>, Pair>
protected

Definition at line 170 of file Scatter.h.

◆ enableIfNestedArrayWithPair

template<size_t N>
template<typename T , typename U >
using YODA::ScatterND< N >::enableIfNestedArrayWithPair = std::enable_if_t<(isIterable<T,U,containedType<T>,containedType<U> > && containsPair<containedType<U> >::value)>
protected

Definition at line 175 of file Scatter.h.

◆ isAllVals

template<size_t N>
template<typename... Args>
using YODA::ScatterND< N >::isAllVals = std::is_same<double, std::common_type_t<Args..., double> >
protected

Definition at line 180 of file Scatter.h.

◆ isHalfValsHalfPairs

template<size_t N>
template<typename... Args>
using YODA::ScatterND< N >::isHalfValsHalfPairs = HalfValsHalfPairs<std::tuple<Args...>, std::make_index_sequence<N> >
protected

Definition at line 186 of file Scatter.h.

◆ NdVal

template<size_t N>
using YODA::ScatterND< N >::NdVal = Utils::ndarray<double, N>

Definition at line 191 of file Scatter.h.

◆ NdValPair

template<size_t N>
using YODA::ScatterND< N >::NdValPair = Utils::ndarray<std::pair<double,double>, N>

Definition at line 192 of file Scatter.h.

◆ Pair

template<size_t N>
using YODA::ScatterND< N >::Pair = std::pair<double,double>
protected

Definition at line 158 of file Scatter.h.

◆ PairList

template<size_t N>
using YODA::ScatterND< N >::PairList = std::initializer_list<Pair>
protected

Definition at line 162 of file Scatter.h.

◆ PairVec

template<size_t N>
using YODA::ScatterND< N >::PairVec = std::vector<Pair>
protected

Definition at line 160 of file Scatter.h.

◆ Point

template<size_t N>
using YODA::ScatterND< N >::Point = PointND<N>

Definition at line 193 of file Scatter.h.

◆ Points

template<size_t N>
using YODA::ScatterND< N >::Points = Utils::sortedvector<Point>

Definition at line 194 of file Scatter.h.

◆ Ptr

template<size_t N>
using YODA::ScatterND< N >::Ptr = std::shared_ptr<ScatterND>

Definition at line 195 of file Scatter.h.

◆ ValList

template<size_t N>
using YODA::ScatterND< N >::ValList = std::initializer_list<double>
protected

Definition at line 161 of file Scatter.h.

◆ ValVec

template<size_t N>
using YODA::ScatterND< N >::ValVec = std::vector<double>
protected

Definition at line 159 of file Scatter.h.

Constructor & Destructor Documentation

◆ ScatterND() [1/8]

template<size_t N>
YODA::ScatterND< N >::ScatterND ( const std::string &  path = "",
const std::string &  title = "" 
)
inline

Empty constructor.

Definition at line 203 of file Scatter.h.

204 : AnalysisObject("Scatter"+std::to_string(N)+"D", path, title) { }
const std::string title() const
Get the AO title.
const std::string path() const
Get the AO path.
AnalysisObject()
Default constructor.

◆ ScatterND() [2/8]

template<size_t N>
YODA::ScatterND< N >::ScatterND ( const Points points,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from a set of points.

Definition at line 207 of file Scatter.h.

209 : AnalysisObject("Scatter"+std::to_string(N)+"D", path, title),
210 _points(points) { }
Points & points()
Get the collection of points.
Definition Scatter.h:340

◆ ScatterND() [3/8]

template<size_t N>
YODA::ScatterND< N >::ScatterND ( Points &&  points,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from a set of rvalue points.

Definition at line 213 of file Scatter.h.

215 : AnalysisObject("Scatter"+std::to_string(N)+"D", path, title),
216 _points(std::move(points)) { }

◆ ScatterND() [4/8]

template<size_t N>
template<typename ValRange = std::initializer_list<ValList>, typename = std::enable_if_t<isIterable<ValRange, containedType<ValRange>>>>
YODA::ScatterND< N >::ScatterND ( ValRange &&  positions,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from a vector of position values with no errors.

Definition at line 221 of file Scatter.h.

222 : AnalysisObject("Scatter"+std::to_string(N)+"D", path, title) {
223 for (size_t i = 0; i < positions.size(); ++i) {
224 addPoint(PointND<N>(std::forward<containedType<ValRange>>(positions[i])));
225 }
226 }
ScatterND< N > & addPoint(const PointND< N > &pt)
Insert a new point.
Definition Scatter.h:369

References YODA::ScatterND< N >::addPoint().

◆ ScatterND() [5/8]

template<size_t N>
template<typename ValRange = std::initializer_list<ValList>, typename = std::enable_if_t<isIterable<ValRange, containedType<ValRange>>>>
YODA::ScatterND< N >::ScatterND ( ValRange &&  positions,
ValRange &&  errors,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from vectors of values for positions and a single set of symmetric errors.

Definition at line 231 of file Scatter.h.

232 : AnalysisObject("Scatter"+std::to_string(N)+"D", path, title) {
233 if (positions.size() != errors.size()) throw RangeError("Number of errors doesn't match number of positions");
234 for (size_t i = 0; i < positions.size(); ++i) {
235 addPoint(PointND<N>(std::forward<containedType<ValRange>>(positions[i]),
236 std::forward<containedType<ValRange>>(errors[i])));
237 }
238 }

References YODA::ScatterND< N >::addPoint().

◆ ScatterND() [6/8]

template<size_t N>
template<typename ValRange = std::initializer_list<ValList>, typename PairRange = std::initializer_list<PairList>, typename = enableIfNestedArrayWithPair<ValRange,PairRange>>
YODA::ScatterND< N >::ScatterND ( ValRange &&  positions,
PairRange &&  errors,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from vectors of values for positions and a single set of symmetric errors.

Definition at line 244 of file Scatter.h.

245 : AnalysisObject("Scatter"+std::to_string(N)+"D", path, title) {
246 if (positions.size() != errors.size()) throw RangeError("Number of error pairs doesn't match number of positions");
247 for (size_t i = 0; i < positions.size(); ++i) {
248 addPoint(PointND<N>(std::forward<containedType<ValRange>>(positions[i]),
249 std::forward<containedType<PairRange>>(errors[i])));
250 }
251 }

References YODA::ScatterND< N >::addPoint().

◆ ScatterND() [7/8]

template<size_t N>
YODA::ScatterND< N >::ScatterND ( const ScatterND< N > &  s,
const std::string &  path = "" 
)
inline

Copy constructor with optional new path.

Definition at line 254 of file Scatter.h.

255 : AnalysisObject("Scatter"+std::to_string(N)+"D", (path != "")? path : s.path(), s, s.title()),
256 _points(s._points) { }

◆ ScatterND() [8/8]

template<size_t N>
YODA::ScatterND< N >::ScatterND ( ScatterND< N > &&  s,
const std::string &  path = "" 
)
inline

Move constructor with optional new path.

Definition at line 259 of file Scatter.h.

260 : AnalysisObject("Scatter"+std::to_string(N)+"D", (path != "")? path : s.path(), s, s.title()),
261 _points(std::move(s._points)) {
262 }

Member Function Documentation

◆ addPoint() [1/7]

template<size_t N>
template<typename... Args>
auto YODA::ScatterND< N >::addPoint ( Args &&...  args) -> std::enable_if_t<(sizeof...(Args) == 2*N || sizeof...(Args) == 3*N), ScatterND<N>>&
inline

Insert a new point from a parameter pack

The deduction guide on the parameter pack asks that its length be 2N or 3N for dimension N.

If accepted, the parameter pack is then forwarded as a tuple to the helper method addPoint_aux, which is overloaded to deal with the following three cases:

Case 1: position and symmetric errors: Scatter1D::addPoint(x, ex); Scatter2D::addPoint(x,y, ex,ey); ... Case 2: position and asymmetric errors: Scatter1D::addPoint(x, exdn,exup); Scatter2D::addPoint(x,y, exdn,eydn, exup,eyup); ... Case 3: position and error pairs Scatter1D::addPoint(x, make_pair(exdn,exup)); Scatter2D::addPoint(x,y, make_pair(exdn,eydn), make_pair(exup,eyup)); ...

Definition at line 436 of file Scatter.h.

437 {
438 return addPoint_aux(std::make_tuple(std::forward<Args>(args)...), std::make_index_sequence<N>{});
439 }
auto addPoint_aux(std::tuple< Args... > &&t, std::index_sequence< Is... >) -> std::enable_if_t<(isAllVals< Args... >::value), ScatterND< N > > &
Definition Scatter.h:459

References YODA::ScatterND< N >::addPoint_aux().

◆ addPoint() [2/7]

◆ addPoint() [3/7]

template<size_t N>
ScatterND< N > & YODA::ScatterND< N >::addPoint ( PointND< N > &&  pt)
inline

Insert a new rvalue point.

Definition at line 375 of file Scatter.h.

375 {
376 _points.insert(std::move(pt));
377 return *this;
378 }

◆ addPoint() [4/7]

template<size_t N>
template<typename ValRange = ValList, typename = std::enable_if_t<isIterable<ValRange>>>
ScatterND< N > & YODA::ScatterND< N >::addPoint ( ValRange &&  pos)
inline

Insert a new point from a position array (of N elements)

Definition at line 383 of file Scatter.h.

383 {
384 _points.insert(PointND<N>(std::forward<ValRange>(pos)));
385 return *this;
386 }

◆ addPoint() [5/7]

template<size_t N>
template<typename ValRange = ValList, typename PairRange = PairList>
auto YODA::ScatterND< N >::addPoint ( ValRange &&  pos,
PairRange &&  err 
) -> std::enable_if_t<(isIterable<ValRange,PairRange> && containsPair<PairRange>::value), ScatterND<N>>&
inline

Insert a new point from a position and error-pair array.

Definition at line 408 of file Scatter.h.

409 {
410 _points.insert(PointND<N>(pos, err));
411 return *this;
412 }

◆ addPoint() [6/7]

template<size_t N>
template<typename ValRange = ValList, typename = std::enable_if_t<isIterable<ValRange>>>
ScatterND< N > & YODA::ScatterND< N >::addPoint ( ValRange &&  pos,
ValRange &&  err 
)
inline

Insert a new point from position and symmetric error arrays (of N elements)

Definition at line 391 of file Scatter.h.

391 {
392 _points.insert(PointND<N>(std::forward<ValRange>(pos), std::forward<ValRange>(err)));
393 return *this;
394 }

◆ addPoint() [7/7]

template<size_t N>
template<typename ValRange = ValList, typename = std::enable_if_t<isIterable<ValRange>>>
ScatterND< N > & YODA::ScatterND< N >::addPoint ( ValRange &&  pos,
ValRange &&  errdn,
ValRange &&  errup 
)
inline

Insert a new point from position and asymmetric error arrays (of N elements)

Definition at line 399 of file Scatter.h.

399 {
400 _points.insert(PointND<N>(std::forward<ValRange>(pos),
401 std::forward<ValRange>(errdn),
402 std::forward<ValRange>(errup)));
403 return *this;
404 }

◆ addPoint_aux() [1/2]

template<size_t N>
template<typename... Args, size_t... Is>
auto YODA::ScatterND< N >::addPoint_aux ( std::tuple< Args... > &&  t,
std::index_sequence< Is... >   
) -> std::enable_if_t<(isAllVals<Args...>::value), ScatterND<N>>&
inlineprotected

Helper method to deal with parameter pack that has been forwarded as a tuple from addPoints.

The deduction guide on the parameter pack asks that all arguments can be cast to double, thereby covering the following two cases:

Case 1: position and symmetric errors: Scatter1D::addPoint(x, ex); Scatter2D::addPoint(x,y, ex,ey); ... Case 2: position and asymmetric errors: Scatter1D::addPoint(x, exdn,exup); Scatter2D::addPoint(x,y, exdn,eydn, exup,eyup); ...

Definition at line 459 of file Scatter.h.

460 {
461 if constexpr(sizeof...(Args) == 2*N) { // Case 1: symmetric errors
462 _points.insert(
463 PointND<N>( ValVec{ static_cast<double>(std::get<Is>(t))...},
464 PairVec{{static_cast<double>(std::get<N+Is>(t)),
465 static_cast<double>(std::get<N+Is>(t))}...} ));
466 }
467 else { // Case 2: asymmetric errors
468 _points.insert(PointND<N>( ValVec{ static_cast<double>(std::get<Is>(t))...},
469 PairVec{{static_cast<double>(std::get<N+2*Is>(t)),
470 static_cast<double>(std::get<N+2*Is+1>(t))}...} ));
471 }
472 return *this;
473 }
std::vector< Pair > PairVec
Definition Scatter.h:160
std::vector< double > ValVec
Definition Scatter.h:159

Referenced by YODA::ScatterND< N >::addPoint().

◆ addPoint_aux() [2/2]

template<size_t N>
template<typename... Args, size_t... Is>
auto YODA::ScatterND< N >::addPoint_aux ( std::tuple< Args... > &&  t,
std::index_sequence< Is... >   
) -> std::enable_if_t<(sizeof...(Args) == 2*N && isHalfValsHalfPairs<Args...>::value), ScatterND<N>>&
inlineprotected

Helper method to deal with parameter pack that has been forwarded as a tuple from addPoints.

The deduction guide on the parameter pack asks that its length be 2N for dimension N, that the first half of the arguments can be cast to double, and that the second half can be cast to Pair, thereby covering the following case:

Case 3: position and error pairs Scatter1D::addPoint(x, make_pair(exdn,exup)); Scatter2D::addPoint(x,y, make_pair(exdn,eydn), make_pair(exup,eyup)); ...

Definition at line 490 of file Scatter.h.

491 {
492 _points.insert(PointND<N>( ValVec{ static_cast<double>(std::get<Is>(t))...},
493 PairVec{ static_cast<Pair>(std::get<N+Is>(t))...} ));
494 return *this;
495 }
std::pair< double, double > Pair
Definition Scatter.h:158

◆ addPoints()

template<size_t N>
ScatterND< N > & YODA::ScatterND< N >::addPoints ( Points  pts)
inline

Insert a collection of new points.

Definition at line 501 of file Scatter.h.

501 {
502 for (const PointND<N>& pt : pts) addPoint(pt);
503 return *this;
504 }

References YODA::ScatterND< N >::addPoint().

Referenced by YODA::ScatterND< N >::combineWith(), and YODA::ScatterND< N >::combineWith().

◆ clone()

template<size_t N>
ScatterND< N > YODA::ScatterND< N >::clone ( ) const
inline

Make a copy on the stack.

Definition at line 284 of file Scatter.h.

284 {
285 return ScatterND<N>(*this);
286 }

Referenced by YODA::WriterYODA1::writeScatter1D(), YODA::WriterYODA1::writeScatter2D(), and YODA::WriterYODA1::writeScatter3D().

◆ combineWith() [1/4]

template<size_t N>
ScatterND< N > & YODA::ScatterND< N >::combineWith ( const ScatterND< N > &  other)
inline
Todo:
Better name?

Definition at line 558 of file Scatter.h.

558 {
559 addPoints(other.points());
560 return *this;
561 }
ScatterND< N > & addPoints(Points pts)
Insert a collection of new points.
Definition Scatter.h:501

References YODA::ScatterND< N >::addPoints(), and YODA::ScatterND< N >::points().

Referenced by YODA::combine(), YODA::combine(), YODA::combine(), YODA::combine(), YODA::ScatterND< N >::combineWith(), and YODA::ScatterND< N >::combineWith().

◆ combineWith() [2/4]

template<size_t N>
ScatterND< N > & YODA::ScatterND< N >::combineWith ( const std::vector< ScatterND< N > > &  others)
inline
Todo:
Better name?

Definition at line 570 of file Scatter.h.

570 {
571 for (const ScatterND<N>& s : others) combineWith(s);
572 return *this;
573 }
ScatterND< N > & combineWith(const ScatterND< N > &other)
Definition Scatter.h:558

References YODA::ScatterND< N >::combineWith().

◆ combineWith() [3/4]

template<size_t N>
ScatterND< N > & YODA::ScatterND< N >::combineWith ( ScatterND< N > &&  other)
inline
Todo:
Better name?

Definition at line 564 of file Scatter.h.

564 {
565 addPoints(std::move(other._points));
566 return *this;
567 }

References YODA::ScatterND< N >::addPoints().

◆ combineWith() [4/4]

template<size_t N>
ScatterND< N > & YODA::ScatterND< N >::combineWith ( std::vector< ScatterND< N > > &&  others)
inline
Todo:
Better name?

Definition at line 576 of file Scatter.h.

576 {
577 for (ScatterND<N>&& s : others) combineWith(std::move(s));
578 return *this;
579 }

References YODA::ScatterND< N >::combineWith().

◆ deserializeContent()

template<size_t N>
void YODA::ScatterND< N >::deserializeContent ( const std::vector< double > &  data)
inlinevirtual

Content deserialisation for MPI reduce operations.

Implements YODA::AnalysisObject.

Definition at line 535 of file Scatter.h.

535 {
536
537 if (data.size() % Point::DataSize::value)
538 throw UserError("Length of serialized data should be a multiple of "+std::to_string(Point::DataSize::value)+"!");
539
540 const size_t nPoints = data.size()/Point::DataSize::value;
541 const auto itr = data.cbegin();
542 reset();
543 for (size_t i = 0; i < nPoints; ++i) {
544 addPoint(Point());
545 auto first = itr + i*Point::DataSize::value;
546 auto last = first + Point::DataSize::value;
547 point(i)._deserializeContent(std::vector<double>{first, last});
548 }
549
550 }
PointND< N > & point(size_t index)
Get a reference to the point with index index.
Definition Scatter.h:352
PointND< N > Point
Definition Scatter.h:193
void reset()
Clear all points.
Definition Scatter.h:302

References YODA::ScatterND< N >::addPoint(), YODA::ScatterND< N >::point(), and YODA::ScatterND< N >::reset().

◆ dim()

template<size_t N>
size_t YODA::ScatterND< N >::dim ( ) const
inlinevirtualnoexcept

Dimension of this data object.

Implements YODA::AnalysisObject.

Definition at line 296 of file Scatter.h.

296{ return N; }

◆ edges()

template<size_t N>
std::vector< Pair > YODA::ScatterND< N >::edges ( const size_t  i) const
inline

Definition at line 745 of file Scatter.h.

745 {
746 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
747 std::vector<Pair> rtn;
748 rtn.resize(numPoints());
749 size_t j = 0;
750 for (const Point& p : points()) {
751 rtn[j++] = std::make_pair(p.min(i), p.max(i));
752 }
753 std::sort(rtn.begin(), rtn.end());
754 rtn.erase(std::unique(rtn.begin(), rtn.end()), rtn.end());
755 return rtn;
756 }
size_t numPoints() const
Number of points in the scatter.
Definition Scatter.h:334

References YODA::ScatterND< N >::numPoints(), and YODA::ScatterND< N >::points().

◆ errs()

template<size_t N>
PairVec YODA::ScatterND< N >::errs ( const size_t  i) const
inline

Get the error pairs along axis i.

Definition at line 631 of file Scatter.h.

631 {
632 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
633 PairVec rtn; rtn.reserve(_points.size());
634 for (const auto& pt : _points) {
635 rtn.push_back( pt.errs(i) );
636 }
637 return rtn;
638 }

Referenced by YODA::ScatterND< N >::xErrs(), YODA::ScatterND< N >::yErrs(), and YODA::ScatterND< N >::zErrs().

◆ errsAvg()

template<size_t N>
ValVec YODA::ScatterND< N >::errsAvg ( const size_t  i) const
inline

Get the average error along axis i.

Definition at line 641 of file Scatter.h.

641 {
642 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
643 ValVec rtn; rtn.reserve(_points.size());
644 for (const auto& pt : _points) {
645 rtn.push_back( pt.errAvg(i) );
646 }
647 return rtn;
648 }

◆ lengthContent()

template<size_t N>
size_t YODA::ScatterND< N >::lengthContent ( bool  fixed_length = false) const
inlinevirtualnoexcept

Length of serialized content vector for MPI reduce operations.

Implements YODA::AnalysisObject.

Definition at line 515 of file Scatter.h.

515 {
516 if (fixed_length) return 0;
517 return numPoints() * Point::DataSize::value;
518 }

References YODA::ScatterND< N >::numPoints().

◆ max()

template<size_t N>
double YODA::ScatterND< N >::max ( const size_t  i) const
inline

Get the largest central value along axis i.

Definition at line 624 of file Scatter.h.

624 {
625 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
626 const ValVec cvals = vals(i);
627 return *std::max_element(cvals.begin(), cvals.end());
628 }
ValVec vals(const size_t i) const
Get the coordinate vector along axis i.
Definition Scatter.h:587

References YODA::ScatterND< N >::vals().

Referenced by YODA::ScatterND< N >::xMax(), YODA::ScatterND< N >::yMax(), and YODA::ScatterND< N >::zMax().

◆ maxs()

template<size_t N>
ValVec YODA::ScatterND< N >::maxs ( const size_t  i) const
inline

Get the positive error vector along axis i.

Definition at line 607 of file Scatter.h.

607 {
608 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
609 ValVec rtn; rtn.reserve(_points.size());
610 for (const auto& pt : _points) {
611 rtn.push_back( pt.max(i) );
612 }
613 return rtn;
614 }

Referenced by YODA::ScatterND< N >::xMaxs(), YODA::ScatterND< N >::yMaxs(), and YODA::ScatterND< N >::zMaxs().

◆ min()

template<size_t N>
double YODA::ScatterND< N >::min ( const size_t  i) const
inline

Get the smallest central value along axis i.

Definition at line 617 of file Scatter.h.

617 {
618 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
619 const ValVec cvals = vals(i);
620 return *std::min_element(cvals.begin(), cvals.end());
621 }

References YODA::ScatterND< N >::vals().

Referenced by YODA::ScatterND< N >::xMin(), YODA::ScatterND< N >::yMin(), and YODA::ScatterND< N >::zMin().

◆ mins()

template<size_t N>
ValVec YODA::ScatterND< N >::mins ( const size_t  i) const
inline

Get the lowest value vector along axis i.

Definition at line 597 of file Scatter.h.

597 {
598 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
599 ValVec rtn; rtn.reserve(_points.size());
600 for (const auto& pt : _points) {
601 rtn.push_back( pt.min(i) );
602 }
603 return rtn;
604 }

Referenced by YODA::ScatterND< N >::xMins(), YODA::ScatterND< N >::yMins(), and YODA::ScatterND< N >::zMins().

◆ newclone()

template<size_t N>
ScatterND< N > * YODA::ScatterND< N >::newclone ( ) const
inlinevirtual

Make a copy on the heap, via 'new'.

Implements YODA::AnalysisObject.

Definition at line 289 of file Scatter.h.

289 {
290 return new ScatterND<N>(*this);
291 }

◆ numPoints()

template<size_t N>
size_t YODA::ScatterND< N >::numPoints ( ) const
inlinevirtual

Number of points in the scatter.

Implements YODA::Scatter.

Definition at line 334 of file Scatter.h.

334 {
335 return _points.size();
336 }

Referenced by YODA::ScatterND< N >::edges(), YODA::ScatterND< N >::lengthContent(), and YODA::ScatterND< N >::serializeContent().

◆ operator=() [1/2]

template<size_t N>
ScatterND< N > & YODA::ScatterND< N >::operator= ( const ScatterND< N > &  s)
inline

Assignment operator.

Definition at line 266 of file Scatter.h.

266 {
267 if (this != &s) {
269 _points = s._points;
270 }
271 return *this;
272 }
virtual AnalysisObject & operator=(const AnalysisObject &ao) noexcept
Default copy assignment operator.

References YODA::AnalysisObject::operator=().

◆ operator=() [2/2]

template<size_t N>
ScatterND< N > & YODA::ScatterND< N >::operator= ( ScatterND< N > &&  s)
inline

Move operator.

Definition at line 275 of file Scatter.h.

275 {
276 if (this != &s) {
278 _points = std::move(s._points);
279 }
280 return *this;
281 }

References YODA::AnalysisObject::operator=().

◆ point() [1/2]

template<size_t N>
PointND< N > & YODA::ScatterND< N >::point ( size_t  index)
inline

Get a reference to the point with index index.

Definition at line 352 of file Scatter.h.

352 {
353 return _points.at(index);
354 }

Referenced by YODA::ScatterND< N >::deserializeContent(), YODA::DbnStorage< DbnN, AxisT >::mkScatter(), and YODA::ScatterND< N >::serializeContent().

◆ point() [2/2]

template<size_t N>
const PointND< N > & YODA::ScatterND< N >::point ( size_t  index) const
inline

Get the point with index index (const version)

Definition at line 358 of file Scatter.h.

358 {
359 return _points.at(index);
360 }

◆ points() [1/2]

template<size_t N>
Points & YODA::ScatterND< N >::points ( )
inline

◆ points() [2/2]

template<size_t N>
const Points & YODA::ScatterND< N >::points ( ) const
inline

Get the collection of points (const version)

Definition at line 346 of file Scatter.h.

346 {
347 return _points;
348 }

◆ reset()

template<size_t N>
void YODA::ScatterND< N >::reset ( )
inlinevirtual

Clear all points.

Implements YODA::AnalysisObject.

Definition at line 302 of file Scatter.h.

302 {
303 _points.clear();
304 }

Referenced by YODA::ScatterND< N >::deserializeContent().

◆ rmPoint()

template<size_t N>
void YODA::ScatterND< N >::rmPoint ( size_t  index)
inlinevirtual

Remove the point with index index.

Implements YODA::Scatter.

Definition at line 506 of file Scatter.h.

506 {
507 _points.erase(_points.begin()+index);
508 }

◆ scale() [1/3]

template<size_t N>
void YODA::ScatterND< N >::scale ( const NdVal scales)
inline

Scaling.

Definition at line 307 of file Scatter.h.

307 {
308 for (PointND<N>& p : _points) p.scale(scales);
309 }
void scale(const NdVal &scales)
Scaling.
Definition Scatter.h:307

◆ scale() [2/3]

template<size_t N>
void YODA::ScatterND< N >::scale ( const size_t  i,
double  factor 
)
inline

Definition at line 316 of file Scatter.h.

316 {
317 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
318 std::array<double,N> scales;
319 scales.fill(1.0);
320 scales[i] = factor;
321 for (PointND<N>& p : _points) p.scale(scales);
322 }

◆ scale() [3/3]

template<size_t N>
void YODA::ScatterND< N >::scale ( const std::vector< double > &  scales)
inline

Definition at line 311 of file Scatter.h.

311 {
312 if (scales.size() != N) throw RangeError("Expected " + std::to_string(N) + " scale factors");
313 for (PointND<N>& p : _points) p.scale(scales);
314 }

◆ serializeContent()

template<size_t N>
std::vector< double > YODA::ScatterND< N >::serializeContent ( bool  fixed_length = false) const
inlinevirtualnoexcept

Content serialisation for MPI reduce operations.

Implements YODA::AnalysisObject.

Definition at line 520 of file Scatter.h.

520 {
521
522 if (fixed_length) return { }; // cannot guarantee fixed length
523
524 std::vector<double> rtn;
525 rtn.reserve(numPoints() * Point::DataSize::value);
526 for (size_t i = 0; i < numPoints(); ++i) {
527 std::vector<double> pdata = point(i)._serializeContent();
528 rtn.insert(std::end(rtn),
529 std::make_move_iterator(std::begin(pdata)),
530 std::make_move_iterator(std::end(pdata)));
531 }
532 return rtn;
533 }

References YODA::ScatterND< N >::numPoints(), and YODA::ScatterND< N >::point().

◆ vals()

template<size_t N>
ValVec YODA::ScatterND< N >::vals ( const size_t  i) const
inline

Get the coordinate vector along axis i.

Definition at line 587 of file Scatter.h.

587 {
588 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
589 ValVec rtn; rtn.reserve(_points.size());
590 for (const auto& pt : _points) {
591 rtn.push_back( pt.val(i) );
592 }
593 return rtn;
594 }

Referenced by YODA::ScatterND< N >::max(), YODA::ScatterND< N >::min(), YODA::ScatterND< N >::xVals(), YODA::ScatterND< N >::yVals(), and YODA::ScatterND< N >::zVals().

◆ xErrs()

template<size_t N>
PairVec YODA::ScatterND< N >::xErrs ( ) const
inline

Axis-specific alias.

Definition at line 706 of file Scatter.h.

706{ return errs(0); }
PairVec errs(const size_t i) const
Get the error pairs along axis i.
Definition Scatter.h:631

References YODA::ScatterND< N >::errs().

◆ xMax()

template<size_t N>
double YODA::ScatterND< N >::xMax ( ) const
inline

Axis-specific alias.

Definition at line 695 of file Scatter.h.

695{ return max(0); }
double max(const size_t i) const
Get the largest central value along axis i.
Definition Scatter.h:624

References YODA::ScatterND< N >::max().

◆ xMaxs()

template<size_t N>
ValVec YODA::ScatterND< N >::xMaxs ( ) const
inline

Axis-specific alias.

Definition at line 673 of file Scatter.h.

673{ return maxs(0); }
ValVec maxs(const size_t i) const
Get the positive error vector along axis i.
Definition Scatter.h:607

References YODA::ScatterND< N >::maxs().

◆ xMin()

template<size_t N>
double YODA::ScatterND< N >::xMin ( ) const
inline

Axis-specific alias.

Definition at line 684 of file Scatter.h.

684{ return min(0); }
double min(const size_t i) const
Get the smallest central value along axis i.
Definition Scatter.h:617

References YODA::ScatterND< N >::min().

◆ xMins()

template<size_t N>
ValVec YODA::ScatterND< N >::xMins ( ) const
inline

Axis-specific alias.

Definition at line 662 of file Scatter.h.

662{ return mins(0); }
ValVec mins(const size_t i) const
Get the lowest value vector along axis i.
Definition Scatter.h:597

References YODA::ScatterND< N >::mins().

◆ xVals()

template<size_t N>
ValVec YODA::ScatterND< N >::xVals ( ) const
inline

Axis-specific alias.

Definition at line 651 of file Scatter.h.

651{ return vals(0); }

References YODA::ScatterND< N >::vals().

◆ yErrs()

template<size_t N>
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 2)>>
PairVec YODA::ScatterND< N >::yErrs ( ) const
inline

Axis-specific alias.

Definition at line 710 of file Scatter.h.

710{ return errs(1); }

References YODA::ScatterND< N >::errs().

◆ yMax()

template<size_t N>
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 2)>>
double YODA::ScatterND< N >::yMax ( ) const
inline

Axis-specific alias.

Definition at line 699 of file Scatter.h.

699{ return max(1); }

References YODA::ScatterND< N >::max().

◆ yMaxs()

template<size_t N>
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 2)>>
ValVec YODA::ScatterND< N >::yMaxs ( ) const
inline

Axis-specific alias.

Definition at line 677 of file Scatter.h.

677{ return maxs(1); }

References YODA::ScatterND< N >::maxs().

◆ yMin()

template<size_t N>
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 2)>>
double YODA::ScatterND< N >::yMin ( ) const
inline

Axis-specific alias.

Definition at line 688 of file Scatter.h.

688{ return min(1); }

References YODA::ScatterND< N >::min().

◆ yMins()

template<size_t N>
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 2)>>
ValVec YODA::ScatterND< N >::yMins ( ) const
inline

Axis-specific alias.

Definition at line 666 of file Scatter.h.

666{ return mins(1); }

References YODA::ScatterND< N >::mins().

◆ yVals()

template<size_t N>
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 2)>>
ValVec YODA::ScatterND< N >::yVals ( ) const
inline

Axis-specific alias.

Definition at line 655 of file Scatter.h.

655{ return vals(1); }

References YODA::ScatterND< N >::vals().

◆ zErrs()

template<size_t N>
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 3)>>
PairVec YODA::ScatterND< N >::zErrs ( ) const
inline

Axis-specific alias.

Definition at line 714 of file Scatter.h.

714{ return errs(2); }

References YODA::ScatterND< N >::errs().

◆ zMax()

template<size_t N>
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 3)>>
double YODA::ScatterND< N >::zMax ( ) const
inline

Axis-specific alias.

Definition at line 703 of file Scatter.h.

703{ return max(2); }

References YODA::ScatterND< N >::max().

◆ zMaxs()

template<size_t N>
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 3)>>
ValVec YODA::ScatterND< N >::zMaxs ( ) const
inline

Axis-specific alias.

Definition at line 681 of file Scatter.h.

681{ return maxs(2); }

References YODA::ScatterND< N >::maxs().

◆ zMin()

template<size_t N>
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 3)>>
double YODA::ScatterND< N >::zMin ( ) const
inline

Axis-specific alias.

Definition at line 692 of file Scatter.h.

692{ return min(2); }

References YODA::ScatterND< N >::min().

◆ zMins()

template<size_t N>
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 3)>>
ValVec YODA::ScatterND< N >::zMins ( ) const
inline

Axis-specific alias.

Definition at line 670 of file Scatter.h.

670{ return mins(2); }

References YODA::ScatterND< N >::mins().

◆ zVals()

template<size_t N>
template<size_t axisN = N, typename = std::enable_if_t<(axisN >= 3)>>
ValVec YODA::ScatterND< N >::zVals ( ) const
inline

Axis-specific alias.

Definition at line 659 of file Scatter.h.

659{ return vals(2); }

References YODA::ScatterND< N >::vals().


The documentation for this class was generated from the following file: