YODA is hosted by Hepforge, IPPP Durham
YODA::Scatter1D Class Reference

A very generic data type which is just a collection of 1D data points with errors. More...

#include <Scatter1D.h>

Inheritance diagram for YODA::Scatter1D:
YODA::AnalysisObject

Public Types

typedef Point1D Point
 Type of the native Point1D collection. More...
 
typedef Utils::sortedvector
< Point1D
Points
 
- Public Types inherited from YODA::AnalysisObject
typedef std::map< std::string,
std::string > 
Annotations
 Collection type for annotations, as a string-string map. More...
 

Public Member Functions

bool operator== (const Scatter1D &other)
 Equality operator. More...
 
bool operator!= (const Scatter1D &other)
 Non-equality operator. More...
 
Constructors
 Scatter1D (const std::string &path="", const std::string &title="")
 Empty constructor. More...
 
 Scatter1D (const Points &points, const std::string &path="", const std::string &title="")
 Constructor from a set of points. More...
 
 Scatter1D (const std::vector< double > &x, const std::string &path="", const std::string &title="")
 Constructor from a vector of x values with no errors. More...
 
 Scatter1D (const std::vector< double > &x, const std::vector< double > &ex, const std::string &path="", const std::string &title="")
 Constructor from vectors of x values with symmetric errors. More...
 
 Scatter1D (const std::vector< double > &x, const std::vector< std::pair< double, double > > &ex, const std::string &path="", const std::string &title="")
 Constructor from x values with asymmetric errors. More...
 
 Scatter1D (const std::vector< double > &x, const std::vector< double > &y, const std::vector< double > &exminus, const std::vector< double > &explus, const std::vector< double > &eyminus, const std::vector< double > &eyplus, const std::string &path="", const std::string &title="")
 Constructor from values with completely explicit asymmetric errors. More...
 
 Scatter1D (const Scatter1D &s1, const std::string &path="")
 
Scatter1Doperator= (const Scatter1D &s1)
 Assignment operator. More...
 
Scatter1D clone () const
 Make a copy on the stack. More...
 
Scatter1Dnewclone () const
 Make a copy on the heap, via 'new'. More...
 
Modifiers
void reset ()
 Clear all points. More...
 
void scaleX (double scalex)
 Scaling of x axis. More...
 
Point accessors
size_t numPoints () const
 Number of points in the scatter. More...
 
Pointspoints ()
 Get the collection of points (non-const) More...
 
const Pointspoints () const
 Get the collection of points (const) More...
 
Point1Dpoint (size_t index)
 Get a reference to the point with index index (non-const) More...
 
const Point1Dpoint (size_t index) const
 Get a reference to the point with index index (const) More...
 
Point inserters
void addPoint (const Point1D &pt)
 Insert a new point. More...
 
void addPoint (double x)
 Insert a new point, defined as the x value and no errors. More...
 
void addPoint (double x, double ex)
 Insert a new point, defined as the x value and symmetric errors. More...
 
void addPoint (double x, const std::pair< double, double > &ex)
 Insert a new point, defined as the x value and an asymmetric error pair. More...
 
void addPoint (double x, double exminus, double explus)
 Insert a new point, defined as the x value and explicit asymmetric errors. More...
 
void addPoints (const Points &pts)
 Insert a collection of new points. More...
 
Combining sets of scatter points
void combineWith (const Scatter1D &other)
 
void combineWith (const std::vector< Scatter1D > &others)
 
- Public Member Functions inherited from YODA::AnalysisObject
 AnalysisObject ()
 Default constructor. More...
 
 AnalysisObject (const std::string &type, const std::string &path, const std::string &title="")
 Constructor giving a type, a path and an optional title. More...
 
 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. More...
 
virtual ~AnalysisObject ()
 Default destructor. More...
 
virtual AnalysisObjectoperator= (const AnalysisObject &ao)
 Default copy assignment operator. More...
 
const std::vector< std::string > annotations () const
 Get all the annotation names. More...
 
bool hasAnnotation (const std::string &name) const
 Check if an annotation is defined. More...
 
