yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis  1.7.2
YODA::Point1D Class Reference

A 1D data point to be contained in a Scatter1D. More...

#include <Point1D.h>

Inheritance diagram for YODA::Point1D:
YODA::Point< N >

Public Member Functions

size_t dim ()
 Space dimension of the point. More...
 
Constructors
 Point1D ()
 
 Point1D (double x, double ex=0.0, std::string source="")
 Constructor from values with optional symmetric errors. More...
 
 Point1D (double x, double exminus, double explus, std::string source="")
 Constructor from values with explicit asymmetric errors. More...
 
 Point1D (double x, const std::pair< double, double > &ex, std::string source="")
 Constructor from values with asymmetric errors. More...
 
 Point1D (const Point1D &p)
 Copy constructor. More...
 
Point1Doperator= (const Point1D &p)
 Copy assignment. More...
 
Value accessors
double x () const
 Get x value. More...
 
void setX (double x)
 Set x value. More...
 
x error accessors
Todo:
Uniform "coords" accessor across all Scatters: returning fixed-size tuple?
const std::pair< double, double > & xErrs (std::string source="") const
 Get x-error values. More...
 
double xErrMinus (std::string source="") const
 Get negative x-error value. More...
 
double xErrPlus (std::string source="") const
 Get positive x-error value. More...
 
double xErrAvg (std::string source="") const
 Get average x-error value. More...
 
void setXErrMinus (double exminus, std::string source="")
 Set negative x error. More...
 
void setXErrPlus (double explus, std::string source="")
 Set positive x error. More...
 
void setXErr (double ex, std::string source="")
 Set symmetric x error. More...
 
void setXErrs (double ex, std::string source="")
 Set symmetric x error (alias) More...
 
void setXErrs (double exminus, double explus, std::string source="")
 Set asymmetric x error. More...
 
void setXErrs (const std::pair< double, double > &ex, std::string source="")
 Set asymmetric x error. More...
 
double xMin (std::string source="") const
 Get value minus negative x-error. More...
 
double xMax (std::string source="") const
 Get value plus positive x-error. More...
 
Combined x value and error setters
void setX (double x, double ex, std::string source="")
 Set x value and symmetric error. More...
 
void setX (double x, double exminus, double explus, std::string source="")
 Set x value and asymmetric error. More...
 
void setX (double x, std::pair< double, double > &ex, std::string source="")
 Set x value and asymmetric error. More...
 
void scaleX (double scalex)
 Scaling of x axis. More...
 
Integer axis accessor equivalents
double val (size_t i) const
 Get the point value for direction i. More...
 
void setVal (size_t i, double val)
 Set the point value for direction i. More...
 
const std::map< std::string, std::pair< double, double > > & errMap () const
 Get error map for direction i. More...
 
const std::pair< double, double > & errs (size_t i, std::string source="") const
 Get error values for direction i. More...
 
double errMinus (size_t i, std::string source="") const
 Get negative error value for direction i. More...
 
double errPlus (size_t i, std::string source="") const
 Get positive error value for direction i. More...
 
double errAvg (size_t i, std::string source="") const
 Get average error value for direction i. More...
 
void setErrMinus (size_t i, double eminus, std::string source="")
 Set negative error for direction i. More...
 
void setErrPlus (size_t i, double eplus, std::string source="")
 Set positive error for direction i. More...
 
void setErr (size_t i, double e, std::string source="")
 Set symmetric error for direction i. More...
 
void setErrs (size_t i, double eminus, double eplus, std::string source="")
 Set asymmetric error for direction i. More...
 
void setErrs (size_t i, std::pair< double, double > &e, std::string source="")
 Set asymmetric error for direction i. More...
 
void set (size_t i, double val, double e, std::string source="")
 Set value and symmetric error for direction i. More...
 
void set (size_t i, double val, double eminus, double eplus, std::string source="")
 Set value and asymmetric error for direction i. More...
 
