YODA is hosted by Hepforge, IPPP Durham
YODA::Scatter< N > Class Template Reference

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

#include <ScatterND.h>

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

Public Types

typedef Utils::ndarray< double, N > NdVal
 
typedef Utils::ndarray
< std::pair< double, double >
, N > 
NdValPair
 
typedef Utils::sortedvector
< Point< N > > 
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

Constructors
 Scatter (const std::string &path="", const std::string &title="")
 Empty constructor. More...
 
 Scatter (const Points &points, const std::string &path="", const std::string &title="")
 Constructor from a set of points. More...
 
 Scatter (const std::vector< NdVal > &positions, const std::string &path="", const std::string &title="")
 Constructor from a vector of position values with no errors. More...
 
 Scatter (const std::vector< NdVal > &positions, const std::vector< NdVal > &errors, const std::string &path="", const std::string &title="")
 Constructor from vectors of values for positions and a single set of symmetric errors. More...
 
 Scatter (const Scatter< N > &s, const std::string &path="")
 Copy constructor with optional new path. More...
 
Scatter< N > & operator= (const Scatter< N > &s)
 Assignment operator. More...
 
Scatter< N > clone () const
 Make a copy on the stack. More...
 
Scatter< N > * newclone () const
 Make a copy on the heap, via 'new'. More...
 
Modifiers
void reset ()
 Clear all points. More...
 
void scale (const NdVal &scales)
 Scaling. More...
 
Point accessors
size_t numPoints () const
 Number of points in the scatter. More...
 
Pointspoints ()
 Get the collection of points. More...
 
const Pointspoints () const
 Get the collection of points (const version) More...
 
Point< N > & point (size_t index)
 Get a reference to the point with index index. More...
 
const Point< N > & point (size_t index) const
 Get the point with index index (const version) More...
 
Point inserters
Scatter< N > & addPoint (const Point< N > &pt)
 Insert a new point. More...
 
Scatter< N > & addPoint (const NdVal &pos)
 Insert a new point, from a position array. More...
 
Scatter< N > & addPoints (Points pts)
 Insert a collection of new points. More...
 
Combining sets of scatter points
Scatter< N > & combineWith (const Scatter< N > &other)
 