const std::string & annotation (const std::string &name) const
 Get an annotation by name (as a string) More...
 
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. More...
 
template<typename T >
const T annotation (const std::string &name) const
 Get an annotation by name (copied to another type) More...
 
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. More...
 
template<typename T >
void setAnnotation (const std::string &name, const T &value)
 Add or set an annotation by name. More...
 
void setAnnotations (const Annotations &anns)
 Set all annotations at once. More...
 
template<typename T >
void addAnnotation (const std::string &name, const T &value)
 Add or set an annotation by name. More...
 
void rmAnnotation (const std::string &name)
 Delete an annotation by name. More...
 
void clearAnnotations ()
 Delete an annotation by name. More...
 
const std::string title () const
 
void setTitle (const std::string &title)
 Set the AO title. More...
 
const std::string path () const
 
void setPath (const std::string &path)
 Set the AO path. More...
 
virtual std::string type () const
 Get name of the analysis object type, for persistency. More...
 

Detailed Description

A very generic data type which is just a collection of 1D data points with errors.

Definition at line 22 of file Scatter1D.h.

Member Typedef Documentation

Type of the native Point1D collection.

Definition at line 26 of file Scatter1D.h.

typedef Utils::sortedvector<Point1D> YODA::Scatter1D::Points

Definition at line 27 of file Scatter1D.h.

Constructor & Destructor Documentation

YODA::Scatter1D::Scatter1D ( const std::string &  path = "",
const std::string &  title = "" 
)
inline

Empty constructor.

Definition at line 34 of file Scatter1D.h.

Referenced by clone(), and newclone().