void set (size_t i, double val, std::pair< double, double > &e, std::string source="")
 Set value and asymmetric error for direction i. More...
 
- Public Member Functions inherited from YODA::Point< N >
virtual ~Point ()
 Virtual destructor for inheritance. More...
 
virtual void setErrs (size_t i, double e, std::string source="")
 Set symmetric error for direction i (alias) More...
 
 Point ()
 
 Point (const NdVal &pos)
 Constructor from position values without errors. More...
 
 Point (const NdVal &pos, const NdValPair &errs)
 Constructor from values with a single set of asymmetric errors. More...
 
 Point (const NdVal &pos, const Error< N > &err)
 Constructor from values and a single Error object. More...
 
 Point (const std::vector< double > &pos, const std::vector< Error< N > > &errs)
 Constructor from values and a collection of Error objects. More...
 
void clear ()
 Clear the point values and errors. More...
 
NdValpos ()
 Get the coordinate vector. More...
 
const NdValpos () const
 Get the coordinate vector (const version) More...
 
void setPos (const NdVal &pos)
 Set the coordinate vector. More...
 
Errorserrs ()
 Get error values. More...
 
const Errorserrs () const
 Get error values (const version) More...
 
void setErrs (const Errors &errs)
 Set the error values. More...
 
void scale (const NdVal &scales)
 Uniform scaling. More...
 

Additional Inherited Members

- Public Types inherited from YODA::Point< N >
typedef std::pair< double, double > ValuePair
 
typedef Utils::ndarray< double, N > NdVal
 
typedef Utils::ndarray< std::pair< double, double >, N > NdValPair
 
typedef Utils::sortedvector< Error< N > > Errors
 

Detailed Description

A 1D data point to be contained in a Scatter1D.

Definition at line 18 of file Point1D.h.

Constructor & Destructor Documentation

◆ Point1D() [1/5]

YODA::Point1D::Point1D ( )
inline

Definition at line 25 of file Point1D.h.

25 { }

◆ Point1D() [2/5]

YODA::Point1D::Point1D ( double  x,
double  ex = 0.0,
std::string  source = "" 
)
inline

Constructor from values with optional symmetric errors.

Definition at line 29 of file Point1D.h.

30  : _x(x)
31  {
32  _ex[source] = std::make_pair(ex, ex);
33  }
double x() const
Get x value.
Definition: Point1D.h:78

◆ Point1D() [3/5]

YODA::Point1D::Point1D ( double  x,
double  exminus,
double  explus,
std::string  source = "" 
)
inline

Constructor from values with explicit asymmetric errors.

Definition at line 37 of file Point1D.h.

38  : _x(x)
39  {
40  _ex[source] = std::make_pair(exminus, explus);
41  }
double x() const
Get x value.
Definition: Point1D.h:78

◆ Point1D() [4/5]

YODA::Point1D::Point1D ( double  x,
const std::pair< double, double > &  ex,
std::string  source = "" 
)
inline

Constructor from values with asymmetric errors.

Definition at line 45 of file Point1D.h.

46  : _x(x)
47  {
48  _ex[source] = ex;
49  }
double x() const
Get x value.
Definition: Point1D.h:78

◆ Point1D() [5/5]

YODA::Point1D::Point1D ( const Point1D p)
inline

Copy constructor.

Definition at line 53 of file Point1D.h.

54  : _x(p._x), _ex(p._ex)
55  { }

Member Function Documentation

◆ dim()

size_t YODA::Point1D::dim ( )
inlinevirtual

Space dimension of the point.

Implements YODA::Point< N >.

Definition at line 71 of file Point1D.h.

71 { return 1; }

◆ errAvg()

double YODA::Point1D::errAvg ( size_t  i,
std::string  source = "" 
) const
inlinevirtual

Get average error value for direction i.

Implements YODA::Point< N >.

Definition at line 237 of file Point1D.h.

References xErrAvg().

