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

The base for an N-dimensional data point to be contained in a Scatter<N> More...

#include <Point.h>

Inheritance diagram for YODA::PointBase< N >:
YODA::Point YODA::PointND< N >

Public Types

using NdVal = typename Utils::ndarray< double, N >
 
using NdValPair = typename Utils::ndarray< std::pair< double, double >, N >
 
using DataSize = std::integral_constant< size_t, 3 *N >
 
- Public Types inherited from YODA::Point
using ValuePair = std::pair< double, double >
 

Public Member Functions

size_t dim () const
 Space dimension of the point.
 
Constructors
 PointBase ()
 
template<typename ValRange = ValList, typename = isIterable<ValRange>>
 PointBase (ValRange &&val)
 Constructor from position values without errors.
 
template<typename ValRange = ValList, typename PairRange = PairList, typename = isIterableWithPair<ValRange,PairRange>>
 PointBase (ValRange &&val, PairRange &&errs)
 Constructor from values and a set of asymmetric errors.
 
template<typename ValRange = ValList, typename = isIterable<ValRange>>
 PointBase (ValRange &&val, ValRange &&errs)
 Constructor from values and a set of symmetric errors.
 
template<typename ValRange = ValList, typename = isIterable<ValRange>>
 PointBase (ValRange &&val, ValRange &&errsdn, ValRange &&errsup)
 Constructor from values and a set of asymmetric errors.
 
 PointBase (const PointBase &p)
 
 PointBase (PointBase &&p)
 
Modifiers
void clear ()
 Clear the point values and errors.
 
PointBaseoperator= (const PointBase &p)
 Assignment operator.
 
PointBaseoperator= (PointBase &&p)
 Assignment operator.
 
Coordinate accessors
Todo:
addError, addErrors, setErrors
NdValvals ()
 Get the coordinate vector.
 
const NdValvals () const
 Get the coordinate vector (const version)
 
double val (size_t i) const
 Get the value along direction i.
 
void setVal (const NdVal &val)
 Set the coordinate vector.
 
void setVal (const size_t i, const double val)
 Set a specific coordinate.
 
Error accessors
NdValPairerrs ()
 Get error values.
 
const NdValPairerrs () const
 Get error values (const version)
 
Pair errs (const size_t i) const
 Get error values along axis i.
 
double errMinus (const size_t i) const
 Get the minus error along axis i.
 
double errPlus (const size_t i) const
 Get the plus error along axis i.
 
double errAvg (const size_t i) const
 
double min (const size_t i) const
 Get value minus negative error along axis i.
 
double max (const size_t i) const
 Get value plus positive error along axis i.
 
void setErr (const size_t i, const double e)
 Set a symmetric error pair along axis i.
 
void setErrs (const size_t i, const double eminus, const double eplus)
 Set an asymmetric error pair along axis i.
 
void setErrs (const size_t i, const std::pair< double, double > &e)
 Set a specific error pair along axis i.
 
void setErrMinus (const size_t i, const double eminus)
 Set a specific minus error along axis i.
 
void setErrPlus (const size_t i, const double eplus)
 Set a specific plus error along axis i.
 
Combined value and error setters
void set (const size_t i, const double val, const double e)
 Set value and symmetric error for direction i.
 
void set (const size_t i, const double val, const double eminus, const double eplus)
 Set value and asymmetric error for direction i.
 
void set (const size_t i, const double val, const std::pair< double, double > &e)
 Set value and asymmetric error for direction i.
 
Scaling and transformations
void scaleVal (const size_t i, const double scale)
 Scaling value along direction i.
 
void scaleErr (const size_t i, const double scale)
 Scaling error along direction i.
 
void scale (const size_t i, const double scale)
 Scaling along direction i.
 
void scale (const NdVal &scales)
 Uniform scaling.
 
void scale (const Trf< N > &trf)
 Generalised transformations with functors.
 
void scale (const size_t i, const Trf< N > &trf)
 
void transform (const size_t i, const Trf< N > &trf)
 
- Public Member Functions inherited from YODA::Point
virtual ~Point ()
 Virtual destructor for inheritance.
 