35  : AnalysisObject("Scatter1D", path, title)
36  { }
AnalysisObject()
Default constructor.
const std::string path() const
const std::string title() const
YODA::Scatter1D::Scatter1D ( const Points points,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from a set of points.

Definition at line 40 of file Scatter1D.h.

42  : AnalysisObject("Scatter1D", path, title),
43  _points(points)
44  { }
AnalysisObject()
Default constructor.
const std::string path() const
Points & points()
Get the collection of points (non-const)
Definition: Scatter1D.h:147
const std::string title() const
YODA::Scatter1D::Scatter1D ( const std::vector< double > &  x,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from a vector of x values with no errors.

Definition at line 48 of file Scatter1D.h.

References addPoint().

50  : AnalysisObject("Scatter1D", path, title)
51  {
52  for (size_t i = 0; i < x.size(); ++i) addPoint(x[i]);
53  }
AnalysisObject()
Default constructor.
void addPoint(const Point1D &pt)
Insert a new point.
Definition: Scatter1D.h:178
const std::string path() const
const std::string title() const
YODA::Scatter1D::Scatter1D ( const std::vector< double > &  x,
const std::vector< double > &  ex,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from vectors of x values with symmetric errors.

Definition at line 57 of file Scatter1D.h.

References addPoint().

59  : AnalysisObject("Scatter1D", path, title)
60  {
61  if (x.size() != ex.size()) throw UserError("x and ex vectors must have same length");
62  for (size_t i = 0; i < x.size(); ++i) addPoint(x[i], ex[i]);
63  }
AnalysisObject()
Default constructor.
void addPoint(const Point1D &pt)
Insert a new point.
Definition: Scatter1D.h:178
const std::string path() const
const std::string title() const
YODA::Scatter1D::Scatter1D ( const std::vector< double > &  x,
const std::vector< std::pair< double, double > > &  ex,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from x values with asymmetric errors.

Definition at line 66 of file Scatter1D.h.

References addPoint().

68  : AnalysisObject("Scatter1D", path, title)
69  {
70  if (x.size() != ex.size()) throw UserError("x and ex vectors must have same length");
71  for (size_t i = 0; i < x.size(); ++i) addPoint(Point1D(x[i], ex[i]));
72  }
AnalysisObject()
Default constructor.
void addPoint(const Point1D &pt)
Insert a new point.
Definition: Scatter1D.h:178
const std::string path() const
const std::string title() const
YODA::Scatter1D::Scatter1D ( const std::vector< double > &  x,
const std::vector< double > &  y,
const std::vector< double > &  exminus,
const std::vector< double > &  explus,
const std::vector< double > &  eyminus,
const std::vector< double > &  eyplus,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from values with completely explicit asymmetric errors.

Definition at line 76 of file Scatter1D.h.

References addPoint().

82  : AnalysisObject("Scatter1D", path, title)
83  {
84  if (x.size() != exminus.size()) throw UserError("x and ex vectors must have same length");
85  if (exminus.size() != explus.size()) throw UserError("ex plus and minus vectors must have same length");
86  for (size_t i = 0; i < x.size(); ++i) addPoint(Point1D(x[i], exminus[i], explus[i]));
87  }
AnalysisObject()
Default constructor.
void addPoint(const Point1D &pt)
Insert a new point.
Definition: Scatter1D.h:178
const std::string path() const
const std::string title() const
YODA::Scatter1D::Scatter1D ( const Scatter1D s1,
const std::string &  path = "" 
)
inline

Copy constructor with optional new path

Todo:
Also allow title setting from the constructor?

Definition at line 92 of file Scatter1D.h.

93  : AnalysisObject("Scatter1D", (path.size() == 0) ? s1.path() : path, s1, s1.title()),
94  _points(s1._points)
95  { }
AnalysisObject()
Default constructor.
const std::string path() const

Member Function Documentation

void YODA::Scatter1D::addPoint ( const Point1D pt)
inline

Insert a new point.

Definition at line 178 of file Scatter1D.h.

Referenced by addPoints(), YODA::divide(), YODA::mkScatter(), and Scatter1D().

178  {
179  _points.insert(pt);
180  }
void YODA::Scatter1D::addPoint ( double  x)
inline

Insert a new point, defined as the x value and no errors.

Definition at line 183 of file Scatter1D.h.

183  {
184  _points.insert(Point1D(x));
185  }
void YODA::Scatter1D::addPoint ( double  x,
double  ex 
)
inline

Insert a new point, defined as the x value and symmetric errors.

Definition at line 188 of file Scatter1D.h.

188  {
189  _points.insert(Point1D(x, ex));
190  }
void YODA::Scatter1D::addPoint ( double  x,
const std::pair< double, double > &  ex 
)
inline

Insert a new point, defined as the x value and an asymmetric error pair.

Definition at line 193 of file Scatter1D.h.

193  {
194  _points.insert(Point1D(x, ex));
195  }
void YODA::Scatter1D::addPoint ( double  x,
double  exminus,
double  explus 
)
inline

Insert a new point, defined as the x value and explicit asymmetric errors.

Definition at line 198 of file Scatter1D.h.

198  {
199  _points.insert(Point1D(x, exminus, explus));
200  }
void YODA::Scatter1D::addPoints ( const Points pts)
inline

Insert a collection of new points.

Definition at line 203 of file Scatter1D.h.

References addPoint().

Referenced by combineWith().

203  {
204  BOOST_FOREACH (const Point1D& pt, pts) addPoint(pt);
205  }
void addPoint(const Point1D &pt)
Insert a new point.
Definition: Scatter1D.h:178
Scatter1D YODA::Scatter1D::clone ( ) const
inline

Make a copy on the stack.

Definition at line 106 of file Scatter1D.h.

References Scatter1D().

106  {
107  return Scatter1D(*this);
108  }
Scatter1D(const std::string &path="", const std::string &title="")
Empty constructor.
Definition: Scatter1D.h:34
void YODA::Scatter1D::combineWith ( const Scatter1D other)
inline
Todo:
Better name? Make this the add operation?

Definition at line 214 of file Scatter1D.h.

References addPoints(), and points().

Referenced by YODA::combine(), and combineWith().

214  {
215  addPoints(other.points());
216  }
void addPoints(const Points &pts)
Insert a collection of new points.
Definition: Scatter1D.h:203
void YODA::Scatter1D::combineWith ( const std::vector< Scatter1D > &  others)
inline
Todo:

Better name? Make this the add operation?

Convert/extend to accept a Range or generic

Definition at line 220 of file Scatter1D.h.

References combineWith().

220  {
221  BOOST_FOREACH (const Scatter1D& s, others) combineWith(s);
222  }
Scatter1D(const std::string &path="", const std::string &title="")
Empty constructor.
Definition: Scatter1D.h:34
void combineWith(const Scatter1D &other)
Definition: Scatter1D.h:214
Scatter1D* YODA::Scatter1D::newclone ( ) const
inlinevirtual

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

Implements YODA::AnalysisObject.

Definition at line 111 of file Scatter1D.h.

References Scatter1D().

111  {
112  return new Scatter1D(*this);
113  }
Scatter1D(const std::string &path="", const std::string &title="")
Empty constructor.
Definition: Scatter1D.h:34
size_t YODA::Scatter1D::numPoints ( ) const
inline

Number of points in the scatter.

Definition at line 141 of file Scatter1D.h.

Referenced by YODA::efficiency(), point(), and YODA::transformX().

141  {
142  return _points.size();
143  }
bool YODA::Scatter1D::operator!= ( const Scatter1D other)
inline

Non-equality operator.

Definition at line 233 of file Scatter1D.h.

References operator==().

233  {
234  return ! operator == (other);
235  }
bool operator==(const Scatter1D &other)
Equality operator.
Definition: Scatter1D.h:228
Scatter1D& YODA::Scatter1D::operator= ( const Scatter1D s1)
inline

Assignment operator.

Definition at line 99 of file Scatter1D.h.

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

99  {
100  AnalysisObject::operator = (s1); //< AO treatment of paths etc.
101  _points = s1._points;
102  return *this;
103  }
virtual AnalysisObject & operator=(const AnalysisObject &ao)
Default copy assignment operator.
bool YODA::Scatter1D::operator== ( const Scatter1D other)
inline

Equality operator.

Definition at line 228 of file Scatter1D.h.

Referenced by operator!=().

228  {
229  return _points == other._points;
230  }
Point1D& YODA::Scatter1D::point ( size_t  index)
inline

Get a reference to the point with index index (non-const)

Definition at line 159 of file Scatter1D.h.

References numPoints().

Referenced by YODA::efficiency(), and YODA::transformX().

159  {
160  if (index >= numPoints()) throw RangeError("There is no point with this index");
161  return _points.at(index);
162  }
size_t numPoints() const
Number of points in the scatter.
Definition: Scatter1D.h:141
const Point1D& YODA::Scatter1D::point ( size_t  index) const
inline

Get a reference to the point with index index (const)

Definition at line 166 of file Scatter1D.h.

References numPoints().

166  {
167  if (index >= numPoints()) throw RangeError("There is no point with this index");
168  return _points.at(index);
169  }
size_t numPoints() const
Number of points in the scatter.
Definition: Scatter1D.h:141
Points& YODA::Scatter1D::points ( )
inline

Get the collection of points (non-const)

Definition at line 147 of file Scatter1D.h.

Referenced by combineWith(), YODA::WriterYODA::writeScatter1D(), and YODA::WriterFLAT::writeScatter1D().

147  {
148  return _points;
149  }
const Points& YODA::Scatter1D::points ( ) const
inline

Get the collection of points (const)

Definition at line 153 of file Scatter1D.h.

153  {
154  return _points;
155  }
void YODA::Scatter1D::reset ( )
inlinevirtual

Clear all points.

Implements YODA::AnalysisObject.

Definition at line 122 of file Scatter1D.h.

122  {
123  _points.clear();
124  }
void YODA::Scatter1D::scaleX ( double  scalex)
inline

Scaling of x axis.

Definition at line 127 of file Scatter1D.h.

References YODA::Point1D::scaleX().

127  {
128  BOOST_FOREACH (Point1D& p, _points) p.scaleX(scalex);
129  }
void scaleX(double scalex)
Scaling of x axis.
Definition: Scatter1D.h:127

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