237  {
238  if (i != 1) throw RangeError("Invalid axis int, must be in range 1..dim");
239  return xErrAvg(source);
240  }
double xErrAvg(std::string source="") const
Get average x-error value.
Definition: Point1D.h:110

◆ errMap()

const std::map< std::string, std::pair<double,double> >& YODA::Point1D::errMap ( ) const
inlinevirtual

Get error map for direction i.

Implements YODA::Point< N >.

Definition at line 217 of file Point1D.h.

Referenced by YODA::Scatter1D::variations().

217  {
218  return _ex;
219  }

◆ errMinus()

double YODA::Point1D::errMinus ( size_t  i,
std::string  source = "" 
) const
inlinevirtual

Get negative error value for direction i.

Implements YODA::Point< N >.

Definition at line 227 of file Point1D.h.

References xErrMinus().

227  {
228  if (i != 1) throw RangeError("Invalid axis int, must be in range 1..dim");
229  return xErrMinus(source);
230  }
double xErrMinus(std::string source="") const
Get negative x-error value.
Definition: Point1D.h:98

◆ errPlus()

double YODA::Point1D::errPlus ( size_t  i,
std::string  source = "" 
) const
inlinevirtual

Get positive error value for direction i.

Implements YODA::Point< N >.

Definition at line 232 of file Point1D.h.

References xErrPlus().

232  {
233  if (i != 1) throw RangeError("Invalid axis int, must be in range 1..dim");
234  return xErrPlus(source);
235  }
double xErrPlus(std::string source="") const
Get positive x-error value.
Definition: Point1D.h:104

◆ errs()

const std::pair<double,double>& YODA::Point1D::errs ( size_t  i,
std::string  source = "" 
) const
inlinevirtual

Get error values for direction i.

Implements YODA::Point< N >.

Definition at line 222 of file Point1D.h.

References xErrs().

222  {
223  if (i != 1) throw RangeError("Invalid axis int, must be in range 1..dim");
224  return xErrs(source);
225  }
const std::pair< double, double > & xErrs(std::string source="") const
Get x-error values.
Definition: Point1D.h:92

◆ operator=()

Point1D& YODA::Point1D::operator= ( const Point1D p)
inline

Copy assignment.

Definition at line 59 of file Point1D.h.

59  {
60  _x = p._x;
61  _ex = p._ex;
62  return *this;
63  }

◆ scaleX()

void YODA::Point1D::scaleX ( double  scalex)
inline

Scaling of x axis.

Definition at line 192 of file Point1D.h.

References setX(), setXErrs(), x(), xErrMinus(), and xErrPlus().

192  {
193  setX(x()*scalex);
194  for (const auto &source : _ex){
195  setXErrs(xErrMinus()*scalex, xErrPlus()*scalex, source.first);
196  }
197  }
double x() const
Get x value.
Definition: Point1D.h:78
double xErrMinus(std::string source="") const
Get negative x-error value.
Definition: Point1D.h:98
void setXErrs(double ex, std::string source="")
Set symmetric x error (alias)
Definition: Point1D.h:134
double xErrPlus(std::string source="") const
Get positive x-error value.
Definition: Point1D.h:104
void setX(double x)
Set x value.
Definition: Point1D.h:81

◆ set() [1/3]

void YODA::Point1D::set ( size_t  i,
double  val,
double  e,
std::string  source = "" 
)
inlinevirtual

Set value and symmetric error for direction i.

Implements YODA::Point< N >.

Definition at line 270 of file Point1D.h.

References setX().

270  {
271  if (i != 1) throw RangeError("Invalid axis int, must be in range 1..dim");
272  setX(val, e, source);
273  }
double val(size_t i) const
Get the point value for direction i.
Definition: Point1D.h:206
void setX(double x)
Set x value.
Definition: Point1D.h:81

◆ set() [2/3]

void YODA::Point1D::set ( size_t  i,
double  val,
double  eminus,
double  eplus,
std::string  source = "" 
)
inlinevirtual

Set value and asymmetric error for direction i.

Implements YODA::Point< N >.