Scatter< N > & combineWith (const std::vector< Scatter< N > > &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

template<int N>
class YODA::Scatter< N >

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

Definition at line 23 of file ScatterND.h.

Member Typedef Documentation

template<int N>
typedef Utils::ndarray<double, N> YODA::Scatter< N >::NdVal

Definition at line 27 of file ScatterND.h.

template<int N>
typedef Utils::ndarray<std::pair<double,double>, N> YODA::Scatter< N >::NdValPair

Definition at line 28 of file ScatterND.h.

template<int N>
typedef Utils::sortedvector< Point<N> > YODA::Scatter< N >::Points

Definition at line 29 of file ScatterND.h.

Constructor & Destructor Documentation

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

Empty constructor.

Definition at line 36 of file ScatterND.h.

37  : AnalysisObject("Scatter", path, title)
38  { }
AnalysisObject()
Default constructor.
const std::string path() const
const std::string title() const
template<int N>
YODA::Scatter< N >::Scatter ( const Points points,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from a set of points.

Definition at line 42 of file ScatterND.h.

44  : AnalysisObject("Scatter", path, title),
45  _points(points)
46  { }
AnalysisObject()
Default constructor.
Points & points()
Get the collection of points.
Definition: ScatterND.h:150
const std::string path() const
const std::string title() const
template<int N>
YODA::Scatter< N >::Scatter ( const std::vector< NdVal > &  positions,
const std::string &  path = "",
const std::string &  title = "" 
)
inline

Constructor from a vector of position values with no errors.

Definition at line 50 of file ScatterND.h.

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

52  : AnalysisObject("Scatter", path, title)
53  {
54  for (size_t i = 0; i < positions.size(); ++i) {
55  addPoint(Point<N>(positions[i]));
56  }
57  }
Scatter< N > & addPoint(const Point< N > &pt)
Insert a new point.
Definition: ScatterND.h:179
AnalysisObject()
Default constructor.
const std::string path() const
const std::string title() const
template<int N>
YODA::Scatter< N >::Scatter ( const std::vector< NdVal > &  positions,
const std::vector< NdVal > &  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 61 of file ScatterND.h.

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

64  : AnalysisObject("Scatter", path, title)
65  {
66  assert(positions.size() == errors.size());
67  for (size_t i = 0; i < positions.size(); ++i) {
68  addPoint(Point<N>(positions[i], errors[i]));
69  }
70  }
Scatter< N > & addPoint(const Point< N > &pt)
Insert a new point.
Definition: ScatterND.h:179
AnalysisObject()
Default constructor.
const std::string path() const
const std::string title() const
template<int N>
YODA::Scatter< N >::Scatter ( const Scatter< N > &  s,
const std::string &  path = "" 
)
inline

Copy constructor with optional new path.

Definition at line 92 of file ScatterND.h.

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

Member Function Documentation

template<int N>
Scatter<N>& YODA::Scatter< N >::addPoint ( const Point< N > &  pt)
inline

Insert a new point.

Definition at line 179 of file ScatterND.h.

Referenced by YODA::Scatter< N >::addPoints(), and YODA::Scatter< N >::Scatter().

179  {
180  _points.insert(pt);
181  return *this;
182  }
template<int N>
Scatter<N>& YODA::Scatter< N >::addPoint ( const NdVal pos)
inline

Insert a new point, from a position array.

Definition at line 185 of file ScatterND.h.

185  {
186  _points.insert(Point<N>(pos));
187  return *this;
188  }
template<int N>
Scatter<N>& YODA::Scatter< N >::addPoints ( Points  pts)
inline

Insert a collection of new points.

Todo:
More addPoint combinations with arrays for errors

Definition at line 193 of file ScatterND.h.

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

Referenced by YODA::Scatter< N >::combineWith().

193  {
194  BOOST_FOREACH (const Point<N>& pt, pts) {
195  addPoint(pt);
196  }
197  return *this;
198  }
Scatter< N > & addPoint(const Point< N > &pt)
Insert a new point.
Definition: ScatterND.h:179
template<int N>
Scatter<N> YODA::Scatter< N >::clone ( ) const
inline

Make a copy on the stack.

Definition at line 107 of file ScatterND.h.

107  {
108  return Scatter<N>(*this);
109  }
template<int N>
Scatter<N>& YODA::Scatter< N >::combineWith ( const Scatter< N > &  other)
inline
Todo:
Better name?

Definition at line 207 of file ScatterND.h.

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

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

207  {
208  addPoints(other.points());
209  return *this;
210  }
Scatter< N > & addPoints(Points pts)
Insert a collection of new points.
Definition: ScatterND.h:193
template<int N>
Scatter<N>& YODA::Scatter< N >::combineWith ( const std::vector< Scatter< N > > &  others)
inline
Todo:
Better name?

Definition at line 213 of file ScatterND.h.

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

213  {
214  BOOST_FOREACH (const Scatter<N>& s, others) {
215  combineWith(s);
216  }
217  return *this;
218  }
Scatter< N > & combineWith(const Scatter< N > &other)
Definition: ScatterND.h:207
template<int N>
Scatter<N>* YODA::Scatter< N >::newclone ( ) const
inlinevirtual

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

Implements YODA::AnalysisObject.

Definition at line 112 of file ScatterND.h.

112  {
113  return new Scatter<N>(*this);
114  }
template<int N>
size_t YODA::Scatter< N >::numPoints ( ) const
inline

Number of points in the scatter.

Definition at line 144 of file ScatterND.h.

144  {
145  return _points.size();
146  }
template<int N>
Scatter<N>& YODA::Scatter< N >::operator= ( const Scatter< N > &  s)
inline

Assignment operator.

Definition at line 99 of file ScatterND.h.

References YODA::AnalysisObject::path(), YODA::AnalysisObject::setPath(), YODA::AnalysisObject::setTitle(), and YODA::AnalysisObject::title().

99  {
100  setPath(s.path());
101  setTitle(s.title());
102  _points = s._points;
103  return *this;
104  }
void setPath(const std::string &path)
Set the AO path.
void setTitle(const std::string &title)
Set the AO title.
template<int N>
Point<N>& YODA::Scatter< N >::point ( size_t  index)
inline

Get a reference to the point with index index.

Definition at line 162 of file ScatterND.h.

162  {
163  return _points.at(index);
164  }
template<int N>
const Point<N>& YODA::Scatter< N >::point ( size_t  index) const
inline

Get the point with index index (const version)

Definition at line 168 of file ScatterND.h.

168  {
169  return _points.at(index);
170  }
template<int N>
Points& YODA::Scatter< N >::points ( )
inline

Get the collection of points.

Definition at line 150 of file ScatterND.h.

Referenced by YODA::Scatter< N >::combineWith().

150  {
151  return _points;
152  }
template<int N>
const Points& YODA::Scatter< N >::points ( ) const
inline

Get the collection of points (const version)

Definition at line 156 of file ScatterND.h.

156  {
157  return _points;
158  }
template<int N>
void YODA::Scatter< N >::reset ( )
inlinevirtual

Clear all points.

Implements YODA::AnalysisObject.

Definition at line 123 of file ScatterND.h.

123  {
124  _points.clear();
125  }
template<int N>
void YODA::Scatter< N >::scale ( const NdVal scales)
inline

Scaling.

Definition at line 128 of file ScatterND.h.

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

128  {
129  BOOST_FOREACH (Point<N>& p, _points) {
130  p.scale(scales);
131  }
132  }

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