Protected Types

using Pair = std::pair< double, double >
 
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 >
using isIterable = std::enable_if_t< Iterable< T >::value >
 
template<typename T , typename U >
using isIterableWithPair = std::enable_if_t<(Iterable< T >::value &&Iterable< U >::value &&containsPair< U >::value)>
 

Detailed Description

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

The base for an N-dimensional data point to be contained in a Scatter<N>

Definition at line 119 of file Point.h.

Member Typedef Documentation

◆ containedType

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

Definition at line 129 of file Point.h.

◆ containsPair

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

Definition at line 133 of file Point.h.

◆ DataSize

template<size_t N>
using YODA::PointBase< N >::DataSize = std::integral_constant<size_t, 3*N>

Definition at line 148 of file Point.h.

◆ isIterable

template<size_t N>
template<typename T >
using YODA::PointBase< N >::isIterable = std::enable_if_t<Iterable<T>::value>
protected

Definition at line 137 of file Point.h.

◆ isIterableWithPair

template<size_t N>
template<typename T , typename U >
using YODA::PointBase< N >::isIterableWithPair = std::enable_if_t<(Iterable<T>::value && Iterable<U>::value && containsPair<U>::value)>
protected

Definition at line 141 of file Point.h.

◆ NdVal

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

Definition at line 146 of file Point.h.

◆ NdValPair

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

Definition at line 147 of file Point.h.

◆ Pair

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

Definition at line 123 of file Point.h.

◆ PairList

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

Definition at line 125 of file Point.h.

◆ ValList

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

Definition at line 124 of file Point.h.

Constructor & Destructor Documentation

◆ PointBase() [1/7]

template<size_t N>
YODA::PointBase< N >::PointBase ( )
inline

Definition at line 155 of file Point.h.

155 {
156 clear();
157 }
void clear()
Clear the point values and errors.
Definition Point.h:231

References YODA::PointBase< N >::clear().

◆ PointBase() [2/7]

template<size_t N>
template<typename ValRange = ValList, typename = isIterable<ValRange>>
YODA::PointBase< N >::PointBase ( ValRange &&  val)
inline

Constructor from position values without errors.

Definition at line 162 of file Point.h.

162: _val(std::forward<ValRange>(val)) { }
double val(size_t i) const
Get the value along direction i.
Definition Point.h:273

◆ PointBase() [3/7]

template<size_t N>
template<typename ValRange = ValList, typename PairRange = PairList, typename = isIterableWithPair<ValRange,PairRange>>
YODA::PointBase< N >::PointBase ( ValRange &&  val,
PairRange &&  errs 
)
inline

Constructor from values and a set of asymmetric errors.

Definition at line 169 of file Point.h.

170 : _val(std::forward<ValRange>(val)), _errs(std::forward<PairRange>(errs)) { }
NdValPair & errs()
Get error values.
Definition Point.h:296

◆ PointBase() [4/7]

template<size_t N>
template<typename ValRange = ValList, typename = isIterable<ValRange>>
YODA::PointBase< N >::PointBase ( ValRange &&  val,
ValRange &&  errs 
)
inline

Constructor from values and a set of symmetric errors.

Definition at line 174 of file Point.h.

175 : _val(std::forward<ValRange>(val)) {
176 if (val.size() != N || errs.size() != N)
177 throw RangeError("Expected " + std::to_string(N) + " dimensions.");
178 size_t i = 0;
179 auto it = std::begin(errs);
180 const auto& itEnd = std::end(errs);
181 for (; it != itEnd; ++it) {
182 _errs[i++] = std::make_pair(*it, *it);
183 }
184 }

References YODA::PointBase< N >::errs(), and YODA::PointBase< N >::val().

◆ PointBase() [5/7]

template<size_t N>
template<typename ValRange = ValList, typename = isIterable<ValRange>>
YODA::PointBase< N >::PointBase ( ValRange &&  val,
ValRange &&  errsdn,
ValRange &&  errsup 
)
inline

Constructor from values and a set of asymmetric errors.

Definition at line 189 of file Point.h.