Definition at line 275 of file Point1D.h.

References setX().

275  {
276  if (i != 1) throw RangeError("Invalid axis int, must be in range 1..dim");
277  setX(val, eminus, eplus, source);
278  }
double val(size_t i) const
Get the point value for direction i.
Definition: Point1D.h:206
void setX(double x)
Set x value.
Definition: Point1D.h:81

◆ set() [3/3]

void YODA::Point1D::set ( size_t  i,
double  val,
std::pair< double, double > &  e,
std::string  source = "" 
)
inlinevirtual

Set value and asymmetric error for direction i.

Implements YODA::Point< N >.

Definition at line 280 of file Point1D.h.

References setX().

280  {
281  if (i != 1) throw RangeError("Invalid axis int, must be in range 1..dim");
282  setX(val, e, source);
283  }
double val(size_t i) const
Get the point value for direction i.
Definition: Point1D.h:206
void setX(double x)
Set x value.
Definition: Point1D.h:81

◆ setErr()

void YODA::Point1D::setErr ( size_t  i,
double  e,
std::string  source = "" 
)
inlinevirtual

Set symmetric error for direction i.

Implements YODA::Point< N >.

Definition at line 254 of file Point1D.h.

References setXErr().

254  {
255  if (i != 1) throw RangeError("Invalid axis int, must be in range 1..dim");
256  setXErr(e, source);
257  }
void setXErr(double ex, std::string source="")
Set symmetric x error.
Definition: Point1D.h:128

◆ setErrMinus()

void YODA::Point1D::setErrMinus ( size_t  i,
double  eminus,
std::string  source = "" 
)
inlinevirtual

Set negative error for direction i.

Implements YODA::Point< N >.

Definition at line 243 of file Point1D.h.

References setXErrMinus().

243  {
244  if (i != 1) throw RangeError("Invalid axis int, must be in range 1..dim");
245  setXErrMinus(eminus, source);
246  }
void setXErrMinus(double exminus, std::string source="")
Set negative x error.
Definition: Point1D.h:116

◆ setErrPlus()

void YODA::Point1D::setErrPlus ( size_t  i,
double  eplus,
std::string  source = "" 
)
inlinevirtual

Set positive error for direction i.

Implements YODA::Point< N >.

Definition at line 248 of file Point1D.h.

References setXErrPlus().

248  {
249  if (i != 1) throw RangeError("Invalid axis int, must be in range 1..dim");
250  setXErrPlus(eplus, source);
251  }
void setXErrPlus(double explus, std::string source="")
Set positive x error.
Definition: Point1D.h:122

◆ setErrs() [1/2]

void YODA::Point1D::setErrs ( size_t  i,
double  eminus,
double  eplus,
std::string  source = "" 
)
inlinevirtual

Set asymmetric error for direction i.

Implements YODA::Point< N >.

Definition at line 259 of file Point1D.h.

References setXErrs().

259  {
260  if (i != 1) throw RangeError("Invalid axis int, must be in range 1..dim");
261  setXErrs(eminus, eplus, source);
262  }
void setXErrs(double ex, std::string source="")
Set symmetric x error (alias)
Definition: Point1D.h:134

◆ setErrs() [2/2]

void YODA::Point1D::setErrs ( size_t  i,
std::pair< double, double > &  e,
std::string  source = "" 
)
inlinevirtual

Set asymmetric error for direction i.

Implements YODA::Point< N >.

Definition at line 264 of file Point1D.h.

References setXErrs().

264  {
265  if (i != 1) throw RangeError("Invalid axis int, must be in range 1..dim");
266  setXErrs(e, source);
267  }
void setXErrs(double ex, std::string source="")
Set symmetric x error (alias)
Definition: Point1D.h:134

◆ setVal()

void YODA::Point1D::setVal ( size_t  i,
double  val 
)
inlinevirtual

Set the point value for direction i.

Implements YODA::Point< N >.

Definition at line 211 of file Point1D.h.

