yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis  1.7.2
YODA::Scatter< N > Class Template Referenceabstract

Abstract base class for all Scatter*Ds. More...

#include <Scatter.h>

Inheritance diagram for YODA::Scatter< N >:
YODA::AnalysisObject 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
 
typedef std::shared_ptr< ScatterPtr
 
- 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

virtual Scatternewclone () const =0
 Make a copy on the heap, via 'new'. More...
 
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...
 
std::vector< std::string > annotations () const
 
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...
 
void setAnnotation (const std::string &name, const std::string &value)
 Add or set a string-valued annotation by name. More...
 
void setAnnotation (const std::string &name, double value)
 Add or set a double-valued annotation by name. More...
 
void setAnnotation (const std::string &name, float value)
 Add or set a float-valued annotation by name. More...
 
void setAnnotation (const std::string &name, long double value)
 Add or set a long-double-valued annotation by name. More...
 
template<typename T >
void setAnnotation (const std::string &name, const T &value)
 Add or set an annotation by name (templated for remaining types) 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
 Get the AO title. More...
 
void setTitle (const std::string &title)
 Set the AO title. More...
 
const std::string path () const
 Get the AO path. More...
 
void setPath (const std::string &path)
 
const std::string name () const
 
virtual std::string type () const
 Get name of the analysis object type. More...
 
virtual size_t dim () const =0
 Get the dimension of the analysis object type. More...
 

Detailed Description

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

Abstract base class for all Scatter*Ds.

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

Definition at line 15 of file Scatter.h.

Member Typedef Documentation

◆ NdVal

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

Definition at line 28 of file ScatterND.h.

◆ NdValPair

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

Definition at line 29 of file ScatterND.h.

◆ Points

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

Definition at line 30 of file ScatterND.h.

◆ Ptr

template<int N>
typedef std::shared_ptr<Scatter> YODA::Scatter< N >::Ptr

Definition at line 31 of file ScatterND.h.

Constructor & Destructor Documentation

◆ Scatter() [1/5]

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

Empty constructor.

Definition at line 38 of file ScatterND.h.

39  : AnalysisObject("Scatter", path, title)
40  { }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.
const std::string title() const
Get the AO title.

◆ Scatter() [2/5]

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 44 of file ScatterND.h.

46  : AnalysisObject("Scatter", path, title),
47  _points(points)
48  { }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.
const std::string title() const
Get the AO title.
Points & points()
Get the collection of points.
Definition: ScatterND.h:150

◆ Scatter() [3/5]

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 52 of file ScatterND.h.

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

54  : AnalysisObject("Scatter", path, title)
55  {
56  for (size_t i = 0; i < positions.size(); ++i) {
57  addPoint(Point<N>(positions[i]));
58  }
59  }
Scatter< N > & addPoint(const Point< N > &pt)
Insert a new point.
Definition: ScatterND.h:179
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.
const std::string title() const
Get the AO title.

◆ Scatter() [4/5]

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 63 of file ScatterND.h.

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

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

◆ Scatter() [5/5]

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 94 of file ScatterND.h.

95  : AnalysisObject("Scatter", (path.size() == 0) ? s.path() : path, s, s.title()),
96  _points(s._points)
97  { }
AnalysisObject()
Default constructor.
const std::string path() const
Get the AO path.

Member Function Documentation

◆ addPoint() [1/2]

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  }

◆ addPoint() [2/2]

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  }

◆ addPoints()

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  for (const Point<N>& pt : pts) addPoint(pt);
195  return *this;
196  }
Scatter< N > & addPoint(const Point< N > &pt)
Insert a new point.
Definition: ScatterND.h:179

◆ clone()

template<int N>
Scatter<N> YODA::Scatter< N >::clone ( ) const
inline

Make a copy on the stack.

Definition at line 109 of file ScatterND.h.

109  {
110  return Scatter<N>(*this);
111  }

◆ combineWith() [1/2]

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

Definition at line 205 of file ScatterND.h.

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

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

205  {
206  addPoints(other.points());
207  return *this;
208  }
Scatter< N > & addPoints(Points pts)
Insert a collection of new points.
Definition: ScatterND.h:193

◆ combineWith() [2/2]

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

Definition at line 211 of file ScatterND.h.

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

211  {
212  for (const Scatter<N>& s : others) combineWith(s);
213  return *this;
214  }
Scatter< N > & combineWith(const Scatter< N > &other)
Definition: ScatterND.h:205

◆ newclone() [1/2]

template<int N>
virtual Scatter* YODA::Scatter< N >::newclone ( ) const
pure virtual

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

Implements YODA::AnalysisObject.

◆ newclone() [2/2]

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 114 of file ScatterND.h.

114  {
115  return new Scatter<N>(*this);
116  }

◆ numPoints()

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  }

◆ operator=()

template<int N>
Scatter<N>& YODA::Scatter< N >::operator= ( const Scatter< N > &  s)
inline

Assignment operator.

Definition at line 101 of file ScatterND.h.

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

101  {
102  setPath(s.path());
103  setTitle(s.title());
104  _points = s._points;
105  return *this;
106  }
void setPath(const std::string &path)
void setTitle(const std::string &title)
Set the AO title.

◆ point() [1/2]

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  }

◆ point() [2/2]

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  }

◆ points() [1/2]

template<int N>
Points& YODA::Scatter< N >::points ( )
inline

Get the collection of points.

Definition at line 150 of file ScatterND.h.

150  {
151  return _points;
152  }

◆ points() [2/2]

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  }

◆ reset()

template<int N>
void YODA::Scatter< N >::reset ( )
inlinevirtual

Clear all points.

Implements YODA::AnalysisObject.

Definition at line 125 of file ScatterND.h.

125  {
126  _points.clear();
127  }

◆ scale()

template<int N>
void YODA::Scatter< N >::scale ( const NdVal scales)
inline

Scaling.

Definition at line 130 of file ScatterND.h.

130  {
131  for (Point<N>& p : _points) p.scale(scales);
132  }

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