190 : _val(std::forward<ValRange>(val)) {
191 if (val.size() != N || errsdn.size() != N || errsup.size() != N)
192 throw RangeError("Expected " + std::to_string(N) + " dimensions.");
193 size_t i = 0;
194 auto itdn = std::begin(errsdn);
195 auto itup = std::begin(errsup);
196 const auto& itEnd = std::end(errsdn);
197 for (; itdn != itEnd; ) {
198 _errs[i++] = std::make_pair(*itdn++, *itup++);
199 }
200 }

References YODA::PointBase< N >::val().

◆ PointBase() [6/7]

template<size_t N>
YODA::PointBase< N >::PointBase ( const PointBase< N > &  p)
inline

Definition at line 202 of file Point.h.

202: _val(p._val), _errs(p._errs) { }

◆ PointBase() [7/7]

template<size_t N>
YODA::PointBase< N >::PointBase ( PointBase< N > &&  p)
inline

Definition at line 204 of file Point.h.

204: _val(std::move(p._val)), _errs(std::move(p._errs)) { }

Member Function Documentation

◆ clear()

template<size_t N>
void YODA::PointBase< N >::clear ( )
inline

Clear the point values and errors.

Definition at line 231 of file Point.h.

231 {
232 for (size_t i = 0; i < N; ++i) {
233 _val[i] = 0;
234 _errs[i] = {0.,0.};
235 }
236 }

Referenced by YODA::PointBase< N >::PointBase().

◆ dim()

template<size_t N>
size_t YODA::PointBase< N >::dim ( ) const
inlinevirtual

Space dimension of the point.

Implements YODA::Point.

Definition at line 209 of file Point.h.

209{ return N; }

◆ errAvg()

template<size_t N>
double YODA::PointBase< N >::errAvg ( const size_t  i) const
inline

Definition at line 324 of file Point.h.

324 {
325 return 0.5*(errMinus(i) + errPlus(i));
326 }
double errMinus(const size_t i) const
Get the minus error along axis i.
Definition Point.h:312
double errPlus(const size_t i) const
Get the plus error along axis i.
Definition Point.h:318

References YODA::PointBase< N >::errMinus(), and YODA::PointBase< N >::errPlus().

◆ errMinus()

template<size_t N>
double YODA::PointBase< N >::errMinus ( const size_t  i) const
inline

Get the minus error along axis i.

Definition at line 312 of file Point.h.

312 {
313 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
314 return _errs[i].first;
315 }

Referenced by YODA::PointBase< N >::errAvg().

◆ errPlus()

template<size_t N>
double YODA::PointBase< N >::errPlus ( const size_t  i) const
inline

Get the plus error along axis i.

Definition at line 318 of file Point.h.

318 {
319 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
320 return _errs[i].second;
321 }

Referenced by YODA::PointBase< N >::errAvg().

◆ errs() [1/3]

template<size_t N>
NdValPair & YODA::PointBase< N >::errs ( )
inline

Get error values.

Definition at line 296 of file Point.h.

296 {
297 return _errs;
298 }

Referenced by YODA::operator<(), YODA::operator==(), and YODA::PointBase< N >::PointBase().

◆ errs() [2/3]

template<size_t N>
const NdValPair & YODA::PointBase< N >::errs ( ) const
inline

Get error values (const version)

Definition at line 301 of file Point.h.

301 {
302 return _errs;
303 }

◆ errs() [3/3]

template<size_t N>
Pair YODA::PointBase< N >::errs ( const size_t  i) const
inline

Get error values along axis i.

Definition at line 306 of file Point.h.

306 {
307 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
308 return _errs[i];
309 }

◆ max()

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

Get value plus positive error along axis i.

Definition at line 335 of file Point.h.

335 {
336 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
337 return _val[i] + _errs[i].second;
338 }

◆ min()

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

Get value minus negative error along axis i.

Definition at line 329 of file Point.h.

329 {
330 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
331 return _val[i] - _errs[i].first;
332 }

◆ operator=() [1/2]

template<size_t N>
PointBase & YODA::PointBase< N >::operator= ( const PointBase< N > &  p)
inline

Assignment operator.

Definition at line 239 of file Point.h.