References setX().

211  {
212  if (i != 1) throw RangeError("Invalid axis int, must be in range 1..dim");
213  setX(val);
214  }
double val(size_t i) const
Get the point value for direction i.
Definition: Point1D.h:206
void setX(double x)
Set x value.
Definition: Point1D.h:81

◆ setX() [1/4]

void YODA::Point1D::setX ( double  x)
inline

Set x value.

Definition at line 81 of file Point1D.h.

References x().

Referenced by YODA::efficiency(), scaleX(), set(), setVal(), setX(), and YODA::transformX().

81 { _x = x; }
double x() const
Get x value.
Definition: Point1D.h:78

◆ setX() [2/4]

void YODA::Point1D::setX ( double  x,
double  ex,
std::string  source = "" 
)
inline

Set x value and symmetric error.

Definition at line 168 of file Point1D.h.

References setX(), and setXErr().

168  {
169  setX(x);
170  setXErr(ex, source);
171  }
double x() const
Get x value.
Definition: Point1D.h:78
void setXErr(double ex, std::string source="")
Set symmetric x error.
Definition: Point1D.h:128
void setX(double x)
Set x value.
Definition: Point1D.h:81

◆ setX() [3/4]

void YODA::Point1D::setX ( double  x,
double  exminus,
double  explus,
std::string  source = "" 
)
inline

Set x value and asymmetric error.

Definition at line 174 of file Point1D.h.

References setX(), and setXErrs().

174  {
175  setX(x);
176  setXErrs(exminus, explus, source);
177  }
double x() const
Get x value.
Definition: Point1D.h:78
void setXErrs(double ex, std::string source="")
Set symmetric x error (alias)
Definition: Point1D.h:134
void setX(double x)
Set x value.
Definition: Point1D.h:81

◆ setX() [4/4]

void YODA::Point1D::setX ( double  x,
std::pair< double, double > &  ex,
std::string  source = "" 
)
inline

Set x value and asymmetric error.

Definition at line 180 of file Point1D.h.

References setX(), and setXErrs().

180  {
181  setX(x);
182  setXErrs(ex, source);
183  }
double x() const
Get x value.
Definition: Point1D.h:78
void setXErrs(double ex, std::string source="")
Set symmetric x error (alias)
Definition: Point1D.h:134
void setX(double x)
Set x value.
Definition: Point1D.h:81

◆ setXErr()

void YODA::Point1D::setXErr ( double  ex,
std::string  source = "" 
)
inline

Set symmetric x error.

Definition at line 128 of file Point1D.h.

References setXErrMinus(), and setXErrPlus().

Referenced by setErr(), setX(), and setXErrs().

128  {
129  setXErrMinus(ex, source);
130  setXErrPlus(ex, source);
131  }
void setXErrMinus(double exminus, std::string source="")
Set negative x error.
Definition: Point1D.h:116
void setXErrPlus(double explus, std::string source="")
Set positive x error.
Definition: Point1D.h:122

◆ setXErrMinus()

void YODA::Point1D::setXErrMinus ( double  exminus,
std::string  source = "" 
)
inline

Set negative x error.

Definition at line 116 of file Point1D.h.

Referenced by setErrMinus(), setXErr(), setXErrs(), and YODA::transformX().

116  {
117  if (!_ex.count(source)) _ex[source] = std::make_pair(0.,0.);
118  _ex.at(source).first = exminus;
119  }

◆ setXErrPlus()

void YODA::Point1D::setXErrPlus ( double  explus,
std::string  source = "" 
)
inline

Set positive x error.

Definition at line 122 of file Point1D.h.

Referenced by setErrPlus(), setXErr(), setXErrs(), and YODA::transformX().

122  {
123  if (!_ex.count(source)) _ex[source] = std::make_pair(0.,0.);
124  _ex.at(source).second = explus;
125  }

◆ setXErrs() [1/3]

void YODA::Point1D::setXErrs ( double  ex,
std::string  source = "" 
)
inline