239 {
240 if (this != &p) {
241 _val = p._val;
242 _errs = p._errs;
243 }
244 return *this;
245 }

◆ operator=() [2/2]

template<size_t N>
PointBase & YODA::PointBase< N >::operator= ( PointBase< N > &&  p)
inline

Assignment operator.

Definition at line 248 of file Point.h.

248 {
249 if (this != &p) {
250 _val = std::move(p._val);
251 _errs = std::move(p._errs);
252 }
253 return *this;
254 }

◆ scale() [1/4]

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

Uniform scaling.

Definition at line 421 of file Point.h.

421 {
422 for (size_t i = 0; i < N; ++i) {
423 scale(i, scales[i]);
424 }
425 }
void scale(const size_t i, const double scale)
Scaling along direction i.
Definition Point.h:415

References YODA::PointBase< N >::scale().

◆ scale() [2/4]

template<size_t N>
void YODA::PointBase< N >::scale ( const size_t  i,
const double  scale 
)
inlinevirtual

Scaling along direction i.

Implements YODA::Point.

Definition at line 415 of file Point.h.

415 {
416 scaleVal(i, scale);
417 scaleErr(i, scale);
418 }
void scaleErr(const size_t i, const double scale)
Scaling error along direction i.
Definition Point.h:408
void scaleVal(const size_t i, const double scale)
Scaling value along direction i.
Definition Point.h:402

References YODA::PointBase< N >::scale(), YODA::PointBase< N >::scaleErr(), and YODA::PointBase< N >::scaleVal().

Referenced by YODA::PointBase< N >::scale(), YODA::PointBase< N >::scale(), YODA::PointBase< N >::scaleErr(), YODA::PointBase< N >::scaleVal(), and YODA::PointBase< N >::transform().

◆ scale() [3/4]

template<size_t N>
void YODA::PointBase< N >::scale ( const size_t  i,
const Trf< N > &  trf 
)
inline

Generalised transformations with functors along axis i

Definition at line 434 of file Point.h.

434 {
435 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
436 trf.transform(_val[i], _errs[i]);
437 }

References YODA::Transformation< N, Args >::transform().

◆ scale() [4/4]

template<size_t N>
void YODA::PointBase< N >::scale ( const Trf< N > &  trf)
inline

Generalised transformations with functors.

Definition at line 428 of file Point.h.

428 {
429 trf.transform(_val, _errs);
430 }

References YODA::Transformation< N, Args >::transform().

◆ scaleErr()

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

Scaling error along direction i.

Definition at line 408 of file Point.h.

408 {
409 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
410 _errs[i].first *= scale;
411 _errs[i].second *= scale;
412 }

References YODA::PointBase< N >::scale().

Referenced by YODA::PointBase< N >::scale().

◆ scaleVal()

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

Scaling value along direction i.

Definition at line 402 of file Point.h.

402 {
403 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
404 _val[i] *= scale;
405 }

References YODA::PointBase< N >::scale().

Referenced by YODA::PointBase< N >::scale().

◆ set() [1/3]

template<size_t N>
void YODA::PointBase< N >::set ( const size_t  i,
const double  val,
const double  e 
)
inlinevirtual

Set value and symmetric error for direction i.

Implements YODA::Point.

Definition at line 376 of file Point.h.

376 {
377 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
378 const double err = fabs(e);
379 _val[i] = val;
380 _errs[i] = {err,err};
381 }

References YODA::PointBase< N >::val().

◆ set() [2/3]

template<size_t N>
void YODA::PointBase< N >::set ( const size_t  i,
const double  val,
const double  eminus,
const double  eplus 
)
inlinevirtual

Set value and asymmetric error for direction i.

Implements YODA::Point.

Definition at line 383 of file Point.h.

383 {
384 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
385 _val[i] = val;
386 _errs[i].first = eminus;
387 _errs[i].second = eplus;
388 }

References YODA::PointBase< N >::val().

◆ set() [3/3]

template<size_t N>
void YODA::PointBase< N >::set ( const size_t  i,
const double  val,
const std::pair< double, double > &  e 
)
inlinevirtual

Set value and asymmetric error for direction i.

Implements YODA::Point.

Definition at line 390 of file Point.h.

390 {
391 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
392 _val[i] = val;
393 _errs[i] = e;
394 }

References YODA::PointBase< N >::val().

◆ setErr()

template<size_t N>
void YODA::PointBase< N >::setErr ( const size_t  i,
const double  e 
)
inlinevirtual

Set a symmetric error pair along axis i.

Implements YODA::Point.

Definition at line 341 of file Point.h.

341 {
342 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
343 const double err = fabs(e);
344 _errs[i] = { err, err};
345 }

◆ setErrMinus()

template<size_t N>
void YODA::PointBase< N >::setErrMinus ( const size_t  i,
const double  eminus 
)
inlinevirtual

Set a specific minus error along axis i.

Implements YODA::Point.

Definition at line 360 of file Point.h.

360 {
361 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
362 _errs[i].first = eminus;
363 }

◆ setErrPlus()

template<size_t N>
void YODA::PointBase< N >::setErrPlus ( const size_t  i,
const double  eplus 
)
inlinevirtual

Set a specific plus error along axis i.

Implements YODA::Point.

Definition at line 366 of file Point.h.

366 {
367 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
368 _errs[i].second = eplus;
369 }

◆ setErrs() [1/2]

template<size_t N>
void YODA::PointBase< N >::setErrs ( const size_t  i,
const double  eminus,
const double  eplus 
)
inlinevirtual

Set an asymmetric error pair along axis i.

Implements YODA::Point.

Definition at line 348 of file Point.h.

348 {
349 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
350 _errs[i] = { eminus, eplus};
351 }

◆ setErrs() [2/2]

template<size_t N>
void YODA::PointBase< N >::setErrs ( const size_t  i,
const std::pair< double, double > &  e 
)
inlinevirtual

Set a specific error pair along axis i.

Implements YODA::Point.

Definition at line 354 of file Point.h.

354 {
355 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
356 _errs[i] = e;
357 }

◆ setVal() [1/2]

template<size_t N>
void YODA::PointBase< N >::setVal ( const NdVal val)
inline

Set the coordinate vector.

Definition at line 279 of file Point.h.

279 {
280 _val = val;
281 }

References YODA::PointBase< N >::val().

◆ setVal() [2/2]

template<size_t N>
void YODA::PointBase< N >::setVal ( const size_t  i,
const double  val 
)
inlinevirtual

Set a specific coordinate.

Implements YODA::Point.

Definition at line 284 of file Point.h.

284 {
285 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
286 _val[i] = val;
287 }

References YODA::PointBase< N >::val().

◆ transform()

template<size_t N>
void YODA::PointBase< N >::transform ( const size_t  i,
const Trf< N > &  trf 
)
inline

Definition at line 439 of file Point.h.

439 {
440 scale(i, trf);
441 }

References YODA::PointBase< N >::scale().

◆ val()

template<size_t N>
double YODA::PointBase< N >::val ( size_t  i) const
inlinevirtual

Get the value along direction i.

Implements YODA::Point.

Reimplemented in YODA::PointND< 1 >.

Definition at line 273 of file Point.h.

273 {
274 if (i >= N) throw RangeError("Invalid axis int, must be in range 0..dim-1");
275 return _val[i];
276 }

Referenced by YODA::PointBase< N >::PointBase(), YODA::PointBase< N >::PointBase(), YODA::PointBase< N >::set(), YODA::PointBase< N >::set(), YODA::PointBase< N >::set(), YODA::PointBase< N >::setVal(), and YODA::PointBase< N >::setVal().

◆ vals() [1/2]

template<size_t N>
NdVal & YODA::PointBase< N >::vals ( )
inline

Get the coordinate vector.

Definition at line 267 of file Point.h.

267{ return _val; }

Referenced by YODA::operator<(), and YODA::operator==().

◆ vals() [2/2]

template<size_t N>
const NdVal & YODA::PointBase< N >::vals ( ) const
inline

Get the coordinate vector (const version)

Definition at line 270 of file Point.h.

270{ return _val; }

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