Set symmetric x error (alias)

Definition at line 134 of file Point1D.h.

References setXErr().

Referenced by scaleX(), setErrs(), and setX().

134  {
135  setXErr(ex, source);
136  }
void setXErr(double ex, std::string source="")
Set symmetric x error.
Definition: Point1D.h:128

◆ setXErrs() [2/3]

void YODA::Point1D::setXErrs ( double  exminus,
double  explus,
std::string  source = "" 
)
inline

Set asymmetric x error.

Definition at line 139 of file Point1D.h.

References setXErrMinus(), and setXErrPlus().

139  {
140  setXErrMinus(exminus, source);
141  setXErrPlus(explus, source);
142  }
void setXErrMinus(double exminus, std::string source="")
Set negative x error.
Definition: Point1D.h:116
void setXErrPlus(double explus, std::string source="")
Set positive x error.
Definition: Point1D.h:122

◆ setXErrs() [3/3]

void YODA::Point1D::setXErrs ( const std::pair< double, double > &  ex,
std::string  source = "" 
)
inline

Set asymmetric x error.

Definition at line 145 of file Point1D.h.

145  {
146  _ex[source] = ex;
147  }

◆ val()

double YODA::Point1D::val ( size_t  i) const
inlinevirtual

Get the point value for direction i.

Implements YODA::Point< N >.

Definition at line 206 of file Point1D.h.

References x().

206  {
207  if (i == 0 || i > 1) throw RangeError("Invalid axis int, must be in range 1..dim");
208  return x();
209  }
double x() const
Get x value.
Definition: Point1D.h:78

◆ x()

double YODA::Point1D::x ( ) const
inline

Get x value.

Definition at line 78 of file Point1D.h.

Referenced by YODA::operator<(), YODA::operator==(), scaleX(), setX(), YODA::transformX(), and val().

78 { return _x; }

◆ xErrAvg()

double YODA::Point1D::xErrAvg ( std::string  source = "") const
inline

Get average x-error value.

Definition at line 110 of file Point1D.h.

Referenced by errAvg().

110  {
111  if (!_ex.count(source)) throw RangeError("xErrs has no such key: "+source);
112  return (_ex.at(source).first + _ex.at(source).second)/2.0;
113  }

◆ xErrMinus()

double YODA::Point1D::xErrMinus ( std::string  source = "") const
inline

Get negative x-error value.

Definition at line 98 of file Point1D.h.

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

98  {
99  if (!_ex.count(source)) throw RangeError("xErrs has no such key: "+source);
100  return _ex.at(source).first;
101  }

◆ xErrPlus()

double YODA::Point1D::xErrPlus ( std::string  source = "") const
inline

Get positive x-error value.

Definition at line 104 of file Point1D.h.

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

104  {
105  if (!_ex.count(source)) throw RangeError("xErrs has no such key: "+source);
106  return _ex.at(source).second;
107  }

◆ xErrs()

const std::pair<double,double>& YODA::Point1D::xErrs ( std::string  source = "") const
inline

Get x-error values.

Definition at line 92 of file Point1D.h.

Referenced by errs().

92  {
93  if (!_ex.count(source)) throw RangeError("xErrs has no such key: "+source);
94  return _ex.at(source);
95  }

◆ xMax()

double YODA::Point1D::xMax ( std::string  source = "") const
inline

Get value plus positive x-error.

Definition at line 156 of file Point1D.h.

Referenced by YODA::transformX().

156  {
157  if (!_ex.count(source)) throw RangeError("xErrs has no such key: "+source);
158  return _x + _ex.at(source).second;
159  }

◆ xMin()

double YODA::Point1D::xMin ( std::string  source = "") const
inline

Get value minus negative x-error.

Definition at line 150 of file Point1D.h.

Referenced by YODA::transformX().

150  {
151  if (!_ex.count(source)) throw RangeError("xErrs has no such key: "+source);
152  return _x - _ex.at(source).first;
153  }

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